Skip to contentSkip to conversation

mfd: Add support for Asus Transformer embedded controller

PATCH Superseded Svyatoslav Ryhel 6 participants 31 messages Oct 19 – Nov 4

Subsystems (6)

v12 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v12 cover mfd: Add support for Asus Transformer embedded controller

Add support for embedded controller used in Asus Transformers for managing power and input functions.

---
Changes in v2:
- converted sysfs debug exports into debugfs
- added kernel-doc comments for exposed functions
- fixed minor typos and inconsistencies

Changes in v3:
- dropped DockRAM commits (both schema and driver)
- integrated DockRAM functionality directly into the controller driver
- EC schema moved to embedded controllers folder
- removed all cell descriptions from the schema
- removed all compatibles from the cell drivers
- adjusted naming conventions to better align with the ASUS Transformers
- defined EC variant sets to provide coverage for all known devices

Changes in v4:
- grouped known programming models of EC chronologically (both schema and driver)
- call debugfs init only if CONFIG_DEBUG_FS is enabled

Changes in v5:
- added asus,tf600t-ec-dock compatible to schema
- rebased on top of v7.0
- kzalloc > kzalloc_obj in keys and kbc

Changes in v6:
- removed asus_ec_handle_smi casting
- asus_dockram_access_ctl > asus_ec_get_ctl in control_reg_*
- fixed battery Kconfig description

Changes in v7:
- added status check of devm_kasprintf where missing
- devm_asus_ec_register_notifier dropped, added .remove where it was used
- removed cell_to_ec, asus_dockram_read, asus_dockram_write, asus_ec_* public API asus_ec_i2c_command, devm_asus_ec_register_notifier, asus_ec_read, asus_ec_write
- renamed asusec_info > asusec_core
- ec-kbc: added packed size check
ret > error
improved key remap logic
- ec-keys: improve formatting and comments
ret > error
switched to dev_err_probe
- ec-leds: reworked to register both leds via loop
- ec-mfd: adjusted Kconfig description
fixed smbus operation sizes
fixed saving of EC fw model
adjusted IRQ flags
converted to use definer for set cell composition
added factory mode states enum and handling
defined some "magic" values
self > client, info > ec, ecreq > ecreq_gpio, priv > ddata asus_ec_chip_data data > asus_ec_chip_info info
ec_data > ec_buf, ctl_data > ctl_buf
added and improved comments, added structure descriptions asus_ec_magic_debug > asus_ec_susb_on_status
removed all dev_dbg and most of dev_info
pronts with model, fw behavior, factory and susb state preserved switched to MFD_CELL_* macros
removed debugfs
- ec-battery: swithced to BIT macro
lock usage moved to asus_ec_battery_get_value
in asus_ec_battery_poll_work fixed possible rescheduling fail in asus_ec_battery_poll_work fixed missing not charging
- ec-charger: POWER_SUPPLY_PROP_MODEL_NAME set as the first check

Changes in v8:
- added MODULE_ALIAS
- renamed DOCKRAM_* to ASUSEC_*
- ec-keys: input_handler moved into private structure
- ec-leds: added brightness_get
- ec-mdf: fixed i2c_smbus_* return checks () improved model storing
- ec-batt: added status check of devm_kasprintf

Changes in v9:
- fixed i2c_smbus_read_i2c_block_data return check
- blocking_notifier_chain_register moved before serio registration
- adjusted get_unaligned_le16 bounds check
- unsigned long long > u64
- iterator vars made scoped
- removed "magic" values from ec-mfd
- simplified logging, detect split into detect and init
- improved error logs formatting
- adjusted handler in media keys to connect strictly to dock keyboard

Changes in v10:
- ec-kbc: fixed possible out of buffer reads
- ec-kbc: set notifier_call before blocking_notifier_chain_register
- ec-keys: dropped input_unregister_device which should be handled by devm_input_allocate_device

Changes in v11:
- applied changes from Florian Krischer (read_size parameterized and fix keyboard response framing)
- ec-kbc: switch notifier and serio register calls
- ec-keys: used WRITE_ONCE()/READ_ONCE() for priv->special_key_pressed

Changes in v12:
- removed unused includes
- fixed kernel-doc warns
- added check if dockram client and data are not NULL
- replaced handler in media keys with Dmitry's implementation
- calculate battery time props with unsigned value
---

Michał Mirosław (6):
mfd: Add driver for ASUS Transformer embedded controller
input: serio: Add driver for ASUS Transformer dock keyboard and
touchpad
input: keyboard: Add driver for ASUS Transformer dock multimedia keys
leds: Add driver for ASUS Transformer LEDs
power: supply: Add driver for ASUS Transformer battery
power: supply: Add charger driver for Asus Transformers

Svyatoslav Ryhel (1):
dt-bindings: embedded-controller: document ASUS Transformer EC

 .../asus,tf201-ec-pad.yaml                    | 119 ++++
 drivers/input/keyboard/Kconfig                |  10 +
 drivers/input/keyboard/Makefile               |   1 +
 .../input/keyboard/asus-transformer-ec-keys.c | 212 +++++++
 drivers/input/serio/Kconfig                   |  15 +
 drivers/input/serio/Makefile                  |   1 +
 drivers/input/serio/asus-transformer-ec-kbc.c | 264 ++++++++
 drivers/leds/Kconfig                          |  11 +
 drivers/leds/Makefile                         |   1 +
 drivers/leds/leds-asus-transformer-ec.c       | 125 ++++
 drivers/mfd/Kconfig                           |  16 +
 drivers/mfd/Makefile                          |   1 +
 drivers/mfd/asus-transformer-ec.c             | 569 ++++++++++++++++++
 drivers/power/supply/Kconfig                  |  22 +
 drivers/power/supply/Makefile                 |   2 +
 .../supply/asus-transformer-ec-battery.c      | 289 +++++++++
 .../supply/asus-transformer-ec-charger.c      | 208 +++++++
 include/linux/mfd/asus-transformer-ec.h       | 100 +++
 18 files changed, 1966 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/embedded-controller/asus,tf201-ec-pad.yaml
 create mode 100644 drivers/input/keyboard/asus-transformer-ec-keys.c
 create mode 100644 drivers/input/serio/asus-transformer-ec-kbc.c
 create mode 100644 drivers/leds/leds-asus-transformer-ec.c
 create mode 100644 drivers/mfd/asus-transformer-ec.c
 create mode 100644 drivers/power/supply/asus-transformer-ec-battery.c
 create mode 100644 drivers/power/supply/asus-transformer-ec-charger.c
 create mode 100644 include/linux/mfd/asus-transformer-ec.h
Signature · 1 line
2.53.0
#1 lore raw

PATCH v12 1/7 dt-bindings: embedded-controller: document ASUS Transformer EC

Document embedded controller used in ASUS Transformer device series.

---
 .../asus,tf201-ec-pad.yaml                    | 119 ++++++++++++++++++
 1 file changed, 119 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/embedded-controller/asus,tf201-ec-pad.yaml
Documentation/devicetree/bindings/embedded-controller/asus,tf201-ec-pad.yaml new file +119 -0
new file mode 100644
index 0000000000000..60b6375864aaf
@@ -0,0 +1,119 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/embedded-controller/asus,tf201-ec-pad.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASUS Transformer's Embedded Controller
+
+description:
+  Several Nuvoton based Embedded Controllers attached to an I2C bus,
+  running a custom ASUS firmware, specific to the ASUS Transformer
+  device series.
+
+maintainers:
+  - Svyatoslav Ryhel <[email protected]>
+
+properties:
+  compatible:
+    description:
+      The 'pad' suffix is used for the controller within the tablet, while
+      the 'dock' suffix refers to the controller in the mobile dock keyboard.
+    oneOf:
+      - enum:
+          - asus,sl101-ec-dock
+          - asus,tf101-ec-dock
+          - asus,tf201-ec-pad
+          - asus,tf600t-ec-dock
+          - asus,tf600t-ec-pad
+
+      - items:
+          - enum:
+              - asus,tf101g-ec-dock
+              - asus,tf201-ec-dock
+              - asus,tf300t-ec-dock
+              - asus,tf300tg-ec-dock
+              - asus,tf300tl-ec-dock
+              - asus,tf700t-ec-dock
+          - const: asus,tf101-ec-dock
+
+      - items:
+          - enum:
+              - asus,tf300t-ec-pad
+              - asus,tf300tg-ec-pad
+              - asus,tf300tl-ec-pad
+              - asus,tf700t-ec-pad
+          - const: asus,tf201-ec-pad
+
+      - items:
+          - enum:
+              - asus,tf701t-ec-dock
+          - const: asus,tf600t-ec-dock
+
+      - items:
+          - enum:
+              - asus,p1801-t-ec-pad
+              - asus,tf701t-ec-pad
+          - const: asus,tf600t-ec-pad
+
+  reg:
+    description:
+      The ASUS Transformer EC has a main I2C address and an associated
+      DockRAM device, which provides power-related functions for the
+      embedded controller. Both addresses are required for operation.
+    minItems: 2
+
+  reg-names:
+    items:
+      - const: ec
+      - const: dockram
+
+  interrupts:
+    maxItems: 1
+
+  request-gpios:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - reg-names
+
+allOf:
+  - $ref: /schemas/power/supply/power-supply.yaml
+  - if:
+      properties:
+        compatible:
+          not:
+            contains:
+              const: asus,tf600t-ec-dock
+    then:
+      required:
+        - interrupts
+        - request-gpios
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      embedded-controller@19 {
+        compatible = "asus,tf201-ec-dock", "asus,tf101-ec-dock";
+        reg = <0x19>, <0x1b>;
+        reg-names = "ec", "dockram";
+
+        interrupt-parent = <&gpio>;
+        interrupts = <151 IRQ_TYPE_LEVEL_LOW>;
+
+        request-gpios = <&gpio 134 GPIO_ACTIVE_LOW>;
+
+        monitored-battery = <&dock_battery>;
+      };
+    };
+...
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v12 1/7] dt-bindings: embedded-controller: document ASUS Transformer EC

Sashiko has reviewed this patch and found no issues.
Quoted 3 lines

Document embedded controller used in ASUS Transformer device series.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

PATCH v12 2/7 mfd: Add driver for ASUS Transformer embedded controller

In reply to Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

Support Nuvoton NPCE795-based ECs as used in Asus Transformer TF201, TF300T, TF300TG, TF300TL and TF700T pad and dock, as well as TF101 dock and TF600T, P1801-T and TF701T pad. This is a glue driver handling detection and common operations for EC's functions.

---
 drivers/mfd/Kconfig                     |  16 +
 drivers/mfd/Makefile                    |   1 +
 drivers/mfd/asus-transformer-ec.c       | 569 ++++++++++++++++++++++++
 include/linux/mfd/asus-transformer-ec.h | 100 +++++
 4 files changed, 686 insertions(+)
 create mode 100644 drivers/mfd/asus-transformer-ec.c
 create mode 100644 include/linux/mfd/asus-transformer-ec.h
drivers/mfd/Kconfig +16 -0
index 0a2778052519f..590f33f19ff62 100644
@@ -137,6 +137,22 @@ config MFD_AAT2870_CORE
 	  additional drivers must be enabled in order to use the
 	  functionality of the device.
 
+config MFD_ASUS_TRANSFORMER_EC
+	tristate "ASUS Transformer's embedded controller"
+	select MFD_CORE
+	depends on I2C && OF
+	help
+	  Select this to enable support for the Embedded Controller (EC)
+	  found in Tegra based ASUS Transformer series tablets and mobile
+	  docks.
+
+	  This driver handles the core I2C communication with the EC and
+	  provides support for its sub-devices, including battery management,
+	  charger detection, LEDs and keyboard dock functions support.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called asus-transformer-ec.
+
 config MFD_AT91_USART
 	tristate "AT91 USART Driver"
 	select MFD_CORE
drivers/mfd/Makefile +1 -0
index 72d3944b0ad8e..873af6376992c 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_MFD_88PM805)	+= 88pm805.o 88pm80x.o
 obj-$(CONFIG_MFD_88PM886_PMIC)	+= 88pm886.o
 obj-$(CONFIG_MFD_ACT8945A)	+= act8945a.o
 obj-$(CONFIG_MFD_SM501)		+= sm501.o
+obj-$(CONFIG_MFD_ASUS_TRANSFORMER_EC)	+= asus-transformer-ec.o
 obj-$(CONFIG_ARCH_BCM2835)	+= bcm2835-pm.o
 obj-$(CONFIG_MFD_BCM590XX)	+= bcm590xx.o
 obj-$(CONFIG_MFD_BD9571MWV)	+= bd9571mwv.o
drivers/mfd/asus-transformer-ec.c new file +569 -0

569 lines not on this page · raw message

include/linux/mfd/asus-transformer-ec.h new file +100 -0

100 lines not on this page · raw message

Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH v12 2/7] mfd: Add driver for ASUS Transformer embedded controller

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] mfd: asus-transformer-ec: hard-coded cell IDs instead of PLATFORM_DEVID_AUTO --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] mfd: asus-transformer-ec: hard-coded cell IDs instead of PLATFORM_DEVID_AUTO --

commit 69f71ab310cf2527cceba8746f7a17bbb27f3ab4
Author: Michał Mirosław <[email protected]>

mfd: Add driver for ASUS Transformer embedded controller

This commit adds an MFD core driver for the Nuvoton NPCE795-based embedded controller found in ASUS Transformer series tablets and keyboard docks. It handles I2C communication, firmware detection, interrupt notifications, and sub-device registration.

Quoted 6 lines
drivers/mfd/asus-transformer-ec.c new file +0 -0
new file mode 100644
index 0000000000000..15942ea59fe1a
@@ -0,0 +1,569 @@

[ ... ]

