Skip to contentSkip to conversation

mfd: Add support for Asus Transformer embedded controller

PATCH Superseded Svyatoslav Ryhel 4 participants 27 messages Jul 21 – Sep 22

Subsystems (6)

v10 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v10 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
---

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 | 310 ++++++++++
 drivers/input/serio/Kconfig                   |  15 +
 drivers/input/serio/Makefile                  |   1 +
 drivers/input/serio/asus-transformer-ec-kbc.c | 168 ++++++
 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             | 549 ++++++++++++++++++
 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       |  92 +++
 18 files changed, 1940 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 v10 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 v10 1/7] dt-bindings: embedded-controller: document ASUS Transformer EC

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The `reg` property lacks a `maxItems` constraint or explicit `items` list, which will cause a…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The reg property lacks a maxItems constraint or explicit items list, which will cause a meta-schema validation failure. --

--- Patch [1]: [PATCH v10 1/7] dt-bindings: embedded-controller: document ASUS Transformer EC --- commit 9a8d6db220adffb6b7bdbf5fea9059f76a4c94f3
Author: Svyatoslav Ryhel <[email protected]>

dt-bindings: embedded-controller: document ASUS Transformer EC

This commit documents the embedded controller used in the ASUS Transformer device series. It adds a new YAML binding describing the Nuvoton-based controllers attached to an I2C bus.

Quoted 5 lines
Documentation/devicetree/bindings/embedded-controller/asus,tf201-ec-pad.yaml new file +0 -0
new file mode 100644
index 0000000000000..60b6375864aaf

[ ... ]

Documentation/devicetree/bindings/embedded-controller/asus,tf201-ec-pad.yaml line 64

Quoted 6 lines
Documentation/devicetree/bindings/embedded-controller/asus,tf201-ec-pad.yaml new file +6 -0
+  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

[Severity: Low]
Does this reg property also need a maxItems constraint or an explicit items array list? The device tree meta-schema requires standard array properties to be fully bounded to avoid implicitly unbounded arrays, which will likely trigger a failure during make dt_binding_check.

[ ... ]

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

PATCH v10 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       | 549 ++++++++++++++++++++++++
 include/linux/mfd/asus-transformer-ec.h |  92 ++++
 4 files changed, 658 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 35f6e9b76d056..7e67d4e4249ff 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 dd4bb7e77c336..79806201bbb24 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 +549 -0

549 lines not on this page · raw message

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

92 lines not on this page · raw message

Signature · 1 line
2.53.0
#4 lore raw

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

Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider: - [High] The shared interrupt buffer `ddata->ec_buf` is overwritten during SMI handling, causing event loss…

Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
- [High] The shared interrupt buffer ddata->ec_buf is overwritten during SMI handling, causing event loss and data corruption before broadcast.
- [Medium] The driver exports a bespoke accessor function (asus_dockram_access_ctl) for child devices, violating MFD architecture guidelines.
- [Medium] The driver hardcodes MFD cell IDs and the base ID instead of using automatic cell indexing (PLATFORM_DEVID_AUTO).
- [Medium] A complex pointer to a structure is passed as match data via the .data field in the device tree match table.
- [Low] The commit message prefix does not follow the mandatory format for the MFD subsystem.
- [Low] A driver-specific header file is incorrectly placed in the global MFD include directory.
--

--- Patch [2]: [PATCH v10 2/7] mfd: Add driver for ASUS Transformer embedded controller --- commit a8d39d11a11a5c2d6e44a0723ad1b451adc8effe
Author: Michał Mirosław <[email protected]>

mfd: Add driver for ASUS Transformer embedded controller

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.

Quoted 1 line

mfd: Add driver for ASUS Transformer embedded controller

[Severity: Low]
This isn't a bug, but does this commit message prefix follow the standard MFD subsystem format? I believe it should be formatted as "mfd: <Driver>: <Capitalized description>", for example:
"mfd: asus-transformer-ec: Add driver...".

[ ... ]

Quoted 5 lines
drivers/mfd/asus-transformer-ec.c new file +0 -0
new file mode 100644
index 0000000000000..739c66fdaf22f

[ ... ]

Quoted 13 lines
drivers/mfd/asus-transformer-ec.c new file +13 -0
+int asus_dockram_access_ctl(struct i2c_client *client, u64 *out, u64 mask,
+			    u64 xor)
+{
+	struct dockram_ec_data *ddata = i2c_get_clientdata(client);
+	u8 *buf = ddata->ctl_buf;
+	u64 val;
+	int ret = 0;
+
+	guard(mutex)(&ddata->ctl_lock);
+
+	memset(buf, 0, ASUSEC_ENTRY_BUFSIZE);
+	ret = i2c_smbus_read_i2c_block_data(client, ASUSEC_DOCKRAM_CONTROL,
+					    ASUSEC_ENTRY_SIZE, buf);

[ ... ]

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

Quoted 3 lines
drivers/mfd/asus-transformer-ec.c new file +3 -0
+	return 0;
+}
+EXPORT_SYMBOL_GPL(asus_dockram_access_ctl);

[Severity: Medium]
Does exporting this bespoke accessor for child devices violate the MFD layering rules? It looks like it creates tight coupling between the parent and child drivers instead of using standard APIs like regmap or dev_get_drvdata().

[ ... ]

