Skip to contentSkip to conversation

usb/gpio/i2c: Add Intel USBIO USB IO-expander drivers

PATCH Superseded Hans de Goede 3 participants 10 messages Sep 10, 2025 – Sep 11, 2025

Subsystems (4)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Hans de Goede

author maintainer
#0 lore raw

v4 cover usb/gpio/i2c: Add Intel USBIO USB IO-expander drivers

Hi All,

Here is v4 of the patch series to add support for the Intel USBIO USB IO-expander used by the MIPI cameras on various new (Meteor Lake and later) Intel laptops.

Changes in v4:
- GPIO: Drop include <linux/dev_printk.h>, unneeded auxiliary_set_drvdata()

Changes in v3:
- Drop (offset >= gc->ngpio) check and make usbio_gpio_get_bank_and_pin() return void
- Propagate usbio_gpio_set() ret val in usbio_gpio_direction_output()
- Use devm_gpiochip_add_data() and drop auxiliary_driver remove() callback

Changes in v2:
- Split usbio-bridge mutex into ctrl_mutex and bulk_mutex
- Drop SPI support since this is not used on devices in the field
- Rework disconnect handling to be more robust
- Several different revisions need special casing add a quirks mechanism for this
- Stop using stdint.h (uintX_t) types
- Use __le16, __le32 type + cpu_to_le16() and friends for on wire words
- Properly check auxiliary_device_add() return value
- Add a mutex to the GPIO driver to protect usbio_gpio_update_config() calls, which read-modify-write banks[x].config, racing with each other
- Adjust usbio_gpio_get() to have an int return value and propagate the usbio_control_msg() return value
- Various (small) style fixes from Sakari's review of all 3 patches

The first patch adds an USB bridge driver which registers auxbus children for the GPIO and I2C functions of the USBIO chip.

The second and third patch add a GPIO resp. an I2C driver for the auxbus children using the IO functions exported by the USB bridge driver.

The second and third patch depend on the IO functions exported by the first patch. So to merge this we will need either an immutable tag on the USB tree, or all 3 patches can be merged through the USB tree with acks from the GPIO and I2C subsystem maintainers.

Regards,

Hans

Israel Cepeda (3):
usb: misc: Add Intel USBIO bridge driver
gpio: Add Intel USBIO GPIO driver
i2c: Add Intel USBIO I2C driver

 MAINTAINERS                    |  10 +
 drivers/gpio/Kconfig           |  11 +
 drivers/gpio/Makefile          |   1 +
 drivers/gpio/gpio-usbio.c      | 247 +++++++++++
 drivers/i2c/busses/Kconfig     |  11 +
 drivers/i2c/busses/Makefile    |   1 +
 drivers/i2c/busses/i2c-usbio.c | 325 ++++++++++++++
 drivers/usb/misc/Kconfig       |  14 +
 drivers/usb/misc/Makefile      |   1 +
 drivers/usb/misc/usbio.c       | 749 +++++++++++++++++++++++++++++++++
 include/linux/usb/usbio.h      | 177 ++++++++
 11 files changed, 1547 insertions(+)
 create mode 100644 drivers/gpio/gpio-usbio.c
 create mode 100644 drivers/i2c/busses/i2c-usbio.c
 create mode 100644 drivers/usb/misc/usbio.c
 create mode 100644 include/linux/usb/usbio.h
Signature · 1 line
2.51.0
author maintainer
#1 lore raw

PATCH v4 1/3 usb: misc: Add Intel USBIO bridge driver

From: Israel Cepeda <[email protected]>

Add a driver for the Intel USBIO USB IO-expander used by the MIPI cameras on various new (Meteor Lake and later) Intel laptops.

This is an USB bridge driver which adds auxbus child devices for the GPIO, I2C and SPI functions of the USBIO chip and which exports IO-functions for the drivers for the auxbus child devices to communicate with the USBIO device's firmware.

---
Changes in v2:
- Split usbio-bridge mutex into ctrl_mutex and bulk_mutex
- Drop SPI support since this is not used on devices in the field
- Rework disconnect handling to be more robust
- Several different revisions need special casing add a quirks mechanism for this
- Stop using stdint.h (uintX_t) types
- Use __le16, __le32 type + cpu_to_le16() and friends for on wire words
- Properly check auxiliary_device_add() return value
- Some small style fixes from Sakari's review