Quoted 25 lines
drivers/mfd/asus-transformer-ec.c new file +25 -0
+static const struct mfd_cell asus_ec_sl101_dock_mfd_devices[] = {
+	MFD_CELL_NAME("asus-transformer-ec-kbc"),
+};
+
+static const struct mfd_cell asus_ec_tf101_dock_mfd_devices[] = {
+	MFD_CELL_BASIC("asus-transformer-ec-battery", NULL, NULL, 0, 1),
+	MFD_CELL_BASIC("asus-transformer-ec-charger", NULL, NULL, 0, 1),
+	MFD_CELL_BASIC("asus-transformer-ec-led", NULL, NULL, 0, 1),
+	MFD_CELL_NAME("asus-transformer-ec-kbc"),
+	MFD_CELL_NAME("asus-transformer-ec-keys"),
+};
+
+static const struct mfd_cell asus_ec_tf201_pad_mfd_devices[] = {
+	MFD_CELL_NAME("asus-transformer-ec-battery"),
+	MFD_CELL_NAME("asus-transformer-ec-led"),
+};
+
+static const struct mfd_cell asus_ec_tf600t_pad_mfd_devices[] = {
+	MFD_CELL_NAME("asus-transformer-ec-battery"),
+	MFD_CELL_NAME("asus-transformer-ec-charger"),
+	MFD_CELL_NAME("asus-transformer-ec-led"),
+};
+
+static int asus_ec_probe(struct i2c_client *client)
+{

[ ... ]

drivers/mfd/asus-transformer-ec.c line 505

Quoted 6 lines
drivers/mfd/asus-transformer-ec.c new file +6 -0
+	/* Parent I2C controller uses DMA, ASUS EC and child devices do not */
+	client->dev.coherent_dma_mask = 0;
+	client->dev.dma_mask = &client->dev.coherent_dma_mask;
+
+	return devm_mfd_add_devices(dev, 0, cells, num_cells, NULL, 0, NULL);
+}

[Severity: Low]
In asus_ec_probe(), devm_mfd_add_devices() is called with a hard-coded base ID of 0, while asus_ec_tf101_dock_mfd_devices[] manually sets a cell ID of 1 via MFD_CELL_BASIC() for the battery, charger, and led subdevices to offset them from the pad EC cells (leaving kbc and keys at ID 0).

Could devm_mfd_add_devices() pass PLATFORM_DEVID_AUTO instead of 0, so that asus_ec_tf101_dock_mfd_devices[] can use MFD_CELL_NAME() for all entries and rely on automatic cell indexing without risk of platform device name collisions in sysfs if multiple EC instances with identical cell IDs are registered?

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
maintainer
#5 lore raw

Re: [PATCH v12 2/7] mfd: Add driver for ASUS Transformer embedded controller

In reply to Svyatoslav Ryhel

--- checkpatch.pl (4 issues) ---
Line 607: WARNING: DT compatible string "asus,sl101-ec-dock" appears un-documented -- check ./Documentation/devicetree/bindings/ Line 610: WARNING: DT compatible string "asus,tf101-ec-dock" appears un-documented -- check ./Documentation/devicetree/bindings/ Line 613: WARNING: DT compatible string "asus,tf201-ec-pad" appears un-documented -- check ./Documentation/devicetree/bindings/ Line 616: WARNING: DT compatible string "asus,tf600t-ec-pad" appears un-documented -- check ./Documentation/devicetree/bindings/
----------------------------------

Quoted 18 lines · Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

Support Nuvoton NPCE795-based ECs as used in Asus Transformer TF201, TF300T, TF300TG, TF300TL and TF700T pad and dock, as well as TF101 dock and TF600T, P1801-T and TF701T pad. This is a glue driver handling detection and common operations for EC's functions.

---
 drivers/mfd/Kconfig                     |  16 +
 drivers/mfd/Makefile                    |   1 +
 drivers/mfd/asus-transformer-ec.c       | 569 ++++++++++++++++++++++++
 include/linux/mfd/asus-transformer-ec.h | 100 +++++
 4 files changed, 686 insertions(+)
 create mode 100644 drivers/mfd/asus-transformer-ec.c
 create mode 100644 include/linux/mfd/asus-transformer-ec.h

[...]

drivers/mfd/asus-transformer-ec.c line 232

Quoted 7 lines
drivers/mfd/asus-transformer-ec.c new file +7 -0
+static int asus_ec_reset(struct asus_ec_data *ddata)
+{
+	int retry, ret;
+
+	guard(mutex)(&ddata->ecreq_lock);
+
+	for (retry = 0; retry < ASUSEC_RETRY_MAX; retry++) {

As mentioned on v8, 'for (int retry = 0; ...)' is generally preferred for throw-away loop variables.

Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+		ret = i2c_smbus_write_word_data(ddata->client, ASUSEC_WRITE_BUF,
+						ASUSEC_RESET);
+		if (!ret)
+			return 0;
+
+		msleep(ASUSEC_ACCESS_TIMEOUT);
+	}
+
+	return ret;
+}

[...]

Quoted 78 lines
drivers/mfd/asus-transformer-ec.c new file +78 -0
+static int asus_ec_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct asus_ec_data *ddata;
+	const struct mfd_cell *cells;
+	unsigned int num_cells;
+	unsigned long irqflags;
+	int ret;
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
+		return dev_err_probe(dev, -ENXIO,
+			"I2C bus is missing required SMBus block mode support\n");
+
+	ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+	if (!ddata)
+		return -ENOMEM;
+
+	ddata->info = device_get_match_data(dev);
+	if (!ddata->info)
+		return -ENODEV;
+
+	switch (ddata->info->variant) {
+	case ASUSEC_SL101_DOCK:
+		cells = asus_ec_sl101_dock_mfd_devices;
+		num_cells = ARRAY_SIZE(asus_ec_sl101_dock_mfd_devices);
+		break;
+	case ASUSEC_TF101_DOCK:
+		cells = asus_ec_tf101_dock_mfd_devices;
+		num_cells = ARRAY_SIZE(asus_ec_tf101_dock_mfd_devices);
+		break;
+	case ASUSEC_TF201_PAD:
+		cells = asus_ec_tf201_pad_mfd_devices;
+		num_cells = ARRAY_SIZE(asus_ec_tf201_pad_mfd_devices);
+		break;
+	case ASUSEC_TF600T_PAD:
+		cells = asus_ec_tf600t_pad_mfd_devices;
+		num_cells = ARRAY_SIZE(asus_ec_tf600t_pad_mfd_devices);
+		break;
+	default:
+		return dev_err_probe(dev, -EINVAL,
+				     "unknown device variant %d\n",
+				     ddata->info->variant);
+	}
+
+	i2c_set_clientdata(client, ddata);
+	ddata->client = client;
+
+	ddata->ec.dockram = devm_asus_dockram_get(dev);
+	if (IS_ERR(ddata->ec.dockram))
+		return dev_err_probe(dev, PTR_ERR(ddata->ec.dockram),
+				     "failed to get dockram\n");
+
+	ddata->ecreq_gpio = devm_gpiod_get(dev, "request", GPIOD_OUT_LOW);
+	if (IS_ERR(ddata->ecreq_gpio))
+		return dev_err_probe(dev, PTR_ERR(ddata->ecreq_gpio),
+				     "failed to get EC request GPIO\n");
+
+	BLOCKING_INIT_NOTIFIER_HEAD(&ddata->ec.notify_list);
+	mutex_init(&ddata->ecreq_lock);
+
+	asus_ec_signal_request(ddata);
+
+	ret = asus_ec_detect(ddata);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to detect EC version\n");
+
+	ret = asus_ec_init(ddata);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to init EC\n");
+
+	/*
+	 * Systems using device tree should set up interrupt via DTS,
+	 * the rest will use the default low interrupt.
+	 */
+	irqflags = dev->of_node ? 0 : IRQF_TRIGGER_LOW;
+
+	ret = devm_request_threaded_irq(dev, client->irq, NULL,
+					&asus_ec_interrupt,

drivers/mfd/asus-transformer-ec.c line 504

Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+					IRQF_ONESHOT | irqflags,
+					client->name, ddata);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to register IRQ\n");
+
+	/* Parent I2C controller uses DMA, ASUS EC and child devices do not */
+	client->dev.coherent_dma_mask = 0;
+	client->dev.dma_mask = &client->dev.coherent_dma_mask;
+
+	return devm_mfd_add_devices(dev, 0, cells, num_cells, NULL, 0, NULL);

Why not use 'PLATFORM_DEVID_NONE' or 'PLATFORM_DEVID_AUTO' here instead of a raw '0' and hard-coded cell IDs in 'asus_ec_tf101_dock_mfd_devices'?

Quoted 1 line

+}

Signature · 1 line
Lee Jones
#6 lore raw

Re: [PATCH v12 2/7] mfd: Add driver for ASUS Transformer embedded controller

вт, 3 лист. 2026 р. о 13:43 Lee Jones <[email protected]> пише:

Quoted 30 lines

--- checkpatch.pl (4 issues) ---
Line 607: WARNING: DT compatible string "asus,sl101-ec-dock" appears un-documented -- check ./Documentation/devicetree/bindings/ Line 610: WARNING: DT compatible string "asus,tf101-ec-dock" appears un-documented -- check ./Documentation/devicetree/bindings/ Line 613: WARNING: DT compatible string "asus,tf201-ec-pad" appears un-documented -- check ./Documentation/devicetree/bindings/ Line 616: WARNING: DT compatible string "asus,tf600t-ec-pad" appears un-documented -- check ./Documentation/devicetree/bindings/
----------------------------------

Quoted 18 lines · Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

Support Nuvoton NPCE795-based ECs as used in Asus Transformer TF201, TF300T, TF300TG, TF300TL and TF700T pad and dock, as well as TF101 dock and TF600T, P1801-T and TF701T pad. This is a glue driver handling detection and common operations for EC's functions.

---
 drivers/mfd/Kconfig                     |  16 +
 drivers/mfd/Makefile                    |   1 +
 drivers/mfd/asus-transformer-ec.c       | 569 ++++++++++++++++++++++++
 include/linux/mfd/asus-transformer-ec.h | 100 +++++
 4 files changed, 686 insertions(+)
 create mode 100644 drivers/mfd/asus-transformer-ec.c
 create mode 100644 include/linux/mfd/asus-transformer-ec.h

[...]

Quoted 11 lines

drivers/mfd/asus-transformer-ec.c line 232

Quoted 7 lines
drivers/mfd/asus-transformer-ec.c new file +7 -0
+static int asus_ec_reset(struct asus_ec_data *ddata)
+{
+     int retry, ret;
+
+     guard(mutex)(&ddata->ecreq_lock);
+
+     for (retry = 0; retry < ASUSEC_RETRY_MAX; retry++) {

As mentioned on v8, 'for (int retry = 0; ...)' is generally preferred for throw-away loop variables.

I must have overlooked this, appologies.

Quoted 96 lines
Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+             ret = i2c_smbus_write_word_data(ddata->client, ASUSEC_WRITE_BUF,
+                                             ASUSEC_RESET);
+             if (!ret)
+                     return 0;
+
+             msleep(ASUSEC_ACCESS_TIMEOUT);
+     }
+
+     return ret;
+}

[...]

Quoted 83 lines
drivers/mfd/asus-transformer-ec.c new file +83 -0
+static int asus_ec_probe(struct i2c_client *client)
+{
+     struct device *dev = &client->dev;
+     struct asus_ec_data *ddata;
+     const struct mfd_cell *cells;
+     unsigned int num_cells;
+     unsigned long irqflags;
+     int ret;
+
+     if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
+             return dev_err_probe(dev, -ENXIO,
+                     "I2C bus is missing required SMBus block mode support\n");
+
+     ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+     if (!ddata)
+             return -ENOMEM;
+
+     ddata->info = device_get_match_data(dev);
+     if (!ddata->info)
+             return -ENODEV;
+
+     switch (ddata->info->variant) {
+     case ASUSEC_SL101_DOCK:
+             cells = asus_ec_sl101_dock_mfd_devices;
+             num_cells = ARRAY_SIZE(asus_ec_sl101_dock_mfd_devices);
+             break;
+     case ASUSEC_TF101_DOCK:
+             cells = asus_ec_tf101_dock_mfd_devices;
+             num_cells = ARRAY_SIZE(asus_ec_tf101_dock_mfd_devices);
+             break;
+     case ASUSEC_TF201_PAD:
+             cells = asus_ec_tf201_pad_mfd_devices;
+             num_cells = ARRAY_SIZE(asus_ec_tf201_pad_mfd_devices);
+             break;
+     case ASUSEC_TF600T_PAD:
+             cells = asus_ec_tf600t_pad_mfd_devices;
+             num_cells = ARRAY_SIZE(asus_ec_tf600t_pad_mfd_devices);
+             break;
+     default:
+             return dev_err_probe(dev, -EINVAL,
+                                  "unknown device variant %d\n",
+                                  ddata->info->variant);
+     }
+
+     i2c_set_clientdata(client, ddata);
+     ddata->client = client;
+
+     ddata->ec.dockram = devm_asus_dockram_get(dev);
+     if (IS_ERR(ddata->ec.dockram))
+             return dev_err_probe(dev, PTR_ERR(ddata->ec.dockram),
+                                  "failed to get dockram\n");
+
+     ddata->ecreq_gpio = devm_gpiod_get(dev, "request", GPIOD_OUT_LOW);
+     if (IS_ERR(ddata->ecreq_gpio))
+             return dev_err_probe(dev, PTR_ERR(ddata->ecreq_gpio),
+                                  "failed to get EC request GPIO\n");
+
+     BLOCKING_INIT_NOTIFIER_HEAD(&ddata->ec.notify_list);
+     mutex_init(&ddata->ecreq_lock);
+
+     asus_ec_signal_request(ddata);
+
+     ret = asus_ec_detect(ddata);
+     if (ret)
+             return dev_err_probe(dev, ret, "failed to detect EC version\n");
+
+     ret = asus_ec_init(ddata);
+     if (ret)
+             return dev_err_probe(dev, ret, "failed to init EC\n");
+
+     /*
+      * Systems using device tree should set up interrupt via DTS,
+      * the rest will use the default low interrupt.
+      */
+     irqflags = dev->of_node ? 0 : IRQF_TRIGGER_LOW;
+
+     ret = devm_request_threaded_irq(dev, client->irq, NULL,
+                                     &asus_ec_interrupt,
+                                     IRQF_ONESHOT | irqflags,
+                                     client->name, ddata);
+     if (ret)
+             return dev_err_probe(dev, ret, "failed to register IRQ\n");
+
Quoted 9 lines

drivers/mfd/asus-transformer-ec.c line 504

Quoted 5 lines
drivers/mfd/asus-transformer-ec.c new file +5 -0
+     /* Parent I2C controller uses DMA, ASUS EC and child devices do not */
+     client->dev.coherent_dma_mask = 0;
+     client->dev.dma_mask = &client->dev.coherent_dma_mask;
+
+     return devm_mfd_add_devices(dev, 0, cells, num_cells, NULL, 0, NULL);

Why not use 'PLATFORM_DEVID_NONE' or 'PLATFORM_DEVID_AUTO' here instead of a raw '0' and hard-coded cell IDs in 'asus_ec_tf101_dock_mfd_devices'?

There can be more then 1 EC in the tablet. PLATFORM_DEVID_NONE will not work in this case and PLATFORM_DEVID_AUTO should work, but one of EC is detachable (dock one) so devices there may need a fixed id. I can test if PLATFORM_DEVID_AUTO works, but may this be sent as a followup?

Quoted 4 lines
Quoted 1 line

+}

