From patchwork Wed Jan 24 21:32:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 10183151 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 5D7F1601D5 for ; Wed, 24 Jan 2018 21:32:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EB5028989 for ; Wed, 24 Jan 2018 21:32:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41C952898C; Wed, 24 Jan 2018 21:32:08 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 85C8E28989 for ; Wed, 24 Jan 2018 21:32:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932906AbeAXVcG (ORCPT ); Wed, 24 Jan 2018 16:32:06 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:45835 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932537AbeAXVcF (ORCPT ); Wed, 24 Jan 2018 16:32:05 -0500 Received: by mail-pg0-f65.google.com with SMTP id m136so3612244pga.12; Wed, 24 Jan 2018 13:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Ib/6sCfBnt01lyOtPf1fw4bbBSfbLrSq0+F6DWQ+tXM=; b=b4VkCVNUm2KSdAgw3WObmaWpXm+njzTYZ5Zap+62VZc4haFlTRDxmUKwYPkFiHq7a4 53wKehQqTdE2r53ARRyIUMDzLPq6wWcBebU8MNmsnxPDkRfBLfqx/YJ+m9OtCrqvuIEh 6edIFOeEV7g+FAapxSn44WwuQMJ9OQ7zn2fj3LNUZUwbZRUPSlAMuruyF1wdE5jKMrm4 qVMhxxNnweZXRZ3E+YDyZF09ICs52Ve5C5vaCc4vq9wVQJnIUxNumSWdTbfo22U8+47p 7imYi4GX39K8rGDhBEhQ6ScbM5tFR+oxqGeK/uvbPMYi1TUJGrUjYJF1XPeiKLemlidO rP/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Ib/6sCfBnt01lyOtPf1fw4bbBSfbLrSq0+F6DWQ+tXM=; b=SUZ5/OxWhuDATLDZFYIPpHzxLY7/ir2vqRw1/F5ojMZHnROJUNGQOZp46ryf9F6+bd GxqKK7Urwu9VtYdCews0XMJ8qB5xt7jYQKnzweNs4vLWVDMEe3dbxqRGY07YjC/5neav taqTpdgu2QUz7MBOnN24mhHzCSDvjW2M2lns+0LAtYTsUz7i268wDVcnFA3Fg18gpdCy dAxtKxZqjqC/HwDKS/LoToDX65u7vL89gi/PUf4Rdc3byDBOQdxaq/0g/+fyIr7qOJ9U OGozXda2gKykaIFDxGhFI0P28YYSmCWO9yWCnf83Q7IxzTw+YDazXAIetXcQ9qCpVGxN 4ntQ== X-Gm-Message-State: AKwxytdpUGkoOfQWi/no4SMPt4OXCvr7Kjlbmw9PNEky80i84W61xPAS /2pkYfctWrHx1jEnog2bEZw= X-Google-Smtp-Source: AH8x226ByY1LXgt2WABJ5b3GWOFSQtfdSavnZad/CAJ2C6UFd4ZsKKOldUcIuVJSZ2OEoJ8vnA3+Ow== X-Received: by 2002:a17:902:33c1:: with SMTP id b59-v6mr9718761plc.111.1516829524113; Wed, 24 Jan 2018 13:32:04 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1611:da80:8749:c06f:9515]) by smtp.gmail.com with ESMTPSA id 13sm12017154pfk.93.2018.01.24.13.32.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Jan 2018 13:32:03 -0800 (PST) Date: Wed, 24 Jan 2018 13:32:01 -0800 From: Dmitry Torokhov To: Marcus Folkesson Cc: Simon Shields , Andi Shyti , Rob Herring , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4 v2] Input: mms114 - add support for mms152 Message-ID: <20180124213201.vemutoltuz43hiwr@dtor-ws> References: <20180124193804.155654-1-dmitry.torokhov@gmail.com> <20180124193804.155654-5-dmitry.torokhov@gmail.com> <20180124200408.GB705@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180124200408.GB705@gmail.com> User-Agent: NeoMutt/20170609 (1.8.3) 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 MMS152 has no configuration registers, but the packet format used in interrupts is identical to mms114. Signed-off-by: Simon Shields Patchwork-Id: 10125841 Signed-off-by: Dmitry Torokhov Reviewed-by: Andi Shyti Tested-by: Andi Shyti --- V2: Fixed issue pointed by Marcus Folkesson. .../bindings/input/touchscreen/mms114.txt | 6 + drivers/input/touchscreen/mms114.c | 92 ++++++++++++++++---- 2 files changed, 77 insertions(+), 21 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt index 8f9f9f38eff4a..2cd954051d299 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/mms114.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/mms114.txt @@ -1,7 +1,9 @@ -* MELFAS MMS114 touchscreen controller +* MELFAS MMS114/MMS152 touchscreen controller Required properties: -- compatible: must be "melfas,mms114" +- compatible: should be one of: + - "melfas,mms114" + - "melfas,mms152" - reg: I2C address of the chip - interrupts: interrupt to which the chip is connected - touchscreen-size-x: See [1] diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index 69e4288bf8aa3..c54f4afe11037 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 @@ -50,12 +54,18 @@ #define MMS114_TYPE_TOUCHSCREEN 1 #define MMS114_TYPE_TOUCHKEY 2 +enum mms_type { + TYPE_MMS114 = 114, + TYPE_MMS152 = 152, +}; + struct mms114_data { struct i2c_client *client; struct input_dev *input_dev; struct regulator *core_reg; struct regulator *io_reg; struct touchscreen_properties props; + enum mms_type type; unsigned int contact_threshold; unsigned int moving_threshold; @@ -239,14 +249,33 @@ static int mms114_get_version(struct mms114_data *data) { struct device *dev = &data->client->dev; u8 buf[6]; + int group; int error; - error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf); - if (error < 0) - return error; + switch (data->type) { + case TYPE_MMS152: + error = __mms114_read_reg(data, MMS152_FW_REV, 3, buf); + if (error) + return error; + + group = i2c_smbus_read_byte_data(data->client, + MMS152_COMPAT_GROUP); + if (group < 0) + return group; + + 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], group); + break; + + case TYPE_MMS114: + error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf); + if (error) + 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; } @@ -261,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->type == TYPE_MMS152) + return 0; + error = mms114_set_active(data, true); if (error < 0) return error; @@ -395,6 +428,7 @@ static int mms114_probe(struct i2c_client *client, { struct mms114_data *data; struct input_dev *input_dev; + const void *match_data; int error; if (!i2c_check_functionality(client->adapter, @@ -415,6 +449,13 @@ static int mms114_probe(struct i2c_client *client, data->client = client; data->input_dev = input_dev; + /* FIXME: switch to device_get_match_data() when available */ + match_data = of_device_get_match_data(&client->dev); + if (!match_data) + return -EINVAL; + + data->type = (enum mms_type)match_data; + input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y); input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0); @@ -435,19 +476,26 @@ static int mms114_probe(struct i2c_client *client, 0, data->props.max_y, 0, 0); } - /* - * The firmware handles movement and pressure fuzz, so - * don't duplicate that in software. - */ - data->moving_threshold = input_abs_get_fuzz(input_dev, - ABS_MT_POSITION_X); - data->contact_threshold = input_abs_get_fuzz(input_dev, - ABS_MT_PRESSURE); - input_abs_set_fuzz(input_dev, ABS_MT_POSITION_X, 0); - input_abs_set_fuzz(input_dev, ABS_MT_POSITION_Y, 0); - input_abs_set_fuzz(input_dev, ABS_MT_PRESSURE, 0); - - input_dev->name = "MELFAS MMS114 Touchscreen"; + if (data->type == TYPE_MMS114) { + /* + * The firmware handles movement and pressure fuzz, so + * don't duplicate that in software. + */ + data->moving_threshold = input_abs_get_fuzz(input_dev, + ABS_MT_POSITION_X); + data->contact_threshold = input_abs_get_fuzz(input_dev, + ABS_MT_PRESSURE); + input_abs_set_fuzz(input_dev, ABS_MT_POSITION_X, 0); + input_abs_set_fuzz(input_dev, ABS_MT_POSITION_Y, 0); + input_abs_set_fuzz(input_dev, ABS_MT_PRESSURE, 0); + } + + input_dev->name = devm_kasprintf(&client->dev, GFP_KERNEL, + "MELFAS MMS%d Touchscreen", + data->type); + if (!input_dev->name) + return -ENOMEM; + input_dev->id.bustype = BUS_I2C; input_dev->dev.parent = &client->dev; input_dev->open = mms114_input_open; @@ -549,7 +597,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);