Skip to contentSkip to conversation

mfd: Add support for Asus Transformer embedded controller

PATCH Superseded Svyatoslav Ryhel 5 participants 25 messages Oct 13 – Oct 16

Subsystems (6)

v11 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

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

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 | 169 ++++++
 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             | 562 ++++++++++++++++++
 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       |  94 +++
 18 files changed, 1956 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 v11 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 v11 1/7] dt-bindings: embedded-controller: document ASUS Transformer EC

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 3 lines

Document embedded controller used in ASUS Transformer device series.

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=1
#3 lore raw

PATCH v11 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       | 562 ++++++++++++++++++++++++
 include/linux/mfd/asus-transformer-ec.h |  94 ++++
 4 files changed, 673 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 +562 -0

562 lines not on this page · raw message

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

94 lines not on this page · raw message

Signature · 1 line
2.53.0
#4 lore raw

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

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] mfd: bespoke parent-child accessor and global shared header - [Medium] mfd: hard-coded cell IDs…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] mfd: bespoke parent-child accessor and global shared header
- [Medium] mfd: hard-coded cell IDs instead of PLATFORM_DEVID_AUTO
--

commit b490e5f8ad65fb577857c831f5de2998a3c0d3de
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 5 lines
drivers/mfd/asus-transformer-ec.c new file +0 -0
new file mode 100644
index 0000000000000..37dcd1b77465d

[ ... ]

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

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

[Severity: Medium]
Does this introduce a bespoke parent-child accessor?

The MFD architecture guidelines strictly prohibit writing bespoke accessors or helper functions in the parent driver to pass state to child devices, as this creates tight coupling. Instead, child drivers should retrieve parent data using standard APIs like dev_get_drvdata(pdev->dev.parent).

[ ... ]

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

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"),
+};

[Severity: Medium]
Are these hard-coded cell IDs intended?

The MFD guidelines require using PLATFORM_DEVID_AUTO for automatic cell indexing to avoid sysfs naming collisions and driver load failures. Here it appears a hard-coded ID of 1 is assigned for the battery, charger, and led subdevices.

[ ... ]

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

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: Medium]
Could we pass PLATFORM_DEVID_AUTO instead of 0 for the base id here?

Passing 0 bypasses auto-indexing and violates the MFD subsystem constraints for cell identification.

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

[ ... ]

Quoted 6 lines
include/linux/mfd/asus-transformer-ec.h new file +6 -0
+/**
+ * struct asusec_core - public part shared with all cells
+ *
+ * @model: firmware version running on the EC
+ * @name: prefix associated with the EC
+ * @dockram: pointer to Dockram's i2c_client

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

Quoted 10 lines
include/linux/mfd/asus-transformer-ec.h new file +10 -0
+ * @notify_list: notify list used by cells
+ * @keyboard_mask: mask of keyboard packets
+ */
+struct asusec_core {
+	const char *model;
+	const char *name;
+	struct i2c_client *dockram;
+	struct blocking_notifier_head notify_list;
+	u8 keyboard_mask;
+};

[Severity: Medium]
Is this shared structure and header required in the global include directory?

This appears to violate the MFD API layering guidelines, which state that driver-specific header files should not be included in the global include/linux/mfd/ directory if they are only used by the parent and its immediate children. They 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 v11 2/7] mfd: Add driver for ASUS Transformer embedded controller

In reply to Svyatoslav Ryhel
kernel test robot noticed the following build warnings:

Hi Svyatoslav,

kernel test robot noticed the following build warnings:

