From patchwork Mon Sep 2 12:43:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Cai X-Patchwork-Id: 11126609 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D75414F7 for ; Mon, 2 Sep 2019 12:46:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2EFE21881 for ; Mon, 2 Sep 2019 12:46:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=typeblog-net.20150623.gappssmtp.com header.i=@typeblog-net.20150623.gappssmtp.com header.b="xZeRG54Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730582AbfIBMqC (ORCPT ); Mon, 2 Sep 2019 08:46:02 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35601 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730544AbfIBMqC (ORCPT ); Mon, 2 Sep 2019 08:46:02 -0400 Received: by mail-pf1-f193.google.com with SMTP id 205so6502247pfw.2 for ; Mon, 02 Sep 2019 05:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=typeblog-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UxK0D/fheIqSygqLr5s8Jq9AxF3QesYF0ilcNylte7o=; b=xZeRG54YWKgB5dbF3y59khScl7yI/HflO++6A95O/QzD0f+8H5FUe2QQ3uAhJzFOqW MOZhRtvQsBNttdrNi6MzxpT9+vo+cisz5qhPDQhREQA2QDNNLA2JR8SF4xoUAe0v7Ju0 uDuMxGHHYUZFf9CHrGwFQEI3PszflA2AtaQ8qPf4tyjkU9iFpBKQ2wWTdDX2V1ODXDqB 5Vv9Vd0Lty5qxiYaMFwrRNYzk+TYv6WpdYIPAyM+o/Fninkl1JRoboszMWFnjzGQiEFn dGv7QXx+L13ylOkzwOA3ssTwjv36EHLkuJ3yFJAo74527kCN8levJC1nPNfz+YY7WZHc K2ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UxK0D/fheIqSygqLr5s8Jq9AxF3QesYF0ilcNylte7o=; b=hd5AtuNiq2cTgAciCXGdaHWjb+4P9Phgv2IRbBbF6v3LFhqN9CZtu4UMMBloXvUmqc /dAan5efYG21ps4EMugmxRJASZzEBLbDiLWEbnyNAnMpWjerSKa4m1jOzFV529OcH/FA tSlDyPRoX4n0GNehqh0q3QX8P1z/FsN+cP7Dbc5T1YKUa8dH/fvuN4PGK3VOJM4qAayS DVJKUDV9r0MQMkzmRrkc2/zEYhTGg8y670wZ279tsKg883mbK+ecaplMUsKvTVaDw1sK yRBhzgDF/87AAIjhh2Pngxfcn33zfVtEc7RM7SN4jy11io8BynGdgTiIZflaejcGRhkJ yimg== X-Gm-Message-State: APjAAAXEusK7UFgMxc3JUpXwqxhHVAUpZPWMafM2SgUZV91/IBsK3N37 EdRauAZshlyPtBerM+IAl0sLCA== X-Google-Smtp-Source: APXvYqxIvcyPxpnb3yh6eeP7HxC1AmtMZNRoGdxnjCor2F+TkQe4/r3whehjlKum19mXExKsD3b4OQ== X-Received: by 2002:a17:90a:d0c6:: with SMTP id y6mr3298714pjw.76.1567428361563; Mon, 02 Sep 2019 05:46:01 -0700 (PDT) Received: from peter-pc.home ([91.207.174.229]) by smtp.gmail.com with ESMTPSA id 2sm15884652pjh.13.2019.09.02.05.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2019 05:46:00 -0700 (PDT) From: Peter Cai Cc: Peter Cai , Andy Shevchenko , Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Bastien Nocera , Dmitry Torokhov , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v3 1/2] gpio: acpi: add quirk to override GpioInt polarity Date: Mon, 2 Sep 2019 20:43:51 +0800 Message-Id: <20190902124352.12291-1-peter@typeblog.net> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190831030916.13172-1-peter@typeblog.net> References: <20190831030916.13172-1-peter@typeblog.net> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On GPD P2 Max, the firmware could not reset the touch panel correctly. The kernel needs to take on the job instead, but the GpioInt definition in DSDT specifies ActiveHigh while the GPIO pin should actually be ActiveLow. We need to override the polarity defined by DSDT. The GPIO driver already allows defining polarity in acpi_gpio_params, but the option is not applied to GpioInt. This patch adds a new quirk that enables the polarity specified in acpi_gpio_params to also be applied to GpioInt. Signed-off-by: Peter Cai Acked-by: Andy Shevchenko --- v2: rebased to gpio/for-next, moved quirk out of the gpioint conditional. v3: no change, series update. --- drivers/gpio/gpiolib-acpi.c | 9 +++++++++ include/linux/gpio/consumer.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index fdee8afa5339..ab16ea61a8fa 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -603,6 +603,15 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) lookup->info.flags = acpi_gpio_to_gpiod_flags(agpio); lookup->info.polarity = lookup->active_low; } + + /* + * Override the polarity specified by GpioInt if + * ACPI_GPIO_QUIRK_OVERRIDE_POLARITY is set. + */ + if (lookup->info.quirks & ACPI_GPIO_QUIRK_OVERRIDE_POLARITY) { + dev_warn(&lookup->info.adev->dev, FW_BUG "Incorrect polarity specified by GpioInt, overriding.\n"); + lookup->info.polarity = lookup->active_low; + } } return 1; diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index b70af921c614..7e9f24ebb085 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -622,6 +622,12 @@ struct acpi_gpio_mapping { * get GpioIo type explicitly, this quirk may be used. */ #define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1) +/* + * Use the GPIO polarity (ActiveHigh / ActiveLow) from acpi_gpio_params + * for GpioInt as well. The default behavior is to use the one specified + * by GpioInt, which can be incorrect on some devices. + */ +#define ACPI_GPIO_QUIRK_OVERRIDE_POLARITY BIT(2) unsigned int quirks; }; From patchwork Mon Sep 2 12:43:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Cai X-Patchwork-Id: 11126613 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1032714F7 for ; Mon, 2 Sep 2019 12:46:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E41D9216C8 for ; Mon, 2 Sep 2019 12:46:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=typeblog-net.20150623.gappssmtp.com header.i=@typeblog-net.20150623.gappssmtp.com header.b="zuYm0kxl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729571AbfIBMqK (ORCPT ); Mon, 2 Sep 2019 08:46:10 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44524 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730845AbfIBMqJ (ORCPT ); Mon, 2 Sep 2019 08:46:09 -0400 Received: by mail-pf1-f194.google.com with SMTP id q21so3916974pfn.11 for ; Mon, 02 Sep 2019 05:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=typeblog-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i1gf/fWXrC1UDTPa/HgYMmRTeFmFTDpK3Sjfi5JLiP4=; b=zuYm0kxlA3UZd2AfAZGCdmm0KMcyb3mO+Fa2dTsIu7PMGg/o0oB9QMBj3eyUs25sME qfaiEmW1dsnRr8Q6YQ3ttGpIzNQD5H8fjPswWN9tBzXWgHdfRZDFIUTvA7NuJLBB5ESw 9LCUT1z0PQIQQEga3BFk9A89Cs8zO3QnJwgX3SssBQDFVjFO3cEelI6wkA5REqw9Xc3M +CGIibhrTO96fKD2Zmo8km7LqiSsvThXZYEezUs3mv4XxwQNjkbl7lhVtKr+X5KuXZNO GGWbnB4EP9thVZi70ghAhQ42jXnnJ0k7Cz9IPX6Dyu908F8HSsA2JJNKGr9EE/3lDty9 zdYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i1gf/fWXrC1UDTPa/HgYMmRTeFmFTDpK3Sjfi5JLiP4=; b=MPwIfrcfsU0O8z43GxNot5V/MupBJCx8wmh46Hb2Vu3C5DMyWLrkFHhOtZNU5eXSA7 Kh0N3k4o8nmNjbA5gkfD4fmYPmhUn8tAAX3By8zu6cxhwtpHnfAXjJO6ln9CEXYtTEtT DB7C42SaM1yplITVFZX7YJ9gSOeXxg0oPHLRQsZJ2Yb3y0qxhTmmMTln1P8n4jmJ3DMw JWyYi2kK1GIrQHmJIMEEwS4TdG1MmR0Rsi4yAEPgxd5umLaRCPJf4IOScjVmmZYHFFgX n8nRYrGjDK+lQSLtmgKbFq+IOSndJnxsQen8trBmTQl6lHMTG2ZCw+Z7DFisR9+m03F5 MSvA== X-Gm-Message-State: APjAAAUtN0uQD2kXIH042VKdaduda3Kxinaf7AdxI+uGxA3jrC1P0p5Q mMoQoIsx+Xh34FkZ46phL5c8Ag== X-Google-Smtp-Source: APXvYqx2EJ+yyowBKcAvoN8UoSPZ6gpuS48SesGzR28go5Qbjp5hCRtr8nQmq993xztaJuRn8q/qlw== X-Received: by 2002:a65:6458:: with SMTP id s24mr24781132pgv.158.1567428368700; Mon, 02 Sep 2019 05:46:08 -0700 (PDT) Received: from peter-pc.home ([91.207.174.229]) by smtp.gmail.com with ESMTPSA id 2sm15884652pjh.13.2019.09.02.05.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2019 05:46:07 -0700 (PDT) From: Peter Cai Cc: Peter Cai , Andy Shevchenko , Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Bastien Nocera , Dmitry Torokhov , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v3 2/2] touchscreen: goodix: define GPIO mapping for GPD P2 Max Date: Mon, 2 Sep 2019 20:43:52 +0800 Message-Id: <20190902124352.12291-2-peter@typeblog.net> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190902124352.12291-1-peter@typeblog.net> References: <20190831030916.13172-1-peter@typeblog.net> <20190902124352.12291-1-peter@typeblog.net> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The firmware of GPD P2 Max could not handle panel resets although code is present in DSDT. The kernel needs to take on this job instead, but the DSDT does not provide _DSD, rendering kernel helpless when trying to find the respective GPIO pins. Fortunately, this time GPD has proper DMI vendor / product strings that we could match against. We simply apply an acpi_gpio_mapping table when GPD P2 Max is matched. Additionally, the DSDT definition of the irq pin specifies a wrong polarity. The new quirk introduced in the previous patch (ACPI_GPIO_QUIRK_OVERRIDE_POLARITY) is applied to correct this. Signed-off-by: Peter Cai Reviewed-by: Andy Shevchenko --- v2: removed '#ifdef CONFIG_ACPI' as per suggestion. The #ifdef guards for CONFIG_DMI is kept for consistency with the other dmi_system_id definition in the same file. v3: minor style adjustments. Added 'const' to dmi_match and moved it in reverse xmas tree order as per suggestion. --- drivers/input/touchscreen/goodix.c | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 5178ea8b5f30..49ce478c1134 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -144,6 +144,31 @@ static const struct dmi_system_id rotated_screen[] = { {} }; +static const struct acpi_gpio_params irq_gpios_default = { 0, 0, false }; +static const struct acpi_gpio_params reset_gpios_default = { 1, 0, false }; +static const struct acpi_gpio_mapping gpio_mapping_force_irq_active_high[] = { + { "irq-gpios", &irq_gpios_default, 1, ACPI_GPIO_QUIRK_OVERRIDE_POLARITY }, + { "reset-gpios", &reset_gpios_default, 1 }, + {} +}; + +/* + * Devices that need acpi_gpio_mapping to function correctly + */ +static const struct dmi_system_id need_gpio_mapping[] = { +#if defined(CONFIG_DMI) && defined(CONFIG_X86) + { + .ident = "GPD P2 Max", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "GPD"), + DMI_MATCH(DMI_PRODUCT_NAME, "P2 MAX") + }, + .driver_data = &gpio_mapping_force_irq_active_high + }, +#endif + {} +}; + /** * goodix_i2c_read - read data from a register of the i2c slave device. * @@ -793,9 +818,15 @@ static void goodix_disable_regulators(void *arg) static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { + const struct dmi_system_id *dmi_match; struct goodix_ts_data *ts; int error; + dmi_match = dmi_first_match(need_gpio_mapping); + if (dmi_match) + devm_acpi_dev_add_driver_gpios(&client->dev, + dmi_match->driver_data); + dev_dbg(&client->dev, "I2C Address: 0x%02x\n", client->addr); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {