Linux I2C development
 help / color / mirror / Atom feed
* [PATCH v1 0/2] platform/asus: Add driver for ASUS Transformer's Dock
@ 2026-11-18 13:45 Svyatoslav Ryhel
  2026-11-18 13:45 ` [PATCH v1 1/2] dt-bindings: i2c: Document " Svyatoslav Ryhel
  2026-11-18 13:45 ` [PATCH v1 2/2] platform/asus: Add driver for ASUS Transformer's Dock of Tegra based devices Svyatoslav Ryhel
  0 siblings, 2 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-18 13:45 UTC (permalink / raw)
  To: Hans de Goede, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Ilpo Järvinen, Svyatoslav Ryhel,
	Michał Mirosław
  Cc: linux-i2c, devicetree, linux-kernel

The ASUS Transformer dock used by Tegra-based devices has an extended I2C
bus where certain devices are hot-pluggable and their presence
is indicated by a GPIO line. The set of hot-pluggable devices must be
predetermined and static.

Tegra20 and Tegra30 Transformers have EC and dockram clients on this line,
while TF600T and Tegra114 Transformers have hid-over-i2c keyboard,
touchpad and EC here.

I have tried to submit this patch in more generic way, but I was rejected.
More details: https://lore.kernel.org/lkml/20251013060018.43851-1-clamor95@gmail.com/

Michał Mirosław (1):
  platform/asus: Add driver for ASUS Transformer's Dock of Tegra based
    devices

Svyatoslav Ryhel (1):
  dt-bindings: i2c: Document ASUS Transformer's Dock

 .../bindings/i2c/asus,transformer-dock.yaml   |  56 ++++
 drivers/platform/asus/Kconfig                 |  11 +
 drivers/platform/asus/Makefile                |   1 +
 drivers/platform/asus/asus-transformer-dock.c | 260 ++++++++++++++++++
 4 files changed, 328 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
 create mode 100644 drivers/platform/asus/asus-transformer-dock.c

-- 
2.53.0


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

* [PATCH v1 1/2] dt-bindings: i2c: Document ASUS Transformer's Dock
  2026-11-18 13:45 [PATCH v1 0/2] platform/asus: Add driver for ASUS Transformer's Dock Svyatoslav Ryhel
@ 2026-11-18 13:45 ` Svyatoslav Ryhel
  2026-11-18 14:40   ` Wolfram Sang
  2026-12-01 19:33   ` Rob Herring
  2026-11-18 13:45 ` [PATCH v1 2/2] platform/asus: Add driver for ASUS Transformer's Dock of Tegra based devices Svyatoslav Ryhel
  1 sibling, 2 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-18 13:45 UTC (permalink / raw)
  To: Hans de Goede, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Ilpo Järvinen, Svyatoslav Ryhel,
	Michał Mirosław
  Cc: linux-i2c, devicetree, linux-kernel

Document a hardware configuration that uses a GPIO signal to determine the
presence and state of devices on the bus, allowing the system to
dynamically configure a predetermined set of I2C devices as they are
plugged in or removed used in Tegra based ASUS Transformers.

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

diff --git a/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
new file mode 100644
index 0000000000000..5f4a40539c2b4
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/asus,transformer-dock.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASUS Transformer's Dock for Tegra based devices
+
+maintainers:
+  - Michał Mirosław <mirq-linux@rere.qmqm.pl>
+  - Svyatoslav Ryhel <clamor95@gmail.com>
+
+description: An I2C bus extension found in the ASUS Transformers, where
+  certain devices are hot-pluggable, with their presence indicated by a
+  GPIO line. The set of potential hot-pluggable devices must be predefined
+  and fixed.
+
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml
+
+properties:
+  compatible:
+    const: asus,transformer-dock
+
+  detect-gpios:
+    description:
+      A pin whose active state indicates that detachable devices are plugged in.
+    maxItems: 1
+
+  i2c-parent:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      The phandle of the I2C bus that this multiplexer's master-side port is
+      connected to.
+
+required:
+  - compatible
+  - detect-gpios
+  - i2c-parent
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c-dock {
+        compatible = "asus,transformer-dock";
+
+        detect-gpios = <&gpio 164 GPIO_ACTIVE_LOW>;
+        i2c-parent = <&gen2_i2c>;
+
+        #address-cells = <1>;
+        #size-cells = <0>;
+    };
+...
-- 
2.53.0


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