[auto build test WARNING on dtor-input/next]
[also build test WARNING on dtor-input/for-linus sre-power-supply/for-next robh/for-next linus/master v7.3-rc7 next-20261012] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Svyatoslav-Ryhel/dt-bindings-embedded-controller-document-ASUS-Transformer-EC/20261013-203457
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
patch link:    https://lore.kernel.org/r/20261013173504.451391-3-clamor95%40gmail.com
patch subject: [PATCH v11 2/7] mfd: Add driver for ASUS Transformer embedded controller
config: csky-randconfig-1001-20261015 (https://download.01.org/0day-ci/archive/20261015/[email protected]/config)
compiler: csky-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261015/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> Warning: drivers/mfd/asus-transformer-ec.c:59 struct member 'fmode' not described in 'asus_ec_chip_info'
   Warning: drivers/mfd/asus-transformer-ec.c:59 Excess struct member 'mode' description in 'asus_ec_chip_info'
>> Warning: drivers/mfd/asus-transformer-ec.c:79 Excess struct member 'logging_disabled' description in 'asus_ec_data'
>> Warning: drivers/mfd/asus-transformer-ec.c:59 struct member 'fmode' not described in 'asus_ec_chip_info'
   Warning: drivers/mfd/asus-transformer-ec.c:59 Excess struct member 'mode' description in 'asus_ec_chip_info'
>> Warning: drivers/mfd/asus-transformer-ec.c:79 Excess struct member 'logging_disabled' description in 'asus_ec_data'

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

maintainer
#6 lore raw

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

In reply to Svyatoslav Ryhel

Hi Svyatoslav,

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

Quoted 4 lines · Svyatoslav Ryhel
drivers/mfd/asus-transformer-ec.c new file +4 -0
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/array_size.h>
+#include <linux/debugfs.h>

Unused include (left over after debugfs support was dropped).

Quoted 26 lines
drivers/mfd/asus-transformer-ec.c new file +26 -0
+/**
+ * struct asus_ec_chip_info
+ *
+ * @name: prefix associated with the EC
+ * @variant: id of programming model of EC
+ * @mode: state of Factory Mode bit in EC control register
+ * @read_size: size of block to read
+ * @keyboard_mask: mask of keyboard packets
+ */
+struct asus_ec_chip_info {
+	const char *name;
+	enum asusec_variant variant;
+	enum asusec_mode fmode;
+	u8 read_size;
+	u8 keyboard_mask;
+};
+
+/**
+ * struct asus_ec_data
+ *
+ * @ec: public part shared with all cells (must be first)
+ * @ecreq_lock: prevents simultaneous access to EC
+ * @ecreq_gpio: EC request GPIO
+ * @client: pointer to EC's i2c_client
+ * @info: pointer to EC's version description
+ * @ec_buf: buffer for EC read

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

Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+ * @logging_disabled: flag disabling logging on reset events
+ */
+struct asus_ec_data {
+	struct asusec_core ec;
+	struct mutex ecreq_lock;
+	struct gpio_desc *ecreq_gpio;
+	struct i2c_client *client;
+	const struct asus_ec_chip_info *info;
+	u8 ec_buf[ASUSEC_ENTRY_BUFSIZE];
+};

scripts/kernel-doc warns on these two structs:
- In struct asus_ec_chip_info, the kerneldoc says @mode while the field is named fmode.
- In struct asus_ec_data, @logging_disabled no longer exists.

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

...

Quoted 16 lines
drivers/mfd/asus-transformer-ec.c new file +16 -0
+static struct i2c_client *devm_asus_dockram_get(struct device *dev)
+{
+	struct i2c_client *parent = to_i2c_client(dev);
+	struct i2c_client *dockram;
+	struct dockram_ec_data *ddata;
+	int ret;
+
+	dockram = i2c_new_ancillary_device(parent, "dockram",
+					   parent->addr + ASUSEC_DOCKRAM_OFFSET);
+	if (IS_ERR(dockram))
+		return dockram;
+
+	ret = devm_add_action_or_reset(dev, asus_ec_release_dockram_dev,
+				       dockram);
+	if (ret)
+		return ERR_PTR(ret);

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

Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+
+	ddata = devm_kzalloc(&dockram->dev, sizeof(*ddata), GFP_KERNEL);
+	if (!ddata)
+		return ERR_PTR(-ENOMEM);
+
+	i2c_set_clientdata(dockram, ddata);
+	mutex_init(&ddata->ctl_lock);
+
+	return dockram;
+}

Attaching ddata to &dockram->dev via devm_kzalloc() and i2c_set_clientdata() is fragile because dockram is bound to the I2C dummy driver. If the dummy driver is unbound from dockram via sysfs, the driver core frees &dockram->dev devres allocations and clears dockram's driver_data to NULL, so the next call to asus_dockram_access_ctl() will dereference NULL.

Instead of allocating a separate struct dockram_ec_data on the ancillary i2c_client, could ctl_lock and ctl_buf live in struct asus_ec_data (or struct asusec_core) and have asus_dockram_access_ctl() take struct asusec_core *ec?

Thanks.

Signature · 1 line
Dmitry
#7 lore raw

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

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

Quoted 11 lines

Hi Svyatoslav,

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

Quoted 4 lines · Svyatoslav Ryhel
drivers/mfd/asus-transformer-ec.c new file +4 -0
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/array_size.h>
+#include <linux/debugfs.h>

Unused include (left over after debugfs support was dropped).

Noted

Quoted 33 lines
Quoted 33 lines
drivers/mfd/asus-transformer-ec.c new file +33 -0
+/**
+ * struct asus_ec_chip_info
+ *
+ * @name: prefix associated with the EC
+ * @variant: id of programming model of EC
+ * @mode: state of Factory Mode bit in EC control register
+ * @read_size: size of block to read
+ * @keyboard_mask: mask of keyboard packets
+ */
+struct asus_ec_chip_info {
+     const char *name;
+     enum asusec_variant variant;
+     enum asusec_mode fmode;
+     u8 read_size;
+     u8 keyboard_mask;
+};
+
+/**
+ * struct asus_ec_data
+ *
+ * @ec: public part shared with all cells (must be first)
+ * @ecreq_lock: prevents simultaneous access to EC
+ * @ecreq_gpio: EC request GPIO
+ * @client: pointer to EC's i2c_client
+ * @info: pointer to EC's version description
+ * @ec_buf: buffer for EC read
+ * @logging_disabled: flag disabling logging on reset events
+ */
+struct asus_ec_data {
+     struct asusec_core ec;
+     struct mutex ecreq_lock;
+     struct gpio_desc *ecreq_gpio;
+     struct i2c_client *client;
Quoted 9 lines

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

Quoted 3 lines
drivers/mfd/asus-transformer-ec.c new file +3 -0
+     const struct asus_ec_chip_info *info;
+     u8 ec_buf[ASUSEC_ENTRY_BUFSIZE];
+};

scripts/kernel-doc warns on these two structs:
- In struct asus_ec_chip_info, the kerneldoc says @mode while the field is named fmode.
- In struct asus_ec_data, @logging_disabled no longer exists.

Noted

Quoted 40 lines
Quoted 5 lines
drivers/mfd/asus-transformer-ec.c new file +5 -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;

...

Quoted 16 lines
drivers/mfd/asus-transformer-ec.c new file +16 -0
+static struct i2c_client *devm_asus_dockram_get(struct device *dev)
+{
+     struct i2c_client *parent = to_i2c_client(dev);
+     struct i2c_client *dockram;
+     struct dockram_ec_data *ddata;
+     int ret;
+
+     dockram = i2c_new_ancillary_device(parent, "dockram",
+                                        parent->addr + ASUSEC_DOCKRAM_OFFSET);
+     if (IS_ERR(dockram))
+             return dockram;
+
+     ret = devm_add_action_or_reset(dev, asus_ec_release_dockram_dev,
+                                    dockram);
+     if (ret)
+             return ERR_PTR(ret);

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

Quoted 10 lines
drivers/mfd/asus-transformer-ec.c new file +10 -0
+
+     ddata = devm_kzalloc(&dockram->dev, sizeof(*ddata), GFP_KERNEL);
+     if (!ddata)
+             return ERR_PTR(-ENOMEM);
+
+     i2c_set_clientdata(dockram, ddata);
+     mutex_init(&ddata->ctl_lock);
+
+     return dockram;
+}

Attaching ddata to &dockram->dev via devm_kzalloc() and i2c_set_clientdata() is fragile because dockram is bound to the I2C dummy driver. If the dummy driver is unbound from dockram via sysfs, the driver core frees &dockram->dev devres allocations and clears dockram's driver_data to NULL, so the next call to asus_dockram_access_ctl() will dereference NULL.

Quoted 7 lines

Instead of allocating a separate struct dockram_ec_data on the ancillary i2c_client, could ctl_lock and ctl_buf live in struct asus_ec_data (or struct asusec_core) and have asus_dockram_access_ctl() take struct asusec_core *ec?

Thanks.

I did this since dockram and ec can be accessed and work independently, hence separate locks and buffers. I would like this to remain as it is, but you have a point here. Adding check if dockram client is not NULL should resolve possible issues with asus_dockram_access_ctl calls.

Quoted 2 lines

--
Dmitry

#8 lore raw

PATCH v11 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 | 169 ++++++++++++++++++
 3 files changed, 185 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 +169 -0

169 lines not on this page · raw message

Signature · 1 line
2.53.0
#9 lore raw

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

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

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=3
#10 lore raw

PATCH v11 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 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 +310 -0

310 lines not on this page · raw message

Signature · 1 line
2.53.0
#11 lore raw

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

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

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

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

In reply to Svyatoslav Ryhel

Hi Svyatoslav,

Quoted 5 lines · Svyatoslav Ryhel

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.

I still think registering a global input_handler just to observe Right Alt state on the dock keyboard is heavier than necessary, and because the handler is a passive observer rather than a filter, pressing AltGr+ScreenLock or AltGr+F1..F12 still leaks the KEY_RIGHTALT press and release events from atkbd to userspace alongside the mode switch or media key event.

Since asus-transformer-ec-kbc already inspects and remaps 0xe0-prefixed scancodes on the keyboard port before passing them to serio, we can track and delay AltGr (0xe0 0x11) there when the extension keys driver is active, and coordinate with asus-transformer-ec-keys via struct asusec_core:

- When AltGr is pressed on the dock keyboard, asus-transformer-ec-kbc delays emitting the 0xe0 0x11 make sequence and sets ec->right_alt_pressed.
- If an extension key is pressed while right_alt_pressed is set, asus-transformer-ec-keys sets ec->special_combo_triggered (either toggling special_key_mode on ScreenLock or reporting the shifted key for other top-row keys), and asus-transformer-ec-kbc suppresses both the delayed AltGr make and the subsequent AltGr break (0xe0 0xf0 0x11).
- If any regular key make event arrives on the primary keyboard port first, or if AltGr is released without triggering an extension key combo, asus-transformer-ec-kbc flushes the delayed 0xe0 0x11 make sequence before forwarding the event.

This avoids registering an input_handler altogether and drops about 100 lines of boilerplate from asus-transformer-ec-keys.c.

What do you think about folding the change below into patches 2, 3, and 4?

(Also, a minor typo in patch 3/7 in drivers/input/serio/Kconfig:
"Asus Transformed's Mobile Dock" -> "Asus Transformer's Mobile Dock".)

drivers/input/keyboard/asus-transformer-ec-keys.c +14 -112
index 8e83b27ce60e..ec72c38d7653 100644
@@ -7,7 +7,6 @@
 #include <linux/mfd/asus-transformer-ec.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
 
 #define ASUSEC_EXT_KEY_CODES		0x20
 
@@ -15,74 +14,8 @@ struct asus_ec_keys_data {
 	struct notifier_block nb;
 	struct asusec_core *ec;
 	struct input_dev *xidev;
-	struct input_handler input_handler;
-	unsigned short keymap[ASUSEC_EXT_KEY_CODES * 2];
-	const char *kbc_phys;
-	bool special_key_pressed;
 	bool special_key_mode;
-};
-
-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)
-		WRITE_ONCE(priv->special_key_pressed, !!value);
-}
-
-static int asus_ec_input_connect(struct input_handler *handler,
-				 struct input_dev *dev,
-				 const struct input_device_id *id)
-{
-	struct asus_ec_keys_data *priv = handler->private;
-	struct input_handle *handle;
-	int error;
-
-	if (!dev->phys || !strstr(dev->phys, priv->kbc_phys))
-		return -ENODEV;
-
-	handle = kzalloc_obj(*handle);
-	if (!handle)
-		return -ENOMEM;
-
-	handle->dev = dev;
-	handle->handler = handler;
-	handle->name = handler->name;
-
-	error = input_register_handle(handle);
-	if (error)
-		goto err_free_handle;
-
-	error = input_open_device(handle);
-	if (error)
-		goto err_unregister_handle;
-
-	return 0;
-
- err_unregister_handle:
-	input_unregister_handle(handle);
- err_free_handle:
-	kfree(handle);
-
-	return error;
-}
-
-static void asus_ec_input_disconnect(struct input_handle *handle)
-{
-	input_close_device(handle);
-	input_unregister_handle(handle);
-	kfree(handle);
-}
-
-static const struct input_device_id asus_ec_input_ids[] = {
-	{
-		.flags = INPUT_DEVICE_ID_MATCH_EVBIT,
-		.evbit = { BIT_MASK(EV_KEY) },
-	},
-	{ }
+	unsigned short keymap[ASUSEC_EXT_KEY_CODES * 2];
 };
 
 static const unsigned short asus_ec_dock_ext_keys[] = {
@@ -138,17 +71,21 @@ static int asus_ec_keys_process_key(struct input_dev *dev, u8 code)
 	if (code == 0)
 		return NOTIFY_DONE;
 
-	/* Flip special key mode state when pressing SCREEN LOCK + R ALT */
-	if (READ_ONCE(priv->special_key_pressed) && code == 1) {
-		priv->special_key_mode = !priv->special_key_mode;
-		return NOTIFY_DONE;
+	if (priv->ec->right_alt_pressed) {
+		priv->ec->special_combo_triggered = true;
+
+		/* Flip special key mode state when pressing SCREEN LOCK + R ALT */
+		if (code == 1) {
+			priv->special_key_mode = !priv->special_key_mode;
+			return NOTIFY_OK;
+		}
 	}
 
 	/*
 	 * Relocate code to second "page" if pressed state XOR's mode state
 	 * This way special key will invert the current mode
 	 */
-	if (priv->special_key_mode ^ READ_ONCE(priv->special_key_pressed))
+	if (priv->special_key_mode ^ priv->ec->right_alt_pressed)
 		code += ASUSEC_EXT_KEY_CODES;
 
 	if (code < dev->keycodemax) {
@@ -207,37 +144,6 @@ static void asus_ec_keys_setup_keymap(struct asus_ec_keys_data *priv)
 	}
 }
 
-static int asus_ec_keys_register_handler(struct device *dev,
-					 struct asus_ec_keys_data *priv)
-{
-	struct i2c_client *parent = to_i2c_client(dev->parent);
-	int error;
-
-	priv->input_handler.event = asus_ec_input_event;
-	priv->input_handler.connect = asus_ec_input_connect;
-	priv->input_handler.disconnect = asus_ec_input_disconnect;
-	priv->input_handler.id_table = asus_ec_input_ids;
-	priv->input_handler.passive_observer = true;
-	priv->input_handler.private = priv;
-	priv->input_handler.name = devm_kasprintf(dev, GFP_KERNEL,
-						  "%s-media-handler",
-						  priv->ec->name);
-	if (!priv->input_handler.name)
-		return -ENOMEM;
-
-	priv->kbc_phys = devm_kasprintf(dev, GFP_KERNEL, "i2c-%u-%04x/serio0",
-					i2c_adapter_id(parent->adapter),
-					parent->addr);
-	if (!priv->kbc_phys)
-		return -ENOMEM;
-
-	error = input_register_handler(&priv->input_handler);
-	if (error)
-		return error;
-
-	return 0;
-}
-
 static int asus_ec_keys_probe(struct platform_device *pdev)
 {
 	struct i2c_client *parent = to_i2c_client(pdev->dev.parent);
@@ -273,17 +179,13 @@ static int asus_ec_keys_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, error,
 				     "failed to register extension keys\n");
 
-	error = asus_ec_keys_register_handler(dev, priv);
-	if (error)
-		return error;
-
 	priv->nb.notifier_call = asus_ec_keys_notify;
 
 	error = blocking_notifier_chain_register(&ec->notify_list, &priv->nb);
-	if (error) {
-		input_unregister_handler(&priv->input_handler);
+	if (error)
 		return error;
-	}
+
+	ec->ext_keys_enabled = true;
 
 	return 0;
 }