---
 MAINTAINERS               |   8 +
 drivers/usb/misc/Kconfig  |  14 +
 drivers/usb/misc/Makefile |   1 +
 drivers/usb/misc/usbio.c  | 749 ++++++++++++++++++++++++++++++++++++++
 include/linux/usb/usbio.h | 177 +++++++++
 5 files changed, 949 insertions(+)
 create mode 100644 drivers/usb/misc/usbio.c
 create mode 100644 include/linux/usb/usbio.h
MAINTAINERS +8 -0
index d91348a66738..3410699ad0b2 100644
@@ -12694,6 +12694,14 @@ S:	Maintained
 F:	Documentation/admin-guide/pm/intel_uncore_frequency_scaling.rst
 F:	drivers/platform/x86/intel/uncore-frequency/
 
+INTEL USBIO USB I/O EXPANDER DRIVERS
+M:	Israel Cepeda <[email protected]>
+M:	Hans de Goede <[email protected]>
+R:	Sakari Ailus <[email protected]>
+S:	Maintained
+F:	drivers/usb/misc/usbio.c
+F:	include/linux/usb/usbio.h
+
 INTEL VENDOR SPECIFIC EXTENDED CAPABILITIES DRIVER
 M:	David E. Box <[email protected]>
 S:	Supported
drivers/usb/misc/Kconfig +14 -0
index 6497c4e81e95..bfe08e15d051 100644
@@ -178,6 +178,20 @@ config USB_LJCA
 	  This driver can also be built as a module. If so, the module
 	  will be called usb-ljca.
 
+config USB_USBIO
+	tristate "Intel USBIO Bridge support"
+	depends on USB && ACPI
+	select AUXILIARY_BUS
+	help
+	  This adds support for Intel USBIO drivers.
+	  This enables the USBIO bridge driver module in charge to talk
+	  to the USB device. Additional drivers such as GPIO_USBIO and
+	  I2C_USBIO must be enabled in order to use the device's full
+	  functionality.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called usbio.
+
 source "drivers/usb/misc/sisusbvga/Kconfig"
 
 config USB_LD
drivers/usb/misc/Makefile +1 -0
index 0cd5bc8f52fe..494ab0377f35 100644
@@ -12,6 +12,7 @@ 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_USBIO)			+= usbio.o
 obj-$(CONFIG_USB_IDMOUSE)		+= idmouse.o
 obj-$(CONFIG_USB_IOWARRIOR)		+= iowarrior.o
 obj-$(CONFIG_USB_ISIGHTFW)		+= isight_firmware.o
drivers/usb/misc/usbio.c new file +749 -0

749 lines not on this page · raw message

include/linux/usb/usbio.h new file +177 -0

177 lines not on this page · raw message

Signature · 1 line
2.51.0
author maintainer
#2 lore raw

PATCH v4 2/3 gpio: Add Intel USBIO GPIO driver

In reply to Hans de Goede

From: Israel Cepeda <[email protected]>

Add a a driver for the GPIO auxbus child device of the Intel USBIO USB IO-expander used by the MIPI cameras on various new (Meteor Lake and later) Intel laptops.

---
Changes in v4:
- Drop include <linux/dev_printk.h>, unneeded auxiliary_set_drvdata()

Changes in v3:
- Drop (offset >= gc->ngpio) check and make usbio_gpio_get_bank_and_pin() return void
- Propagate usbio_gpio_set() ret val in usbio_gpio_direction_output()
- Use devm_gpiochip_add_data() and drop auxiliary_driver remove() callback

Changes in v2:
- Add a config_mutex protect usbio_gpio_update_config() calls, which read-modify-write banks[x].config, racing with each other
- Adjust usbio_gpio_get() to have an int return value and propagate the usbio_control_msg() return value
- Use __le16, __le32 type + cpu_to_le16() and friends for on wire words
- Some small style fixes from Sakari's review

---
 MAINTAINERS               |   1 +
 drivers/gpio/Kconfig      |  11 ++
 drivers/gpio/Makefile     |   1 +
 drivers/gpio/gpio-usbio.c | 247 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 260 insertions(+)
 create mode 100644 drivers/gpio/gpio-usbio.c
