From patchwork Sat Aug 31 03:09:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Cai X-Patchwork-Id: 1156096 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=typeblog.net Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=typeblog-net.20150623.gappssmtp.com header.i=@typeblog-net.20150623.gappssmtp.com header.b="FxDkvpiL"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46L1ZM4Qvdz9sNp for ; Sat, 31 Aug 2019 13:10:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728246AbfHaDKd (ORCPT ); Fri, 30 Aug 2019 23:10:33 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33698 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726942AbfHaDKc (ORCPT ); Fri, 30 Aug 2019 23:10:32 -0400 Received: by mail-pg1-f194.google.com with SMTP id n190so4461647pgn.0 for ; Fri, 30 Aug 2019 20:10:32 -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=xPp/KNeXkBz5eBYg4mT+UA0qSZaP/9dyi5AxdOhW8oY=; b=FxDkvpiLmDCdVySmdKZFxU+2EWG20fKrRnf810YGsm3sKyNqJj1MWnVW0tk2eCnr3i GLP+gnBwlz7OLbQitK8znNiv1RsFw6mxfxKzg/HaE4ObLZZ4iQZ8EBIAu2fKDwc6ZNy4 Fjoa89AzJ9MtWSGUjfmL4LuEyg/dkT/67EkioOiqmp2oWovIKYae/Athutb2V3Sz9GBJ 8v+Wy05IzpzJG9ctYb3A3G2xy4zUWzrynpWZx4O7enZAlazh7RTyiKqfRd7tOvHpkl3m Zyt403oqlfbqEw3cJfLUGC7TjLFzICr1l2cy6Jr/7q4bJWHpJIQCq04Y+nthKCJqfpn8 jMWQ== 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=xPp/KNeXkBz5eBYg4mT+UA0qSZaP/9dyi5AxdOhW8oY=; b=kNaaLaR4cF2fou7uoaR+HbPPEENWDO3GhZ5KXeE1aOQ6AQg2A3+Rks5qTo9lZINLDL jLV+jS6U3Fi7S88KA2H/ihoXQW0Nz1SPlIqhqcquHso/d4zR+wlfb6L9RBukM/nuYUzg 2uOV3RRgwa+f/HIY2RX8ckW3633sFYVOF4wS7S3qmEwvsfknNCvWusgpIaT36BqupaNv bnQ1+j2cr6uMzb60GLO4TzLr1ds/oL0N++iYnXqtTocM9smn1qzRfq1uB+/rOPLDT9Wh mc3tO7tHzGHvtFPLRSz0ZVs/0FgMZ48y5ti6Eg2nLpxbr/QAlFF0DxqFe+0uSNzPrxNr gP+g== X-Gm-Message-State: APjAAAXHILuuFtEH3sODzeg8qPWjpp8GNAKbiN1YfV7aSUTCnhNqW0Al MDMFZmYRS1H+jUo4nj3Lkx7YNw== X-Google-Smtp-Source: APXvYqyleC9XvInNiTuUuZU4vpeR5UtTD2SFLPqm9Q3cOcEE/uZaNhwkLgxs2UsAggMgWosJ1+NyAQ== X-Received: by 2002:a65:6406:: with SMTP id a6mr15168119pgv.393.1567221031768; Fri, 30 Aug 2019 20:10:31 -0700 (PDT) Received: from peter-pc.home ([91.207.174.229]) by smtp.gmail.com with ESMTPSA id 185sm10961454pff.54.2019.08.30.20.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2019 20:10:30 -0700 (PDT) From: Peter Cai Cc: "Rafael J. Wysocki" , Len Brown , Peter Cai , Mika Westerberg , Andy Shevchenko , 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 v2 1/2] gpio: acpi: add quirk to override GpioInt polarity Date: Sat, 31 Aug 2019 11:09:14 +0800 Message-Id: <20190831030916.13172-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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 Acked-by: Linus Walleij --- v2: rebased to gpio/for-next, moved quirk out of the gpioint conditional. --- 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 Sat Aug 31 03:09:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Cai X-Patchwork-Id: 1156097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=typeblog.net Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=typeblog-net.20150623.gappssmtp.com header.i=@typeblog-net.20150623.gappssmtp.com header.b="KlKjRfva"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46L1ZN0CbVz9sNx for ; Sat, 31 Aug 2019 13:10:52 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728366AbfHaDKj (ORCPT ); Fri, 30 Aug 2019 23:10:39 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33711 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728350AbfHaDKj (ORCPT ); Fri, 30 Aug 2019 23:10:39 -0400 Received: by mail-pg1-f196.google.com with SMTP id n190so4461744pgn.0 for ; Fri, 30 Aug 2019 20:10:39 -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=SXbglKvD0SQmCRxcZtB9WBlJczTPMt6e3pZqM3DgZ18=; b=KlKjRfvad7u6uFblyFqzf8FnNcX/HdKZa8Ou7elxmC+GPWRiGv+M/RH//EOe2nn4WN kTz+vJODFike6WQUKh1X9zklhP/gQSg7k7yme0uYvo3xoTNXSWWdukoFtziz0ugRRCJk t48o7jdirGq7ZMKPb/rUguEBC2sL/3AOcRGxLv3vrocVmgly3k6DzImNxELKh3fZpHA8 ShSM0+CW3qBBi8sQZ4RUv7/ZQVA0Tra/QbupG06R2cMpu3WfNpJjwG489pxusCqsYlZp HPW9iZpwXScQT0SuB1dKoi7Rqi2Kk9KpVOfTEkhsSU0RX2Rwhj+cUdkFV9fH7Xi1PWmn ZTsg== 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=SXbglKvD0SQmCRxcZtB9WBlJczTPMt6e3pZqM3DgZ18=; b=IpSJ4x8sRvbh6Jnz8murPIhb1qXlzl9FrrhLHCh1ttolrdwl0NkyigmPJBherNfYpy WP4eNOdacgVVnlsTBBxuNb8cQh5EoL0fd9IaOf2t27XUHBWCmNbOuNZ3l9vSP/oAke+O /Chrj+Y2mjOtrOcMCrzmJdAhjgg155zZWK9rIUYQs9HSg72sxULF4kK1ZYzZXxieWsg9 WFkZ7GWrFHqFrPWgvKrgMOJuMJE6LvXx17Gz8bkprWCwGEV9gZsbYonxD5XfrVfD5Glt atY5Aw+VW3dcC06IEjBxPpvjw6KcAlNRd1Ex6LARK5NNJYgxKPcfFxXI/jYWh0+mqnJ3 IZjQ== X-Gm-Message-State: APjAAAWcKsN6QxVYphAAuKX+IPdPWpg1jm18o38dFKM7uw4ZDuhVPGjs Y5otOwdaWnhjmBBcf0KlJ9fkgw== X-Google-Smtp-Source: APXvYqy3AvEy6GfXGMsBVelFOUgqliOk3kGp0ODR2dCYzbwoReny6L9IgY3VfEzMVZ4Htgn0gs/zcw== X-Received: by 2002:a17:90a:a00b:: with SMTP id q11mr1783420pjp.91.1567221039116; Fri, 30 Aug 2019 20:10:39 -0700 (PDT) Received: from peter-pc.home ([91.207.174.229]) by smtp.gmail.com with ESMTPSA id 185sm10961454pff.54.2019.08.30.20.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2019 20:10:38 -0700 (PDT) From: Peter Cai Cc: "Rafael J. Wysocki" , Len Brown , Peter Cai , Mika Westerberg , Andy Shevchenko , 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 v2 2/2] touchscreen: goodix: define GPIO mapping for GPD P2 Max Date: Sat, 31 Aug 2019 11:09:15 +0800 Message-Id: <20190831030916.13172-2-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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. --- 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..df476f7dcd95 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. * @@ -795,6 +820,12 @@ static int goodix_ts_probe(struct i2c_client *client, { struct goodix_ts_data *ts; int error; + 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); dev_dbg(&client->dev, "I2C Address: 0x%02x\n", client->addr);