From patchwork Thu Feb 17 16:55:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 543530 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 35A05C433F5 for ; Thu, 17 Feb 2022 16:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243507AbiBQQ43 (ORCPT ); Thu, 17 Feb 2022 11:56:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243484AbiBQQ4X (ORCPT ); Thu, 17 Feb 2022 11:56:23 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F125D2B356B for ; Thu, 17 Feb 2022 08:56:08 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id p14so8677620ejf.11 for ; Thu, 17 Feb 2022 08:56:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5FXIG1Rp9D4NgAZ2oOx6JgdhKdrDvM+0LjdQT4OHOI8=; b=VnHYi5Wj0YE13I1AUCj+Cx7Y1RB4UEuq7ssWnN/HkT+mon1Tdocm01PyP/Mo+KI926 qtqHU7Q3+Zhd+OKwP2A1ZubKIqIaVXkVadLxfkQF5yqe4ir0MV5a1T1hzQ19VEKHryMm /ZaohaM4t2K6QOwE3FSWbTCfnlQ+6aHmcmulA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5FXIG1Rp9D4NgAZ2oOx6JgdhKdrDvM+0LjdQT4OHOI8=; b=GdMltGxP4f9G7lYzXbaiMQTSkZNgUlfsBswZbzmwgZV4Fp1EKPx8lTGWYbp7AlIr5E bUyTL+HNueNfGQdL/jfUadFklM3bOVBh0k5UK4aO+FtuAoS4OrSkvcRiG1aq/qLkHote 5Xbz+bDVnZgKSB2rgEecppcIT8cdK2NFZ3wUFtJjm/WP+g7+tCUSjwm0Qi0MzY/JDFIW DJmL9uYKA7DZQ6N7j+deLd0SxNBXT53H4nEPhV4Ur7tYyH/lt+1zSpItbmO5mTZ3vl0u CJ771y1AFQKyIMSOxnlewtF8Vw8VaUuVjpr5khdRpjMiisEl0OksvEPFunHC15QKbQSl sduw== X-Gm-Message-State: AOAM533GX8W+mE4Rxg39zKliV3HawHSh0Q1Gyo6s/tIYUz9FLsHXdoA3 RxmgBAMEiNNJ6RDk+M+JsEPz9Q== X-Google-Smtp-Source: ABdhPJwUJDfUAOD47DS3HfFExOVcay3yIGwA7ZYdpu7Vcp+s3rokOfa5/fg5Z5uwP/kn2w3E7Ebf3Q== X-Received: by 2002:a17:906:e218:b0:6cf:7483:36c8 with SMTP id gf24-20020a170906e21800b006cf748336c8mr3042038ejb.747.1645116967527; Thu, 17 Feb 2022 08:56:07 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-87-0-15-73.retail.telecomitalia.it. [87.0.15.73]) by smtp.gmail.com with ESMTPSA id v4sm965323ejb.72.2022.02.17.08.56.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 08:56:06 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Dario Binacchi , Michael Trimarchi , Dmitry Torokhov , Marco Felsch , Oliver Graute , Stephan Gerhold , linux-input@vger.kernel.org Subject: [PATCH v2 2/6] Input: edt-ft5x06 - get/set M12 report rate by sysfs Date: Thu, 17 Feb 2022 17:55:54 +0100 Message-Id: <20220217165559.313366-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220217165559.313366-1-dario.binacchi@amarulasolutions.com> References: <20220217165559.313366-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add support for reading/writing scan rate (SC) register for M12 by sysfs. The register value is equal to the SC (Hz), unlike M06, where instead it is equal to SC / 10. Co-developed-by: Michael Trimarchi Signed-off-by: Michael Trimarchi Tested-by: Dario Binacchi Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/input/touchscreen/edt-ft5x06.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index bb2e1cbffba7..77f061af5c61 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -47,6 +47,8 @@ #define M09_REGISTER_NUM_X 0x94 #define M09_REGISTER_NUM_Y 0x95 +#define M12_REGISTER_REPORT_RATE 0x88 + #define EV_REGISTER_THRESHOLD 0x40 #define EV_REGISTER_GAIN 0x41 #define EV_REGISTER_OFFSET_Y 0x45 @@ -523,9 +525,9 @@ static EDT_ATTR(offset_y, S_IWUSR | S_IRUGO, NO_REGISTER, NO_REGISTER, /* m06: range 20 to 80, m09: range 0 to 30, m12: range 1 to 255... */ static EDT_ATTR(threshold, S_IWUSR | S_IRUGO, WORK_REGISTER_THRESHOLD, M09_REGISTER_THRESHOLD, EV_REGISTER_THRESHOLD, 0, 255); -/* m06: range 3 to 14, m12: (0x64: 100Hz) */ +/* m06: range 3 to 14, m12: range 1 to 255 */ static EDT_ATTR(report_rate, S_IWUSR | S_IRUGO, WORK_REGISTER_REPORT_RATE, - NO_REGISTER, NO_REGISTER, 0, 255); + M12_REGISTER_REPORT_RATE, NO_REGISTER, 0, 255); static struct attribute *edt_ft5x06_attrs[] = { &edt_ft5x06_attr_gain.dattr.attr, @@ -1030,7 +1032,8 @@ static void edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) case EDT_M09: case EDT_M12: reg_addr->reg_threshold = M09_REGISTER_THRESHOLD; - reg_addr->reg_report_rate = NO_REGISTER; + reg_addr->reg_report_rate = tsdata->version == EDT_M12 ? + M12_REGISTER_REPORT_RATE : NO_REGISTER; reg_addr->reg_gain = M09_REGISTER_GAIN; reg_addr->reg_offset = M09_REGISTER_OFFSET; reg_addr->reg_offset_x = NO_REGISTER; From patchwork Thu Feb 17 16:55:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 543529 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 937F2C4332F for ; Thu, 17 Feb 2022 16:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243484AbiBQQ4a (ORCPT ); Thu, 17 Feb 2022 11:56:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243472AbiBQQ4Z (ORCPT ); Thu, 17 Feb 2022 11:56:25 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3EC32B356E for ; Thu, 17 Feb 2022 08:56:10 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id p9so8746318ejd.6 for ; Thu, 17 Feb 2022 08:56:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CDm5jz0D+G162hhNQQb+42Oen0khrTArByJVDch1fBg=; b=d/xa9ZzlkaV74zSGE4aEZA5l+U6zoyyQLko3FPT+5xJO/khMDluXU5Ql2O6iL64Vfq Bsm03d+JHrsnJ0miXZ9L/+hpk4zzcgJOHfLzmmZIMBvVynfu4aGDyhAhYFZdbuRFNwf1 jOykPokMVmOdGksVryUHgQwEbOB/uE3U64eRQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CDm5jz0D+G162hhNQQb+42Oen0khrTArByJVDch1fBg=; b=aoeP3NdFqS/F/1ASOvHZpgAvpXueoC8YZHB3J1oqFkKxZES09ZFQ74cxm3hNLcjkjq EizoUveNzqc5DFIUCsQzJcpeV9ITiq1saiBw+XKwpfe53Vl2ebge9oZPH5XayTw5HlPg F+BfaX4Jzn4wBmG0r9PRCGCMoLLYIdjLmiEV40x6yZnkQQedt0bhDeeqODAFJLsab6hf Msjj8WFn0DNgJ5vjiOJjRbEAxBLmkYLJUheLN7GWSMEmriZcnrru3A1+K03tdL9JuGe/ fKZo2FwoEdGKqUnM2ATfB+bAUKMGGUHO2IkAitpf/07ROL6lJKVMj+d8Lu23Y+csQIEb jAIQ== X-Gm-Message-State: AOAM530AYIrrQow6tBSl/PzmIZ7JVrkb4ICOjif9EwMvRah7kiXPag0C dNIGVuglIDlZ/aGlOwzWKlhOOrmNBRs78w== X-Google-Smtp-Source: ABdhPJzzjCUyb0VmdzDUT42y8ZyBZDTPXeCXWb/oUvKUkjhvpgJKI/xCdxMVYxQJ+byNmygM5FY1vQ== X-Received: by 2002:a17:906:3283:b0:6ce:78f9:fafd with SMTP id 3-20020a170906328300b006ce78f9fafdmr3048502ejw.534.1645116969198; Thu, 17 Feb 2022 08:56:09 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-87-0-15-73.retail.telecomitalia.it. [87.0.15.73]) by smtp.gmail.com with ESMTPSA id v4sm965323ejb.72.2022.02.17.08.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 08:56:08 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Dario Binacchi , Michael Trimarchi , Dmitry Torokhov , Oliver Graute , Stephan Gerhold , linux-input@vger.kernel.org Subject: [PATCH v2 3/6] Input: edt-ft5x06 - set report rate by dts property Date: Thu, 17 Feb 2022 17:55:55 +0100 Message-Id: <20220217165559.313366-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220217165559.313366-1-dario.binacchi@amarulasolutions.com> References: <20220217165559.313366-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org It allows to change the M06/M12 default scan rate on driver probing. Co-developed-by: Michael Trimarchi Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/input/touchscreen/edt-ft5x06.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 77f061af5c61..b3e492cfc41c 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -1213,6 +1213,14 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, edt_ft5x06_ts_get_defaults(&client->dev, tsdata); edt_ft5x06_ts_get_parameters(tsdata); + if (tsdata->reg_addr.reg_report_rate != NO_REGISTER && + !of_property_read_u32(client->dev.of_node, "report-rate", + (u32 *)&tsdata->report_rate)) { + edt_ft5x06_register_write(tsdata, + tsdata->reg_addr.reg_report_rate, + tsdata->report_rate); + } + dev_dbg(&client->dev, "Model \"%s\", Rev. \"%s\", %dx%d sensors\n", tsdata->name, fw_version, tsdata->num_x, tsdata->num_y); From patchwork Thu Feb 17 16:55:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 543528 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 DBCB4C43219 for ; Thu, 17 Feb 2022 16:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243493AbiBQQ4b (ORCPT ); Thu, 17 Feb 2022 11:56:31 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243501AbiBQQ43 (ORCPT ); Thu, 17 Feb 2022 11:56:29 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7315F2B357F for ; Thu, 17 Feb 2022 08:56:13 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id vz16so8877553ejb.0 for ; Thu, 17 Feb 2022 08:56:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qYQz8gky+qHKsHMYT1BO0VS7TpJLRjv0uSqSzI+TAgE=; b=dlrddxDbzDVUNrDPxjnn0fmRX/EXv8asQmJobbE6eGLg93BV+JOb3qtyE9hIWqJ3Pd tQYzpoGxJf5npBm3k4VgypdVrmFLk8fGYn6jVk7c9XQJwNVdOLxWY0lAOI4S4ToQQjKW 8HcAqqJQov6RB+eRFZjFKdg6GnKdiy7nKwIs0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qYQz8gky+qHKsHMYT1BO0VS7TpJLRjv0uSqSzI+TAgE=; b=DmHz9Om5OxnXkRnyr8eP1wCRLrM2pAkWSioI43xfl9g3y9gEz22OTRriJgwSOgxBVf nAk6Mh1o+Cme9jA7YH277mBe0WWwMcdq+nyU40q+8Jy0+groW1rN2kcnHZaQi/kDCKWE NofqSHOQbuD/VV3uc4F5CC9FkOLFXcIOt2AtsyUksuT/fMFDXw+tkvjt/6gCVrxkDTY3 NAPdwpzlsKlCR2FzifEcEaQ3TsiglYsjGwAuqYds4e9kENHVzPu9oEI8WtFixpRstoYo oajI95nR8eYaU5+0RIA3YkJM76v1zrCd8rZEDteE9SyCbX1+fuB1Wk7RQaKrYGtOH0Ff KZsQ== X-Gm-Message-State: AOAM532f77000s8wZGBu0SsYoaBDrYJsMF/d6YNKuY38mdjrPSBVo7CO d82DsmyE02WoRo9miF/gy8h4LQ== X-Google-Smtp-Source: ABdhPJyPXSGmnM8vcnQUMCoJo0vgIHpbH9uH2okTjPQXaZSSezf4M/eAihkkyXrjbgWTspU2mgStCw== X-Received: by 2002:a17:907:6006:b0:6ce:46f:fe4b with SMTP id fs6-20020a170907600600b006ce046ffe4bmr2906289ejc.7.1645116971996; Thu, 17 Feb 2022 08:56:11 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-87-0-15-73.retail.telecomitalia.it. [87.0.15.73]) by smtp.gmail.com with ESMTPSA id v4sm965323ejb.72.2022.02.17.08.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 08:56:11 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Dario Binacchi , Michael Trimarchi , Oliver Graute , Dmitry Torokhov , Stephan Gerhold , linux-input@vger.kernel.org Subject: [PATCH v2 5/6] Input: edt-ft5x06 - show firmware version by sysfs Date: Thu, 17 Feb 2022 17:55:57 +0100 Message-Id: <20220217165559.313366-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220217165559.313366-1-dario.binacchi@amarulasolutions.com> References: <20220217165559.313366-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The firmware version was printed only if debug mode was enabled. Now you can always get it from sysfs. Co-developed-by: Michael Trimarchi Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi Acked-by: Oliver Graute --- (no changes since v1) drivers/input/touchscreen/edt-ft5x06.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index eb1231d1c0b4..2c946c155108 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -129,6 +129,7 @@ struct edt_ft5x06_ts_data { int max_support_points; char name[EDT_NAME_LEN]; + char fw_version[EDT_NAME_LEN]; struct edt_reg_addr reg_addr; enum edt_ver version; @@ -540,6 +541,17 @@ static ssize_t model_show(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR_RO(model); +static ssize_t fw_version_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); + + return scnprintf(buf, PAGE_SIZE, "%s\n", tsdata->fw_version); +} + +static DEVICE_ATTR_RO(fw_version); + static struct attribute *edt_ft5x06_attrs[] = { &edt_ft5x06_attr_gain.dattr.attr, &edt_ft5x06_attr_offset.dattr.attr, @@ -548,6 +560,7 @@ static struct attribute *edt_ft5x06_attrs[] = { &edt_ft5x06_attr_threshold.dattr.attr, &edt_ft5x06_attr_report_rate.dattr.attr, &dev_attr_model.attr, + &dev_attr_fw_version.attr, NULL }; @@ -834,13 +847,13 @@ static void edt_ft5x06_ts_teardown_debugfs(struct edt_ft5x06_ts_data *tsdata) #endif /* CONFIG_DEBUGFS */ static int edt_ft5x06_ts_identify(struct i2c_client *client, - struct edt_ft5x06_ts_data *tsdata, - char *fw_version) + struct edt_ft5x06_ts_data *tsdata) { u8 rdbuf[EDT_NAME_LEN]; char *p; int error; char *model_name = tsdata->name; + char *fw_version = tsdata->fw_version; /* see what we find if we assume it is a M06 * * if we get less than EDT_NAME_LEN, we don't want @@ -1096,7 +1109,6 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, struct input_dev *input; unsigned long irq_flags; int error; - char fw_version[EDT_NAME_LEN]; dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n"); @@ -1209,7 +1221,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, tsdata->input = input; tsdata->factory_mode = false; - error = edt_ft5x06_ts_identify(client, tsdata, fw_version); + error = edt_ft5x06_ts_identify(client, tsdata); if (error) { dev_err(&client->dev, "touchscreen probe failed\n"); return error; @@ -1235,7 +1247,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, dev_dbg(&client->dev, "Model \"%s\", Rev. \"%s\", %dx%d sensors\n", - tsdata->name, fw_version, tsdata->num_x, tsdata->num_y); + tsdata->name, tsdata->fw_version, tsdata->num_x, tsdata->num_y); input->name = tsdata->name; input->id.bustype = BUS_I2C;