* [PATCH v1 2/2] platform/asus: Add driver for ASUS Transformer's Dock of Tegra based devices
  2026-11-18 13:45 [PATCH v1 0/2] platform/asus: Add driver for ASUS Transformer's Dock Svyatoslav Ryhel
  2026-11-18 13:45 ` [PATCH v1 1/2] dt-bindings: i2c: Document " Svyatoslav Ryhel
@ 2026-11-18 13:45 ` Svyatoslav Ryhel
  2026-11-29 16:38   ` Svyatoslav Ryhel
  1 sibling, 1 reply; 9+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-18 13:45 UTC (permalink / raw)
  To: Hans de Goede, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Ilpo Järvinen, Svyatoslav Ryhel,
	Michał Mirosław
  Cc: linux-i2c, devicetree, linux-kernel

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

The ASUS Transformer dock used by Tegra-based devices has an extended I2C
bus where certain devices are hot-pluggable and their presence
is indicated by a GPIO line. The set of hot-pluggable devices must be
predetermined and static.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/platform/asus/Kconfig                 |  11 +
 drivers/platform/asus/Makefile                |   1 +
 drivers/platform/asus/asus-transformer-dock.c | 260 ++++++++++++++++++
 3 files changed, 272 insertions(+)
 create mode 100644 drivers/platform/asus/asus-transformer-dock.c

diff --git a/drivers/platform/asus/Kconfig b/drivers/platform/asus/Kconfig
index 0219418ce3523..af670a3c0d014 100644
--- a/drivers/platform/asus/Kconfig
+++ b/drivers/platform/asus/Kconfig
@@ -113,6 +113,17 @@ config ASUS_ARMOURY
 	  To compile this driver as a module, choose M here: the module will
 	  be called asus-armoury.
 
+config ASUS_TRANSFORMER_DOCK
+	tristate "ASUS Transformer Dock for Tegra based devices"
+	depends on GPIOLIB
+	depends on OF
+	help
+	  Say Y here if you want support for ASUS Transformer Dock for
+	  Tegra devices.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called asus-transformer-dock.
+
 config ASUS_WMI
 	tristate "ASUS WMI Driver"
 	depends on ACPI_WMI
diff --git a/drivers/platform/asus/Makefile b/drivers/platform/asus/Makefile
index 7bb25cba4853d..f130141dda534 100644
--- a/drivers/platform/asus/Makefile
+++ b/drivers/platform/asus/Makefile
@@ -10,5 +10,6 @@ obj-$(CONFIG_ASUS_ARMOURY)	+= asus-armoury.o
 obj-$(CONFIG_ASUS_WMI)		+= asus-wmi.o
 obj-$(CONFIG_ASUS_NB_WMI)	+= asus-nb-wmi.o
 obj-$(CONFIG_ASUS_TF103C_DOCK)	+= asus-tf103c-dock.o
+obj-$(CONFIG_ASUS_TRANSFORMER_DOCK)	+= asus-transformer-dock.o
 obj-$(CONFIG_EEEPC_LAPTOP)	+= eeepc-laptop.o
 obj-$(CONFIG_EEEPC_WMI)		+= eeepc-wmi.o
diff --git a/drivers/platform/asus/asus-transformer-dock.c b/drivers/platform/asus/asus-transformer-dock.c
new file mode 100644
index 0000000000000..7c9346af5e1f3
--- /dev/null
+++ b/drivers/platform/asus/asus-transformer-dock.c
@@ -0,0 +1,260 @@
+// 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>
+
+#define ASUS_TF_DOCK_ATTACHED		0
+
+struct asus_tf_dock_priv {
+	struct i2c_adapter adap;
+	struct i2c_adapter *parent;
+	struct device *dev;
+	struct gpio_desc *gpio;
+	unsigned long state_flags;
+};
+
+static inline struct i2c_adapter *asus_tf_dock_parent(struct i2c_adapter *adap)
+{
+	struct asus_tf_dock_priv *priv =
+		container_of(adap, struct asus_tf_dock_priv, adap);
+
+	return priv->parent;
+}
+
+static int asus_tf_dock_master_xfer(struct i2c_adapter *adap,
+				    struct i2c_msg msgs[], int num)
+{
+	struct i2c_adapter *parent = asus_tf_dock_parent(adap);
+
+	return parent->algo->master_xfer(parent, msgs, num);
+}
+
+static int asus_tf_dock_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 = asus_tf_dock_parent(adap);
+
+	return parent->algo->smbus_xfer(parent, addr, flags, read_write,
+					command, protocol, data);
+}
+
+static u32 asus_tf_dock_functionality(struct i2c_adapter *adap)
+{
+	u32 parent_func = i2c_get_functionality(asus_tf_dock_parent(adap));
+
+	return parent_func & ~I2C_FUNC_SLAVE;
+}
+
+static const struct i2c_algorithm asus_tf_dock_algo_i2c = {
+	.master_xfer = asus_tf_dock_master_xfer,
+	.functionality = asus_tf_dock_functionality,
+};
+
+static const struct i2c_algorithm asus_tf_dock_algo_smbus = {
+	.smbus_xfer = asus_tf_dock_smbus_xfer,
+	.functionality = asus_tf_dock_functionality,
+};
+
+static const struct i2c_algorithm asus_tf_dock_algo_both = {
+	.master_xfer = asus_tf_dock_master_xfer,
+	.smbus_xfer = asus_tf_dock_smbus_xfer,
+	.functionality = asus_tf_dock_functionality,
+};
+
+static const struct i2c_algorithm *const asus_tf_dock_algo[2][2] = {
+	/* non-I2C */
+	{ NULL, &asus_tf_dock_algo_smbus },
+	/* I2C */
+	{ &asus_tf_dock_algo_i2c, &asus_tf_dock_algo_both }
+};
+
+static void asus_tf_dock_lock_bus(struct i2c_adapter *adap, unsigned int flags)
+{
+	i2c_lock_bus(asus_tf_dock_parent(adap), flags);
+}
+
+static int asus_tf_dock_trylock_bus(struct i2c_adapter *adap,
+				    unsigned int flags)
+{
+	return i2c_trylock_bus(asus_tf_dock_parent(adap), flags);
+}
+
+static void asus_tf_dock_unlock_bus(struct i2c_adapter *adap,
+				    unsigned int flags)
+{
+	i2c_unlock_bus(asus_tf_dock_parent(adap), flags);
+}
+
+static const struct i2c_lock_operations asus_tf_dock_lock_ops = {
+	.lock_bus = asus_tf_dock_lock_bus,
+	.trylock_bus = asus_tf_dock_trylock_bus,
+	.unlock_bus = asus_tf_dock_unlock_bus,
+};
+
+static int asus_tf_dock_recover_bus(struct i2c_adapter *adap)
+{
+	return i2c_recover_bus(asus_tf_dock_parent(adap));
+}
+
+static struct i2c_bus_recovery_info asus_tf_dock_recovery_info = {
+	.recover_bus = asus_tf_dock_recover_bus,
+};
+
+static int asus_tf_dock_activate(struct asus_tf_dock_priv *priv)
+{
+	int ret;
+
+	if (test_bit(ASUS_TF_DOCK_ATTACHED, &priv->state_flags))
+		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)
+		set_bit(ASUS_TF_DOCK_ATTACHED, &priv->state_flags);
+
+	return ret;
+}
+
+static void asus_tf_dock_deactivate(struct asus_tf_dock_priv *priv)
+{
+	if (!test_bit(ASUS_TF_DOCK_ATTACHED, &priv->state_flags))
+		return;
+
+	dev_dbg(priv->adap.dev.parent, "disconnection detected");
+
+	i2c_del_adapter(&priv->adap);
+	clear_bit(ASUS_TF_DOCK_ATTACHED, &priv->state_flags);
+}
+
+static irqreturn_t asus_tf_dock_interrupt(int irq, void *dev_id)
+{
+	struct asus_tf_dock_priv *priv = dev_id;
+
+	/* debounce */
+	msleep(20);
+
+	if (gpiod_get_value_cansleep(priv->gpio))
+		asus_tf_dock_activate(priv);
+	else
+		asus_tf_dock_deactivate(priv);
+
+	return IRQ_HANDLED;
+}
+
+static void wrap_i2c_put_adapter(void *adapter)
+{
+	i2c_put_adapter(adapter);
+}
+
+static void wrap_asus_tf_dock_deactivate(void *priv)
+{
+	asus_tf_dock_deactivate(priv);
+}
+
+static int asus_tf_dock_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *parent_np;
+	struct i2c_adapter *parent;
+	struct asus_tf_dock_priv *priv;
+	bool is_i2c, is_smbus;
+	int err;
+
+	priv = devm_kzalloc_obj(dev, struct asus_tf_dock_priv);
+	if (!priv)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, priv);
+	priv->dev = dev;
+
+	parent_np = of_parse_phandle(dev->of_node, "i2c-parent", 0);
+	if (IS_ERR(parent_np))
+		return dev_err_probe(dev, PTR_ERR(parent_np),
+				     "Failed to 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(dev, PTR_ERR(parent),
+				     "Failed to get parent I2C adapter\n");
+	priv->parent = parent;
+
+	err = devm_add_action_or_reset(dev, wrap_i2c_put_adapter, parent);
+	if (err)
+		return err;
+
+	priv->gpio = devm_gpiod_get(dev, "detect", GPIOD_IN);
+	if (IS_ERR(priv->gpio))
+		return dev_err_probe(dev, PTR_ERR(priv->gpio),
+				     "Failed to get detect GPIO\n");
+
+	is_i2c = parent->algo->master_xfer;
+	is_smbus = parent->algo->smbus_xfer;
+
+	priv->adap.algo = asus_tf_dock_algo[is_i2c][is_smbus];
+	if (!priv->adap.algo)
+		return -EINVAL;
+
+	snprintf(priv->adap.name, sizeof(priv->adap.name),
+		 "asus-transformer-dock (master i2c-%d)", i2c_adapter_id(parent));
+	priv->adap.owner = THIS_MODULE;
+	priv->adap.lock_ops = &asus_tf_dock_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)
+		priv->adap.bus_recovery_info = &asus_tf_dock_recovery_info;
+
+	err = devm_add_action_or_reset(dev, wrap_asus_tf_dock_deactivate, priv);
+	if (err)
+		return err;
+
+	err = devm_request_threaded_irq(dev, gpiod_to_irq(priv->gpio), NULL,
+					asus_tf_dock_interrupt,
+					IRQF_TRIGGER_RISING |
+					IRQF_TRIGGER_FALLING |
+					IRQF_ONESHOT | IRQF_SHARED,
+					"asus-transformer-dock", priv);
+	if (err)
+		return dev_err_probe(dev, err, "Failed to register IRQ %d\n",
+				     gpiod_to_irq(priv->gpio));
+
+	irq_wake_thread(gpiod_to_irq(priv->gpio), priv);
+
+	return 0;
+}
+
+static const struct of_device_id asus_tf_dock_of_match[] = {
+	{ .compatible = "asus,transformer-dock" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, asus_tf_dock_of_match);
+
+static struct platform_driver asus_tf_dock_driver = {
+	.driver	= {
+		.name = "asus-transformer-dock",
+		.of_match_table = asus_tf_dock_of_match,
+	},
+	.probe = asus_tf_dock_probe,
+};
+module_platform_driver(asus_tf_dock_driver);
+
+MODULE_DESCRIPTION("ASUS Transformer's Dock for Tegra based devices");
+MODULE_AUTHOR("Michał Mirosław <mirq-linux@rere.qmqm.pl>");
+MODULE_LICENSE("GPL");
-- 
2.53.0


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

* Re: [PATCH v1 1/2] dt-bindings: i2c: Document ASUS Transformer's Dock
  2026-11-18 13:45 ` [PATCH v1 1/2] dt-bindings: i2c: Document " Svyatoslav Ryhel
