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 X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6F11C3A5A6 for ; Fri, 30 Aug 2019 00:01:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A8F5522CEA for ; Fri, 30 Aug 2019 00:01:55 +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 S1727103AbfH3ABy (ORCPT ); Thu, 29 Aug 2019 20:01:54 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36293 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726369AbfH3ABy (ORCPT ); Thu, 29 Aug 2019 20:01:54 -0400 Received: by mail-pf1-f193.google.com with SMTP id w2so3254198pfi.3 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=AaPIXe4owt/RoEOAJqjtMAKf+OqngxeRDdp6KFG1SFdSyvKoEbBDznovQuM4jwKAN/ bQGnU4y5O+zyhzBKIf1i+eI0bbThuXK4MCgM5+3/MpnxdqRbIejTpTykJOAxGpZk9ziq 6qQSoT00bc3utTUoSxcVZfMbfPqhJS4t1QDVIxXMzGpPnAPUBP7YFDUWyucnd0uHKdE1 sBiXavux5HW/+rkImG6z+MAHHq0fB9W0e8hkNGPm6fjKDbzX4h/7BRnUlXrvtq0FudSI pyGtpQ+iTVXNo7K1MjJKk5dy93YYQKufcteH/CPPT5TjndC4JjwpTyzkdmNUrIW+KQKc gb2A== X-Gm-Message-State: APjAAAVHRVZX8aFrdg7gxLf+on799chpOjFvHo6LZFYxGXpAB8o0pBs6 AbiqgRbhbq+3W2AYL6uGWyo/xN5ToJYNRg== 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 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; }; -- 2.23.0