public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C
@ 2025-09-15  6:01 Svyatoslav Ryhel
  2025-09-15  6:01 ` [PATCH v1 1/2] dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus Svyatoslav Ryhel
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-09-15  6:01 UTC (permalink / raw)
  To: Andi Shyti, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Peter Rosin, Michał Mirosław, Svyatoslav Ryhel,
	Jonas Schwöbel
  Cc: linux-i2c, devicetree, linux-kernel

Implement driver for hot-plugged I2C busses, where some devices on
a bus are hot-pluggable and their presence is indicated by GPIO line.
This feature is used by the ASUS Transformers family, by the  Microsoft
Surface RT/2 and maybe more.

ASUS Transformers expose i2c line via proprietary 40 pin plug and wire
that line through optional dock accessory. Devices in the dock are
connected to this i2c line and docks presence is detected by a dedicted
GPIO.

Michał Mirosław (1):
  i2c: muxes: Add GPIO-detected hotplug I2C

Svyatoslav Ryhel (1):
  dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus

 .../bindings/i2c/i2c-hotplug-gpio.yaml        |  65 +++++
 drivers/i2c/muxes/Kconfig                     |  11 +
 drivers/i2c/muxes/Makefile                    |   1 +
 drivers/i2c/muxes/i2c-hotplug-gpio.c          | 263 ++++++++++++++++++
 4 files changed, 340 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml
 create mode 100644 drivers/i2c/muxes/i2c-hotplug-gpio.c

-- 
2.48.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v1 1/2] dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus
  2025-09-15  6:01 [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C Svyatoslav Ryhel
@ 2025-09-15  6:01 ` Svyatoslav Ryhel
  2025-09-15  6:01 ` [PATCH v1 2/2] i2c: muxes: Add GPIO-detected hotplug I2C Svyatoslav Ryhel
  2025-09-15 11:35 ` [PATCH v1 0/2] " Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-09-15  6:01 UTC (permalink / raw)
  To: Andi Shyti, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Peter Rosin, Michał Mirosław, Svyatoslav Ryhel,
	Jonas Schwöbel
  Cc: linux-i2c, devicetree, linux-kernel

Schema describes hardware configuration that uses a GPIO signal to
determine the bus's presence and state, allowing the system to dynamically
configure I2C devices as they are plugged in or removed.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 .../bindings/i2c/i2c-hotplug-gpio.yaml        | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml

