From mboxrd@z Thu Jan 1 00:00:00 1970 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 9E0E7C433FE for ; Mon, 21 Nov 2022 17:19:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231441AbiKURTa convert rfc822-to-8bit (ORCPT ); Mon, 21 Nov 2022 12:19:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231450AbiKURTN (ORCPT ); Mon, 21 Nov 2022 12:19:13 -0500 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B111958E; Mon, 21 Nov 2022 09:17:51 -0800 (PST) Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id 655B060006; Mon, 21 Nov 2022 17:17:43 +0000 (UTC) From: Quentin Schulz To: Shawn Guo , Krzysztof Kozlowski , Heiko Stuebner , Samuel Holland , Bjorn Andersson , Konrad Dybcio , Fabio Estevam , Jernej Skrabec , Bastien Nocera , Chen-Yu Tsai , Sascha Hauer , Pengutronix Kernel Team , Hans de Goede , Andy Gross , Rob Herring , NXP Linux Team , Dmitry Torokhov Cc: Quentin Schulz , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, devicetree@vger.kernel.org Subject: [PATCH RFC v2 1/7] Input: goodix - fix reset polarity Date: Mon, 21 Nov 2022 18:17:18 +0100 Message-Id: <20221103-upstream-goodix-reset-v2-1-2c38fb03a300@theobroma-systems.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221103-upstream-goodix-reset-v2-0-2c38fb03a300@theobroma-systems.com> References: <20221103-upstream-goodix-reset-v2-0-2c38fb03a300@theobroma-systems.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.10.1 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Quentin Schulz 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 --- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A759BC433FE for ; Mon, 21 Nov 2022 17:28:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Tb6ibBqapeq8tBOaffHg4A+FXNnQyyTC+gVm374vEu4=; b=DywpLb1utH99SF Ogb5xOAncLX6uGPd51kE8ZprjZ6mtA+UTcOu9ChWRsxJxFi0o6fQo+34fuEbNKvoCHHkqfFRg1Wl6 BQUL5/+TkSYwQBSKw/A2s+Gyj3mm4cMLxFet0Yy9HCqhPjaFT5DJJCNWuSzPnIbNCZymNjeNx5rhZ ep/F+WiZPZbGcPkRy+MaNA6VzM1W5qE1YucWdjaHa6Bj1AOYbNCddUXag16m8IKDbNYsKHpdQZ1B3 ztz4VDiUENuzEkbrXo62+lbNXLVgQxYxLD3KDT1VTsjkY6ul9iYTZLVcHt5Ct9tebfUrChqfW50dl fCworpDjJwEARSAdU8+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxAZo-00GIbB-Fv; Mon, 21 Nov 2022 17:27:24 +0000 Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxAQn-00GEG9-Qj; Mon, 21 Nov 2022 17:18:13 +0000 Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id 655B060006; Mon, 21 Nov 2022 17:17:43 +0000 (UTC) From: Quentin Schulz To: Shawn Guo , Krzysztof Kozlowski , Heiko Stuebner , Samuel Holland , Bjorn Andersson , Konrad Dybcio , Fabio Estevam , Jernej Skrabec , Bastien Nocera , Chen-Yu Tsai , Sascha Hauer , Pengutronix Kernel Team , Hans de Goede , Andy Gross , Rob Herring , NXP Linux Team , Dmitry Torokhov Cc: Quentin Schulz , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, devicetree@vger.kernel.org Subject: [PATCH RFC v2 1/7] Input: goodix - fix reset polarity Date: Mon, 21 Nov 2022 18:17:18 +0100 Message-Id: <20221103-upstream-goodix-reset-v2-1-2c38fb03a300@theobroma-systems.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221103-upstream-goodix-reset-v2-0-2c38fb03a300@theobroma-systems.com> References: <20221103-upstream-goodix-reset-v2-0-2c38fb03a300@theobroma-systems.com> MIME-Version: 1.0 X-Mailer: b4 0.10.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221121_091806_224108_094CA7C1 X-CRM114-Status: GOOD ( 13.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Quentin Schulz 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 --- 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58A91C433FE for ; Mon, 21 Nov 2022 17:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VFjW+R1TxJnHVN1nd5DIpO78HelmBOHGVb2375IVV/I=; b=xm0A6MIzQr95tB +f0CtjIKyI3RZG+Tslw8wWKbfocw7YN21FGuhkmkdQSZgMybYcYEnilYn5XkMCeh+iuo9rOPYDHuK 7kQFkH1pxB0U06eepYlawzeCLoFfMDIBJ9HZLuXBElAXWvxZewnSM3cOZLu5HjLoS/Qn6tLVibsSD wqz+v2ih5QoctO+DugqYcj2HdQppgpQH6oBGryfONM9xtMZ+eaM97UU2ilTOb/DQ8IPp3o24bR4vK sBGoiFUA8f/HikdG83ltvJ8dUO0+ZUg1610eHBfyxdz4YGwfcFN18kl0qjf1FUJeotpXsI7VE3rji 2lQPcUw7OZKUjCFjhviQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxAc6-00GJdD-JV; Mon, 21 Nov 2022 17:29:46 +0000 Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxAQn-00GEG9-Qj; Mon, 21 Nov 2022 17:18:13 +0000 Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id 655B060006; Mon, 21 Nov 2022 17:17:43 +0000 (UTC) From: Quentin Schulz To: Shawn Guo , Krzysztof Kozlowski , Heiko Stuebner , Samuel Holland , Bjorn Andersson , Konrad Dybcio , Fabio Estevam , Jernej Skrabec , Bastien Nocera , Chen-Yu Tsai , Sascha Hauer , Pengutronix Kernel Team , Hans de Goede , Andy Gross , Rob Herring , NXP Linux Team , Dmitry Torokhov Cc: Quentin Schulz , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, devicetree@vger.kernel.org Subject: [PATCH RFC v2 1/7] Input: goodix - fix reset polarity Date: Mon, 21 Nov 2022 18:17:18 +0100 Message-Id: <20221103-upstream-goodix-reset-v2-1-2c38fb03a300@theobroma-systems.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221103-upstream-goodix-reset-v2-0-2c38fb03a300@theobroma-systems.com> References: <20221103-upstream-goodix-reset-v2-0-2c38fb03a300@theobroma-systems.com> MIME-Version: 1.0 X-Mailer: b4 0.10.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221121_091806_224108_094CA7C1 X-CRM114-Status: GOOD ( 13.01 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: Quentin Schulz 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 --- 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 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [217.70.178.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E77F6FAD for ; Mon, 21 Nov 2022 17:34:23 +0000 (UTC) Received: from relay3-d.mail.gandi.net (unknown [217.70.183.195]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 98845C3DDE for ; Mon, 21 Nov 2022 17:17:58 +0000 (UTC) Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id 655B060006; Mon, 21 Nov 2022 17:17:43 +0000 (UTC) From: Quentin Schulz To: Shawn Guo , Krzysztof Kozlowski , Heiko Stuebner , Samuel Holland , Bjorn Andersson , Konrad Dybcio , Fabio Estevam , Jernej Skrabec , Bastien Nocera , Chen-Yu Tsai , Sascha Hauer , Pengutronix Kernel Team , Hans de Goede , Andy Gross , Rob Herring , NXP Linux Team , Dmitry Torokhov Cc: Quentin Schulz , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, devicetree@vger.kernel.org Subject: [PATCH RFC v2 1/7] Input: goodix - fix reset polarity Date: Mon, 21 Nov 2022 18:17:18 +0100 Message-Id: <20221103-upstream-goodix-reset-v2-1-2c38fb03a300@theobroma-systems.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221103-upstream-goodix-reset-v2-0-2c38fb03a300@theobroma-systems.com> References: <20221103-upstream-goodix-reset-v2-0-2c38fb03a300@theobroma-systems.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.10.1 Content-Transfer-Encoding: quoted-printable From: Quentin Schulz =0D The reset line is asserted for selecting the I2C target address and then=0D deasserted.=0D =0D This inverted logic works because the boards using this touchscreen=0D controller also invert the polarity of their reset GPIO.=0D =0D Instead of depending on this double-inversion of meaning, let's *assert*=0D the line.=0D =0D Signed-off-by: Quentin Schulz =0D ---=0D Changes in v2:=0D - implemented ACPI support as suggested by Hans,=0D - added comment on how to read gpiod_request_output and the GPIO DT polarit= y,=0D =0D drivers/input/touchscreen/goodix.c | 45 +++++++++++++++++++++++++++++-----= ----=0D 1 file changed, 35 insertions(+), 10 deletions(-)=0D =0D diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen= /goodix.c=0D index a33cc7950cf5b..da10cbb6f8264 100644=0D --- a/drivers/input/touchscreen/goodix.c=0D +++ b/drivers/input/touchscreen/goodix.c=0D @@ -742,8 +742,25 @@ int goodix_reset_no_int_sync(struct goodix_ts_data *ts= )=0D {=0D int error;=0D =0D - /* begin select I2C slave addr */=0D - error =3D gpiod_direction_output(ts->gpiod_rst, 0);=0D + /*=0D + * begin select I2C slave addr by activating/asserting RESET.=0D + *=0D + * The value passed to gpiod_direction_output is decorrelated from the=0D + * actual physical state of the line. The 1 value here is just to=0D + * specify the *assertion* of the line, its meaning being dependent on=0D + * the HW design of the system.=0D + *=0D + * DT-based systems need to specify the GPIO level in which the reset is= =0D + * active. Since the touchscreen controller is in reset when its RESET=0D + * line is low, it is the level of the GPIO that results in the RESET=0D + * pin on the touchscreen controller side being low. In a HW design in=0D + * which the GPIO is directly connected to the touchscreen controller=0D + * RESET pin, this would be GPIO_ACTIVE_LOW.=0D + *=0D + * ACPI systems do not have the ability to specify the level of the GPIO= =0D + * and they are therefore all assumed active low.=0D + */=0D + error =3D gpiod_direction_output(ts->gpiod_rst, 1);=0D if (error)=0D goto error;=0D =0D @@ -756,7 +773,8 @@ int goodix_reset_no_int_sync(struct goodix_ts_data *ts)= =0D =0D usleep_range(100, 2000); /* T3: > 100us */=0D =0D - error =3D gpiod_direction_output(ts->gpiod_rst, 1);=0D + /* Disable/de-assert RESET */=0D + error =3D gpiod_direction_output(ts->gpiod_rst, 0);=0D if (error)=0D goto error;=0D =0D @@ -797,23 +815,30 @@ static int goodix_reset(struct goodix_ts_data *ts)=0D }=0D =0D #ifdef ACPI_GPIO_SUPPORT=0D -static const struct acpi_gpio_params first_gpio =3D { 0, 0, false };=0D -static const struct acpi_gpio_params second_gpio =3D { 1, 0, false };=0D +static const struct acpi_gpio_params int_first_gpio =3D { 0, 0, false };=0D +static const struct acpi_gpio_params int_second_gpio =3D { 1, 0, false };= =0D +=0D +/*=0D + * The controller is in reset when the RESET GPIO is output low, so=0D + * set acpi_gpio_params.active_low appropriately.=0D + */=0D +static const struct acpi_gpio_params rst_first_gpio =3D { 0, 0, true };=0D +static const struct acpi_gpio_params rst_second_gpio =3D { 1, 0, true };=0D =0D static const struct acpi_gpio_mapping acpi_goodix_int_first_gpios[] =3D {= =0D - { GOODIX_GPIO_INT_NAME "-gpios", &first_gpio, 1 },=0D - { GOODIX_GPIO_RST_NAME "-gpios", &second_gpio, 1 },=0D + { GOODIX_GPIO_INT_NAME "-gpios", &int_first_gpio, 1 },=0D + { GOODIX_GPIO_RST_NAME "-gpios", &rst_second_gpio, 1 },=0D { },=0D };=0D =0D static const struct acpi_gpio_mapping acpi_goodix_int_last_gpios[] =3D {=0D - { GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 },=0D - { GOODIX_GPIO_INT_NAME "-gpios", &second_gpio, 1 },=0D + { GOODIX_GPIO_RST_NAME "-gpios", &rst_first_gpio, 1 },=0D + { GOODIX_GPIO_INT_NAME "-gpios", &int_second_gpio, 1 },=0D { },=0D };=0D =0D static const struct acpi_gpio_mapping acpi_goodix_reset_only_gpios[] =3D {= =0D - { GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1 },=0D + { GOODIX_GPIO_RST_NAME "-gpios", &rst_first_gpio, 1 },=0D { },=0D };=0D =0D =0D -- =0D b4 0.10.1=0D