--
Lee Jones

maintainer
#7 lore raw

Re: [PATCH v12 2/7] mfd: Add driver for ASUS Transformer embedded controller

Quoted 151 lines · Svyatoslav Ryhel

вт, 3 лист. 2026 р. о 13:43 Lee Jones <[email protected]> пише:

Quoted 30 lines

--- checkpatch.pl (4 issues) ---
Line 607: WARNING: DT compatible string "asus,sl101-ec-dock" appears un-documented -- check ./Documentation/devicetree/bindings/ Line 610: WARNING: DT compatible string "asus,tf101-ec-dock" appears un-documented -- check ./Documentation/devicetree/bindings/ Line 613: WARNING: DT compatible string "asus,tf201-ec-pad" appears un-documented -- check ./Documentation/devicetree/bindings/ Line 616: WARNING: DT compatible string "asus,tf600t-ec-pad" appears un-documented -- check ./Documentation/devicetree/bindings/
----------------------------------

Quoted 18 lines · Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

Support Nuvoton NPCE795-based ECs as used in Asus Transformer TF201, TF300T, TF300TG, TF300TL and TF700T pad and dock, as well as TF101 dock and TF600T, P1801-T and TF701T pad. This is a glue driver handling detection and common operations for EC's functions.

---
 drivers/mfd/Kconfig                     |  16 +
 drivers/mfd/Makefile                    |   1 +
 drivers/mfd/asus-transformer-ec.c       | 569 ++++++++++++++++++++++++
 include/linux/mfd/asus-transformer-ec.h | 100 +++++
 4 files changed, 686 insertions(+)
 create mode 100644 drivers/mfd/asus-transformer-ec.c
 create mode 100644 include/linux/mfd/asus-transformer-ec.h

[...]

Quoted 11 lines

drivers/mfd/asus-transformer-ec.c line 232

Quoted 7 lines
drivers/mfd/asus-transformer-ec.c new file +7 -0
+static int asus_ec_reset(struct asus_ec_data *ddata)
+{
+     int retry, ret;
+
+     guard(mutex)(&ddata->ecreq_lock);
+
+     for (retry = 0; retry < ASUSEC_RETRY_MAX; retry++) {

As mentioned on v8, 'for (int retry = 0; ...)' is generally preferred for throw-away loop variables.

I must have overlooked this, appologies.

Quoted 96 lines
Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+             ret = i2c_smbus_write_word_data(ddata->client, ASUSEC_WRITE_BUF,
+                                             ASUSEC_RESET);
+             if (!ret)
+                     return 0;
+
+             msleep(ASUSEC_ACCESS_TIMEOUT);
+     }
+
+     return ret;
+}

[...]

Quoted 83 lines
drivers/mfd/asus-transformer-ec.c new file +83 -0
+static int asus_ec_probe(struct i2c_client *client)
+{
+     struct device *dev = &client->dev;
+     struct asus_ec_data *ddata;
+     const struct mfd_cell *cells;
+     unsigned int num_cells;
+     unsigned long irqflags;
+     int ret;
+
+     if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
+             return dev_err_probe(dev, -ENXIO,
+                     "I2C bus is missing required SMBus block mode support\n");
+
+     ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+     if (!ddata)
+             return -ENOMEM;
+
+     ddata->info = device_get_match_data(dev);
+     if (!ddata->info)
+             return -ENODEV;
+
+     switch (ddata->info->variant) {
+     case ASUSEC_SL101_DOCK:
+             cells = asus_ec_sl101_dock_mfd_devices;
+             num_cells = ARRAY_SIZE(asus_ec_sl101_dock_mfd_devices);
+             break;
+     case ASUSEC_TF101_DOCK:
+             cells = asus_ec_tf101_dock_mfd_devices;
+             num_cells = ARRAY_SIZE(asus_ec_tf101_dock_mfd_devices);
+             break;
+     case ASUSEC_TF201_PAD:
+             cells = asus_ec_tf201_pad_mfd_devices;
+             num_cells = ARRAY_SIZE(asus_ec_tf201_pad_mfd_devices);
+             break;
+     case ASUSEC_TF600T_PAD:
+             cells = asus_ec_tf600t_pad_mfd_devices;
+             num_cells = ARRAY_SIZE(asus_ec_tf600t_pad_mfd_devices);
+             break;
+     default:
+             return dev_err_probe(dev, -EINVAL,
+                                  "unknown device variant %d\n",
+                                  ddata->info->variant);
+     }
+
+     i2c_set_clientdata(client, ddata);
+     ddata->client = client;
+
+     ddata->ec.dockram = devm_asus_dockram_get(dev);
+     if (IS_ERR(ddata->ec.dockram))
+             return dev_err_probe(dev, PTR_ERR(ddata->ec.dockram),
+                                  "failed to get dockram\n");
+
+     ddata->ecreq_gpio = devm_gpiod_get(dev, "request", GPIOD_OUT_LOW);
+     if (IS_ERR(ddata->ecreq_gpio))
+             return dev_err_probe(dev, PTR_ERR(ddata->ecreq_gpio),
+                                  "failed to get EC request GPIO\n");
+
+     BLOCKING_INIT_NOTIFIER_HEAD(&ddata->ec.notify_list);
+     mutex_init(&ddata->ecreq_lock);
+
+     asus_ec_signal_request(ddata);
+
+     ret = asus_ec_detect(ddata);
+     if (ret)
+             return dev_err_probe(dev, ret, "failed to detect EC version\n");
+
+     ret = asus_ec_init(ddata);
+     if (ret)
+             return dev_err_probe(dev, ret, "failed to init EC\n");
+
+     /*
+      * Systems using device tree should set up interrupt via DTS,
+      * the rest will use the default low interrupt.
+      */
+     irqflags = dev->of_node ? 0 : IRQF_TRIGGER_LOW;
+
+     ret = devm_request_threaded_irq(dev, client->irq, NULL,
+                                     &asus_ec_interrupt,
+                                     IRQF_ONESHOT | irqflags,
+                                     client->name, ddata);
+     if (ret)
+             return dev_err_probe(dev, ret, "failed to register IRQ\n");
+
Quoted 9 lines

drivers/mfd/asus-transformer-ec.c line 504

Quoted 5 lines
drivers/mfd/asus-transformer-ec.c new file +5 -0
+     /* Parent I2C controller uses DMA, ASUS EC and child devices do not */
+     client->dev.coherent_dma_mask = 0;
+     client->dev.dma_mask = &client->dev.coherent_dma_mask;
+
+     return devm_mfd_add_devices(dev, 0, cells, num_cells, NULL, 0, NULL);

Why not use 'PLATFORM_DEVID_NONE' or 'PLATFORM_DEVID_AUTO' here instead of a raw '0' and hard-coded cell IDs in 'asus_ec_tf101_dock_mfd_devices'?

Quoted 5 lines

There can be more then 1 EC in the tablet. PLATFORM_DEVID_NONE will not work in this case and PLATFORM_DEVID_AUTO should work, but one of EC is detachable (dock one) so devices there may need a fixed id. I can test if PLATFORM_DEVID_AUTO works, but may this be sent as a followup?

Sure.

Signature · 1 line
Lee Jones
#8 lore raw

PATCH v12 3/7 input: serio: Add driver for ASUS Transformer dock keyboard and touchpad

In reply to Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

Add input driver for ASUS Transformer dock keyboard and touchpad.

Some keys in ASUS Dock report keycodes that don't make sense according to their position, this patch modifies the incoming data that is sent to serio to send proper scancodes.

---
 drivers/input/serio/Kconfig                   |  15 +
 drivers/input/serio/Makefile                  |   1 +
 drivers/input/serio/asus-transformer-ec-kbc.c | 264 ++++++++++++++++++
 3 files changed, 280 insertions(+)
 create mode 100644 drivers/input/serio/asus-transformer-ec-kbc.c
drivers/input/serio/Kconfig +15 -0
index 087f0203fff99..58d415ca1d540 100644
@@ -84,6 +84,21 @@ config SERIO_RPCKBD
 	  To compile this driver as a module, choose M here: the
 	  module will be called rpckbd.
 
+config SERIO_ASUS_TRANSFORMER_EC
+	tristate "Asus Transformer's Dock keyboard and touchpad controller"
+	depends on MFD_ASUS_TRANSFORMER_EC
+	help
+	  Say Y here if you want to use the keyboard and/or touchpad on
+	  Asus Transformed's Mobile Dock.
+
+	  For keyboard support you also need atkbd driver.
+
+	  For touchpad support you also need psmouse driver with Elantech
+	  touchpad option enabled.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called asus-transformer-ec-kbc.
+
 config SERIO_AMBAKMI
 	tristate "AMBA KMI keyboard controller"
 	depends on ARM_AMBA
drivers/input/serio/Makefile +1 -0
index 7f5137dc02e26..bed2a7a92a13d 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_SERIO_SERPORT)	+= serport.o
 obj-$(CONFIG_SERIO_RPCKBD)	+= rpckbd.o
 obj-$(CONFIG_SERIO_SA1111)	+= sa1111ps2.o
 obj-$(CONFIG_SERIO_AMBAKMI)	+= ambakmi.o
+obj-$(CONFIG_SERIO_ASUS_TRANSFORMER_EC)	+= asus-transformer-ec-kbc.o
 obj-$(CONFIG_SERIO_Q40KBD)	+= q40kbd.o
 obj-$(CONFIG_SERIO_GSCPS2)	+= gscps2.o
 obj-$(CONFIG_HP_SDC)		+= hp_sdc.o
drivers/input/serio/asus-transformer-ec-kbc.c new file +264 -0

264 lines not on this page · raw message

Signature · 1 line
2.53.0
#9 lore raw

Re: [PATCH v12 3/7] input: serio: Add driver for ASUS Transformer dock keyboard and touchpad

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] input: serio: serio ports registered before notifier in asus_ec_kbc_probe() --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] input: serio: serio ports registered before notifier in asus_ec_kbc_probe() --

commit 03f99aa77c8833478d88304ecd5af6dc8d7131c2
Author: Michał Mirosław <[email protected]>

input: serio: Add driver for ASUS Transformer dock keyboard and touchpad

This commit adds a serio driver for the ASUS Transformer dock keyboard and touchpad controller, forwarding EC notifications to serio ports and remapping several non-standard keycodes.

Quoted 6 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +0 -0
new file mode 100644
index 0000000000000..fa7f7c3f037db
@@ -0,0 +1,264 @@

[ ... ]

Quoted 57 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +57 -0
+static int asus_ec_register_serio(struct platform_device *pdev, int idx,
+				  const char *name, int cmd)
+{
+	struct asus_ec_kbc_data *priv = platform_get_drvdata(pdev);
+	struct i2c_client *parent = priv->parent;
+	struct serio *port = kzalloc_obj(*port);
+
+	if (!port)
+		return -ENOMEM;
+
+	priv->sdev[idx] = port;
+	port->dev.parent = &pdev->dev;
+	port->id.type = SERIO_8042;
+	port->id.extra = cmd & 0xFF;
+	port->write = asus_ec_serio_write;
+	port->port_data = (void *)priv;
+	snprintf(port->name, sizeof(port->name), "%s %s",
+		 priv->ec->model, name);
+	snprintf(port->phys, sizeof(port->phys), "i2c-%u-%04x/serio%d",
+		 i2c_adapter_id(parent->adapter), parent->addr, idx);
+
+	serio_register_port(port);
+
+	return devm_add_action_or_reset(&pdev->dev, asus_ec_serio_remove, port);
+}
+
+static void asus_ec_notifier_chain_unregister(void *data)
+{
+	struct asus_ec_kbc_data *priv = data;
+	struct asusec_core *ec = priv->ec;
+
+	blocking_notifier_chain_unregister(&ec->notify_list, &priv->nb);
+}
+
+static int asus_ec_kbc_probe(struct platform_device *pdev)
+{
+	struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
+	struct asus_ec_kbc_data *priv;
+	int error;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, priv);
+
+	priv->ec = ec;
+	priv->parent = to_i2c_client(pdev->dev.parent);
+
+	error = asus_ec_register_serio(pdev, 0, "Keyboard", 0);
+	if (error)
+		return error;
+
+	error = asus_ec_register_serio(pdev, 1, "Touchpad", I8042_CMD_AUX_SEND);
+	if (error)
+		return error;
+

drivers/input/serio/asus-transformer-ec-kbc.c line 248

Quoted 10 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +10 -0
+	priv->nb.notifier_call = asus_ec_kbc_notify;
+
+	error = blocking_notifier_chain_register(&ec->notify_list, &priv->nb);
+	if (error)
+		return dev_err_probe(&pdev->dev, error,
+				     "failed to register blocking notifier chain");
+
+	error = devm_add_action_or_reset(&pdev->dev,
+					 asus_ec_notifier_chain_unregister,
+					 priv);

