From patchwork Fri Nov 18 18:21:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Meng-Bo" X-Patchwork-Id: 13048586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7235CC43219 for ; Fri, 18 Nov 2022 18:21:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242603AbiKRSVt (ORCPT ); Fri, 18 Nov 2022 13:21:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242601AbiKRSVj (ORCPT ); Fri, 18 Nov 2022 13:21:39 -0500 Received: from mail-40130.protonmail.ch (mail-40130.protonmail.ch [185.70.40.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE17D8A15B; Fri, 18 Nov 2022 10:21:35 -0800 (PST) Date: Fri, 18 Nov 2022 18:21:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1668795693; x=1669054893; bh=nKZq4tmaBqgKx9awfbe4f1Daih6aVe8UbZ5zGA/hMz4=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Pce44jgmteToADvrAXVbI07aA92l9gdqKYlzFvdEj9sSN9SPpMwSWqXEIl1DbR1Mj joc5vwOkadInRqwWSep31MasbvcVEETJMpEIUam/qcaBh5JBDdabekDAJERXUDDbXB 8fctyIQ+uSjdUdXmIXAG1P9o8bMaZvwrXlklQ7rDBd9afiZuTRtBW1C5NX01KoGLlr Q5QIKWl9dbtYmPJltKpsjGHt5zY6ytevGYR1w6bQB8AvH1DHUl0TfO7wSKOVBcmmOr CVuMveIwjg7KkCxm+NpefO+B+IVMmwRELMq/FdaHqG0pBBlExChAUCsf+E07g13DOE 8G6PlIbwiqHDg== To: linux-kernel@vger.kernel.org From: "Lin, Meng-Bo" Cc: Markuss Broks , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Henrik Rydberg , Stephan Gerhold , Nikita Travkin , linux-input@vger.kernel.org, devicetree@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Subject: [PATCH v2 1/3] dt-bindings: input/touchscreen: Add compatible for IST3038 Message-ID: <20221118182103.3405-2-linmengbo0689@protonmail.com> In-Reply-To: <20221118182103.3405-1-linmengbo0689@protonmail.com> References: <20221118182103.3405-1-linmengbo0689@protonmail.com> Feedback-ID: 40467236:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Markuss Broks Imagis IST3038 is a variant (firmware?) of Imagis IST3038 IC, add the compatible for it to the IST3038C bindings. Signed-off-by: Markuss Broks [Change from IST3038B to IST3038] Signed-off-by: Lin, Meng-Bo Acked-by: Krzysztof Kozlowski Reviewed-by: Mattijs Korpershoek --- .../devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml b/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml index e3a2b871e50c..a58c045d2ba1 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/imagis,ist3038c.yaml @@ -18,6 +18,7 @@ properties: compatible: enum: + - imagis,ist3038 - imagis,ist3038c reg: From patchwork Fri Nov 18 18:21:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Meng-Bo" X-Patchwork-Id: 13048587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C7B5C4332F for ; Fri, 18 Nov 2022 18:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242609AbiKRSVv (ORCPT ); Fri, 18 Nov 2022 13:21:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242584AbiKRSVu (ORCPT ); Fri, 18 Nov 2022 13:21:50 -0500 Received: from mail-4325.protonmail.ch (mail-4325.protonmail.ch [185.70.43.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5FAB7DECB; Fri, 18 Nov 2022 10:21:49 -0800 (PST) Date: Fri, 18 Nov 2022 18:21:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1668795708; x=1669054908; bh=4aGhH9EhVaylkFLr9Cl301UNeKoyJLsI4X3gUZFSH9M=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Z5HVHKGDen/kzJHlqMSklLwNX41bXVqxyGPXLYKWygFVqURHUnbdLDs1VBD+MX1/3 nchNN+godIa5cgNoazTOpsyZGdiGyfhS5fzP5xj9pJFlkx89hiLyF2OtI7hFDrybeZ +fCNGDuCPhgbHxPpol81P8tcn+DYMSS/vai5TxpQhaD7AqwjyCDZbYT0FZE6Xa1jcP 6BsZrLKqR06JkZ9lPYhB168Q5wWlT1kXIVHJTSmau7yUom7Uo+MywpGRLbQNgW8t4a tNYK9zIP/radRqL6skV4JFdi3Yy5PLcSq+H5LQf6j99cLs7LCy6DR4j2TX+/nqeJMy 47FFiqmcI7czg== To: linux-kernel@vger.kernel.org From: "Lin, Meng-Bo" Cc: Markuss Broks , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Henrik Rydberg , Stephan Gerhold , Nikita Travkin , linux-input@vger.kernel.org, devicetree@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Subject: [PATCH v2 2/3] input/touchscreen: imagis: Correct the maximum touch area value Message-ID: <20221118182103.3405-3-linmengbo0689@protonmail.com> In-Reply-To: <20221118182103.3405-1-linmengbo0689@protonmail.com> References: <20221118182103.3405-1-linmengbo0689@protonmail.com> Feedback-ID: 40467236:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Markuss Broks As specified in downstream IST3038 driver and proved by testing, the correct maximum reported value of touch area is 16. Signed-off-by: Markuss Broks [Change from IST3038B to IST3038] Signed-off-by: Lin, Meng-Bo Reviewed-by: Mattijs Korpershoek --- drivers/input/touchscreen/imagis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c index e2697e6c6d2a..b667914a44f1 100644 --- a/drivers/input/touchscreen/imagis.c +++ b/drivers/input/touchscreen/imagis.c @@ -210,7 +210,7 @@ static int imagis_init_input_dev(struct imagis_ts *ts) 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_TOUCH_MAJOR, 0, 255, 0, 0); + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 16, 0, 0); touchscreen_parse_properties(input_dev, true, &ts->prop); if (!ts->prop.max_x || !ts->prop.max_y) { From patchwork Fri Nov 18 18:21:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Meng-Bo" X-Patchwork-Id: 13048588 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FC70C4332F for ; Fri, 18 Nov 2022 18:22:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241807AbiKRSWR (ORCPT ); Fri, 18 Nov 2022 13:22:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242658AbiKRSV7 (ORCPT ); Fri, 18 Nov 2022 13:21:59 -0500 Received: from mail-4319.protonmail.ch (mail-4319.protonmail.ch [185.70.43.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7638E922D7; Fri, 18 Nov 2022 10:21:55 -0800 (PST) Date: Fri, 18 Nov 2022 18:21:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1668795713; x=1669054913; bh=pbKTa64ww9zf2YjQDVJFvTEv+LvOGCj/fGrZioGjwnM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=TwT/sYEOpDbDsX8Nr6x6hyvqKYFrnxnVlSH13Oynr7KYbR6Fg29S2qwhKEUjG5jqV QXhyCLx7R2Xg2YF4HaA6HdlND3j9TVGOoAAIj6zSzbd3nG3qPbNwGHxTbuL7y21AXK zki3z7GVHiH2kQLsCA2iKqzM5tyw3fhhy1/NBm9thn8nA39J9+pPpcOXB6RyG1Hnj1 TtA3dNnXQ+xbkw8aE36SRqrWcEUGI1uwBsKtIF3ZYYiqPQHrurqloRvYU/w3Fj3mJU mxQV8r3W4QyPTkL3+Sb2hl44CLQb/TVXd5vMVjHzz6gRe8MmRkq56kNSfarUHpPwuv p/0pr1DM63NMg== To: linux-kernel@vger.kernel.org From: "Lin, Meng-Bo" Cc: Markuss Broks , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Henrik Rydberg , Stephan Gerhold , Nikita Travkin , linux-input@vger.kernel.org, devicetree@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Subject: [PATCH v2 3/3] input/touchscreen: imagis: Add supports for Imagis IST3038 Message-ID: <20221118182103.3405-4-linmengbo0689@protonmail.com> In-Reply-To: <20221118182103.3405-1-linmengbo0689@protonmail.com> References: <20221118182103.3405-1-linmengbo0689@protonmail.com> Feedback-ID: 40467236:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Markuss Broks Imagis IST3038 is another variant of Imagis IST3038 IC, which has a different register interface from IST3038C (possibly firmware defined). This should also work for IST3044B (though untested), however other variants using this interface/protocol(IST3026, IST3032, IST3026B, IST3032B) have a different format for coordinates, and they'd need additional effort to be supported by this driver. Signed-off-by: Markuss Broks [Use IST3038C_REG_CHIPID_BASE] Signed-off-by: Lin, Meng-Bo Reviewed-by: Mattijs Korpershoek --- drivers/input/touchscreen/imagis.c | 62 ++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c index b667914a44f1..eb3b0684817f 100644 --- a/drivers/input/touchscreen/imagis.c +++ b/drivers/input/touchscreen/imagis.c @@ -13,7 +13,8 @@ #define IST3038C_HIB_ACCESS (0x800B << 16) #define IST3038C_DIRECT_ACCESS BIT(31) -#define IST3038C_REG_CHIPID 0x40001000 +#define IST3038C_REG_CHIPID_BASE 0x40001000 +#define IST3038C_REG_CHIPID(base) (base | IST3038C_DIRECT_ACCESS) #define IST3038C_REG_HIB_BASE 0x30000100 #define IST3038C_REG_TOUCH_STATUS (IST3038C_REG_HIB_BASE | IST3038C_HIB_ACCESS) #define IST3038C_REG_TOUCH_COORD (IST3038C_REG_HIB_BASE | IST3038C_HIB_ACCESS | 0x8) @@ -31,8 +32,24 @@ #define IST3038C_FINGER_COUNT_SHIFT 12 #define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0) +#define IST30XX_REG_STATUS 0x20 +#define IST30XXB_REG_CHIPID_BASE 0x40000000 +#define IST30XX_WHOAMI 0x30003000 +#define IST30XXA_WHOAMI 0x300a300a +#define IST30XXB_WHOAMI 0x300b300b +#define IST3038_WHOAMI 0x30383038 + +struct imagis_properties { + unsigned int interrupt_msg_cmd; + unsigned int touch_coord_cmd; + unsigned int chipid_base; + unsigned int whoami_val; + bool protocol_b; +}; + struct imagis_ts { struct i2c_client *client; + const struct imagis_properties *tdata; struct input_dev *input_dev; struct touchscreen_properties prop; struct regulator_bulk_data supplies[2]; @@ -84,8 +101,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id) int i; int error; - error = imagis_i2c_read_reg(ts, IST3038C_REG_INTR_MESSAGE, - &intr_message); + error = imagis_i2c_read_reg(ts, ts->tdata->interrupt_msg_cmd, &intr_message); if (error) { dev_err(&ts->client->dev, "failed to read the interrupt message: %d\n", error); @@ -104,9 +120,13 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id) finger_pressed = intr_message & IST3038C_FINGER_STATUS_MASK; for (i = 0; i < finger_count; i++) { - error = imagis_i2c_read_reg(ts, - IST3038C_REG_TOUCH_COORD + (i * 4), - &finger_status); + if (ts->tdata->protocol_b) + error = imagis_i2c_read_reg(ts, + ts->tdata->touch_coord_cmd, &finger_status); + else + error = imagis_i2c_read_reg(ts, + ts->tdata->touch_coord_cmd + (i * 4), + &finger_status); if (error) { dev_err(&ts->client->dev, "failed to read coordinates for finger %d: %d\n", @@ -261,6 +281,12 @@ static int imagis_probe(struct i2c_client *i2c) ts->client = i2c; + ts->tdata = device_get_match_data(dev); + if (!ts->tdata) { + dev_err(dev, "missing chip data\n"); + return -EINVAL; + } + error = imagis_init_regulators(ts); if (error) { dev_err(dev, "regulator init error: %d\n", error); @@ -279,15 +305,13 @@ static int imagis_probe(struct i2c_client *i2c) return error; } - error = imagis_i2c_read_reg(ts, - IST3038C_REG_CHIPID | IST3038C_DIRECT_ACCESS, - &chip_id); + error = imagis_i2c_read_reg(ts, IST3038C_REG_CHIPID(ts->tdata->chipid_base), &chip_id); if (error) { dev_err(dev, "chip ID read failure: %d\n", error); return error; } - if (chip_id != IST3038C_WHOAMI) { + if (chip_id != ts->tdata->whoami_val) { dev_err(dev, "unknown chip ID: 0x%x\n", chip_id); return -EINVAL; } @@ -343,9 +367,25 @@ static int __maybe_unused imagis_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(imagis_pm_ops, imagis_suspend, imagis_resume); +static const struct imagis_properties imagis_3038_data = { + .interrupt_msg_cmd = IST30XX_REG_STATUS, + .touch_coord_cmd = IST30XX_REG_STATUS, + .chipid_base = IST30XXB_REG_CHIPID_BASE, + .whoami_val = IST3038_WHOAMI, + .protocol_b = true, +}; + +static const struct imagis_properties imagis_3038c_data = { + .interrupt_msg_cmd = IST3038C_REG_INTR_MESSAGE, + .touch_coord_cmd = IST3038C_REG_TOUCH_COORD, + .chipid_base = IST3038C_REG_CHIPID_BASE, + .whoami_val = IST3038C_WHOAMI, +}; + #ifdef CONFIG_OF static const struct of_device_id imagis_of_match[] = { - { .compatible = "imagis,ist3038c", }, + { .compatible = "imagis,ist3038", .data = &imagis_3038_data }, + { .compatible = "imagis,ist3038c", .data = &imagis_3038c_data }, { }, }; MODULE_DEVICE_TABLE(of, imagis_of_match);