Skip to contentSkip to conversation

Revert "USB: serial: ch341: add new Product ID for CH341A"

PATCH Superseded Frank Zago 3 participants 5 messages Apr 20, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Frank Zago

author
#0 lore raw

PATCH 1/2 Revert "USB: serial: ch341: add new Product ID for CH341A"

From: frank zago <[email protected]>

The 0x5512 USB PID is for the I2C/GPIO/SPI interfaces. UART is still present but only the TX and RX pins are available; DTS, DTR, ... are used for other things. Remove the PID, and let a I2C driver bind to it.

Existing CH341 boards usually have physical jumpers to switch between the 3 modes.

This reverts commit 46ee4abb10a07bd8f8ce910ee6b4ae6a947d7f63.

---
 drivers/usb/serial/ch341.c | 1 -
 1 file changed, 1 deletion(-)
drivers/usb/serial/ch341.c +0 -1
index 2db917eab799..235adc77ee0e 100644
@@ -81,7 +81,6 @@
 #define CH341_QUIRK_SIMULATE_BREAK	BIT(1)
 
 static const struct usb_device_id id_table[] = {
-	{ USB_DEVICE(0x1a86, 0x5512) },
 	{ USB_DEVICE(0x1a86, 0x5523) },
 	{ USB_DEVICE(0x1a86, 0x7522) },
 	{ USB_DEVICE(0x1a86, 0x7523) },
Signature · 1 line
2.27.0
author
#1 lore raw

PATCH 2/2 USB: misc: Add driver for the WCH CH341 in I2C/GPIO mode

From: frank zago <[email protected]>

The CH341 is a multifunction chip, presenting 3 different USB PID. One of these functions is for I2C/SPI/GPIO. This new driver manages I2C and GPIO. A future update will manage the SPI part as well.

The I2C interface can run at 4 different speeds. This driver currently only offer 100MHz. Tested with a variety of I2C sensors, and the IIO subsystem.

The GPIO interface offers 8 GPIOs. 6 are read/write, and 2 are rea-only. However the SPI interface will use 6 of them, leaving 2 available GPIOs.

---
 MAINTAINERS                         |   6 +
 drivers/usb/misc/Kconfig            |  18 ++
 drivers/usb/misc/Makefile           |   1 +
 drivers/usb/misc/ch341/Kconfig      |   0
 drivers/usb/misc/ch341/Makefile     |   3 +
 drivers/usb/misc/ch341/ch341-core.c |  87 +++++++++
 drivers/usb/misc/ch341/ch341-gpio.c | 249 ++++++++++++++++++++++++++
 drivers/usb/misc/ch341/ch341-i2c.c  | 267 ++++++++++++++++++++++++++++
 drivers/usb/misc/ch341/ch341.h      |  50 ++++++
 9 files changed, 681 insertions(+)
 create mode 100644 drivers/usb/misc/ch341/Kconfig
 create mode 100644 drivers/usb/misc/ch341/Makefile
 create mode 100644 drivers/usb/misc/ch341/ch341-core.c
 create mode 100644 drivers/usb/misc/ch341/ch341-gpio.c
 create mode 100644 drivers/usb/misc/ch341/ch341-i2c.c
 create mode 100644 drivers/usb/misc/ch341/ch341.h
MAINTAINERS +6 -0
index 95e6766718b0..17e3d03cf9bf 100644
@@ -19349,6 +19349,12 @@ M:	David Härdeman <[email protected]>
 S:	Maintained
 F:	drivers/media/rc/winbond-cir.c
 
+WINCHIPHEAD CH341 I2C/GPIO/SPI DRIVER
+M:	Frank Zago <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/usb/misc/ch341/
+
 WINSYSTEMS EBC-C384 WATCHDOG DRIVER
 M:	William Breathitt Gray <[email protected]>
 L:	[email protected]
drivers/usb/misc/Kconfig +18 -0
index 8f1144359012..2d4db92f0de4 100644
@@ -284,3 +284,21 @@ config BRCM_USB_PINMAP
 	  This option enables support for remapping some USB external
 	  signals, which are typically on dedicated pins on the chip,
 	  to any gpio.
+
+config USB_CH341_CORE
+	tristate "USB WinChipHead CH341 in I2C/SPI/GPIO mode"
+	depends on USB && GPIOLIB && I2C && SPI
+	help
+
+	  If you say yes to this option, support for the CH341 chips,
+	  running in I2C/SPI/GPIO mode will be included. Some versions
+	  of the chip do not support all the functionnalities but
+	  there is no way to differentiate them. For instance the
+	  CH341A and CH341B support everything while the CH341T can
+	  only do I2C.
+
+	  The serial mode is not supported by this driver. Use the
+	  CH341 USB serial driver.
+
+	  This driver can also be built as a module.  If so, the
+	  module will be called ch341-buses.
drivers/usb/misc/Makefile +1 -0
index 5f4e598573ab..95c0ca15b8c9 100644
@@ -32,3 +32,4 @@ obj-$(CONFIG_USB_CHAOSKEY)		+= chaoskey.o
 obj-$(CONFIG_USB_SISUSBVGA)		+= sisusbvga/
 obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
 obj-$(CONFIG_BRCM_USB_PINMAP)		+= brcmstb-usb-pinmap.o
+obj-$(CONFIG_USB_CH341_CORE)		+= ch341/
drivers/usb/misc/ch341/Kconfig new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
drivers/usb/misc/ch341/Makefile new file +3 -0
new file mode 100644
index 000000000000..7c6429e7a46e
@@ -0,0 +1,3 @@
+obj-$(CONFIG_USB_CH341_CORE) := ch341-buses.o
+
+ch341-buses-objs := ch341-core.o ch341-i2c.o ch341-gpio.o
drivers/usb/misc/ch341/ch341-core.c new file +87 -0

87 lines not on this page · raw message

drivers/usb/misc/ch341/ch341-gpio.c new file +249 -0

249 lines not on this page · raw message

drivers/usb/misc/ch341/ch341-i2c.c new file +267 -0

267 lines not on this page · raw message

drivers/usb/misc/ch341/ch341.h new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
2.27.0
#2 lore raw

Re: [PATCH 2/2] USB: misc: Add driver for the WCH CH341 in I2C/GPIO mode

Hi--

Quoted 6 lines · Frank Zago

From: frank zago <[email protected]>

Don't think you need both of those.

Quoted 35 lines
---
 MAINTAINERS                         |   6 +
 drivers/usb/misc/Kconfig            |  18 ++
 drivers/usb/misc/Makefile           |   1 +
 drivers/usb/misc/ch341/Kconfig      |   0
 drivers/usb/misc/ch341/Makefile     |   3 +
 drivers/usb/misc/ch341/ch341-core.c |  87 +++++++++
 drivers/usb/misc/ch341/ch341-gpio.c | 249 ++++++++++++++++++++++++++
 drivers/usb/misc/ch341/ch341-i2c.c  | 267 ++++++++++++++++++++++++++++
 drivers/usb/misc/ch341/ch341.h      |  50 ++++++
 9 files changed, 681 insertions(+)
 create mode 100644 drivers/usb/misc/ch341/Kconfig
 create mode 100644 drivers/usb/misc/ch341/Makefile
 create mode 100644 drivers/usb/misc/ch341/ch341-core.c
 create mode 100644 drivers/usb/misc/ch341/ch341-gpio.c
 create mode 100644 drivers/usb/misc/ch341/ch341-i2c.c
 create mode 100644 drivers/usb/misc/ch341/ch341.h
drivers/usb/misc/Kconfig +8 -0
index 8f1144359012..2d4db92f0de4 100644
@@ -284,3 +284,21 @@ config BRCM_USB_PINMAP
 	  This option enables support for remapping some USB external
 	  signals, which are typically on dedicated pins on the chip,
 	  to any gpio.
+
+config USB_CH341_CORE
+	tristate "USB WinChipHead CH341 in I2C/SPI/GPIO mode"
+	depends on USB && GPIOLIB && I2C && SPI
+	help
+
+	  If you say yes to this option, support for the CH341 chips,
+	  running in I2C/SPI/GPIO mode will be included. Some versions

drivers/usb/misc/Kconfig config BRCM_USB_PINMAP · line 304

Quoted 10 lines
drivers/usb/misc/Kconfig +10 -0
+	  of the chip do not support all the functionnalities but
+	  there is no way to differentiate them. For instance the
+	  CH341A and CH341B support everything while the CH341T can
+	  only do I2C.
+
+	  The serial mode is not supported by this driver. Use the
+	  CH341 USB serial driver.
+
+	  This driver can also be built as a module.  If so, the
+	  module will be called ch341-buses.

Above should be in drivers/usb/misc/ch341/Kconfig file instead?

drivers/usb/misc/ch341/Kconfig

Quoted 12 lines
drivers/usb/misc/Makefile +1 -0
index 5f4e598573ab..95c0ca15b8c9 100644
@@ -32,3 +32,4 @@ obj-$(CONFIG_USB_CHAOSKEY)		+= chaoskey.o
 obj-$(CONFIG_USB_SISUSBVGA)		+= sisusbvga/
 obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
 obj-$(CONFIG_BRCM_USB_PINMAP)		+= brcmstb-usb-pinmap.o
+obj-$(CONFIG_USB_CH341_CORE)		+= ch341/
drivers/usb/misc/ch341/Kconfig new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1

Is that file (above) empty on purpose?

Quoted 9 lines
drivers/usb/misc/ch341/Makefile new file +3 -0
new file mode 100644
index 000000000000..7c6429e7a46e
@@ -0,0 +1,3 @@
+obj-$(CONFIG_USB_CH341_CORE) := ch341-buses.o
+
+ch341-buses-objs := ch341-core.o ch341-i2c.o ch341-gpio.o
Signature · 1 line
~Randy
#3 lore raw
In reply to Frank Zago
Quoted 7 lines · Frank Zago

From: frank zago <[email protected]>

The 0x5512 USB PID is for the I2C/GPIO/SPI interfaces. UART is still present but only the TX and RX pins are available; DTS, DTR, ... are used for other things. Remove the PID, and let a I2C driver bind to it.

Quoted 7 lines

Existing CH341 boards usually have physical jumpers to switch between the 3 modes.

This reverts commit 46ee4abb10a07bd8f8ce910ee6b4ae6a947d7f63.

Why are you signing off twice?

author
#4 lore raw
Quoted 11 lines · Greg Kroah-Hartman
Quoted 10 lines · Frank Zago

From: frank zago <[email protected]>

The 0x5512 USB PID is for the I2C/GPIO/SPI interfaces. UART is still present but only the TX and RX pins are available; DTS, DTR, ... are used for other things. Remove the PID, and let a I2C driver bind to it.

Existing CH341 boards usually have physical jumpers to switch between the 3 modes.

Quoted 7 lines
Quoted 4 lines

This reverts commit 46ee4abb10a07bd8f8ce910ee6b4ae6a947d7f63.

Why are you signing off twice?

I did it in the patch, then git send-mail added another one. That'll be fixed in the next revision.

Regards,
Frank