[Severity: Medium]
Can registering the serio ports before registering the notifier in asus_ec_kbc_probe() cause a race with serio driver probing?

Inside asus_ec_register_serio(), serio_register_port() immediately queues SERIO_REGISTER_PORT onto system_long_wq (serio_event_work). If serio_event_work runs on another CPU before blocking_notifier_chain_register() completes, serio_add_port() will bind atkbd or psmouse, which immediately send PS/2 reset and identification commands via asus_ec_serio_write() and wait for responses via serio_interrupt().

Since the parent MFD driver has already enabled its IRQ handler asus_ec_interrupt(), the EC response will be read from ASUSEC_READ_BUF and passed to blocking_notifier_call_chain(&ddata->ec.notify_list, ...) before priv->nb is on the list, dropping the response bytes and causing ps2_command() timeouts.

Similarly, on driver unbind, devm will run asus_ec_notifier_chain_unregister() before asus_ec_serio_remove() calls serio_unregister_port(), disconnecting the receive path while the serio ports and their drivers are still active.

Should the notifier be registered (or gated via serio open/close or start/stop callbacks with priv->sdev[] initialized beforehand) so that the receive path is active whenever the serio ports are registered?

Quoted 5 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +5 -0
+	if (error)
+		return error;
+
+	return 0;
+}

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#10 lore raw

Re: [PATCH v12 3/7] input: serio: Add driver for ASUS Transformer dock keyboard and touchpad

In reply to Svyatoslav Ryhel

пн, 19 жовт. 2026 р. о 13:04 Svyatoslav Ryhel <[email protected]> пише:

Quoted 13 lines

From: Michał Mirosław <[email protected]>

Add input driver for ASUS Transformer dock keyboard and touchpad.

Some keys in ASUS Dock report keycodes that don't make sense according to their position, this patch modifies the incoming data that is sent to serio to send proper scancodes.

Quoted 7 lines
---
 drivers/input/serio/Kconfig                   |  15 +
 drivers/input/serio/Makefile                  |   1 +
 drivers/input/serio/asus-transformer-ec-kbc.c | 264 ++++++++++++++++++
 3 files changed, 280 insertions(+)
 create mode 100644 drivers/input/serio/asus-transformer-ec-kbc.c

Hello Dmitry!

Would you mind to add your ACK/Review to input patches so this patchset could be finally picked.

Thank you!

Best regards,
Svyatoslav R.

maintainer Acked-by on v12 3/7
#11 lore raw

Re: [PATCH v12 3/7] input: serio: Add driver for ASUS Transformer dock keyboard and touchpad

In reply to Svyatoslav Ryhel
Quoted 4 lines · Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

Add input driver for ASUS Transformer dock keyboard and touchpad.

Quoted 8 lines

Some keys in ASUS Dock report keycodes that don't make sense according to their position, this patch modifies the incoming data that is sent to serio to send proper scancodes.

Quoted 19 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +19 -0
+static int asus_ec_kbc_probe(struct platform_device *pdev)
+{
+	struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
+	struct asus_ec_kbc_data *priv;
+	int error;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, priv);
+
+	priv->ec = ec;
+	priv->parent = to_i2c_client(pdev->dev.parent);
+
+	error = asus_ec_register_serio(pdev, 0, "Keyboard", 0);
+	if (error)
+		return error;
+

drivers/input/serio/asus-transformer-ec-kbc.c line 244

Quoted 10 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +10 -0
+	error = asus_ec_register_serio(pdev, 1, "Touchpad", I8042_CMD_AUX_SEND);
+	if (error)
+		return error;
+
+	priv->nb.notifier_call = asus_ec_kbc_notify;
+
+	error = blocking_notifier_chain_register(&ec->notify_list, &priv->nb);
+	if (error)
+		return dev_err_probe(&pdev->dev, error,
+				     "failed to register blocking notifier chain");

I think sashiko is right that we need to register the notifier first, and in it check if serio ports are ready/registered or not. For that we probably need a lock and set pointers or flags in serio's start()/stop() or open()/close() methods.

This can be done as a followup I think.

Thanks.

Signature · 1 line
Dmitry
#12 lore raw

Re: [PATCH v12 3/7] input: serio: Add driver for ASUS Transformer dock keyboard and touchpad

вт, 20 жовт. 2026 р. о 22:04 Dmitry Torokhov <[email protected]> пише:

Quoted 52 lines · Svyatoslav Ryhel
Quoted 4 lines

From: Michał Mirosław <[email protected]>

Add input driver for ASUS Transformer dock keyboard and touchpad.

Quoted 8 lines

Some keys in ASUS Dock report keycodes that don't make sense according to their position, this patch modifies the incoming data that is sent to serio to send proper scancodes.

Quoted 19 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +19 -0
+static int asus_ec_kbc_probe(struct platform_device *pdev)
+{
+     struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
+     struct asus_ec_kbc_data *priv;
+     int error;
+
+     priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+     if (!priv)
+             return -ENOMEM;
+
+     platform_set_drvdata(pdev, priv);
+
+     priv->ec = ec;
+     priv->parent = to_i2c_client(pdev->dev.parent);
+
+     error = asus_ec_register_serio(pdev, 0, "Keyboard", 0);
+     if (error)
+             return error;
+

drivers/input/serio/asus-transformer-ec-kbc.c line 244

Quoted 10 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +10 -0
+     error = asus_ec_register_serio(pdev, 1, "Touchpad", I8042_CMD_AUX_SEND);
+     if (error)
+             return error;
+
+     priv->nb.notifier_call = asus_ec_kbc_notify;
+
+     error = blocking_notifier_chain_register(&ec->notify_list, &priv->nb);
+     if (error)
+             return dev_err_probe(&pdev->dev, error,
+                                  "failed to register blocking notifier chain");

I think sashiko is right that we need to register the notifier first, and in it check if serio ports are ready/registered or not. For that we probably need a lock and set pointers or flags in serio's start()/stop() or open()/close() methods.

Quoted 2 lines

This can be done as a followup I think.

FYI, Sashiko likes to hallucinate. Initially notifier was registered after ports, then sashiko suggested to move it before. Then in v10 it fussed again and suggested to move after. Then v11 passed without regressions and now in v12 it fusses again that notifier should be before.

Quoted 4 lines

Thanks.

--
Dmitry

#13 lore raw

PATCH v12 4/7 input: keyboard: Add driver for ASUS Transformer dock multimedia keys

In reply to Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

Add support for multimedia top button row of ASUS Transformer's Mobile Dock keyboard. Driver is made that function keys (F1-F12) are used by default which suits average Linux use better and with pressing ScreenLock + AltGr function keys layout is switched to multimedia keys. Only Dock keyboard input events are tracked for AltGr pressing.

---
 drivers/input/keyboard/Kconfig                |  10 +
 drivers/input/keyboard/Makefile               |   1 +
 .../input/keyboard/asus-transformer-ec-keys.c | 212 ++++++++++++++++++
 3 files changed, 223 insertions(+)
 create mode 100644 drivers/input/keyboard/asus-transformer-ec-keys.c
drivers/input/keyboard/Kconfig +10 -0
index d8c64f333462c..728bc068667e7 100644
@@ -89,6 +89,16 @@ config KEYBOARD_APPLESPI
 	  To compile this driver as a module, choose M here: the
 	  module will be called applespi.
 
+config KEYBOARD_ASUS_TRANSFORMER_EC
+	tristate "Asus Transformer's Mobile Dock multimedia keys"
+	depends on MFD_ASUS_TRANSFORMER_EC
+	help
+	  Say Y here if you want to use multimedia keys present on Asus
+	  Transformer's Mobile Dock.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called asus-transformer-ec-keys.
+
 config KEYBOARD_ATARI
 	tristate "Atari keyboard"
 	depends on ATARI
drivers/input/keyboard/Makefile +1 -0
index 60bb7baf802f7..0d81096887ada 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_KEYBOARD_ADP5585)		+= adp5585-keys.o
 obj-$(CONFIG_KEYBOARD_ADP5588)		+= adp5588-keys.o
 obj-$(CONFIG_KEYBOARD_AMIGA)		+= amikbd.o
 obj-$(CONFIG_KEYBOARD_APPLESPI)		+= applespi.o
+obj-$(CONFIG_KEYBOARD_ASUS_TRANSFORMER_EC)	+= asus-transformer-ec-keys.o
 obj-$(CONFIG_KEYBOARD_ATARI)		+= atakbd.o
 obj-$(CONFIG_KEYBOARD_ATKBD)		+= atkbd.o
 obj-$(CONFIG_KEYBOARD_BCM)		+= bcm-keypad.o
drivers/input/keyboard/asus-transformer-ec-keys.c new file +212 -0

212 lines not on this page · raw message

Signature · 1 line
2.53.0
#14 lore raw

Re: [PATCH v12 4/7] input: keyboard: Add driver for ASUS Transformer dock multimedia keys

Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

From: Michał Mirosław <[email protected]>

Add support for multimedia top button row of ASUS Transformer's Mobile Dock keyboard. Driver is made that function keys (F1-F12) are used by default which suits average Linux use better and with pressing ScreenLock + AltGr function keys layout is switched to multimedia keys. Only Dock keyboard input events are tracked for AltGr pressing.

Quoted 4 lines

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
maintainer Acked-by on v12 4/7
#15 lore raw

Re: [PATCH v12 4/7] input: keyboard: Add driver for ASUS Transformer dock multimedia keys

In reply to Svyatoslav Ryhel
Quoted 8 lines · Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

Add support for multimedia top button row of ASUS Transformer's Mobile Dock keyboard. Driver is made that function keys (F1-F12) are used by default which suits average Linux use better and with pressing ScreenLock + AltGr function keys layout is switched to multimedia keys. Only Dock keyboard input events are tracked for AltGr pressing.

Quoted 4 lines
Quoted 10 lines
drivers/input/keyboard/asus-transformer-ec-keys.c new file +10 -0
+
+static void asus_ec_keys_setup_keymap(struct asus_ec_keys_data *priv)
+{
+	struct input_dev *dev = priv->xidev;
+	unsigned int i;
+
+	BUILD_BUG_ON(ARRAY_SIZE(priv->keymap) < ARRAY_SIZE(asus_ec_dock_ext_keys));
+
+	dev->keycode = priv->keymap;
+	dev->keycodesize = sizeof(*priv->keymap);

drivers/input/keyboard/asus-transformer-ec-keys.c line 140

Quoted 10 lines
drivers/input/keyboard/asus-transformer-ec-keys.c new file +10 -0
+	dev->keycodemax = ARRAY_SIZE(priv->keymap);
+
+	input_set_capability(dev, EV_MSC, MSC_SCAN);
+	input_set_capability(dev, EV_KEY, KEY_UNKNOWN);
+
+	for (i = 0; i < ARRAY_SIZE(asus_ec_dock_ext_keys); i++) {
+		unsigned int code = asus_ec_dock_ext_keys[i];
+
+		if (!code)
+			continue;

Nit: this check is not needed, input core will remove KEY_RESERVED (0) from the keybit when device is registered.

Quoted 38 lines
drivers/input/keyboard/asus-transformer-ec-keys.c new file +38 -0
+
+		__set_bit(code, dev->keybit);
+		priv->keymap[i] = code;
+	}
+}
+
+static int asus_ec_keys_probe(struct platform_device *pdev)
+{
+	struct i2c_client *parent = to_i2c_client(pdev->dev.parent);
+	struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
+	struct device *dev = &pdev->dev;
+	struct asus_ec_keys_data *priv;
+	int error;
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, priv);
+	priv->ec = ec;
+
+	priv->xidev = devm_input_allocate_device(dev);
+	if (!priv->xidev)
+		return -ENOMEM;
+
+	priv->xidev->name = devm_kasprintf(dev, GFP_KERNEL, "%s Keyboard Ext",
+					   ec->model);
+	priv->xidev->phys = devm_kasprintf(dev, GFP_KERNEL, "i2c-%u-%04x",
+					   i2c_adapter_id(parent->adapter),
+					   parent->addr);
+
+	if (!priv->xidev->name || !priv->xidev->phys)
+		return -ENOMEM;
+
+	asus_ec_keys_setup_keymap(priv);
+
+	error = input_register_device(priv->xidev);
+	if (error)

drivers/input/keyboard/asus-transformer-ec-keys.c line 188

Quoted 10 lines
drivers/input/keyboard/asus-transformer-ec-keys.c new file +10 -0
+		return dev_err_probe(dev, error,
+				     "failed to register extension keys\n");
+
+	priv->nb.notifier_call = asus_ec_keys_notify;
+
+	error = blocking_notifier_chain_register(&ec->notify_list, &priv->nb);
+	if (error)
+		return error;
+
+	ec->ext_keys_enabled = true;

I think this block (after input_register_device()) can go into open() method for the input device.

drivers/input/keyboard/asus-transformer-ec-keys.c line 199

Quoted 11 lines
drivers/input/keyboard/asus-transformer-ec-keys.c new file +11 -0
+
+	return 0;
+}
+
+static void asus_ec_keys_remove(struct platform_device *pdev)
+{
+	struct asus_ec_keys_data *priv = platform_get_drvdata(pdev);
+	struct asusec_core *ec = priv->ec;
+
+	ec->ext_keys_enabled = false;
+	blocking_notifier_chain_unregister(&ec->notify_list, &priv->nb);

And this into close().

Thanks.

Signature · 1 line
Dmitry
#16 lore raw

PATCH v12 5/7 leds: Add driver for ASUS Transformer LEDs

In reply to Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

ASUS Transformer tablets have a green and an amber LED on both the Pad and the Dock. If both LEDs are enabled simultaneously, the emitted light will be yellow.

---
 drivers/leds/Kconfig                    |  11 +++
 drivers/leds/Makefile                   |   1 +
 drivers/leds/leds-asus-transformer-ec.c | 125 ++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 drivers/leds/leds-asus-transformer-ec.c
drivers/leds/Kconfig +11 -0
index 7ec2c8d785426..788e689fe875c 100644
@@ -120,6 +120,17 @@ config LEDS_OSRAM_AMS_AS3668
 	  To compile this driver as a module, choose M here: the module
 	  will be called leds-as3668.
 
+config LEDS_ASUS_TRANSFORMER_EC
+	tristate "LED Support for Asus Transformer charging LED"
+	depends on LEDS_CLASS
+	depends on MFD_ASUS_TRANSFORMER_EC
+	help
+	  This option enables support for charging indicator on
+	  Asus Transformer's Pad and its Dock.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called leds-asus-transformer-ec.
+
 config LEDS_AW200XX
 	tristate "LED support for Awinic AW20036/AW20054/AW20072/AW20108"
 	depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 4d4b089156e24..3da746279bb81 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_LEDS_ADP5520)		+= leds-adp5520.o
 obj-$(CONFIG_LEDS_AN30259A)		+= leds-an30259a.o
 obj-$(CONFIG_LEDS_APU)			+= leds-apu.o
 obj-$(CONFIG_LEDS_ARIEL)		+= leds-ariel.o
