diff --git a/target/linux/generic/files/drivers/tty/serial/xr14xx_usb/xr_usb_serial_common.c b/target/linux/generic/files/drivers/tty/serial/xr14xx_usb/xr_usb_serial_common.c index f5164dff2364ea..31f4afdb30914f 100644 --- a/target/linux/generic/files/drivers/tty/serial/xr14xx_usb/xr_usb_serial_common.c +++ b/target/linux/generic/files/drivers/tty/serial/xr14xx_usb/xr_usb_serial_common.c @@ -120,6 +120,22 @@ static int xr_usb_serial_alloc_minor(struct xr_usb_serial *xr_usb_serial) return minor; } +/* + * Try to bind minor number associate it with 'xr_usb_serial'. + */ +static int xr_usb_serial_set_minor(struct xr_usb_serial *xr_usb_serial, int minor) +{ + mutex_lock(&xr_usb_serial_table_lock); + if (!xr_usb_serial_table[minor]) { + xr_usb_serial_table[minor] = xr_usb_serial; + mutex_unlock(&xr_usb_serial_table_lock); + return minor; + } + mutex_unlock(&xr_usb_serial_table_lock); + + return XR_USB_SERIAL_TTY_MINORS; +} + /* Release the minor number associated with 'xr_usb_serial'. */ static void xr_usb_serial_release_minor(struct xr_usb_serial *xr_usb_serial) { @@ -1532,7 +1548,17 @@ static int xr_usb_serial_probe(struct usb_interface *intf, goto alloc_fail; } - minor = xr_usb_serial_alloc_minor(xr_usb_serial); + if (intf->dev.of_node) { + if (of_property_read_s32(intf->dev.of_node, "xr_tty_minor", &minor)) { + minor = xr_usb_serial_alloc_minor(xr_usb_serial); + } else { + dev_info(&intf->dev, "of_node:%pOF got minor:%d\n", intf->dev.of_node, minor); + minor = xr_usb_serial_set_minor(xr_usb_serial, minor); + } + } else { + minor = xr_usb_serial_alloc_minor(xr_usb_serial); + } + if (minor == XR_USB_SERIAL_TTY_MINORS) { dev_err(&intf->dev, "no more free xr_usb_serial devices\n"); kfree(xr_usb_serial); @@ -1712,12 +1738,12 @@ static int xr_usb_serial_probe(struct usb_interface *intf, dev_info(&intf->dev, "ttyXR_USB_SERIAL%d: USB XR_USB_SERIAL device\n", minor); xr_usb_serial->rs485mode = 0; - if (usb_dev->dev.of_node) { - if (of_property_read_bool(usb_dev->dev.of_node, "xr_485_mode")) { + if (intf->dev.of_node) { + if (of_property_read_bool(intf->dev.of_node, "xr_485_mode")) { xr_usb_serial->rs485mode = 1; - dev_info(&usb_dev->dev, "of_node:%pOF using xr_485_mode\n", usb_dev->dev.of_node); + dev_info(&intf->dev, "of_node:%pOF using xr_485_mode\n", intf->dev.of_node); } else { - dev_info(&usb_dev->dev, "of_node:%pOF has no xr_485_mode\n", usb_dev->dev.of_node); + dev_info(&intf->dev, "of_node:%pOF has no xr_485_mode\n", intf->dev.of_node); } } else { dev_info(&usb_dev->dev, "no of_mode found\n"); diff --git a/target/linux/sunxi/base-files/etc/hotplug.d/tty/90-tlink b/target/linux/sunxi/base-files/etc/hotplug.d/tty/90-tlink index a0af75da0c6c7a..ad65a995bd5370 100755 --- a/target/linux/sunxi/base-files/etc/hotplug.d/tty/90-tlink +++ b/target/linux/sunxi/base-files/etc/hotplug.d/tty/90-tlink @@ -30,52 +30,52 @@ tlink_m408_xr_usb() { tlink_m416_xr_usb() { case "$DEVICENAME" in ttyXRUSB0) - rm /dev/ttyS9 - ln -s /dev/$DEVICENAME /dev/ttyS9 + rm /dev/ttyS5 + ln -s /dev/$DEVICENAME /dev/ttyS5 ;; ttyXRUSB1) - rm /dev/ttyS10 - ln -s /dev/$DEVICENAME /dev/ttyS10 + rm /dev/ttyS6 + ln -s /dev/$DEVICENAME /dev/ttyS6 ;; ttyXRUSB2) - rm /dev/ttyS11 - ln -s /dev/$DEVICENAME /dev/ttyS11 + rm /dev/ttyS7 + ln -s /dev/$DEVICENAME /dev/ttyS7 ;; ttyXRUSB3) - rm /dev/ttyS12 - ln -s /dev/$DEVICENAME /dev/ttyS12 + rm /dev/ttyS8 + ln -s /dev/$DEVICENAME /dev/ttyS8 ;; ttyXRUSB4) rm /dev/ttyS13 - ln -s /dev/$DEVICENAME /dev/ttyS13 + ln -s /dev/$DEVICENAME /dev/ttyS9 ;; ttyXRUSB5) rm /dev/ttyS14 - ln -s /dev/$DEVICENAME /dev/ttyS14 + ln -s /dev/$DEVICENAME /dev/ttyS10 ;; ttyXRUSB6) rm /dev/ttyS15 - ln -s /dev/$DEVICENAME /dev/ttyS15 + ln -s /dev/$DEVICENAME /dev/ttyS11 ;; ttyXRUSB7) rm /dev/ttyS16 - ln -s /dev/$DEVICENAME /dev/ttyS16 + ln -s /dev/$DEVICENAME /dev/ttyS12 ;; ttyXRUSB8) rm /dev/ttyS5 - ln -s /dev/$DEVICENAME /dev/ttyS5 + ln -s /dev/$DEVICENAME /dev/ttyS13 ;; ttyXRUSB9) rm /dev/ttyS6 - ln -s /dev/$DEVICENAME /dev/ttyS6 + ln -s /dev/$DEVICENAME /dev/ttyS14 ;; ttyXRUSB10) rm /dev/ttyS7 - ln -s /dev/$DEVICENAME /dev/ttyS7 + ln -s /dev/$DEVICENAME /dev/ttyS15 ;; ttyXRUSB11) rm /dev/ttyS8 - ln -s /dev/$DEVICENAME /dev/ttyS8 + ln -s /dev/$DEVICENAME /dev/ttyS16 ;; esac } diff --git a/target/linux/sunxi/patches-5.15/891-ARM-dts-sun8i-kooiot-tlink-dly-t3v1.patch b/target/linux/sunxi/patches-5.15/891-ARM-dts-sun8i-kooiot-tlink-dly-t3v1.patch index 7d6595b8f9b2fc..3fcb7e71657ef6 100644 --- a/target/linux/sunxi/patches-5.15/891-ARM-dts-sun8i-kooiot-tlink-dly-t3v1.patch +++ b/target/linux/sunxi/patches-5.15/891-ARM-dts-sun8i-kooiot-tlink-dly-t3v1.patch @@ -220,7 +220,7 @@ + #address-cells = <1>; + #size-cells = <0>; + -+ xr22800: hub@1 { ++ xr22800: xr22800@1 { + compatible = "usb4e2,800"; + reg = <1>; + #address-cells = <1>; @@ -238,7 +238,7 @@ + #address-cells = <1>; + #size-cells = <0>; + -+ xr22804: hub@1 { ++ xr22804: xr22804@1 { + compatible = "usb4e2,804"; + reg = <1>; + #address-cells = <1>; @@ -248,21 +248,45 @@ + reg = <1>; + local-mac-address = [00 00 00 00 00 00]; + }; -+ uart@2 { ++ xr_uart1: xr-uart1@2 { + reg = <2>; -+ xr_485_mode; ++ #address-cells = <2>; ++ #size-cells = <0>; ++ xr-uart1-interface@0 { /* interface 0 of configuration 1 */ ++ reg = <0 1>; ++ xr_485_mode; ++ xr_tty_minor=<0>; ++ }; + }; -+ uart@3 { ++ xr_uart2: xr-uart2@3 { + reg = <3>; -+ xr_485_mode; ++ #address-cells = <2>; ++ #size-cells = <0>; ++ xr-uart2-interface@0 { /* interface 0 of configuration 1 */ ++ reg = <0 1>; ++ xr_485_mode; ++ xr_tty_minor=<1>; ++ }; + }; -+ uart@4 { ++ xr_uart3: xr-uart3@4 { + reg = <4>; -+ xr_485_mode; ++ #address-cells = <2>; ++ #size-cells = <0>; ++ xr-uart3-interface@0 { /* interface 0 of configuration 1 */ ++ reg = <0 1>; ++ xr_485_mode; ++ xr_tty_minor=<2>; ++ }; + }; -+ uart@5 { ++ xr_uart4: xr-uart4@5 { + reg = <5>; -+ xr_485_mode; ++ #address-cells = <2>; ++ #size-cells = <0>; ++ xr-uart4-interface@0 { /* interface 0 of configuration 1 */ ++ reg = <0 1>; ++ xr_485_mode; ++ xr_tty_minor=<3>; ++ }; + }; + }; +}; diff --git a/target/linux/sunxi/patches-5.15/893-ARM-dts-sun8i-kooiot-tlink-m4xx.patch b/target/linux/sunxi/patches-5.15/893-ARM-dts-sun8i-kooiot-tlink-m4xx.patch index e09704dbbf3849..620d4895fbbd29 100644 --- a/target/linux/sunxi/patches-5.15/893-ARM-dts-sun8i-kooiot-tlink-m4xx.patch +++ b/target/linux/sunxi/patches-5.15/893-ARM-dts-sun8i-kooiot-tlink-m4xx.patch @@ -70,7 +70,7 @@ +}; --- /dev/null +++ b/arch/arm/boot/dts/sun8i-t3-tlink-m416.dts -@@ -0,0 +1,45 @@ +@@ -0,0 +1,103 @@ +/* + * Copyright (C) 2021 Dirk Chang + * @@ -97,22 +97,80 @@ + #address-cells = <1>; + #size-cells = <0>; + -+ hub2514@1 { ++ xr_uart1414: xr2514@1 { + compatible = "usb424,2514"; + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + -+ uart1414@1 { ++ xr_uart5: xr-uart5@1 { + compatible = "usb4e2,1414"; + reg = <1>; -+ xr_485_mode; ++ #address-cells = <2>; ++ #size-cells = <0>; ++ ++ xr-uart5-intf-0@0,1 { /* interface 0 of configuration 1 */ ++ compatible = "usb4e2,1414.config1.0"; ++ reg = <0 1>; ++ xr_485_mode; ++ xr_tty_minor=<4>; ++ }; ++ ++ xr-uart5-intf-2@2,1 { /* interface 2 of configuration 1 */ ++ compatible = "usb4e2,1414.config1.2"; ++ reg = <2 1>; ++ xr_485_mode; ++ xr_tty_minor=<5>; ++ }; ++ ++ xr-uart5-intf-4@4,1 { /* interface 4 of configuration 1 */ ++ compatible = "usb4e2,1414.config1.4"; ++ reg = <4 1>; ++ xr_485_mode; ++ xr_tty_minor=<6>; ++ }; ++ ++ xr-uart5-intf-6@6,1 { /* interface 6 of configuration 1 */ ++ compatible = "usb4e2,1414.config1.6"; ++ reg = <6 1>; ++ xr_485_mode; ++ xr_tty_minor=<7>; ++ }; + }; + -+ uart1414@2 { ++ xr_uart6: xr-uart6@2 { + compatible = "usb4e2,1414"; + reg = <2>; -+ xr_485_mode; ++ #address-cells = <2>; ++ #size-cells = <0>; ++ ++ xr-uart6-intf-0@0,1 { /* interface 0 of configuration 1 */ ++ compatible = "usb4e2,1414.config1.0"; ++ reg = <0 1>; ++ xr_485_mode; ++ xr_tty_minor=<8>; ++ }; ++ ++ xr-uart6-intf-2@2,1 { /* interface 2 of configuration 1 */ ++ compatible = "usb4e2,1414.config1.2"; ++ reg = <2 1>; ++ xr_485_mode; ++ xr_tty_minor=<9>; ++ }; ++ ++ xr-uart6-intf-4@4,1 { /* interface 4 of configuration 1 */ ++ compatible = "usb4e2,1414.config1.4"; ++ reg = <4 1>; ++ xr_485_mode; ++ xr_tty_minor=<10>; ++ }; ++ ++ xr-uart6-intf-6@6,1 { /* interface 6 of configuration 1 */ ++ compatible = "usb4e2,1414.config1.6"; ++ reg = <6 1>; ++ xr_485_mode; ++ xr_tty_minor=<11>; ++ }; + }; + }; +};