MAINTAINERS +1 -0
index 3410699ad0b2..53694bd91861 100644
@@ -12699,6 +12699,7 @@ M:	Israel Cepeda <[email protected]>
 M:	Hans de Goede <[email protected]>
 R:	Sakari Ailus <[email protected]>
 S:	Maintained
+F:	drivers/gpio/gpio-usbio.c
 F:	drivers/usb/misc/usbio.c
 F:	include/linux/usb/usbio.h
 
drivers/gpio/Kconfig +11 -0
index e43abb322fa6..5d3ca3dd2687 100644
@@ -1448,6 +1448,17 @@ config GPIO_LJCA
 	  This driver can also be built as a module. If so, the module
 	  will be called gpio-ljca.
 
+config GPIO_USBIO
+	tristate "Intel USBIO GPIO support"
+	depends on USB_USBIO
+	default USB_USBIO
+	help
+	  Select this option to enable GPIO driver for the INTEL
+	  USBIO driver stack.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called gpio_usbio.
+
 config GPIO_LP3943
 	tristate "TI/National Semiconductor LP3943 GPIO expander"
 	depends on MFD_LP3943
drivers/gpio/Makefile +1 -0
index 379f55e9ed1e..8c55e2d5de42 100644
@@ -90,6 +90,7 @@ obj-$(CONFIG_GPIO_JANZ_TTL)		+= gpio-janz-ttl.o
 obj-$(CONFIG_GPIO_KEMPLD)		+= gpio-kempld.o
 obj-$(CONFIG_GPIO_LATCH)		+= gpio-latch.o
 obj-$(CONFIG_GPIO_LJCA) 		+= gpio-ljca.o
+obj-$(CONFIG_GPIO_USBIO) 		+= gpio-usbio.o
 obj-$(CONFIG_GPIO_LOGICVC)		+= gpio-logicvc.o
 obj-$(CONFIG_GPIO_LOONGSON1)		+= gpio-loongson1.o
 obj-$(CONFIG_GPIO_LOONGSON)		+= gpio-loongson.o
drivers/gpio/gpio-usbio.c new file +247 -0

247 lines not on this page · raw message

Signature · 1 line
2.51.0
Reviewed-by on v4 2/3
#3 lore raw

Re: [PATCH v4 2/3] gpio: Add Intel USBIO GPIO driver

Hi Hans,

thanks for your patch!

Quoted 9 lines · Hans de Goede

From: Israel Cepeda <[email protected]>

Add a a driver for the GPIO auxbus child device of the Intel USBIO USB IO-expander used by the MIPI cameras on various new (Meteor Lake and later) Intel laptops.

(...)

Quoted 6 lines
drivers/gpio/Kconfig +0 -0
@@ -1448,6 +1448,17 @@ config GPIO_LJCA
          This driver can also be built as a module. If so, the module
          will be called gpio-ljca.
 

drivers/gpio/Kconfig config GPIO_LJCA · line 1460

Quoted 10 lines
drivers/gpio/Kconfig +10 -0
+config GPIO_USBIO
+       tristate "Intel USBIO GPIO support"
+       depends on USB_USBIO
+       default USB_USBIO
+       help
+         Select this option to enable GPIO driver for the INTEL
+         USBIO driver stack.
+
+         This driver can also be built as a module. If so, the module
+         will be called gpio_usbio.

This is in the wrong submenu (and the GPIO_LJCA is in the wrong place too, but that's not your problem...)

We have:

menu "USB GPIO expanders"
depends on USB

So put it in this submeny.

Other than that it looks good, so with that change:

Yours,
Linus Walleij

author maintainer
#4 lore raw

Re: [PATCH v4 2/3] gpio: Add Intel USBIO GPIO driver

Hi,

Quoted 39 lines · Linus Walleij

Hi Hans,

thanks for your patch!

Quoted 9 lines · Hans de Goede

From: Israel Cepeda <[email protected]>

Add a a driver for the GPIO auxbus child device of the Intel USBIO USB IO-expander used by the MIPI cameras on various new (Meteor Lake and later) Intel laptops.

(...)

Quoted 6 lines
drivers/gpio/Kconfig +0 -0
@@ -1448,6 +1448,17 @@ config GPIO_LJCA
          This driver can also be built as a module. If so, the module
          will be called gpio-ljca.
 

drivers/gpio/Kconfig config GPIO_LJCA · line 1460

Quoted 10 lines
drivers/gpio/Kconfig +10 -0
+config GPIO_USBIO
+       tristate "Intel USBIO GPIO support"
+       depends on USB_USBIO
+       default USB_USBIO
+       help
+         Select this option to enable GPIO driver for the INTEL
+         USBIO driver stack.
+
+         This driver can also be built as a module. If so, the module
+         will be called gpio_usbio.

This is in the wrong submenu (and the GPIO_LJCA is in the wrong place too, but that's not your problem...)

We have:

Quoted 7 lines

menu "USB GPIO expanders"
depends on USB

So put it in this submeny.

Other than that it looks good, so with that change:

Thank you, I'll fix this for v5 and add your R-b.

Regards,

Hans

author maintainer
#5 lore raw

PATCH v4 3/3 i2c: Add Intel USBIO I2C driver

In reply to Hans de Goede

From: Israel Cepeda <[email protected]>

Add a a driver for the I2C auxbus child device of the Intel USBIO USB IO-expander used by the MIPI cameras on various new (Meteor Lake and later) Intel laptops.

---
Changes in v2:
- Use new quirks mechanism to treat various revisions differently
- Use __le16, __le32 type + cpu_to_le16() and friends for on wire words
- Some small style fixes from Sakari's review

---
 MAINTAINERS                    |   1 +
 drivers/i2c/busses/Kconfig     |  11 ++
 drivers/i2c/busses/Makefile    |   1 +
 drivers/i2c/busses/i2c-usbio.c | 325 +++++++++++++++++++++++++++++++++
 4 files changed, 338 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-usbio.c
MAINTAINERS +1 -0
index 53694bd91861..0f5de266d6df 100644
@@ -12700,6 +12700,7 @@ M:	Hans de Goede <[email protected]>
 R:	Sakari Ailus <[email protected]>
 S:	Maintained
 F:	drivers/gpio/gpio-usbio.c
+F:	drivers/i2c/busses/i2c-usbio.c
 F:	drivers/usb/misc/usbio.c
 F:	include/linux/usb/usbio.h
 
drivers/i2c/busses/Kconfig +11 -0
index 070d014fdc5d..06b1b702fd7a 100644
@@ -1357,6 +1357,17 @@ config I2C_LJCA
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-ljca.
 
+config I2C_USBIO
+	tristate "Intel USBIO I2C Adapter support"
+	depends on USB_USBIO
+	default USB_USBIO
+	help
+	  Select this option to enable I2C driver for the INTEL
+	  USBIO driver stack.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c_usbio.
+
 config I2C_CP2615
 	tristate "Silicon Labs CP2615 USB sound card and I2C adapter"
 	depends on USB
drivers/i2c/busses/Makefile +1 -0
index 04db855fdfd6..401a79c9767e 100644
@@ -135,6 +135,7 @@ obj-$(CONFIG_I2C_GXP)		+= i2c-gxp.o
 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_USBIO)		+= i2c-usbio.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-usbio.c new file +325 -0

325 lines not on this page · raw message

Signature · 1 line
2.51.0
#6 lore raw

Re: [PATCH v4 3/3] i2c: Add Intel USBIO I2C driver

Hi Hans,

drivers/i2c/busses/i2c-usbio.c line 122

Quoted 2 lines
drivers/i2c/busses/i2c-usbio.c new file +2 -0
+out_log:
+	dev_dbg(adap->dev.parent, "RD[%d]:%*phN\n", msg->len, msg->len, msg->buf);

I think this...

drivers/i2c/busses/i2c-usbio.c line 134

Quoted 12 lines
drivers/i2c/busses/i2c-usbio.c new file +12 -0
+
+	return 0;
+}
+
+static int usbio_i2c_write(struct i2c_adapter *adap, struct i2c_msg *msg)
+{
+	struct usbio_i2c *i2c = i2c_get_adapdata(adap);
+	u16 txchunk = i2c->txbuf_len - I2C_RW_OVERHEAD;
+	struct usbio_i2c_rw *wbuf = i2c->rwbuf;
+	int ret;
+
+	dev_dbg(adap->dev.parent, "WR[%d]:%*phN\n", msg->len, msg->len, msg->buf);

... and this dbg can go. The tracepoints we have should do?

drivers/i2c/busses/i2c-usbio.c line 211

Quoted 4 lines
drivers/i2c/busses/i2c-usbio.c new file +4 -0
+static u32 usbio_i2c_func(struct i2c_adapter *adap)
+{
+	return I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR | I2C_FUNC_SMBUS_EMUL;
+}

How did you test 10 bit addresses? I have never seen them in the wild?

Did you also check SMBUS_QUICK? 'i2cdetect' uses it by default.

Does the underlying USBIO driver use usb_control_msg? If so, we need to disable zero length read messages. See [1] for a reference.

Rest looks good to me!

[1] https://lore.kernel.org/all/[email protected]/

author maintainer
#7 lore raw

Re: [PATCH v4 3/3] i2c: Add Intel USBIO I2C driver

Hi Wolfram,

Thank you for the review.

Quoted 7 lines · Wolfram Sang

Hi Hans,

drivers/i2c/busses/i2c-usbio.c line 122

Quoted 2 lines
drivers/i2c/busses/i2c-usbio.c new file +2 -0
+out_log:
+	dev_dbg(adap->dev.parent, "RD[%d]:%*phN\n", msg->len, msg->len, msg->buf);

I think this...

Quoted 14 lines

drivers/i2c/busses/i2c-usbio.c line 134

Quoted 12 lines
drivers/i2c/busses/i2c-usbio.c new file +12 -0
+
+	return 0;
+}
+
+static int usbio_i2c_write(struct i2c_adapter *adap, struct i2c_msg *msg)
+{
+	struct usbio_i2c *i2c = i2c_get_adapdata(adap);
+	u16 txchunk = i2c->txbuf_len - I2C_RW_OVERHEAD;
+	struct usbio_i2c_rw *wbuf = i2c->rwbuf;
+	int ret;
+
+	dev_dbg(adap->dev.parent, "WR[%d]:%*phN\n", msg->len, msg->len, msg->buf);

... and this dbg can go. The tracepoints we have should do?

Ack, I've dropped both for the upcoming v5.

Quoted 6 lines

drivers/i2c/busses/i2c-usbio.c line 211

Quoted 4 lines
drivers/i2c/busses/i2c-usbio.c new file +4 -0
+static u32 usbio_i2c_func(struct i2c_adapter *adap)
+{
+	return I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR | I2C_FUNC_SMBUS_EMUL;
+}

How did you test 10 bit addresses? I have never seen them in the wild?

I did not test 10 bit addresses. This was there in the original code from Intel.

Quoted 1 line

Did you also check SMBUS_QUICK? 'i2cdetect' uses it by default.

I just tested this and this indeed does not work, when doing a 0 byte write then waiting for the chip to respond times-out and further i2c transfers after that also fail until the chip is power-cycled.

Quoted 2 lines

Does the underlying USBIO driver use usb_control_msg? If so, we need to disable zero length read messages. See [1] for a reference.

No it uses bulk messages.

Still based on the no support for writing 0 byte messages, I've tried a 0 byte read, since the 0 byte write was not liked much and doing i2ctransfer ... r0@0x10 results in the same problem.

So I'll add I2C_AQ_NO_ZERO_LEN to the quirks.

Regards,

Hans

#8 lore raw

Re: [PATCH v4 3/3] i2c: Add Intel USBIO I2C driver

Quoted 5 lines
Quoted 2 lines

How did you test 10 bit addresses? I have never seen them in the wild?

I did not test 10 bit addresses. This was there in the original code from Intel.

I suggest to drop it. There is no code handling the I2C_M_TEN flag which should be handled if support is advertised.

Quoted 1 line

So I'll add I2C_AQ_NO_ZERO_LEN to the quirks.

Ack.

author maintainer
#9 lore raw

Re: [PATCH v4 3/3] i2c: Add Intel USBIO I2C driver

Hi,

Quoted 8 lines · Wolfram Sang
Quoted 5 lines
Quoted 2 lines

How did you test 10 bit addresses? I have never seen them in the wild?

I did not test 10 bit addresses. This was there in the original code from Intel.

I suggest to drop it. There is no code handling the I2C_M_TEN flag which should be handled if support is advertised.

Ok, I'll drop this for v6. Hopefully that will be the last version of this series then.

Regards,

Hans