From patchwork Mon Jan 7 18:53:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Chmiel?= X-Patchwork-Id: 10751101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4607C6C5 for ; Mon, 7 Jan 2019 18:55:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36738289A0 for ; Mon, 7 Jan 2019 18:55:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AA3A289AA; Mon, 7 Jan 2019 18:55:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE68A289A0 for ; Mon, 7 Jan 2019 18:55:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726676AbfAGSyK (ORCPT ); Mon, 7 Jan 2019 13:54:10 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:35291 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727048AbfAGSyK (ORCPT ); Mon, 7 Jan 2019 13:54:10 -0500 Received: by mail-lf1-f65.google.com with SMTP id e26so1095258lfc.2; Mon, 07 Jan 2019 10:54:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X2xmaLsg9+x3NOOa9a3z9y0xnBcsw3Eg+1EpWLMSG6k=; b=U/uaXTk48haB58XjQDNWEWvQDj2qNa+gwEXqtLDendilnltwq2czrtHqYIViYfIYJz 58iFmatzCSe6aCoLBbj9EXpl8n4w3EWgBvHMoxGNgmbKJiiQ3n13n0piZJ29pqNrvrVG m8KuW55O+Jf8N2YgxyHkfDinDWS1BtMz3y0nhLdhuQgc7qSjFm6wQSwY7c8APY0ApNYD oh4gagTsj+0O/5VvrMvaO7b5B2l56R10Kma2YkNtHfPKo5/YzyadE/EPrVpNMUzQV+ul D5hT6W4Fkac45aIO5XPdjU/7GszDca2z3b95frvq/EuPEY5CBqjJVpCaA2CkhNS342Jg 1sbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X2xmaLsg9+x3NOOa9a3z9y0xnBcsw3Eg+1EpWLMSG6k=; b=qPtJxKQevTqlUv1JXqqo12eEA+aLWtgfI7+ETIxqDDPxzLBfZaZhHiYwQoOrFxPgMK U8H0S8NtCQ67eqU0bDNhFadVVXFeP26FUeag2rLhaIVC1TciA+CZHTuhPp8Vffx8+uR7 t2Vg0lpNxVpHiLggx8iuQgosRSX184LJytvRcmF12t3q13w/X+AwMXhiUcoWI731w2A7 +UsUxgNg/b4Q60xNeT/d6SwnFCKb5sCuL5KSxkhHpQiXCmH/l9y9cdIn3ocn8Qcqzqvv eoajkHqOeuy5B49buWWgDvMgQAxikql46XjMssh+cL466/GR2OydAICH+Fql+Pj6Xil1 tsQQ== X-Gm-Message-State: AA+aEWZ1ZeaVgQWskojteSve+k3f8RLCLa7+S41qgcsq7Ct5aCUtUv5d lPQwFB16ENnD6avWCO4uUPQ= X-Google-Smtp-Source: AFSGD/Vij7p1CEcLNAVrinK7J08BklMtIEMMx8FQP/f017DZC4I69rS+O9lSwHVbU739Q58zzuN8rg== X-Received: by 2002:a19:f89:: with SMTP id 9mr30185815lfp.10.1546887247456; Mon, 07 Jan 2019 10:54:07 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:c050:d453:6c2:1d01]) by smtp.googlemail.com with ESMTPSA id h203sm12825007lfe.44.2019.01.07.10.54.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 10:54:06 -0800 (PST) From: =?utf-8?q?Pawe=C5=82_Chmiel?= To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, pawel.mikolaj.chmiel@gmail.com, xc-racer2@live.ca, simon@lineageos.org Subject: [PATCH v3 1/7] Input: tm2-touchkey: Add support for midas touchkey Date: Mon, 7 Jan 2019 19:53:40 +0100 Message-Id: <20190107185346.30184-2-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> References: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Simon Shields The touchkey on midas boards is almost identical. The only real difference is that it uses the same register for both keycode and base. Signed-off-by: Simon Shields Signed-off-by: Paweł Chmiel --- Changes from v1: - Droped separate name changes - Added missing const in few places - Removed redundant cast --- drivers/input/keyboard/tm2-touchkey.c | 34 +++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c index abc266e40e17..5a1fe08bdd76 100644 --- a/drivers/input/keyboard/tm2-touchkey.c +++ b/drivers/input/keyboard/tm2-touchkey.c @@ -22,12 +22,12 @@ #include #include #include +#include #include #include #define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey" -#define TM2_TOUCHKEY_KEYCODE_REG 0x03 -#define TM2_TOUCHKEY_BASE_REG 0x00 + #define TM2_TOUCHKEY_CMD_LED_ON 0x10 #define TM2_TOUCHKEY_CMD_LED_OFF 0x20 #define TM2_TOUCHKEY_BIT_PRESS_EV BIT(3) @@ -40,12 +40,28 @@ enum { TM2_TOUCHKEY_KEY_BACK, }; +struct touchkey_variant { + u8 keycode_reg; + u8 base_reg; +}; + struct tm2_touchkey_data { struct i2c_client *client; struct input_dev *input_dev; struct led_classdev led_dev; struct regulator *vdd; struct regulator_bulk_data regulators[2]; + const struct touchkey_variant *variant; +}; + +static const struct touchkey_variant tm2_touchkey_variant = { + .keycode_reg = 0x03, + .base_reg = 0x00, +}; + +static const struct touchkey_variant midas_touchkey_variant = { + .keycode_reg = 0x00, + .base_reg = 0x00, }; static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev, @@ -66,7 +82,7 @@ static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev, regulator_set_voltage(touchkey->vdd, volt, volt); i2c_smbus_write_byte_data(touchkey->client, - TM2_TOUCHKEY_BASE_REG, data); + touchkey->variant->base_reg, data); } static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey) @@ -99,7 +115,7 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid) int key; data = i2c_smbus_read_byte_data(touchkey->client, - TM2_TOUCHKEY_KEYCODE_REG); + touchkey->variant->keycode_reg); if (data < 0) { dev_err(&touchkey->client->dev, "failed to read i2c data: %d\n", data); @@ -153,6 +169,8 @@ static int tm2_touchkey_probe(struct i2c_client *client, touchkey->client = client; i2c_set_clientdata(client, touchkey); + touchkey->variant = of_device_get_match_data(&client->dev); + touchkey->regulators[0].supply = "vcc"; touchkey->regulators[1].supply = "vdd"; error = devm_regulator_bulk_get(&client->dev, @@ -262,7 +280,13 @@ static const struct i2c_device_id tm2_touchkey_id_table[] = { MODULE_DEVICE_TABLE(i2c, tm2_touchkey_id_table); static const struct of_device_id tm2_touchkey_of_match[] = { - { .compatible = "cypress,tm2-touchkey", }, + { + .compatible = "cypress,tm2-touchkey", + .data = &tm2_touchkey_variant, + }, { + .compatible = "cypress,midas-touchkey", + .data = &midas_touchkey_variant, + }, { }, }; MODULE_DEVICE_TABLE(of, tm2_touchkey_of_match); From patchwork Mon Jan 7 18:53:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Chmiel?= X-Patchwork-Id: 10751097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16D461399 for ; Mon, 7 Jan 2019 18:55:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 064CB289A0 for ; Mon, 7 Jan 2019 18:55:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE708289AA; Mon, 7 Jan 2019 18:55:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FACE289A0 for ; Mon, 7 Jan 2019 18:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728187AbfAGSyM (ORCPT ); Mon, 7 Jan 2019 13:54:12 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:40595 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727751AbfAGSyL (ORCPT ); Mon, 7 Jan 2019 13:54:11 -0500 Received: by mail-lf1-f65.google.com with SMTP id v5so1077445lfe.7; Mon, 07 Jan 2019 10:54:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/MiFsFGxkATaKSohAbLvhLUzl5KdlriZpggnL4SZpos=; b=Ih4XoQZxHUGN1rypAdEa0zF7Ux6jV0VUOslQNrC/pk+uUVtF+auHbG7Tsxwv55kf2m m2iTpffFMAAsY7PEq8z5m689Ph0CdUD6LTrPdSoccZgePeody1kt4MEXEonkNm9ilibt 4xuZUfooFza+KP1jd0WcbwrADVX8JFKOd13KmSlyC8ISwnLbdPq3RFnO5FvlPja/lTmf cmz0IYqcAIBFOkeREpetXhHyYlnuQZg5MMTX+678mytKmZHJWN0+YRckVZrJeMKm8tRm jV5Pr1cK6MqcpJslHuHLvaw7BZrIWHh7BzLixhZkbES2KFD+oKp2yNg/27vYfXEtItno 31Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/MiFsFGxkATaKSohAbLvhLUzl5KdlriZpggnL4SZpos=; b=UfzMm0WO7OsLmCnA5AEE+TdUYzwxyUTlMReliWfVF5mpNI8/IcHy+SImp8bfKaioDy 6mB44/GxRMpyuyxpdSbLh7jIz5Qv24gAk5Hws8Mh9I/Cwxd7qXi18LphY7dTc3xjvis2 7ecssMlNq+vYuh83LbTX/8lTBmSAgEHUURgskh6UBRFghawrGcD6EJeDZTLB1U3WpEyL iOt/cH0c4KUJYYSLWV/LoLkWTVbs7dSahIvp95FdCR37Uhngmuwyn0iD73hXce1l0KTf V0dg13qfgX9i23gU1N0TiPQS7m4gvH86EeqWAXK3DQ38Ac6hly4FCubwA6GEoWHqdggR ImDg== X-Gm-Message-State: AA+aEWaTJSxht6AqDv37HUepJlpztbxVwxKvRfVIPh2hSrXRvmzzosnn ctX4OUq7pAXqfgAWqqfD8fA= X-Google-Smtp-Source: AFSGD/XjR0D7IOEvwqPXopBEC64JE6jDaNXu2IWK+m4qAi6NcZlu47BYeDTudNwq3mKjGaqHHvOL9Q== X-Received: by 2002:a19:9508:: with SMTP id x8mr32213693lfd.112.1546887248599; Mon, 07 Jan 2019 10:54:08 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:c050:d453:6c2:1d01]) by smtp.googlemail.com with ESMTPSA id h203sm12825007lfe.44.2019.01.07.10.54.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 10:54:08 -0800 (PST) From: =?utf-8?q?Pawe=C5=82_Chmiel?= To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, pawel.mikolaj.chmiel@gmail.com, xc-racer2@live.ca, simon@lineageos.org Subject: [PATCH v3 2/7] Input: dt-bindings: tm2-touchkey: Add support for midas touchkey Date: Mon, 7 Jan 2019 19:53:41 +0100 Message-Id: <20190107185346.30184-3-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> References: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Simon Shields Document compatible for midas touchkey. Signed-off-by: Simon Shields Signed-off-by: Paweł Chmiel Reviewed-by: Rob Herring --- Changes from v1: - Added Reviewed-by --- .../devicetree/bindings/input/cypress,tm2-touchkey.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt index 0c252d9306da..dfb3b9f0ee40 100644 --- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt +++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt @@ -1,7 +1,9 @@ Samsung tm2-touchkey Required properties: -- compatible: must be "cypress,tm2-touchkey" +- compatible: + * "cypress,tm2-touchkey" - for the touchkey found on the tm2 board + * "cypress,midas-touchkey" - for the touchkey found on midas boards - reg: I2C address of the chip. - interrupts: interrupt to which the chip is connected (see interrupt binding[0]). From patchwork Mon Jan 7 18:53:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Chmiel?= X-Patchwork-Id: 10751099 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 971E16C5 for ; Mon, 7 Jan 2019 18:55:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 839EA289A0 for ; Mon, 7 Jan 2019 18:55:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73DA4289AA; Mon, 7 Jan 2019 18:55:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24D85289A0 for ; Mon, 7 Jan 2019 18:55:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728548AbfAGSzA (ORCPT ); Mon, 7 Jan 2019 13:55:00 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:45122 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbfAGSyM (ORCPT ); Mon, 7 Jan 2019 13:54:12 -0500 Received: by mail-lf1-f67.google.com with SMTP id b20so1051152lfa.12; Mon, 07 Jan 2019 10:54:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x/c+ISyiSRiDIt4sidmbC1nUvxvjzDpzrqa5uzk8AQg=; b=vbJQS5dHja6YT2ONoe/Mhb6vzDvAyxh9NS28mxwDuNmn1cB3OJYGD7d9t1LOpTVAts UViZKsHR0nM6HXwdbWS6W66ecCgt+AZjZ4looIOnVzqzMJHykOOFJGMEbIsqtyxIh3g8 X5RQssjaLq62I5KWHbxcHoUX1hGudzShybVf1yFOoMKUcfnQQfJjSazif/ABw88CPz2g LwhrfUq3MiNSyWSOvz/E6BVxar2N+4ocP5/AU1ccrK7ozzyIpywiyKMXD4OS3JekXL1j KAZjC5Ix0ZokYwFd8xC6LQNNhe41lWw/zju2dUtB3vAJuQbh5ijGqBxmOqbD13zJpyCQ DSrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x/c+ISyiSRiDIt4sidmbC1nUvxvjzDpzrqa5uzk8AQg=; b=thi5+RU7EQOY8DauI5wVhXxW6QDfIEVn/+1Exk1+rrj13+CdYDrLzbK+EriB4Fquz/ bdus30BjzvITJDgoF/Qd7zX7EwsA/DvDEqOj4btDy2g1Ls/72ETM/sB0RgOUZ4tqvqkz /ZPGM9VtbT0JtQsKFZRX2j/f4fXp9ZRgYb3MelIwgDQlcTqVvZQc3JdsnK2qqIhkivSX av6g1tFgApZKwYOjfkzc1WoURFr5LC8BhOqzjNgXY6k1765/uoz62GKAYxBJ++LF82VL g3H8wkDKx01eSa9Z5txbOhGi82CS3j+PZ5yrCtAthPLwSvsLdut1/RROpoxQY0F5bdta ZpYA== X-Gm-Message-State: AA+aEWZVJo8sTIHBRAJytcSz++6QX0a7WQ3KMUIJZ5sR5FYlcj57kSQk Cc+3Dpk5IzS+kqwOtpmydLQ= X-Google-Smtp-Source: AFSGD/WSJ2p1LaR7WA9g/hsMkElJipef5Ine2e8s08YHiWNT6TN+Kp+KXCGOfzXUM9yDnJ9g0Unjng== X-Received: by 2002:a19:1a14:: with SMTP id a20mr29588891lfa.1.1546887250145; Mon, 07 Jan 2019 10:54:10 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:c050:d453:6c2:1d01]) by smtp.googlemail.com with ESMTPSA id h203sm12825007lfe.44.2019.01.07.10.54.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 10:54:09 -0800 (PST) From: =?utf-8?q?Pawe=C5=82_Chmiel?= To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, pawel.mikolaj.chmiel@gmail.com, xc-racer2@live.ca, simon@lineageos.org Subject: [PATCH v3 3/7] Input: tm2-touchkey: Correct initial brightness Date: Mon, 7 Jan 2019 19:53:42 +0100 Message-Id: <20190107185346.30184-4-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> References: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jonathan Bakker Tm2-touchkey don't have brightness levels, but only on/off states, so replace LED_FULL with LED_ON. Signed-off-by: Jonathan Bakker Signed-off-by: Paweł Chmiel --- drivers/input/keyboard/tm2-touchkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c index 5a1fe08bdd76..0336789ab1bb 100644 --- a/drivers/input/keyboard/tm2-touchkey.c +++ b/drivers/input/keyboard/tm2-touchkey.c @@ -230,7 +230,7 @@ static int tm2_touchkey_probe(struct i2c_client *client, /* led device */ touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME; - touchkey->led_dev.brightness = LED_FULL; + touchkey->led_dev.brightness = LED_ON; touchkey->led_dev.max_brightness = LED_ON; touchkey->led_dev.brightness_set = tm2_touchkey_led_brightness_set; From patchwork Mon Jan 7 18:53:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Chmiel?= X-Patchwork-Id: 10751095 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 353831399 for ; Mon, 7 Jan 2019 18:54:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 251EE289A0 for ; Mon, 7 Jan 2019 18:54:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1644A289AA; Mon, 7 Jan 2019 18:54:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 904B9289A0 for ; Mon, 7 Jan 2019 18:54:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727037AbfAGSyv (ORCPT ); Mon, 7 Jan 2019 13:54:51 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41467 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728146AbfAGSyO (ORCPT ); Mon, 7 Jan 2019 13:54:14 -0500 Received: by mail-lj1-f194.google.com with SMTP id k15-v6so1241754ljc.8; Mon, 07 Jan 2019 10:54:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xZHCO4PB5R9mGa0HRcFdo1+yp8HDWMwNcsydZLbmBsI=; b=rfi74SVx0nA3nKa8vxqpibbOjUMjwV2TmnFNRpSZglZhZrcIxN66MsUdKKGV1ZMg7P CCSEzVj2jMW10uIRHASbf5dNAIblAgXMVoXweorBGHgAQUH+HlrHkDWr7cHktUa7pSRw y41ClJlV/HHGgy0jCi4MjTha4LzrLep1DU8+MwQy8hp22l0Cr54W8RgNgscJvztgZKG1 W4xP0ARSqzBzZtXx5sBmRpCCY2SdCJnNVmvcrx37fwXluKpUVOjQQv/KaC8B1SIKs2r2 Ki5monsCpBsJz5tP/7cDtHxNPZrmzFwjbiYU4pcNINFIZHGFnk2gOfDuxjYyuX8zcTRM 8Z2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xZHCO4PB5R9mGa0HRcFdo1+yp8HDWMwNcsydZLbmBsI=; b=s+A5lW8FdKI4phVWv97MLGZVhzQqtflZU87i1Qn1oIW8xKbsaeVeBaStt47HhyP9fP ReXkfb7bKkERhlCT4nozElbrrFvencwL8gG/UeeWnaIn1pVA03OSx+TiyWik2jJ6PgjX um9h4KPT0t+ccaqsuJA4eEcI+pzy8lvFbe/zwpfKJ4WCRvwUiCtyVQNr2vIT1VGAvrj8 oHFZGq6PSbiHSvdXBzqNL47P9nCa8bk9OZdtM1woFxPQdYbL2xiNfm+IEGaNKK241E0B 4/LdT0JyCFzx+MaqaaR7jcJHdHu6L1DtF/Wru+RAQ8AERYWvHFu2KRtLoN77guBaAzmo wkHw== X-Gm-Message-State: AJcUukd4QbcOrICLcd2VGYVXtzMM765ddN92v8CZAbcD0s+TVKeDL1X6 YH81VFGv/8qx4/rGkQ8SgLSx7ZJOgvrACw== X-Google-Smtp-Source: ALg8bN488wK0WUXnAUY4jT9OiSxYuCxI2tVms568V2aBMZtSTBajvIspNIZbkAoK6w6LejBXJpHyAA== X-Received: by 2002:a2e:80d3:: with SMTP id r19-v6mr33696307ljg.151.1546887251525; Mon, 07 Jan 2019 10:54:11 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:c050:d453:6c2:1d01]) by smtp.googlemail.com with ESMTPSA id h203sm12825007lfe.44.2019.01.07.10.54.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 10:54:10 -0800 (PST) From: =?utf-8?q?Pawe=C5=82_Chmiel?= To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, pawel.mikolaj.chmiel@gmail.com, xc-racer2@live.ca, simon@lineageos.org Subject: [PATCH v3 4/7] Input: tm2-touchkey: Allow specifying custom keycodes Date: Mon, 7 Jan 2019 19:53:43 +0100 Message-Id: <20190107185346.30184-5-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> References: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jonathan Bakker Not all devices use the same keycodes in the same order, so add possibility to define keycodes for buttons present on actual hardware. If keycodes property is not present, we assume that device has at least MENU and BACK keys. Signed-off-by: Jonathan Bakker Signed-off-by: Paweł Chmiel --- Changes from v2: - Change property name from keycodes to linux,keycodes Changes from v1: - Because key codes could be bigger than 255, use ints for keycodes --- drivers/input/keyboard/tm2-touchkey.c | 49 +++++++++++++++------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c index 0336789ab1bb..b55faf597d8a 100644 --- a/drivers/input/keyboard/tm2-touchkey.c +++ b/drivers/input/keyboard/tm2-touchkey.c @@ -35,11 +35,6 @@ #define TM2_TOUCHKEY_LED_VOLTAGE_MIN 2500000 #define TM2_TOUCHKEY_LED_VOLTAGE_MAX 3300000 -enum { - TM2_TOUCHKEY_KEY_MENU = 0x1, - TM2_TOUCHKEY_KEY_BACK, -}; - struct touchkey_variant { u8 keycode_reg; u8 base_reg; @@ -52,6 +47,8 @@ struct tm2_touchkey_data { struct regulator *vdd; struct regulator_bulk_data regulators[2]; const struct touchkey_variant *variant; + u32 keycodes[4]; + int num_keycodes; }; static const struct touchkey_variant tm2_touchkey_variant = { @@ -112,7 +109,8 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid) { struct tm2_touchkey_data *touchkey = devid; int data; - int key; + int index; + int i; data = i2c_smbus_read_byte_data(touchkey->client, touchkey->variant->keycode_reg); @@ -122,26 +120,20 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid) goto out; } - switch (data & TM2_TOUCHKEY_BIT_KEYCODE) { - case TM2_TOUCHKEY_KEY_MENU: - key = KEY_PHONE; - break; - - case TM2_TOUCHKEY_KEY_BACK: - key = KEY_BACK; - break; - - default: + index = (data & TM2_TOUCHKEY_BIT_KEYCODE) - 1; + if (index < 0 || index >= touchkey->num_keycodes) { dev_warn(&touchkey->client->dev, - "unhandled keycode, data %#02x\n", data); + "invalid keycode index %d\n", index); goto out; } if (data & TM2_TOUCHKEY_BIT_PRESS_EV) { - input_report_key(touchkey->input_dev, KEY_PHONE, 0); - input_report_key(touchkey->input_dev, KEY_BACK, 0); + for (i = 0; i < touchkey->num_keycodes; i++) + input_report_key(touchkey->input_dev, + touchkey->keycodes[i], 0); } else { - input_report_key(touchkey->input_dev, key, 1); + input_report_key(touchkey->input_dev, + touchkey->keycodes[index], 1); } input_sync(touchkey->input_dev); @@ -153,8 +145,10 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid) static int tm2_touchkey_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct device_node *np = client->dev.of_node; struct tm2_touchkey_data *touchkey; int error; + int i; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA)) { @@ -184,6 +178,16 @@ static int tm2_touchkey_probe(struct i2c_client *client, /* Save VDD for easy access */ touchkey->vdd = touchkey->regulators[1].consumer; + touchkey->num_keycodes = of_property_read_variable_u32_array(np, + "linux,keycodes", touchkey->keycodes, 0, + ARRAY_SIZE(touchkey->keycodes)); + if (touchkey->num_keycodes <= 0) { + /* default keycodes */ + touchkey->keycodes[0] = KEY_PHONE; + touchkey->keycodes[1] = KEY_BACK; + touchkey->num_keycodes = 2; + } + error = tm2_touchkey_power_enable(touchkey); if (error) { dev_err(&client->dev, "failed to power up device: %d\n", error); @@ -208,8 +212,9 @@ static int tm2_touchkey_probe(struct i2c_client *client, touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME; touchkey->input_dev->id.bustype = BUS_I2C; - input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE); - input_set_capability(touchkey->input_dev, EV_KEY, KEY_BACK); + for (i = 0; i < touchkey->num_keycodes; i++) + input_set_capability(touchkey->input_dev, EV_KEY, + touchkey->keycodes[i]); error = input_register_device(touchkey->input_dev); if (error) { From patchwork Mon Jan 7 18:53:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Chmiel?= X-Patchwork-Id: 10751093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7376C6C5 for ; Mon, 7 Jan 2019 18:54:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63294289A0 for ; Mon, 7 Jan 2019 18:54:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5654B289AA; Mon, 7 Jan 2019 18:54:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A0E1289A0 for ; Mon, 7 Jan 2019 18:54:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727048AbfAGSyP (ORCPT ); Mon, 7 Jan 2019 13:54:15 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:46226 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728254AbfAGSyP (ORCPT ); Mon, 7 Jan 2019 13:54:15 -0500 Received: by mail-lj1-f193.google.com with SMTP id v15-v6so1218679ljh.13; Mon, 07 Jan 2019 10:54:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PDHMr/fiYRXHunVviW84NpOBn4IvlCGGXSsFuynM5YY=; b=MUjx7LlYA3CmLu1+6uDKq8/02Cz388/IhEAw4lX7xrpO+JJmihZrCRHrdTkgO89naM 50tf1Fd/pSeFSDf/t/uj+AJiCiSPKDEbPN82WSnR6SFe/3MjoT6yfCiQKTzq/0k/oHtV GbWWB6uOfbrJBXwGwWB8+HkORR1kQY2JubgptuXCeKRP/egZqvcxBBsSqLRqwTWyUna+ apabiBykcC30nn+gSGIHcAJnrLSo9PmccLloO0u9pLAE9LT3F8eeuvVONIvIx40NA2st fL2vPOfLsY7qBg84ztunF+wRzyWpJxQCZkjjjr/AtB2LLTctOtdYaq16Dh0Af+LVo+8E dNxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PDHMr/fiYRXHunVviW84NpOBn4IvlCGGXSsFuynM5YY=; b=pJ/C0TfycbUXGmyPCtP26+9FZeXCzYYhuPvII/CqG8j69cBc9KthTJMpYnuvAraaDr Hsos/VrBThRlgNOuAQ4zvHMS1eMgmOVmD8v9r+lP0IFKoRb1zRlxxZ8G0fMk6LwgtCIp 2VoH5n9/VB6RpCs0Kyy5g3Q4DKCThBWvVasEDxLyy+H6AhkdoxkLr+hS9kX1BWlaPfJM qLbaqSEpsJOiFkZ4SdTaaNPck4XVMckXtwP7aw7tzyHH5koAK7PBYnRrf+Ns7r3/Cb/6 QTSZmQvNP9awaCkB7td6sYC2yILs57d2Hf3JFAHipAFVJYbThvwqlV22RzLKREooJLpa /UgQ== X-Gm-Message-State: AJcUukeKMIMhaufzE0spIkGNc5z4f+ytcQ/31a8G1UC6Rmq6yIsQggiM TKHw7iFoDOFIVidsckjeYRI= X-Google-Smtp-Source: ALg8bN6jymLTId+oLs5XuW1fhzw+GHD7NNJCYuiWbTP9PgU06np0XNegP7VMENDyklVLT7UeWlA7UQ== X-Received: by 2002:a2e:1f01:: with SMTP id f1-v6mr33064543ljf.129.1546887252979; Mon, 07 Jan 2019 10:54:12 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:c050:d453:6c2:1d01]) by smtp.googlemail.com with ESMTPSA id h203sm12825007lfe.44.2019.01.07.10.54.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 10:54:12 -0800 (PST) From: =?utf-8?q?Pawe=C5=82_Chmiel?= To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, pawel.mikolaj.chmiel@gmail.com, xc-racer2@live.ca, simon@lineageos.org Subject: [PATCH v3 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property Date: Mon, 7 Jan 2019 19:53:44 +0100 Message-Id: <20190107185346.30184-6-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> References: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jonathan Bakker Document new optional property for setting custom keycodes. Signed-off-by: Jonathan Bakker Signed-off-by: Paweł Chmiel Reviewed-by: Rob Herring --- Changes from v2: - Change property name from keycodes to linux,keycodes Changes from v1: - Because key codes could be bigger than 255, use ints for keycodes --- .../devicetree/bindings/input/cypress,tm2-touchkey.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt index dfb3b9f0ee40..8ef1517c0220 100644 --- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt +++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt @@ -10,6 +10,9 @@ Required properties: - vcc-supply : internal regulator output. 1.8V - vdd-supply : power supply for IC 3.3V +Optional properties: +- linux,keycodes: array of keycodes (max 4), default KEY_PHONE and KEY_BACK + [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt Example: @@ -23,5 +26,6 @@ Example: interrupts = <2 IRQ_TYPE_EDGE_FALLING>; vcc-supply=<&ldo32_reg>; vdd-supply=<&ldo33_reg>; + linux,keycodes = ; }; }; From patchwork Mon Jan 7 18:53:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Chmiel?= X-Patchwork-Id: 10751091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB4141399 for ; Mon, 7 Jan 2019 18:54:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC1E5289A9 for ; Mon, 7 Jan 2019 18:54:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0C14289AA; Mon, 7 Jan 2019 18:54:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54706289B0 for ; Mon, 7 Jan 2019 18:54:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728326AbfAGSyR (ORCPT ); Mon, 7 Jan 2019 13:54:17 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37970 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727434AbfAGSyR (ORCPT ); Mon, 7 Jan 2019 13:54:17 -0500 Received: by mail-lf1-f66.google.com with SMTP id a8so1080479lfk.5; Mon, 07 Jan 2019 10:54:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L4bb9ndCPhJNyXeb/1qH8VH7BbvWrL2P/9iDLwRWQao=; b=DOuNbKzoEJ4J2WByL1LbHQ6BAwdFPdYnrvmg5arzhf6wbMqN7br8UaCx83hWLBGUhc Lf6WLg1iQ9tTRXYU843vm5hg7UTyi9TaMM1jBVEtQxcv93ANTpnz9v6VD2Ro2RHDoq+4 9a/iHl3jew/l/rYfy5kDGR7om65Grxijf7e1dZlNATvaRW18Ayte6iV8MLkGNyXPGvVC yd2qs8IyWvtNwDdlraFJFATutR0USTYkK4vFrkhVCMAy/8DTfOZz6ISKsvobJltYSkVE Yv8WPIwj8HsuqN82X94pd/CPpe/AcJEhYTGc1pVeZ/VKtp/WGa/t/jJlS716FQppRcAN GvEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L4bb9ndCPhJNyXeb/1qH8VH7BbvWrL2P/9iDLwRWQao=; b=nI3kjRzfWJYGeTAmcJemwDms1UFvqrts++7rimUfhvHN13sV55F5aFaZb0sZzdFUM/ f9J+RLNYDma6HxOBDT5odX2QEpdGopUnVZEAqLrxm3UATQMp57rptZENnA6c9c8YZIZD jXlk+Udqe5aBnGZcNyLJVM3XqtHP6vJMLD9VA9XNm4m39cdVmDnDd6/z8BqM6iwDcnVK 4qDnqVY8slm3wD8Z4GXf4TxtBl6/aq+gmf7/KhZFpW+tUghc5LcKZBvWcnM8is/q5+vq azg1SSf0oR4C0eurwPFxSvenLALLX7DNoe84X39X7R/H1XAjCtW+CWccMffDnlEBCPd/ LQqQ== X-Gm-Message-State: AA+aEWaFrSl9Bp7eCwxCZlhhlJPBxlJ3n5hpl9BQv6rHPU5rA/IyPRtL 9OZ4KNjH7ZlrKZ4MdzLt/rc= X-Google-Smtp-Source: AFSGD/VBySk+MsMdzrrfiAepo+XTanHwE4mhojMVa1Rny72WvW6WppS6u0zLKImuj0Boz/vwfisRkA== X-Received: by 2002:a19:d90c:: with SMTP id q12mr29896473lfg.24.1546887254272; Mon, 07 Jan 2019 10:54:14 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:c050:d453:6c2:1d01]) by smtp.googlemail.com with ESMTPSA id h203sm12825007lfe.44.2019.01.07.10.54.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 10:54:13 -0800 (PST) From: =?utf-8?q?Pawe=C5=82_Chmiel?= To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, pawel.mikolaj.chmiel@gmail.com, xc-racer2@live.ca, simon@lineageos.org Subject: [PATCH v3 6/7] Input: tm2-touchkey: Add support for aries touchkey variant Date: Mon, 7 Jan 2019 19:53:45 +0100 Message-Id: <20190107185346.30184-7-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> References: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jonathan Bakker The touchkey variant found on aries board is slighty different, it uses a fixed regulator and writes/read to the same place Signed-off-by: Jonathan Bakker Signed-off-by: Paweł Chmiel --- drivers/input/keyboard/tm2-touchkey.c | 53 +++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c index b55faf597d8a..7dbef96559d2 100644 --- a/drivers/input/keyboard/tm2-touchkey.c +++ b/drivers/input/keyboard/tm2-touchkey.c @@ -28,6 +28,8 @@ #define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey" +#define ARIES_TOUCHKEY_CMD_LED_ON 0x1 +#define ARIES_TOUCHKEY_CMD_LED_OFF 0x2 #define TM2_TOUCHKEY_CMD_LED_ON 0x10 #define TM2_TOUCHKEY_CMD_LED_OFF 0x20 #define TM2_TOUCHKEY_BIT_PRESS_EV BIT(3) @@ -38,6 +40,10 @@ struct touchkey_variant { u8 keycode_reg; u8 base_reg; + u8 cmd_led_on; + u8 cmd_led_off; + bool no_reg; + bool fixed_regulator; }; struct tm2_touchkey_data { @@ -54,11 +60,22 @@ struct tm2_touchkey_data { static const struct touchkey_variant tm2_touchkey_variant = { .keycode_reg = 0x03, .base_reg = 0x00, + .cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON, + .cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF, }; static const struct touchkey_variant midas_touchkey_variant = { .keycode_reg = 0x00, .base_reg = 0x00, + .cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON, + .cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF, +}; + +static struct touchkey_variant aries_touchkey_variant = { + .no_reg = true, + .fixed_regulator = true, + .cmd_led_on = ARIES_TOUCHKEY_CMD_LED_ON, + .cmd_led_off = ARIES_TOUCHKEY_CMD_LED_OFF, }; static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev, @@ -71,15 +88,20 @@ static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev, if (brightness == LED_OFF) { volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN; - data = TM2_TOUCHKEY_CMD_LED_OFF; + data = touchkey->variant->cmd_led_off; } else { volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX; - data = TM2_TOUCHKEY_CMD_LED_ON; + data = touchkey->variant->cmd_led_on; } - regulator_set_voltage(touchkey->vdd, volt, volt); - i2c_smbus_write_byte_data(touchkey->client, - touchkey->variant->base_reg, data); + if (!touchkey->variant->fixed_regulator) + regulator_set_voltage(touchkey->vdd, volt, volt); + + if (touchkey->variant->no_reg) + i2c_smbus_write_byte(touchkey->client, data); + else + i2c_smbus_write_byte_data(touchkey->client, + touchkey->variant->base_reg, data); } static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey) @@ -112,8 +134,11 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid) int index; int i; - data = i2c_smbus_read_byte_data(touchkey->client, - touchkey->variant->keycode_reg); + if (touchkey->variant->no_reg) + data = i2c_smbus_read_byte(touchkey->client); + else + data = i2c_smbus_read_byte_data(touchkey->client, + touchkey->variant->keycode_reg); if (data < 0) { dev_err(&touchkey->client->dev, "failed to read i2c data: %d\n", data); @@ -139,6 +164,14 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid) input_sync(touchkey->input_dev); out: + if (touchkey->variant->fixed_regulator && + data & TM2_TOUCHKEY_BIT_PRESS_EV) { + /* touch turns backlight on, so make sure we're in sync */ + if (touchkey->led_dev.brightness == LED_OFF) + tm2_touchkey_led_brightness_set(&touchkey->led_dev, + LED_OFF); + } + return IRQ_HANDLED; } @@ -246,6 +279,9 @@ static int tm2_touchkey_probe(struct i2c_client *client, return error; } + if (touchkey->variant->fixed_regulator) + tm2_touchkey_led_brightness_set(&touchkey->led_dev, LED_ON); + return 0; } @@ -291,6 +327,9 @@ static const struct of_device_id tm2_touchkey_of_match[] = { }, { .compatible = "cypress,midas-touchkey", .data = &midas_touchkey_variant, + }, { + .compatible = "cypress,aries-touchkey", + .data = &aries_touchkey_variant, }, { }, }; From patchwork Mon Jan 7 18:53:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Chmiel?= X-Patchwork-Id: 10751089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7AFB86C5 for ; Mon, 7 Jan 2019 18:54:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69282289AA for ; Mon, 7 Jan 2019 18:54:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 588A2289A9; Mon, 7 Jan 2019 18:54:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00B96289A9 for ; Mon, 7 Jan 2019 18:54:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727176AbfAGSy0 (ORCPT ); Mon, 7 Jan 2019 13:54:26 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46231 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728314AbfAGSyS (ORCPT ); Mon, 7 Jan 2019 13:54:18 -0500 Received: by mail-lj1-f194.google.com with SMTP id v15-v6so1218798ljh.13; Mon, 07 Jan 2019 10:54:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t705wjl/OuJqESix5qpnaG3nZBnidSIcHveU5yicvAM=; b=i+z9H0/vLgwaOxNSAfQPaYYVipVrcgDKztGEOswsgqQQAEY/PVRC2o0lJ02CNpakow 6Ql+usoSxk2IkJKrOgyjFUoRuuA8VCMa9EgYV/cXtzpisBPJYuy9ju336kYexW+zyOTr kOYO5jJui/+4S1Q/K4/B+PEGrJO2wjc+3Jl7Z9b7mY5vnTmDaq9ElF79iBMoeJalxbeM Lbfx5Nnm0FciH7Hme3J/gXZFhOhz2TZATC8R4WIxNfVh1y5CXsivr5xQD0d0OTg+GHKf iNZlV6K3y7hYUN44yE3QXZsha9gwFMxzHEr4D16nN/MuAx2rxZGeFoDKs27np8uwGos1 knpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t705wjl/OuJqESix5qpnaG3nZBnidSIcHveU5yicvAM=; b=fxCWrqzms9G2jDn86eI75H/QDKjMmm+7H98msP6BOY+KZrAfBwTALfjJXWZpmxCiCE 9UJO2csAXNBlB84C1UTG799kV2u17fUd2HuFEbPCMh7/XhfTvXhANw2q/S6HY63NdNie ZdjPTSG16LFiJaPdrXjCg+Jb1kkdBzmcrRveoYCaZ2j5L9RkSKo+4ZVLeNLOcoSvlMcM 3q7ZYBI/PMpMXhk8DNNlRXyaXLt6ElsMDMSQlJz1qj+mLzcRf4BovDQdsGIpOL7YHUNl 29Q9MOW2uG/Wifg+naloA8890XMKO6GmT8jGclOMmZ6Sj/e0+gYNJEPfY8jg3amdOSVI Oh/A== X-Gm-Message-State: AA+aEWaeasskzGQB03fNwy5ttuxGcwL93QNJfN9hF3dZSulQZtGnmHIe OR9poS1T+H5xRNMyzNQXKGo= X-Google-Smtp-Source: ALg8bN4ORBfmxaHjZ6qfzVy95hYXCeMuc7a3bObI4a0A6rlkb120H8SNlwy/fsGDzoiFGXWsE3yt6Q== X-Received: by 2002:a2e:9a84:: with SMTP id p4-v6mr33589514lji.73.1546887255780; Mon, 07 Jan 2019 10:54:15 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:c050:d453:6c2:1d01]) by smtp.googlemail.com with ESMTPSA id h203sm12825007lfe.44.2019.01.07.10.54.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 10:54:15 -0800 (PST) From: =?utf-8?q?Pawe=C5=82_Chmiel?= To: dmitry.torokhov@gmail.com Cc: robh+dt@kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, pawel.mikolaj.chmiel@gmail.com, xc-racer2@live.ca, simon@lineageos.org Subject: [PATCH v3 7/7] Input: dt-bindings: tm2-touchkey: Add support for aries touchkey Date: Mon, 7 Jan 2019 19:53:46 +0100 Message-Id: <20190107185346.30184-8-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> References: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jonathan Bakker Document compatible for aries touchkey. Signed-off-by: Jonathan Bakker Signed-off-by: Paweł Chmiel Reviewed-by: Rob Herring --- Changes from v1: - Added Reviewed-by --- Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt index 8ef1517c0220..ef2ae729718f 100644 --- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt +++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt @@ -4,6 +4,7 @@ Required properties: - compatible: * "cypress,tm2-touchkey" - for the touchkey found on the tm2 board * "cypress,midas-touchkey" - for the touchkey found on midas boards + * "cypress,aries-touchkey" - for the touchkey found on aries boards - reg: I2C address of the chip. - interrupts: interrupt to which the chip is connected (see interrupt binding[0]).