@ 2026-11-18 14:40   ` Wolfram Sang
  2026-11-18 14:42     ` Svyatoslav Ryhel
  2026-12-01 19:33   ` Rob Herring
  1 sibling, 1 reply; 9+ messages in thread
From: Wolfram Sang @ 2026-11-18 14:40 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Hans de Goede, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Ilpo Järvinen, Michał Mirosław,
	linux-i2c, devicetree, linux-kernel

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


>  .../bindings/i2c/asus,transformer-dock.yaml   | 56 +++++++++++++++++++
>  1 file changed, 56 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> 
> diff --git a/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> new file mode 100644
> index 0000000000000..5f4a40539c2b4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml

This is not an I2C controller, so "i2c" is not the proper directory, I'd
say. "connector" maybe? DT maintainers may have another suggestion.

> +allOf:
> +  - $ref: /schemas/i2c/i2c-controller.yaml

Hmm, this bindings only uses "i2c-parent" which is not even described in
the above file. Not your fault / problem, but we should describe it
somewhen somewhere central maybe? I guess the above $ref could be
dropped still.

No comments on the general approach, I'll leave this to DT and Asus
platform maintainers.


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

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

* Re: [PATCH v1 1/2] dt-bindings: i2c: Document ASUS Transformer's Dock
  2026-11-18 14:40   ` Wolfram Sang
@ 2026-11-18 14:42     ` Svyatoslav Ryhel
  2026-11-29 16:40       ` Svyatoslav Ryhel
  0 siblings, 1 reply; 9+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-18 14:42 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Hans de Goede, Andi Shyti, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Ilpo Järvinen, Michał Mirosław,
	linux-i2c, devicetree, linux-kernel

ср, 18 лист. 2026 р. о 16:40 Wolfram Sang
<wsa+renesas@sang-engineering.com> пише:
>
>
> >  .../bindings/i2c/asus,transformer-dock.yaml   | 56 +++++++++++++++++++
> >  1 file changed, 56 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> > new file mode 100644
> > index 0000000000000..5f4a40539c2b4
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
>
> This is not an I2C controller, so "i2c" is not the proper directory, I'd
> say. "connector" maybe? DT maintainers may have another suggestion.
>

I have placed it here arbitrary. I am perfectly fine with any place
schema maintainers point to.

> > +allOf:
> > +  - $ref: /schemas/i2c/i2c-controller.yaml
>
> Hmm, this bindings only uses "i2c-parent" which is not even described in
> the above file. Not your fault / problem, but we should describe it
> somewhen somewhere central maybe? I guess the above $ref could be
> dropped still.
>

Child nodes too. IIRC i2c-controller.yaml covers those.

> No comments on the general approach, I'll leave this to DT and Asus
> platform maintainers.
>

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

* Re: [PATCH v1 2/2] platform/asus: Add driver for ASUS Transformer's Dock of Tegra based devices
  2026-11-18 13:45 ` [PATCH v1 2/2] platform/asus: Add driver for ASUS Transformer's Dock of Tegra based devices Svyatoslav Ryhel
@ 2026-11-29 16:38   ` Svyatoslav Ryhel
  0 siblings, 0 replies; 9+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-29 16:38 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Andi Shyti, Svyatoslav Ryhel, Rob Herring, Conor Dooley,
	Ilpo Järvinen, Michał Mirosław,
	Krzysztof Kozlowski, linux-i2c, devicetree, linux-kernel

