Skip to contentSkip to conversation

Add Intel LJCA device driver

PATCH Superseded Wentong Wu 2 participants 6 messages Sep 4, 2023

Subsystems (5)

v13 of 20 Superseded Latest is v20 →

lore
Share & tools
lore

Wentong Wu

author
#0 lore raw

v13 cover Add Intel LJCA device driver

Add driver for Intel La Jolla Cove Adapter (LJCA) device. This IO-expander expands additional functions to the host system such as GPIO, I2C and SPI with USB host interface. We add 4 drivers to support this device: a USB driver, a GPIO chip driver, a I2C controller driver and a SPI controller driver.

---
v13:
- make ljca-usb more robust with the help of Hans de Goede
- call acpi_dev_clear_dependencies() to mark _DEP ACPI dependencies on
the I2C controller as satisfied, and patch is from Hans de Goede

v12:
- switch dev_err to dev_dbg for i2c-ljca driver
- avoid err printing because of calling usb_kill_urb when attempts to resubmit the rx urb

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 | 333 +++++++++++++++++
 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   | 834 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/ljca.h      | 113 ++++++
 12 files changed, 1761 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
author
#1 lore raw

PATCH v13 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 | 834 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/ljca.h    | 113 ++++++
 4 files changed, 962 insertions(+)
 create mode 100644 drivers/usb/misc/usb-ljca.c
 create mode 100644 include/linux/usb/ljca.h
drivers/usb/misc/Kconfig +14 -0
index 99b15b7..999193e 100644
@@ -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
index 1992cc2..0bc732bc 100644
@@ -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 +834 -0

834 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
author
#2 lore raw

PATCH v13 2/4 i2c: Add support for Intel LJCA USB I2C driver

In reply to 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.

---
 drivers/i2c/busses/Kconfig    |  11 ++
 drivers/i2c/busses/Makefile   |   1 +
 drivers/i2c/busses/i2c-ljca.c | 333 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 345 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-ljca.c
drivers/i2c/busses/Kconfig +11 -0
index 9cfe8fc..7e2c52d 100644
@@ -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
index af56fe2..3757b93 100644
@@ -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 +333 -0

333 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH v13 2/4] i2c: Add support for Intel LJCA USB I2C driver

kernel test robot noticed the following build errors:

Hi Wentong,

kernel test robot noticed the following build errors:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on broonie-spi/for-next linus/master v6.5 next-20230831] [cannot apply to usb/usb-testing usb/usb-next usb/usb-linus]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Wentong-Wu/usb-Add-support-for-Intel-LJCA-device/20230904-112200
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link:    https://lore.kernel.org/r/1693797462-4833-3-git-send-email-wentong.wu%40intel.com
patch subject: [PATCH v13 2/4] i2c: Add support for Intel LJCA USB I2C driver
config: sparc-allmodconfig (https://download.01.org/0day-ci/archive/20230904/[email protected]/config)
compiler: sparc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230904/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/i2c/busses/i2c-ljca.c: In function 'ljca_i2c_probe':

>> drivers/i2c/busses/i2c-ljca.c:311:17: error: implicit declaration of function 'acpi_dev_clear_dependencies' [-Werror=implicit-function-declaration]
     311 |                 acpi_dev_clear_dependencies(ACPI_COMPANION(&ljca_i2c->adap.dev));
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1: some warnings being treated as errors

vim +/acpi_dev_clear_dependencies +311 drivers/i2c/busses/i2c-ljca.c

270
271 static int ljca_i2c_probe(struct auxiliary_device *auxdev,
272 const struct auxiliary_device_id *aux_dev_id)
273 {
274 struct ljca_client *ljca = auxiliary_dev_to_ljca_client(auxdev);
275 struct ljca_i2c_dev *ljca_i2c;
276 int ret;
277
278 ljca_i2c = devm_kzalloc(&auxdev->dev, sizeof(*ljca_i2c), GFP_KERNEL);
279 if (!ljca_i2c)
280 return -ENOMEM;
281
282 ljca_i2c->ljca = ljca;
283 ljca_i2c->i2c_info = dev_get_platdata(&auxdev->dev);
284
285 ljca_i2c->adap.owner = THIS_MODULE;
286 ljca_i2c->adap.class = I2C_CLASS_HWMON;
287 ljca_i2c->adap.algo = &ljca_i2c_algo;
288 ljca_i2c->adap.quirks = &ljca_i2c_quirks;
289 ljca_i2c->adap.dev.parent = &auxdev->dev;
290
291 snprintf(ljca_i2c->adap.name, sizeof(ljca_i2c->adap.name), "%s-%s-%d",
292 dev_name(&auxdev->dev), dev_name(auxdev->dev.parent),
293 ljca_i2c->i2c_info->id);
294
295 device_set_node(&ljca_i2c->adap.dev, dev_fwnode(&auxdev->dev));
296
297 i2c_set_adapdata(&ljca_i2c->adap, ljca_i2c);
298 auxiliary_set_drvdata(auxdev, ljca_i2c);
299
300 ret = ljca_i2c_init(ljca_i2c, ljca_i2c->i2c_info->id);
301 if (ret)
302 return dev_err_probe(&auxdev->dev, -EIO,
303 "i2c init failed id: %d\n",
304 ljca_i2c->i2c_info->id);
305
306 ret = devm_i2c_add_adapter(&auxdev->dev, &ljca_i2c->adap);
307 if (ret)
308 return ret;
309
310 if (has_acpi_companion(&ljca_i2c->adap.dev))

 > 311			acpi_dev_clear_dependencies(ACPI_COMPANION(&ljca_i2c->adap.dev));

312
313 return 0;
314 }
315

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author
#4 lore raw

PATCH v13 3/4 spi: Add support for Intel LJCA USB SPI driver

In reply to Wentong Wu

Implements 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
index 8962b25..ad18864 100644
@@ -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
index 080c2c1..0847962 100644
@@ -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
author
#5 lore raw

PATCH v13 4/4 gpio: update Intel LJCA USB GPIO driver

In reply to Wentong Wu

This 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
index e382dfe..c85843b 100644
@@ -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