@@ -293,8 +195,8 @@ 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);
-	input_unregister_handler(&priv->input_handler);
 }
 
 static struct platform_driver asus_ec_keys_driver = {
drivers/input/serio/asus-transformer-ec-kbc.c +99 -4

139 lines not on this page · raw message

include/linux/mfd/asus-transformer-ec.h +6 -0
index d09d3b70171e..fda6fb08cc41 100644
@@ -19,6 +19,9 @@ struct i2c_client;
  * @dockram: pointer to Dockram's i2c_client
  * @notify_list: notify list used by cells
  * @keyboard_mask: mask of keyboard packets
+ * @ext_keys_enabled: true if extension keys driver is active
+ * @right_alt_pressed: state of Right Alt (AltGr) key
+ * @special_combo_triggered: true if AltGr + extension key combo was triggered
  */
 struct asusec_core {
 	const char *model;
@@ -26,6 +29,9 @@ struct asusec_core {
 	struct i2c_client *dockram;
 	struct blocking_notifier_head notify_list;
 	u8 keyboard_mask;
+	bool ext_keys_enabled;
+	bool right_alt_pressed;
+	bool special_combo_triggered;
 };
 
 /* interrupt sources */

Thanks.

Signature · 1 line
Dmitry
#13 lore raw

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

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

Quoted 399 lines

Hi Svyatoslav,

Quoted 5 lines · Svyatoslav Ryhel

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.

I still think registering a global input_handler just to observe Right Alt state on the dock keyboard is heavier than necessary, and because the handler is a passive observer rather than a filter, pressing AltGr+ScreenLock or AltGr+F1..F12 still leaks the KEY_RIGHTALT press and release events from atkbd to userspace alongside the mode switch or media key event.

Since asus-transformer-ec-kbc already inspects and remaps 0xe0-prefixed scancodes on the keyboard port before passing them to serio, we can track and delay AltGr (0xe0 0x11) there when the extension keys driver is active, and coordinate with asus-transformer-ec-keys via struct asusec_core:

- When AltGr is pressed on the dock keyboard, asus-transformer-ec-kbc delays emitting the 0xe0 0x11 make sequence and sets ec->right_alt_pressed.
- If an extension key is pressed while right_alt_pressed is set, asus-transformer-ec-keys sets ec->special_combo_triggered (either toggling special_key_mode on ScreenLock or reporting the shifted key for other top-row keys), and asus-transformer-ec-kbc suppresses both the delayed AltGr make and the subsequent AltGr break (0xe0 0xf0 0x11).
- If any regular key make event arrives on the primary keyboard port first, or if AltGr is released without triggering an extension key combo, asus-transformer-ec-kbc flushes the delayed 0xe0 0x11 make sequence before forwarding the event.

This avoids registering an input_handler altogether and drops about 100 lines of boilerplate from asus-transformer-ec-keys.c.

What do you think about folding the change below into patches 2, 3, and 4?

(Also, a minor typo in patch 3/7 in drivers/input/serio/Kconfig:
"Asus Transformed's Mobile Dock" -> "Asus Transformer's Mobile Dock".)

drivers/input/keyboard/asus-transformer-ec-keys.c +14 -112
index 8e83b27ce60e..ec72c38d7653 100644
@@ -7,7 +7,6 @@
 #include <linux/mfd/asus-transformer-ec.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
 
 #define ASUSEC_EXT_KEY_CODES           0x20
 
@@ -15,74 +14,8 @@ struct asus_ec_keys_data {
        struct notifier_block nb;
        struct asusec_core *ec;
        struct input_dev *xidev;
-       struct input_handler input_handler;
-       unsigned short keymap[ASUSEC_EXT_KEY_CODES * 2];
-       const char *kbc_phys;
-       bool special_key_pressed;
        bool special_key_mode;
-};
-
-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)
-               WRITE_ONCE(priv->special_key_pressed, !!value);
-}
-
-static int asus_ec_input_connect(struct input_handler *handler,
-                                struct input_dev *dev,
-                                const struct input_device_id *id)
-{
-       struct asus_ec_keys_data *priv = handler->private;
-       struct input_handle *handle;
-       int error;
-
-       if (!dev->phys || !strstr(dev->phys, priv->kbc_phys))
-               return -ENODEV;
-
-       handle = kzalloc_obj(*handle);
-       if (!handle)
-               return -ENOMEM;
-
-       handle->dev = dev;
-       handle->handler = handler;
-       handle->name = handler->name;
-
-       error = input_register_handle(handle);
-       if (error)
-               goto err_free_handle;
-
-       error = input_open_device(handle);
-       if (error)
-               goto err_unregister_handle;
-
-       return 0;
-
- err_unregister_handle:
-       input_unregister_handle(handle);
- err_free_handle:
-       kfree(handle);
-
-       return error;
-}
-
-static void asus_ec_input_disconnect(struct input_handle *handle)
-{
-       input_close_device(handle);
-       input_unregister_handle(handle);
-       kfree(handle);
-}
-
-static const struct input_device_id asus_ec_input_ids[] = {
-       {
-               .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
-               .evbit = { BIT_MASK(EV_KEY) },
-       },
-       { }
+       unsigned short keymap[ASUSEC_EXT_KEY_CODES * 2];
 };
 
 static const unsigned short asus_ec_dock_ext_keys[] = {
@@ -138,17 +71,21 @@ static int asus_ec_keys_process_key(struct input_dev *dev, u8 code)
        if (code == 0)
                return NOTIFY_DONE;
 
-       /* Flip special key mode state when pressing SCREEN LOCK + R ALT */
-       if (READ_ONCE(priv->special_key_pressed) && code == 1) {
-               priv->special_key_mode = !priv->special_key_mode;
-               return NOTIFY_DONE;
+       if (priv->ec->right_alt_pressed) {
+               priv->ec->special_combo_triggered = true;
+
+               /* Flip special key mode state when pressing SCREEN LOCK + R ALT */
+               if (code == 1) {
+                       priv->special_key_mode = !priv->special_key_mode;
+                       return NOTIFY_OK;
+               }
        }
 
        /*
         * Relocate code to second "page" if pressed state XOR's mode state
         * This way special key will invert the current mode
         */
-       if (priv->special_key_mode ^ READ_ONCE(priv->special_key_pressed))
+       if (priv->special_key_mode ^ priv->ec->right_alt_pressed)
                code += ASUSEC_EXT_KEY_CODES;
 
        if (code < dev->keycodemax) {
@@ -207,37 +144,6 @@ static void asus_ec_keys_setup_keymap(struct asus_ec_keys_data *priv)
        }
 }
 
-static int asus_ec_keys_register_handler(struct device *dev,
-                                        struct asus_ec_keys_data *priv)
-{
-       struct i2c_client *parent = to_i2c_client(dev->parent);
-       int error;
-
-       priv->input_handler.event = asus_ec_input_event;
-       priv->input_handler.connect = asus_ec_input_connect;
-       priv->input_handler.disconnect = asus_ec_input_disconnect;
-       priv->input_handler.id_table = asus_ec_input_ids;
-       priv->input_handler.passive_observer = true;
-       priv->input_handler.private = priv;
-       priv->input_handler.name = devm_kasprintf(dev, GFP_KERNEL,
-                                                 "%s-media-handler",
-                                                 priv->ec->name);
-       if (!priv->input_handler.name)
-               return -ENOMEM;
-
-       priv->kbc_phys = devm_kasprintf(dev, GFP_KERNEL, "i2c-%u-%04x/serio0",
-                                       i2c_adapter_id(parent->adapter),
-                                       parent->addr);
-       if (!priv->kbc_phys)
-               return -ENOMEM;
-
-       error = input_register_handler(&priv->input_handler);
-       if (error)
-               return error;
-
-       return 0;
-}
-
 static int asus_ec_keys_probe(struct platform_device *pdev)
 {
        struct i2c_client *parent = to_i2c_client(pdev->dev.parent);
@@ -273,17 +179,13 @@ static int asus_ec_keys_probe(struct platform_device *pdev)
                return dev_err_probe(dev, error,
                                     "failed to register extension keys\n");
 
-       error = asus_ec_keys_register_handler(dev, priv);
-       if (error)
-               return error;
-
        priv->nb.notifier_call = asus_ec_keys_notify;
 
        error = blocking_notifier_chain_register(&ec->notify_list, &priv->nb);
-       if (error) {
-               input_unregister_handler(&priv->input_handler);
+       if (error)
                return error;
-       }
+
+       ec->ext_keys_enabled = true;
 
        return 0;
 }
@@ -293,8 +195,8 @@ 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);
-       input_unregister_handler(&priv->input_handler);
 }
 
 static struct platform_driver asus_ec_keys_driver = {
drivers/input/serio/asus-transformer-ec-kbc.c +99 -4
index 62ffaf4d4371..0842158f13da 100644
@@ -13,8 +13,85 @@ struct asus_ec_kbc_data {
        struct asusec_core *ec;
        struct i2c_client *parent;
        struct serio *sdev[2];
+       bool altgr_delayed;
+       bool altgr_suppressed;
 };
 
+static bool asus_ec_kbc_altgr_active(struct asus_ec_kbc_data *priv)
+{
+       return IS_ENABLED(CONFIG_KEYBOARD_ASUS_TRANSFORMER_EC) &&
+              (priv->ec->ext_keys_enabled ||
+               priv->altgr_delayed || priv->altgr_suppressed);
+}
+
+static void asus_ec_kbc_reset_altgr(struct asus_ec_kbc_data *priv)
+{
+       if (!IS_ENABLED(CONFIG_KEYBOARD_ASUS_TRANSFORMER_EC))
+               return;
+
+       priv->ec->right_alt_pressed = false;
+       priv->ec->special_combo_triggered = false;
+       priv->altgr_delayed = false;
+       priv->altgr_suppressed = false;
+}
+
+static void asus_ec_kbc_sync_altgr_combo(struct asus_ec_kbc_data *priv)
+{
+       if (priv->ec->special_combo_triggered) {
+               priv->ec->special_combo_triggered = false;
+               if (priv->altgr_delayed) {
+                       priv->altgr_delayed = false;
+                       priv->altgr_suppressed = true;
+               }
+       }
+}
+
+static void asus_ec_kbc_flush_altgr(struct asus_ec_kbc_data *priv)
+{
+       if (!asus_ec_kbc_altgr_active(priv))
+               return;
+
+       asus_ec_kbc_sync_altgr_combo(priv);
+
+       if (!priv->altgr_delayed)
+               return;
+
+       serio_interrupt(priv->sdev[0], 0xe0, 0);
+       serio_interrupt(priv->sdev[0], 0x11, 0);
+
+       priv->altgr_delayed = false;
+}
+
+static bool asus_ec_kbc_handle_altgr(struct asus_ec_kbc_data *priv, bool is_release)
+{
+       bool suppressed;
+
+       if (!asus_ec_kbc_altgr_active(priv)) {
+               asus_ec_kbc_reset_altgr(priv);
+               return false;
+       }
+
+       asus_ec_kbc_sync_altgr_combo(priv);
+
+       if (!is_release) {
+               if (!priv->ec->right_alt_pressed) {
+                       asus_ec_kbc_reset_altgr(priv);
+                       priv->ec->right_alt_pressed = true;
+                       priv->altgr_delayed = true;
+                       return true;
+               }
+
+               return priv->altgr_delayed || priv->altgr_suppressed;
+       }
+
+       suppressed = priv->altgr_suppressed;
+       if (!suppressed)
+               asus_ec_kbc_flush_altgr(priv);
+
+       asus_ec_kbc_reset_altgr(priv);
+       return suppressed;
+}
+
 static int asus_ec_kbc_notify(struct notifier_block *nb,
                              unsigned long action, void *data_)
 {
@@ -22,14 +99,18 @@ static int asus_ec_kbc_notify(struct notifier_block *nb,
        unsigned int port_idx, n;
        u8 *data = data_;
 
-       if (action & (ASUSEC_SMI_MASK | ASUSEC_SCI_MASK))
+       if (action & (ASUSEC_SMI_MASK | ASUSEC_SCI_MASK)) {
+               if (action == ASUSEC_SMI_ACTION(HANDSHAKE) ||
+                   action == ASUSEC_SMI_ACTION(RESET))
+                       asus_ec_kbc_reset_altgr(priv);
                return NOTIFY_DONE;
-       else if (action & ASUSEC_AUX_MASK)
+       } else if (action & ASUSEC_AUX_MASK) {
                port_idx = 1;
-       else if (action & priv->ec->keyboard_mask)
+       } else if (action & priv->ec->keyboard_mask) {
                port_idx = 0;
-       else
+       } else {
                return NOTIFY_DONE;
+       }
 
        /*
         * The data[0] is the number of bytes following the count byte: one
@@ -46,6 +127,7 @@ static int asus_ec_kbc_notify(struct notifier_block *nb,
        if (port_idx == 0) {
                /*
                 * Remap keyboard key codes to match AT layout:
+                * ALTGR:  RIGHT-ALT  [E0 11] -> delayed / suppressed
                 * SEARCH: RIGHT-META [E0 27] -> LEFT-ALT   [11]
                 * MENU:   COMPOSE    [E0 2F] -> RIGHT-META [E0 27]
                 */
@@ -53,6 +135,10 @@ static int asus_ec_kbc_notify(struct notifier_block *nb,
                        u8 *keycode = &data[n - 1];
 
                        switch (*keycode) {
+                       case 0x11:
+                               if (asus_ec_kbc_handle_altgr(priv, n == 3))
+                                       return NOTIFY_OK;
+                               break;
                        case 0x27:
                                *keycode = 0x11;
                                ++data;
@@ -63,6 +149,15 @@ static int asus_ec_kbc_notify(struct notifier_block *nb,
                                break;
                        }
                }
+
+               /*
+                * Only flush delayed AltGr on key make events, ignoring
+                * key break codes and PS/2 command responses (ACK, BAT, etc.).
+                */
+               if ((n == 2 && data[0] == 0xe0) ||
+                   (n == 1 && data[0] > 0 && data[0] < 0x84) ||
+                   data[0] == 0xe1)
+                       asus_ec_kbc_flush_altgr(priv);
        }
 
        while (n--)
include/linux/mfd/asus-transformer-ec.h +6 -0
index d09d3b70171e..fda6fb08cc41 100644
@@ -19,6 +19,9 @@ struct i2c_client;
  * @dockram: pointer to Dockram's i2c_client
  * @notify_list: notify list used by cells
  * @keyboard_mask: mask of keyboard packets
+ * @ext_keys_enabled: true if extension keys driver is active
+ * @right_alt_pressed: state of Right Alt (AltGr) key
+ * @special_combo_triggered: true if AltGr + extension key combo was triggered
  */
 struct asusec_core {
        const char *model;
@@ -26,6 +29,9 @@ struct asusec_core {
        struct i2c_client *dockram;
        struct blocking_notifier_head notify_list;
        u8 keyboard_mask;
+       bool ext_keys_enabled;
+       bool right_alt_pressed;
+       bool special_combo_triggered;
 };
 
 /* interrupt sources */
Quoted 4 lines

Thanks.

--
Dmitry

This looks very promising. Thank you for taking time and modelling this code. I will test it thoroughly and if all goes well, incorporate it into v12. If you want me to add any of your credentials let me know or you can add them later on while v12 review.

#14 lore raw

PATCH v11 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
#15 lore raw

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

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Low] leds: Commit message prefix violates naming convention - [Low] mfd: Driver-specific header placed…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] leds: Commit message prefix violates naming convention
- [Low] mfd: Driver-specific header placed in global include/linux/mfd/
--

commit 6dfd67b7a2e641ea71f3bcae79bf5a863c4f809d
Author: Michał Mirosław <[email protected]>

leds: Add driver for ASUS Transformer LEDs

This commit adds a driver for the charging indicator LEDs on the Asus Transformer pad and dock. It registers amber and green LEDs using the asus-transformer-ec MFD core.

Quoted 1 line

leds: Add driver for ASUS Transformer LEDs

[Severity: Low]
This isn't a bug, but does the commit subject omit the mandatory driver name segment? The LED subsystem guidelines recommend the commit message prefix to follow the format "leds: <Driver>: <Capitalized description>".

Could this be updated to something like "leds: asus-transformer-ec: Add driver for ASUS Transformer LEDs" for better git history categorization?

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

Quoted 10 lines
drivers/leds/leds-asus-transformer-ec.c new file +5 -0
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>

[Severity: Low]
Is this driver-specific header globally exposed in include/linux/mfd/?

The MFD subsystem guidelines suggest keeping driver-specific header files local to drivers/mfd/ if they are only used by the parent and its immediate children, rather than placing them in the global include/linux/mfd/ directory.

Would it be possible to move asus-transformer-ec.h out of the global include path?

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

PATCH v11 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
#17 lore raw

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

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

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

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

In reply to Svyatoslav Ryhel

Hi Svyatoslav,

Quoted 20 lines · Svyatoslav Ryhel
drivers/power/supply/asus-transformer-ec-battery.c new file +20 -0
+static int asus_ec_battery_get_property(struct power_supply *psy,
+					enum power_supply_property psp,
+					union power_supply_propval *val)
+{
+	struct asus_ec_battery_data *priv = power_supply_get_drvdata(psy);
+	int ret;
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_PRESENT:
+		val->intval = 1;
+		break;
+
+	default:
+		ret = asus_ec_battery_get_value(priv, psp);
+		if (ret < 0)
+			return ret;
+
+		val->intval = (s16)ret;
+
+		switch (psp) {

...

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

Quoted 4 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +4 -0
+		case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
+		case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
+			val->intval *= 60;
+			break;

asus_ec_battery_get_value() returns a u16 (via get_unaligned_le16()), and unconditionally casting it with (s16)ret sign-extends unsigned 16-bit properties >= 0x8000 into negative values.

In particular, when the battery is not discharging or not charging, TIME_TO_EMPTY_NOW / TIME_TO_FULL_NOW report 0xffff, which (s16)ret turns into -1 and then -60 seconds instead of an unsigned value (or -ENODATA). Should only signed properties (like POWER_SUPPLY_PROP_CURRENT_NOW) be cast to s16?

Thanks.

Signature · 1 line
Dmitry
#19 lore raw

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

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

Quoted 34 lines

Hi Svyatoslav,

Quoted 20 lines · Svyatoslav Ryhel
drivers/power/supply/asus-transformer-ec-battery.c new file +20 -0
+static int asus_ec_battery_get_property(struct power_supply *psy,
+                                     enum power_supply_property psp,
+                                     union power_supply_propval *val)
+{
+     struct asus_ec_battery_data *priv = power_supply_get_drvdata(psy);
+     int ret;
+
+     switch (psp) {
+     case POWER_SUPPLY_PROP_PRESENT:
+             val->intval = 1;
+             break;
+
+     default:
+             ret = asus_ec_battery_get_value(priv, psp);
+             if (ret < 0)
+                     return ret;
+
+             val->intval = (s16)ret;
+
+             switch (psp) {

...

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

Quoted 4 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +4 -0
+             case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
+             case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
+                     val->intval *= 60;
+                     break;

asus_ec_battery_get_value() returns a u16 (via get_unaligned_le16()), and unconditionally casting it with (s16)ret sign-extends unsigned 16-bit properties >= 0x8000 into negative values.

Quoted 8 lines

In particular, when the battery is not discharging or not charging, TIME_TO_EMPTY_NOW / TIME_TO_FULL_NOW report 0xffff, which (s16)ret turns into -1 and then -60 seconds instead of an unsigned value (or -ENODATA). Should only signed properties (like POWER_SUPPLY_PROP_CURRENT_NOW) be cast to s16?

Thanks.

You have a point. I assume that using val->intval = ret * 60 should be acceptable.

Quoted 2 lines

--
Dmitry

#20 lore raw

Re: [PATCH v11 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 91

Quoted 6 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +6 -0
+};
+
+static int asus_ec_battery_get_value(struct asus_ec_battery_data *priv,
+				     enum power_supply_property psp)
+{
+	int ret, offs;

…

The referenced array provides unsigned integers.
Would you like to specify a more appropriate data type for the corresponding variable?

Regards,
Markus

#21 lore raw

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

чт, 15 жовт. 2026 р. о 21:06 Markus Elfring <[email protected]> пише:

Quoted 16 lines

…

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,

…

Quoted 6 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +6 -0
+};
+
+static int asus_ec_battery_get_value(struct asus_ec_battery_data *priv,
+                                  enum power_supply_property psp)
+{
+     int ret, offs;

…

Quoted 3 lines

The referenced array provides unsigned integers.
Would you like to specify a more appropriate data type for the corresponding variable?

This is a nitpick, it does not affect anything.

Quoted 2 lines

Regards,
Markus

#22 lore raw

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

Quoted 15 lines
Quoted 15 lines

…

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,

…

Quoted 6 lines
drivers/power/supply/asus-transformer-ec-battery.c new file +6 -0
+};
+
+static int asus_ec_battery_get_value(struct asus_ec_battery_data *priv,
+                                  enum power_supply_property psp)
+{
+     int ret, offs;

…

Quoted 4 lines
Quoted 2 lines

The referenced array provides unsigned integers.
Would you like to specify a more appropriate data type for the corresponding variable?

This is a nitpick, it does not affect anything.

Will consistent data type specifications be preferred in subsequent software revisions?

Regards,
Markus

#23 lore raw

PATCH v11 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
#24 lore raw

Re: [PATCH v11 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