ср, 18 лист. 2026 р. о 15:46 Svyatoslav Ryhel <clamor95@gmail.com> пише:
>
> From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
>
> The ASUS Transformer dock used by Tegra-based devices has an extended I2C
> bus where certain devices are hot-pluggable and their presence
> is indicated by a GPIO line. The set of hot-pluggable devices must be
> predetermined and static.
>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
>  drivers/platform/asus/Kconfig                 |  11 +
>  drivers/platform/asus/Makefile                |   1 +
>  drivers/platform/asus/asus-transformer-dock.c | 260 ++++++++++++++++++
>  3 files changed, 272 insertions(+)
>  create mode 100644 drivers/platform/asus/asus-transformer-dock.c
>
> diff --git a/drivers/platform/asus/Kconfig b/drivers/platform/asus/Kconfig
> index 0219418ce3523..af670a3c0d014 100644
> --- a/drivers/platform/asus/Kconfig
> +++ b/drivers/platform/asus/Kconfig
> @@ -113,6 +113,17 @@ config ASUS_ARMOURY
>           To compile this driver as a module, choose M here: the module will
>           be called asus-armoury.
>
> +config ASUS_TRANSFORMER_DOCK
> +       tristate "ASUS Transformer Dock for Tegra based devices"
> +       depends on GPIOLIB
> +       depends on OF
> +       help
> +         Say Y here if you want support for ASUS Transformer Dock for
> +         Tegra devices.
> +
> +         This driver can also be built as a module. If so, the module
> +         will be called asus-transformer-dock.
> +
>  config ASUS_WMI
>         tristate "ASUS WMI Driver"
>         depends on ACPI_WMI
> diff --git a/drivers/platform/asus/Makefile b/drivers/platform/asus/Makefile
> index 7bb25cba4853d..f130141dda534 100644
> --- a/drivers/platform/asus/Makefile
> +++ b/drivers/platform/asus/Makefile
> @@ -10,5 +10,6 @@ obj-$(CONFIG_ASUS_ARMOURY)    += asus-armoury.o
>  obj-$(CONFIG_ASUS_WMI)         += asus-wmi.o
>  obj-$(CONFIG_ASUS_NB_WMI)      += asus-nb-wmi.o
>  obj-$(CONFIG_ASUS_TF103C_DOCK) += asus-tf103c-dock.o
> +obj-$(CONFIG_ASUS_TRANSFORMER_DOCK)    += asus-transformer-dock.o
>  obj-$(CONFIG_EEEPC_LAPTOP)     += eeepc-laptop.o
>  obj-$(CONFIG_EEEPC_WMI)                += eeepc-wmi.o
> diff --git a/drivers/platform/asus/asus-transformer-dock.c b/drivers/platform/asus/asus-transformer-dock.c
> new file mode 100644
> index 0000000000000..7c9346af5e1f3
> --- /dev/null
> +++ b/drivers/platform/asus/asus-transformer-dock.c
> @@ -0,0 +1,260 @@
> +// 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>
> +
> +#define ASUS_TF_DOCK_ATTACHED          0
> +
> +struct asus_tf_dock_priv {
> +       struct i2c_adapter adap;
> +       struct i2c_adapter *parent;
> +       struct device *dev;
> +       struct gpio_desc *gpio;
> +       unsigned long state_flags;
> +};
> +
> +static inline struct i2c_adapter *asus_tf_dock_parent(struct i2c_adapter *adap)
> +{
> +       struct asus_tf_dock_priv *priv =
> +               container_of(adap, struct asus_tf_dock_priv, adap);
> +
> +       return priv->parent;
> +}
> +
> +static int asus_tf_dock_master_xfer(struct i2c_adapter *adap,
> +                                   struct i2c_msg msgs[], int num)
> +{
> +       struct i2c_adapter *parent = asus_tf_dock_parent(adap);
> +
> +       return parent->algo->master_xfer(parent, msgs, num);
> +}
> +
> +static int asus_tf_dock_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 = asus_tf_dock_parent(adap);
> +
> +       return parent->algo->smbus_xfer(parent, addr, flags, read_write,
> +                                       command, protocol, data);
> +}
> +
> +static u32 asus_tf_dock_functionality(struct i2c_adapter *adap)
> +{
> +       u32 parent_func = i2c_get_functionality(asus_tf_dock_parent(adap));
> +
> +       return parent_func & ~I2C_FUNC_SLAVE;
> +}
> +
> +static const struct i2c_algorithm asus_tf_dock_algo_i2c = {
> +       .master_xfer = asus_tf_dock_master_xfer,
> +       .functionality = asus_tf_dock_functionality,
> +};
> +
> +static const struct i2c_algorithm asus_tf_dock_algo_smbus = {
> +       .smbus_xfer = asus_tf_dock_smbus_xfer,
> +       .functionality = asus_tf_dock_functionality,
> +};
> +
> +static const struct i2c_algorithm asus_tf_dock_algo_both = {
> +       .master_xfer = asus_tf_dock_master_xfer,
> +       .smbus_xfer = asus_tf_dock_smbus_xfer,
> +       .functionality = asus_tf_dock_functionality,
> +};
> +
> +static const struct i2c_algorithm *const asus_tf_dock_algo[2][2] = {
> +       /* non-I2C */
> +       { NULL, &asus_tf_dock_algo_smbus },
> +       /* I2C */
> +       { &asus_tf_dock_algo_i2c, &asus_tf_dock_algo_both }
> +};
> +
> +static void asus_tf_dock_lock_bus(struct i2c_adapter *adap, unsigned int flags)
> +{
> +       i2c_lock_bus(asus_tf_dock_parent(adap), flags);
> +}
> +
> +static int asus_tf_dock_trylock_bus(struct i2c_adapter *adap,
> +                                   unsigned int flags)
> +{
> +       return i2c_trylock_bus(asus_tf_dock_parent(adap), flags);
> +}
> +
> +static void asus_tf_dock_unlock_bus(struct i2c_adapter *adap,
> +                                   unsigned int flags)
> +{
> +       i2c_unlock_bus(asus_tf_dock_parent(adap), flags);
> +}
> +
> +static const struct i2c_lock_operations asus_tf_dock_lock_ops = {
> +       .lock_bus = asus_tf_dock_lock_bus,
> +       .trylock_bus = asus_tf_dock_trylock_bus,
> +       .unlock_bus = asus_tf_dock_unlock_bus,
> +};
> +
> +static int asus_tf_dock_recover_bus(struct i2c_adapter *adap)
> +{
> +       return i2c_recover_bus(asus_tf_dock_parent(adap));
> +}
> +
> +static struct i2c_bus_recovery_info asus_tf_dock_recovery_info = {
> +       .recover_bus = asus_tf_dock_recover_bus,
> +};
> +
> +static int asus_tf_dock_activate(struct asus_tf_dock_priv *priv)
> +{
> +       int ret;
> +
> +       if (test_bit(ASUS_TF_DOCK_ATTACHED, &priv->state_flags))
> +               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)
> +               set_bit(ASUS_TF_DOCK_ATTACHED, &priv->state_flags);
> +
> +       return ret;
> +}
> +
> +static void asus_tf_dock_deactivate(struct asus_tf_dock_priv *priv)
> +{
> +       if (!test_bit(ASUS_TF_DOCK_ATTACHED, &priv->state_flags))
> +               return;
> +
> +       dev_dbg(priv->adap.dev.parent, "disconnection detected");
> +
> +       i2c_del_adapter(&priv->adap);
> +       clear_bit(ASUS_TF_DOCK_ATTACHED, &priv->state_flags);
> +}
> +
> +static irqreturn_t asus_tf_dock_interrupt(int irq, void *dev_id)
> +{
> +       struct asus_tf_dock_priv *priv = dev_id;
> +
> +       /* debounce */
> +       msleep(20);
> +
> +       if (gpiod_get_value_cansleep(priv->gpio))
> +               asus_tf_dock_activate(priv);
> +       else
> +               asus_tf_dock_deactivate(priv);
> +
> +       return IRQ_HANDLED;
> +}
> +
> +static void wrap_i2c_put_adapter(void *adapter)
> +{
> +       i2c_put_adapter(adapter);
> +}
> +
> +static void wrap_asus_tf_dock_deactivate(void *priv)
> +{
> +       asus_tf_dock_deactivate(priv);
> +}
> +
> +static int asus_tf_dock_probe(struct platform_device *pdev)
> +{
> +       struct device *dev = &pdev->dev;
> +       struct device_node *parent_np;
> +       struct i2c_adapter *parent;
> +       struct asus_tf_dock_priv *priv;
> +       bool is_i2c, is_smbus;
> +       int err;
> +
> +       priv = devm_kzalloc_obj(dev, struct asus_tf_dock_priv);
> +       if (!priv)
> +               return -ENOMEM;
> +
> +       platform_set_drvdata(pdev, priv);
> +       priv->dev = dev;
> +
> +       parent_np = of_parse_phandle(dev->of_node, "i2c-parent", 0);
> +       if (IS_ERR(parent_np))
> +               return dev_err_probe(dev, PTR_ERR(parent_np),
> +                                    "Failed to 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(dev, PTR_ERR(parent),
> +                                    "Failed to get parent I2C adapter\n");
> +       priv->parent = parent;
> +
> +       err = devm_add_action_or_reset(dev, wrap_i2c_put_adapter, parent);
> +       if (err)
> +               return err;
> +
> +       priv->gpio = devm_gpiod_get(dev, "detect", GPIOD_IN);
> +       if (IS_ERR(priv->gpio))
> +               return dev_err_probe(dev, PTR_ERR(priv->gpio),
> +                                    "Failed to get detect GPIO\n");
> +
> +       is_i2c = parent->algo->master_xfer;
> +       is_smbus = parent->algo->smbus_xfer;
> +
> +       priv->adap.algo = asus_tf_dock_algo[is_i2c][is_smbus];
> +       if (!priv->adap.algo)
> +               return -EINVAL;
> +
> +       snprintf(priv->adap.name, sizeof(priv->adap.name),
> +                "asus-transformer-dock (master i2c-%d)", i2c_adapter_id(parent));
> +       priv->adap.owner = THIS_MODULE;
> +       priv->adap.lock_ops = &asus_tf_dock_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)
> +               priv->adap.bus_recovery_info = &asus_tf_dock_recovery_info;
> +
> +       err = devm_add_action_or_reset(dev, wrap_asus_tf_dock_deactivate, priv);
> +       if (err)
> +               return err;
> +
> +       err = devm_request_threaded_irq(dev, gpiod_to_irq(priv->gpio), NULL,
> +                                       asus_tf_dock_interrupt,
> +                                       IRQF_TRIGGER_RISING |
> +                                       IRQF_TRIGGER_FALLING |
> +                                       IRQF_ONESHOT | IRQF_SHARED,
> +                                       "asus-transformer-dock", priv);
> +       if (err)
> +               return dev_err_probe(dev, err, "Failed to register IRQ %d\n",
> +                                    gpiod_to_irq(priv->gpio));
> +
> +       irq_wake_thread(gpiod_to_irq(priv->gpio), priv);
> +
> +       return 0;
> +}
> +
> +static const struct of_device_id asus_tf_dock_of_match[] = {
> +       { .compatible = "asus,transformer-dock" },
> +       { },
> +};
> +MODULE_DEVICE_TABLE(of, asus_tf_dock_of_match);
> +
> +static struct platform_driver asus_tf_dock_driver = {
> +       .driver = {
> +               .name = "asus-transformer-dock",
> +               .of_match_table = asus_tf_dock_of_match,
> +       },
> +       .probe = asus_tf_dock_probe,
> +};
> +module_platform_driver(asus_tf_dock_driver);
> +
> +MODULE_DESCRIPTION("ASUS Transformer's Dock for Tegra based devices");
> +MODULE_AUTHOR("Michał Mirosław <mirq-linux@rere.qmqm.pl>");
> +MODULE_LICENSE("GPL");
> --
> 2.53.0
>

