From patchwork Fri Nov 6 10:05:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Valek, Andrej" X-Patchwork-Id: 321551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E2D1C388F2 for ; Fri, 6 Nov 2020 10:12:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BB27206DC for ; Fri, 6 Nov 2020 10:12:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726447AbgKFKMa (ORCPT ); Fri, 6 Nov 2020 05:12:30 -0500 Received: from goliath.siemens.de ([192.35.17.28]:44741 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbgKFKMa (ORCPT ); Fri, 6 Nov 2020 05:12:30 -0500 Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id 0A6ACIPv023943 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 6 Nov 2020 11:12:18 +0100 Received: from dev.vm7.ccp.siemens.com ([139.22.40.104]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id 0A6ACHg9025432; Fri, 6 Nov 2020 11:12:17 +0100 Received: from dev.vm7.ccp.siemens.com (localhost [127.0.0.1]) by dev.vm7.ccp.siemens.com (Postfix) with ESMTP id 1BAD870FF87; Fri, 6 Nov 2020 11:06:56 +0100 (CET) From: Andrej Valek To: robh@kernel.org, nick@shmanahar.org, hadess@hadess.net, dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Andrej Valek Subject: [PATCH v2 1/3] Input: st1232 - add support resolution reading Date: Fri, 6 Nov 2020 11:05:37 +0100 Message-Id: <20201106100539.6646-2-andrej.valek@siemens.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201029170313.25529-1-andrej.valek@siemens.com> References: <20201029170313.25529-1-andrej.valek@siemens.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Hard-coding resolution for st1633 device was wrong. Some of LCDs like YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too. But the resolution is not 320x480 as was hard-coded. Add new function which reads correct resolution directly from register. Signed-off-by: Andrej Valek --- drivers/input/touchscreen/st1232.c | 52 +++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index 63b29c7279e2..1b4b139c8533 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -26,15 +26,14 @@ #define ST1232_TS_NAME "st1232-ts" #define ST1633_TS_NAME "st1633-ts" +#define REG_XY_RESOLUTION 0x04 +#define REG_XY_COORDINATES 0x12 #define ST_TS_MAX_FINGERS 10 struct st_chip_info { bool have_z; - u16 max_x; - u16 max_y; u16 max_area; u16 max_fingers; - u8 start_reg; }; struct st1232_ts_data { @@ -48,15 +47,14 @@ struct st1232_ts_data { u8 *read_buf; }; -static int st1232_ts_read_data(struct st1232_ts_data *ts) +static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg) { struct i2c_client *client = ts->client; - u8 start_reg = ts->chip_info->start_reg; struct i2c_msg msg[] = { { .addr = client->addr, - .len = sizeof(start_reg), - .buf = &start_reg, + .len = sizeof(reg), + .buf = ®, }, { .addr = client->addr, @@ -74,6 +72,25 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts) return 0; } +static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x, + u16 *max_y) +{ + u8 *buf; + int error; + + /* select resolution register */ + error = st1232_ts_read_data(ts, REG_XY_RESOLUTION); + if (error) + return error; + + buf = ts->read_buf; + + *max_x = ((buf[0] & 0x0070) << 4) | buf[1]; + *max_y = ((buf[0] & 0x0007) << 8) | buf[2]; + + return 0; +} + static int st1232_ts_parse_and_report(struct st1232_ts_data *ts) { struct input_dev *input = ts->input_dev; @@ -123,7 +140,7 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id) int count; int error; - error = st1232_ts_read_data(ts); + error = st1232_ts_read_data(ts, REG_XY_COORDINATES); if (error) goto out; @@ -157,20 +174,14 @@ static void st1232_ts_power_off(void *data) static const struct st_chip_info st1232_chip_info = { .have_z = true, - .max_x = 0x31f, /* 800 - 1 */ - .max_y = 0x1df, /* 480 -1 */ .max_area = 0xff, .max_fingers = 2, - .start_reg = 0x12, }; static const struct st_chip_info st1633_chip_info = { .have_z = false, - .max_x = 0x13f, /* 320 - 1 */ - .max_y = 0x1df, /* 480 -1 */ .max_area = 0x00, .max_fingers = 5, - .start_reg = 0x12, }; static int st1232_ts_probe(struct i2c_client *client, @@ -179,6 +190,7 @@ static int st1232_ts_probe(struct i2c_client *client, const struct st_chip_info *match; struct st1232_ts_data *ts; struct input_dev *input_dev; + u16 max_x, max_y; int error; match = device_get_match_data(&client->dev); @@ -239,14 +251,22 @@ static int st1232_ts_probe(struct i2c_client *client, input_dev->name = "st1232-touchscreen"; input_dev->id.bustype = BUS_I2C; + /* read resolution from chip */ + error = st1232_ts_read_resolution(ts, &max_x, &max_y); + if (error) { + dev_err(&client->dev, + "Failed to read resolution: %d\n", error); + return error; + } + if (ts->chip_info->have_z) input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, ts->chip_info->max_area, 0, 0); input_set_abs_params(input_dev, ABS_MT_POSITION_X, - 0, ts->chip_info->max_x, 0, 0); + 0, max_x, 0, 0); input_set_abs_params(input_dev, ABS_MT_POSITION_Y, - 0, ts->chip_info->max_y, 0, 0); + 0, max_y, 0, 0); touchscreen_parse_properties(input_dev, true, &ts->prop); From patchwork Thu Oct 29 17:03:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Valek, Andrej" X-Patchwork-Id: 314965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A978C2D0A3 for ; Thu, 29 Oct 2020 17:15:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B87E920796 for ; Thu, 29 Oct 2020 17:15:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725948AbgJ2RPk (ORCPT ); Thu, 29 Oct 2020 13:15:40 -0400 Received: from goliath.siemens.de ([192.35.17.28]:36929 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbgJ2RPk (ORCPT ); Thu, 29 Oct 2020 13:15:40 -0400 Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id 09TH47WX011958 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Oct 2020 18:04:07 +0100 Received: from dev.vm7.ccp.siemens.com ([139.22.33.215]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id 09TH47uD015940; Thu, 29 Oct 2020 18:04:07 +0100 Received: from mail2.siemens.de (localhost [127.0.0.1]) by dev.vm7.ccp.siemens.com (Postfix) with ESMTP id D963270FF87; Thu, 29 Oct 2020 18:04:06 +0100 (CET) From: Andrej Valek To: nick@shmanahar.org, hadess@hadess.net, dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Andrej Valek Subject: [PATCH 2/3] dt-bindings: goodix Date: Thu, 29 Oct 2020 18:03:12 +0100 Message-Id: <20201029170313.25529-3-andrej.valek@siemens.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201029170313.25529-1-andrej.valek@siemens.com> References: <20201029170313.25529-1-andrej.valek@siemens.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add information about option how to disable FW loading for each boot. Signed-off-by: Andrej Valek --- Documentation/devicetree/bindings/input/touchscreen/goodix.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.yaml b/Documentation/devicetree/bindings/input/touchscreen/goodix.yaml index da5b0d87e16d0..e7d9404c86abf 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/goodix.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.yaml @@ -53,6 +53,7 @@ properties: touchscreen-size-x: true touchscreen-size-y: true touchscreen-swapped-x-y: true + touchscreen-do-not-load-fw: false additionalProperties: false From patchwork Fri Nov 6 10:05:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Valek, Andrej" X-Patchwork-Id: 319593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F547C55178 for ; Fri, 6 Nov 2020 10:12:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EAB97206DC for ; Fri, 6 Nov 2020 10:12:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726074AbgKFKMd (ORCPT ); Fri, 6 Nov 2020 05:12:33 -0500 Received: from thoth.sbs.de ([192.35.17.2]:51290 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbgKFKMd (ORCPT ); Fri, 6 Nov 2020 05:12:33 -0500 Received: from mail2.siemens.de (mail2.siemens.de [139.25.208.11]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 0A6ACIan003171 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 6 Nov 2020 11:12:18 +0100 Received: from dev.vm7.ccp.siemens.com ([139.22.40.104]) by mail2.siemens.de (8.15.2/8.15.2) with ESMTP id 0A6ACHAl009302; Fri, 6 Nov 2020 11:12:17 +0100 Received: from dev.vm7.ccp.siemens.com (localhost [127.0.0.1]) by dev.vm7.ccp.siemens.com (Postfix) with ESMTP id 3422970FF8B; Fri, 6 Nov 2020 11:06:56 +0100 (CET) From: Andrej Valek To: robh@kernel.org, nick@shmanahar.org, hadess@hadess.net, dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Andrej Valek Subject: [PATCH v2 3/3] Input: goodix - add option to disable firmware loading Date: Fri, 6 Nov 2020 11:05:39 +0100 Message-Id: <20201106100539.6646-4-andrej.valek@siemens.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201029170313.25529-1-andrej.valek@siemens.com> References: <20201029170313.25529-1-andrej.valek@siemens.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Firmware file loadind for GT911 controller takes too much time (~60s). There is no check that configuration is the same which is already present. This happens always during boot, which makes touchscreen unusable. Add there an option to prevent firmware file loading, but keep it enabled by default. Signed-off-by: Andrej Valek --- drivers/input/touchscreen/goodix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 44336ecd2acd..41f8eb8963b1 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -943,7 +943,7 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts) ts->reset_controller_at_probe = true; /* Prevent cfg loading for each start */ ts->load_cfg_from_disk = !device_property_read_bool(dev, - "touchscreen-do-not-load-fw"); + "goodix-do-not-load-fw"); ts->irq_pin_access_method = IRQ_PIN_ACCESS_GPIO; } } From patchwork Tue Nov 10 09:07:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Valek, Andrej" X-Patchwork-Id: 321537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B753C55ABD for ; Tue, 10 Nov 2020 09:08:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1493920781 for ; Tue, 10 Nov 2020 09:08:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729943AbgKJJIZ (ORCPT ); Tue, 10 Nov 2020 04:08:25 -0500 Received: from goliath.siemens.de ([192.35.17.28]:34203 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730239AbgKJJIW (ORCPT ); Tue, 10 Nov 2020 04:08:22 -0500 Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id 0AA983k6023081 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Nov 2020 10:08:03 +0100 Received: from dev.vm7.ccp.siemens.com ([167.87.134.60]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id 0AA982vD003820; Tue, 10 Nov 2020 10:08:03 +0100 Received: from mail3.siemens.de (localhost [127.0.0.1]) by dev.vm7.ccp.siemens.com (Postfix) with ESMTP id 1F4F670BAB5; Tue, 10 Nov 2020 10:08:01 +0100 (CET) From: Andrej Valek To: robh@kernel.org, nick@shmanahar.org, hadess@hadess.net, dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Andrej Valek Subject: [PATCH v3 4/4] Input: st1232 - add support resolution reading Date: Tue, 10 Nov 2020 10:07:20 +0100 Message-Id: <20201110090720.6650-5-andrej.valek@siemens.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201106100539.6646-2-andrej.valek@siemens.com> References: <20201029170313.25529-1-andrej.valek@siemens.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Hard-coding resolution for st1633 device was wrong. Some of LCDs like YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too. But the resolution is not 320x480 as was hard-coded. Add new function which reads correct resolution directly from register. Signed-off-by: Andrej Valek --- drivers/input/touchscreen/st1232.c | 52 +++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index 63b29c7279e29..1b4b139c85330 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -26,15 +26,14 @@ #define ST1232_TS_NAME "st1232-ts" #define ST1633_TS_NAME "st1633-ts" +#define REG_XY_RESOLUTION 0x04 +#define REG_XY_COORDINATES 0x12 #define ST_TS_MAX_FINGERS 10 struct st_chip_info { bool have_z; - u16 max_x; - u16 max_y; u16 max_area; u16 max_fingers; - u8 start_reg; }; struct st1232_ts_data { @@ -48,15 +47,14 @@ struct st1232_ts_data { u8 *read_buf; }; -static int st1232_ts_read_data(struct st1232_ts_data *ts) +static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg) { struct i2c_client *client = ts->client; - u8 start_reg = ts->chip_info->start_reg; struct i2c_msg msg[] = { { .addr = client->addr, - .len = sizeof(start_reg), - .buf = &start_reg, + .len = sizeof(reg), + .buf = ®, }, { .addr = client->addr, @@ -74,6 +72,25 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts) return 0; } +static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x, + u16 *max_y) +{ + u8 *buf; + int error; + + /* select resolution register */ + error = st1232_ts_read_data(ts, REG_XY_RESOLUTION); + if (error) + return error; + + buf = ts->read_buf; + + *max_x = ((buf[0] & 0x0070) << 4) | buf[1]; + *max_y = ((buf[0] & 0x0007) << 8) | buf[2]; + + return 0; +} + static int st1232_ts_parse_and_report(struct st1232_ts_data *ts) { struct input_dev *input = ts->input_dev; @@ -123,7 +140,7 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id) int count; int error; - error = st1232_ts_read_data(ts); + error = st1232_ts_read_data(ts, REG_XY_COORDINATES); if (error) goto out; @@ -157,20 +174,14 @@ static void st1232_ts_power_off(void *data) static const struct st_chip_info st1232_chip_info = { .have_z = true, - .max_x = 0x31f, /* 800 - 1 */ - .max_y = 0x1df, /* 480 -1 */ .max_area = 0xff, .max_fingers = 2, - .start_reg = 0x12, }; static const struct st_chip_info st1633_chip_info = { .have_z = false, - .max_x = 0x13f, /* 320 - 1 */ - .max_y = 0x1df, /* 480 -1 */ .max_area = 0x00, .max_fingers = 5, - .start_reg = 0x12, }; static int st1232_ts_probe(struct i2c_client *client, @@ -179,6 +190,7 @@ static int st1232_ts_probe(struct i2c_client *client, const struct st_chip_info *match; struct st1232_ts_data *ts; struct input_dev *input_dev; + u16 max_x, max_y; int error; match = device_get_match_data(&client->dev); @@ -239,14 +251,22 @@ static int st1232_ts_probe(struct i2c_client *client, input_dev->name = "st1232-touchscreen"; input_dev->id.bustype = BUS_I2C; + /* read resolution from chip */ + error = st1232_ts_read_resolution(ts, &max_x, &max_y); + if (error) { + dev_err(&client->dev, + "Failed to read resolution: %d\n", error); + return error; + } + if (ts->chip_info->have_z) input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, ts->chip_info->max_area, 0, 0); input_set_abs_params(input_dev, ABS_MT_POSITION_X, - 0, ts->chip_info->max_x, 0, 0); + 0, max_x, 0, 0); input_set_abs_params(input_dev, ABS_MT_POSITION_Y, - 0, ts->chip_info->max_y, 0, 0); + 0, max_y, 0, 0); touchscreen_parse_properties(input_dev, true, &ts->prop);