Quoted 21 lines
drivers/mfd/asus-transformer-ec.c new file +21 -0
+static void asus_ec_clear_buffer(struct asus_ec_data *ddata)
+{
+	int ret, retry = ASUSEC_RSP_BUFFER_SIZE;
+
+	/*
+	 * Read the buffer till we get valid data by checking ASUSEC_OBF_MASK
+	 * of the status byte or till we reach end of the 256 byte buffer.
+	 */
+	while (retry--) {
+		ret = i2c_smbus_read_i2c_block_data(ddata->client, ASUSEC_READ_BUF,
+						    ASUSEC_ENTRY_SIZE,
+						    ddata->ec_buf);
+		if (ret < ASUSEC_ENTRY_SIZE)
+			continue;
+
+		if (ddata->ec_buf[ASUSEC_IRQ_STATUS] & ASUSEC_OBF_MASK)
+			continue;
+
+		break;
+	}
+}

[ ... ]

Quoted 20 lines
drivers/mfd/asus-transformer-ec.c new file +20 -0
+static irqreturn_t asus_ec_interrupt(int irq, void *dev_id)
+{
+	struct asus_ec_data *ddata = dev_id;
+	unsigned long notify_action;
+	int ret;
+
+	ret = i2c_smbus_read_i2c_block_data(ddata->client, ASUSEC_READ_BUF,
+					    ASUSEC_ENTRY_SIZE, ddata->ec_buf);
+	if (ret < ASUSEC_ENTRY_SIZE)
+		return IRQ_NONE;
+
+	/* Check status byte with ASUSEC_OBF_MASK if data is valid */
+	ret = ddata->ec_buf[ASUSEC_IRQ_STATUS] & ASUSEC_OBF_MASK;
+	if (!ret)
+		return IRQ_NONE;
+
+	notify_action = ddata->ec_buf[ASUSEC_IRQ_STATUS];
+	if (notify_action & ASUSEC_SMI_MASK) {
+		unsigned int code = ddata->ec_buf[ASUSEC_SMI_CODE];
+

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

Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+		asus_ec_handle_smi(ddata, code);
+
+		notify_action |= code << 8;
+	}
+
+	blocking_notifier_call_chain(&ddata->ec.notify_list,
+				     notify_action, ddata->ec_buf);
+
+	return IRQ_HANDLED;
+}

[Severity: High]
Can this sequence corrupt the interrupt event payload?

When asus_ec_handle_smi() receives ASUSEC_SMI_HANDSHAKE or ASUSEC_SMI_RESET, it calls asus_ec_init() which then calls asus_ec_clear_buffer().

Because asus_ec_clear_buffer() repeatedly reads from the bus into the exact same shared ddata->ec_buf until the queue is empty, won't it overwrite the original event payload?

If so, the subsequent call to blocking_notifier_call_chain() will broadcast a clobbered buffer (containing the final empty read) to the notifiers instead of the actual event data.

[ ... ]

Quoted 7 lines
drivers/mfd/asus-transformer-ec.c new file +7 -0
+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"),
+};

[ ... ]

Quoted 2 lines
drivers/mfd/asus-transformer-ec.c new file +2 -0
+static int asus_ec_probe(struct i2c_client *client)
+{

[ ... ]

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

Quoted 2 lines
drivers/mfd/asus-transformer-ec.c new file +2 -0
+	return devm_mfd_add_devices(dev, 0, cells, num_cells, NULL, 0, NULL);
+}

[Severity: Medium]
Does hardcoding the cell IDs and the base ID lead to device naming collisions?

The MFD subsystem guidelines mandate using PLATFORM_DEVID_AUTO for automatic cell indexing instead of explicitly passing 0 or statically mapped IDs via the MFD_CELL_BASIC macro.

[ ... ]

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

