From patchwork Sun Apr 3 16:09:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 12799646 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 B23ECC4321E for ; Sun, 3 Apr 2022 16:10:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359348AbiDCQMI (ORCPT ); Sun, 3 Apr 2022 12:12:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359346AbiDCQMH (ORCPT ); Sun, 3 Apr 2022 12:12:07 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A444D26541 for ; Sun, 3 Apr 2022 09:10:13 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id n6so1263452ejc.13 for ; Sun, 03 Apr 2022 09:10:13 -0700 (PDT) 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=NIUuHRgvgWCmYJCricL+FHDsiVQYgUJ0FjEwcnUqvHA=; b=hd7rJB3C5Y4XSBLY/KDKNm08VdUSXnsrPOnuFOPdrlqeDPMGdLcvJEGg9NRy1ZVmqE kIJMPZGO7jdv4gvLF3mT2f7CTWyXpAWq2pxte1SUnWvkOV+pjXbiZ4phZMKeS8uKzI2K EghIZ+5W8Qsb0YW2CVvKairMG5L58p1T1ljxE= 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=NIUuHRgvgWCmYJCricL+FHDsiVQYgUJ0FjEwcnUqvHA=; b=kcs+Y1nGrBTkO24A/p42tkp2cxezqMPxr5D4DMp2gQ2Y0YOqaKg9mOR5zZ+TDTuLZV Zwc+gVqSiicZNrQfUxRccydQTO21DyknN05gRkLcLHNMSj7ZDgS963BmwcuYJo6E/JK8 YvfiJOdDko3AHH4IUWt/P/o6Ihf9ZO+V7lI++p1kdvBvDggfdhqe9QB/LMZ3e09P+hze 54WoNllGZLBzWA2MeoJoXb1/3iMJyxMjUGLdJNuIEqB4g5Zp57PPoNDLQ943cqr+jwuY qxSfeyGDDjNkdYCuyF3esKNV/1YJHQls3wAguIAPEJ1Q6qhcrqQ6lZIFPPA5JIsVYHuU GTuw== X-Gm-Message-State: AOAM531BOcws34RNOd8I7KWlpW1iW4Ei434HCn/QvY+VoPmtaYBLZXVa BeWEGnzE0gsaMbCuKj2WzDgOsMcZE9/hAA== X-Google-Smtp-Source: ABdhPJwxkkD74Kb5RSwttXg/1bmRJ+1VogERBB+jgoNHYldMlN+gM2rpVZRa1xb20ZeUACCAea1MMA== X-Received: by 2002:a17:907:6d12:b0:6e4:cd9b:c7f0 with SMTP id sa18-20020a1709076d1200b006e4cd9bc7f0mr7354000ejc.628.1649002212208; Sun, 03 Apr 2022 09:10:12 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-0-15-73.retail.telecomitalia.it. [87.0.15.73]) by smtp.gmail.com with ESMTPSA id do8-20020a170906c10800b006dfe2af50d8sm3350119ejc.121.2022.04.03.09.10.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 09:10:11 -0700 (PDT) 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 v4 3/6] Input: edt-ft5x06 - set report rate by dts property Date: Sun, 3 Apr 2022 18:09:36 +0200 Message-Id: <20220403160939.541621-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220403160939.541621-1-dario.binacchi@amarulasolutions.com> References: <20220403160939.541621-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 v3) Changes in v3: - Check the lower and upper limits of the report-rate-hz value - Convert the M06 report-rate-hz value drivers/input/touchscreen/edt-ft5x06.c | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 77f061af5c61..843e8b0522f7 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -1084,6 +1084,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, struct input_dev *input; unsigned long irq_flags; int error; + u32 report_rate; char fw_version[EDT_NAME_LEN]; dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n"); @@ -1213,6 +1214,35 @@ 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-hz", + &report_rate)) { + tsdata->report_rate = report_rate; + if (tsdata->version == EDT_M06) { + if (report_rate < 30) + report_rate = 30; + else if (report_rate > 140) + report_rate = 140; + } else if (report_rate < 1) { + report_rate = 1; + } else if (report_rate > 255) + report_rate = 255; + + if (report_rate != tsdata->report_rate) + dev_warn(&client->dev, + "report-rate %dHz is unsupported, use %dHz\n", + tsdata->report_rate, report_rate); + + if (tsdata->version == EDT_M06) + report_rate /= 10; + + tsdata->report_rate = 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);