Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5998071rwb; Mon, 5 Dec 2022 06:48:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf48d491GP3RX4y3wwedoVb1yyHsedpj86GP4R3pYCa82j5ltkci9DRrijP9b5h9Qh8s8Q50 X-Received: by 2002:a17:903:251:b0:189:78d9:fe3c with SMTP id j17-20020a170903025100b0018978d9fe3cmr44781028plh.101.1670251723300; Mon, 05 Dec 2022 06:48:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670251723; cv=none; d=google.com; s=arc-20160816; b=d1xKEGZewFscPIqXULEEZdeQLsIxkbbZsXEgjVATF5sHOEAnMtXMEeDJEVtr37cw3w osLgBdEuDTTLS/q2tEAcsRjzaG3Pl2CGxvqy5REjS/BYTxGCkZn+m2tR79ulzPyH0F+J oQ9bAtd1ZYGjAcx7vZKp541mnSOl9u31Yofe6BxcYJPmwl8mycYsW6j7O54DGLyXY0KI cc2Ty9P1eZVHffFqTwV27tkDhj3LoGcEZLNIve+mQpZ6NH2leyTj7xBWSpLI+FQ38Nje 4EC2mN5LP0xLdWZLzMvIKi1hEN5Nw9u5kCl31IWK1qDn3R5mrgmb5OIArdvCaUVS6HX8 RguQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1v2dvqoGnIUnB3C3w0lQ3kyh6EI2JGVwx+Ss2ydctP8=; b=bCw+mpZ8MvHLUMRVdt/EsVZaSpRB+xVH7iasW8yH9xLiqmo+MED52XgPfd+sSVrWL7 nuPUfCpOn4mxBZygcqZc2+PPQ2kWdmfEuMHr9MmvZXWuwRdSoPZF9fl5w+Tz/dOpIbDc m3uKXgzedv9rgvOSmMlRp1Z7wmQ+BB0oI7Uq+xcDawHcwxM8HYoT6Sgu7NUHdyo9/0Q+ xSbMDJ5XeOVgUWUGl360mDuaAgUcJgbiMhzW5UBfjsPSO9qZLk4i9SAIqd5OXyboUyWB UqTAP//8tS6Uvr+5VQFY5p4Fi2oO04pMvDlaFPZcYz7aoTU8LzJ9h+zPWblZAkM5gZWF 3+GQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p1-20020a635b01000000b00477b64d8e5csi14970229pgb.160.2022.12.05.06.48.30; Mon, 05 Dec 2022 06:48:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbiLENlq (ORCPT + 81 others); Mon, 5 Dec 2022 08:41:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232295AbiLENlm (ORCPT ); Mon, 5 Dec 2022 08:41:42 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19BEF1CFD7; Mon, 5 Dec 2022 05:41:39 -0800 (PST) Received: (Authenticated sender: foss@0leil.net) by mail.gandi.net (Postfix) with ESMTPSA id 68281FF807; Mon, 5 Dec 2022 13:41:26 +0000 (UTC) From: Quentin Schulz To: Samuel Holland , Bastien Nocera , =?UTF-8?q?Guido=20G=C3=BCnther?= , Sascha Hauer , Pengutronix Kernel Team , Angus Ainslie , Ondrej Jirman , Icenowy Zheng , Andy Gross , Aleksei Mamlin , Fabio Estevam , David Jander , Frieder Schrempf , Bjorn Andersson , Konrad Dybcio , Peter Geis , Heiko Stuebner , Shawn Guo , Jernej Skrabec , Lukasz Majewski , AngeloGioacchino Del Regno , Chen-Yu Tsai , Michael Riesch , Rob Herring , NXP Linux Team , Dmitry Torokhov , Hans de Goede , Jagan Teki , Krzysztof Kozlowski Cc: Quentin Schulz , linux-input@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, devicetree@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: [PATCH v3 3/9] Input: goodix - fix reset polarity Date: Mon, 5 Dec 2022 14:40:32 +0100 Message-Id: <20221103-upstream-goodix-reset-v3-3-0975809eb183@theobroma-systems.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221103-upstream-goodix-reset-v3-0-0975809eb183@theobroma-systems.com> References: <20221103-upstream-goodix-reset-v3-0-0975809eb183@theobroma-systems.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.10.1 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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 1639f2f8a31e3..5fff9483640c9 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; @@ -806,23 +824,30 @@ static int goodix_reset(struct goodix_ts_data *ts) .quirks = ACPI_GPIO_QUIRK_NO_IO_RESTRICTION, \ } -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_MAPPING(GOODIX_GPIO_INT_NAME "-gpios", &first_gpio, 1), - GOODIX_GPIO_MAPPING(GOODIX_GPIO_RST_NAME "-gpios", &second_gpio, 1), + GOODIX_GPIO_MAPPING(GOODIX_GPIO_INT_NAME "-gpios", &int_first_gpio, 1), + GOODIX_GPIO_MAPPING(GOODIX_GPIO_RST_NAME "-gpios", &rst_second_gpio, 1), { }, }; static const struct acpi_gpio_mapping acpi_goodix_int_last_gpios[] = { - GOODIX_GPIO_MAPPING(GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1), - GOODIX_GPIO_MAPPING(GOODIX_GPIO_INT_NAME "-gpios", &second_gpio, 1), + GOODIX_GPIO_MAPPING(GOODIX_GPIO_RST_NAME "-gpios", &rst_first_gpio, 1), + GOODIX_GPIO_MAPPING(GOODIX_GPIO_INT_NAME "-gpios", &int_second_gpio, 1), { }, }; static const struct acpi_gpio_mapping acpi_goodix_reset_only_gpios[] = { - GOODIX_GPIO_MAPPING(GOODIX_GPIO_RST_NAME "-gpios", &first_gpio, 1), + GOODIX_GPIO_MAPPING(GOODIX_GPIO_RST_NAME "-gpios", &rst_first_gpio, 1), { }, }; -- b4 0.10.1