+obj-$(CONFIG_LEDS_ASUS_TRANSFORMER_EC)	+= leds-asus-transformer-ec.o
 obj-$(CONFIG_LEDS_OSRAM_AMS_AS3668)	+= leds-as3668.o
 obj-$(CONFIG_LEDS_AW200XX)		+= leds-aw200xx.o
 obj-$(CONFIG_LEDS_AW2013)		+= leds-aw2013.o
drivers/leds/leds-asus-transformer-ec.c new file +125 -0

125 lines not on this page · raw message

Signature · 1 line
2.53.0
#17 lore raw

Re: [PATCH v12 5/7] leds: Add driver for ASUS Transformer LEDs

Sashiko has reviewed this patch and found no issues.
Quoted 9 lines

From: Michał Mirosław <[email protected]>

ASUS Transformer tablets have a green and an amber LED on both the Pad and the Dock. If both LEDs are enabled simultaneously, the emitted light will be yellow.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
maintainer
#18 lore raw

Re: [PATCH v12 5/7] leds: Add driver for ASUS Transformer LEDs

In reply to Svyatoslav Ryhel
Quoted 69 lines · Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

ASUS Transformer tablets have a green and an amber LED on both the Pad and the Dock. If both LEDs are enabled simultaneously, the emitted light will be yellow.

---
 drivers/leds/Kconfig                    |  11 +++
 drivers/leds/Makefile                   |   1 +
 drivers/leds/leds-asus-transformer-ec.c | 125 ++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 drivers/leds/leds-asus-transformer-ec.c
drivers/leds/Kconfig +11 -0
index 7ec2c8d785426..788e689fe875c 100644
@@ -120,6 +120,17 @@ config LEDS_OSRAM_AMS_AS3668
 	  To compile this driver as a module, choose M here: the module
 	  will be called leds-as3668.
 
+config LEDS_ASUS_TRANSFORMER_EC
+	tristate "LED Support for Asus Transformer charging LED"
+	depends on LEDS_CLASS
+	depends on MFD_ASUS_TRANSFORMER_EC
+	help
+	  This option enables support for charging indicator on
+	  Asus Transformer's Pad and its Dock.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called leds-asus-transformer-ec.
+
 config LEDS_AW200XX
 	tristate "LED support for Awinic AW20036/AW20054/AW20072/AW20108"
 	depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 4d4b089156e24..3da746279bb81 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_LEDS_ADP5520)		+= leds-adp5520.o
 obj-$(CONFIG_LEDS_AN30259A)		+= leds-an30259a.o
 obj-$(CONFIG_LEDS_APU)			+= leds-apu.o
 obj-$(CONFIG_LEDS_ARIEL)		+= leds-ariel.o
+obj-$(CONFIG_LEDS_ASUS_TRANSFORMER_EC)	+= leds-asus-transformer-ec.o
 obj-$(CONFIG_LEDS_OSRAM_AMS_AS3668)	+= leds-as3668.o
 obj-$(CONFIG_LEDS_AW200XX)		+= leds-aw200xx.o
 obj-$(CONFIG_LEDS_AW2013)		+= leds-aw2013.o
drivers/leds/leds-asus-transformer-ec.c new file +13 -0
new file mode 100644
index 0000000000000..1b129247ea6c6
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/leds.h>
+#include <linux/mfd/asus-transformer-ec.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+enum {
+	ASUSEC_LED_AMBER,
+	ASUSEC_LED_GREEN,
+	ASUSEC_LED_MAX

drivers/leds/leds-asus-transformer-ec.c line 23

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+};
+
+struct asus_ec_led_config {
+	const char *name;
+	unsigned int color;
+	u64 ctrl_bit;
+};
+
+struct asus_ec_led {
+	struct asus_ec_leds_data *ddata;

Why do we need 'struct asus_ec_leds_data' at all?

If we put 'const struct asusec_core *ec;' directly into 'struct asus_ec_led', we can drop the outer wrapper struct and the back-pointer completely.

Quoted 20 lines
drivers/leds/leds-asus-transformer-ec.c new file +20 -0
+	struct led_classdev cdev;
+	u64 ctrl_bit;
+};
+
+struct asus_ec_leds_data {
+	const struct asusec_core *ec;
+	struct asus_ec_led leds[ASUSEC_LED_MAX];
+};
+
+static const struct asus_ec_led_config asus_ec_leds[] = {
+	[ASUSEC_LED_AMBER] = {
+		.name = "amber",
+		.color = LED_COLOR_ID_AMBER,
+		.ctrl_bit = ASUSEC_CTL_LED_AMBER,
+	},
+	[ASUSEC_LED_GREEN] = {
+		.name = "green",
+		.color = LED_COLOR_ID_GREEN,
+		.ctrl_bit = ASUSEC_CTL_LED_GREEN,
+	},

drivers/leds/leds-asus-transformer-ec.c line 53

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+};
+
+static enum led_brightness asus_ec_led_get_brightness(struct led_classdev *cdev)
+{
+	struct asus_ec_led *led = container_of(cdev, struct asus_ec_led, cdev);
+	const struct asusec_core *ec = led->ddata->ec;
+	u64 ctl;
+	int ret;
+
+	ret = asus_dockram_access_ctl(ec->dockram, &ctl, 0, 0);

As requested on v6 and v8, why are we still using this bespoke accessor instead of Regmap?

Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
+	if (ret)
+		return LED_OFF;
+
+	return ctl & led->ctrl_bit ? LED_ON : LED_OFF;
+}

drivers/leds/leds-asus-transformer-ec.c line 68

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+
+static int asus_ec_led_set_brightness(struct led_classdev *cdev,
+				      enum led_brightness brightness)
+{
+	struct asus_ec_led *led = container_of(cdev, struct asus_ec_led, cdev);
+	const struct asusec_core *ec = led->ddata->ec;
+
+	if (brightness)
+		return asus_dockram_access_ctl(ec->dockram, NULL,
+					       led->ctrl_bit, led->ctrl_bit);

Use 100-chars throughout to prevent early wrapping.

Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
+	return asus_dockram_access_ctl(ec->dockram, NULL, led->ctrl_bit, 0);
+}
+
+static int asus_ec_led_probe(struct platform_device *pdev)
+{

drivers/leds/leds-asus-transformer-ec.c line 84

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+	const struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
+	struct asus_ec_leds_data *ddata;
+	struct device *dev = &pdev->dev;
+	int ret;
+
+	ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+	if (!ddata)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, ddata);

What consumes this?

drivers/leds/leds-asus-transformer-ec.c line 87

Quoted 3 lines
drivers/leds/leds-asus-transformer-ec.c new file +3 -0
+	ddata->ec = ec;
+
+	for (int i = 0; i < ASUSEC_LED_MAX; i++) {

i isn't just a random iterator here - maybe call it led?

Quoted 19 lines
drivers/leds/leds-asus-transformer-ec.c new file +19 -0
+		const struct asus_ec_led_config *cfg = &asus_ec_leds[i];
+		struct asus_ec_led *led = &ddata->leds[i];
+
+		led->cdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s",
+						ddata->ec->name, cfg->name);
+		if (!led->cdev.name)
+			return -ENOMEM;
+
+		led->cdev.max_brightness = 1;
+		led->cdev.color = cfg->color;
+		led->cdev.flags = LED_CORE_SUSPENDRESUME | LED_RETAIN_AT_SHUTDOWN;
+		led->cdev.brightness_get = asus_ec_led_get_brightness;
+		led->cdev.brightness_set_blocking = asus_ec_led_set_brightness;
+
+		led->ddata = ddata;
+		led->ctrl_bit = cfg->ctrl_bit;
+
+		ret = devm_led_classdev_register(dev, &led->cdev);
+		if (ret)

drivers/leds/leds-asus-transformer-ec.c line 116

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+			return dev_err_probe(dev, ret,
+					     "Failed to register %s LED\n",
+					     cfg->name);
+	}
+
+	return 0;
+}
+
+static struct platform_driver asus_ec_led_driver = {
+	.driver.name = "asus-transformer-ec-led",

Clever! But, I'd prefer we still to the usual format to be honest.

Quoted 12 lines
drivers/leds/leds-asus-transformer-ec.c new file +9 -0
+	.probe = asus_ec_led_probe,
+};
+module_platform_driver(asus_ec_led_driver);
+
+MODULE_ALIAS("platform:asus-transformer-ec-led");
+MODULE_AUTHOR("Michał Mirosław <[email protected]>");
+MODULE_AUTHOR("Svyatoslav Ryhel <[email protected]>");
+MODULE_DESCRIPTION("ASUS Transformer's charging LED driver");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.53.0
Signature · 1 line
Lee Jones
#19 lore raw

Re: [PATCH v12 5/7] leds: Add driver for ASUS Transformer LEDs

вт, 3 лист. 2026 р. о 16:03 Lee Jones <[email protected]> пише:

Quoted 85 lines · Svyatoslav Ryhel
Quoted 69 lines

From: Michał Mirosław <[email protected]>

ASUS Transformer tablets have a green and an amber LED on both the Pad and the Dock. If both LEDs are enabled simultaneously, the emitted light will be yellow.

---
 drivers/leds/Kconfig                    |  11 +++
 drivers/leds/Makefile                   |   1 +
 drivers/leds/leds-asus-transformer-ec.c | 125 ++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 drivers/leds/leds-asus-transformer-ec.c
drivers/leds/Kconfig +11 -0
index 7ec2c8d785426..788e689fe875c 100644
@@ -120,6 +120,17 @@ config LEDS_OSRAM_AMS_AS3668
        To compile this driver as a module, choose M here: the module
        will be called leds-as3668.
 
+config LEDS_ASUS_TRANSFORMER_EC
+     tristate "LED Support for Asus Transformer charging LED"
+     depends on LEDS_CLASS
+     depends on MFD_ASUS_TRANSFORMER_EC
+     help
+       This option enables support for charging indicator on
+       Asus Transformer's Pad and its Dock.
+
+       To compile this driver as a module, choose M here: the module
+       will be called leds-asus-transformer-ec.
+
 config LEDS_AW200XX
      tristate "LED support for Awinic AW20036/AW20054/AW20072/AW20108"
      depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 4d4b089156e24..3da746279bb81 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_LEDS_ADP5520)          += leds-adp5520.o
 obj-$(CONFIG_LEDS_AN30259A)          += leds-an30259a.o
 obj-$(CONFIG_LEDS_APU)                       += leds-apu.o
 obj-$(CONFIG_LEDS_ARIEL)             += leds-ariel.o
+obj-$(CONFIG_LEDS_ASUS_TRANSFORMER_EC)       += leds-asus-transformer-ec.o
 obj-$(CONFIG_LEDS_OSRAM_AMS_AS3668)  += leds-as3668.o
 obj-$(CONFIG_LEDS_AW200XX)           += leds-aw200xx.o
 obj-$(CONFIG_LEDS_AW2013)            += leds-aw2013.o
drivers/leds/leds-asus-transformer-ec.c new file +13 -0
new file mode 100644
index 0000000000000..1b129247ea6c6
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/leds.h>
+#include <linux/mfd/asus-transformer-ec.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+enum {
+     ASUSEC_LED_AMBER,
+     ASUSEC_LED_GREEN,
+     ASUSEC_LED_MAX

drivers/leds/leds-asus-transformer-ec.c line 23

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+};
+
+struct asus_ec_led_config {
+     const char *name;
+     unsigned int color;
+     u64 ctrl_bit;
+};
+
+struct asus_ec_led {
+     struct asus_ec_leds_data *ddata;

Why do we need 'struct ' at all?

Quoted 4 lines

If we put 'const struct asusec_core *ec;' directly into 'struct asus_ec_led', we can drop the outer wrapper struct and the back-pointer completely.

You propose to allocate asus_ec_led for each led in a loop? I have not seen this done by other leds. The asus_ec_leds_data is driver ddata, asus_ec_led is each led individual structure.

Quoted 25 lines
Quoted 25 lines
drivers/leds/leds-asus-transformer-ec.c new file +25 -0
+     struct led_classdev cdev;
+     u64 ctrl_bit;
+};
+
+struct asus_ec_leds_data {
+     const struct asusec_core *ec;
+     struct asus_ec_led leds[ASUSEC_LED_MAX];
+};
+
+static const struct asus_ec_led_config asus_ec_leds[] = {
+     [ASUSEC_LED_AMBER] = {
+             .name = "amber",
+             .color = LED_COLOR_ID_AMBER,
+             .ctrl_bit = ASUSEC_CTL_LED_AMBER,
+     },
+     [ASUSEC_LED_GREEN] = {
+             .name = "green",
+             .color = LED_COLOR_ID_GREEN,
+             .ctrl_bit = ASUSEC_CTL_LED_GREEN,
+     },
+};
+
+static enum led_brightness asus_ec_led_get_brightness(struct led_classdev *cdev)
+{
+     struct asus_ec_led *led = container_of(cdev, struct asus_ec_led, cdev);
Quoted 9 lines

drivers/leds/leds-asus-transformer-ec.c line 53

Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
+     const struct asusec_core *ec = led->ddata->ec;
+     u64 ctl;
+     int ret;
+
+     ret = asus_dockram_access_ctl(ec->dockram, &ctl, 0, 0);

As requested on v6 and v8, why are we still using this bespoke accessor instead of Regmap?

https://lore.kernel.org/lkml/CAPVz0n0imF_ESoGMJSrEX7NOnBShFj8wehDtQKXZV_DMcGqq=A@mail.gmail.com/

Quoted 27 lines
Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
+     if (ret)
+             return LED_OFF;
+
+     return ctl & led->ctrl_bit ? LED_ON : LED_OFF;
+}