Quoted 5 lines
drivers/mfd/asus-transformer-ec.c new file +5 -0
+static const struct of_device_id asus_ec_match[] = {
+	{
+		.compatible = "asus,sl101-ec-dock",
+		.data = &asus_ec_sl101_dock_data
+	}, {

[Severity: Medium]
Is it safe to pass a complex structure pointer via the match table's .data field?

Passing complex pointers this way can cause memory safety hazards and initialization ordering races. Should this store an enum or integer ID instead, and resolve the struct in the probe function?

[ ... ]

include/linux/mfd/asus-transformer-ec.h

Quoted 5 lines
include/linux/mfd/asus-transformer-ec.h new file +0 -0
new file mode 100644
index 0000000000000..1c25c3a18355c

[Severity: Low]
This isn't a bug, but should this driver-specific header be placed in the global include/linux/mfd/ directory? It looks like it is only used by the parent and its immediate children, which suggests it should be kept local to drivers/mfd/ to avoid tight coupling.

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

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

In reply to Svyatoslav Ryhel

Hello,

Quoted 10 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.

Documentation/process/submitting-patches.rst has:

[...] the ordering of Signed-off-by: tags should reflect the chronological history of the patch insofar as possible [...]

So your S-o-b should be last when you submit a patch.

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

Quoted 3 lines
drivers/mfd/asus-transformer-ec.c new file +2 -0
+#include <linux/i2c.h>
[...]
+#include <linux/mod_devicetable.h>

<linux/mod_devicetable.h> will go away soon. Please rely on <linux/i2c.h> to provide a definition of struct of_device_id and drop the #include of mod_devicetable.h.

Quoted 6 lines
drivers/mfd/asus-transformer-ec.c new file +6 -0
+static const struct of_device_id asus_ec_match[] = {
+	{
+		.compatible = "asus,sl101-ec-dock",
+		.data = &asus_ec_sl101_dock_data
+	}, {
+		.compatible = "asus,tf101-ec-dock",

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

Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+		.data = &asus_ec_tf101_dock_data
+	}, {
+		.compatible = "asus,tf201-ec-pad",
+		.data = &asus_ec_tf201_pad_data
+	}, {
+		.compatible = "asus,tf600t-ec-pad",
+		.data = &asus_ec_tf600t_pad_data
+	},
+	{ /* sentinel */ }
+};

Trailing comma after the assignments to .data please.

Best regards
Uwe

#6 lore raw

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

чт, 23 лип. 2026 р. о 09:25 Uwe Kleine-König
<[email protected]> пише:

Quoted 40 lines

Hello,

Quoted 10 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.

Documentation/process/submitting-patches.rst has:

[...] the ordering of Signed-off-by: tags should reflect the chronological history of the patch insofar as possible [...]

So your S-o-b should be last when you submit a patch.

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

Quoted 3 lines
drivers/mfd/asus-transformer-ec.c new file +2 -0
+#include <linux/i2c.h>
[...]
+#include <linux/mod_devicetable.h>

<linux/mod_devicetable.h> will go away soon. Please rely on <linux/i2c.h> to provide a definition of struct of_device_id and drop the #include of mod_devicetable.h.

Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+static const struct of_device_id asus_ec_match[] = {
+     {
+             .compatible = "asus,sl101-ec-dock",
+             .data = &asus_ec_sl101_dock_data
+     }, {
+             .compatible = "asus,tf101-ec-dock",
+             .data = &asus_ec_tf101_dock_data
+     }, {
+             .compatible = "asus,tf201-ec-pad",
+             .data = &asus_ec_tf201_pad_data
Quoted 9 lines

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

Quoted 6 lines
drivers/mfd/asus-transformer-ec.c new file +6 -0
+     }, {
+             .compatible = "asus,tf600t-ec-pad",
+             .data = &asus_ec_tf600t_pad_data
+     },
+     { /* sentinel */ }
+};

Trailing comma after the assignments to .data please.

Sure, but out of curiosity, why in this case you ask for trailing comma and if entries are in one line, you don't.

Quoted 2 lines

Best regards
Uwe

#7 lore raw

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

Quoted 52 lines · Svyatoslav Ryhel

чт, 23 лип. 2026 р. о 09:25 Uwe Kleine-König
<[email protected]> пише:

Quoted 40 lines

Hello,

Quoted 10 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.

Documentation/process/submitting-patches.rst has:

[...] the ordering of Signed-off-by: tags should reflect the chronological history of the patch insofar as possible [...]

So your S-o-b should be last when you submit a patch.

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

Quoted 3 lines
drivers/mfd/asus-transformer-ec.c new file +2 -0
+#include <linux/i2c.h>
[...]
+#include <linux/mod_devicetable.h>

<linux/mod_devicetable.h> will go away soon. Please rely on <linux/i2c.h> to provide a definition of struct of_device_id and drop the #include of mod_devicetable.h.

Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+static const struct of_device_id asus_ec_match[] = {
+     {
+             .compatible = "asus,sl101-ec-dock",
+             .data = &asus_ec_sl101_dock_data
+     }, {
+             .compatible = "asus,tf101-ec-dock",
+             .data = &asus_ec_tf101_dock_data
+     }, {
+             .compatible = "asus,tf201-ec-pad",
+             .data = &asus_ec_tf201_pad_data
Quoted 9 lines

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

Quoted 6 lines
drivers/mfd/asus-transformer-ec.c new file +6 -0
+     }, {
+             .compatible = "asus,tf600t-ec-pad",
+             .data = &asus_ec_tf600t_pad_data
+     },
+     { /* sentinel */ }
+};

Trailing comma after the assignments to .data please.

Quoted 2 lines

Sure, but out of curiosity, why in this case you ask for trailing comma and if entries are in one line, you don't.

Because this is the most used style. The rationale for the trailing comma is that if you want to add a new assignment to a multiline initializer you have to touch the line without comma:

}, {
.compatible = "asus,tf600t-ec-pad",
- .data = &asus_ec_tf600t_pad_data
+ .data = &asus_ec_tf600t_pad_data,
+ .something_else = &foobar,
},

so if the comma is already there, the patch reduces to:

}, {
.compatible = "asus,tf600t-ec-pad", .data = &asus_ec_tf600t_pad_data,
+ .something_else = &foobar,
},

. For adding a new assignment to:

{ .compatible = "..." }

you have to touch the line anyhow, so there is no advantage to already have the comma. And then it seems parsimony prevails.

Best regards
Uwe

#8 lore raw

PATCH v10 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 | 168 ++++++++++++++++++
 3 files changed, 184 insertions(+)
 create mode 100644 drivers/input/serio/asus-transformer-ec-kbc.c
drivers/input/serio/Kconfig +15 -0
index bacab1f584009..efb5aa59c364b 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 +168 -0

168 lines not on this page · raw message

Signature · 1 line
2.53.0
#9 lore raw

Re: [PATCH v10 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: - [High] Incorrect registration order of the notifier and serio ports leads to NULL pointer dereferences…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incorrect registration order of the notifier and serio ports leads to NULL pointer dereferences during probe and use-after-free bugs during driver removal. --

--- Patch [3]: [PATCH v10 3/7] input: serio: Add driver for ASUS Transformer dock keyboard and touchpad --- commit 4e9b70c95d0f43e6f5bf78aeff2f78f72b9b2f82
Author: Michał Mirosław <[email protected]>

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

Add input driver for ASUS Transformer dock keyboard and touchpad.

Quoted 5 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +0 -0
new file mode 100644
index 0000000000000..c6d12c44449d0

[ ... ]

Quoted 3 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +3 -0
+static int asus_ec_kbc_notify(struct notifier_block *nb,
+			      unsigned long action, void *data_)
+{

[ ... ]

Quoted 5 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +5 -0
+	while (n--)
+		serio_interrupt(priv->sdev[port_idx], *data++, 0);
+
+	return NOTIFY_OK;
+}

[ ... ]

Quoted 23 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +23 -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);
+
+	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,

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

Quoted 10 lines
drivers/input/serio/asus-transformer-ec-kbc.c new file +10 -0
+					 asus_ec_notifier_chain_unregister,
+					 priv);
+	if (error)
+		return error;
+
+	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);

[Severity: High]
Does this registration order leave the driver vulnerable to race conditions?

Since the parent MFD device might have already enabled its IRQ, an interrupt can fire immediately after blocking_notifier_chain_register() completes. If this occurs before the serio ports are registered, asus_ec_kbc_notify() will read priv->sdev[port_idx] which is still NULL, and pass it to serio_interrupt(), leading to a NULL pointer dereference.

Additionally, because devm actions execute in LIFO order during driver removal or probe failure, the serio ports will be unregistered and freed before the notifier is unregistered. If an interrupt fires during this teardown window, could it pass a freed serio pointer to serio_interrupt() and cause a use-after-free?

Should the notifier be registered only after the serio ports are fully allocated and registered to prevent these crashes?

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

PATCH v10 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 | 310 ++++++++++++++++++
 3 files changed, 321 insertions(+)
 create mode 100644 drivers/input/keyboard/asus-transformer-ec-keys.c
drivers/input/keyboard/Kconfig +10 -0
index 9d1019ba0245b..913cb4900565c 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 +310 -0

310 lines not on this page · raw message

Signature · 1 line
2.53.0
#11 lore raw

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

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Concurrent lockless access to the shared state variable `priv->special_key_pressed` across…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Concurrent lockless access to the shared state variable priv->special_key_pressed across different execution contexts without READ_ONCE() / WRITE_ONCE() annotations. --

--- Patch [4]: [PATCH v10 4/7] input: keyboard: Add driver for ASUS Transformer dock multimedia keys --- commit 258dea9f255ed0dea28a80d3eb88521b79b225d6
Author: Michał Mirosław <[email protected]>

input: keyboard: Add driver for ASUS Transformer dock multimedia keys

This patch adds support for the multimedia top button row of the ASUS Transformer's Mobile Dock keyboard. It enables function keys by default and allows switching to multimedia keys by pressing ScreenLock + AltGr.

Quoted 5 lines
drivers/input/keyboard/asus-transformer-ec-keys.c new file +0 -0
new file mode 100644
index 0000000000000..44235e4a7f548

[ ... ]

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

Quoted 9 lines
drivers/input/keyboard/asus-transformer-ec-keys.c new file +9 -0
+static void asus_ec_input_event(struct input_handle *handle,
+				unsigned int event_type,
+				unsigned int event_code, int value)
+{
+	struct asus_ec_keys_data *priv = handle->handler->private;
+
+	/* Store special key state */
+	if (event_type == EV_KEY && event_code == KEY_RIGHTALT)
+		priv->special_key_pressed = !!value;

[Severity: Medium]
Could this lockless write cause data races when accessed concurrently?

This executes in the input core's event delivery context, while the EC notification path reads it. Should this use WRITE_ONCE() to prevent potential KCSAN warnings about unmarked data races?

Quoted 1 line

+}

[ ... ]

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

