From patchwork Wed Dec 20 15:38:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Shields X-Patchwork-Id: 10125841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB61C60388 for ; Wed, 20 Dec 2017 15:38:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC6A829184 for ; Wed, 20 Dec 2017 15:38:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C119E2920C; Wed, 20 Dec 2017 15:38: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=-6.9 required=2.0 tests=BAYES_00,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 426A929184 for ; Wed, 20 Dec 2017 15:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755445AbdLTPii (ORCPT ); Wed, 20 Dec 2017 10:38:38 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:33507 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755271AbdLTPih (ORCPT ); Wed, 20 Dec 2017 10:38:37 -0500 Received: by mail-pl0-f67.google.com with SMTP id 1so7752806plv.0; Wed, 20 Dec 2017 07:38:37 -0800 (PST) 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; bh=ZASi3NC2UsJ4gtoJXIIcRqTqnaMH/zQJhtb3Ieb/ykI=; b=RaZn9ZVkOTiGOvV1rFjk1UM4ZqVZGRUV9gZroMHRglZVXBoJNsBypifCC47cImQE4F q83ezgQr6GS3OoF3ltaBwaeTygCZwU6AK94/JpSBKSlZ0WfrAWY99AhTREJhVPZO1ObS dHi1LOFDMfGAy8IXRi988Dp5/92g4Aurn5VFmfHq5c6VY9hBtYFeRciTj1pSWfyMmOb8 /hUowWslJPkigGEsXaGHK4Mk6BIHgKW2Kque7ppczLFnrWFxlARG4stxIN1/ikOKJ/3K OhD8k1/3ajEK5fe0tmdC19wEBXjJErwgkmLVwsRQ1Ph3/MFvJ3ptcRPNtwlr8fSXUdRx 5AiQ== X-Gm-Message-State: AKGB3mID7RgsXme5PlPM3hBVpPqXHRnAV1WVVJiFPk4h0pHieLPWW87E F7IcMY9bS2pjNcF8HlB436w= X-Google-Smtp-Source: ACJfBot0PZec0ajU/PrGuFa4rxmtHDSZ2S5EdjV2k0EHJ7Vzr2OQfY0iZH+DgwyJfg1arQfPhW0PZg== X-Received: by 10.159.242.10 with SMTP id t10mr7473218plr.227.1513784317025; Wed, 20 Dec 2017 07:38:37 -0800 (PST) Received: from archbox.home (27-32-42-49.static.tpgi.com.au. [27.32.42.49]) by smtp.gmail.com with ESMTPSA id k23sm36207761pfj.22.2017.12.20.07.38.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Dec 2017 07:38:35 -0800 (PST) From: Simon Shields To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, Andi Shyti , Simon Shields Subject: [PATCH v2] Input: mms114 - add support for mms152 Date: Thu, 21 Dec 2017 02:38:10 +1100 Message-Id: <20171220153810.1961-1-simon@lineageos.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171218124933.1803-1-simon@lineageos.org> References: <20171218124933.1803-1-simon@lineageos.org> 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 MMS152 has no configuration registers, but the packet format used in interrupts is identical to mms114. Signed-off-by: Simon Shields --- .../bindings/input/touchscreen/mms114.txt | 8 ++-- drivers/input/touchscreen/mms114.c | 53 +++++++++++++++++++--- include/linux/platform_data/mms114.h | 6 +++ 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt index 89d4c56c5671..733411020ced 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt @@ -1,15 +1,15 @@ -* MELFAS MMS114 touchscreen controller +* MELFAS MMS114/MMS152 touchscreen controller Required properties: -- compatible: must be "melfas,mms114" +- compatible: "melfas,mms114" for MMS114, or "melfas,mms152" for MMS152 - reg: I2C address of the chip - interrupts: interrupt to which the chip is connected - x-size: horizontal resolution of touchscreen - y-size: vertical resolution of touchscreen Optional properties: -- contact-threshold: -- moving-threshold: +- contact-threshold: only with "melfas,mms114" +- moving-threshold: only with "melfas,mms114" - x-invert: invert X axis - y-invert: invert Y axis diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index e5eeb6311f7d..9ecda193802b 100644 --- a/drivers/input/touchscreen/mms114.c +++ b/drivers/input/touchscreen/mms114.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,9 @@ #define MMS114_INFOMATION 0x10 #define MMS114_TSP_REV 0xF0 +#define MMS152_FW_REV 0xE1 +#define MMS152_COMPAT_GROUP 0xF2 + /* Minimum delay time is 50us between stop and start signal of i2c */ #define MMS114_I2C_DELAY 50 @@ -251,12 +255,27 @@ static int mms114_get_version(struct mms114_data *data) u8 buf[6]; int error; - error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf); - if (error < 0) - return error; + switch (data->pdata->type) { + case TYPE_MMS152: + error = __mms114_read_reg(data, MMS152_FW_REV, 3, buf); + if (error < 0) + return error; + buf[3] = i2c_smbus_read_byte_data(data->client, + MMS152_COMPAT_GROUP); + if (buf[3] < 0) + return buf[3]; + dev_info(dev, "TSP FW Rev: bootloader 0x%x / core 0x%x / config 0x%x, Compat group: %c\n", + buf[0], buf[1], buf[2], buf[3]); + break; + case TYPE_MMS114: + error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf); + if (error < 0) + return error; - dev_info(dev, "TSP Rev: 0x%x, HW Rev: 0x%x, Firmware Ver: 0x%x\n", - buf[0], buf[1], buf[3]); + dev_info(dev, "TSP Rev: 0x%x, HW Rev: 0x%x, Firmware Ver: 0x%x\n", + buf[0], buf[1], buf[3]); + break; + } return 0; } @@ -271,6 +290,10 @@ static int mms114_setup_regs(struct mms114_data *data) if (error < 0) return error; + /* MMS152 has no configuration or power on registers */ + if (data->pdata->type == TYPE_MMS152) + return 0; + error = mms114_set_active(data, true); if (error < 0) return error; @@ -391,6 +414,8 @@ static struct mms114_platform_data *mms114_parse_dt(struct device *dev) return NULL; } + pdata->type = (enum mms_type)of_device_get_match_data(dev); + if (of_property_read_u32(np, "x-size", &pdata->x_size)) { dev_err(dev, "failed to get x-size property\n"); return NULL; @@ -456,7 +481,15 @@ static int mms114_probe(struct i2c_client *client, data->input_dev = input_dev; data->pdata = pdata; - input_dev->name = "MELFAS MMS114 Touchscreen"; + switch (pdata->type) { + case TYPE_MMS114: + input_dev->name = "MELFAS MMS114 Touchscreen"; + break; + case TYPE_MMS152: + input_dev->name = "MELFAS MMS152 Touchscreen"; + break; + } + input_dev->id.bustype = BUS_I2C; input_dev->dev.parent = &client->dev; input_dev->open = mms114_input_open; @@ -569,7 +602,13 @@ MODULE_DEVICE_TABLE(i2c, mms114_id); #ifdef CONFIG_OF static const struct of_device_id mms114_dt_match[] = { - { .compatible = "melfas,mms114" }, + { + .compatible = "melfas,mms114", + .data = (void *)TYPE_MMS114, + }, { + .compatible = "melfas,mms152", + .data = (void *)TYPE_MMS152, + }, { } }; MODULE_DEVICE_TABLE(of, mms114_dt_match); diff --git a/include/linux/platform_data/mms114.h b/include/linux/platform_data/mms114.h index 5722ebfb2738..58e4c463bf0c 100644 --- a/include/linux/platform_data/mms114.h +++ b/include/linux/platform_data/mms114.h @@ -10,6 +10,11 @@ #ifndef __LINUX_MMS114_H #define __LINUX_MMS114_H +enum mms_type { + TYPE_MMS114, + TYPE_MMS152, +}; + struct mms114_platform_data { unsigned int x_size; unsigned int y_size; @@ -17,6 +22,7 @@ struct mms114_platform_data { unsigned int moving_threshold; bool x_invert; bool y_invert; + enum mms_type type; void (*cfg_pin)(bool); };