Hello Hans!

May you please have a look if this driver can live in platform
subsystem, I have prepared a few updates.

Thanks.

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

* Re: [PATCH v1 1/2] dt-bindings: i2c: Document ASUS Transformer's Dock
  2026-11-18 14:42     ` Svyatoslav Ryhel
@ 2026-11-29 16:40       ` Svyatoslav Ryhel
  2026-12-01 19:27         ` Rob Herring
  0 siblings, 1 reply; 9+ messages in thread
From: Svyatoslav Ryhel @ 2026-11-29 16:40 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Hans de Goede
  Cc: Wolfram Sang, Andi Shyti, Ilpo Järvinen,
	Michał Mirosław, linux-i2c, devicetree, linux-kernel

ср, 18 лист. 2026 р. о 16:42 Svyatoslav Ryhel <clamor95@gmail.com> пише:
>
> ср, 18 лист. 2026 р. о 16:40 Wolfram Sang
> <wsa+renesas@sang-engineering.com> пише:
> >
> >
> > >  .../bindings/i2c/asus,transformer-dock.yaml   | 56 +++++++++++++++++++
> > >  1 file changed, 56 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> > >
> > > diff --git a/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> > > new file mode 100644
> > > index 0000000000000..5f4a40539c2b4
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> >
> > This is not an I2C controller, so "i2c" is not the proper directory, I'd
> > say. "connector" maybe? DT maintainers may have another suggestion.
> >
>
> I have placed it here arbitrary. I am perfectly fine with any place
> schema maintainers point to.
>

Hello schema maintainers! Would you be so kind to point to place where
this schema can be placed? Thank you.

> > > +allOf:
> > > +  - $ref: /schemas/i2c/i2c-controller.yaml
> >
> > Hmm, this bindings only uses "i2c-parent" which is not even described in
> > the above file. Not your fault / problem, but we should describe it
> > somewhen somewhere central maybe? I guess the above $ref could be
> > dropped still.
> >
>
> Child nodes too. IIRC i2c-controller.yaml covers those.
>
> > No comments on the general approach, I'll leave this to DT and Asus
> > platform maintainers.
> >

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

* Re: [PATCH v1 1/2] dt-bindings: i2c: Document ASUS Transformer's Dock
  2026-11-29 16:40       ` Svyatoslav Ryhel