drivers/leds/leds-asus-transformer-ec.c line 68

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+
+static int asus_ec_led_set_brightness(struct led_classdev *cdev,
+                                   enum led_brightness brightness)
+{
+     struct asus_ec_led *led = container_of(cdev, struct asus_ec_led, cdev);
+     const struct asusec_core *ec = led->ddata->ec;
+
+     if (brightness)
+             return asus_dockram_access_ctl(ec->dockram, NULL,
+                                            led->ctrl_bit, led->ctrl_bit);

Use 100-chars throughout to prevent early wrapping.

Quoted 9 lines
drivers/leds/leds-asus-transformer-ec.c new file +9 -0
+     return asus_dockram_access_ctl(ec->dockram, NULL, led->ctrl_bit, 0);
+}
+
+static int asus_ec_led_probe(struct platform_device *pdev)
+{
+     const struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
+     struct asus_ec_leds_data *ddata;
+     struct device *dev = &pdev->dev;
+     int ret;
Quoted 9 lines

drivers/leds/leds-asus-transformer-ec.c line 84

Quoted 6 lines
drivers/leds/leds-asus-transformer-ec.c new file +6 -0
+
+     ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+     if (!ddata)
+             return -ENOMEM;
+
+     platform_set_drvdata(pdev, ddata);

What consumes this?

Seems to be an overlook, must have forgotten to remove it during 12 iterations over last 10 month

Quoted 6 lines

drivers/leds/leds-asus-transformer-ec.c line 87

Quoted 3 lines
drivers/leds/leds-asus-transformer-ec.c new file +3 -0
+     ddata->ec = ec;
+
+     for (int i = 0; i < ASUSEC_LED_MAX; i++) {

i isn't just a random iterator here - maybe call it led?

This is just a disposable iterator.

Quoted 32 lines
Quoted 19 lines
drivers/leds/leds-asus-transformer-ec.c new file +19 -0
+             const struct asus_ec_led_config *cfg = &asus_ec_leds[i];
+             struct asus_ec_led *led = &ddata->leds[i];
+
+             led->cdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s",
+                                             ddata->ec->name, cfg->name);
+             if (!led->cdev.name)
+                     return -ENOMEM;
+
+             led->cdev.max_brightness = 1;
+             led->cdev.color = cfg->color;
+             led->cdev.flags = LED_CORE_SUSPENDRESUME | LED_RETAIN_AT_SHUTDOWN;
+             led->cdev.brightness_get = asus_ec_led_get_brightness;
+             led->cdev.brightness_set_blocking = asus_ec_led_set_brightness;
+
+             led->ddata = ddata;
+             led->ctrl_bit = cfg->ctrl_bit;
+
+             ret = devm_led_classdev_register(dev, &led->cdev);
+             if (ret)

drivers/leds/leds-asus-transformer-ec.c line 116

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+                     return dev_err_probe(dev, ret,
+                                          "Failed to register %s LED\n",
+                                          cfg->name);
+     }
+
+     return 0;
+}
+
+static struct platform_driver asus_ec_led_driver = {
+     .driver.name = "asus-transformer-ec-led",

Clever! But, I'd prefer we still to the usual format to be honest.

Quoted 15 lines
Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +9 -1
+     .probe = asus_ec_led_probe,
+};
+module_platform_driver(asus_ec_led_driver);
+
+MODULE_ALIAS("platform:asus-transformer-ec-led");
+MODULE_AUTHOR("Michał Mirosław <[email protected]>");
+MODULE_AUTHOR("Svyatoslav Ryhel <[email protected]>");
+MODULE_DESCRIPTION("ASUS Transformer's charging LED driver");
+MODULE_LICENSE("GPL");
--
Quoted 2 lines

2.53.0

--
Lee Jones

v7 seem fine https://lore.kernel.org/lkml/[email protected]/
v9 as well https://lore.kernel.org/lkml/[email protected]/

Yet again complains and nits

maintainer
#20 lore raw

Re: [PATCH v12 5/7] leds: Add driver for ASUS Transformer LEDs

Quoted 86 lines · Svyatoslav Ryhel

вт, 3 лист. 2026 р. о 16:03 Lee Jones <[email protected]> пише:

Quoted 85 lines · Svyatoslav Ryhel
Quoted 69 lines

From: Michał Mirosław <[email protected]>

ASUS Transformer tablets have a green and an amber LED on both the Pad and the Dock. If both LEDs are enabled simultaneously, the emitted light will be yellow.

---
 drivers/leds/Kconfig                    |  11 +++
 drivers/leds/Makefile                   |   1 +
 drivers/leds/leds-asus-transformer-ec.c | 125 ++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 drivers/leds/leds-asus-transformer-ec.c
drivers/leds/Kconfig +11 -0
index 7ec2c8d785426..788e689fe875c 100644
@@ -120,6 +120,17 @@ config LEDS_OSRAM_AMS_AS3668
        To compile this driver as a module, choose M here: the module
        will be called leds-as3668.
 
+config LEDS_ASUS_TRANSFORMER_EC
+     tristate "LED Support for Asus Transformer charging LED"
+     depends on LEDS_CLASS
+     depends on MFD_ASUS_TRANSFORMER_EC
+     help
+       This option enables support for charging indicator on
+       Asus Transformer's Pad and its Dock.
+
+       To compile this driver as a module, choose M here: the module
+       will be called leds-asus-transformer-ec.
+
 config LEDS_AW200XX
      tristate "LED support for Awinic AW20036/AW20054/AW20072/AW20108"
      depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 4d4b089156e24..3da746279bb81 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_LEDS_ADP5520)          += leds-adp5520.o
 obj-$(CONFIG_LEDS_AN30259A)          += leds-an30259a.o
 obj-$(CONFIG_LEDS_APU)                       += leds-apu.o
 obj-$(CONFIG_LEDS_ARIEL)             += leds-ariel.o
+obj-$(CONFIG_LEDS_ASUS_TRANSFORMER_EC)       += leds-asus-transformer-ec.o
 obj-$(CONFIG_LEDS_OSRAM_AMS_AS3668)  += leds-as3668.o
 obj-$(CONFIG_LEDS_AW200XX)           += leds-aw200xx.o
 obj-$(CONFIG_LEDS_AW2013)            += leds-aw2013.o
drivers/leds/leds-asus-transformer-ec.c new file +13 -0
new file mode 100644
index 0000000000000..1b129247ea6c6
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/leds.h>
+#include <linux/mfd/asus-transformer-ec.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+enum {
+     ASUSEC_LED_AMBER,
+     ASUSEC_LED_GREEN,
+     ASUSEC_LED_MAX

drivers/leds/leds-asus-transformer-ec.c line 23

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+};
+
+struct asus_ec_led_config {
+     const char *name;
+     unsigned int color;
+     u64 ctrl_bit;
+};
+
+struct asus_ec_led {
+     struct asus_ec_leds_data *ddata;

Why do we need 'struct ' at all?

Quoted 8 lines
Quoted 4 lines

If we put 'const struct asusec_core *ec;' directly into 'struct asus_ec_led', we can drop the outer wrapper struct and the back-pointer completely.

You propose to allocate asus_ec_led for each led in a loop? I have not seen this done by other leds. The asus_ec_leds_data is driver ddata, asus_ec_led is each led individual structure.

For your whole 2 LEDs, yes, I think that will be better.

Quoted 34 lines
Quoted 25 lines
Quoted 25 lines
drivers/leds/leds-asus-transformer-ec.c new file +25 -0
+     struct led_classdev cdev;
+     u64 ctrl_bit;
+};
+
+struct asus_ec_leds_data {
+     const struct asusec_core *ec;
+     struct asus_ec_led leds[ASUSEC_LED_MAX];
+};
+
+static const struct asus_ec_led_config asus_ec_leds[] = {
+     [ASUSEC_LED_AMBER] = {
+             .name = "amber",
+             .color = LED_COLOR_ID_AMBER,
+             .ctrl_bit = ASUSEC_CTL_LED_AMBER,
+     },
+     [ASUSEC_LED_GREEN] = {
+             .name = "green",
+             .color = LED_COLOR_ID_GREEN,
+             .ctrl_bit = ASUSEC_CTL_LED_GREEN,
+     },
+};
+
+static enum led_brightness asus_ec_led_get_brightness(struct led_classdev *cdev)
+{
+     struct asus_ec_led *led = container_of(cdev, struct asus_ec_led, cdev);
Quoted 8 lines

drivers/leds/leds-asus-transformer-ec.c line 53

Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
+     const struct asusec_core *ec = led->ddata->ec;
+     u64 ctl;
+     int ret;
+
+     ret = asus_dockram_access_ctl(ec->dockram, &ctl, 0, 0);

As requested on v6 and v8, why are we still using this bespoke accessor instead of Regmap?

Quoted 1 line

https://lore.kernel.org/lkml/CAPVz0n0imF_ESoGMJSrEX7NOnBShFj8wehDtQKXZV_DMcGqq=A@mail.gmail.com/

Sorry, I've slept since then, and subsequently forgotten this conversation. You can drop this request.

Quoted 36 lines
Quoted 27 lines
Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
+     if (ret)
+             return LED_OFF;
+
+     return ctl & led->ctrl_bit ? LED_ON : LED_OFF;
+}

drivers/leds/leds-asus-transformer-ec.c line 68

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+
+static int asus_ec_led_set_brightness(struct led_classdev *cdev,
+                                   enum led_brightness brightness)
+{
+     struct asus_ec_led *led = container_of(cdev, struct asus_ec_led, cdev);
+     const struct asusec_core *ec = led->ddata->ec;
+
+     if (brightness)
+             return asus_dockram_access_ctl(ec->dockram, NULL,
+                                            led->ctrl_bit, led->ctrl_bit);

Use 100-chars throughout to prevent early wrapping.

Quoted 9 lines
drivers/leds/leds-asus-transformer-ec.c new file +9 -0
+     return asus_dockram_access_ctl(ec->dockram, NULL, led->ctrl_bit, 0);
+}
+
+static int asus_ec_led_probe(struct platform_device *pdev)
+{
+     const struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
+     struct asus_ec_leds_data *ddata;
+     struct device *dev = &pdev->dev;
+     int ret;
Quoted 8 lines

drivers/leds/leds-asus-transformer-ec.c line 84

Quoted 6 lines
drivers/leds/leds-asus-transformer-ec.c new file +6 -0
+
+     ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+     if (!ddata)
+             return -ENOMEM;
+
+     platform_set_drvdata(pdev, ddata);

What consumes this?

Quoted 2 lines

Seems to be an overlook, must have forgotten to remove it during 12 iterations over last 10 month

No problem, it happens.

Quoted 8 lines
Quoted 6 lines

drivers/leds/leds-asus-transformer-ec.c line 87

Quoted 3 lines
drivers/leds/leds-asus-transformer-ec.c new file +3 -0
+     ddata->ec = ec;
+
+     for (int i = 0; i < ASUSEC_LED_MAX; i++) {

i isn't just a random iterator here - maybe call it led?

This is just a disposable iterator.

It's a disposable iterator that is clearly a led.

Thus my request for and improvement in the nomenclature remains valid.

Quoted 2 lines

v7 seem fine https://lore.kernel.org/lkml/[email protected]/
v9 as well https://lore.kernel.org/lkml/[email protected]/

These are the same link.

Quoted 1 line

Yet again complains and nits

That my job. You're welcome. =;-)

Sometimes new things are found on re-review.

Apologies for the disappointment.

Signature · 1 line
Lee Jones
#21 lore raw

Re: [PATCH v12 5/7] leds: Add driver for ASUS Transformer LEDs

ср, 4 лист. 2026 р. о 10:28 Lee Jones <[email protected]> пише:

Quoted 189 lines · Svyatoslav Ryhel
Quoted 87 lines

вт, 3 лист. 2026 р. о 16:03 Lee Jones <[email protected]> пише:

Quoted 85 lines · Svyatoslav Ryhel
Quoted 69 lines

From: Michał Mirosław <[email protected]>

ASUS Transformer tablets have a green and an amber LED on both the Pad and the Dock. If both LEDs are enabled simultaneously, the emitted light will be yellow.

---
 drivers/leds/Kconfig                    |  11 +++
 drivers/leds/Makefile                   |   1 +
 drivers/leds/leds-asus-transformer-ec.c | 125 ++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 drivers/leds/leds-asus-transformer-ec.c
drivers/leds/Kconfig +11 -0
index 7ec2c8d785426..788e689fe875c 100644
@@ -120,6 +120,17 @@ config LEDS_OSRAM_AMS_AS3668
        To compile this driver as a module, choose M here: the module
        will be called leds-as3668.
 
+config LEDS_ASUS_TRANSFORMER_EC
+     tristate "LED Support for Asus Transformer charging LED"
+     depends on LEDS_CLASS
+     depends on MFD_ASUS_TRANSFORMER_EC
+     help
+       This option enables support for charging indicator on
+       Asus Transformer's Pad and its Dock.
+
+       To compile this driver as a module, choose M here: the module
+       will be called leds-asus-transformer-ec.
+
 config LEDS_AW200XX
      tristate "LED support for Awinic AW20036/AW20054/AW20072/AW20108"
      depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 4d4b089156e24..3da746279bb81 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_LEDS_ADP5520)          += leds-adp5520.o
 obj-$(CONFIG_LEDS_AN30259A)          += leds-an30259a.o
 obj-$(CONFIG_LEDS_APU)                       += leds-apu.o
 obj-$(CONFIG_LEDS_ARIEL)             += leds-ariel.o
+obj-$(CONFIG_LEDS_ASUS_TRANSFORMER_EC)       += leds-asus-transformer-ec.o
 obj-$(CONFIG_LEDS_OSRAM_AMS_AS3668)  += leds-as3668.o
 obj-$(CONFIG_LEDS_AW200XX)           += leds-aw200xx.o
 obj-$(CONFIG_LEDS_AW2013)            += leds-aw2013.o
drivers/leds/leds-asus-transformer-ec.c new file +13 -0
new file mode 100644
index 0000000000000..1b129247ea6c6
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/leds.h>
+#include <linux/mfd/asus-transformer-ec.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+enum {
+     ASUSEC_LED_AMBER,
+     ASUSEC_LED_GREEN,
+     ASUSEC_LED_MAX

drivers/leds/leds-asus-transformer-ec.c line 23

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+};
+
+struct asus_ec_led_config {
+     const char *name;
+     unsigned int color;
+     u64 ctrl_bit;
+};
+
+struct asus_ec_led {
+     struct asus_ec_leds_data *ddata;

Why do we need 'struct ' at all?

Quoted 8 lines
Quoted 4 lines

If we put 'const struct asusec_core *ec;' directly into 'struct asus_ec_led', we can drop the outer wrapper struct and the back-pointer completely.

You propose to allocate asus_ec_led for each led in a loop? I have not seen this done by other leds. The asus_ec_leds_data is driver ddata, asus_ec_led is each led individual structure.

For your whole 2 LEDs, yes, I think that will be better.

Quoted 34 lines
Quoted 25 lines
Quoted 25 lines
drivers/leds/leds-asus-transformer-ec.c new file +25 -0
+     struct led_classdev cdev;
+     u64 ctrl_bit;
+};
+
+struct asus_ec_leds_data {
+     const struct asusec_core *ec;
+     struct asus_ec_led leds[ASUSEC_LED_MAX];
+};
+
+static const struct asus_ec_led_config asus_ec_leds[] = {
+     [ASUSEC_LED_AMBER] = {
+             .name = "amber",
+             .color = LED_COLOR_ID_AMBER,
+             .ctrl_bit = ASUSEC_CTL_LED_AMBER,
+     },
+     [ASUSEC_LED_GREEN] = {
+             .name = "green",
+             .color = LED_COLOR_ID_GREEN,
+             .ctrl_bit = ASUSEC_CTL_LED_GREEN,
+     },
+};
+
+static enum led_brightness asus_ec_led_get_brightness(struct led_classdev *cdev)
+{
+     struct asus_ec_led *led = container_of(cdev, struct asus_ec_led, cdev);
Quoted 8 lines

drivers/leds/leds-asus-transformer-ec.c line 53

Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
+     const struct asusec_core *ec = led->ddata->ec;
+     u64 ctl;
+     int ret;
+
+     ret = asus_dockram_access_ctl(ec->dockram, &ctl, 0, 0);

As requested on v6 and v8, why are we still using this bespoke accessor instead of Regmap?

Quoted 1 line

https://lore.kernel.org/lkml/CAPVz0n0imF_ESoGMJSrEX7NOnBShFj8wehDtQKXZV_DMcGqq=A@mail.gmail.com/

Sorry, I've slept since then, and subsequently forgotten this conversation. You can drop this request.

Quoted 36 lines
Quoted 27 lines
Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
+     if (ret)
+             return LED_OFF;
+
+     return ctl & led->ctrl_bit ? LED_ON : LED_OFF;
+}

