From nobody Wed Dec 17 00:00:53 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFFED230BD5; Mon, 15 Dec 2025 12:30:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765801841; cv=pass; b=PiYNPx6jv+y5vRlZqWlHlzMVSkDsZU8lyqfgfig/MwRxt5+ok5s1LaW5ADScySAKrqfrXMEL3aScmYv5e+xV/17mM6FcxIYTtAhAo4fBDxdAE/7RU1BM1ODlr/LlkAxFxnWchwB2zLYUJesHuwmhLSPvL+PxTIJ75JdplXuEAsk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765801841; c=relaxed/simple; bh=OLHayUs7V9b/o+/hh1s8WHuPya3qVcW0Bybto2UJzF0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SlFQtm88kNEnD1gRWnhfIHijOHgg73tAmJKjYjIy83Kn2zD26s03DOMgCKjol4S5l3nC+R2cftSAgHgkMvmZRqhNBkaDV2mYVAOxAOU4fa/U8CCRoCdPoEtzt4M/aoNgpbvm/BtRBrw9HNGcx1thnv+8wvkbxPc7T++Qy/5K4cc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=WlgM9zOd; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="WlgM9zOd" ARC-Seal: i=1; a=rsa-sha256; t=1765801797; cv=none; d=zohomail.com; s=zohoarc; b=NLE7W6B1mOuoDcXwW1XAoLLAmagS6oyKJKxl7CaU1nywuPYY3WFykZQnYFo07fQYOEEGdZvjsMnJTZwpjGw+sJ5HMZSJ/npyFcmP/rfXed9xAelll1JkW2b2RPGc+oBK9QNxwo+O5WVsNZ+B/ztKm4RAmxkLTY/ABFfNYGuwuuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765801797; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=YFvkp8sx9x7p+ety3YU1OWBYrz0nSL8Cjejt5tXhoXY=; b=GjE8xM3YZHW8+IBDQMM7+Lr9wDE8nQikU8UfVwX8Z47g7i8UTmS5hc854UZMJyjXf40Lw7c1mP3xqmrtaPmbeGU8fmzOMdzTgRdJtAHbsP37rEkYXBAPbC7PtZGl3OynEafhF+KZa6/o4QW9+v3fM8vLLosemFHWFgM/uk580Fg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1765801797; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=YFvkp8sx9x7p+ety3YU1OWBYrz0nSL8Cjejt5tXhoXY=; b=WlgM9zOdeK7/1T9h5CDUKt9jGDi0MbmpLvxiZIH86qNNrjY/Spwu376r2z1gVMFe BAqtFRIFBORKjIbyCWx/kd61UBCFCxfoEJwpq4ePIzOqWX3rx9dBYZjSPoqn4FzSSuc 22YsFV0ckstqo4BcsYs/f2ZinvAJJZ2QkFOjJBHU= Received: by mx.zohomail.com with SMTPS id 176580179655941.66611173233514; Mon, 15 Dec 2025 04:29:56 -0800 (PST) From: Nicolas Frattaroli Date: Mon, 15 Dec 2025 13:29:29 +0100 Subject: [PATCH v2 1/4] dt-bindings: input: adc-keys: allow linux,input-type property Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251215-rock4d-audio-v2-1-82a61de39b4c@collabora.com> References: <20251215-rock4d-audio-v2-0-82a61de39b4c@collabora.com> In-Reply-To: <20251215-rock4d-audio-v2-0-82a61de39b4c@collabora.com> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Belloni , Heiko Stuebner Cc: kernel@collabora.com, linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 adc-keys, unlike gpio-keys, does not allow linux,input-type as a valid property. This makes it impossible to model devices that have ADC inputs that should generate switch events. Add the property to the binding with the same default as gpio-keys. Reviewed-by: Heiko Stuebner Signed-off-by: Nicolas Frattaroli Reviewed-by: Alexandre Belloni --- Documentation/devicetree/bindings/input/adc-keys.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/input/adc-keys.yaml b/Docume= ntation/devicetree/bindings/input/adc-keys.yaml index 7aa078dead37..e372ebc23d16 100644 --- a/Documentation/devicetree/bindings/input/adc-keys.yaml +++ b/Documentation/devicetree/bindings/input/adc-keys.yaml @@ -42,6 +42,9 @@ patternProperties: =20 linux,code: true =20 + linux,input-type: + default: 1 # EV_KEY + press-threshold-microvolt: description: Voltage above or equal to which this key is considered pressed. = No --=20 2.52.0 From nobody Wed Dec 17 00:00:53 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C553621146C; Mon, 15 Dec 2025 12:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765801833; cv=pass; b=RGbnrYecthoFLypD3AYeQtw3yYSmrojRdnU5Rzk4FYZy54KYBjDpL7KGt8OXC91AgPFhQxlkXhe/G6xg5nBbldCROPCy1lMfOY+PAeNb+rPam1gHOiIG0h7cQdrTTC5K9ZfMAAaLTAHC9dAHnpQUIq76UNMegmTValFc0LK/34Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765801833; c=relaxed/simple; bh=7C6Q3SSN+d7+kzGDmCPbKwmMa1GEa0w+hl6HzzkS/c4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PaittQY3oeaK+w5hd9sX6Of1+7d2lYzjpWEHYxyWESUR0WCmCYqgf1yymguDMFcUWRdQYd92pxCEEs+vepFq7/P0U1v1q53ZkjEOK9kmXKXWZ3xV/RfJTWEl2vL/0+0yv9mhTYelm1FoWO5EdCzr9TJY6NI9mL9/2BuE6Xhaibw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=LryNsyYC; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="LryNsyYC" ARC-Seal: i=1; a=rsa-sha256; t=1765801801; cv=none; d=zohomail.com; s=zohoarc; b=CvR3Zn1MaPwq2vkBfl9IUi21oYWD3iMXyRi2x3ycVcs7QCkMYrBmIoAlirl8czz3rf3HLs5/Rwm4rlbkf7/JYJAGMV9er2u7buC43/Cr+wP0ZbK/nf/RdQ9cBZ1JoaqHRqG+rGGpTzEv1c5LYQu3sZ33bKUj5+3kb1mlrHlrfFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765801801; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=39OmIwXfdmPw69o0cpAowcv7j0z798lr3Zhxe2aAZ+I=; b=ks9k7pmiZIS5i/DlJ/lSOFjhkR17AGPCUKB0dxbCKV/E5reJvusbk4Azmby1dm4QXrs3WlKG1bsMDdq1g6cCKM2JgXYYMmS4MX3/PDHatM5dFY7iZzRg2nxJ5FEn2690JJLIuGL5RWgGxjWPAse9/WpExJ27sfUi+6GJZzWs+mQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1765801801; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=39OmIwXfdmPw69o0cpAowcv7j0z798lr3Zhxe2aAZ+I=; b=LryNsyYChnaPRg4/Za7PeYsFJFTlgFgnmCO/TGC8JG1/LUFTyh7DFRYes3IKy/d2 rsi44gUotpQPe3umEAp6HYHRz1YXcubcP9ckfNgngZNNs7KouEeAz8NVARw4nHqwz/4 wRzD5HQ4bacTDsLbEPVM7LGgZbwX/7Ii1KdRwzrA= Received: by mx.zohomail.com with SMTPS id 1765801799867522.9935835434184; Mon, 15 Dec 2025 04:29:59 -0800 (PST) From: Nicolas Frattaroli Date: Mon, 15 Dec 2025 13:29:30 +0100 Subject: [PATCH v2 2/4] Input: adc-keys - support EV_SW as well, not just EV_KEY. Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251215-rock4d-audio-v2-2-82a61de39b4c@collabora.com> References: <20251215-rock4d-audio-v2-0-82a61de39b4c@collabora.com> In-Reply-To: <20251215-rock4d-audio-v2-0-82a61de39b4c@collabora.com> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Belloni , Heiko Stuebner Cc: kernel@collabora.com, linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 Instead of doing something like what gpio-keys is doing, adc-keys hardcodes that all keycodes must be of type EV_KEY. This limits the usefulness of adc-keys, and overcomplicates the code with manual bit-setting logic. Instead, refactor the code to read the linux,input-type fwnode property, and get rid of the custom bit setting logic, replacing it with input_set_capability instead. input_report_key is replaced with input_event, which allows us to explicitly pass the type. Only EV_KEY and EV_SW is allowed at this stage. Signed-off-by: Nicolas Frattaroli Reviewed-by: Alexandre Belloni --- drivers/input/keyboard/adc-keys.c | 37 +++++++++++++++++++++++++----------= -- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/drivers/input/keyboard/adc-keys.c b/drivers/input/keyboard/adc= -keys.c index f1753207429d..62376f34f7d0 100644 --- a/drivers/input/keyboard/adc-keys.c +++ b/drivers/input/keyboard/adc-keys.c @@ -18,13 +18,15 @@ =20 struct adc_keys_button { u32 voltage; - u32 keycode; + u32 code; + u32 type; }; =20 struct adc_keys_state { struct iio_channel *channel; u32 num_keys; u32 last_key; + u32 last_type; u32 keyup_voltage; const struct adc_keys_button *map; }; @@ -34,7 +36,8 @@ static void adc_keys_poll(struct input_dev *input) struct adc_keys_state *st =3D input_get_drvdata(input); int i, value, ret; u32 diff, closest =3D 0xffffffff; - int keycode =3D 0; + u32 code =3D 0; + u32 type =3D EV_KEY; =20 ret =3D iio_read_channel_processed(st->channel, &value); if (unlikely(ret < 0)) { @@ -45,22 +48,24 @@ static void adc_keys_poll(struct input_dev *input) diff =3D abs(st->map[i].voltage - value); if (diff < closest) { closest =3D diff; - keycode =3D st->map[i].keycode; + code =3D st->map[i].code; + type =3D st->map[i].type; } } } =20 if (abs(st->keyup_voltage - value) < closest) - keycode =3D 0; + code =3D 0; =20 - if (st->last_key && st->last_key !=3D keycode) - input_report_key(input, st->last_key, 0); + if (st->last_key && st->last_key !=3D code) + input_event(input, st->last_type, st->last_key, 0); =20 - if (keycode) - input_report_key(input, keycode, 1); + if (code) + input_event(input, type, code, 1); =20 input_sync(input); - st->last_key =3D keycode; + st->last_key =3D code; + st->last_type =3D type; } =20 static int adc_keys_load_keymap(struct device *dev, struct adc_keys_state = *st) @@ -88,11 +93,20 @@ static int adc_keys_load_keymap(struct device *dev, str= uct adc_keys_state *st) map[i].voltage /=3D 1000; =20 if (fwnode_property_read_u32(child, "linux,code", - &map[i].keycode)) { + &map[i].code)) { dev_err(dev, "Key with invalid or missing linux,code\n"); return -EINVAL; } =20 + if (fwnode_property_read_u32(child, "linux,input-type", + &map[i].type)) + map[i].type =3D EV_KEY; + + if (map[i].type !=3D EV_KEY && map[i].type !=3D EV_SW) + return dev_err_probe(dev, -EINVAL, + "Invalid linux,input-type: 0x%x\n", + map[i].type); + i++; } =20 @@ -156,9 +170,8 @@ static int adc_keys_probe(struct platform_device *pdev) input->id.product =3D 0x0001; input->id.version =3D 0x0100; =20 - __set_bit(EV_KEY, input->evbit); for (i =3D 0; i < st->num_keys; i++) - __set_bit(st->map[i].keycode, input->keybit); + input_set_capability(input, st->map[i].type, st->map[i].code); =20 if (device_property_read_bool(dev, "autorepeat")) __set_bit(EV_REP, input->evbit); --=20 2.52.0 From nobody Wed Dec 17 00:00:53 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB43623BD17; Mon, 15 Dec 2025 12:30:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765801844; cv=pass; b=lQL6k0GvJO6pMcJ6KDujovvit8y9FHipQClF/YZnLxNdFPSqchI9EDQHjoYRjxLvFKbR5T1g3nZpPkjEpGrBWnAXxJutfIxQlElpGgNSBqKJUa9yUmtGCU9c+uzsUru2EjALDltA6l36Yv3v4TME6EBbblcJSwTNMgGC/u/5vSU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765801844; c=relaxed/simple; bh=z668XgwPST8e2Yu8ccoR34JkPQXmjHez0OHtJeY41pM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aJHy4iKwcFW0wrTmfbAd7vcaGOgHuL14NWuR6uosTXAQAfWUBKru/xsLRAFjIxZ6hxB3f089LkPcegVe3tkrmeDyAe/1oMrC/rCBjBb7cmuFQ1DibZxGcdGue6jkjG6P8M01X1Xxkiv5ueOSsHibjoLlcpYJhpRt3gFMxpXsmpc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=kuLtwajX; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="kuLtwajX" ARC-Seal: i=1; a=rsa-sha256; t=1765801805; cv=none; d=zohomail.com; s=zohoarc; b=MIqPvcu8f4lxYvcZwsgV8rAX3pVUZHTMnXNL64KenDPT/wCnpJiSxx2H+rHfOl57smOYIfv+m1tCkivMb2spJtwsO5dHcO/UmqaNWJDEZd+fA0L9S0POWxegCpCxbYzu3uIZ3Lslfl/6KE+BadWJuSrLBKAqy5dJH3zLpVg1kTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765801805; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=TuKNRaz7MrQ0hh61vH11eGIxG3RyMa5h1730t+udGTs=; b=IsNDvLFrk6aLJMgauGdh1pBfg3y+hs3v7kD1+q8Vp9f5WqTAg24Qix8dHZGa/fePgtumdrL4JnIXwzVbCW4HktaQnyFcfyP/B5RjSfHYZazyZSRzAXN95lH4jf5a/SMWeIECAT2s94ShAX19SA6ex37rNhNhUSosCyjtFW12A/M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1765801805; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=TuKNRaz7MrQ0hh61vH11eGIxG3RyMa5h1730t+udGTs=; b=kuLtwajXx7289h4z8M055JO6EtPECSzvaKBVOLAAVs8A8ETvwt9+WvCK3GanUZx7 7ScxqacgN/q+BCLrQCrI8LPdXoeQ6QLRhWlbGg3jXmwQzwCrhouDvJ5euxb4ht5YdwH yLM4PgJjVd6wCEMTZsajPV1OVOzqKHu/BI6XkVG8= Received: by mx.zohomail.com with SMTPS id 176580180327052.47775160298363; Mon, 15 Dec 2025 04:30:03 -0800 (PST) From: Nicolas Frattaroli Date: Mon, 15 Dec 2025 13:29:31 +0100 Subject: [PATCH v2 3/4] Input: adc-keys - Use dev_err_probe in probe function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251215-rock4d-audio-v2-3-82a61de39b4c@collabora.com> References: <20251215-rock4d-audio-v2-0-82a61de39b4c@collabora.com> In-Reply-To: <20251215-rock4d-audio-v2-0-82a61de39b4c@collabora.com> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Belloni , Heiko Stuebner Cc: kernel@collabora.com, linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 Rework the probe function, and functions called by the probe function, to use dev_err_probe for error logging. While at it, also do some minor style cleanups, like not error logging on -ENOMEM and using ! instead of =3D=3D 0. Signed-off-by: Nicolas Frattaroli Reviewed-by: Alexandre Belloni --- drivers/input/keyboard/adc-keys.c | 53 ++++++++++++++++-------------------= ---- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/drivers/input/keyboard/adc-keys.c b/drivers/input/keyboard/adc= -keys.c index 62376f34f7d0..6f2ddcecea99 100644 --- a/drivers/input/keyboard/adc-keys.c +++ b/drivers/input/keyboard/adc-keys.c @@ -74,10 +74,8 @@ static int adc_keys_load_keymap(struct device *dev, stru= ct adc_keys_state *st) int i; =20 st->num_keys =3D device_get_child_node_count(dev); - if (st->num_keys =3D=3D 0) { - dev_err(dev, "keymap is missing\n"); - return -EINVAL; - } + if (!st->num_keys) + return dev_err_probe(dev, -EINVAL, "keymap is missing\n"); =20 map =3D devm_kmalloc_array(dev, st->num_keys, sizeof(*map), GFP_KERNEL); if (!map) @@ -86,17 +84,16 @@ static int adc_keys_load_keymap(struct device *dev, str= uct adc_keys_state *st) i =3D 0; device_for_each_child_node_scoped(dev, child) { if (fwnode_property_read_u32(child, "press-threshold-microvolt", - &map[i].voltage)) { - dev_err(dev, "Key with invalid or missing voltage\n"); - return -EINVAL; - } + &map[i].voltage)) + return dev_err_probe(dev, -EINVAL, + "Key with invalid or missing voltage\n"); + map[i].voltage /=3D 1000; =20 if (fwnode_property_read_u32(child, "linux,code", - &map[i].code)) { - dev_err(dev, "Key with invalid or missing linux,code\n"); - return -EINVAL; - } + &map[i].code)) + return dev_err_probe(dev, -EINVAL, + "Key with invalid or missing linux,code\n"); =20 if (fwnode_property_read_u32(child, "linux,input-type", &map[i].type)) @@ -129,7 +126,8 @@ static int adc_keys_probe(struct platform_device *pdev) =20 st->channel =3D devm_iio_channel_get(dev, "buttons"); if (IS_ERR(st->channel)) - return PTR_ERR(st->channel); + return dev_err_probe(dev, PTR_ERR(st->channel), + "Could not get iio channel\n"); =20 if (!st->channel->indio_dev) return -ENXIO; @@ -138,16 +136,13 @@ static int adc_keys_probe(struct platform_device *pde= v) if (error < 0) return error; =20 - if (type !=3D IIO_VOLTAGE) { - dev_err(dev, "Incompatible channel type %d\n", type); - return -EINVAL; - } + if (type !=3D IIO_VOLTAGE) + return dev_err_probe(dev, -EINVAL, "Incompatible channel type %d\n", typ= e); =20 if (device_property_read_u32(dev, "keyup-threshold-microvolt", - &st->keyup_voltage)) { - dev_err(dev, "Invalid or missing keyup voltage\n"); - return -EINVAL; - } + &st->keyup_voltage)) + return dev_err_probe(dev, -EINVAL, "Invalid or missing keyup voltage\n"); + st->keyup_voltage /=3D 1000; =20 error =3D adc_keys_load_keymap(dev, st); @@ -155,10 +150,8 @@ static int adc_keys_probe(struct platform_device *pdev) return error; =20 input =3D devm_input_allocate_device(dev); - if (!input) { - dev_err(dev, "failed to allocate input device\n"); + if (!input) return -ENOMEM; - } =20 input_set_drvdata(input, st); =20 @@ -178,19 +171,15 @@ static int adc_keys_probe(struct platform_device *pde= v) =20 =20 error =3D input_setup_polling(input, adc_keys_poll); - if (error) { - dev_err(dev, "Unable to set up polling: %d\n", error); - return error; - } + if (error) + return dev_err_probe(dev, error, "Unable to set up polling\n"); =20 if (!device_property_read_u32(dev, "poll-interval", &value)) input_set_poll_interval(input, value); =20 error =3D input_register_device(input); - if (error) { - dev_err(dev, "Unable to register input device: %d\n", error); - return error; - } + if (error) + return dev_err_probe(dev, error, "Unable to register input device\n"); =20 return 0; } --=20 2.52.0 From nobody Wed Dec 17 00:00:53 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEDB22135C5; Mon, 15 Dec 2025 12:30:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765801853; cv=pass; b=JAjdU/gTr+OEGkJ8NgjidSBsXBMJ/RP96v4wJvRBkNByIN82u9FHVN0juTvxnuv/MR9xFUVmk7mMUah2moZUjaQ50AHypCEGfGgN9GrnH57axlWz0CXxy6n7idlramwk2gUAKgESaCiBO017oQ+79ubtJIGPN2945YJZqVMIp+A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765801853; c=relaxed/simple; bh=saMowi89mdKizIgjfjlUJq4vBk5daMY3aXxvL2i2/f0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AKV4QjEZDeBAb7hdjwzCdWLmAr+bzdqc15AWFdIiHfCuzJHEH5ChRA7eGHwZgqphdgY5Yu348OXkXlUargudqHn5oocYIxFIUSy+pEBcM4wqJNFGuiW6E+YO1E6krR5NNShvQSo4VJqo6a5EGvc+mXczouwbuGmWNSze018zG/s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=ci0ioW4z; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="ci0ioW4z" ARC-Seal: i=1; a=rsa-sha256; t=1765801809; cv=none; d=zohomail.com; s=zohoarc; b=IkQhk3qgaT0JEZCT+ICA+VpgJqzUKjZ5dXc5wZo5AbZyXXrtoe8NiraYfYV4BGaRp5f03Qrin3Xtzf9asGWyGsQN9zFfVGNEVEzNnV3TMRdJwrV73V780Wo5jc/j1WLzceC1EhidBu5fqfXjHEh1SuoYrjKOhDXHFN7OMw9TpTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765801809; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=KeacQ4CeOE09azYmxQDko//Tpjw/tUJXHdiwkLf+/DM=; b=mShRcSZwr+AKd13J8lsiNFoYe4Sp/Bpp+TPY9uJvCU0M0kVIa3rB4YwBRkOyl+Tb6FCcr0yXiOm13gRliWzYoDGm5f+vxR9P3tvApWnWOtl3jWVZ6vGSsl0EfUqlQmzka4Lwxjk+qMGsQLcoO6J/bcSFioVDmZcHEwNPjrkJJCY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1765801809; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=KeacQ4CeOE09azYmxQDko//Tpjw/tUJXHdiwkLf+/DM=; b=ci0ioW4zERaa+1afcdhbATNSbDRVokSy+jGsQR4XJ/G3SVmc6vWi8QpjosEb7mhC HGgiM7+RJhNgIEBYhiwKVti03r3ue0VVW0Z2mO8sysEPdMayOAlCyjq1bOGIoNZ5KUe q6MsfuBbUvAcug6xAXfjJ+ouhpSiHZTsZaog6qic= Received: by mx.zohomail.com with SMTPS id 17658018079051022.900831674124; Mon, 15 Dec 2025 04:30:07 -0800 (PST) From: Nicolas Frattaroli Date: Mon, 15 Dec 2025 13:29:32 +0100 Subject: [PATCH v2 4/4] arm64: dts: rockchip: add analog audio to ROCK 4D Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251215-rock4d-audio-v2-4-82a61de39b4c@collabora.com> References: <20251215-rock4d-audio-v2-0-82a61de39b4c@collabora.com> In-Reply-To: <20251215-rock4d-audio-v2-0-82a61de39b4c@collabora.com> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Belloni , Heiko Stuebner Cc: kernel@collabora.com, linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Nicolas Frattaroli , Cristian Ciocaltea X-Mailer: b4 0.14.3 The RADXA ROCK 4D, like many other Rockchip-based boards, uses an ES8388 analog audio codec. On the production version of the board, the codec's LOUT1 and ROUT1 pins are tied to the headphone jack, whereas pins LOUT2 and ROUT2 lead to a non-populated speaker amplifier that itself leads to a non-populated speaker jack. The schematic is still haunted by the ghosts of those symbols, but it clearly marks them as "NC". The 3.5mm TRRS jack has its microphone ring (and ground ring) wired to the codec's LINPUT1 and RINPUT1 pins for differential signalling. Furthermore, it uses the SoCs ADC to detect whether the inserted cable is of headphones (i.e., no microphone), or a headset (i.e., with microphone). The way this is done is that the ADC input taps the output of a 100K/100K resistor divider that divides the microphone ring pin that's pulled up to 3.3V. There is no ADC level difference between a completely empty jack and one with a set of headphones (i.e., ones that don't have a microphone) connected. Consequently headphone insertion detection isn't something that can be done. Add the necessary codec and audio card nodes. The non-populated parts, i.e. LOUT2 and ROUT2, are not modeled at all, as they are not present on the hardware. Also, add an adc-keys node for the headset detection, which uses an input type of EV_SW with the SW_MICROPHONE_INSERT keycode. Below the 220mV pressed voltage level of our SW_MICROPHONE_INSERT switch, we also define a button that emits a KEY_RESERVED code, which is there to model this part of the voltage range as not just being extra legroom for the button above it, but actually a state that is encountered in the real world, and should be recognised as a valid state for the ADC range to be in so that no "closer" ADC button is chosen. Tested-by: Cristian Ciocaltea Signed-off-by: Nicolas Frattaroli --- arch/arm64/boot/dts/rockchip/rk3576-rock-4d.dts | 90 +++++++++++++++++++++= ++++ 1 file changed, 90 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3576-rock-4d.dts b/arch/arm64/b= oot/dts/rockchip/rk3576-rock-4d.dts index 7023dc326d0e..d86fe2951da6 100644 --- a/arch/arm64/boot/dts/rockchip/rk3576-rock-4d.dts +++ b/arch/arm64/boot/dts/rockchip/rk3576-rock-4d.dts @@ -6,6 +6,7 @@ /dts-v1/; =20 #include +#include #include #include #include @@ -37,6 +38,31 @@ hdmi_con_in: endpoint { }; }; =20 + es8388_sound: es8388-sound { + compatible =3D "simple-audio-card"; + simple-audio-card,format =3D "i2s"; + simple-audio-card,mclk-fs =3D <256>; + simple-audio-card,name =3D "On-board Analog ES8388"; + simple-audio-card,widgets =3D "Microphone", "Headphone Mic", + "Headphone", "Headphone"; + simple-audio-card,routing =3D "Headphone", "LOUT1", + "Headphone", "ROUT1", + "Left PGA Mux", "Differential Mux", + "Differential Mux", "LINPUT1", + "Differential Mux", "RINPUT1", + "LINPUT1", "Headphone Mic", + "RINPUT1", "Headphone Mic"; + + simple-audio-card,cpu { + sound-dai =3D <&sai1>; + }; + + simple-audio-card,codec { + sound-dai =3D <&es8388>; + system-clock-frequency =3D <12288000>; + }; + }; + rfkill { compatible =3D "rfkill-gpio"; pinctrl-names =3D "default"; @@ -65,6 +91,37 @@ user-led { }; }; =20 + saradc_keys: adc-keys { + compatible =3D "adc-keys"; + io-channels =3D <&saradc 3>; + io-channel-names =3D "buttons"; + keyup-threshold-microvolt =3D <3000000>; + poll-interval =3D <100>; + + /* + * During insertion and removal of a regular set of headphones, + * i.e. one without a microphone, the voltage level briefly + * dips below the 220mV of the headset connection switch. + * By having a button definition with a KEY_RESERVED signal + * between 0 to 220, we ensure no driver implementation thinks + * that the closest thing to 0V is 220mV so clearly there must + * be a headset connected. + */ + + button-headset-disconnected { + label =3D "Headset Microphone Disconnected"; + linux,code =3D ; + press-threshold-microvolt =3D <0>; + }; + + button-headset-connected { + label =3D "Headset Microphone Connected"; + linux,code =3D ; + linux,input-type =3D ; + press-threshold-microvolt =3D <220000>; + }; + }; + vcc_5v0_dcin: regulator-vcc-5v0-dcin { compatible =3D "regulator-fixed"; regulator-always-on; @@ -682,6 +739,25 @@ hym8563: rtc@51 { }; }; =20 +&i2c3 { + status =3D "okay"; + + es8388: audio-codec@10 { + compatible =3D "everest,es8388", "everest,es8328"; + reg =3D <0x10>; + clocks =3D <&cru CLK_SAI1_MCLKOUT_TO_IO>; + AVDD-supply =3D <&vcca_3v3_s0>; + DVDD-supply =3D <&vcc_3v3_s0>; + HPVDD-supply =3D <&vcca_3v3_s0>; + PVDD-supply =3D <&vcc_3v3_s0>; + assigned-clocks =3D <&cru CLK_SAI1_MCLKOUT_TO_IO>; + assigned-clock-rates =3D <12288000>; + #sound-dai-cells =3D <0>; + pinctrl-names =3D "default"; + pinctrl-0 =3D <&sai1m0_mclk>; + }; +}; + &mdio0 { rgmii_phy0: ethernet-phy@1 { compatible =3D "ethernet-phy-id001c.c916"; @@ -756,10 +832,24 @@ wifi_en_h: wifi-en-h { }; }; =20 +&sai1 { + pinctrl-names =3D "default"; + pinctrl-0 =3D <&sai1m0_lrck + &sai1m0_sclk + &sai1m0_sdi0 + &sai1m0_sdo0>; + status =3D "okay"; +}; + &sai6 { status =3D "okay"; }; =20 +&saradc { + vref-supply =3D <&vcca1v8_pldo2_s0>; + status =3D "okay"; +}; + &sdmmc { bus-width =3D <4>; cap-mmc-highspeed; --=20 2.52.0