@ 2026-12-01 19:27         ` Rob Herring
  0 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2026-12-01 19:27 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Krzysztof Kozlowski, Conor Dooley, Hans de Goede, Wolfram Sang,
	Andi Shyti, Ilpo Järvinen, Michał Mirosław,
	linux-i2c, devicetree, linux-kernel

On Sun, Nov 29, 2026 at 06:40:32PM +0200, Svyatoslav Ryhel wrote:
> ср, 18 лист. 2026 р. о 16:42 Svyatoslav Ryhel <clamor95@gmail.com> пише:
> >
> > ср, 18 лист. 2026 р. о 16:40 Wolfram Sang
> > <wsa+renesas@sang-engineering.com> пише:
> > >
> > >
> > > >  .../bindings/i2c/asus,transformer-dock.yaml   | 56 +++++++++++++++++++
> > > >  1 file changed, 56 insertions(+)
> > > >  create mode 100644 Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> > > > new file mode 100644
> > > > index 0000000000000..5f4a40539c2b4
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> > >
> > > This is not an I2C controller, so "i2c" is not the proper directory, I'd
> > > say. "connector" maybe? DT maintainers may have another suggestion.
> > >
> >
> > I have placed it here arbitrary. I am perfectly fine with any place
> > schema maintainers point to.
> >
> 
> Hello schema maintainers! Would you be so kind to point to place where
> this schema can be placed? Thank you.

Check DT patchwork if you want to know where your patch stands. 
Congrats, you are now 1st in 313 patches.

Rob

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

* Re: [PATCH v1 1/2] dt-bindings: i2c: Document ASUS Transformer's Dock
  2026-11-18 13:45 ` [PATCH v1 1/2] dt-bindings: i2c: Document " Svyatoslav Ryhel
  2026-11-18 14:40   ` Wolfram Sang
@ 2026-12-01 19:33   ` Rob Herring
  1 sibling, 0 replies; 9+ messages in thread
