Message ID | 20190923022449.10952-6-hpeter+linux_kernel@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add Fintek F81534A series usb-to-serial driver | expand |
On Mon, Sep 23, 2019 at 10:24:47AM +0800, Ji-Ze Hong (Peter Hong) wrote: > The Fintek F81532A/534A/535/536 is USB-to-2/4/8/12 serial ports device > and the serial ports are default disabled. Each port contains max 3 pins > GPIO and the 3 pins are default pull high with input mode. > > When the serial port had activated (running probe()), we'll transform the > 3 pins from GPIO function publicly to control Tranceiver privately use. I'm not sure I understand what you're saying here. > We'll default set to 0/0/1 for control transceiver to RS232 mode. > > Otherwise, If the serial port is not active, the 3 pins is in GPIO mode > and controlled by global GPIO device with VID/PID: 2c42/16f8. Does this mean that you can control the three GPIOs either through the serial device or through the gpio-control device (which are two separate USB devices)? > Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com> > --- > drivers/usb/serial/f81232.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c > index 36a17aedc2ae..01cb5a5ea1d2 100644 > --- a/drivers/usb/serial/f81232.c > +++ b/drivers/usb/serial/f81232.c > @@ -96,6 +96,15 @@ MODULE_DEVICE_TABLE(usb, all_serial_id_table); > #define F81534A_TRIGGER_MULTPILE_4X BIT(3) > #define F81534A_FIFO_128BYTE (BIT(1) | BIT(0)) > > +/* Serial port self GPIO control, 2bytes [control&output data][input data] */ > +#define F81534A_GPIO_REG 0x10e > +#define F81534A_GPIO_MODE2_DIR BIT(6) /* 1: input, 0: output */ > +#define F81534A_GPIO_MODE1_DIR BIT(5) > +#define F81534A_GPIO_MODE0_DIR BIT(4) > +#define F81534A_GPIO_MODE2_OUTPUT BIT(2) > +#define F81534A_GPIO_MODE1_OUTPUT BIT(1) > +#define F81534A_GPIO_MODE0_OUTPUT BIT(0) > + > struct f81232_private { > struct mutex lock; > u8 modem_control; > @@ -866,6 +875,14 @@ static int f81232_port_probe(struct usb_serial_port *port) > > static int f81534a_port_probe(struct usb_serial_port *port) > { > + int status; > + > + /* tri-state with pull-high, default RS232 Mode */ > + status = f81232_set_register(port, F81534A_GPIO_REG, > + F81534A_GPIO_MODE2_DIR); > + if (status) > + return status; Ok, so you reset the tranceiver config on every probe. Are the three GPIOs always connected to one particular tranceiver, or are they truly general purpose? In the latter case, it doesn't seem like a good idea to drive pins 0 and 1 low here as you have know idea what they're used for. > + > return f81232_port_probe(port); > } Johan
Hi Johan, Johan Hovold 於 2019/10/23 下午 07:53 寫道: > On Mon, Sep 23, 2019 at 10:24:47AM +0800, Ji-Ze Hong (Peter Hong) wrote: >> The Fintek F81532A/534A/535/536 is USB-to-2/4/8/12 serial ports device >> and the serial ports are default disabled. Each port contains max 3 pins >> GPIO and the 3 pins are default pull high with input mode. >> >> When the serial port had activated (running probe()), we'll transform the >> 3 pins from GPIO function publicly to control Tranceiver privately use. > > I'm not sure I understand what you're saying here. > >> We'll default set to 0/0/1 for control transceiver to RS232 mode. >> >> Otherwise, If the serial port is not active, the 3 pins is in GPIO mode >> and controlled by global GPIO device with VID/PID: 2c42/16f8. > > Does this mean that you can control the three GPIOs either through the > serial device or through the gpio-control device (which are two separate > USB devices)? > Yes, when 1 F81534A connect to Host, it'll report device as following. virtual HUB GPIO Device. serial port 1 ... serial port n The link are F81534A pin-out: https://imgur.com/a/AZHqQ1N So we can control F81534A series all GPIO pins via GPIO Device. Serial ports are also control MODE0_x, MODE1_x, MODE2_x (e.g. UART1 MODE0_1, MODE1_1, MODE2_1), but when Serial ports is h/w disabled (DTR pull low), the mode pin will change to GPIO pin. > Ok, so you reset the tranceiver config on every probe. > > Are the three GPIOs always connected to one particular tranceiver, or > are they truly general purpose? > > In the latter case, it doesn't seem like a good idea to drive pins 0 > and 1 low here as you have know idea what they're used for. If we want to change the mode pin to GPIO pin, it need do h/w disable. It the serial ports are activated, the 3 pin will be mode pin and set default 0/0/1 to RS232 mode due to this driver not implement RS422/485 currently. Thanks
Hi Peter, Sorry about the late reply. Had a change to look into this again today. On Thu, Oct 24, 2019 at 04:52:01PM +0800, Ji-Ze Hong (Peter Hong) wrote: > Hi Johan, > > Johan Hovold 於 2019/10/23 下午 07:53 寫道: > > On Mon, Sep 23, 2019 at 10:24:47AM +0800, Ji-Ze Hong (Peter Hong) wrote: > >> The Fintek F81532A/534A/535/536 is USB-to-2/4/8/12 serial ports device > >> and the serial ports are default disabled. Each port contains max 3 pins > >> GPIO and the 3 pins are default pull high with input mode. > >> > >> When the serial port had activated (running probe()), we'll transform the > >> 3 pins from GPIO function publicly to control Tranceiver privately use. > > > > I'm not sure I understand what you're saying here. > > > >> We'll default set to 0/0/1 for control transceiver to RS232 mode. > >> > >> Otherwise, If the serial port is not active, the 3 pins is in GPIO mode > >> and controlled by global GPIO device with VID/PID: 2c42/16f8. > > > > Does this mean that you can control the three GPIOs either through the > > serial device or through the gpio-control device (which are two separate > > USB devices)? > > Yes, when 1 F81534A connect to Host, it'll report device as following. > virtual HUB > GPIO Device. > serial port 1 > ... > serial port n Could you post lsusb -v output for this with a couple of UARTs enabled? > The link are F81534A pin-out: > https://imgur.com/a/AZHqQ1N Do you have a datasheet for the device? I think I'm starting to get an idea of how this work, but I really don't like having to spend this much time on detective work just to understand how the hw works. > So we can control F81534A series all GPIO pins via GPIO Device. > Serial ports are also control MODE0_x, MODE1_x, MODE2_x > (e.g. UART1 MODE0_1, MODE1_1, MODE2_1), but when Serial ports > is h/w disabled (DTR pull low), the mode pin will change to GPIO pin. So you tie a ports DTR pin, even though it's normally an output, and use that at boot to determine whether the UART should be enabled or not? And the GPIO device can only control a pin if the corresponding port is disabled? Can you read back the enable state of each port? > > Ok, so you reset the tranceiver config on every probe. > > > > Are the three GPIOs always connected to one particular tranceiver, or > > are they truly general purpose? > > > > In the latter case, it doesn't seem like a good idea to drive pins 0 > > and 1 low here as you have know idea what they're used for. > > If we want to change the mode pin to GPIO pin, it need do h/w disable. > It the serial ports are activated, the 3 pin will be mode pin and set > default 0/0/1 to RS232 mode due to this driver not implement RS422/485 > currently. What about devices using a different tranceiver? Should the state of the mode pins ultimately be tied to VID/PID (can your customers change VID/PID)? Johan
Hi Johan, Johan Hovold 於 2020/1/8 下午 10:35 寫道: >> Yes, when 1 F81534A connect to Host, it'll report device as following. >> virtual HUB >> GPIO Device. >> serial port 1 >> ... >> serial port n > > Could you post lsusb -v output for this with a couple of UARTs enabled? The following lsusb log is F81536 informations 2c42:1608 => HUB 2c42:16f8 => GPIO device 2c42:163x => UART (need driver enable) *before insmod driver Bus 002 Device 003: ID 05e3:0620 Genesys Logic, Inc. Bus 002 Device 002: ID 05e3:0620 Genesys Logic, Inc. Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 007: ID 0603:00f2 Novatek Microelectronics Corp. Keyboard (Labtec Ultra Flat Keyboard) Bus 001 Device 005: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse Bus 001 Device 044: ID 2c42:16f8 Bus 001 Device 043: ID 2c42:1608 Bus 001 Device 003: ID 05e3:0610 Genesys Logic, Inc. 4-port hub Bus 001 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub *after insmod driver and wait for complete Bus 002 Device 003: ID 05e3:0620 Genesys Logic, Inc. Bus 002 Device 002: ID 05e3:0620 Genesys Logic, Inc. Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 007: ID 0603:00f2 Novatek Microelectronics Corp. Keyboard (Labtec Ultra Flat Keyboard) Bus 001 Device 005: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse Bus 001 Device 052: ID 2c42:1636 Bus 001 Device 051: ID 2c42:1636 Bus 001 Device 050: ID 2c42:1636 Bus 001 Device 049: ID 2c42:1636 Bus 001 Device 048: ID 2c42:1636 Bus 001 Device 047: ID 2c42:1636 Bus 001 Device 046: ID 2c42:1636 Bus 001 Device 045: ID 2c42:1636 Bus 001 Device 056: ID 2c42:1636 Bus 001 Device 055: ID 2c42:1636 Bus 001 Device 054: ID 2c42:1636 Bus 001 Device 053: ID 2c42:1636 Bus 001 Device 044: ID 2c42:16f8 Bus 001 Device 043: ID 2c42:1608 Bus 001 Device 003: ID 05e3:0610 Genesys Logic, Inc. 4-port hub Bus 001 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub >> The link are F81534A pin-out: >> https://imgur.com/a/AZHqQ1N > > Do you have a datasheet for the device? > > I think I'm starting to get an idea of how this work, but I really don't > like having to spend this much time on detective work just to understand > how the hw works. The following link is F81536 spec: https://drive.google.com/drive/folders/1oA8DvpevFXoTLCDfPZHzaBWKr32ch5xc?usp=sharing >> So we can control F81534A series all GPIO pins via GPIO Device. >> Serial ports are also control MODE0_x, MODE1_x, MODE2_x >> (e.g. UART1 MODE0_1, MODE1_1, MODE2_1), but when Serial ports >> is h/w disabled (DTR pull low), the mode pin will change to GPIO pin. > > So you tie a ports DTR pin, even though it's normally an output, and use > that at boot to determine whether the UART should be enabled or not? > > And the GPIO device can only control a pin if the corresponding port is > disabled? > > Can you read back the enable state of each port? DTR pin of the F81534A series are strap pin on power on, when IC detect it pulled to low, the UART device can't enable and DTR change to input mode. I can read the UART enable state from GPIO Device, so I can do when the GPIO is associated with UART enabled, change it as output only otherwise can be set to input/output. Is this OK ?? > What about devices using a different tranceiver? Should the state of the > mode pins ultimately be tied to VID/PID (can your customers change > VID/PID)? > Our device VID/PID is changeable, but we assume don't change it.
On Thu, Jan 09, 2020 at 10:37:09AM +0800, Ji-Ze Hong (Peter Hong) wrote: > Hi Johan, > > Johan Hovold 於 2020/1/8 下午 10:35 寫道: > >> Yes, when 1 F81534A connect to Host, it'll report device as following. > >> virtual HUB > >> GPIO Device. > >> serial port 1 > >> ... > >> serial port n > > > > Could you post lsusb -v output for this with a couple of UARTs enabled? > > The following lsusb log is F81536 informations > 2c42:1608 => HUB > 2c42:16f8 => GPIO device > 2c42:163x => UART (need driver enable) > *after insmod driver and wait for complete > Bus 001 Device 053: ID 2c42:1636 > Bus 001 Device 044: ID 2c42:16f8 > Bus 001 Device 043: ID 2c42:1608 Can you post verbose ("lsusb -v") output for the three device types for completeness? > >> The link are F81534A pin-out: > >> https://imgur.com/a/AZHqQ1N > > > > Do you have a datasheet for the device? > > > > I think I'm starting to get an idea of how this work, but I really don't > > like having to spend this much time on detective work just to understand > > how the hw works. > > The following link is F81536 spec: > https://drive.google.com/drive/folders/1oA8DvpevFXoTLCDfPZHzaBWKr32ch5xc?usp=sharing Thanks! > >> So we can control F81534A series all GPIO pins via GPIO Device. > >> Serial ports are also control MODE0_x, MODE1_x, MODE2_x > >> (e.g. UART1 MODE0_1, MODE1_1, MODE2_1), but when Serial ports > >> is h/w disabled (DTR pull low), the mode pin will change to GPIO pin. > > > > So you tie a ports DTR pin, even though it's normally an output, and use > > that at boot to determine whether the UART should be enabled or not? > > > > And the GPIO device can only control a pin if the corresponding port is > > disabled? > > > > Can you read back the enable state of each port? > > DTR pin of the F81534A series are strap pin on power on, when IC detect > it pulled to low, the UART device can't enable and DTR change to input > mode. Can you read back the state of the DTR pin when pulled low? So that you can determine which UARTs have been disabled in hardware? > I can read the UART enable state from GPIO Device, so I can do when the > GPIO is associated with UART enabled, change it as output only otherwise > can be set to input/output. Is this OK ?? I'm leaning more towards not exporting this as a gpio device at all. It's clear from the datasheet (and your implementation) that these pins are supposed to be used with your own tranceivers. You can start with only supporting RS232, and then we can discuss an interface for switching modes later. > > What about devices using a different tranceiver? Should the state of the > > mode pins ultimately be tied to VID/PID (can your customers change > > VID/PID)? > > > > Our device VID/PID is changeable, but we assume don't change it. Ok, then I guess we must assume that the MODE pins are only connected to your tranceivers and hardcoding the various configurations is fine. Johan
Hi Johan, Johan Hovold 於 2020/1/13 下午 11:17 寫道: > On Thu, Jan 09, 2020 at 10:37:09AM +0800, Ji-Ze Hong (Peter Hong) wrote: >> Bus 001 Device 053: ID 2c42:1636 >> Bus 001 Device 044: ID 2c42:16f8 >> Bus 001 Device 043: ID 2c42:1608 > > Can you post verbose ("lsusb -v") output for the three device types for > completeness? Bus 001 Device 007: ID 2c42:1608 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 9 Hub bDeviceSubClass 0 Unused bDeviceProtocol 1 Single TT bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1608 bcdDevice 80.ff iManufacturer 0 iProduct 1 FINTEK_USB2.0 HUB iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 25 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 500mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 9 Hub bInterfaceSubClass 0 Unused bInterfaceProtocol 0 Full speed (or root) hub iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0002 1x 2 bytes bInterval 12 Hub Descriptor: bLength 10 bDescriptorType 41 nNbrPorts 13 wHubCharacteristic 0x00e9 Per-port power switching Per-port overcurrent protection TT think time 32 FS bits Port indicators bPwrOn2PwrGood 8 * 2 milli seconds bHubContrCurrent 100 milli Ampere DeviceRemovable 0x03 0xc0 PortPwrCtrlMask 0xff 0xa2 Hub Port Status: Port 1: 0000.0503 highspeed power enable connect Port 2: 0000.0503 highspeed power enable connect Port 3: 0000.0503 highspeed power enable connect Port 4: 0000.0503 highspeed power enable connect Port 5: 0000.0503 highspeed power enable connect Port 6: 0000.0503 highspeed power enable connect Port 7: 0000.0503 highspeed power enable connect Port 8: 0000.0503 highspeed power enable connect Port 9: 0000.0503 highspeed power enable connect Port 10: 0000.0503 highspeed power enable connect Port 11: 0000.0503 highspeed power enable connect Port 12: 0000.0503 highspeed power enable connect Port 13: 0000.0503 highspeed power enable connect Device Qualifier (for other device speed): bLength 10 bDescriptorType 6 bcdUSB 2.00 bDeviceClass 9 Hub bDeviceSubClass 0 Unused bDeviceProtocol 0 Full speed (or root) hub bMaxPacketSize0 64 bNumConfigurations 1 Device Status: 0x0001 Self Powered Bus 001 Device 008: ID 2c42:16f8 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x16f8 bcdDevice 80.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 88635600168801 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 18 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 0 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Device Status: 0x0000 (Bus Powered) Bus 001 Device 016: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 88.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 015: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 87.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 014: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 86.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 013: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 85.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 012: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 84.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 011: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 83.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 010: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 82.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 009: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 81.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 020: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 8c.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 019: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 8b.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 018: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 8a.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Bus 001 Device 017: ID 2c42:1636 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2c42 idProduct 0x1636 bcdDevice 89.00 iManufacturer 1 FINTEK iProduct 2 USB TO UART BRIDGE iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 39 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 0 (Defined at Interface level) bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 10 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0080 1x 128 bytes bInterval 0 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled >>> Can you read back the enable state of each port? >> >> DTR pin of the F81534A series are strap pin on power on, when IC detect >> it pulled to low, the UART device can't enable and DTR change to input >> mode. > > Can you read back the state of the DTR pin when pulled low? So that you > can determine which UARTs have been disabled in hardware? If the DTR pin pulled low, the UART device always can't be enabled. We can read the port en/disabled infomation in GPIO device only. > > I'm leaning more towards not exporting this as a gpio device at all. > It's clear from the datasheet (and your implementation) that these pins > are supposed to be used with your own tranceivers. You can start with > only supporting RS232, and then we can discuss an interface for > switching modes later. OK, I'll send patch v3 only with UART & device enable function after clarify all issues. >>> >> >> Our device VID/PID is changeable, but we assume don't change it. > > Ok, then I guess we must assume that the MODE pins are only connected to > your tranceivers and hardcoding the various configurations is fine. Agree
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 36a17aedc2ae..01cb5a5ea1d2 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -96,6 +96,15 @@ MODULE_DEVICE_TABLE(usb, all_serial_id_table); #define F81534A_TRIGGER_MULTPILE_4X BIT(3) #define F81534A_FIFO_128BYTE (BIT(1) | BIT(0)) +/* Serial port self GPIO control, 2bytes [control&output data][input data] */ +#define F81534A_GPIO_REG 0x10e +#define F81534A_GPIO_MODE2_DIR BIT(6) /* 1: input, 0: output */ +#define F81534A_GPIO_MODE1_DIR BIT(5) +#define F81534A_GPIO_MODE0_DIR BIT(4) +#define F81534A_GPIO_MODE2_OUTPUT BIT(2) +#define F81534A_GPIO_MODE1_OUTPUT BIT(1) +#define F81534A_GPIO_MODE0_OUTPUT BIT(0) + struct f81232_private { struct mutex lock; u8 modem_control; @@ -866,6 +875,14 @@ static int f81232_port_probe(struct usb_serial_port *port) static int f81534a_port_probe(struct usb_serial_port *port) { + int status; + + /* tri-state with pull-high, default RS232 Mode */ + status = f81232_set_register(port, F81534A_GPIO_REG, + F81534A_GPIO_MODE2_DIR); + if (status) + return status; + return f81232_port_probe(port); }
The Fintek F81532A/534A/535/536 is USB-to-2/4/8/12 serial ports device and the serial ports are default disabled. Each port contains max 3 pins GPIO and the 3 pins are default pull high with input mode. When the serial port had activated (running probe()), we'll transform the 3 pins from GPIO function publicly to control Tranceiver privately use. We'll default set to 0/0/1 for control transceiver to RS232 mode. Otherwise, If the serial port is not active, the 3 pins is in GPIO mode and controlled by global GPIO device with VID/PID: 2c42/16f8. Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com> --- drivers/usb/serial/f81232.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)