From patchwork Mon May 16 14:22:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 573521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08F65C433F5 for ; Mon, 16 May 2022 14:23:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244489AbiEPOXH (ORCPT ); Mon, 16 May 2022 10:23:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244456AbiEPOXG (ORCPT ); Mon, 16 May 2022 10:23:06 -0400 Received: from mail-4022.proton.ch (mail-4022.proton.ch [185.70.40.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 973051EEF0; Mon, 16 May 2022 07:23:03 -0700 (PDT) Date: Mon, 16 May 2022 14:22:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=connolly.tech; s=protonmail; t=1652710981; bh=GkePH7lDmIvIojm6pGTuooS3sc5yfWTWPTLAwIltkVs=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:Feedback-ID:From:To: Cc:Date:Subject:Reply-To:Feedback-ID:Message-ID; b=Iu4UUEXzb8YMWcK2+IKaJRgVBCMjowcsik/ivcBKKE9FbKbVTgjgHDLjnbzsLirhI 7WNisTP4LOFJApvSQ06S8cDZ/F81SAbrmtHRzKGbkTW5nTtwQZ8A3Pr9OT0ZKhMGPN /CSpGn5iyaSI2Emx4v/X/t502l2OgCwa2m2ufueA= To: Andy Gross , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Dmitry Torokhov , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, phone-devel@vger.kernel.org From: Caleb Connolly Cc: Caleb Connolly Reply-To: Caleb Connolly Subject: [PATCH 1/3] input: add event codes for user programmable switch events Message-ID: <20220516142158.1612109-1-caleb@connolly.tech> Feedback-ID: 10753939:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add SW_PROG{1,2,3,4} for device switches which are handled by userspace. This can be used for devices with "generic" switches which are intended to be user-programmable, for example OnePlus phones contain a tri-state key which can be used for switching between mute/vibrate/ring, or programmed by the user to perform any arbitrary actions. These are analogous to the keys KEY_PROG{1,2,3,4} found on some keyboards. Signed-off-by: Caleb Connolly --- See the next patch in this series for an example usecase. --- include/linux/mod_devicetable.h | 2 +- include/uapi/linux/input-event-codes.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) -- 2.36.1 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 5da5d990ff58..45364fbeaaf7 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -326,7 +326,7 @@ struct pcmcia_device_id { #define INPUT_DEVICE_ID_LED_MAX 0x0f #define INPUT_DEVICE_ID_SND_MAX 0x07 #define INPUT_DEVICE_ID_FF_MAX 0x7f -#define INPUT_DEVICE_ID_SW_MAX 0x10 +#define INPUT_DEVICE_ID_SW_MAX 0x14 #define INPUT_DEVICE_ID_PROP_MAX 0x1f #define INPUT_DEVICE_ID_MATCH_BUS 1 diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h index dff8e7f17074..339153886a13 100644 --- a/include/uapi/linux/input-event-codes.h +++ b/include/uapi/linux/input-event-codes.h @@ -917,7 +917,11 @@ #define SW_MUTE_DEVICE 0x0e /* set = device disabled */ #define SW_PEN_INSERTED 0x0f /* set = pen inserted */ #define SW_MACHINE_COVER 0x10 /* set = cover closed */ -#define SW_MAX 0x10 +#define SW_PROG1 0x11 /* set = program 1 (user defined) */ +#define SW_PROG2 0x12 /* set = program 2 (user defined) */ +#define SW_PROG3 0x13 /* set = program 3 (user defined) */ +#define SW_PROG4 0x14 /* set = program 4 (user defined) */ +#define SW_MAX 0x14 #define SW_CNT (SW_MAX+1) /* From patchwork Mon May 16 14:23:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 573520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5313CC4321E for ; Mon, 16 May 2022 14:23:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244560AbiEPOXR (ORCPT ); Mon, 16 May 2022 10:23:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244499AbiEPOXM (ORCPT ); Mon, 16 May 2022 10:23:12 -0400 Received: from mail-4317.proton.ch (mail-4317.proton.ch [185.70.43.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8309E3B03B; Mon, 16 May 2022 07:23:09 -0700 (PDT) Date: Mon, 16 May 2022 14:23:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=connolly.tech; s=protonmail; t=1652710988; bh=VpuPzUmy8azXATgjTkDZFB1+G13PBtCz2A4M2fXlOrg=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:Feedback-ID:From:To:Cc:Date:Subject:Reply-To: Feedback-ID:Message-ID; b=cmkmMr/yrS78LEZeSC33FJb4p5RmsjUu8Z7PxX+HUKNTyVl85FDFswevBA/vERRBK 1MsyAF7jd2eDZRIT5uz+wyWj+pdYIpYpWbGvc8Mi8WaVjgeL/qSILMK8YzB0SPEirf cXC+l+vWT+XejYOelC/v1uiqTiTLvcn7szs6UZNM= To: Andy Gross , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Dmitry Torokhov , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, phone-devel@vger.kernel.org From: Caleb Connolly Cc: Caleb Connolly Reply-To: Caleb Connolly Subject: [PATCH 2/3] arm64: dts: qcom: sdm845-oneplus: add tri-state-key Message-ID: <20220516142158.1612109-2-caleb@connolly.tech> In-Reply-To: <20220516142158.1612109-1-caleb@connolly.tech> References: <20220516142158.1612109-1-caleb@connolly.tech> Feedback-ID: 10753939:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The tri-state-key is a 3-state mute slider found on the OnePlus 6. The default software maps the states to "mute", "vibrate" and "ring", expose them as generic switch events so that they can be configured by userspace. Signed-off-by: Caleb Connolly --- .../boot/dts/qcom/sdm845-oneplus-common.dtsi | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) -- 2.36.1 diff --git a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi index 07b729f9fec5..f134c51e17ec 100644 --- a/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi +++ b/arch/arm64/boot/dts/qcom/sdm845-oneplus-common.dtsi @@ -7,7 +7,7 @@ /dts-v1/; -#include +#include #include #include "sdm845.dtsi" @@ -26,7 +26,7 @@ chosen { stdout-path = "serial0:115200n8"; }; - gpio-keys { + volume-keys { compatible = "gpio-keys"; label = "Volume keys"; autorepeat; @@ -49,6 +49,41 @@ vol-up { }; }; + tri-state-key { + compatible = "gpio-keys"; + label = "Tri-state key"; + + pinctrl-names = "default"; + pinctrl-0 = <&tri_state_key_default>; + + state-top { + label = "Tri-state key top"; + linux,input-type = ; + linux,code = ; + gpios = <&tlmm 126 GPIO_ACTIVE_LOW>; + debounce-interval = <50>; + linux,can-disable; + }; + + state-middle { + label = "Tri-state key middle"; + linux,input-type = ; + linux,code = ; + gpios = <&tlmm 52 GPIO_ACTIVE_LOW>; + debounce-interval = <50>; + linux,can-disable; + }; + + state-bottom { + label = "Tri-state key bottom"; + linux,input-type = ; + linux,code = ; + gpios = <&tlmm 24 GPIO_ACTIVE_LOW>; + debounce-interval = <50>; + linux,can-disable; + }; + }; + reserved-memory { /* The rmtfs_mem needs to be guarded due to "XPU limitations" * it is otherwise possible for an allocation adjacent to the @@ -607,9 +642,10 @@ &usb_1_hsphy { &tlmm { gpio-reserved-ranges = <0 4>, <81 4>; - tri_state_key_default: tri_state_key_default { + /* The GPIOs have a hardware pullup */ + tri_state_key_default: tri-state-pins { mux { - pins = "gpio40", "gpio42", "gpio26"; + pins = "gpio126", "gpio52", "gpio24"; function = "gpio"; drive-strength = <2>; bias-disable; From patchwork Mon May 16 14:23:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 573033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60ADEC43217 for ; Mon, 16 May 2022 14:23:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244546AbiEPOXQ (ORCPT ); Mon, 16 May 2022 10:23:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244493AbiEPOXM (ORCPT ); Mon, 16 May 2022 10:23:12 -0400 Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F26FE3B03F; Mon, 16 May 2022 07:23:10 -0700 (PDT) Date: Mon, 16 May 2022 14:23:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=connolly.tech; s=protonmail; t=1652710989; bh=r0c6Fy6+bDH4824g2iGMHucscG/Y0NMZJhVGiSc6orw=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:Feedback-ID:From:To:Cc:Date:Subject:Reply-To: Feedback-ID:Message-ID; b=iy6O0EM5FeLCJHvKD9Tdi+Fhtvy9e/D6djEvwL4apmROygGU2tAaz4pu5qEdgLRx1 bOyhU7psCO2CwXRbhKhJIheslZYDtjfGASdkAANn07W8UP3vomMJcm+hvx3+w4z/n0 tTb/CMNPBsHSI+k3wZmDVlYcecx+2gvlSFmTV+kM= To: Andy Gross , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Dmitry Torokhov , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, phone-devel@vger.kernel.org From: Caleb Connolly Cc: Caleb Connolly , Jami Kettunen Reply-To: Caleb Connolly Subject: [PATCH 3/3] arm64: dts: qcom: msm8998-oneplus: add tri-state-key Message-ID: <20220516142158.1612109-3-caleb@connolly.tech> In-Reply-To: <20220516142158.1612109-1-caleb@connolly.tech> References: <20220516142158.1612109-1-caleb@connolly.tech> Feedback-ID: 10753939:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The tri-state-key is a 3-state mute slider found on the OnePlus 5. The default software maps the states to "mute", "vibrate" and "ring", expose them as generic switch events so that they can be configured by userspace. Signed-off-by: Caleb Connolly Signed-off-by: Jami Kettunen --- .../boot/dts/qcom/msm8998-oneplus-common.dtsi | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) -- 2.36.1 diff --git a/arch/arm64/boot/dts/qcom/msm8998-oneplus-common.dtsi b/arch/arm64/boot/dts/qcom/msm8998-oneplus-common.dtsi index 9823d48a91b1..9ae6b3e4fc32 100644 --- a/arch/arm64/boot/dts/qcom/msm8998-oneplus-common.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8998-oneplus-common.dtsi @@ -94,6 +94,41 @@ vol-up { }; }; + tri-state-key { + compatible = "gpio-keys"; + label = "Tri-state key"; + + pinctrl-names = "default"; + pinctrl-0 = <&tri_state_key_default>; + + state-top { + label = "Tri-state key top"; + linux,input-type = ; + linux,code = ; + gpios = <&tlmm 40 GPIO_ACTIVE_LOW>; + debounce-interval = <50>; + linux,can-disable; + }; + + state-middle { + label = "Tri-state key middle"; + linux,input-type = ; + linux,code = ; + gpios = <&tlmm 42 GPIO_ACTIVE_LOW>; + debounce-interval = <50>; + linux,can-disable; + }; + + state-bottom { + label = "Tri-state key bottom"; + linux,input-type = ; + linux,code = ; + gpios = <&tlmm 26 GPIO_ACTIVE_LOW>; + debounce-interval = <50>; + linux,can-disable; + }; + }; + gpio-hall-sensor { compatible = "gpio-keys"; label = "Hall effect sensor"; @@ -441,6 +476,14 @@ vreg_bob: bob { &tlmm { gpio-reserved-ranges = <0 4>, <81 4>; + /* The GPIOs have a hardware pullup */ + tri_state_key_default: tri-state-pins { + pins = "gpio40", "gpio42", "gpio26"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; + hall_sensor_default: hall-sensor-default { pins = "gpio124"; function = "gpio";