diff --git a/Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml b/Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml
new file mode 100644
index 000000000000..d1d5d830c91b
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/i2c-hotplug-gpio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: GPIO detected hot-plugged I2C bus
+
+maintainers:
+  - Michał Mirosław <mirq-linux@rere.qmqm.pl>
+  - Svyatoslav Ryhel <clamor95@gmail.com>
+
+description: An I2C bus, where some devices on the bus are hot-pluggable
+  and their presence is indicated by GPIO line.
+
+properties:
+  compatible:
+    const: i2c-hotplug-gpio
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+  interrupts:
+    maxItems: 1
+
+  detect-gpios:
+    description: usually the same GPIO used as an interrupt. In the active
+      state should indicate that detachable devices are plugged in.
+    maxItems: 1
+
+  i2c-parent:
+    maxItems: 1
+
+required:
+  - compatible
+  - '#address-cells'
+  - '#size-cells'
+  - interrupts
+  - detect-gpios
+  - i2c-parent
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c-dock {
+        compatible = "i2c-hotplug-gpio";
+
+        interrupt-parent = <&gpio>;
+        interrupts = <164 IRQ_TYPE_EDGE_BOTH>;
+
+        detect-gpios = <&gpio 164 GPIO_ACTIVE_LOW>;
+
+        i2c-parent = <&gen2_i2c>;
+
+        #address-cells = <1>;
+        #size-cells = <0>;
+    };
+...
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 2/2] i2c: muxes: Add GPIO-detected hotplug I2C
  2025-09-15  6:01 [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C Svyatoslav Ryhel
  2025-09-15  6:01 ` [PATCH v1 1/2] dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus Svyatoslav Ryhel
@ 2025-09-15  6:01 ` Svyatoslav Ryhel
  2025-09-15 11:35 ` [PATCH v1 0/2] " Wolfram Sang
  2 siblings, 0 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-09-15  6:01 UTC (permalink / raw)
  To: Andi Shyti, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Peter Rosin, Michał Mirosław, Svyatoslav Ryhel,
	Jonas Schwöbel
  Cc: linux-i2c, devicetree, linux-kernel

From: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Add support for hot-plugged I2C busses, where some devices on the bus are
hot-pluggable and their presence is indicated by GPIO line.

This feature is used by the ASUS Transformers, Microsoft Surface RT/2 and
maybe more.

Co-developed-by: Ion Agorria <ion@agorria.com>
Signed-off-by: Ion Agorria <ion@agorria.com>
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/i2c/muxes/Kconfig            |  11 ++
 drivers/i2c/muxes/Makefile           |   1 +
 drivers/i2c/muxes/i2c-hotplug-gpio.c | 263 +++++++++++++++++++++++++++
 3 files changed, 275 insertions(+)
 create mode 100644 drivers/i2c/muxes/i2c-hotplug-gpio.c

diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig
index 6d2f66810cdc..0e410be5ce55 100644
--- a/drivers/i2c/muxes/Kconfig
+++ b/drivers/i2c/muxes/Kconfig
@@ -19,6 +19,17 @@ config I2C_ARB_GPIO_CHALLENGE
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-arb-gpio-challenge.
 
+config I2C_HOTPLUG_GPIO
+	tristate "Hot-plugged I2C bus detected by GPIO"
+	depends on GPIOLIB
+	depends on OF
+	help
+	  Say Y here if you want support for hot-plugging I2C devices
+	  with presence detected by GPIO pin value.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called i2c-hotplug-gpio.
+
 config I2C_MUX_GPIO
 	tristate "GPIO-based I2C multiplexer"
 	depends on GPIOLIB
diff --git a/drivers/i2c/muxes/Makefile b/drivers/i2c/muxes/Makefile
index 4b24f49515a7..36df41c8cf05 100644
--- a/drivers/i2c/muxes/Makefile
+++ b/drivers/i2c/muxes/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_I2C_ARB_GPIO_CHALLENGE)	+= i2c-arb-gpio-challenge.o
 
 obj-$(CONFIG_I2C_DEMUX_PINCTRL)		+= i2c-demux-pinctrl.o
 
+obj-$(CONFIG_I2C_HOTPLUG_GPIO)	+= i2c-hotplug-gpio.o
 obj-$(CONFIG_I2C_MUX_GPIO)	+= i2c-mux-gpio.o
 obj-$(CONFIG_I2C_MUX_GPMUX)	+= i2c-mux-gpmux.o
 obj-$(CONFIG_I2C_MUX_LTC4306)	+= i2c-mux-ltc4306.o
diff --git a/drivers/i2c/muxes/i2c-hotplug-gpio.c b/drivers/i2c/muxes/i2c-hotplug-gpio.c
new file mode 100644
index 000000000000..7f56964e285e
--- /dev/null
+++ b/drivers/i2c/muxes/i2c-hotplug-gpio.c
@@ -0,0 +1,263 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+struct i2c_hotplug_priv {
+	struct i2c_adapter adap;
+	struct i2c_adapter *parent;
+	struct device *dev;
+	struct gpio_desc *gpio;
+	int irq;
+};
+
+static inline struct i2c_adapter *i2c_hotplug_parent(struct i2c_adapter *adap)
+{
+	struct i2c_hotplug_priv *priv = container_of(adap, struct i2c_hotplug_priv, adap);
+
+	return priv->parent;
+}
+
+static int i2c_hotplug_master_xfer(struct i2c_adapter *adap,
+				   struct i2c_msg msgs[], int num)
+{
+	struct i2c_adapter *parent = i2c_hotplug_parent(adap);
+
+	return parent->algo->master_xfer(parent, msgs, num);
+}
+
+static int i2c_hotplug_smbus_xfer(struct i2c_adapter *adap, u16 addr,
+				  unsigned short flags, char read_write,
+				  u8 command, int protocol,
+				  union i2c_smbus_data *data)
+{
+	struct i2c_adapter *parent = i2c_hotplug_parent(adap);
+
+	return parent->algo->smbus_xfer(parent, addr, flags, read_write,
+					command, protocol, data);
+}
+
+static u32 i2c_hotplug_functionality(struct i2c_adapter *adap)
+{
+	u32 parent_func = i2c_get_functionality(i2c_hotplug_parent(adap));
+
+	return parent_func & ~I2C_FUNC_SLAVE;
+}
+
+static const struct i2c_algorithm i2c_hotplug_algo_i2c = {
+	.master_xfer = i2c_hotplug_master_xfer,
+	.functionality = i2c_hotplug_functionality,
+};
+
+static const struct i2c_algorithm i2c_hotplug_algo_smbus = {
+	.smbus_xfer = i2c_hotplug_smbus_xfer,
+	.functionality = i2c_hotplug_functionality,
+};
+
+static const struct i2c_algorithm i2c_hotplug_algo_both = {
+	.master_xfer = i2c_hotplug_master_xfer,
+	.smbus_xfer = i2c_hotplug_smbus_xfer,
+	.functionality = i2c_hotplug_functionality,
+};
+
+static const struct i2c_algorithm *const i2c_hotplug_algo[2][2] = {
+	/* non-I2C */
+	{ NULL, &i2c_hotplug_algo_smbus },
+	/* I2C */
+	{ &i2c_hotplug_algo_i2c, &i2c_hotplug_algo_both }
+};
+
+static void i2c_hotplug_lock_bus(struct i2c_adapter *adap, unsigned int flags)
+{
+	i2c_lock_bus(i2c_hotplug_parent(adap), flags);
+}
+
+static int i2c_hotplug_trylock_bus(struct i2c_adapter *adap,
+				   unsigned int flags)
+{
+	return i2c_trylock_bus(i2c_hotplug_parent(adap), flags);
+}
+
+static void i2c_hotplug_unlock_bus(struct i2c_adapter *adap,
+				   unsigned int flags)
+{
+	i2c_unlock_bus(i2c_hotplug_parent(adap), flags);
+}
+
+static const struct i2c_lock_operations i2c_hotplug_lock_ops = {
+	.lock_bus = i2c_hotplug_lock_bus,
+	.trylock_bus = i2c_hotplug_trylock_bus,
+	.unlock_bus = i2c_hotplug_unlock_bus,
+};
+
+static int i2c_hotplug_recover_bus(struct i2c_adapter *adap)
+{
+	return i2c_recover_bus(i2c_hotplug_parent(adap));
+}
+
+static struct i2c_bus_recovery_info i2c_hotplug_recovery_info = {
+	.recover_bus = i2c_hotplug_recover_bus,
+};
+
+static int i2c_hotplug_activate(struct i2c_hotplug_priv *priv)
+{
+	int ret;
+
+	if (priv->adap.algo_data)
+		return 0;
+
+	/*
+	 * Store the dev data in adapter dev, since
+	 * previous i2c_del_adapter might have wiped it.
+	 */
+	priv->adap.dev.parent = priv->dev;
+	priv->adap.dev.of_node = priv->dev->of_node;
+
+	dev_dbg(priv->adap.dev.parent, "connection detected");
+
+	ret = i2c_add_adapter(&priv->adap);
+	if (!ret)
+		priv->adap.algo_data = (void *)1;
+
+	return ret;
+}
+
+static void i2c_hotplug_deactivate(struct i2c_hotplug_priv *priv)
+{
+	if (!priv->adap.algo_data)
+		return;
+
+	dev_dbg(priv->adap.dev.parent, "disconnection detected");
+
+	i2c_del_adapter(&priv->adap);
+	priv->adap.algo_data = NULL;
+}
+
+static irqreturn_t i2c_hotplug_interrupt(int irq, void *dev_id)
+{
+	struct i2c_hotplug_priv *priv = dev_id;
+
+	/* debounce */
+	msleep(20);
+
+	if (gpiod_get_value_cansleep(priv->gpio))
+		i2c_hotplug_activate(priv);
+	else
+		i2c_hotplug_deactivate(priv);
+
+	return IRQ_HANDLED;
+}
+
+static void wrap_i2c_put_adapter(void *adapter)
+{
+	i2c_put_adapter(adapter);
+}
+
+static void wrap_i2c_hotplug_deactivate(void *priv)
+{
+	i2c_hotplug_deactivate(priv);
+}
+
+static int i2c_hotplug_gpio_probe(struct platform_device *pdev)
+{
+	struct device_node *parent_np;
+	struct i2c_adapter *parent;
+	struct i2c_hotplug_priv *priv;
+	bool is_i2c, is_smbus;
+	int err;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, priv);
+	priv->dev = &pdev->dev;
+
+	parent_np = of_parse_phandle(pdev->dev.of_node, "i2c-parent", 0);
+	if (IS_ERR(parent_np))
+		return dev_err_probe(&pdev->dev, PTR_ERR(parent_np),
+				     "cannot parse i2c-parent\n");
+
+	parent = of_find_i2c_adapter_by_node(parent_np);
+	of_node_put(parent_np);
+	if (IS_ERR(parent))
+		return dev_err_probe(&pdev->dev, PTR_ERR(parent),
+				     "failed to get parent I2C adapter\n");
+	priv->parent = parent;
+
+	err = devm_add_action_or_reset(&pdev->dev, wrap_i2c_put_adapter,
+				       parent);
+	if (err)
+		return err;
+
+	priv->gpio = devm_gpiod_get(&pdev->dev, "detect", GPIOD_IN);
+	if (IS_ERR(priv->gpio))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->gpio),
+				     "failed to get detect GPIO\n");
+
+	is_i2c = parent->algo->master_xfer;
+	is_smbus = parent->algo->smbus_xfer;
+
+	snprintf(priv->adap.name, sizeof(priv->adap.name),
+		 "i2c-hotplug (master i2c-%d)", i2c_adapter_id(parent));
+	priv->adap.owner = THIS_MODULE;
+	priv->adap.algo = i2c_hotplug_algo[is_i2c][is_smbus];
+	priv->adap.algo_data = NULL;
+	priv->adap.lock_ops = &i2c_hotplug_lock_ops;
+	priv->adap.class = parent->class;
+	priv->adap.retries = parent->retries;
+	priv->adap.timeout = parent->timeout;
+	priv->adap.quirks = parent->quirks;
+	if (parent->bus_recovery_info)
+		/* .bus_recovery_info is not const, but won't be modified */
+		priv->adap.bus_recovery_info = (void *)&i2c_hotplug_recovery_info;
+
+	if (!priv->adap.algo)
+		return -EINVAL;
+
+	err = devm_add_action_or_reset(&pdev->dev, wrap_i2c_hotplug_deactivate, priv);
+	if (err)
+		return err;
+
+	priv->irq = platform_get_irq(pdev, 0);
+	if (priv->irq < 0)
+		return dev_err_probe(&pdev->dev, priv->irq,
+				     "failed to get IRQ %d\n", priv->irq);
+
+	err = devm_request_threaded_irq(&pdev->dev, priv->irq, NULL,
+					i2c_hotplug_interrupt,
+					IRQF_ONESHOT | IRQF_SHARED,
+					"i2c-hotplug", priv);
+	if (err)
+		return dev_err_probe(&pdev->dev, err,
+				     "failed to register IRQ %d\n", priv->irq);
+
+	irq_wake_thread(priv->irq, priv);
+
+	return 0;
+}
+
+static const struct of_device_id i2c_hotplug_gpio_of_match[] = {
+	{ .compatible = "i2c-hotplug-gpio" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, i2c_hotplug_gpio_of_match);
+
+static struct platform_driver i2c_hotplug_gpio_driver = {
+	.driver	= {
+		.name = "i2c-hotplug-gpio",
+		.of_match_table = i2c_hotplug_gpio_of_match,
+	},
+	.probe = i2c_hotplug_gpio_probe,
+};
+
+module_platform_driver(i2c_hotplug_gpio_driver);
+
+MODULE_DESCRIPTION("Hot-plugged I2C bus detected by GPIO");
+MODULE_AUTHOR("Michał Mirosław <mirq-linux@rere.qmqm.pl>");
+MODULE_LICENSE("GPL");
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C
  2025-09-15  6:01 [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C Svyatoslav Ryhel
  2025-09-15  6:01 ` [PATCH v1 1/2] dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus Svyatoslav Ryhel
  2025-09-15  6:01 ` [PATCH v1 2/2] i2c: muxes: Add GPIO-detected hotplug I2C Svyatoslav Ryhel
@ 2025-09-15 11:35 ` Wolfram Sang
  2025-09-15 11:53   ` Svyatoslav Ryhel
  2 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2025-09-15 11:35 UTC (permalink / raw)
  To: Svyatoslav Ryhel, Herve Codina, Luca Ceresoli
  Cc: Andi Shyti, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Peter Rosin, Michał Mirosław, Jonas Schwöbel,
	linux-i2c, devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]

On Mon, Sep 15, 2025 at 09:01:36AM +0300, Svyatoslav Ryhel wrote:
> Implement driver for hot-plugged I2C busses, where some devices on
> a bus are hot-pluggable and their presence is indicated by GPIO line.
> This feature is used by the ASUS Transformers family, by the  Microsoft
> Surface RT/2 and maybe more.
> 
> ASUS Transformers expose i2c line via proprietary 40 pin plug and wire
> that line through optional dock accessory. Devices in the dock are
> connected to this i2c line and docks presence is detected by a dedicted
> GPIO.
> 
> Michał Mirosław (1):
>   i2c: muxes: Add GPIO-detected hotplug I2C
> 
> Svyatoslav Ryhel (1):
>   dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus
> 
>  .../bindings/i2c/i2c-hotplug-gpio.yaml        |  65 +++++
>  drivers/i2c/muxes/Kconfig                     |  11 +
>  drivers/i2c/muxes/Makefile                    |   1 +
>  drivers/i2c/muxes/i2c-hotplug-gpio.c          | 263 ++++++++++++++++++
>  4 files changed, 340 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml
>  create mode 100644 drivers/i2c/muxes/i2c-hotplug-gpio.c

Adding Herve and Luca to CC because they want to achieve the same with
their I2C bus extensions, no?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C
  2025-09-15 11:35 ` [PATCH v1 0/2] " Wolfram Sang
@ 2025-09-15 11:53   ` Svyatoslav Ryhel
  2025-09-15 15:42     ` Wolfram Sang
  0 siblings, 1 reply; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-09-15 11:53 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Herve Codina, Luca Ceresoli, Andi Shyti, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Peter Rosin,
	Michał Mirosław, Jonas Schwöbel, linux-i2c,
	devicetree, linux-kernel

пн, 15 вер. 2025 р. о 14:35 Wolfram Sang
<wsa+renesas@sang-engineering.com> пише:
>
> On Mon, Sep 15, 2025 at 09:01:36AM +0300, Svyatoslav Ryhel wrote:
> > Implement driver for hot-plugged I2C busses, where some devices on
> > a bus are hot-pluggable and their presence is indicated by GPIO line.
> > This feature is used by the ASUS Transformers family, by the  Microsoft
> > Surface RT/2 and maybe more.
> >
> > ASUS Transformers expose i2c line via proprietary 40 pin plug and wire
> > that line through optional dock accessory. Devices in the dock are
> > connected to this i2c line and docks presence is detected by a dedicted
> > GPIO.
> >
> > Michał Mirosław (1):
> >   i2c: muxes: Add GPIO-detected hotplug I2C
> >
> > Svyatoslav Ryhel (1):
> >   dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus
> >
> >  .../bindings/i2c/i2c-hotplug-gpio.yaml        |  65 +++++
> >  drivers/i2c/muxes/Kconfig                     |  11 +
> >  drivers/i2c/muxes/Makefile                    |   1 +
> >  drivers/i2c/muxes/i2c-hotplug-gpio.c          | 263 ++++++++++++++++++
> >  4 files changed, 340 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml
> >  create mode 100644 drivers/i2c/muxes/i2c-hotplug-gpio.c
>
> Adding Herve and Luca to CC because they want to achieve the same with
> their I2C bus extensions, no?
>

I have no idea what you are talking about, this an original series I
have sent 2 years ago but now I decided that would be nice to have it
in mainline Linux.  Here is a link to patchset from 19th Jun 2023
https://lkml.org/lkml/2023/6/19/781

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C
  2025-09-15 11:53   ` Svyatoslav Ryhel
@ 2025-09-15 15:42     ` Wolfram Sang
  2025-09-16  6:19       ` Herve Codina
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2025-09-15 15:42 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Herve Codina, Luca Ceresoli, Andi Shyti, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Peter Rosin,
	Michał Mirosław, Jonas Schwöbel, linux-i2c,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1739 bytes --]

On Mon, Sep 15, 2025 at 02:53:23PM +0300, Svyatoslav Ryhel wrote:
> пн, 15 вер. 2025 р. о 14:35 Wolfram Sang
> <wsa+renesas@sang-engineering.com> пише:
> >
> > On Mon, Sep 15, 2025 at 09:01:36AM +0300, Svyatoslav Ryhel wrote:
> > > Implement driver for hot-plugged I2C busses, where some devices on
> > > a bus are hot-pluggable and their presence is indicated by GPIO line.
> > > This feature is used by the ASUS Transformers family, by the  Microsoft
> > > Surface RT/2 and maybe more.
> > >
> > > ASUS Transformers expose i2c line via proprietary 40 pin plug and wire
> > > that line through optional dock accessory. Devices in the dock are
> > > connected to this i2c line and docks presence is detected by a dedicted
> > > GPIO.
> > >
> > > Michał Mirosław (1):
> > >   i2c: muxes: Add GPIO-detected hotplug I2C
> > >
> > > Svyatoslav Ryhel (1):
> > >   dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus
> > >
> > >  .../bindings/i2c/i2c-hotplug-gpio.yaml        |  65 +++++
> > >  drivers/i2c/muxes/Kconfig                     |  11 +
> > >  drivers/i2c/muxes/Makefile                    |   1 +
> > >  drivers/i2c/muxes/i2c-hotplug-gpio.c          | 263 ++++++++++++++++++
> > >  4 files changed, 340 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml
> > >  create mode 100644 drivers/i2c/muxes/i2c-hotplug-gpio.c
> >
> > Adding Herve and Luca to CC because they want to achieve the same with
> > their I2C bus extensions, no?

Sorry, a misunderstanding: the question was for Herve and Luca. I wanted
to ask for a comment from them if this is the same problem (which I
think it is). The question was not meant for you.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C
  2025-09-15 15:42     ` Wolfram Sang
@ 2025-09-16  6:19       ` Herve Codina
  2025-09-16  7:50         ` Luca Ceresoli
  0 siblings, 1 reply; 9+ messages in thread
From: Herve Codina @ 2025-09-16  6:19 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Svyatoslav Ryhel, Luca Ceresoli, Andi Shyti, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Peter Rosin,
	Michał Mirosław, Jonas Schwöbel, linux-i2c,
	devicetree, linux-kernel

Hi Wolfram,

On Mon, 15 Sep 2025 17:42:06 +0200
Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:

> On Mon, Sep 15, 2025 at 02:53:23PM +0300, Svyatoslav Ryhel wrote:
> > пн, 15 вер. 2025 р. о 14:35 Wolfram Sang
> > <wsa+renesas@sang-engineering.com> пише:  
> > >
> > > On Mon, Sep 15, 2025 at 09:01:36AM +0300, Svyatoslav Ryhel wrote:  
> > > > Implement driver for hot-plugged I2C busses, where some devices on
> > > > a bus are hot-pluggable and their presence is indicated by GPIO line.
> > > > This feature is used by the ASUS Transformers family, by the  Microsoft
> > > > Surface RT/2 and maybe more.
> > > >
> > > > ASUS Transformers expose i2c line via proprietary 40 pin plug and wire
> > > > that line through optional dock accessory. Devices in the dock are
> > > > connected to this i2c line and docks presence is detected by a dedicted
> > > > GPIO.
> > > >
> > > > Michał Mirosław (1):
> > > >   i2c: muxes: Add GPIO-detected hotplug I2C
> > > >
> > > > Svyatoslav Ryhel (1):
> > > >   dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus
> > > >
> > > >  .../bindings/i2c/i2c-hotplug-gpio.yaml        |  65 +++++
> > > >  drivers/i2c/muxes/Kconfig                     |  11 +
> > > >  drivers/i2c/muxes/Makefile                    |   1 +
> > > >  drivers/i2c/muxes/i2c-hotplug-gpio.c          | 263 ++++++++++++++++++
> > > >  4 files changed, 340 insertions(+)
> > > >  create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml
> > > >  create mode 100644 drivers/i2c/muxes/i2c-hotplug-gpio.c  
> > >
> > > Adding Herve and Luca to CC because they want to achieve the same with
> > > their I2C bus extensions, no?  
> 
> Sorry, a misunderstanding: the question was for Herve and Luca. I wanted
> to ask for a comment from them if this is the same problem (which I
> think it is). The question was not meant for you.
> 

Indeed, we try to handle the same use case.

The i2c-hotplug-gpio.c driver handles only an connector with an I2C bus.

On our side, we try to have something more generic that can handle more
than one I2C and some other busses and resources (gpio, pwm, ...) wired
to a connector.

To move this i2c-hotplug-gpio to our proposal direction, this should become
a connector driver with a i2c bus extension and an addon DT describing the
i2c devices available on the addon board.

The connector driver should monitor the gpio and apply the addon DT when it
detects the addon plugged.

Also, I am waiting for conclusions in the export symbols discussion [1] to
re-spin the i2c bus extension series.

Best regards,
Hervé

[1]: https://lore.kernel.org/all/20250902105710.00512c6d@booty/

-- 
Hervé Codina, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C
  2025-09-16  6:19       ` Herve Codina
@ 2025-09-16  7:50         ` Luca Ceresoli
  2025-09-16  8:11           ` Svyatoslav Ryhel
  0 siblings, 1 reply; 9+ messages in thread
From: Luca Ceresoli @ 2025-09-16  7:50 UTC (permalink / raw)
  To: Herve Codina, Wolfram Sang
  Cc: Svyatoslav Ryhel, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Peter Rosin, Michał Mirosław,
	Jonas Schwöbel, linux-i2c, devicetree, linux-kernel,
	luca.ceresoli

Hello,

thanks Wolfram for pulling Hervé and me in.

+Cc my Bootlin e-mail address

Il 16/09/25 08:19, Herve Codina ha scritto:
> Hi Wolfram,
> 
> On Mon, 15 Sep 2025 17:42:06 +0200
> Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:
> 
>> On Mon, Sep 15, 2025 at 02:53:23PM +0300, Svyatoslav Ryhel wrote:
>>> пн, 15 вер. 2025 р. о 14:35 Wolfram Sang
>>> <wsa+renesas@sang-engineering.com> пише:  
>>>>
>>>> On Mon, Sep 15, 2025 at 09:01:36AM +0300, Svyatoslav Ryhel wrote:  
>>>>> Implement driver for hot-plugged I2C busses, where some devices on
>>>>> a bus are hot-pluggable and their presence is indicated by GPIO line.
>>>>> This feature is used by the ASUS Transformers family, by the  Microsoft
>>>>> Surface RT/2 and maybe more.
>>>>>
>>>>> ASUS Transformers expose i2c line via proprietary 40 pin plug and wire
>>>>> that line through optional dock accessory. Devices in the dock are
>>>>> connected to this i2c line and docks presence is detected by a dedicted
>>>>> GPIO.
>>>>>
>>>>> Michał Mirosław (1):
>>>>>   i2c: muxes: Add GPIO-detected hotplug I2C
>>>>>
>>>>> Svyatoslav Ryhel (1):
>>>>>   dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus
>>>>>
>>>>>  .../bindings/i2c/i2c-hotplug-gpio.yaml        |  65 +++++
>>>>>  drivers/i2c/muxes/Kconfig                     |  11 +
>>>>>  drivers/i2c/muxes/Makefile                    |   1 +
>>>>>  drivers/i2c/muxes/i2c-hotplug-gpio.c          | 263 ++++++++++++++++++
>>>>>  4 files changed, 340 insertions(+)
>>>>>  create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml
>>>>>  create mode 100644 drivers/i2c/muxes/i2c-hotplug-gpio.c  
>>>>
>>>> Adding Herve and Luca to CC because they want to achieve the same with
>>>> their I2C bus extensions, no?  
>>
>> Sorry, a misunderstanding: the question was for Herve and Luca. I wanted
>> to ask for a comment from them if this is the same problem (which I
>> think it is). The question was not meant for you.
>>
> 
> Indeed, we try to handle the same use case.
> 
> The i2c-hotplug-gpio.c driver handles only an connector with an I2C bus.
> 
> On our side, we try to have something more generic that can handle more
> than one I2C and some other busses and resources (gpio, pwm, ...) wired
> to a connector.
> 
> To move this i2c-hotplug-gpio to our proposal direction, this should become
> a connector driver with a i2c bus extension and an addon DT describing the
> i2c devices available on the addon board.
> 
> The connector driver should monitor the gpio and apply the addon DT when it
> detects the addon plugged.
> 
> Also, I am waiting for conclusions in the export symbols discussion [1] to
> re-spin the i2c bus extension series.

I just have one question to add to what Hervé wrote.

I guess in the big picture you have a device tree where all
hot-pluggable I2C devices are always described, but they won't probe
until i2c_hotplug_activate() adds an adapter for them. Is my
understanding correct?

If correct, this implies you can connect only one type of dock. Multple
dock models with different peripherals cannot be supported.

Best regards,
Luca


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C
  2025-09-16  7:50         ` Luca Ceresoli
@ 2025-09-16  8:11           ` Svyatoslav Ryhel
  0 siblings, 0 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2025-09-16  8:11 UTC (permalink / raw)
  To: Luca Ceresoli
  Cc: Herve Codina, Wolfram Sang, Andi Shyti, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Peter Rosin,
	Michał Mirosław, Jonas Schwöbel, linux-i2c,
	devicetree, linux-kernel, luca.ceresoli

вт, 16 вер. 2025 р. о 10:50 Luca Ceresoli <luca@lucaceresoli.net> пише:
>
> Hello,
>
> thanks Wolfram for pulling Hervé and me in.
>
> +Cc my Bootlin e-mail address
>
> Il 16/09/25 08:19, Herve Codina ha scritto:
> > Hi Wolfram,
> >
> > On Mon, 15 Sep 2025 17:42:06 +0200
> > Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:
> >
> >> On Mon, Sep 15, 2025 at 02:53:23PM +0300, Svyatoslav Ryhel wrote:
> >>> пн, 15 вер. 2025 р. о 14:35 Wolfram Sang
> >>> <wsa+renesas@sang-engineering.com> пише:
> >>>>
> >>>> On Mon, Sep 15, 2025 at 09:01:36AM +0300, Svyatoslav Ryhel wrote:
> >>>>> Implement driver for hot-plugged I2C busses, where some devices on
> >>>>> a bus are hot-pluggable and their presence is indicated by GPIO line.
> >>>>> This feature is used by the ASUS Transformers family, by the  Microsoft
> >>>>> Surface RT/2 and maybe more.
> >>>>>
> >>>>> ASUS Transformers expose i2c line via proprietary 40 pin plug and wire
> >>>>> that line through optional dock accessory. Devices in the dock are
> >>>>> connected to this i2c line and docks presence is detected by a dedicted
> >>>>> GPIO.
> >>>>>
> >>>>> Michał Mirosław (1):
> >>>>>   i2c: muxes: Add GPIO-detected hotplug I2C
> >>>>>
> >>>>> Svyatoslav Ryhel (1):
> >>>>>   dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus
> >>>>>
> >>>>>  .../bindings/i2c/i2c-hotplug-gpio.yaml        |  65 +++++
> >>>>>  drivers/i2c/muxes/Kconfig                     |  11 +
> >>>>>  drivers/i2c/muxes/Makefile                    |   1 +
> >>>>>  drivers/i2c/muxes/i2c-hotplug-gpio.c          | 263 ++++++++++++++++++
> >>>>>  4 files changed, 340 insertions(+)
> >>>>>  create mode 100644 Documentation/devicetree/bindings/i2c/i2c-hotplug-gpio.yaml
> >>>>>  create mode 100644 drivers/i2c/muxes/i2c-hotplug-gpio.c
> >>>>
> >>>> Adding Herve and Luca to CC because they want to achieve the same with
> >>>> their I2C bus extensions, no?
> >>
> >> Sorry, a misunderstanding: the question was for Herve and Luca. I wanted
> >> to ask for a comment from them if this is the same problem (which I
> >> think it is). The question was not meant for you.
> >>
> >
> > Indeed, we try to handle the same use case.
> >
> > The i2c-hotplug-gpio.c driver handles only an connector with an I2C bus.
> >
> > On our side, we try to have something more generic that can handle more
> > than one I2C and some other busses and resources (gpio, pwm, ...) wired
> > to a connector.
> >
> > To move this i2c-hotplug-gpio to our proposal direction, this should become
> > a connector driver with a i2c bus extension and an addon DT describing the
> > i2c devices available on the addon board.
> >
> > The connector driver should monitor the gpio and apply the addon DT when it
> > detects the addon plugged.
> >
> > Also, I am waiting for conclusions in the export symbols discussion [1] to
> > re-spin the i2c bus extension series.
>
> I just have one question to add to what Hervé wrote.
>
> I guess in the big picture you have a device tree where all
> hot-pluggable I2C devices are always described, but they won't probe
> until i2c_hotplug_activate() adds an adapter for them. Is my
> understanding correct?
>

Yes, your understanding is correct, i2c_hotplug creates a i2c mux from
parent with a set of always described devices by GPIO signal.

> If correct, this implies you can connect only one type of dock. Multple
> dock models with different peripherals cannot be supported.
>

This configuration is used for ASUS Transformers and they don't have
multiple docks, only one accessory is used and it is not swappable
even between models by design, not even talking about different
generations. SO configuration used by Transformers can be described
just as title says "GPIO-detected hotplug I2C" devices are fixed just
can be detached, but never swapped.

> Best regards,
> Luca
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-09-16  8:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15  6:01 [PATCH v1 0/2] i2c: muxes: Add GPIO-detected hotplug I2C Svyatoslav Ryhel
2025-09-15  6:01 ` [PATCH v1 1/2] dt-bindings: i2c: Document GPIO detected hot-plugged I2C bus Svyatoslav Ryhel
2025-09-15  6:01 ` [PATCH v1 2/2] i2c: muxes: Add GPIO-detected hotplug I2C Svyatoslav Ryhel
2025-09-15 11:35 ` [PATCH v1 0/2] " Wolfram Sang
2025-09-15 11:53   ` Svyatoslav Ryhel
2025-09-15 15:42     ` Wolfram Sang
2025-09-16  6:19       ` Herve Codina
2025-09-16  7:50         ` Luca Ceresoli
2025-09-16  8:11           ` Svyatoslav Ryhel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox