mbox series

[v6,0/4] add driver for the WCH CH341 in I2C/GPIO mode

Message ID 20220616013747.126051-1-frank@zago.net
Headers show
Series add driver for the WCH CH341 in I2C/GPIO mode | expand

Message

Frank Zago June 16, 2022, 1:37 a.m. UTC
The CH341 is a multifunction chip, presenting 3 different USB PID. One
of these functions is for I2C/SPI/GPIO. This new set of drivers will
manage I2C and GPIO.

Changes from v5:
Addressed reviewers' comments.
Better handling of 0-bytes i2c commands
Use of better USB API.

Changes from v4:
I should have addressed all the comments: rework of the GPIO interrupt
handling code to be more modern, changes in Kconfig wording, some code
cleanup.
Driver was tested again with up to 4 of these devices. No
error seen.

Changes from v3:
  - really converted to an MFD driver. Driver is now split into 3
    modules (MFD+I2C+GPIO).
  - minor code cleanups

Changes from v2:
  - bug fixes
  - more robust USB enumeration
  - Changed to an MFD driver as suggested

During testing I found that i2c handles hot removal, but not gpio. The
gpio subsystem will complain with 'REMOVING GPIOCHIP WITH GPIOS STILL
REQUESTED', but it's a gpiolib issue.

Changes from v1:
  - Removed double Signed-off-by
  - Move Kconfig into the same directory as the driver

frank zago (4):
  mfd: ch341: add core driver for the WCH CH341 in I2C/SPI/GPIO mode
  gpio: ch341: add GPIO MFD cell driver for the CH341
  i2c: ch341: add I2C MFD cell driver for the CH341
  docs: misc: add documentation for ch341 driver

 Documentation/misc-devices/ch341.rst | 109 ++++++++
 Documentation/misc-devices/index.rst |   1 +
 MAINTAINERS                          |   9 +
 drivers/gpio/Kconfig                 |  10 +
 drivers/gpio/Makefile                |   1 +
 drivers/gpio/gpio-ch341.c            | 385 +++++++++++++++++++++++++++
 drivers/i2c/busses/Kconfig           |  10 +
 drivers/i2c/busses/Makefile          |   1 +
 drivers/i2c/busses/i2c-ch341.c       | 377 ++++++++++++++++++++++++++
 drivers/mfd/Kconfig                  |  10 +
 drivers/mfd/Makefile                 |   1 +
 drivers/mfd/ch341-core.c             |  90 +++++++
 include/linux/mfd/ch341.h            |  26 ++
 13 files changed, 1030 insertions(+)
 create mode 100644 Documentation/misc-devices/ch341.rst
 create mode 100644 drivers/gpio/gpio-ch341.c
 create mode 100644 drivers/i2c/busses/i2c-ch341.c
 create mode 100644 drivers/mfd/ch341-core.c
 create mode 100644 include/linux/mfd/ch341.h

--
2.32.0

Comments

Randy Dunlap June 16, 2022, 5:09 a.m. UTC | #1
Hi--

On 6/15/22 18:37, frank zago wrote:
> The I2C interface can run at 4 different speeds. This driver currently
> only offer 100kHz. Tested with a variety of I2C sensors, and the IIO
> subsystem.
> 
> Signed-off-by: frank zago <frank@zago.net>
> ---
>  MAINTAINERS                    |   1 +
>  drivers/i2c/busses/Kconfig     |  10 +
>  drivers/i2c/busses/Makefile    |   1 +
>  drivers/i2c/busses/i2c-ch341.c | 377 +++++++++++++++++++++++++++++++++
>  4 files changed, 389 insertions(+)
>  create mode 100644 drivers/i2c/busses/i2c-ch341.c
> 

> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index a1bae59208e3..db9797345ad5 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -1199,6 +1199,16 @@ config I2C_RCAR
>  
>  comment "External I2C/SMBus adapter drivers"
>  
> +config I2C_CH341
> +	tristate "CH341 USB to I2C support"
> +	select MFD_CH341
> +	help
> +	  If you say yes to this option, I2C support will be included for the
> +	  WCH CH341, a USB to I2C/SPI/GPIO interface.
> +
> +	  This driver can also be built as a module.  If so, the module
> +	  will be called i2c-ch341.

I haven't tested it, but just from reading, it looks like
this one needs a "depends on USB" since it selects MFD_CH341, which
depends on USB, and since 'select' ignores dependency chains.

The GPIO driver (patch 2/4) already depends on USB.
Johan Hovold June 20, 2022, 10:08 a.m. UTC | #2
On Wed, Jun 15, 2022 at 08:37:43PM -0500, frank zago wrote:
> The CH341 is a multifunction chip, presenting 3 different USB PID. One
> of these functions is for I2C/SPI/GPIO. This new set of drivers will
> manage I2C and GPIO.
> 
> Changes from v5:
> Addressed reviewers' comments.

Please be more specific in your changelogs. This essentially just says
"changed stuff".

> Better handling of 0-bytes i2c commands
> Use of better USB API.

What does this even mean?

Johan
Matwey V. Kornilov Nov. 8, 2024, 3:58 p.m. UTC | #3
Hi Frank,