From: Rob Herring @ 2026-12-01 19:33 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Hans de Goede, Andi Shyti, Krzysztof Kozlowski, Conor Dooley,
	Ilpo Järvinen, Michał Mirosław, linux-i2c,
	devicetree, linux-kernel

On Wed, Nov 18, 2026 at 03:45:46PM +0200, Svyatoslav Ryhel wrote:
> Document a hardware configuration that uses a GPIO signal to determine the
> presence and state of devices on the bus, allowing the system to
> dynamically configure a predetermined set of I2C devices as they are
> plugged in or removed used in Tegra based ASUS Transformers.
> 
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
>  .../bindings/i2c/asus,transformer-dock.yaml   | 56 +++++++++++++++++++
>  1 file changed, 56 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> 
> diff --git a/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> new file mode 100644
> index 0000000000000..5f4a40539c2b4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/asus,transformer-dock.yaml
> @@ -0,0 +1,56 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/i2c/asus,transformer-dock.yaml#

schemas/connector/

> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: ASUS Transformer's Dock for Tegra based devices
> +
> +maintainers:
> +  - Michał Mirosław <mirq-linux@rere.qmqm.pl>
> +  - Svyatoslav Ryhel <clamor95@gmail.com>
> +
> +description: An I2C bus extension found in the ASUS Transformers, where

Start 'An ...' on the next line.

> +  certain devices are hot-pluggable, with their presence indicated by a
> +  GPIO line. The set of potential hot-pluggable devices must be predefined
> +  and fixed.
> +
> +allOf:
> +  - $ref: /schemas/i2c/i2c-controller.yaml

I think this should be under an 'i2c' child node.

> +
> +properties:
> +  compatible:
> +    const: asus,transformer-dock
> +
> +  detect-gpios:
> +    description:
> +      A pin whose active state indicates that detachable devices are plugged in.
> +    maxItems: 1
> +
> +  i2c-parent:
> +    $ref: /schemas/types.yaml#/definitions/phandle

We really need a common type definition, but what's one more for now.

> +    description:
> +      The phandle of the I2C bus that this multiplexer's master-side port is
> +      connected to.
> +
> +required:
> +  - compatible
> +  - detect-gpios
> +  - i2c-parent
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +
> +    i2c-dock {
> +        compatible = "asus,transformer-dock";
> +
> +        detect-gpios = <&gpio 164 GPIO_ACTIVE_LOW>;
> +        i2c-parent = <&gen2_i2c>;
> +
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +    };
> +...
> -- 
> 2.53.0
> 

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

end of thread, other threads:[~2026-12-01 19:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 13:45 [PATCH v1 0/2] platform/asus: Add driver for ASUS Transformer's Dock Svyatoslav Ryhel
2026-11-18 13:45 ` [PATCH v1 1/2] dt-bindings: i2c: Document " Svyatoslav Ryhel
2026-11-18 14:40   ` Wolfram Sang
2026-11-18 14:42     ` Svyatoslav Ryhel
2026-11-29 16:40       ` Svyatoslav Ryhel
2026-12-01 19:27         ` Rob Herring
2026-12-01 19:33   ` Rob Herring
2026-11-18 13:45 ` [PATCH v1 2/2] platform/asus: Add driver for ASUS Transformer's Dock of Tegra based devices Svyatoslav Ryhel
2026-11-29 16:38   ` Svyatoslav Ryhel

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