mbox series

[v4,0/3] WCH CH341 GPIO and SPI support

Message ID 20220321042142.69239-1-frank@zago.net
Headers show
Series WCH CH341 GPIO and SPI support | expand

Message

Frank Zago March 21, 2022, 4:21 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 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 (3):
  mfd: ch341: add core driver for the WCH CH341 in I2C/GPIO mode
  gpio: ch341: add MFD cell driver for the CH341
  i2c: ch341: add MFD cell driver CH341 for I2C

 Documentation/misc-devices/ch341.rst | 114 ++++++++
 Documentation/misc-devices/index.rst |   1 +
 MAINTAINERS                          |   9 +
 drivers/gpio/Kconfig                 |  10 +
 drivers/gpio/Makefile                |   1 +
 drivers/gpio/gpio-ch341.c            | 421 +++++++++++++++++++++++++++
 drivers/i2c/busses/Kconfig           |  10 +
 drivers/i2c/busses/Makefile          |   1 +
 drivers/i2c/busses/i2c-ch341.c       | 325 +++++++++++++++++++++
 drivers/mfd/Kconfig                  |  12 +
 drivers/mfd/Makefile                 |   1 +
 drivers/mfd/ch341-core.c             | 109 +++++++
 include/linux/mfd/ch341.h            |  25 ++
 13 files changed, 1039 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

Linus Walleij March 28, 2022, 3:05 p.m. UTC | #1
Hi Frank,

thanks for your patch!

I see you already got a bunch of homework from Andy, I will do a more
thorough review on the next iteration, just a few things:

On Mon, Mar 21, 2022 at 5:21 AM frank zago <frank@zago.net> wrote:

> The GPIO interface offers 16 GPIOs. 6 are read/write, and 10 are
> read-only.
>
> Signed-off-by: frank zago <frank@zago.net>
(...)
> +config GPIO_CH341
> +       tristate "CH341 USB adapter in GPIO/I2C/SPI mode"
> +       depends on MFD_CH341

I would add
default MFD_CD341

This way it gets selected automatically if the MFD module gets
selected. (I suspect you should do the same with the I2C module).

> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/mfd/core.h>
> +#include <linux/gpio.h>

Use <linux/gpio/driver.h>

Yours,
Linus Walleij