Are you going to further proceed with this patch set? As far as I can 
see, there were no updates since 2022.


16.06.2022 04:37, frank zago пишет:
> The CH341 is a multifunction chip, presenting 3 different USB PID. One
> of these functions is for I2C/SPI/GPIO. This new set of drivers will
> manage I2C and GPIO.
> 
> Changes from v5:
> Addressed reviewers' comments.
> Better handling of 0-bytes i2c commands
> Use of better USB API.
> 
> Changes from v4:
> I should have addressed all the comments: rework of the GPIO interrupt
> handling code to be more modern, changes in Kconfig wording, some code
> cleanup.
> Driver was tested again with up to 4 of these devices. No
> error seen.
> 
> Changes from v3:
>    - really converted to an MFD driver. Driver is now split into 3
>      modules (MFD+I2C+GPIO).
>    - minor code cleanups
> 
> Changes from v2:
>    - bug fixes
>    - more robust USB enumeration
>    - Changed to an MFD driver as suggested
> 
> During testing I found that i2c handles hot removal, but not gpio. The
> gpio subsystem will complain with 'REMOVING GPIOCHIP WITH GPIOS STILL
> REQUESTED', but it's a gpiolib issue.
> 
> Changes from v1:
>    - Removed double Signed-off-by
>    - Move Kconfig into the same directory as the driver
> 
> frank zago (4):
>    mfd: ch341: add core driver for the WCH CH341 in I2C/SPI/GPIO mode
>    gpio: ch341: add GPIO MFD cell driver for the CH341
>    i2c: ch341: add I2C MFD cell driver for the CH341
>    docs: misc: add documentation for ch341 driver
> 
>   Documentation/misc-devices/ch341.rst | 109 ++++++++
>   Documentation/misc-devices/index.rst |   1 +
>   MAINTAINERS                          |   9 +
>   drivers/gpio/Kconfig                 |  10 +
>   drivers/gpio/Makefile                |   1 +
>   drivers/gpio/gpio-ch341.c            | 385 +++++++++++++++++++++++++++
>   drivers/i2c/busses/Kconfig           |  10 +
>   drivers/i2c/busses/Makefile          |   1 +
>   drivers/i2c/busses/i2c-ch341.c       | 377 ++++++++++++++++++++++++++
>   drivers/mfd/Kconfig                  |  10 +
>   drivers/mfd/Makefile                 |   1 +
>   drivers/mfd/ch341-core.c             |  90 +++++++
>   include/linux/mfd/ch341.h            |  26 ++
>   13 files changed, 1030 insertions(+)
>   create mode 100644 Documentation/misc-devices/ch341.rst
>   create mode 100644 drivers/gpio/gpio-ch341.c
>   create mode 100644 drivers/i2c/busses/i2c-ch341.c
>   create mode 100644 drivers/mfd/ch341-core.c
>   create mode 100644 include/linux/mfd/ch341.h
> ---
> 2.32.0
Linus Walleij Nov. 8, 2024, 7:11 p.m. UTC | #4
On Fri, Nov 8, 2024 at 4:58 PM Matwey V. Kornilov
<matwey.kornilov@gmail.com> wrote:


> Hi Frank,
>
> Are you going to further proceed with this patch set? As far as I can
> see, there were no updates since 2022.

I suggest you take it over if there is no reply in a week or so.

IIRC Howard Harte also has this very device inside the USR8200 router,
but I don't know if it uses the I2C/GPIO portions in that device.

Yours,
Linus Walleij
Frank Zago Nov. 8, 2024, 11:15 p.m. UTC | #5
On 11/8/24 9:58 AM, Matwey V. Kornilov wrote:
> 
> Hi Frank,
> 
> 
> Are you going to further proceed with this patch set? As far as I can see, there were no updates since 2022.
> 

Hi Matwey,

I've been maintaining it at https://github.com/frank-zago/ch341-i2c-spi-gpio, but I have had no desire to try again to upstream it. Feel free to do it if you'd like.

Also there's been an SPI only driver that was upstreamed a couple revisions ago, which is incompatible with this driver.

Regards,
  Frank.
Matwey V. Kornilov Nov. 9, 2024, 7:32 a.m. UTC | #6
сб, 9 нояб. 2024 г. в 02:15, Frank Zago <frank@zago.net>:
>
> On 11/8/24 9:58 AM, Matwey V. Kornilov wrote:
> >
> > Hi Frank,
> >
> >
> > Are you going to further proceed with this patch set? As far as I can see, there were no updates since 2022.
> >
>
> Hi Matwey,

Hi Frank,

>
> I've been maintaining it at https://github.com/frank-zago/ch341-i2c-spi-gpio, but I have had no desire to try again to upstream it.

Thank you for the response and for the code.

> Feel free to do it if you'd like.

Just to make it clear for other people who will find this discussion
while looking for a CH341 I2C driver: currently I don't have
motivation to make this kind of contribution.

>
> Also there's been an SPI only driver that was upstreamed a couple revisions ago, which is incompatible with this driver.
>
> Regards,
>   Frank.
>
>