Quoted 10 lines
drivers/input/keyboard/asus-transformer-ec-keys.c new file +10 -0
+static int asus_ec_keys_process_key(struct input_dev *dev, u8 code)
+{
+	struct asus_ec_keys_data *priv = dev_get_drvdata(dev->dev.parent);
+	unsigned int key = 0;
+
+	if (code == 0)
+		return NOTIFY_DONE;
+
+	/* Flip special key mode state when pressing SCREEN LOCK + R ALT */
+	if (priv->special_key_pressed && code == 1) {

[Severity: Medium]
Is it possible to read a stale value here due to concurrent modification?

Since priv->special_key_pressed is updated in the input event path and read here in the blocking notifier thread without synchronization, should this use READ_ONCE() to ensure the compiler doesn't perform unexpected optimizations?

Quoted 3 lines
drivers/input/keyboard/asus-transformer-ec-keys.c new file +3 -0
+		priv->special_key_mode = !priv->special_key_mode;
+		return NOTIFY_DONE;
+	}

[ ... ]

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

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

In reply to Svyatoslav Ryhel

вт, 21 лип. 2026 р. о 12:53 Svyatoslav Ryhel <[email protected]> пише:

Quoted 13 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 7 lines
---
 drivers/input/keyboard/Kconfig                |  10 +
 drivers/input/keyboard/Makefile               |   1 +
 .../input/keyboard/asus-transformer-ec-keys.c | 310 ++++++++++++++++++
 3 files changed, 321 insertions(+)
 create mode 100644 drivers/input/keyboard/asus-transformer-ec-keys.c

Hello Dmitry!

May you please take a look? ATM only ACK on input patches left.

Thank you!

#13 lore raw

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

ср, 19 серп. 2026 р. о 12:20 Svyatoslav Ryhel <[email protected]> пише:

Quoted 23 lines

вт, 21 лип. 2026 р. о 12:53 Svyatoslav Ryhel <[email protected]> пише:

Quoted 13 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 7 lines
---
 drivers/input/keyboard/Kconfig                |  10 +
 drivers/input/keyboard/Makefile               |   1 +
 .../input/keyboard/asus-transformer-ec-keys.c | 310 ++++++++++++++++++
 3 files changed, 321 insertions(+)
 create mode 100644 drivers/input/keyboard/asus-transformer-ec-keys.c
Quoted 5 lines

Hello Dmitry!

May you please take a look? ATM only ACK on input patches left.

Thank you!

Hello Dmitry!

May you please take a look? ATM only ACK on input patches left. I would like this patch set to move forward.

Thank you!

#14 lore raw

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

нд, 6 вер. 2026 р. о 20:22 Svyatoslav Ryhel <[email protected]> пише:

Quoted 29 lines

ср, 19 серп. 2026 р. о 12:20 Svyatoslav Ryhel <[email protected]> пише:

Quoted 27 lines

вт, 21 лип. 2026 р. о 12:53 Svyatoslav Ryhel <[email protected]> пише:

Quoted 13 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 7 lines
---
 drivers/input/keyboard/Kconfig                |  10 +
 drivers/input/keyboard/Makefile               |   1 +
 .../input/keyboard/asus-transformer-ec-keys.c | 310 ++++++++++++++++++
 3 files changed, 321 insertions(+)
 create mode 100644 drivers/input/keyboard/asus-transformer-ec-keys.c

Hello Dmitry!

May you please take a look? ATM only ACK on input patches left.

Quoted 8 lines
Quoted 1 line

Thank you!

Hello Dmitry!

May you please take a look? ATM only ACK on input patches left. I would like this patch set to move forward.

Thank you!

Hello Dmitry!

May you please take a look? ATM only ACK on input patches left. I would like this series to move forward. Thank you!

#15 lore raw

PATCH v10 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 f4a0a3c8c8705..f637d23400a89 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 it's 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 7db3768912ca5..56304ab90eb31 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
#16 lore raw

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

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [Medium] The manually constructed LED sysfs name incorrectly places the color in the function field.…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] The manually constructed LED sysfs name incorrectly places the color in the function field.
- [Medium] The child driver uses a bespoke custom accessor function exposed by the MFD parent, violating MFD API layering guidelines.
- [Low] The commit message subject prefix does not adhere to the mandatory subsystem prefix format.
- [Low] The Kconfig help text contains a grammatical error, using "it's" instead of "its".
--

--- Patch [5]: [PATCH v10 5/7] leds: Add driver for ASUS Transformer LEDs --- commit 177b0b82c65e4fc0357f15d45f7c0353ef5cb99a
Author: Michał Mirosław <[email protected]>

leds: Add driver for ASUS Transformer LEDs

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.

Quoted 1 line

leds: Add driver for ASUS Transformer LEDs

[Severity: Low]
This isn't a bug, but does the commit subject prefix follow the LED subsystem guidelines? The subsystem typically expects the format
leds: <Driver>: <Capitalized description>.

Quoted 5 lines
drivers/leds/Kconfig +0 -0
index f4a0a3c8c8705..f637d23400a89 100644

drivers/leds/Kconfig config LEDS_OSRAM_AMS_AS3668 · line 129

Quoted 10 lines
drivers/leds/Kconfig +7 -0
@@ -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 it's Dock.
                                           ^^^^

[Severity: Low]
This isn't a bug, but should "it's" be "its" here?

[ ... ]

Quoted 5 lines
drivers/leds/leds-asus-transformer-ec.c new file +0 -0
new file mode 100644
index 0000000000000..4421d629911ed

[ ... ]

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

Quoted 8 lines
drivers/leds/leds-asus-transformer-ec.c new file +8 -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);

[Severity: Medium]
Does using the custom parent accessor asus_dockram_access_ctl() violate MFD API layering guidelines?

MFD core drivers should usually expose standard shared resources like regmap rather than bespoke helper functions for child drivers to use, as it creates tight coupling between the parent and child.

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);

[Severity: Medium]
This is the same custom accessor as above, used again here in asus_ec_led_set_brightness(). Should this be refactored to use standard accessors?

[ ... ]

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -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;
+
+	ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+	if (!ddata)
+		return -ENOMEM;

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

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +10 -0
+
+	platform_set_drvdata(pdev, ddata);
+	ddata->ec = ec;
+
+	for (int i = 0; i < ASUSEC_LED_MAX; i++) {
+		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);

[Severity: Medium]
Since cfg->name contains the color (amber or green), does this format string incorrectly place the color in the function segment of the standard devicename:color:function naming scheme?

This will generate devicename::color instead of devicename:color:function, which might confuse userspace LED managers that rely on standard sysfs directories.

Quoted 2 lines
drivers/leds/leds-asus-transformer-ec.c new file +2 -0
+		if (!led->cdev.name)
+			return -ENOMEM;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
#17 lore raw

PATCH v10 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 f0ede1cecb6a8..24996ee6d90dd 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 31fe4a145929a..05c306817b449 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
#18 lore raw

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

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] The bounds check for battery property reading fails to account for the 2-byte read size…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The bounds check for battery property reading fails to account for the 2-byte read size, allowing the second byte to be read from logically invalid padding data.
- [Medium] Battery data cache is not invalidated on system resume, causing user-space to receive potentially stale battery readings.
--

--- Patch [6]: [PATCH v10 6/7] power: supply: Add driver for ASUS Transformer battery --- commit 576ecafdda8cdf8e2dbf1964e8a1e9097bcefa55
Author: Michał Mirosław <[email protected]>

power: supply: Add driver for ASUS Transformer battery

This commit adds a new battery driver for Asus Transformer tablets and mobile docks. It implements one battery cell per EC controller and supports reading battery status via I2C.

