Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3920900imu; Mon, 7 Jan 2019 11:58:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN4KassXJIDg0Lc1PjIgcS0wqSXP0IXzAue0VwxIbu+O6QW6l66qW1VsCKKrvqLoi3/eqmlS X-Received: by 2002:a65:5387:: with SMTP id x7mr12182280pgq.412.1546891096053; Mon, 07 Jan 2019 11:58:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546891096; cv=none; d=google.com; s=arc-20160816; b=qV6ZqifPLzEtfSZrRkRMKoXv6S5yLhplQoY5QoGdYK2o0LttgYRR1K9C1hY1UFvQrm GuHCSRkf9zjS2J1ir9N/GQhouhjizwdN571nvQKYFNg6M/i99dFOlOM+I6p0IrJG3LsV Jkfo9eZ3DtDYrMhsNlVII0/UYUi/LE/jTsWtiBlL6CP79izVV7jILqVKQTNLZtFTZ/b3 f3LtptgBweuK+KaMmpAtq94cI1iQEP2cxWTFAiBuiwOVcaFyCX0w8DUea3Gkmh4FNXPO EugxnICFEZQzgiMstI7KqAaWwALtzcdbTXm66zC9xw+Pk6Ia68ytWu3xSpsKSb+PAL/L pehg== 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=X2xmaLsg9+x3NOOa9a3z9y0xnBcsw3Eg+1EpWLMSG6k=; b=SuLhsflMOcbyjS2UK/5y/07dNsyF0zX8cLAtUHz30d+C3sbNbCjZS0g0ARDirgtMKE tQI1mJsblUO6F8s6E0NdgU8jUX6i4M1GCBBxullRMmsnU/ZwKwbJeVkURdue439i1qLf kSK2GegM0ueVeXjcjMysMIolduIXYKT8iX37WMopw1+8lHYG9dcd2ncSDxJwPeoFKUV6 iE6PJhcFC/6/Ju88HUS2npglZUBhGUyqc3EyBIynl6w+SAgxt9UcHbgX1PzTQc/WAUWz RfFRPgpJqq4DcV42PbVerXhaCL9HJz9LVg3IwW0PXFDM07ChZdYWF21pQYrT/9T+2sGH /bEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="U/uaXTk4"; 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 c7si3251143pgg.339.2019.01.07.11.58.00; Mon, 07 Jan 2019 11:58:15 -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="U/uaXTk4"; 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 S1728264AbfAGSyO (ORCPT + 99 others); Mon, 7 Jan 2019 13:54:14 -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-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=20Chmiel?= 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 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 --- 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); -- 2.17.1