Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp298326pxx; Thu, 29 Oct 2020 02:59:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5FnqmXffbjoDmgVLDbcYXDIYi1kgzWlOPAJWBA+uAqwgkXcnUkFnkdVJPnHzdl6znjeFk X-Received: by 2002:a17:906:2788:: with SMTP id j8mr1208262ejc.185.1603965545022; Thu, 29 Oct 2020 02:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603965545; cv=none; d=google.com; s=arc-20160816; b=zfyxnjhyWlqXBROUSSZf8Ck3X13RscSfTNwybrar4+Unfoph2EhRZL02aLJ9RTDrDc zGx27n1k6ZdnggeM/bbjucZDeSinA/FSoJYWnFk0Ne61tR4fjtI6O8E4lesSlo69Lbft JV174IOJP586KpieZ9jOQ3c7cBJ0fjRrfDFpYCkC13/LRQs726n1ZybiUkkdNBv/S0KR pzj3+7NwArk0e/q2sOYjJTJKtVdVfaq+zqYSlMQ4TdDO3/t0xz6GsYYvrKqzxM4R/kU0 qP9bD1yThW2r31vk5UpQ7hZSMPpYBUy6syzy5yHKgtlrz8cTq1h27PBp3vaYmc7horK5 qSgg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=JzxgzmFEKg3uyOYq0U+7u1Sr88Fa5cBf5J/ai9Bi9w4=; b=bqIAsUmU4enAVgKuSOVggb02v8P3Bm8yj0fGObEpp0iAEqpUscpN1GtyBBmE97AWc8 tGVo6/83O2JOJbhDBqSEB2ki1V2hoxKCHG/zg2ZN0bsvtercLi/GUoS/A5N+kukeY0Zv PfOaO3JvFvIG/OM6tB1ODtRoEPGVW0tcxaoXIW6ErKkXAeiRzZWIPA3ScaHiyj2KIAzL DZZrXm161mpjtSj4zB+aBLlejq4ZifXQMA4CksFzMMKmm3N82Cj/WeuCa83yXkiQw6J/ wtmbpwJMFHRaepEekFz1WbfLrhb+P8Zf8tkihP05MBnAgU/h3FPbNlXlLKX4TTdqwtXD mvSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c8YXWXab; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g15si1614826edp.174.2020.10.29.02.58.43; Thu, 29 Oct 2020 02:59:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c8YXWXab; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731757AbgJ1WoV (ORCPT + 99 others); Wed, 28 Oct 2020 18:44:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389345AbgJ1Wmr (ORCPT ); Wed, 28 Oct 2020 18:42:47 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B73AFC0613CF for ; Wed, 28 Oct 2020 15:42:46 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id a7so831978lfk.9 for ; Wed, 28 Oct 2020 15:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JzxgzmFEKg3uyOYq0U+7u1Sr88Fa5cBf5J/ai9Bi9w4=; b=c8YXWXabra4sW5/XLNopgCr1Ey4kEIOYZ1bnz6+tWCnkIM88z4M2Q3I8N6B+DLSZt4 cJzYWSgKqRYIP05RISLd1JWNSMYFkd9oJV/3pYM+4YbdbwwpPxZY4yZg7EkQpNCDvAMI gD29S7F17ZYzpny8Auzr9eQgNQUDt2NXaN1SE= 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=JzxgzmFEKg3uyOYq0U+7u1Sr88Fa5cBf5J/ai9Bi9w4=; b=Drsqdwq3cEFi8qiuvpWrCPsRhOz9vciExu//VJA1i8yHrKPwpSDQU5K9wOyNkLSDFU Ppjd1GII5Zz1CdHDu09etEcgZUOpMPMBhFHmWM+nhuJHH8GzmPO01mnj1rSR262pA2lk RVOD/BRJv0mG/lrXat1M44Yt34urgf8H0HbFXHA9Tuaxg8I2peDzzKvpgqXtBqAYGZ+X VM68FT7LSvR0xwx+kjdpNbgYouYC6CbvQheMkK3RApO6wfx74FAXq/I8GNMe+cKe6Kev zqnsaV9oqCAjHnPrF2yKsoqP4ILunsD/hin4rPQjkw6NC83dOAmpyOd9aaeu2Ba961v3 ABwA== X-Gm-Message-State: AOAM533kYuq7Y3kSA5rX/c0ebOG6VfiAlnVVJf7cLQRCAY76YNOrk0sa T5XTs/XJ/XNGVhsLneKBBiyliW/XyJ2wHKkOPQw= X-Received: by 2002:adf:e685:: with SMTP id r5mr390473wrm.340.1603905483580; Wed, 28 Oct 2020 10:18:03 -0700 (PDT) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id y4sm222505wrp.74.2020.10.28.10.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 10:18:02 -0700 (PDT) From: Ricardo Ribalda To: Mika Westerberg , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Subject: [PATCH] gpiolib: acpi: Support GpioInt with active_low polarity Date: Wed, 28 Oct 2020 18:17:57 +0100 Message-Id: <20201028171757.765866-1-ribalda@chromium.org> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On the current implementation we only support active_high polarity for GpioInt. There can be cases where a GPIO has active_low polarity and it is also a IRQ source. De-couple the irq_polarity and active_low fields instead of re-use it. With this patch we support ACPI devices such as: Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings { GpioInt (Edge, ActiveBoth, Exclusive, PullDefault, 0x0000, "\\_SB.PCI0.GPIO", 0x00, ResourceConsumer, , ) { // Pin list 0x0064 } }) Name (_DSD, Package (0x02) // _DSD: Device-Specific Data { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */, Package (0x01) { Package (0x02) { "privacy-gpio", Package (0x04) { \_SB.PCI0.XHCI.RHUB.HS07, Zero, Zero, One } } } }) Signed-off-by: Ricardo Ribalda --- drivers/gpio/gpiolib-acpi.c | 8 ++++---- drivers/gpio/gpiolib-acpi.h | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 834a12f3219e..bc33c1056391 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -624,7 +624,7 @@ int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, break; } - if (info->polarity == GPIO_ACTIVE_LOW) + if (info->active_low) *lookupflags |= GPIO_ACTIVE_LOW; return 0; @@ -665,6 +665,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) agpio->pin_table[pin_index]); lookup->info.pin_config = agpio->pin_config; lookup->info.gpioint = gpioint; + lookup->info.active_low = !!lookup->active_low; /* * Polarity and triggering are only specified for GpioInt @@ -675,11 +676,10 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) */ if (lookup->info.gpioint) { lookup->info.flags = GPIOD_IN; - lookup->info.polarity = agpio->polarity; + lookup->info.irq_polarity = agpio->polarity; lookup->info.triggering = agpio->triggering; } else { lookup->info.flags = acpi_gpio_to_gpiod_flags(agpio); - lookup->info.polarity = lookup->active_low; } } @@ -958,7 +958,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) return ret; irq_flags = acpi_dev_get_irq_type(info.triggering, - info.polarity); + info.irq_polarity); /* Set type if specified and different than the current one */ if (irq_flags != IRQ_TYPE_NONE && diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h index 1c6d65cf0629..816a2d7a21ed 100644 --- a/drivers/gpio/gpiolib-acpi.h +++ b/drivers/gpio/gpiolib-acpi.h @@ -16,7 +16,8 @@ struct acpi_device; * @flags: GPIO initialization flags * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo * @pin_config: pin bias as provided by ACPI - * @polarity: interrupt polarity as provided by ACPI + * @irq_polarity: interrupt polarity as provided by ACPI + * @active_low: pin polarity as provided by ACPI * @triggering: triggering type as provided by ACPI * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping */ @@ -25,7 +26,8 @@ struct acpi_gpio_info { enum gpiod_flags flags; bool gpioint; int pin_config; - int polarity; + int irq_polarity; + bool active_low; int triggering; unsigned int quirks; }; -- 2.29.0.rc2.309.g374f81d7ae-goog