Quoted 5 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +0 -0
new file mode 100644
index 0000000000000..4c0c6d4b09e2c

[ ... ]

Quoted 12 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +12 -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];
+	if (!offs)

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

Quoted 10 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +10 -0
+		return -EINVAL;
+
+	ret = asus_ec_battery_refresh(priv);
+	if (ret < 0)
+		return ret;
+
+	if (offs >= priv->batt_data[0])
+		return -ENODATA;
+
+	return get_unaligned_le16(priv->batt_data + offs);

[Severity: Medium]
Should the bounds check account for the 2-byte read size?

If the EC returns a length where offs == priv->batt_data[0] - 1, the bounds check offs >= priv->batt_data[0] will pass.

Since get_unaligned_le16() reads two bytes, wouldn't it read a byte past the logical data length and return corrupted data instead of -ENODATA?

Quoted 1 line

+}

[ ... ]

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

Quoted 9 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +9 -0
+static int __maybe_unused asus_ec_battery_resume(struct device *dev)
+{
+	struct asus_ec_battery_data *priv = dev_get_drvdata(dev);
+
+	schedule_delayed_work(&priv->poll_work,
+			      msecs_to_jiffies(ASUSEC_BATTERY_DATA_FRESH_MSEC));
+
+	return 0;
+}

[Severity: Medium]
Should the data cache be explicitly invalidated here?

If priv->batt_data_ts is not reset on resume, and jiffies has not sufficiently advanced past the expiration timestamp during suspend, could the driver serve stale battery data to user-space from before the sleep?

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

PATCH v10 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 24996ee6d90dd..3011591c9d755 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 05c306817b449..9d51fdb76eee8 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
#20 lore raw

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

Sashiko has reviewed this patch and found no issues. It looks great!
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. It looks great!

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

PATCH v10 1/2 mfd: asus-transformer-ec: use 8-byte event reads on SL101

In reply to Svyatoslav Ryhel

The SL101 embedded controller exposes the event window at 0x6a through 8-byte reads. This matches the downstream ASUS SL101 driver, which uses an 8-byte SMBus I2C block read for command responses and events.

The generic 32-byte event read used by v10 prevents the physical SL101 keyboard from completing PS/2 initialization.

Use a variant-specific event read length for the SL101 in both the clear-buffer and interrupt paths. Keep the 32-byte entry size for other variants.

Tested on an ASUS Eee Pad Slider SL101 with EC firmware SL101-0202. With the matching serio fixup, the built-in keyboard completes atkbd initialization and works.

---
 drivers/mfd/asus-transformer-ec.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/mfd/asus-transformer-ec.c +15 -4
@@ -229,8 +229,18 @@
 	return ret;
 }
 
+static size_t asus_ec_read_size(const struct asus_ec_data *ddata)
+{
+	/* SL101 firmware exposes an 8-byte event window at 0x6a. */
+	if (ddata->info->variant == ASUSEC_SL101_DOCK)
+		return 8;
+
+	return ASUSEC_ENTRY_SIZE;
+}
+
 static void asus_ec_clear_buffer(struct asus_ec_data *ddata)
 {
+	size_t read_size = asus_ec_read_size(ddata);
 	int ret, retry = ASUSEC_RSP_BUFFER_SIZE;
 
 	/*
@@ -239,8 +249,8 @@
 	 */
 	while (retry--) {
 		ret = i2c_smbus_read_i2c_block_data(ddata->client, ASUSEC_READ_BUF,
-						    ASUSEC_ENTRY_SIZE, ddata->ec_buf);
-		if (ret < ASUSEC_ENTRY_SIZE)
+						    read_size, ddata->ec_buf);
+		if (ret < read_size)
 			continue;
 
 		if (ddata->ec_buf[ASUSEC_IRQ_STATUS] & ASUSEC_OBF_MASK)
@@ -318,12 +328,13 @@
 static irqreturn_t asus_ec_interrupt(int irq, void *dev_id)
 {
 	struct asus_ec_data *ddata = dev_id;
+	size_t read_size = asus_ec_read_size(ddata);
 	unsigned long notify_action;
 	int ret;
 
 	ret = i2c_smbus_read_i2c_block_data(ddata->client, ASUSEC_READ_BUF,
-					    ASUSEC_ENTRY_SIZE, ddata->ec_buf);
-	if (ret < ASUSEC_ENTRY_SIZE)
+					    read_size, ddata->ec_buf);
+	if (ret < read_size)
 		return IRQ_NONE;
 
 	/* Check status byte with ASUSEC_OBF_MASK if data is valid */

--

#22 lore raw

Re: [PATCH v10 fixup 1/2] mfd: asus-transformer-ec: use 8-byte event reads on SL101

пн, 21 вер. 2026 р. о 20:52 Florian Krischer <[email protected]> пише:

Quoted 12 lines

The SL101 embedded controller exposes the event window at 0x6a through 8-byte reads. This matches the downstream ASUS SL101 driver, which uses an 8-byte SMBus I2C block read for command responses and events.

The generic 32-byte event read used by v10 prevents the physical SL101 keyboard from completing PS/2 initialization.

Use a variant-specific event read length for the SL101 in both the clear-buffer and interrupt paths. Keep the 32-byte entry size for other variants.

Quoted 9 lines

Tested on an ASUS Eee Pad Slider SL101 with EC firmware SL101-0202. With the matching serio fixup, the built-in keyboard completes atkbd initialization and works.

---
 drivers/mfd/asus-transformer-ec.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

Hello Florian!

Thank you for looking in and testing this series.

Quoted 5 lines
drivers/mfd/asus-transformer-ec.c +0 -0
@@ -229,8 +229,18 @@
        return ret;
 }

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

