Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp398264imu; Fri, 7 Dec 2018 03:00:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/XlsEB8jSuSyGgVGkW4emARuxqJhxsIfTRSQhwrHs87puNcXkbzPZVjbDpPHeqMXZI2rI9r X-Received: by 2002:a62:fc52:: with SMTP id e79mr1799092pfh.8.1544180425346; Fri, 07 Dec 2018 03:00:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544180425; cv=none; d=google.com; s=arc-20160816; b=vHtcm528aZQBPeX/LBdGskWBcw6LBI5/9fkGfs+XValdVL8nz771yKky5TFe7OQIBq mw9d4vktJhyuxBcjRKM35WJrkbMmS0FQYuv/gq+KR6wo0fc3FjDvQZzr370RKDoPi9q1 p+E+rgLnSVv9knl1VILxcOZSX4853zlXACxVXmSGq1+MCnN6T3oKDyi8mS14AJVSzoNH IeRWOCMNaGWi3ptUFeTqQlRyp0PA5uZqG8XdX0/6l9+6HTb9wTmPw9tKSGXgpXl1LEoz 7po934eGondrJBFb7VP5TriCtjgXZQ2qpT4ZH5o/tM5V596UDGkn2ftgCC7Bgb+gZ+xK UcuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GUoyo020/7BIZvMbKzva5ANhccuHEj+8T05zfMoqMeE=; b=douHLzOJ6ic11UTDQ6sp2YZVuPGrJoDsPkPuS/8HFcqRSo/J3Tmtu8Y7RjIautBJA0 bNovCkP6ek8gZzksToAUWi6wvvtv7/BPKC6LmwY7jM8r+sNFkbtfQjSH/cVX6XuwAEoB 3cQscx7SArlALydr6hCy0L/sDUYCgcTD1emVp19saWC7qFHDpVlqtd6FWgrTTczr8oQr tntrFMcW0rqi9hgVLLl8zEfpwrhx9BdXP84lceO/YI5bTCfJI3znkc6GoOS6rMhpaQyU wV/E3Psk5IcLEHvOmL7FKas0KWSUrLXMwGf8tVsFLV/XTdfXKgEOoJVupe60sY6Ij/ab wksw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ek9cZ/sw"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si2519219plr.376.2018.12.07.03.00.10; Fri, 07 Dec 2018 03:00:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ek9cZ/sw"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726086AbeLGK60 (ORCPT + 99 others); Fri, 7 Dec 2018 05:58:26 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34624 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbeLGK6Y (ORCPT ); Fri, 7 Dec 2018 05:58:24 -0500 Received: by mail-lj1-f194.google.com with SMTP id u6-v6so3188651ljd.1; Fri, 07 Dec 2018 02:58:21 -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=GUoyo020/7BIZvMbKzva5ANhccuHEj+8T05zfMoqMeE=; b=Ek9cZ/swgV831GL11fcs5pRo/VUbRKraW3SAj7n0I9R/Qf5ACzaOJ9wdEjwEVIwoId F2PxZ3nTDQ0K/KpdfIrFONItdhBcTawSXIAE1WFdynOQEKTCgqn+kZVtmn3ZhfXLlDlO Q29JPh4gWQFJ45vJ005dvU0219MnXqr32HXGEgOOC2ZaYppMLlmAMkHG+n3gFqlUwpN+ fcYA9vLjr7DKR6OqnHS0OduROdDTmENVFQWAjZVXova1GUCS//Cx+oC1yxibI5xG1tR5 zEEnqQ/ZKm85LHgTFOTuD8yDIKJ+QpuXY9hFbIP+bMKQFm/SCF9JbzSWO0kKGJfhUHKs evhA== 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=GUoyo020/7BIZvMbKzva5ANhccuHEj+8T05zfMoqMeE=; b=Hooxo20vIsccYQCjFU0vLwmMHYf5Zz+CyqcKws5GlcJgOlS+VC5B6OpFdlBfTIPUmx RRwPklEti1OCMiW/s8b9RyePFrJSgadMEOmuONaNNvNlleChme7HPvyU7JraTmqTYI1g J32MZd9azT/wdr86lfQWc9G5S+X2uTKnDdSU/jLsG0EYTj8/elicZiuj62/8cbFD9aSu Q7ml+hFjcvs+CFNvxYyjmWtnk+ltZfrF6e5i2y+wKxsueJofwDzE0wf6J1SMybnNe/qT AEAKpd2WMxFGWuPBWRyRcMXzsWww8tZWF4QP08/aayvrr6CHoGX1/ZD5Lm7CrNUOkdJG s4EA== X-Gm-Message-State: AA+aEWaQnH42ycBmBJFmmQdiNhB98AmdCedBBEw66FFKkq2LtV1lMkxh mHfjt25DL6JFex3c6BmeL7U= X-Received: by 2002:a2e:80d3:: with SMTP id r19-v6mr1048293ljg.151.1544180301013; Fri, 07 Dec 2018 02:58:21 -0800 (PST) Received: from localhost.localdomain ([2a02:a315:5445:5300:74d5:51ba:2673:f3f4]) by smtp.googlemail.com with ESMTPSA id a20-v6sm523362ljf.28.2018.12.07.02.58.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Dec 2018 02:58:20 -0800 (PST) From: =?UTF-8?q?Pawe=C5=82=20Chmiel?= To: dmitry.torokhov@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: 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 1/8] Input: tm2-touchkey: Add support for midas touchkey Date: Fri, 7 Dec 2018 11:58:04 +0100 Message-Id: <20181207105811.1831-2-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181207105811.1831-1-pawel.mikolaj.chmiel@gmail.com> References: <20181207105811.1831-1-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/input/keyboard/tm2-touchkey.c | 48 ++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c index abc266e40e17..37a5ced24009 100644 --- a/drivers/input/keyboard/tm2-touchkey.c +++ b/drivers/input/keyboard/tm2-touchkey.c @@ -22,12 +22,13 @@ #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_DEV_NAME "tm2-touchkey" +#define MIDAS_TOUCHKEY_DEV_NAME "midas-touchkey" + #define TM2_TOUCHKEY_CMD_LED_ON 0x10 #define TM2_TOUCHKEY_CMD_LED_OFF 0x20 #define TM2_TOUCHKEY_BIT_PRESS_EV BIT(3) @@ -40,12 +41,31 @@ enum { TM2_TOUCHKEY_KEY_BACK, }; +struct touchkey_variant { + const char *name; + 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]; + struct touchkey_variant *variant; +}; + +static struct touchkey_variant tm2_touchkey_variant = { + .name = "tm2-touchkey", + .keycode_reg = 0x03, + .base_reg = 0x00, +}; + +static struct touchkey_variant midas_touchkey_variant = { + .name = "midas-touchkey", + .keycode_reg = 0x00, + .base_reg = 0x00, }; static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev, @@ -66,7 +86,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 +119,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 +173,9 @@ static int tm2_touchkey_probe(struct i2c_client *client, touchkey->client = client; i2c_set_clientdata(client, touchkey); + touchkey->variant = (struct 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, @@ -187,7 +210,7 @@ static int tm2_touchkey_probe(struct i2c_client *client, return -ENOMEM; } - touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME; + touchkey->input_dev->name = touchkey->variant->name; touchkey->input_dev->id.bustype = BUS_I2C; input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE); @@ -203,7 +226,7 @@ static int tm2_touchkey_probe(struct i2c_client *client, error = devm_request_threaded_irq(&client->dev, client->irq, NULL, tm2_touchkey_irq_handler, IRQF_ONESHOT, - TM2_TOUCHKEY_DEV_NAME, touchkey); + touchkey->variant->name, touchkey); if (error) { dev_err(&client->dev, "failed to request threaded irq: %d\n", error); @@ -211,7 +234,7 @@ static int tm2_touchkey_probe(struct i2c_client *client, } /* led device */ - touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME; + touchkey->led_dev.name = touchkey->variant->name; touchkey->led_dev.brightness = LED_FULL; touchkey->led_dev.max_brightness = LED_ON; touchkey->led_dev.brightness_set = tm2_touchkey_led_brightness_set; @@ -257,12 +280,19 @@ static SIMPLE_DEV_PM_OPS(tm2_touchkey_pm_ops, static const struct i2c_device_id tm2_touchkey_id_table[] = { { TM2_TOUCHKEY_DEV_NAME, 0 }, + { MIDAS_TOUCHKEY_DEV_NAME, 0 }, { }, }; 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); -- 2.17.1