Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D01E347BD4 for ; Mon, 23 Feb 2026 06:31:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771828296; cv=none; b=UCM3mGW3YRyXdVWCxY0MQbuPUwRbq2p60qxDyBCMoNgsbDOZH5yzeEtJSpPBvw8FDM4gmUtHNzzh4tmWKwK9gAFisGIYbw41W+fnFswh4zdgwvrX7cKouY+BbFOYrO5YcSgSloeX1rUg/M4mErfdWQ31SCPjKQN7XWMS3I6Jqbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771828296; c=relaxed/simple; bh=wRZV9Ps39JOuLtDKFdDXqC3etMqsa7dT+wwhBC/u2Oc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KC4VdlMvGY/y0WEtO3Nlfe/RSvxE2ba+17BA52XE4dMA2sW7nPtnr3sfojnzLHgHsoo+TVY3NvsuA1az9qE7JWMsnQv62Muz2pX7YhJpYRQy+L1xcC+QVuevPiYQ2nwiZUsEsIgaXzWdHsAz5Uol+d1nKnTJx67eV+lqoDv96Ck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=W7kFTZzK; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W7kFTZzK" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-59e699310a8so4752070e87.1 for ; Sun, 22 Feb 2026 22:31:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771828291; x=1772433091; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wHqDc5z+QKkptNzmurjq8jE/aXl1U/uREsq1MT0dnbk=; b=W7kFTZzKh2U+TfYJDR2AMjnOCEsIRZYi0vvtP8+9tCwMkAS38Lx4bWv11LxnbjXkxK s9ziIgNCfUZEmJ6G766RvHtxHVeYCRNAuroIh4UwrHLhZdKB8d9Mt0EKuYCuiU+qzzHT XFI2VPGxq68c/vGhXIt3opIfyAcLlnIGZMeYsW5gCjFE+mtYHhoiuq0jlOPYkGoE0ooO ml+ZFCw7e4xhaeC1rkXeEp3MSM0QeHvFBaALMg3r89dMDZvFerVbxAWB3io72epSyNnK aMXSMS3aHqbdi7FQQaPaw9FygLWipD4xCz29kCsovjlfxWTvtpSDgNrikVp8hDdICqZ0 t/bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771828291; x=1772433091; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wHqDc5z+QKkptNzmurjq8jE/aXl1U/uREsq1MT0dnbk=; b=dCSL9chE3Wbn8M9OK9SxJWjf2QKSJIIeSHYzwat075ad3HpVZLbZ/9fsAeCbZ6+1K8 hmNvaCKmtbkv8ZjOvPDI01EDIJCNohn1xZF6tWKxhQRym+T8whXryWRtqlfAAtdMLUFV oKbUzIk8ECvRjv4QNR3O+kCphnIv7Myoi/dC4yJ2njG+Zq7oxizxUSsvUQ4G4Dp9b43E GochbbCrsEIWmViWYlDyEmujyy4hy2H6NX+rlN2XQQ3vHJxmlGDfrHLgfCMWTJSpFn9s Nkeug45Vz+eqpybUVNohqeWuHFhnD8Lo1HESw2prhqTvdDBxhWv01Osr0/b0hr2I+0RQ dSeg== X-Gm-Message-State: AOJu0Yzsnt/Xamr5FWai0ieCa7uKHCJs5FmciPV3Iaz7syYHNPFaVyux XZXEMMYaD04J5BrOftuIhx2/woI8tBZ2gE9YlnQ8t7hJQ7MiA+bZ5Xs0mMNW3g== X-Gm-Gg: AZuq6aIifDIQKNaSxNg0G2ZMMW4Kj9dUuysoRRvxvNiqu49TvNvJJgDRgcaNJejUJJF xxxRLdRBfkTrVBJPfrHGNb9Q4FPDg4H3Ha7MTgQHG63zqKxz0Zcl15FhIF1trK72jZWDTABcnMJ C4/4ac+CDbBRhJrzHu+1xZOmoxhEUREQFnS2CaNV1VrhdcswQnBMruhfnsvHKVTj7MzcmfwLOEV X10yR17MjpeYItM9iZDVoCpKAzf6Zwzd7KUpqciTxXWhXFmFvwBiJeq5QAn+S53W7IdDTo2WZHG S5oZG5b8Plnj0JfAM3lWX7mFPgOQoMr6Ge9fZJ6GJgq6mcNMHs47ZgFnsCEBaD5BjuDbrLLm22i EQ+2BpBLH2Ur7Jjhpu/ktoEh4BaUwBz6jgOgqM5QTRrt/m/dsdIgJTpQyz10aoPc45IfrrPEpFE DC6mFBTABGIQ/m X-Received: by 2002:a05:6512:108c:b0:59f:822b:b739 with SMTP id 2adb3069b0e04-59f8abde44cmr4841435e87.4.1771828291202; Sun, 22 Feb 2026 22:31:31 -0800 (PST) Received: from xeon ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a0eeb14596sm1361320e87.26.2026.02.22.22.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Feb 2026 22:31:30 -0800 (PST) From: Svyatoslav Ryhel To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Dmitry Torokhov , Lee Jones , Pavel Machek , Sebastian Reichel , Svyatoslav Ryhel , Ion Agorria , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v4 3/7] input: serio: Add driver for ASUS Transformer dock keyboard and touchpad Date: Mon, 23 Feb 2026 08:30:55 +0200 Message-ID: <20260223063059.11322-4-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260223063059.11322-1-clamor95@gmail.com> References: <20260223063059.11322-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Michał Mirosław 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. Co-developed-by: Ion Agorria Signed-off-by: Ion Agorria Signed-off-by: Michał Mirosław Signed-off-by: Svyatoslav Ryhel --- drivers/input/serio/Kconfig | 15 ++ drivers/input/serio/Makefile | 1 + drivers/input/serio/asus-transformer-ec-kbc.c | 147 ++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 drivers/input/serio/asus-transformer-ec-kbc.c diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig index c7ef347a4dff..1ca17ba632cc 100644 --- a/drivers/input/serio/Kconfig +++ b/drivers/input/serio/Kconfig @@ -97,6 +97,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 diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile index 6d97bad7b844..9ecf0d011863 100644 --- a/drivers/input/serio/Makefile +++ b/drivers/input/serio/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_SERIO_CT82C710) += ct82c710.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 diff --git a/drivers/input/serio/asus-transformer-ec-kbc.c b/drivers/input/serio/asus-transformer-ec-kbc.c new file mode 100644 index 000000000000..af755cd0ae38 --- /dev/null +++ b/drivers/input/serio/asus-transformer-ec-kbc.c @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include +#include + +struct asus_ec_kbc_data { + struct notifier_block nb; + struct asusec_info *ec; + struct serio *sdev[2]; +}; + +static int asus_ec_kbc_notify(struct notifier_block *nb, + unsigned long action, void *data_) +{ + struct asus_ec_kbc_data *priv = container_of(nb, struct asus_ec_kbc_data, nb); + unsigned int port_idx, n; + u8 *data = data_; + + if (action & (ASUSEC_SMI_MASK | ASUSEC_SCI_MASK)) + return NOTIFY_DONE; + else if (action & ASUSEC_AUX_MASK) + port_idx = 1; + else if (action & (ASUSEC_KBC_MASK | ASUSEC_KEY_MASK)) + port_idx = 0; + else + return NOTIFY_DONE; + + n = data[0] - 1; + data += 2; + + /* + * We need to replace these incoming data for keys: + * RIGHT_META Press 0xE0 0x27 -> LEFT_ALT Press 0x11 + * RIGHT_META Release 0xE0 0xF0 0x27 -> LEFT_ALT Release 0xF0 0x11 + * COMPOSE Press 0xE0 0x2F -> RIGHT_META Press 0xE0 0x27 + * COMPOSE Release 0xE0 0xF0 0x2F -> RIGHT_META Release 0xE0 0xF0 0x27 + */ + + if (port_idx == 0 && n >= 2 && data[0] == 0xE0) { + if (n == 3 && data[1] == 0xF0) { + switch (data[2]) { + case 0x27: + data[0] = 0xF0; + data[1] = 0x11; + n = 2; + break; + case 0x2F: + data[2] = 0x27; + break; + } + } else if (n == 2) { + switch (data[1]) { + case 0x27: + data[0] = 0x11; + n = 1; + break; + case 0x2F: + data[1] = 0x27; + break; + } + } + } + + while (n--) + serio_interrupt(priv->sdev[port_idx], *data++, 0); + + return NOTIFY_OK; +} + +static int asus_ec_serio_write(struct serio *port, unsigned char data) +{ + const struct asusec_info *ec = port->port_data; + + return asus_ec_i2c_command(ec, (data << 8) | port->id.extra); +} + +static void asus_ec_serio_remove(void *data) +{ + serio_unregister_port(data); +} + +static int asus_ec_register_serio(struct platform_device *pdev, int idx, + const char *name, int cmd) +{ + struct asus_ec_kbc_data *priv = platform_get_drvdata(pdev); + struct i2c_client *parent = to_i2c_client(pdev->dev.parent); + struct serio *port = kzalloc(sizeof(*port), GFP_KERNEL); + + if (!port) + return -ENOMEM; + + priv->sdev[idx] = port; + port->dev.parent = &pdev->dev; + port->id.type = SERIO_8042; + port->id.extra = cmd & 0xFF; + port->write = asus_ec_serio_write; + port->port_data = (void *)priv->ec; + snprintf(port->name, sizeof(port->name), "%s %s", + priv->ec->model, name); + snprintf(port->phys, sizeof(port->phys), "i2c-%u-%04x/serio%d", + i2c_adapter_id(parent->adapter), parent->addr, idx); + + serio_register_port(port); + + return devm_add_action_or_reset(&pdev->dev, asus_ec_serio_remove, port); +} + +static int asus_ec_kbc_probe(struct platform_device *pdev) +{ + struct asusec_info *ec = cell_to_ec(pdev); + struct asus_ec_kbc_data *priv; + int ret; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + platform_set_drvdata(pdev, priv); + priv->ec = ec; + + ret = asus_ec_register_serio(pdev, 0, "Keyboard", 0); + if (ret < 0) + return ret; + + ret = asus_ec_register_serio(pdev, 1, "Touchpad", I8042_CMD_AUX_SEND); + if (ret < 0) + return ret; + + priv->nb.notifier_call = asus_ec_kbc_notify; + + return devm_asus_ec_register_notifier(pdev, &priv->nb); +} + +static struct platform_driver asus_ec_kbc_driver = { + .driver.name = "asus-transformer-ec-kbc", + .probe = asus_ec_kbc_probe, +}; +module_platform_driver(asus_ec_kbc_driver); + +MODULE_AUTHOR("Michał Mirosław "); +MODULE_DESCRIPTION("ASUS Transformer's Dock keyboard and touchpad controller driver"); +MODULE_LICENSE("GPL"); -- 2.51.0