From patchwork Fri Dec 28 15:46:03 2018 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: 10744537 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 7B4D46C5 for ; Fri, 28 Dec 2018 15:47:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DA49287BA for ; Fri, 28 Dec 2018 15:47:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6220928BBE; Fri, 28 Dec 2018 15:47:04 +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 E9A79287BA for ; Fri, 28 Dec 2018 15:47:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732634AbeL1PqU (ORCPT ); Fri, 28 Dec 2018 10:46:20 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45637 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732458AbeL1PqS (ORCPT ); Fri, 28 Dec 2018 10:46:18 -0500 Received: by mail-lj1-f194.google.com with SMTP id s5-v6so18975329ljd.12; Fri, 28 Dec 2018 07:46:17 -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=j6ZWnpzaUE8IsVW8h95j1dgurX0cQUReZzv2NKRSV7cf4NRV5B8nZfLW6AatBXxXRT 5C/0YgWiZh2V9Y3znq63LfxsWHRZPgCvJ3PPn6yxioEzkatf8sEeJ28vwceX1MjfFC15 48aWlPJwD/oyOs92FaOCdsi31+Sa+JGuFhQOJgoTkHwZe01h+VnHYLTOb2Dtsj9Qsnea /YfQz1/E2NwZYgK45OSr8RN9dFkIB7t6HebWLPGxygMgZJw4dncCakRiigO1QmcHl5RK dz3KpMPFqpjY2CUwqipXRAilh25Z/zEO6sYPFMDY4zAB7aVrI49YJJnAEiiAZU6Wwvv9 DbCw== 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=t6K6VGFL/GYGvtWjUL0f0cvRSafxB/N9lI8d1vzJFcjZBbwppT3+vHDXxUQol6VIGx E2knfgatCiAgNOtrVYPjbC1Z5dfmQ21uyKx09Em312Khs7SrJSX+tmd4wqho2ye6Q0Ey 4LBODQAzj/IXsFe7jFjxZA3BBq8OKOu9LAGQZE1rebOXsXd06qtBdDi9aOioiXFC4HZQ 5RPdDKbEpamwJf9CWqEtAp8OGCg3wctKNP4M1KNpoXktMTitegIWelN8xIuQ7Myeylky lZCGKWbBM4AhVPiNR7KB1pRHMj/Le9fFF8dDS0H3Vf7OIPAzRbjlmrAPWswOokGZynq/ Fg+Q== X-Gm-Message-State: AJcUukfcXPyrY1+efzkhjwUDleKKX1/p+Egy0GB0wFfiXQAtt0Q5geNY H8bPC/pQBzS91J639Out46s= X-Google-Smtp-Source: ALg8bN7cJwfUs/UJIpQBrXMTgtXzFnvSjLpmGnxFBBB1U1BftQVtaNZIqAUouRwtXYnHx4WYWxo7KA== X-Received: by 2002:a2e:8719:: with SMTP id m25-v6mr17777397lji.121.1546011976515; Fri, 28 Dec 2018 07:46:16 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:7146:fd07:48ff:9665]) by smtp.googlemail.com with ESMTPSA id c203sm8042444lfe.95.2018.12.28.07.46.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Dec 2018 07:46: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 v2 1/7] Input: tm2-touchkey: Add support for midas touchkey Date: Fri, 28 Dec 2018 16:46:03 +0100 Message-Id: <20181228154609.14846-2-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181228154609.14846-1-pawel.mikolaj.chmiel@gmail.com> References: <20181228154609.14846-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 Fri Dec 28 15:46:04 2018 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: 10744535 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 BC8E76C5 for ; Fri, 28 Dec 2018 15:47:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF496287BA for ; Fri, 28 Dec 2018 15:47:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A31A028BBE; Fri, 28 Dec 2018 15:47:02 +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 497D1287BA for ; Fri, 28 Dec 2018 15:47:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732852AbeL1PqV (ORCPT ); Fri, 28 Dec 2018 10:46:21 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:39171 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727018AbeL1PqV (ORCPT ); Fri, 28 Dec 2018 10:46:21 -0500 Received: by mail-lj1-f195.google.com with SMTP id t9-v6so19014320ljh.6; Fri, 28 Dec 2018 07:46:19 -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=QBEsTFj1Y0RrVTjpnYYTCEI/9zxEV2Sb8ho7kDc/lMKwzd9U1xHCE3pAJN6qiOE7nL qsl7UZEKYfqbhcGU89zJPFu1j3hs//kBS0GJ5xzd/GoeDOVFHlgN6kp82rNHH0ta9/sD Q3G48Vi9PhztXV+wRG1/EZvpF3EosXOU1J1EAayn+1vkeYbmz6VPZYGDzIFyqHOsK/3d DSbsJdhY3fAAAOyYkSyM2zGnALHgYwK5dNI/LM2jXrHNZKRe5BCxpOQf0YgNSnisEOUE w1lVjctGNIXhwmCQ6XxE4AOvZRb1nXhDJoexjj2Fgjh+QThEn16kI/atj+LZSH8SfHBD cpDA== 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=PRp5qG/H+oxzMh71d91bT/z7rT5mrd+XyME3ykIcDX4cUsiqi0hPlzHlLE/vtmxtLv peq5uvXDbB7KbpXFgDHIQE9V+u8kui4TfH0lBTdxKLdpmzaJqEwhyazsft4oCCpnubat szQQiKvfIpP82LDMxXQMalcJXrSzfO7K6qgXIYucHpkgyhWNWUQvMO0MW9MfzR9uiHvn 5AgXB52gYxQYFW9wqkWcq4KpPneLuFpGg2UqEf+ctBNlCNjaIqBlJhKUYQoGOkRKSWnt wvFunfmX5Cox+q+r9SaZt2nR0GyYvQARQ1oxaejG6ffQz/LxCV1PTHfqkzqILA/lqle5 hIXg== X-Gm-Message-State: AJcUukeNOjiMKMruRER9yfl9jOc12yhQxhpzmMxlMy0nCd6dpgIf3yop UW+1rygA5fdwBrPbveTl8wE= X-Google-Smtp-Source: ALg8bN7oIx5CBqajAjlaA1ReWwhrnshBSALFIqRZRZybSjSz8LnJZNlbfSvtB3COw1yNw1JQmojhfA== X-Received: by 2002:a2e:2b85:: with SMTP id r5-v6mr15862933ljr.91.1546011978429; Fri, 28 Dec 2018 07:46:18 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:7146:fd07:48ff:9665]) by smtp.googlemail.com with ESMTPSA id c203sm8042444lfe.95.2018.12.28.07.46.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Dec 2018 07:46:17 -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 v2 2/7] Input: dt-bindings: tm2-touchkey: Add support for midas touchkey Date: Fri, 28 Dec 2018 16:46:04 +0100 Message-Id: <20181228154609.14846-3-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181228154609.14846-1-pawel.mikolaj.chmiel@gmail.com> References: <20181228154609.14846-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 Fri Dec 28 15:46:05 2018 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: 10744533 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 6166413AD for ; Fri, 28 Dec 2018 15:46:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50049287BA for ; Fri, 28 Dec 2018 15:46:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4038028BBE; Fri, 28 Dec 2018 15:46: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 D1E98287BA for ; Fri, 28 Dec 2018 15:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732967AbeL1Pqx (ORCPT ); Fri, 28 Dec 2018 10:46:53 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:43394 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732696AbeL1PqW (ORCPT ); Fri, 28 Dec 2018 10:46:22 -0500 Received: by mail-lj1-f193.google.com with SMTP id q2-v6so18986861lji.10; Fri, 28 Dec 2018 07:46:20 -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=KgONh5LI5USOdOJ6deR/sjVqQrwYSNhOIx9RjfXsA9IQlndnSNJZm99gkZ7f1VGDmi 9wFYJJYo6dzoLFTf1Rtzo9Vccx6Nq1tb9kt0lrQDifdzsXGBNMnJj0lI8BYqtra4McOi P8N/AOpOblMQY68yWpO/aEE3zVdFL3gpbmCztwzD6N6it8O0nYhzsyWg6cuFd/UINlHS N0bH8rZ6vh28k6BZMNMzazAP8EUGpe9R+3vGLExMem0S1Ul47o6vI8MYiR0Nks92gwTe XWISxAlIPnxAYiF9oktsYSmn8rdf7LDsugTkeAGovcgx3R0Ee7slhj6q0QyPEDnJuGTl ZwLg== 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=GocpqE+PE3gg/r4AKC40wutDz91iWQ4jayLjCSe41Q+NGMsFmEdI7cVKSoV20qvA0l gLFldmAYy94Hvkskdcl4xK76w8bFumiWwN9LT6bPsMeLfBjRCFO7v539oHpxlkF8MWi7 Gvj7FeIjrBnqNoTwL9Wy7WqnLkMqQay+y00XNk97HGsJgsUY7coKxo5s2WM56b4tQnuT Y8bWHwhaDg6SGP13Y1UBQAUXM9GajIDPbTWvu5uCZbyG6kJMXMKRQWYjrH7OhVbAccXo 3FhwmSJmwiVdMZ909LyXgJ2m+SowkVyZTbqGUyI6MEn7oZCecVrMBsJXz5F0+VLxDeiU Q5Ig== X-Gm-Message-State: AJcUukdIb3pml1/v4c3ZkWZCQqgGHnxnwjeDc95yUqK+C5BiECxF79su aoEdmkJe1xL9TAbvcGqioc6Em2MVwd2zdg== X-Google-Smtp-Source: ALg8bN48aLT1MsWm8MLzesRbKovjRYcn8sZUL2D+IP9EimtSTUdOsriUXKanWTgDywcnSPv9Wxp/8Q== X-Received: by 2002:a2e:145a:: with SMTP id 26-v6mr16122839lju.116.1546011980006; Fri, 28 Dec 2018 07:46:20 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:7146:fd07:48ff:9665]) by smtp.googlemail.com with ESMTPSA id c203sm8042444lfe.95.2018.12.28.07.46.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Dec 2018 07:46:19 -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 v2 3/7] Input: tm2-touchkey: Correct initial brightness Date: Fri, 28 Dec 2018 16:46:05 +0100 Message-Id: <20181228154609.14846-4-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181228154609.14846-1-pawel.mikolaj.chmiel@gmail.com> References: <20181228154609.14846-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 Fri Dec 28 15:46:06 2018 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: 10744525 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 ECBAF13AD for ; Fri, 28 Dec 2018 15:46:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAB4B28BB6 for ; Fri, 28 Dec 2018 15:46:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C80C428BBE; Fri, 28 Dec 2018 15:46:27 +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 57FD2287BA for ; Fri, 28 Dec 2018 15:46:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732968AbeL1Pq0 (ORCPT ); Fri, 28 Dec 2018 10:46:26 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:40585 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732943AbeL1PqZ (ORCPT ); Fri, 28 Dec 2018 10:46:25 -0500 Received: by mail-lf1-f65.google.com with SMTP id v5so14778754lfe.7; Fri, 28 Dec 2018 07:46:22 -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=7TVTilf2im2mIwScoPJHnBUS9MY3MXep8YuucLBXaAE=; b=Pynw+y1g8O+tIUwrgImDqGBlTg80nCAOEP0Lnlg0OxrgRCBHOTV1uY/BM26zaq/MK3 DNavxyag+ZXiN7l1QOlS8Z0fp5FYZ+5ugY6RwATvb836rqDt9Q1DAYnEl0JqLsrk7SzE oc9zAUh4dkoSDZPTdyUbBoGMW/l+BJj5SgUL48Fx+gHPvFKDXeYv3kcN54pZtOWeazcF Mn9ZpyplqYx/k2Sz12IHZFOdthFdGwyKoRl12lTT7vhosaD8eRaiYGSy1fSdby3wiX1I L/kxF0ypuwxQybyhNKKzrZpspLFyboOo9E2J2SCsWcahlbaB/6qw7olqg+sdxUQW5HUw 1dNw== 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=7TVTilf2im2mIwScoPJHnBUS9MY3MXep8YuucLBXaAE=; b=daKgNKWVIBcNTyaAz1QK1YIIe7I+mZus9KTAq0/ZVjq6qAoMEIWFeR4DPiuHsLxm/U JMgDNJ638ixSFQc05sTPAb9zU0dwREH4HAeHGq+drQ3gvmXbGmIYeoaKxiRcXPWX5Lmu CzJ6pePLQOERrMdHB8i2cgwERBRJaUtpjBRKDB+rr6KBFtdciNTqzx2GphEzn75+KQ1g Pdg7Ys7XbaOHH2Nv5gJlH4+Bz5g/ZjV4xg1VX2x6lnreHhfoOLM0jBPTRqN+O9d8Bgf9 8d5on9Xwt1L/iJasK7PADwNwlOpJNz4kw4I0c+7PHQ0K5D4eicUdSf++SoJNqrb0oiEV QTIg== X-Gm-Message-State: AA+aEWZ8ruiWX74vCoJsvIUJPGiplSUcBPteoQM2rMZhRX/PeZX0uOS1 Jsm+9BSIOZyUsWrnaubKYIc= X-Google-Smtp-Source: AFSGD/W4JTza2aLzstfGoA/Ve8TMBIJzQHV8xVzWMZknn7Ahu3LQn6K9SiekNZrIilRM5szsseSvRg== X-Received: by 2002:a19:5059:: with SMTP id z25mr13990700lfj.120.1546011981695; Fri, 28 Dec 2018 07:46:21 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:7146:fd07:48ff:9665]) by smtp.googlemail.com with ESMTPSA id c203sm8042444lfe.95.2018.12.28.07.46.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Dec 2018 07:46:21 -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 v2 4/7] Input: tm2-touchkey: Allow specifying custom keycodes Date: Fri, 28 Dec 2018 16:46:06 +0100 Message-Id: <20181228154609.14846-5-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181228154609.14846-1-pawel.mikolaj.chmiel@gmail.com> References: <20181228154609.14846-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 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..c5adb928c6b4 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, + "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 Fri Dec 28 15:46:07 2018 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: 10744527 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 4A7F91580 for ; Fri, 28 Dec 2018 15:46:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3935B287BA for ; Fri, 28 Dec 2018 15:46:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D71E28BBE; Fri, 28 Dec 2018 15:46:28 +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 D3A09287BA for ; Fri, 28 Dec 2018 15:46:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732990AbeL1Pq0 (ORCPT ); Fri, 28 Dec 2018 10:46:26 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46540 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727018AbeL1PqZ (ORCPT ); Fri, 28 Dec 2018 10:46:25 -0500 Received: by mail-lj1-f195.google.com with SMTP id v15-v6so18997438ljh.13; Fri, 28 Dec 2018 07:46:24 -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=L8jyxKx8vnHBFlSEptO9LtSbLRa4isvh4Gt7pzfTqTo=; b=NL0gFa9CGJyWzE0cTvarNXFxqNvjf5nlx61P4cJphxcK5iz22Tt4AN0mSrSBMT6RxI /rtgWvmQiS5ELtb7BR5Q9mDhaw55aPObxVlGqpuvtcrUaN0xDm50TMx/bcaV3AHlW9do hBKuqH2yLLKHOY/AebKXZsbh+U1p7vOaObydWPO8Q01D/KaU4AHtbr6e6mHkUOIgXsy2 i6nzm7PYSTjBjzjSb7GolbtutcawUVX/T8LHxA6GUOIogScbshyPaKX6UTjVDoXjatpb HjkqHngZfAYwFgoPM6QZY+ogjjixHyPGTIuPl7Dx59dFTWq0e+MnKfSp2wr0yghoaNP0 hjFQ== 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=L8jyxKx8vnHBFlSEptO9LtSbLRa4isvh4Gt7pzfTqTo=; b=pbQaqadt+n4mDAVwehQKK2jVaer9mMp8RceW0wBNTC4ksrdNr03jTl9U+yDQg8wZZO nU+HWVP58W854y8EQd2hv3om8GzqRpNX0uKJ0cDI5Z/npT1MngvH5Cw9sPSWucfaTBrn Hj28M3dFya8uWHA+cgv867FtVqu09L7pYl2ExQYBELAcY+iFTLu9lZBAEnBq5kz6/7wW ln55/VSh6PxS9bxZeGM7H2hOdh23AynLV5W8Cw5LT8E15PTyT0ow/XEx1LkQR8ZCx0fH WjyMMAsPB9nYGKyS+GzgaX/QyPNz31TckEPbxNG+WleejRvij8p20hhPw8HfnaTQChva X0fQ== X-Gm-Message-State: AJcUukdaYJtmOK6illlZRlc/0fwMc8uEHgWGrvKC+H3sz+ZBnnVp4ZCd lejGNq9ja6ADiD1pEe72LZk= X-Google-Smtp-Source: ALg8bN7+OlDz5GeRHMiC+4+mvgYRg44dmi7CjJSBEblhmePH0dnL8rsKC8qdISOF2JH6DwFuZA7yfg== X-Received: by 2002:a2e:9a16:: with SMTP id o22-v6mr16396278lji.112.1546011983464; Fri, 28 Dec 2018 07:46:23 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:7146:fd07:48ff:9665]) by smtp.googlemail.com with ESMTPSA id c203sm8042444lfe.95.2018.12.28.07.46.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Dec 2018 07:46:22 -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 v2 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property Date: Fri, 28 Dec 2018 16:46:07 +0100 Message-Id: <20181228154609.14846-6-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181228154609.14846-1-pawel.mikolaj.chmiel@gmail.com> References: <20181228154609.14846-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 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..15d4bf4f307e 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: +- 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>; + keycodes = ; }; }; From patchwork Fri Dec 28 15:46:08 2018 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: 10744531 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 04ED713AD for ; Fri, 28 Dec 2018 15:46:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9EF3287BA for ; Fri, 28 Dec 2018 15:46:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBE1E28BBE; Fri, 28 Dec 2018 15:46:45 +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 6598C287BA for ; Fri, 28 Dec 2018 15:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733189AbeL1Pqn (ORCPT ); Fri, 28 Dec 2018 10:46:43 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:40591 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732956AbeL1Pq1 (ORCPT ); Fri, 28 Dec 2018 10:46:27 -0500 Received: by mail-lf1-f68.google.com with SMTP id v5so14778851lfe.7; Fri, 28 Dec 2018 07:46:25 -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=sX4MCT1F/XIaDetWT6pN9Vbnh7JjfzaWkdPb+65pu78=; b=ElN2qHHRyipb6UMC8EsDeWEVj1I/1ALf9QQNVQ8nzu1hUeSYCAmkUfFmXguno6SIC+ p0/pUfYZC11YEMmR9LksSSf2iCF5jguvnMPiO0PdfN2zL2IsTHBJha6E+tAQJEf9T26G pg3cB5uT0ldjA1hh6FI5S10SZbxE0AH7NhCElN2gdn1+2FOzPaZ5gYXkBr/8rNvoGmre 26AP+b9Im372KpC3RnTYt4v1SOSlpuA/Pf+j/la34695CJIAz36VDTyAuPoLMrY6HhGa i1mA4/986O7MclC2ZdWr8/XOzBamjwAI69FoglvPyzvYB0wf/O+dts2pnsJ8Y1eR3XX0 7zbw== 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=sX4MCT1F/XIaDetWT6pN9Vbnh7JjfzaWkdPb+65pu78=; b=aAgqHDN4p6xGRFyASqGIMKP4HqTgzrnygesZzNgfQGhGNzNxIKUnPRAHZ96nGNUBjB /E7k9JZ2RKUgmbjSOML8MDegRuLAmsUg5IiSltqR/Z+69K2A9PyRZH2Y9myOjpIcQRu+ 9g4TwaSmO23nDnP2ITpDDrMt+A+v+JAcTrmjGJR2d6vD80uViQG8G05EteBRV1yQa5dq aNme4Il63sldZe8LVQfWDUPGrMZe0bE26srD0uS2NR83vKX8gVNefaXilSw9IosRqZ5P hhAShLzhqJZQd2+VfYpyMeQ5Kine/WVEFWFz4Q7x7h6t/gECe8qAzQ/QEeVfcwL6VDv/ Yuew== X-Gm-Message-State: AA+aEWZ9VDhZOPW43mgiRRvqFeObYVYbAsSUTq/IOyOVgyZBVsKcq2Xd QNUu8FQTRAfbcpnlkh5o9HY= X-Google-Smtp-Source: AFSGD/VQuEgjFfGsTfLlqZ6lxyi/Z0bXxE0D7LmZyHokMVWCviq/eZ1GUbGDYR0pLBpyX8U/1nKuNA== X-Received: by 2002:a19:f204:: with SMTP id q4mr15279955lfh.133.1546011985040; Fri, 28 Dec 2018 07:46:25 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:7146:fd07:48ff:9665]) by smtp.googlemail.com with ESMTPSA id c203sm8042444lfe.95.2018.12.28.07.46.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Dec 2018 07:46:24 -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 v2 6/7] Input: tm2-touchkey: Add support for aries touchkey variant Date: Fri, 28 Dec 2018 16:46:08 +0100 Message-Id: <20181228154609.14846-7-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181228154609.14846-1-pawel.mikolaj.chmiel@gmail.com> References: <20181228154609.14846-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 c5adb928c6b4..05ad71797e60 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 Fri Dec 28 15:46:09 2018 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: 10744529 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 0AFDC6C5 for ; Fri, 28 Dec 2018 15:46:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE88F287BA for ; Fri, 28 Dec 2018 15:46:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF79428BBE; Fri, 28 Dec 2018 15:46:36 +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 938A8287BA for ; Fri, 28 Dec 2018 15:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733162AbeL1Pqf (ORCPT ); Fri, 28 Dec 2018 10:46:35 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36009 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731486AbeL1Pq3 (ORCPT ); Fri, 28 Dec 2018 10:46:29 -0500 Received: by mail-lf1-f66.google.com with SMTP id a16so14802154lfg.3; Fri, 28 Dec 2018 07:46:27 -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=uyuL012aMVSzztJhiL8O2OGBowL3br08/1hPFhnmrqI=; b=HJx7EoKEQfA1u9l1c91nZ97d3OT08ikoBUsxt/92nGPCHSWduPzbGdRyz5IbvXHmas jW8rz2NgjDgL5iKFhfJ9k1BVJewBo6A43vFD9jj60NlvIzoeEMqMCW38VgagMkhPvkw1 Mj4siqhqcWczaN/N9KapL8o1RXfsUR/M1ntoR0wd9XlC4GX1tvy97rG2foqeoexWMCpG OG32ntIFZOn+ppcVSCloa5Y3XXyOhXK6CqbkyJoik0cNJXYzN4vkdqJtiF3A6CPgQ10C hOHmYwyL4ZJkitbIDNGx7W/sEfqXa2Pgj8HLZQjUrVNP/zOIvS2glWy64TeQAAfLDL1q hPGw== 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=uyuL012aMVSzztJhiL8O2OGBowL3br08/1hPFhnmrqI=; b=WmquRjihctn/YyfwDMtUefV7ljGn4Q2X3e01cxiHWhg2NGJZuQOTYwHBywQ8DkZcYl 84M/yJIc3TXeKjihPo6OBfxHdy3PiRyKHvi9vfJ8yLIaGhZk/Y3I9TJq2/6C81DCsY9M Hk9zrietis90az+TbyDoORyWVqXYGGSvE4zrfdrjbMSPial2LFyYnhGzAAjMbNGNIw0X +ahnjMHd+ALjMSALbipoILIzIMOK8tOJ1BIhHYdDpatwj4ITsKt8LpYTQ95sAXQ6Knws Fj+Tw07bGN7+OlZqKvuDlejQstJEW3q48V4vsTckA9XgYhEPnhe7cL2juQU0TWEBqmR8 BBZw== X-Gm-Message-State: AA+aEWbLIfbp/eTlFOGqCES7u6zQLZk/lJfWVlJsQnIcWD8PJyck8bVG GZ3tLf98aK/4aBMQ1UpjjcA= X-Google-Smtp-Source: AFSGD/Xk6TxcKx6nuAbcsQv/Q/c+W1Wj3WQTAaFXyMWw2Se/EesPY02L9bULqkbyT4t9vu40uj0E1w== X-Received: by 2002:a19:5394:: with SMTP id h20mr14963890lfl.75.1546011986820; Fri, 28 Dec 2018 07:46:26 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:7146:fd07:48ff:9665]) by smtp.googlemail.com with ESMTPSA id c203sm8042444lfe.95.2018.12.28.07.46.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Dec 2018 07:46:26 -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 v2 7/7] Input: dt-bindings: tm2-touchkey: Add support for aries touchkey Date: Fri, 28 Dec 2018 16:46:09 +0100 Message-Id: <20181228154609.14846-8-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181228154609.14846-1-pawel.mikolaj.chmiel@gmail.com> References: <20181228154609.14846-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 15d4bf4f307e..c40a36cd29ad 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]).