Add Intel LJCA device driver
Subsystems (5)
v11 cover Add Intel LJCA device driver
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.
---
v11:
- switch dev_err to dev_dbg for i2c-ljca driver
- remove message length check because of defined quirk structure
- remove I2C_FUNC_SMBUS_EMUL support
v10:
- remove ljca_i2c_format_slave_addr
- remove memset before write write w_packet
- make ljca_i2c_stop void and print err message in case failure
- use dev_err_probe in ljca_i2c_probe function
v9:
- overhaul usb-ljca driver to make it more structured and easy understand
- fix memory leak issue for usb-ljca driver
- add spinlock to protect tx_buf and ex_buf
- change exported APIs for usb-ljca driver
- unify prefix for structures and functions for i2c-ljca driver
- unify prefix for structures and functions for spi-ljca driver
- unify prefix for structures and functions for gpio-ljca driver
- update gpio-ljca, i2c-ljca and spi-ljca drivers according to usb-ljca's changes
Wentong Wu (4):
usb: Add support for Intel LJCA device
i2c: Add support for Intel LJCA USB I2C driver
spi: Add support for Intel LJCA USB SPI driver
gpio: update Intel LJCA USB GPIO driver
drivers/gpio/Kconfig | 4 +- drivers/gpio/gpio-ljca.c | 246 +++++++------ drivers/i2c/busses/Kconfig | 11 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-ljca.c | 326 +++++++++++++++++ drivers/spi/Kconfig | 11 + drivers/spi/Makefile | 1 + drivers/spi/spi-ljca.c | 297 +++++++++++++++ drivers/usb/misc/Kconfig | 14 + drivers/usb/misc/Makefile | 1 + drivers/usb/misc/usb-ljca.c | 817 ++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/ljca.h | 113 ++++++ 12 files changed, 1737 insertions(+), 105 deletions(-) create mode 100644 drivers/i2c/busses/i2c-ljca.c create mode 100644 drivers/spi/spi-ljca.c create mode 100644 drivers/usb/misc/usb-ljca.c create mode 100644 include/linux/usb/ljca.h
Signature · 1 line
2.7.4
PATCH v11 1/4 usb: Add support for Intel LJCA device
Implements the USB part of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA).
The communication between the various LJCA module drivers and the hardware will be muxed/demuxed by this driver. Three modules ( I2C, GPIO, and SPI) are supported currently.
Each sub-module of LJCA device is identified by type field within the LJCA message header.
The sub-modules of LJCA can use ljca_transfer() to issue a transfer between host and hardware. And ljca_register_event_cb is exported to LJCA sub-module drivers for hardware event subscription.
The minimum code in ASL that covers this board is
Scope (\_SB.PCI0.DWC3.RHUB.HS01)
{
Device (GPIO)
{
Name (_ADR, Zero)
Name (_STA, 0x0F)
}
Device (I2C)
{
Name (_ADR, One)
Name (_STA, 0x0F)
}
Device (SPI)
{
Name (_ADR, 0x02)
Name (_STA, 0x0F)
}
}--- drivers/usb/misc/Kconfig | 14 + drivers/usb/misc/Makefile | 1 + drivers/usb/misc/usb-ljca.c | 817 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/ljca.h | 113 ++++++ 4 files changed, 945 insertions(+) create mode 100644 drivers/usb/misc/usb-ljca.c create mode 100644 include/linux/usb/ljca.h
drivers/usb/misc/Kconfig +14 -0
@@ -165,6 +165,20 @@ config APPLE_MFI_FASTCHARGE It is safe to say M here. +config USB_LJCA + tristate "Intel La Jolla Cove Adapter support" + select AUXILIARY_BUS + depends on USB + depends on ACPI || COMPILE_TEST + help + This adds support for Intel La Jolla Cove USB-I2C/SPI/GPIO + Master Adapter (LJCA). Additional drivers such as I2C_LJCA, + GPIO_LJCA and SPI_LJCA must be enabled in order to use the + functionality of the device. + + This driver can also be built as a module. If so, the module + will be called usb-ljca. + source "drivers/usb/misc/sisusbvga/Kconfig" config USB_LD
drivers/usb/misc/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_EMI26) += emi26.o obj-$(CONFIG_USB_EMI62) += emi62.o obj-$(CONFIG_USB_EZUSB_FX2) += ezusb.o obj-$(CONFIG_APPLE_MFI_FASTCHARGE) += apple-mfi-fastcharge.o +obj-$(CONFIG_USB_LJCA) += usb-ljca.o obj-$(CONFIG_USB_IDMOUSE) += idmouse.o obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o
drivers/usb/misc/usb-ljca.c new file +817 -0
817 lines not on this page · raw message
include/linux/usb/ljca.h new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v11 1/4] usb: Add support for Intel LJCA device
Quoted 18 lines · Wentong Wu
drivers/usb/misc/usb-ljca.c new file +18
-0+static void ljca_recv (struct urb *urb) +{ +struct ljca_msg *header = urb->transfer_buffer; +struct ljca_adapter *adap = urb->context; +int ret; + +if (urb->status) { +/* sync/async unlink faults aren't errors */ +if (urb->status == -ENOENT || urb->status == -ECONNRESET || + urb->status == -ESHUTDOWN ) +return ; + +dev_err (adap->dev,"recv urb error: %d\n" , urb->status); + goto resubmit; + } + +if (header->len +sizeof (*header) != urb->actual_length) + goto resubmit;
drivers/usb/misc/usb-ljca.c line 228
Quoted 10 lines
drivers/usb/misc/usb-ljca.c new file +10
-0+ +if (header->flags &LJCA_ACK_FLAG ) +ljca_handle_cmd_ack (adap, header); +else +ljca_handle_event (adap, header); + +resubmit: + ret =usb_submit_urb (urb,GFP_ATOMIC ); +if (ret) +dev_err (adap->dev,"resubmit recv urb error %d\n" , ret);
This will detect an error if you get an unlucky timing with ljca_suspend(). The correct test would be:
if (ret && ret != -EPERM)
HTH
Oliver
RE: [PATCH v11 1/4] usb: Add support for Intel LJCA device
Hi Oliver,
Thanks for your review.
Quoted 25 lines
From: Oliver Neukum <[email protected]>
Quoted 21 lines · Wentong Wu
drivers/usb/misc/usb-ljca.c new file +21
-0+static void ljca_recv (struct urb *urb) { +struct ljca_msg *header = urb->transfer_buffer; +struct ljca_adapter *adap = urb->context; +int ret; + +if (urb->status) { +/* sync/async unlink faults aren't errors */ +if (urb->status == -ENOENT || urb->status == -ECONNRESET || + urb->status == -ESHUTDOWN ) +return ; + +dev_err (adap->dev,"recv urb error: %d\n" , urb->status); + goto resubmit; + } + +if (header->len +sizeof (*header) != urb->actual_length) + goto resubmit; + +if (header->flags &LJCA_ACK_FLAG ) +ljca_handle_cmd_ack (adap, header); +else
Quoted 8 lines
drivers/usb/misc/usb-ljca.c line 228
Quoted 6 lines
drivers/usb/misc/usb-ljca.c new file +6
-0+ljca_handle_event (adap, header); + +resubmit: + ret =usb_submit_urb (urb,GFP_ATOMIC ); +if (ret) +dev_err (adap->dev,"resubmit recv urb error %d\n" , ret);This will detect an error if you get an unlucky timing with
ljca_suspend().
Indeed, thanks, I will fix this in next version.
BR,
Wentong
Quoted 5 lines
The correct test would be:
if (ret && ret !=-EPERM)HTH
Oliver
PATCH v11 2/4 i2c: Add support for Intel LJCA USB I2C driver
In reply to Wentong WuImplements the I2C function of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA I2C module with specific protocol through interfaces exported by LJCA USB driver.
--- drivers/i2c/busses/Kconfig | 11 ++ drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-ljca.c | 326 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 338 insertions(+) create mode 100644 drivers/i2c/busses/i2c-ljca.c
drivers/i2c/busses/Kconfig +11 -0
@@ -1264,6 +1264,17 @@ config I2C_DLN2 This driver can also be built as a module. If so, the module will be called i2c-dln2. +config I2C_LJCA + tristate "I2C functionality of Intel La Jolla Cove Adapter" + depends on USB_LJCA + default USB_LJCA + help + If you say yes to this option, I2C functionality support of Intel + La Jolla Cove Adapter (LJCA) will be included. + + This driver can also be built as a module. If so, the module + will be called i2c-ljca. + config I2C_CP2615 tristate "Silicon Labs CP2615 USB sound card and I2C adapter" depends on USB
drivers/i2c/busses/Makefile +1 -0
@@ -133,6 +133,7 @@ obj-$(CONFIG_I2C_GXP) += i2c-gxp.o # External I2C/SMBus adapter drivers obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o obj-$(CONFIG_I2C_DLN2) += i2c-dln2.o +obj-$(CONFIG_I2C_LJCA) += i2c-ljca.o obj-$(CONFIG_I2C_CP2615) += i2c-cp2615.o obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o obj-$(CONFIG_I2C_PCI1XXXX) += i2c-mchp-pci1xxxx.o
drivers/i2c/busses/i2c-ljca.c new file +326 -0
326 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v11 2/4] i2c: Add support for Intel LJCA USB I2C driver
Quoted 8 lines · Wentong Wu
Implements the I2C function of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA I2C module with specific protocol through interfaces exported by LJCA USB driver.
Signed-off-by Wentong Wu <[email protected]>Reviewed-by Sakari Ailus <[email protected]>Reviewed-by Andi Shyti <[email protected]>
Basically good...
drivers/i2c/busses/i2c-ljca.c line 128
Quoted 4 lines
drivers/i2c/busses/i2c-ljca.c new file +4
-0+if (ret <0 || ret <sizeof (*r_packet)) { +dev_err (&ljca_i2c->adap.dev, +"i2c stop failed ret: %d id: %d\n" , + ret, w_packet->id);
This was forgotten to be turned into dev_dbg. I could fix it while applying. But shall I take this patch via i2c? Or shall all the patches go via some other tree? I'd assume the dependencies are hidden away by auxiliary_bus but I am not 100% sure.
RE: [PATCH v11 2/4] i2c: Add support for Intel LJCA USB I2C driver
Hi Wolfrma,
Thanks for your help
Quoted 12 lines
From: Wolfram Sang <[email protected]>
Quoted 8 lines · Wentong Wu
Implements the I2C function of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA I2C module with specific protocol through interfaces exported by LJCA USB driver.
Signed-off-by Wentong Wu <[email protected]>Reviewed-by Sakari Ailus <[email protected]>Reviewed-by Andi Shyti <[email protected]>
Quoted 8 lines
Basically good...
drivers/i2c/busses/i2c-ljca.c line 128
Quoted 4 lines
drivers/i2c/busses/i2c-ljca.c new file +4
-0+if (ret <0 || ret <sizeof (*r_packet)) { +dev_err (&ljca_i2c->adap.dev, +"i2c stop failed ret: %d id: %d\n" , + ret, w_packet->id);This was forgotten to be turned into
dev_dbg. I could fix it while applying.
Thanks.
Quoted 1 line
But shall I take this patch via i2c?
Yes, please help merge this i2c-ljca patch via i2c tree, thanks
Quoted 1 line
I'd assume the dependencies are hidden away by
auxiliary_bus
Exactly, thanks
BR,
Wentong
PATCH v11 3/4 spi: Add support for Intel LJCA USB SPI driver
In reply to Wentong WuImplements the SPI function of Intel USB-I2C/GPIO/SPI adapter device named "La Jolla Cove Adapter" (LJCA). It communicate with LJCA SPI module with specific protocol through interfaces exported by LJCA USB driver.
--- drivers/spi/Kconfig | 11 ++ drivers/spi/Makefile | 1 + drivers/spi/spi-ljca.c | 297 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 309 insertions(+) create mode 100644 drivers/spi/spi-ljca.c
drivers/spi/Kconfig +11 -0
@@ -583,6 +583,17 @@ config SPI_FSL_ESPI From MPC8536, 85xx platform uses the controller, and all P10xx, P20xx, P30xx,P40xx, P50xx uses this controller. +config SPI_LJCA + tristate "Intel La Jolla Cove Adapter SPI support" + depends on USB_LJCA + default USB_LJCA + help + Select this option to enable SPI driver for the Intel + La Jolla Cove Adapter (LJCA) board. + + This driver can also be built as a module. If so, the module + will be called spi-ljca. + config SPI_MESON_SPICC tristate "Amlogic Meson SPICC controller" depends on COMMON_CLK
drivers/spi/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_SPI_INTEL_PCI) += spi-intel-pci.o obj-$(CONFIG_SPI_INTEL_PLATFORM) += spi-intel-platform.o obj-$(CONFIG_SPI_LANTIQ_SSC) += spi-lantiq-ssc.o obj-$(CONFIG_SPI_JCORE) += spi-jcore.o +obj-$(CONFIG_SPI_LJCA) += spi-ljca.o obj-$(CONFIG_SPI_LM70_LLP) += spi-lm70llp.o obj-$(CONFIG_SPI_LP8841_RTC) += spi-lp8841-rtc.o obj-$(CONFIG_SPI_MESON_SPICC) += spi-meson-spicc.o
drivers/spi/spi-ljca.c new file +297 -0
297 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v11 4/4 gpio: update Intel LJCA USB GPIO driver
In reply to Wentong WuThis driver communicate with LJCA GPIO module with specific protocol through interfaces exported by LJCA USB driver. Update the driver according to LJCA USB driver's changes.
--- drivers/gpio/Kconfig | 4 +- drivers/gpio/gpio-ljca.c | 246 +++++++++++++++++++++++++++-------------------- 2 files changed, 145 insertions(+), 105 deletions(-)
drivers/gpio/Kconfig +2 -2
@@ -1294,9 +1294,9 @@ config GPIO_KEMPLD config GPIO_LJCA tristate "INTEL La Jolla Cove Adapter GPIO support" - depends on MFD_LJCA + depends on USB_LJCA select GPIOLIB_IRQCHIP - default MFD_LJCA + default USB_LJCA help Select this option to enable GPIO driver for the INTEL La Jolla Cove Adapter (LJCA) board.
drivers/gpio/gpio-ljca.c +143 -103
473 lines not on this page · raw message
Signature · 1 line
2.7.4