Quoted 10 lines
drivers/mfd/asus-transformer-ec.c +9 -0
 
+static size_t asus_ec_read_size(const struct asus_ec_data *ddata)
+{
+       /* SL101 firmware exposes an 8-byte event window at 0x6a. */
+       if (ddata->info->variant == ASUSEC_SL101_DOCK)
+               return 8;
+
+       return ASUSEC_ENTRY_SIZE;
+}
+

If SL101 needs a different entry size, it can be passed via asus_ec_chip_info structure and will look much cleaner. I will do that in the v11. Since this patch is intended to be fold into the series. You can test v11 and add your Signed-off-by and Tested-by if it works for you. Will that be acceptable?

Quoted 34 lines
drivers/mfd/asus-transformer-ec.c +6 -5
 static void asus_ec_clear_buffer(struct asus_ec_data *ddata)
 {
+       size_t read_size = asus_ec_read_size(ddata);
        int ret, retry = ASUSEC_RSP_BUFFER_SIZE;
 
        /*
@@ -239,8 +249,8 @@
         */
        while (retry--) {
                ret = i2c_smbus_read_i2c_block_data(ddata->client, ASUSEC_READ_BUF,
-                                                   ASUSEC_ENTRY_SIZE, ddata->ec_buf);
-               if (ret < ASUSEC_ENTRY_SIZE)
+                                                   read_size, ddata->ec_buf);
+               if (ret < read_size)
                        continue;
 
                if (ddata->ec_buf[ASUSEC_IRQ_STATUS] & ASUSEC_OBF_MASK)
@@ -318,12 +328,13 @@
 static irqreturn_t asus_ec_interrupt(int irq, void *dev_id)
 {
        struct asus_ec_data *ddata = dev_id;
+       size_t read_size = asus_ec_read_size(ddata);
        unsigned long notify_action;
        int ret;
 
        ret = i2c_smbus_read_i2c_block_data(ddata->client, ASUSEC_READ_BUF,
-                                           ASUSEC_ENTRY_SIZE, ddata->ec_buf);
-       if (ret < ASUSEC_ENTRY_SIZE)
+                                           read_size, ddata->ec_buf);
+       if (ret < read_size)
                return IRQ_NONE;
 
        /* Check status byte with ASUSEC_OBF_MASK if data is valid */
--
#23 lore raw

Re: [PATCH v10 fixup 1/2] mfd: asus-transformer-ec: use 8-byte event reads on SL101

Hi Svyatoslav,

Yes, that works for me. Passing the entry size through asus_ec_chip_info sounds cleaner.

I'll test v11 on my SL101 when it's ready and add my Tested-by and Signed-off-by.

Thanks for picking this up!

Florian

#24 lore raw

PATCH v10 2/2 input: serio: asus-transformer-ec: fix keyboard response framing

In reply to Svyatoslav Ryhel

Real SL101 hardware exposes two issues in the v10 keyboard response handling.

First, keyboard command responses may carry OBF without KEY or KBC. The downstream ASUS driver treats valid non-AUX OBF responses as keyboard data. Dropping these packets prevents PS/2 ACK responses from reaching atkbd.

Second, the EC count byte is the number of bytes following the count byte, not the total packet size. For example, the SL101 returns the keyboard reset response:

03 09 fa aa

where 03 counts status 09, ACK fa and BAT-success aa.

v9 used data[0] - 1 after skipping the count and status bytes. v10 changed this to data[0] - 2 while tightening the packet bound, which drops the final payload byte. Keep the v10 bound but restore the correct payload count.

Tested on an ASUS Eee Pad Slider SL101 with EC firmware SL101-0202. Together with the SL101 8-byte event-read fixup, the physical sliding keyboard completes atkbd initialization and works.

---
 drivers/input/serio/asus-transformer-ec-kbc.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/input/serio/asus-transformer-ec-kbc.c +11 -5
@@ -26,20 +26,26 @@
 		return NOTIFY_DONE;
 	else if (action & ASUSEC_AUX_MASK)
 		port_idx = 1;
-	else if (action & (ASUSEC_KBC_MASK | ASUSEC_KEY_MASK))
+	else if (action & ASUSEC_OBF_MASK)
+		/*
+		 * Keyboard command responses can carry only OBF, without KEY or
+		 * KBC set. The original SL101 driver treated every valid non-AUX,
+		 * non-SMI/SCI OBF packet as keyboard data, including PS/2 ACKs.
+		 */
 		port_idx = 0;
 	else
 		return NOTIFY_DONE;
 
 	/*
-	 * The data[0] is the length of the packet including itself. The data[]
-	 * buffer has to be at least 3 bytes (length + ctrl + 1 data byte) and
-	 * must not exceed the EC entry size.
+	 * data[0] is the number of bytes following the count byte: one status
+	 * byte plus the payload. The SL101 EC, for example, reports keyboard
+	 * reset as 03 09 fa aa (status 09, ACK fa, BAT aa). Skip the count and
+	 * status bytes and forward every payload byte to serio.
 	 */
 	if (data[0] < 2 || data[0] > ASUSEC_ENTRY_SIZE)
 		return NOTIFY_BAD;
 
-	n = data[0] - 2;
+	n = data[0] - 1;
 	data += 2;
 
 	if (port_idx == 0) {

--

#25 lore raw

Re: [PATCH v10 fixup 2/2] input: serio: asus-transformer-ec: fix keyboard response framing

пн, 21 вер. 2026 р. о 20:52 Florian Krischer <[email protected]> пише:

Quoted 34 lines

Real SL101 hardware exposes two issues in the v10 keyboard response handling.

First, keyboard command responses may carry OBF without KEY or KBC. The downstream ASUS driver treats valid non-AUX OBF responses as keyboard data. Dropping these packets prevents PS/2 ACK responses from reaching atkbd.

Second, the EC count byte is the number of bytes following the count byte, not the total packet size. For example, the SL101 returns the keyboard reset response:

03 09 fa aa

where 03 counts status 09, ACK fa and BAT-success aa.

v9 used data[0] - 1 after skipping the count and status bytes. v10 changed this to data[0] - 2 while tightening the packet bound, which drops the final payload byte. Keep the v10 bound but restore the correct payload count.

Tested on an ASUS Eee Pad Slider SL101 with EC firmware SL101-0202. Together with the SL101 8-byte event-read fixup, the physical sliding keyboard completes atkbd initialization and works.

---
 drivers/input/serio/asus-transformer-ec-kbc.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

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

Quoted 10 lines
drivers/input/serio/asus-transformer-ec-kbc.c +6 -1
@@ -26,20 +26,26 @@
                return NOTIFY_DONE;
        else if (action & ASUSEC_AUX_MASK)
                port_idx = 1;
-       else if (action & (ASUSEC_KBC_MASK | ASUSEC_KEY_MASK))
+       else if (action & ASUSEC_OBF_MASK)
+               /*
+                * Keyboard command responses can carry only OBF, without KEY or
+                * KBC set. The original SL101 driver treated every valid non-AUX,
+                * non-SMI/SCI OBF packet as keyboard data, including PS/2 ACKs.
+                */

I have to test this on my ASUS Transformer Prime TF201 to be sure it does not break other devices. But before that happens I would like to get Dmitry's feedback regarding input patches.

Quoted 8 lines
drivers/input/serio/asus-transformer-ec-kbc.c +0 -3
                port_idx = 0;
        else
                return NOTIFY_DONE;
 
        /*
-        * The data[0] is the length of the packet including itself. The data[]
-        * buffer has to be at least 3 bytes (length + ctrl + 1 data byte) and
-        * must not exceed the EC entry size.

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

Quoted 10 lines
drivers/input/serio/asus-transformer-ec-kbc.c +5 -1
+        * data[0] is the number of bytes following the count byte: one status
+        * byte plus the payload. The SL101 EC, for example, reports keyboard
+        * reset as 03 09 fa aa (status 09, ACK fa, BAT aa). Skip the count and
+        * status bytes and forward every payload byte to serio.
         */
        if (data[0] < 2 || data[0] > ASUSEC_ENTRY_SIZE)
                return NOTIFY_BAD;
 
-       n = data[0] - 2;
+       n = data[0] - 1;

This is legit, I will adjust in v11.

Quoted 4 lines
drivers/input/serio/asus-transformer-ec-kbc.c +0 -1
        data += 2;
 
        if (port_idx == 0) {
--
#26 lore raw

v10 cover ASUS Transformer EC: SL101 keyboard event/response fixes

In reply to Svyatoslav Ryhel

Hi,

I tested the v10 ASUS Transformer EC series on a physical ASUS Eee Pad Slider SL101 while bringing up its built-in sliding keyboard.

The EC probes successfully as:

Model : ASUS-EP102-DOCK
FW version : SL101-0202
Config format : ECFG-0001
HW version : PCBA-EP102

and the KBC child creates an AT Raw Set 2 serio keyboard, but v10-style behavior does not complete atkbd initialization on the SL101.

Real-hardware tracing exposed three details:

1. The SL101 EC event window at 0x6a uses the 8-byte SMBus block reads found in ASUS's downstream driver. The generic 32-byte event read loses the keyboard command-response path on this device.

2. Keyboard command replies can be valid OBF-only packets without KEY/KBC set. Non-AUX, non-SMI/SCI OBF responses therefore need to be routed to keyboard serio0 so PS/2 ACKs reach atkbd.

3. The observed keyboard reset response is:

     03 09 fa aa

where 03 counts the following status + payload bytes, 09 is status, fa is the PS/2 ACK and aa is BAT success. v9's data[0] - 1 payload count matches this framing. v10's data[0] - 2 drops the BAT byte. The fix keeps v10's upper-bound check while restoring data[0] - 1.

With these fixes and the SL101 EC DT node at 0x19/0x1b, Linux 6.18.45 boots through RAM-only kexec and the physical sliding keyboard works.

The two patches in this fixup set are intended to be folded into v10 patches 2/7 and 3/7 respectively, rather than merged as a competing driver series.

The dependent Tegra SL101 DT patch is prepared separately and should be submitted after/with the EC binding dependency.

Hardware:
ASUS Eee Pad Slider SL101
EC model ASUS-EP102-DOCK
EC firmware SL101-0202

Validation:
- physical keyboard PASS on real SL101 hardware
- cleaned MFD and serio objects compile successfully
- cleaned SL101 DTB compiles successfully
- checkpatch: 0 errors, 0 warnings

Florian Krischer (2):
mfd: asus-transformer-ec: use 8-byte event reads on SL101
input: serio: asus-transformer-ec: fix keyboard response framing

 drivers/mfd/asus-transformer-ec.c             | 19 +++++++++++++++----
 drivers/input/serio/asus-transformer-ec-kbc.c | 16 +++++++++++-----
 2 files changed, 26 insertions(+), 9 deletions(-)

--