drivers/leds/leds-asus-transformer-ec.c line 68

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+
+static int asus_ec_led_set_brightness(struct led_classdev *cdev,
+                                   enum led_brightness brightness)
+{
+     struct asus_ec_led *led = container_of(cdev, struct asus_ec_led, cdev);
+     const struct asusec_core *ec = led->ddata->ec;
+
+     if (brightness)
+             return asus_dockram_access_ctl(ec->dockram, NULL,
+                                            led->ctrl_bit, led->ctrl_bit);

Use 100-chars throughout to prevent early wrapping.

Quoted 9 lines
drivers/leds/leds-asus-transformer-ec.c new file +9 -0
+     return asus_dockram_access_ctl(ec->dockram, NULL, led->ctrl_bit, 0);
+}
+
+static int asus_ec_led_probe(struct platform_device *pdev)
+{
+     const struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
+     struct asus_ec_leds_data *ddata;
+     struct device *dev = &pdev->dev;
+     int ret;
Quoted 8 lines

drivers/leds/leds-asus-transformer-ec.c line 84

Quoted 6 lines
drivers/leds/leds-asus-transformer-ec.c new file +6 -0
+
+     ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+     if (!ddata)
+             return -ENOMEM;
+
+     platform_set_drvdata(pdev, ddata);

What consumes this?

Quoted 2 lines

Seems to be an overlook, must have forgotten to remove it during 12 iterations over last 10 month

No problem, it happens.

Quoted 8 lines
Quoted 6 lines

drivers/leds/leds-asus-transformer-ec.c line 87

Quoted 3 lines
drivers/leds/leds-asus-transformer-ec.c new file +3 -0
+     ddata->ec = ec;
+
+     for (int i = 0; i < ASUSEC_LED_MAX; i++) {

i isn't just a random iterator here - maybe call it led?

This is just a disposable iterator.

Quoted 9 lines

It's a disposable iterator that is clearly a led.

Thus my request for and improvement in the nomenclature remains valid.

Quoted 2 lines

v7 seem fine https://lore.kernel.org/lkml/[email protected]/
v9 as well https://lore.kernel.org/lkml/[email protected]/

These are the same link.

Ooops, v7 https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 1 line

Yet again complains and nits

That my job. You're welcome. =;-)

Sometimes new things are found on re-review.

Apologies for the disappointment.

I will incorporate all your requests, but please, may you apply/check v13 a bit quicker. That would be awesome.

Quoted 2 lines

--
Lee Jones

maintainer
#22 lore raw

Re: [PATCH v12 5/7] leds: Add driver for ASUS Transformer LEDs

Quoted 206 lines · Svyatoslav Ryhel

ср, 4 лист. 2026 р. о 10:28 Lee Jones <[email protected]> пише:

Quoted 189 lines · Svyatoslav Ryhel
Quoted 87 lines

вт, 3 лист. 2026 р. о 16:03 Lee Jones <[email protected]> пише:

Quoted 85 lines · Svyatoslav Ryhel
Quoted 69 lines

From: Michał Mirosław <[email protected]>

ASUS Transformer tablets have a green and an amber LED on both the Pad and the Dock. If both LEDs are enabled simultaneously, the emitted light will be yellow.

---
 drivers/leds/Kconfig                    |  11 +++
 drivers/leds/Makefile                   |   1 +
 drivers/leds/leds-asus-transformer-ec.c | 125 ++++++++++++++++++++++++
 3 files changed, 137 insertions(+)
 create mode 100644 drivers/leds/leds-asus-transformer-ec.c
drivers/leds/Kconfig +11 -0
index 7ec2c8d785426..788e689fe875c 100644
@@ -120,6 +120,17 @@ config LEDS_OSRAM_AMS_AS3668
        To compile this driver as a module, choose M here: the module
        will be called leds-as3668.
 
+config LEDS_ASUS_TRANSFORMER_EC
+     tristate "LED Support for Asus Transformer charging LED"
+     depends on LEDS_CLASS
+     depends on MFD_ASUS_TRANSFORMER_EC
+     help
+       This option enables support for charging indicator on
+       Asus Transformer's Pad and its Dock.
+
+       To compile this driver as a module, choose M here: the module
+       will be called leds-asus-transformer-ec.
+
 config LEDS_AW200XX
      tristate "LED support for Awinic AW20036/AW20054/AW20072/AW20108"
      depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 4d4b089156e24..3da746279bb81 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_LEDS_ADP5520)          += leds-adp5520.o
 obj-$(CONFIG_LEDS_AN30259A)          += leds-an30259a.o
 obj-$(CONFIG_LEDS_APU)                       += leds-apu.o
 obj-$(CONFIG_LEDS_ARIEL)             += leds-ariel.o
+obj-$(CONFIG_LEDS_ASUS_TRANSFORMER_EC)       += leds-asus-transformer-ec.o
 obj-$(CONFIG_LEDS_OSRAM_AMS_AS3668)  += leds-as3668.o
 obj-$(CONFIG_LEDS_AW200XX)           += leds-aw200xx.o
 obj-$(CONFIG_LEDS_AW2013)            += leds-aw2013.o
drivers/leds/leds-asus-transformer-ec.c new file +13 -0
new file mode 100644
index 0000000000000..1b129247ea6c6
@@ -0,0 +1,125 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/err.h>
+#include <linux/leds.h>
+#include <linux/mfd/asus-transformer-ec.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+enum {
+     ASUSEC_LED_AMBER,
+     ASUSEC_LED_GREEN,
+     ASUSEC_LED_MAX

drivers/leds/leds-asus-transformer-ec.c line 23

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+};
+
+struct asus_ec_led_config {
+     const char *name;
+     unsigned int color;
+     u64 ctrl_bit;
+};
+
+struct asus_ec_led {
+     struct asus_ec_leds_data *ddata;

Why do we need 'struct ' at all?

Quoted 8 lines
Quoted 4 lines

If we put 'const struct asusec_core *ec;' directly into 'struct asus_ec_led', we can drop the outer wrapper struct and the back-pointer completely.

You propose to allocate asus_ec_led for each led in a loop? I have not seen this done by other leds. The asus_ec_leds_data is driver ddata, asus_ec_led is each led individual structure.

For your whole 2 LEDs, yes, I think that will be better.

Quoted 34 lines
Quoted 25 lines
Quoted 25 lines
drivers/leds/leds-asus-transformer-ec.c new file +25 -0
+     struct led_classdev cdev;
+     u64 ctrl_bit;
+};
+
+struct asus_ec_leds_data {
+     const struct asusec_core *ec;
+     struct asus_ec_led leds[ASUSEC_LED_MAX];
+};
+
+static const struct asus_ec_led_config asus_ec_leds[] = {
+     [ASUSEC_LED_AMBER] = {
+             .name = "amber",
+             .color = LED_COLOR_ID_AMBER,
+             .ctrl_bit = ASUSEC_CTL_LED_AMBER,
+     },
+     [ASUSEC_LED_GREEN] = {
+             .name = "green",
+             .color = LED_COLOR_ID_GREEN,
+             .ctrl_bit = ASUSEC_CTL_LED_GREEN,
+     },
+};
+
+static enum led_brightness asus_ec_led_get_brightness(struct led_classdev *cdev)
+{
+     struct asus_ec_led *led = container_of(cdev, struct asus_ec_led, cdev);
Quoted 8 lines

drivers/leds/leds-asus-transformer-ec.c line 53

Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
+     const struct asusec_core *ec = led->ddata->ec;
+     u64 ctl;
+     int ret;
+
+     ret = asus_dockram_access_ctl(ec->dockram, &ctl, 0, 0);

As requested on v6 and v8, why are we still using this bespoke accessor instead of Regmap?

Quoted 1 line

https://lore.kernel.org/lkml/CAPVz0n0imF_ESoGMJSrEX7NOnBShFj8wehDtQKXZV_DMcGqq=A@mail.gmail.com/

Sorry, I've slept since then, and subsequently forgotten this conversation. You can drop this request.

Quoted 36 lines
Quoted 27 lines
Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
+     if (ret)
+             return LED_OFF;
+
+     return ctl & led->ctrl_bit ? LED_ON : LED_OFF;
+}

drivers/leds/leds-asus-transformer-ec.c line 68

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+
+static int asus_ec_led_set_brightness(struct led_classdev *cdev,
+                                   enum led_brightness brightness)
+{
+     struct asus_ec_led *led = container_of(cdev, struct asus_ec_led, cdev);
+     const struct asusec_core *ec = led->ddata->ec;
+
+     if (brightness)
+             return asus_dockram_access_ctl(ec->dockram, NULL,
+                                            led->ctrl_bit, led->ctrl_bit);

Use 100-chars throughout to prevent early wrapping.

Quoted 9 lines
drivers/leds/leds-asus-transformer-ec.c new file +9 -0
+     return asus_dockram_access_ctl(ec->dockram, NULL, led->ctrl_bit, 0);
+}
+
+static int asus_ec_led_probe(struct platform_device *pdev)
+{
+     const struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
+     struct asus_ec_leds_data *ddata;
+     struct device *dev = &pdev->dev;
+     int ret;
Quoted 8 lines

drivers/leds/leds-asus-transformer-ec.c line 84

Quoted 6 lines
drivers/leds/leds-asus-transformer-ec.c new file +6 -0
+
+     ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+     if (!ddata)
+             return -ENOMEM;
+
+     platform_set_drvdata(pdev, ddata);

What consumes this?

Quoted 2 lines

Seems to be an overlook, must have forgotten to remove it during 12 iterations over last 10 month

No problem, it happens.

Quoted 8 lines
Quoted 6 lines

drivers/leds/leds-asus-transformer-ec.c line 87

Quoted 3 lines
drivers/leds/leds-asus-transformer-ec.c new file +3 -0
+     ddata->ec = ec;
+
+     for (int i = 0; i < ASUSEC_LED_MAX; i++) {

i isn't just a random iterator here - maybe call it led?

This is just a disposable iterator.

Quoted 9 lines

It's a disposable iterator that is clearly a led.

Thus my request for and improvement in the nomenclature remains valid.

Quoted 2 lines

v7 seem fine https://lore.kernel.org/lkml/[email protected]/
v9 as well https://lore.kernel.org/lkml/[email protected]/

These are the same link.

Ooops, v7 https://lore.kernel.org/lkml/[email protected]/

Quoted 4 lines
Quoted 1 line

Yet again complains and nits

That my job. You're welcome. =;-)

Quoted 7 lines
Quoted 4 lines

Sometimes new things are found on re-review.

Apologies for the disappointment.

I will incorporate all your requests, but please, may you apply/check v13 a bit quicker. That would be awesome.

Sure. =:-)

Signature · 1 line
Lee Jones
#23 lore raw

PATCH v12 6/7 power: supply: Add driver for ASUS Transformer battery

In reply to Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

Driver implements one battery cell per EC controller and supports reading of battery status for ASUS Transformer's pad and mobile dock.

---
 drivers/power/supply/Kconfig                  |  11 +
 drivers/power/supply/Makefile                 |   1 +
 .../supply/asus-transformer-ec-battery.c      | 289 ++++++++++++++++++
 3 files changed, 301 insertions(+)
 create mode 100644 drivers/power/supply/asus-transformer-ec-battery.c
drivers/power/supply/Kconfig +11 -0
index ee7dc5f2617a4..856eb81c97ae9 100644
@@ -122,6 +122,17 @@ config BATTERY_CHAGALL
 	  This driver can also be built as a module. If so, the module will be
 	  called chagall-battery.
 
+config BATTERY_ASUS_TRANSFORMER_EC
+	tristate "Asus Transformer's battery driver"
+	depends on MFD_ASUS_TRANSFORMER_EC
+	help
+	  Say Y to enable support for battery status access on Tegra based
+	  ASUS Transformer devices.
+
+	  This sub-driver supports battery cells found in Asus Transformer
+	  tablets and mobile docks and controlled by a special embedded
+	  controller.
+
 config BATTERY_CPCAP
 	tristate "Motorola CPCAP PMIC battery driver"
 	depends on MFD_CPCAP && IIO
drivers/power/supply/Makefile +1 -0
index f3c0d1006c1a2..bec4a6263048c 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_TEST_POWER)	+= test_power.o
 obj-$(CONFIG_BATTERY_88PM860X)	+= 88pm860x_battery.o
 obj-$(CONFIG_CHARGER_ADP5061)	+= adp5061.o
 obj-$(CONFIG_BATTERY_ACT8945A)	+= act8945a_charger.o
