Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3517652pxf; Mon, 15 Mar 2021 11:18:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE8Y27g5NrxKgm8XJ5LxpWtikJRUHQBvT3oicvnNNHsrkQeU/fxZvtAIOBr7WXvxEOMbBK X-Received: by 2002:a05:6402:6cb:: with SMTP id n11mr31952450edy.198.1615832309655; Mon, 15 Mar 2021 11:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832309; cv=none; d=google.com; s=arc-20160816; b=j/saAoDhWNW1AL1BR9i0AmZWLxEFmjVE6RSzuKDigfJS7TQ9p3SDdznEVM6UYF5SYX hSpJUnCcHAsd4k7AWZnEoE2GGiLcunpun9CZ941ZeN11ks9llXQHajBjki4vlAmtYn1R /jLpe9WBLXrOUkrFGn0Nlw6vAl7IXQIzsRrBcTxA1vTxCV39ljKAheJhPhcWjzA4NsX0 f0fehDYzE8ExrQAjzno+i+dXqwGMoTlSEVTWsVAQWdVJhR5S/awcfRnNdrAhSQYtxSjs tjNqk+m0iyz5kB+tj9SnRI2u8gSS3iozaWyn7ucPyQztPMKnZjt1i9LUnBliaKBD6R1H 4m+A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=l0idByFyrRwKfhGDmNDQUNa9u2sxmtZHfaH5XWJBOCQ=; b=guOYs+rLYEDoq/p0e3stKZryY1pIqMlKedAzOl5TwwrOz007KR0dupZ2VhWjuP6jXa ikkcZAyau0rgAk4Q5jYXju2speeoKRAVmTwJDoeprSPV8cJGem8nh0K/cEHBvEdVYdpU AznPuyUfxCY38WLWSaS3Eig+tOrrnR/+xThpEDBh/aFnJQsqtewQtYaxnWcAl7Q0worc SWsHe3KkB6QOnY9/rPNO3wKC6SDR+y1qKM0lRzJF0+Yd8B8XN17GU/u+Pw+wOnaAFcXA ixmcLse1bHNCtsuJHiD32Ie8i9Wddoru1xT7AbhFvSPPR9Qpq3d3XDJQ/vLbzzruxwZH kYsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0YEyxvZX; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si11380679ejd.167.2021.03.15.11.18.07; Mon, 15 Mar 2021 11:18:29 -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=@linuxfoundation.org header.s=korg header.b=0YEyxvZX; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232515AbhCOOQI (ORCPT + 99 others); Mon, 15 Mar 2021 10:16:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:36594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231927AbhCON7L (ORCPT ); Mon, 15 Mar 2021 09:59:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A84FD64F0B; Mon, 15 Mar 2021 13:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816729; bh=KoUpgp8ToaoesoT0JL2Hjzzsk/DNrsi7MvsYZQLfZ28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0YEyxvZXALIbTLqG2dQocveyv01Kn09cfsP7oy8V+Voi8IBPs4gWRezWHM+bMpdav v6f07brrs8PQqBzXLfLc6jhTw0ZwgYtSIfHqDxGLHXdlejMik2jH4w3XKtVAUa/FVm 5H4r3HEX5GwIzAR3upAd2JVbpoOvMd5RIJUYxYHU= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Mika Westerberg , Linus Walleij Subject: [PATCH 5.10 079/290] gpiolib: acpi: Add ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER quirk Date: Mon, 15 Mar 2021 14:52:52 +0100 Message-Id: <20210315135544.583551677@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Andy Shevchenko commit 62d5247d239d4b48762192a251c647d7c997616a upstream. On some systems the ACPI tables has wrong pin number and instead of having a relative one it provides an absolute one in the global GPIO number space. Add ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER quirk to cope with such cases. Fixes: ba8c90c61847 ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2") Depends-on: 0ea683931adb ("gpio: dwapb: Convert driver to using the GPIO-lib-based IRQ-chip") Signed-off-by: Andy Shevchenko Acked-by: Mika Westerberg Acked-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib-acpi.c | 7 ++++++- include/linux/gpio/consumer.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -649,6 +649,7 @@ static int acpi_populate_gpio_lookup(str if (!lookup->desc) { const struct acpi_resource_gpio *agpio = &ares->data.gpio; bool gpioint = agpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT; + struct gpio_desc *desc; int pin_index; if (lookup->info.quirks & ACPI_GPIO_QUIRK_ONLY_GPIOIO && gpioint) @@ -661,8 +662,12 @@ static int acpi_populate_gpio_lookup(str if (pin_index >= agpio->pin_table_length) return 1; - lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr, + if (lookup->info.quirks & ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER) + desc = gpio_to_desc(agpio->pin_table[pin_index]); + else + desc = acpi_get_gpiod(agpio->resource_source.string_ptr, agpio->pin_table[pin_index]); + lookup->desc = desc; lookup->info.pin_config = agpio->pin_config; lookup->info.gpioint = gpioint; --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -674,6 +674,8 @@ struct acpi_gpio_mapping { * get GpioIo type explicitly, this quirk may be used. */ #define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1) +/* Use given pin as an absolute GPIO number in the system */ +#define ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER BIT(2) unsigned int quirks; };