From patchwork Fri Aug 30 00:00:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Cai X-Patchwork-Id: 11122715 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 202B5112C for ; Fri, 30 Aug 2019 00:01:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F194A21670 for ; Fri, 30 Aug 2019 00:01:58 +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="C+rwRawA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726739AbfH3ABy (ORCPT ); Thu, 29 Aug 2019 20:01:54 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35019 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726825AbfH3ABy (ORCPT ); Thu, 29 Aug 2019 20:01:54 -0400 Received: by mail-pf1-f195.google.com with SMTP id 205so781906pfw.2 for ; Thu, 29 Aug 2019 17:01:54 -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:mime-version :content-transfer-encoding; bh=r4FdmecES1mXuhQRWO8rMFn+Nx420CRXp9hbw5E4DeY=; b=C+rwRawAYjEQMmq1XlJqg/oPcrd9+huDhBB/ffgbwV2euRm53zIQKEzHOR/2TGOJgM nKzl3Z6sSCW9v4ByjBtXDP49ANg3dw8ayKkt3IUigIB9aT6LV3nd2GzEzE3rPEHYljfB G6JF1BsruhNFBDg4UiAiSlMS5ip7KyygC3mi2v2BA0gj8gh0/GRqgAaaZfvDovCpsL4j 55uEAummxO8+6zhQKMmUH17J2FFfXWiN+7ifJaBaQ4WGuNd08im5K56a9drKA8GdYr8b fFpZDpz7NRdcKw3Th+tSyYgctrqBYF3pHK8l3x38pGo3t7RNIJFGjdj7LwUUFiLVvdug Pwpg== 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:mime-version :content-transfer-encoding; bh=r4FdmecES1mXuhQRWO8rMFn+Nx420CRXp9hbw5E4DeY=; b=CanfKxYCn9IeYL//caCUDcdD8eU5Nl+HnxKRPWWuE/+haEDaD4K9uKO1q6V68+ucsM i9jE8XM0to56frYMwe/KnH7s3JqTzZgKiav4TlCm1YH7G/AC/F8JyJJ7brD5pabnY4P+ 1zsLYoMNfoUo4DkN5f1/F3x+R1q6JhuWUYsGXgt5lkas76WB+q7IXsUJD/94ocP0OM0K +7ByWmZ3HjVbqj9/Rdj0t8spb2vdXtoPCsfd+QIsYMCqb/bY0BT4MFeyUkQDnSLSrOJg m9aTqK47VovRQi4/NnBgR0H4yLQkHkbp2o4gyQnhc4ZsDpoqQxFO6yW0t0oOrPQc9G0T pnLw== X-Gm-Message-State: APjAAAWEwyITQHX6Ci6+ilg/PH8t0Peu8kWm5lja5VZKUByE2dhHdrl8 jW6QhWmwNAocbaHNQAdza/FNAg== X-Google-Smtp-Source: APXvYqzqeat554HkNrmzQW+v4uxeKH2ucYkRnvGkc20nQ9CzJSLXTHeAVgx+oRGALg9emAc734pNzA== X-Received: by 2002:a17:90a:e505:: with SMTP id t5mr359288pjy.68.1567123313781; Thu, 29 Aug 2019 17:01:53 -0700 (PDT) Received: from peter-pc.home ([91.207.174.229]) by smtp.gmail.com with ESMTPSA id g2sm4369819pfm.32.2019.08.29.17.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 17:01:52 -0700 (PDT) From: Peter Cai Cc: Peter Cai , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , Bastien Nocera , Dmitry Torokhov , "Rafael J. Wysocki" , Len Brown , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH 1/2] gpio: acpi: add quirk to override GpioInt polarity Date: Fri, 30 Aug 2019 08:00:23 +0800 Message-Id: <20190830000024.20384-1-peter@typeblog.net> X-Mailer: git-send-email 2.23.0 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 --- drivers/gpio/gpiolib-acpi.c | 10 +++++++++- include/linux/acpi.h | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 39f2f9035c11..1a07c79ca2de 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -583,13 +583,21 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) /* * Polarity and triggering are only specified for GpioInt * resource. + * Polarity specified by GpioInt may be ignored if + * ACPI_GPIO_QUIRK_OVERRIDE_POLARITY is set. * Note: we expect here: * - ACPI_ACTIVE_LOW == GPIO_ACTIVE_LOW * - ACPI_ACTIVE_HIGH == GPIO_ACTIVE_HIGH */ if (lookup->info.gpioint) { lookup->info.flags = GPIOD_IN; - lookup->info.polarity = agpio->polarity; + 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; + } else { + lookup->info.polarity = agpio->polarity; + } lookup->info.triggering = agpio->triggering; } else { lookup->info.flags = acpi_gpio_to_gpiod_flags(agpio); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 9426b9aaed86..6569773ceffd 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1014,6 +1014,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 Fri Aug 30 00:00:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Cai X-Patchwork-Id: 11122719 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 42C031395 for ; Fri, 30 Aug 2019 00:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D7E222CF5 for ; Fri, 30 Aug 2019 00:02:01 +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="X0Az8igV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727126AbfH3ACA (ORCPT ); Thu, 29 Aug 2019 20:02:00 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44192 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727118AbfH3ACA (ORCPT ); Thu, 29 Aug 2019 20:02:00 -0400 Received: by mail-pf1-f195.google.com with SMTP id c81so3232760pfc.11 for ; Thu, 29 Aug 2019 17:02:00 -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=IldQxyej46YU/SkHEEsnjl/LzmCcMggIbONwXFCSCKE=; b=X0Az8igVrc/4gMnl5ADWTxShGaQFNupE1xbuCezN4YHWmi1aCOQeQyNrfkUh91vEC/ Jnjy2Zvmwn316YjWnNmofhEJ1/MO3Q+vKCkvxCw4RdMjeiegd9ABp5z9r3LQzHhoF/Sr JSHn7bApaXUDGs0DvnqQgDtSNIdofrDOPfJe1tm2UV2HV6lp4kMRyBP4i7nCJag/dJvp r25V44aCqJvk25M6ytooHD9n+xecEEW0Jpn8seM5m4nvbLouIRt3wmhUH4TZ7QbiueqE nYJykgKYmcPoVqu7s78+gPF/ldglPJAbnZ/daCR/4Db90NrT3UrhNC6HvqaEF5zCzZTb zT4A== 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=IldQxyej46YU/SkHEEsnjl/LzmCcMggIbONwXFCSCKE=; b=oYtXVdmFq/w02CEQBSM+7Qo1abDZBYfcLL063YzbRBFsiM2UZWlFkXdMVo+KTPoifp 4iT74u4fsYmy1yFfG1fMEOaZ0+w6+qZltKGWUabTKIXmw1ff3cT6Ig6miWFn4wwqoMan vOp8MLisl9cHmle/rardnWIhyDF53XLsJm0ztGtO0n9Rw0KbUB9nVtSR70M12HO9E4JF j+VDpKnsBv3avhviXfvvVtAAMEJIskXLUTfwIQccN7vQT5oO1UNvjxgphf3z49uFHqbu 7oNh3MQg8/+AhkrtlgPFfoIg16BdZZs62WETCG+LHYkUxEpLE1AmkZ9PWbB7UmuGH1KP Jz3g== X-Gm-Message-State: APjAAAX5hA4wizoECR7hWHsw6tej7JNN8TvBvi/VrPb7X2hBaKyHtf9Z rq+HLS6eCvZWZgE23SpKBPWZUA== X-Google-Smtp-Source: APXvYqwjKLpuXVkSR1nIUL4L0503S/Jm0MrmR+DtmeNp33276pQCiT6zEVNp+Gbr2ogFQbHDmXmnfg== X-Received: by 2002:a63:4c5c:: with SMTP id m28mr11229487pgl.333.1567123319576; Thu, 29 Aug 2019 17:01:59 -0700 (PDT) Received: from peter-pc.home ([91.207.174.229]) by smtp.gmail.com with ESMTPSA id g2sm4369819pfm.32.2019.08.29.17.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 17:01:58 -0700 (PDT) From: Peter Cai Cc: Peter Cai , Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , Bastien Nocera , Dmitry Torokhov , "Rafael J. Wysocki" , Len Brown , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH 2/2] touchscreen: goodix: define GPIO mapping for GPD P2 Max Date: Fri, 30 Aug 2019 08:00:24 +0800 Message-Id: <20190830000024.20384-2-peter@typeblog.net> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190830000024.20384-1-peter@typeblog.net> References: <20190830000024.20384-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 --- drivers/input/touchscreen/goodix.c | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 5178ea8b5f30..65b8d04b6dcf 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -144,6 +144,34 @@ static const struct dmi_system_id rotated_screen[] = { {} }; +#ifdef CONFIG_ACPI +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 + {} +}; +#endif + /** * goodix_i2c_read - read data from a register of the i2c slave device. * @@ -796,6 +824,15 @@ static int goodix_ts_probe(struct i2c_client *client, struct goodix_ts_data *ts; int error; +#ifdef CONFIG_ACPI + struct dmi_system_id *dmi_match; + + dmi_match = dmi_first_match(need_gpio_mapping); + if (dmi_match) + devm_acpi_dev_add_driver_gpios(&client->dev, + dmi_match->driver_data); +#endif + dev_dbg(&client->dev, "I2C Address: 0x%02x\n", client->addr); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {