* [PATCH v3] gpio: Add Intel USBIO GPIO driver
@ 2025-09-10 12:17 Hans de Goede
2025-09-10 13:20 ` Bartosz Golaszewski
0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2025-09-10 12:17 UTC (permalink / raw)
To: Israel Cepeda, Sakari Ailus, Wolfram Sang, Andi Shyti,
Greg Kroah-Hartman, Bartosz Golaszewski, Linus Walleij
Cc: Hans de Goede, Richard Hughes, linux-i2c, linux-usb, linux-gpio
From: Israel Cepeda <israel.a.cepeda.lopez@intel.com>
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.
Co-developed-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Israel Cepeda <israel.a.cepeda.lopez@intel.com>
---
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 | 250 ++++++++++++++++++++++++++++++++++++++
4 files changed, 263 insertions(+)
create mode 100644 drivers/gpio/gpio-usbio.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 3410699ad0b2..53694bd91861 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12699,6 +12699,7 @@ M: Israel Cepeda <israel.a.cepeda.lopez@intel.com>
M: Hans de Goede <hansg@kernel.org>
R: Sakari Ailus <sakari.ailus@linux.intel.com>
S: Maintained
+F: drivers/gpio/gpio-usbio.c
F: drivers/usb/misc/usbio.c
F: include/linux/usb/usbio.h
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index e43abb322fa6..5d3ca3dd2687 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -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
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 379f55e9ed1e..8c55e2d5de42 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -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
diff --git a/drivers/gpio/gpio-usbio.c b/drivers/gpio/gpio-usbio.c
new file mode 100644
index 000000000000..31a376e91877
--- /dev/null
+++ b/drivers/gpio/gpio-usbio.c
@@ -0,0 +1,250 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2025 Intel Corporation.
+ * Copyright (c) 2025 Red Hat, Inc.
+ */
+
+#include <linux/acpi.h>
+#include <linux/auxiliary_bus.h>
+#include <linux/cleanup.h>
+#include <linux/dev_printk.h>
+#include <linux/device.h>
+#include <linux/gpio/driver.h>
+#include <linux/mutex.h>
+#include <linux/types.h>
+#include <linux/usb/usbio.h>
+
+struct usbio_gpio_bank {
+ u8 config[USBIO_GPIOSPERBANK];
+ u32 bitmap;
+};
+
+struct usbio_gpio {
+ struct mutex config_mutex; /* Protects banks[x].config */
+ struct usbio_gpio_bank banks[USBIO_MAX_GPIOBANKS];
+ struct gpio_chip gc;
+ struct auxiliary_device *adev;
+};
+
+static const struct acpi_device_id usbio_gpio_acpi_hids[] = {
+ { "INTC1007" }, /* MTL */
+ { "INTC10B2" }, /* ARL */
+ { "INTC10B5" }, /* LNL */
+ { "INTC10E2" }, /* PTL */
+ { }
+};
+
+static void usbio_gpio_get_bank_and_pin(struct gpio_chip *gc, unsigned int offset,
+ struct usbio_gpio_bank **bank_ret,
+ unsigned int *pin_ret)
+{
+ struct usbio_gpio *gpio = gpiochip_get_data(gc);
+ struct device *dev = &gpio->adev->dev;
+ struct usbio_gpio_bank *bank;
+ unsigned int pin;
+
+ bank = &gpio->banks[offset / USBIO_GPIOSPERBANK];
+ pin = offset % USBIO_GPIOSPERBANK;
+ if (~bank->bitmap & BIT(pin)) {
+ /* The FW bitmap sometimes is invalid, warn and continue */
+ dev_warn_once(dev, FW_BUG "GPIO %u is not in FW pins bitmap\n", offset);
+ }
+
+ *bank_ret = bank;
+ *pin_ret = pin;
+}
+
+static int usbio_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
+{
+ struct usbio_gpio_bank *bank;
+ unsigned int pin;
+ u8 cfg;
+
+ usbio_gpio_get_bank_and_pin(gc, offset, &bank, &pin);
+
+ cfg = bank->config[pin] & USBIO_GPIO_PINMOD_MASK;
+
+ return (cfg == USBIO_GPIO_PINMOD_OUTPUT) ?
+ GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
+}
+
+static int usbio_gpio_get(struct gpio_chip *gc, unsigned int offset)
+{
+ struct usbio_gpio *gpio = gpiochip_get_data(gc);
+ struct usbio_gpio_bank *bank;
+ struct usbio_gpio_rw gbuf;
+ unsigned int pin;
+ int ret;
+
+ usbio_gpio_get_bank_and_pin(gc, offset, &bank, &pin);
+
+ gbuf.bankid = offset / USBIO_GPIOSPERBANK;
+ gbuf.pincount = 1;
+ gbuf.pin = pin;
+
+ ret = usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_READ,
+ &gbuf, sizeof(gbuf) - sizeof(gbuf.value),
+ &gbuf, sizeof(gbuf));
+ if (ret != sizeof(gbuf))
+ return (ret < 0) ? ret : -EPROTO;
+
+ return (le32_to_cpu(gbuf.value) >> pin) & 1;
+}
+
+static int usbio_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
+{
+ struct usbio_gpio *gpio = gpiochip_get_data(gc);
+ struct usbio_gpio_bank *bank;
+ struct usbio_gpio_rw gbuf;
+ unsigned int pin;
+
+ usbio_gpio_get_bank_and_pin(gc, offset, &bank, &pin);
+
+ gbuf.bankid = offset / USBIO_GPIOSPERBANK;
+ gbuf.pincount = 1;
+ gbuf.pin = pin;
+ gbuf.value = cpu_to_le32(value << pin);
+
+ return usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_WRITE,
+ &gbuf, sizeof(gbuf), NULL, 0);
+}
+
+static int usbio_gpio_update_config(struct gpio_chip *gc, unsigned int offset,
+ u8 mask, u8 value)
+{
+ struct usbio_gpio *gpio = gpiochip_get_data(gc);
+ struct usbio_gpio_bank *bank;
+ struct usbio_gpio_init gbuf;
+ unsigned int pin;
+
+ usbio_gpio_get_bank_and_pin(gc, offset, &bank, &pin);
+
+ guard(mutex)(&gpio->config_mutex);
+
+ bank->config[pin] &= ~mask;
+ bank->config[pin] |= value;
+
+ gbuf.bankid = offset / USBIO_GPIOSPERBANK;
+ gbuf.config = bank->config[pin];
+ gbuf.pincount = 1;
+ gbuf.pin = pin;
+
+ return usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_INIT,
+ &gbuf, sizeof(gbuf), NULL, 0);
+}
+
+static int usbio_gpio_direction_input(struct gpio_chip *gc, unsigned int offset)
+{
+ return usbio_gpio_update_config(gc, offset, USBIO_GPIO_PINMOD_MASK,
+ USBIO_GPIO_SET_PINMOD(USBIO_GPIO_PINMOD_INPUT));
+}
+
+static int usbio_gpio_direction_output(struct gpio_chip *gc,
+ unsigned int offset, int value)
+{
+ int ret;
+
+ ret = usbio_gpio_update_config(gc, offset, USBIO_GPIO_PINMOD_MASK,
+ USBIO_GPIO_SET_PINMOD(USBIO_GPIO_PINMOD_OUTPUT));
+ if (ret)
+ return ret;
+
+ return usbio_gpio_set(gc, offset, value);
+}
+
+static int usbio_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
+ unsigned long config)
+{
+ u8 value;
+
+ switch (pinconf_to_config_param(config)) {
+ case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
+ value = USBIO_GPIO_SET_PINCFG(USBIO_GPIO_PINCFG_DEFAULT);
+ break;
+ case PIN_CONFIG_BIAS_PULL_UP:
+ value = USBIO_GPIO_SET_PINCFG(USBIO_GPIO_PINCFG_PULLUP);
+ break;
+ case PIN_CONFIG_BIAS_PULL_DOWN:
+ value = USBIO_GPIO_SET_PINCFG(USBIO_GPIO_PINCFG_PULLDOWN);
+ break;
+ case PIN_CONFIG_DRIVE_PUSH_PULL:
+ value = USBIO_GPIO_SET_PINCFG(USBIO_GPIO_PINCFG_PUSHPULL);
+ break;
+ default:
+ return -ENOTSUPP;
+ }
+
+ return usbio_gpio_update_config(gc, offset, USBIO_GPIO_PINCFG_MASK, value);
+}
+
+static int usbio_gpio_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *adev_id)
+{
+ struct usbio_gpio_bank_desc *bank_desc;
+ struct device *dev = &adev->dev;
+ struct usbio_gpio *gpio;
+ int bank, ret;
+
+ bank_desc = dev_get_platdata(dev);
+ if (!bank_desc)
+ return -EINVAL;
+
+ gpio = devm_kzalloc(dev, sizeof(*gpio), GFP_KERNEL);
+ if (!gpio)
+ return -ENOMEM;
+
+ ret = devm_mutex_init(dev, &gpio->config_mutex);
+ if (ret)
+ return ret;
+
+ gpio->adev = adev;
+
+ usbio_acpi_bind(gpio->adev, usbio_gpio_acpi_hids);
+
+ for (bank = 0; bank < USBIO_MAX_GPIOBANKS && bank_desc[bank].bmap; bank++)
+ gpio->banks[bank].bitmap = le32_to_cpu(bank_desc[bank].bmap);
+
+ gpio->gc.label = ACPI_COMPANION(dev) ?
+ acpi_dev_name(ACPI_COMPANION(dev)) : dev_name(dev);
+ gpio->gc.parent = dev;
+ gpio->gc.owner = THIS_MODULE;
+ gpio->gc.get_direction = usbio_gpio_get_direction;
+ gpio->gc.direction_input = usbio_gpio_direction_input;
+ gpio->gc.direction_output = usbio_gpio_direction_output;
+ gpio->gc.get = usbio_gpio_get;
+ gpio->gc.set = usbio_gpio_set;
+ gpio->gc.set_config = usbio_gpio_set_config;
+ gpio->gc.base = -1;
+ gpio->gc.ngpio = bank * USBIO_GPIOSPERBANK;
+ gpio->gc.can_sleep = true;
+
+ auxiliary_set_drvdata(adev, gpio);
+
+ ret = devm_gpiochip_add_data(dev, &gpio->gc, gpio);
+ if (ret)
+ return ret;
+
+ if (has_acpi_companion(dev))
+ acpi_dev_clear_dependencies(ACPI_COMPANION(dev));
+
+ return 0;
+}
+
+static const struct auxiliary_device_id usbio_gpio_id_table[] = {
+ { "usbio.usbio-gpio" },
+ { }
+};
+MODULE_DEVICE_TABLE(auxiliary, usbio_gpio_id_table);
+
+static struct auxiliary_driver usbio_gpio_driver = {
+ .name = USBIO_GPIO_CLIENT,
+ .probe = usbio_gpio_probe,
+ .id_table = usbio_gpio_id_table
+};
+module_auxiliary_driver(usbio_gpio_driver);
+
+MODULE_DESCRIPTION("Intel USBIO GPIO driver");
+MODULE_AUTHOR("Israel Cepeda <israel.a.cepeda.lopez@intel.com>");
+MODULE_AUTHOR("Hans de Goede <hansg@kernel.org>");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("USBIO");
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v3] gpio: Add Intel USBIO GPIO driver
2025-09-10 12:17 [PATCH v3] gpio: Add Intel USBIO GPIO driver Hans de Goede
@ 2025-09-10 13:20 ` Bartosz Golaszewski
2025-09-10 13:26 ` Hans de Goede
0 siblings, 1 reply; 3+ messages in thread
From: Bartosz Golaszewski @ 2025-09-10 13:20 UTC (permalink / raw)
To: Hans de Goede
Cc: Israel Cepeda, Sakari Ailus, Wolfram Sang, Andi Shyti,
Greg Kroah-Hartman, Linus Walleij, Richard Hughes, linux-i2c,
linux-usb, linux-gpio
On Wed, Sep 10, 2025 at 2:17 PM Hans de Goede <hansg@kernel.org> wrote:
>
> From: Israel Cepeda <israel.a.cepeda.lopez@intel.com>
>
> 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.
>
> Co-developed-by: Hans de Goede <hansg@kernel.org>
> Signed-off-by: Hans de Goede <hansg@kernel.org>
> Signed-off-by: Israel Cepeda <israel.a.cepeda.lopez@intel.com>
> ---
> 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 | 250 ++++++++++++++++++++++++++++++++++++++
> 4 files changed, 263 insertions(+)
> create mode 100644 drivers/gpio/gpio-usbio.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 3410699ad0b2..53694bd91861 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -12699,6 +12699,7 @@ M: Israel Cepeda <israel.a.cepeda.lopez@intel.com>
> M: Hans de Goede <hansg@kernel.org>
> R: Sakari Ailus <sakari.ailus@linux.intel.com>
> S: Maintained
> +F: drivers/gpio/gpio-usbio.c
> F: drivers/usb/misc/usbio.c
> F: include/linux/usb/usbio.h
>
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index e43abb322fa6..5d3ca3dd2687 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -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
> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index 379f55e9ed1e..8c55e2d5de42 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -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
> diff --git a/drivers/gpio/gpio-usbio.c b/drivers/gpio/gpio-usbio.c
> new file mode 100644
> index 000000000000..31a376e91877
> --- /dev/null
> +++ b/drivers/gpio/gpio-usbio.c
> @@ -0,0 +1,250 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2025 Intel Corporation.
> + * Copyright (c) 2025 Red Hat, Inc.
> + */
> +
> +#include <linux/acpi.h>
> +#include <linux/auxiliary_bus.h>
> +#include <linux/cleanup.h>
> +#include <linux/dev_printk.h>
No need to pull this if you include device.h.
> + usbio_acpi_bind(gpio->adev, usbio_gpio_acpi_hids);
> +
> + for (bank = 0; bank < USBIO_MAX_GPIOBANKS && bank_desc[bank].bmap; bank++)
> + gpio->banks[bank].bitmap = le32_to_cpu(bank_desc[bank].bmap);
> +
> + gpio->gc.label = ACPI_COMPANION(dev) ?
> + acpi_dev_name(ACPI_COMPANION(dev)) : dev_name(dev);
> + gpio->gc.parent = dev;
> + gpio->gc.owner = THIS_MODULE;
> + gpio->gc.get_direction = usbio_gpio_get_direction;
> + gpio->gc.direction_input = usbio_gpio_direction_input;
> + gpio->gc.direction_output = usbio_gpio_direction_output;
> + gpio->gc.get = usbio_gpio_get;
> + gpio->gc.set = usbio_gpio_set;
> + gpio->gc.set_config = usbio_gpio_set_config;
> + gpio->gc.base = -1;
> + gpio->gc.ngpio = bank * USBIO_GPIOSPERBANK;
> + gpio->gc.can_sleep = true;
> +
> + auxiliary_set_drvdata(adev, gpio);
> +
Now you no longer need this as there's no remove() anymore.
Bart
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] gpio: Add Intel USBIO GPIO driver
2025-09-10 13:20 ` Bartosz Golaszewski
@ 2025-09-10 13:26 ` Hans de Goede
0 siblings, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2025-09-10 13:26 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Israel Cepeda, Sakari Ailus, Wolfram Sang, Andi Shyti,
Greg Kroah-Hartman, Linus Walleij, Richard Hughes, linux-i2c,
linux-usb, linux-gpio
Hi,
On 10-Sep-25 3:20 PM, Bartosz Golaszewski wrote:
> On Wed, Sep 10, 2025 at 2:17 PM Hans de Goede <hansg@kernel.org> wrote:
>>
>> From: Israel Cepeda <israel.a.cepeda.lopez@intel.com>
>>
>> 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.
>>
>> Co-developed-by: Hans de Goede <hansg@kernel.org>
>> Signed-off-by: Hans de Goede <hansg@kernel.org>
>> Signed-off-by: Israel Cepeda <israel.a.cepeda.lopez@intel.com>
>> ---
>> 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 | 250 ++++++++++++++++++++++++++++++++++++++
>> 4 files changed, 263 insertions(+)
>> create mode 100644 drivers/gpio/gpio-usbio.c
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 3410699ad0b2..53694bd91861 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -12699,6 +12699,7 @@ M: Israel Cepeda <israel.a.cepeda.lopez@intel.com>
>> M: Hans de Goede <hansg@kernel.org>
>> R: Sakari Ailus <sakari.ailus@linux.intel.com>
>> S: Maintained
>> +F: drivers/gpio/gpio-usbio.c
>> F: drivers/usb/misc/usbio.c
>> F: include/linux/usb/usbio.h
>>
>> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
>> index e43abb322fa6..5d3ca3dd2687 100644
>> --- a/drivers/gpio/Kconfig
>> +++ b/drivers/gpio/Kconfig
>> @@ -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
>> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
>> index 379f55e9ed1e..8c55e2d5de42 100644
>> --- a/drivers/gpio/Makefile
>> +++ b/drivers/gpio/Makefile
>> @@ -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
>> diff --git a/drivers/gpio/gpio-usbio.c b/drivers/gpio/gpio-usbio.c
>> new file mode 100644
>> index 000000000000..31a376e91877
>> --- /dev/null
>> +++ b/drivers/gpio/gpio-usbio.c
>> @@ -0,0 +1,250 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (c) 2025 Intel Corporation.
>> + * Copyright (c) 2025 Red Hat, Inc.
>> + */
>> +
>> +#include <linux/acpi.h>
>> +#include <linux/auxiliary_bus.h>
>> +#include <linux/cleanup.h>
>> +#include <linux/dev_printk.h>
>
> No need to pull this if you include device.h.
Ok, I'll fix this for v4, which I will delay till
I've a full v4 series to send.
>
>> + usbio_acpi_bind(gpio->adev, usbio_gpio_acpi_hids);
>> +
>> + for (bank = 0; bank < USBIO_MAX_GPIOBANKS && bank_desc[bank].bmap; bank++)
>> + gpio->banks[bank].bitmap = le32_to_cpu(bank_desc[bank].bmap);
>> +
>> + gpio->gc.label = ACPI_COMPANION(dev) ?
>> + acpi_dev_name(ACPI_COMPANION(dev)) : dev_name(dev);
>> + gpio->gc.parent = dev;
>> + gpio->gc.owner = THIS_MODULE;
>> + gpio->gc.get_direction = usbio_gpio_get_direction;
>> + gpio->gc.direction_input = usbio_gpio_direction_input;
>> + gpio->gc.direction_output = usbio_gpio_direction_output;
>> + gpio->gc.get = usbio_gpio_get;
>> + gpio->gc.set = usbio_gpio_set;
>> + gpio->gc.set_config = usbio_gpio_set_config;
>> + gpio->gc.base = -1;
>> + gpio->gc.ngpio = bank * USBIO_GPIOSPERBANK;
>> + gpio->gc.can_sleep = true;
>> +
>> + auxiliary_set_drvdata(adev, gpio);
>> +
>
> Now you no longer need this as there's no remove() anymore.
Ack, I'll fix this for v4.
Regards,
Hans
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-10 13:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-10 12:17 [PATCH v3] gpio: Add Intel USBIO GPIO driver Hans de Goede
2025-09-10 13:20 ` Bartosz Golaszewski
2025-09-10 13:26 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox