From patchwork Wed Mar 9 19:43:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 12775539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A785C433F5 for ; Wed, 9 Mar 2022 19:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xObeWwxHd1/6UGbohz5KCLnayZE+xa8qa9K9ksyz3Ao=; b=0ojcc/n+BPQr9t HLY8cJ3bl8MVQiuNxRClw+UYXhfQG837TKNSHOy9cptfaFuHo5Vju1CrCig7zgZMYThj5BtZyScr7 AQ4Fw50sNSz2TSSICh15FfQcJlB9XmN9+eCMUCxM9o+U04s9VtQMlN0OZf6AU5lNLdBgKALocE9hM 0dJPuwVZ4W9UD2p4yqkK+DAOgfWDYFAU+DCABKV2EAVQhvykvlLoCpf3swePhThWyLT1xux/4Refd 1fxl5h/bQ2+TA8YNWLhCkoDt4vz+Tp4ffEAVi9CN2tpvmJC4t/10ugR1V0H0ekIeGF5RnhQhTjY/M T3kBLhGz0158T1KPnCiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nS2F6-00AJsF-B7; Wed, 09 Mar 2022 19:45:04 +0000 Received: from mout.kundenserver.de ([212.227.17.13]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nS2Et-00AJqR-SL for linux-arm-kernel@lists.infradead.org; Wed, 09 Mar 2022 19:44:54 +0000 Received: from localhost.localdomain ([37.4.249.169]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MuDPf-1oHfsn2FEz-00uaod; Wed, 09 Mar 2022 20:44:44 +0100 From: Stefan Wahren To: Linus Walleij , Bartosz Golaszewski , Florian Fainelli , Nicolas Saenz Julienne Cc: Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Arnd Bergmann , Phil Elwell , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Stefan Wahren Subject: [PATCH RFC 2/2] pinctrl: bcm2835: implement hook for missing gpio-ranges Date: Wed, 9 Mar 2022 20:43:46 +0100 Message-Id: <1646855026-9132-3-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1646855026-9132-1-git-send-email-stefan.wahren@i2se.com> References: <1646855026-9132-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:gD25VDJriO0WlPO9G1KIEXwcB2q62js2g/T5+gpDWM+vpuAtgJX 8gc4fsnQow22MKJ411B8VqfZ8qfx/epjNPdU2EhjeNnKoBL04UFvhM1+XEVN1qTkXrHHIlX SXGxqfKTny0zh4vETTwQJEYJwKsJ2bQne4Rkc8yZyXFPIHSDIW5hO7/Lpkzk0DGMyYdp/Dx gc+LdAHL0qBbFqJqoolKQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:NNlrxlue2gA=:2weFW0A8nKGHda7lRP6V4R hY62kNe7KWK1c5WDPTNhpSAA2gEN4iLaI5op+GhLFmLyeSssaZpwkduQpBd74Z45aNIQPED63 8C8rZFz2Vr2i/FOajAmk4cikBeK3G1SJ/TLPDTbFUCUJxPZlH5zq0+MqChsUAKLQnNJjmEkFv CGZtWdOB9QBsWWBy5EAN0QNvW8cVB1o09j60bhq+2GltCffD+AOFGuYflP9FfKzY8FPSewFfg mhBNop6YxUH1wIL0rmeU59yofofq+hfvK61cf8eHNCL50AndgV6hB94evWN43b1DOuWLi4NW+ aCfQpyeDT7UwhXYYRE3zph7CUMyLiYTGzEmUpTfobyToViBn0I+N2ciLYyRs8pC/FxT9YUtQo SaJ9x+vPhnmJnc2W2Plr6iIItrG94wD9xkpAb7XiQAP7nNE/fIUPHyBms4wyruXX05dJacOjh CvUv/jcxd3/RpVMjzKpjhN7pZi7Ah8LblZfi9o6Q5o7zEHfqnpy5Vf/tbusjOUMTwNp0FfDnK msGDQQTUdFHqwoZ5XllZATHxSq7FFTyjh6FkRmBAacyyAhVcKjAOguD6/pT3r9dJ5UJ+G0C4R 3nFB1D66ShBFjs2mgJKCRGKf/G0q5A5QJD59WBiV1oWuavKw3UgBDA85ChDnD9m91mQOMu5C8 gIaH00Q3jUuitxqJ+Ggcfg9Ga8NRt4anQD/fAeX9sNLlMTobvR/yTj+vMdsuB0yWOVgBkIGWH tvyfPzl25ugGUCB6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220309_114452_230475_FB9FF0AB X-CRM114-Status: GOOD ( 14.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The commit c8013355ead6 ("ARM: dts: gpio-ranges property is now required") fixed the GPIO probing issues caused by "pinctrl: bcm2835: Change init order for gpio hogs". This changed only the DTS files provided by the kernel tree. Unfortunately it isn't guaranteed that these files are shipped to all users. So implement the necessary backward compatibility for BCM2835 and BCM2711 platform. Signed-off-by: Stefan Wahren --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index 47e433e..dad4530 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -358,6 +358,22 @@ static int bcm2835_gpio_direction_output(struct gpio_chip *chip, return 0; } +static int bcm2835_of_gpio_ranges_fallback(struct gpio_chip *gc, + struct device_node *np) +{ + struct pinctrl_dev *pctldev = of_pinctrl_get(np); + + of_node_put(np); + + if (!pctldev) + return 0; + + gpiochip_add_pin_range(gc, pinctrl_dev_get_devname(pctldev), 0, 0, + gc->ngpio); + + return 0; +} + static const struct gpio_chip bcm2835_gpio_chip = { .label = MODULE_NAME, .owner = THIS_MODULE, @@ -372,6 +388,7 @@ static const struct gpio_chip bcm2835_gpio_chip = { .base = -1, .ngpio = BCM2835_NUM_GPIOS, .can_sleep = false, + .of_gpio_ranges_fallback = bcm2835_of_gpio_ranges_fallback, }; static const struct gpio_chip bcm2711_gpio_chip = { @@ -388,6 +405,7 @@ static const struct gpio_chip bcm2711_gpio_chip = { .base = -1, .ngpio = BCM2711_NUM_GPIOS, .can_sleep = false, + .of_gpio_ranges_fallback = bcm2835_of_gpio_ranges_fallback, }; static void bcm2835_gpio_irq_handle_bank(struct bcm2835_pinctrl *pc,