+obj-$(CONFIG_BATTERY_ASUS_TRANSFORMER_EC)	+= asus-transformer-ec-battery.o
 obj-$(CONFIG_BATTERY_AXP20X)	+= axp20x_battery.o
 obj-$(CONFIG_CHARGER_AXP20X)	+= axp20x_ac_power.o
 obj-$(CONFIG_BATTERY_CHAGALL)	+= chagall-battery.o
drivers/power/supply/asus-transformer-ec-battery.c new file +289 -0

289 lines not on this page · raw message

Signature · 1 line
2.53.0
#24 lore raw

Re: [PATCH v12 6/7] power: supply: Add driver for ASUS Transformer battery

Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

From: Michał Mirosław <[email protected]>

Driver implements one battery cell per EC controller and supports reading of battery status for ASUS Transformer's pad and mobile dock.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
#25 lore raw

Re: [PATCH v12 6/7] power: supply: Add driver for ASUS Transformer battery

In reply to Svyatoslav Ryhel

…

Quoted 2 lines

+++ b/drivers/power/supply/asus-transformer-ec-battery.c

(quoted diff) +0 -0
@@ -0,0 +1,289 @@

…

Quoted 2 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +2 -0
+static const unsigned int asus_ec_battery_prop_offs[] = {
+	[POWER_SUPPLY_PROP_STATUS] = 1,

…

drivers/power/supply/asus-transformer-ec-battery.c line 98

Quoted 13 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +13 -0
+};
+
+static int asus_ec_battery_get_value(struct asus_ec_battery_data *priv,
+				     enum power_supply_property psp)
+{
+	int ret, offs;
+
+	guard(mutex)(&priv->battery_lock);
+
+	if (psp >= ARRAY_SIZE(asus_ec_battery_prop_offs))
+		return -EINVAL;
+
+	offs = asus_ec_battery_prop_offs[psp];

…

What did hinder to make such data type specifications really consistent?
https://lore.kernel.org/linux-pm/[email protected]/

Regards,
Markus

#26 lore raw

PATCH v12 7/7 power: supply: Add charger driver for Asus Transformers

In reply to Svyatoslav Ryhel

From: Michał Mirosław <[email protected]>

Add support for charger detection capabilities found in the embedded controller of ASUS Transformer devices.

---
 drivers/power/supply/Kconfig                  |  11 +
 drivers/power/supply/Makefile                 |   1 +
 .../supply/asus-transformer-ec-charger.c      | 208 ++++++++++++++++++
 3 files changed, 220 insertions(+)
 create mode 100644 drivers/power/supply/asus-transformer-ec-charger.c
drivers/power/supply/Kconfig +11 -0
index 856eb81c97ae9..16d0a38b41b7e 100644
@@ -508,6 +508,17 @@ config CHARGER_88PM860X
 	help
 	  Say Y here to enable charger for Marvell 88PM860x chip.
 
+config CHARGER_ASUS_TRANSFORMER_EC
+	tristate "Asus Transformer's charger driver"
+	depends on MFD_ASUS_TRANSFORMER_EC
+	help
+	  Say Y here to enable support AC plug detection on Asus Transformer
+	  Dock.
+
+	  This sub-driver supports charger detection mechanism found in Asus
+	  Transformer tablets and mobile docks and controlled by special
+	  embedded controller.
+
 config CHARGER_PF1550
 	tristate "NXP PF1550 battery charger driver"
 	depends on MFD_PF1550
drivers/power/supply/Makefile +1 -0
index bec4a6263048c..cd3640f4b7480 100644
@@ -69,6 +69,7 @@ obj-$(CONFIG_CHARGER_RT9471)	+= rt9471.o
 obj-$(CONFIG_CHARGER_RT9756)	+= rt9756.o
 obj-$(CONFIG_BATTERY_TWL4030_MADC)	+= twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X)	+= 88pm860x_charger.o
+obj-$(CONFIG_CHARGER_ASUS_TRANSFORMER_EC)	+= asus-transformer-ec-charger.o
 obj-$(CONFIG_CHARGER_PF1550)	+= pf1550-charger.o
 obj-$(CONFIG_BATTERY_RX51)	+= rx51_battery.o
 obj-$(CONFIG_AB8500_BM)		+= ab8500_bmdata.o ab8500_charger.o ab8500_fg.o ab8500_btemp.o ab8500_chargalg.o
drivers/power/supply/asus-transformer-ec-charger.c new file +208 -0

208 lines not on this page · raw message

Signature · 1 line
2.53.0
#27 lore raw

Re: [PATCH v12 7/7] power: supply: Add charger driver for Asus Transformers

Sashiko has reviewed this patch and found no issues.
Quoted 9 lines

From: Michał Mirosław <[email protected]>

Add support for charger detection capabilities found in the embedded controller of ASUS Transformer devices.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Tested-by on the v12 series
#28 lore raw
In reply to Svyatoslav Ryhel

I tested the v12 series on an ASUS Eee Pad Slider SL101 running Debian 13 with the 7.0.1 postmarketOS Grate kernel.

The system booted successfully. The EC identified as ASUS-EP102-DOCK, firmware SL101-0202. I verified keyboard key events from the EC keyboard and touchscreen contact and coordinate events from the tablet's maXTouch device.

#29 lore raw

вт, 20 жовт. 2026 р. о 03:57 Florian Krischer <[email protected]> пише:

Quoted 10 lines

I tested the v12 series on an ASUS Eee Pad Slider SL101 running Debian 13 with the 7.0.1 postmarketOS Grate kernel.

The system booted successfully. The EC identified as ASUS-EP102-DOCK, firmware SL101-0202. I verified keyboard key events from the EC keyboard and touchscreen contact and coordinate events from the tablet's maXTouch device.

Thank you, Florian! Your feedback is quite valuable.

#30 lore raw
In reply to Svyatoslav Ryhel

пн, 19 жовт. 2026 р. о 13:04 Svyatoslav Ryhel <[email protected]> пише:

Quoted 147 lines

Add support for embedded controller used in Asus Transformers for managing power and input functions.

---
Changes in v2:
- converted sysfs debug exports into debugfs
- added kernel-doc comments for exposed functions
- fixed minor typos and inconsistencies

Changes in v3:
- dropped DockRAM commits (both schema and driver)
- integrated DockRAM functionality directly into the controller driver
- EC schema moved to embedded controllers folder
- removed all cell descriptions from the schema
- removed all compatibles from the cell drivers
- adjusted naming conventions to better align with the ASUS Transformers
- defined EC variant sets to provide coverage for all known devices

Changes in v4:
- grouped known programming models of EC chronologically (both schema and driver)
- call debugfs init only if CONFIG_DEBUG_FS is enabled

Changes in v5:
- added asus,tf600t-ec-dock compatible to schema
- rebased on top of v7.0
- kzalloc > kzalloc_obj in keys and kbc

Changes in v6:
- removed asus_ec_handle_smi casting
- asus_dockram_access_ctl > asus_ec_get_ctl in control_reg_*
- fixed battery Kconfig description

Changes in v7:
- added status check of devm_kasprintf where missing
- devm_asus_ec_register_notifier dropped, added .remove where it was used
- removed cell_to_ec, asus_dockram_read, asus_dockram_write, asus_ec_* public API asus_ec_i2c_command, devm_asus_ec_register_notifier, asus_ec_read, asus_ec_write
- renamed asusec_info > asusec_core
- ec-kbc: added packed size check
ret > error
improved key remap logic
- ec-keys: improve formatting and comments
ret > error
switched to dev_err_probe
- ec-leds: reworked to register both leds via loop
- ec-mfd: adjusted Kconfig description
fixed smbus operation sizes
fixed saving of EC fw model
adjusted IRQ flags
converted to use definer for set cell composition
added factory mode states enum and handling
defined some "magic" values
self > client, info > ec, ecreq > ecreq_gpio, priv > ddata asus_ec_chip_data data > asus_ec_chip_info info
ec_data > ec_buf, ctl_data > ctl_buf
added and improved comments, added structure descriptions asus_ec_magic_debug > asus_ec_susb_on_status
removed all dev_dbg and most of dev_info
pronts with model, fw behavior, factory and susb state preserved switched to MFD_CELL_* macros
removed debugfs
- ec-battery: swithced to BIT macro
lock usage moved to asus_ec_battery_get_value
in asus_ec_battery_poll_work fixed possible rescheduling fail in asus_ec_battery_poll_work fixed missing not charging
- ec-charger: POWER_SUPPLY_PROP_MODEL_NAME set as the first check

Changes in v8:
- added MODULE_ALIAS
- renamed DOCKRAM_* to ASUSEC_*
- ec-keys: input_handler moved into private structure
- ec-leds: added brightness_get
- ec-mdf: fixed i2c_smbus_* return checks () improved model storing
- ec-batt: added status check of devm_kasprintf

Changes in v9:
- fixed i2c_smbus_read_i2c_block_data return check
- blocking_notifier_chain_register moved before serio registration
- adjusted get_unaligned_le16 bounds check
- unsigned long long > u64
- iterator vars made scoped
- removed "magic" values from ec-mfd
- simplified logging, detect split into detect and init
- improved error logs formatting
- adjusted handler in media keys to connect strictly to dock keyboard

Changes in v10:
- ec-kbc: fixed possible out of buffer reads
- ec-kbc: set notifier_call before blocking_notifier_chain_register
- ec-keys: dropped input_unregister_device which should be handled by devm_input_allocate_device

Changes in v11:
- applied changes from Florian Krischer (read_size parameterized and fix keyboard response framing)
- ec-kbc: switch notifier and serio register calls
- ec-keys: used WRITE_ONCE()/READ_ONCE() for priv->special_key_pressed

Changes in v12:
- removed unused includes
- fixed kernel-doc warns
- added check if dockram client and data are not NULL
- replaced handler in media keys with Dmitry's implementation
- calculate battery time props with unsigned value
---

Michał Mirosław (6):
mfd: Add driver for ASUS Transformer embedded controller
input: serio: Add driver for ASUS Transformer dock keyboard and
touchpad
input: keyboard: Add driver for ASUS Transformer dock multimedia keys
leds: Add driver for ASUS Transformer LEDs
power: supply: Add driver for ASUS Transformer battery
power: supply: Add charger driver for Asus Transformers

Svyatoslav Ryhel (1):
dt-bindings: embedded-controller: document ASUS Transformer EC

 .../asus,tf201-ec-pad.yaml                    | 119 ++++
 drivers/input/keyboard/Kconfig                |  10 +
 drivers/input/keyboard/Makefile               |   1 +
 .../input/keyboard/asus-transformer-ec-keys.c | 212 +++++++
 drivers/input/serio/Kconfig                   |  15 +
 drivers/input/serio/Makefile                  |   1 +
 drivers/input/serio/asus-transformer-ec-kbc.c | 264 ++++++++
 drivers/leds/Kconfig                          |  11 +
 drivers/leds/Makefile                         |   1 +
 drivers/leds/leds-asus-transformer-ec.c       | 125 ++++
 drivers/mfd/Kconfig                           |  16 +
 drivers/mfd/Makefile                          |   1 +
 drivers/mfd/asus-transformer-ec.c             | 569 ++++++++++++++++++
 drivers/power/supply/Kconfig                  |  22 +
 drivers/power/supply/Makefile                 |   2 +
 .../supply/asus-transformer-ec-battery.c      | 289 +++++++++
 .../supply/asus-transformer-ec-charger.c      | 208 +++++++
 include/linux/mfd/asus-transformer-ec.h       | 100 +++
 18 files changed, 1966 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/embedded-controller/asus,tf201-ec-pad.yaml
 create mode 100644 drivers/input/keyboard/asus-transformer-ec-keys.c
 create mode 100644 drivers/input/serio/asus-transformer-ec-kbc.c
 create mode 100644 drivers/leds/leds-asus-transformer-ec.c
 create mode 100644 drivers/mfd/asus-transformer-ec.c
 create mode 100644 drivers/power/supply/asus-transformer-ec-battery.c
 create mode 100644 drivers/power/supply/asus-transformer-ec-charger.c
 create mode 100644 include/linux/mfd/asus-transformer-ec.h
Quoted 3 lines

--
2.53.0

Hello Lee!

May you please pick this series? Dmitry Acked input commits. Regarding adjustments to input patches, Dmitry is fine if I send them as followup. Thank you!