[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221103-upstream-goodix-reset-v2-1-2c38fb03a300@theobroma-systems.com>
Date: Mon, 21 Nov 2022 18:17:18 +0100
From: Quentin Schulz <foss+kernel@...il.net>
To: Shawn Guo <shawnguo@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Heiko Stuebner <heiko@...ech.de>,
Samuel Holland <samuel@...lland.org>,
Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konrad.dybcio@...ainline.org>,
Fabio Estevam <festevam@...il.com>,
Jernej Skrabec <jernej.skrabec@...il.com>,
Bastien Nocera <hadess@...ess.net>,
Chen-Yu Tsai <wens@...e.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Hans de Goede <hdegoede@...hat.com>,
Andy Gross <agross@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
NXP Linux Team <linux-imx@....com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: Quentin Schulz <quentin.schulz@...obroma-systems.com>,
linux-kernel@...r.kernel.org, linux-rockchip@...ts.infradead.org,
linux-arm-msm@...r.kernel.org, linux-input@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
devicetree@...r.kernel.org
Subject: [PATCH RFC v2 1/7] Input: goodix - fix reset polarity
From: Quentin Schulz <quentin.schulz@...obroma-systems.com>
The reset line is asserted for selecting the I2C target address and then
deasserted.
This inverted logic works because the boards using this touchscreen
controller also invert the polarity of their reset GPIO.
Instead of depending on this double-inversion of meaning, let's *assert*
the line.
Signed-off-by: Quentin Schulz <quentin.schulz@...obroma-systems.com>
---
Changes in v2:
- implemented ACPI support as suggested by Hans,
- added comment on how to read gpiod_request_output and the GPIO DT polarity,
drivers/input/touchscreen/goodix.c | 45 +++++++++++++++++++++++++++++---------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index a33cc7950cf5b..da10cbb6f8264 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -742,8 +742,25 @@ int goodix_reset_no_int_sync(struct goodix_ts_data *ts)
{
int error;
- /* begin select I2C slave addr */
- error = gpiod_direction_output(ts->gpiod_rst, 0);
+ /*
+ * begin select I2C slave addr by activating/asserting RESET.
+ *
+ * The value passed to gpiod_direction_output is decorrelated from the
+ * actual physical state of the line. The 1 value here is just to
+ * specify the *assertion* of the line, its meaning being dependent on
+ * the HW design of the system.
+ *
+ * DT-based systems need to specify the GPIO level in which the reset is
+ * active. Since the touchscreen controller is in reset when its RESET
+ * line is low, it is the level of the GPIO that results in the RESET
+ * pin on the touchscreen controller side being low. In a HW design in
+ * which the GPIO is directly connected to the touchscreen controller
+ * RESET pin, this would be GPIO_ACTIVE_LOW.
+ *
+ * ACPI systems do not have the ability to specify the level of the GPIO
+ * and they are therefore all assumed active low.
+ */
+ error = gpiod_direction_output(ts->gpiod_rst, 1);
if (error)
goto error;
@@ -756,7 +773,8 @@ int goodix_reset_no_int_sync(struct goodix_ts_data *ts)
usleep_range(100, 2000); /* T3: > 100us */
- error = gpiod_direction_output(ts->gpiod_rst, 1);
+ /* Disable/de-assert RESET */
+ error = gpiod_direction_output(ts->gpiod_rst, 0);
if (error)
goto error;
@@ -797,23 +815,30 @@ static int goodix_reset(struct goodix_ts_data *ts)
}
#ifdef ACPI_GPIO_SUPPORT
-static const struct acpi_gpio_params first_gpio = { 0, 0, false };
-static const struct acpi_gpio_params second_gpio = { 1, 0, false };
+static const struct acpi_gpio_params int_first_gpio = { 0, 0, false };
+static const struct acpi_gpio_params int_second_gpio = { 1, 0, false };
+
+/*
+ * The controller is in reset when the RESET GPIO is output low, so
+ * set acpi_gpio_params.active_low appropriately.
+ */
+static const struct acpi_gpio_params rst_first_gpio = { 0, 0, true };
+static const struct acpi_gpio_params rst_second_gpio = { 1, 0, true };
static const struct acpi_gpio_mapping acpi_goodix_int_first_gpios[] = {
- { GOODIX_GPIO_INT_NAME "-gpios", &first_gpio, 1 },
- { GOODIX_GPIO_RST_NAME "-gpios", &second_gpio, 1 },
+ { GOODIX_GPIO_INT_NAME "-gpios", &int_first_gpio, 1 },
+ { GOODIX_GPIO_RST_NAME "-gpios", &rst_second_gpio, 1 },
{ },
};
static const struct acpi_gpio_mapping acpi_goodix_int_last_gpios[] = {
- { GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 },
- { GOODIX_GPIO_INT_NAME "-gpios", &second_gpio, 1 },
+ { GOODIX_GPIO_RST_NAME "-gpios", &rst_first_gpio, 1 },
+ { GOODIX_GPIO_INT_NAME "-gpios", &int_second_gpio, 1 },
{ },
};
static const struct acpi_gpio_mapping acpi_goodix_reset_only_gpios[] = {
- { GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 },
+ { GOODIX_GPIO_RST_NAME "-gpios", &rst_first_gpio, 1 },
{ },
};
--
b4 0.10.1
Powered by blists - more mailing lists