mbox series

[0/5] Add Intel LJCA device driver

Message ID 20230219183059.1029525-1-xiang.ye@intel.com
Headers show
Series Add Intel LJCA device driver | expand

Message

Ye Xiang Feb. 19, 2023, 6:30 p.m. UTC
Add driver for Intel La Jolla Cove Adapter (LJCA) device.
This is a USB-GPIO, USB-I2C and USB-SPI device. We add 4
drivers to support this device: a USB driver, a GPIO chip
driver, a I2C controller driver and a SPI controller driver.

Ye Xiang (5):
  mfd: Add support for Intel LJCA device
  gpio: Add support for Intel LJCA USB GPIO driver
  i2c: Add support for Intel LJCA USB I2C driver
  spi: Add support for Intel LJCA USB SPI driver
  Documentation: Add ABI doc for attributes of LJCA device

 .../ABI/testing/sysfs-bus-usb-devices-ljca    |  22 +
 drivers/gpio/Kconfig                          |  10 +
 drivers/gpio/Makefile                         |   1 +
 drivers/gpio/gpio-ljca.c                      | 454 ++++++++
 drivers/i2c/busses/Kconfig                    |  10 +
 drivers/i2c/busses/Makefile                   |   1 +
 drivers/i2c/busses/i2c-ljca.c                 | 357 +++++++
 drivers/mfd/Kconfig                           |  13 +
 drivers/mfd/Makefile                          |   1 +
 drivers/mfd/ljca.c                            | 977 ++++++++++++++++++
 drivers/spi/Kconfig                           |  10 +
 drivers/spi/Makefile                          |   1 +
 drivers/spi/spi-ljca.c                        | 291 ++++++
 include/linux/mfd/ljca.h                      |  95 ++
 14 files changed, 2243 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-usb-devices-ljca
 create mode 100644 drivers/gpio/gpio-ljca.c
 create mode 100644 drivers/i2c/busses/i2c-ljca.c
 create mode 100644 drivers/mfd/ljca.c
 create mode 100644 drivers/spi/spi-ljca.c
 create mode 100644 include/linux/mfd/ljca.h

Comments

Linus Walleij Feb. 24, 2023, 10:53 a.m. UTC | #1
Hi Ye,

thanks for your patch!

On Sun, Feb 19, 2023 at 7:31 PM Ye Xiang <xiang.ye@intel.com> wrote:

> Add sysfs attributes Documentation entries for LJCA device
>
> Signed-off-by: Ye Xiang <xiang.ye@intel.com>
(...)
> +What:          /sys/bus/usb/.../cmd
> +Date:          July 2023
> +KernelVersion: 6.4
> +Contact:       Ye Xiang <xiang.ye@intel.com>
> +Description:
> +               Commands supported by LJCA device.
> +               When read, it will return valid commands.
> +               When write with a command, it will execute the command.
> +               Valid commands are [dfu, reset, debug]
> +               dfu:    Force LJCA device to enter DFU mode.
> +               reset:  Trigger soft reset for LJCA device.
> +               debug:  Enable debug logging.

Given that there are kernel drivers for this device, it looks pretty
dangerous to make it possible for userspace to reset the device?

But maybe it will re-enumerate when you do this so all drivers
unload cleanly and then re-probe?

I guess the DFU mode will use the USB standard class for updating
the firmware?

Perhaps a short blurb on the use case for each string could be
helpful, like "echo dfu to this file so as to put the device into
DFU mode so the firmware can be updated".

Is the idea that e.g. fwupdmgr should provide a front-end for this?

Yours,
Linus Walleij
Ye Xiang Feb. 24, 2023, 6:01 p.m. UTC | #2
Hi Walleij,

Thanks for the review.

On Fri, Feb 24, 2023 at 11:53:08AM +0100, Linus Walleij wrote:
> Hi Ye,
> 
> thanks for your patch!
> 
> On Sun, Feb 19, 2023 at 7:31 PM Ye Xiang <xiang.ye@intel.com> wrote:
> 
> > Add sysfs attributes Documentation entries for LJCA device
> >
> > Signed-off-by: Ye Xiang <xiang.ye@intel.com>
> (...)
> > +What:          /sys/bus/usb/.../cmd
> > +Date:          July 2023
> > +KernelVersion: 6.4
> > +Contact:       Ye Xiang <xiang.ye@intel.com>
> > +Description:
> > +               Commands supported by LJCA device.
> > +               When read, it will return valid commands.
> > +               When write with a command, it will execute the command.
> > +               Valid commands are [dfu, reset, debug]
> > +               dfu:    Force LJCA device to enter DFU mode.
> > +               reset:  Trigger soft reset for LJCA device.
> > +               debug:  Enable debug logging.
> 
> Given that there are kernel drivers for this device, it looks pretty
> dangerous to make it possible for userspace to reset the device?
Agree. I would just remove the reset cmd on the next version.
User access LJCA will fail during reset because the reset cmd
could cause LJCA down for a short time.

> 
> But maybe it will re-enumerate when you do this so all drivers
> unload cleanly and then re-probe?
No, I haven't implemented the re-probe yet. It seems quite complicated to
make sure all drivers depend on LJCA re-init. So, I would just stop
exporting the reset interface to userspace.
> 
> I guess the DFU mode will use the USB standard class for updating
> the firmware?
Yes.
> 
> Perhaps a short blurb on the use case for each string could be
> helpful, like "echo dfu to this file so as to put the device into
> DFU mode so the firmware can be updated".
Thanks will add this blurb.
> 
> Is the idea that e.g. fwupdmgr should provide a front-end for this?
We haven't implemented a front-end in fwupdmgr. dfu-util is used to
update LJCA firmware manually currently. Maybe we will consider
implementing this in fwupdmgr later.
> 
> Yours,
> Linus Walleij

--
Thanks
Ye Xiang
Linus Walleij March 6, 2023, 2 p.m. UTC | #3
On Fri, Feb 24, 2023 at 7:02 PM Ye, Xiang <xiang.ye@intel.com> wrote:
> On Fri, Feb 24, 2023 at 11:53:08AM +0100, Linus Walleij wrote:

> > Is the idea that e.g. fwupdmgr should provide a front-end for this?

> We haven't implemented a front-end in fwupdmgr. dfu-util is used to
> update LJCA firmware manually currently. Maybe we will consider
> implementing this in fwupdmgr later.

It's a matter of process rather than implementation really, but if you can
please communicate upward to the project that if this is to go into
consumer hands (i.e. be used by random people on random laptops)
the firmware update should come via fwupdmgr.

Yours,
Linus Walleij