From patchwork Tue Mar 8 06:19:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12773038 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 57EC4C433FE for ; Tue, 8 Mar 2022 06:19:48 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=mpr9t/QEsncu50zrWxWlFHubiSkNnbK7TKIsugk9R3c=; b=FEAH2vLY84elIv cRfXjuM3mNcYMc2nOpD9sYfZHdVsO0ZnQLjxdCyYKjqukeXFYhMP3MyS8WleX8q43kb3gAiYFgryS pvN3EzmSuwzV3qykII3dwHj5/PrHRpoAN/BojyZThuN0A9lJmyzFrn31i6TOu66wDndeTLAJBYRge QofIhhdBGhhjGFkFwMBNJsUME+GUkyl0z9STzQPl18+ZVH6uWEBkN8pVnSdxzECmXVVFzOkXzzVXD XQ8hAbBOvpRq3JikckBX0it7hjz8wQ0UnE2g+uD/7MPWjx9nA1gUdv+OpsAGqbVTiyAXFJ/m5UBQ3 MNNc3F8uLrt9MburncFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRTCC-002mAR-Dw; Tue, 08 Mar 2022 06:19:44 +0000 Received: from mail-m17661.qiye.163.com ([59.111.176.61]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRTC8-002m87-CB for linux-rockchip@lists.infradead.org; Tue, 08 Mar 2022 06:19:42 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m17661.qiye.163.com (Hmail) with ESMTPA id 9B6A31DF341; Tue, 8 Mar 2022 14:19:37 +0800 (CST) From: Jianqun Xu To: heiko@sntech.de Cc: linus.walleij@linaro.org, huangtao@rock-chips.com, kever.yang@rock-chips.com, linux-rockchip@lists.infradead.org, linux-gpio@vger.kernel.org, Jianqun Xu Subject: [PATCH 1/4] gpio: rockchip: get regmap by devm_platform_ioremap_resource Date: Tue, 8 Mar 2022 14:19:32 +0800 Message-Id: <20220308061935.2441447-2-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308061935.2441447-1-jay.xu@rock-chips.com> References: <20220308061935.2441447-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1 kWDxoPAgseWUFZKDYvK1lXWShZQUlKS0tKN1dZLVlBSVdZDwkaFQgSH1lBWUMfTE1WSBkdSkJPSk xOHx1CVRMBExYaEhckFA4PWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NzY6Njo6Az4BLzINLBUCKytK Ni4aCzRVSlVKTU9NTElLSExDS05PVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlPQ083Bg++ X-HM-Tid: 0a7f682ee3c2da2bkuws9b6a31df341 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220307_221940_622317_0B183032 X-CRM114-Status: UNSURE ( 9.18 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use devm_platform_ioremap_resource to get the reg from device. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index a4c4e4584f5b..b67038572285 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -637,18 +637,8 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) { - struct resource res; int id = 0; - if (of_address_to_resource(bank->of_node, 0, &res)) { - dev_err(bank->dev, "cannot find IO resource for bank\n"); - return -ENOENT; - } - - bank->reg_base = devm_ioremap_resource(bank->dev, &res); - if (IS_ERR(bank->reg_base)) - return PTR_ERR(bank->reg_base); - bank->irq = irq_of_parse_and_map(bank->of_node, 0); if (!bank->irq) return -EINVAL; @@ -727,6 +717,9 @@ static int rockchip_gpio_probe(struct platform_device *pdev) bank->of_node = np; raw_spin_lock_init(&bank->slock); + bank->reg_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(bank->reg_base)) + return PTR_ERR(bank->reg_base); ret = rockchip_get_bank_data(bank); if (ret) From patchwork Tue Mar 8 06:19:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12773039 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 06DC7C433EF for ; Tue, 8 Mar 2022 06:19:48 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=covrzxqz/39brgf+K7VniAoq6waHMq9WLXGJZK2IM2A=; b=RYn6z4JvC9Xw1/ 2+x20XsbFfnXmkhu51p6MsV4poqLFMtDgJmpkobBbx0QiT7P5WgdP3TsEmfV+QLlfH585ieZOf4cJ hGikOZKHZEQYP9fuWf+VXcz+0X58FiXKL2W0ut1ENSiwGTc4n9XGH19lcquCDh5ooLyt+3lM1ekvX 73DftV4TIVN59LCY9tDQobXDojuyiMmKBNuBAmVd1irL0CHN7xOXUfmZ97xvcQ53D5RgWcq3s6OJ8 ywjemT0LiX/fMlVslbhifc/Xo43lDmL70B0lZmRZ9erPoU7xhwl67yjIMJmowC55SLNsgC5G10qrN OWUVfSvMcfOD/iyr6XWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRTCD-002mAi-1y; Tue, 08 Mar 2022 06:19:45 +0000 Received: from mail-m17661.qiye.163.com ([59.111.176.61]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRTC8-002m8A-CB for linux-rockchip@lists.infradead.org; Tue, 08 Mar 2022 06:19:43 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m17661.qiye.163.com (Hmail) with ESMTPA id 18F8A1DF400; Tue, 8 Mar 2022 14:19:38 +0800 (CST) From: Jianqun Xu To: heiko@sntech.de Cc: linus.walleij@linaro.org, huangtao@rock-chips.com, kever.yang@rock-chips.com, linux-rockchip@lists.infradead.org, linux-gpio@vger.kernel.org, Jianqun Xu Subject: [PATCH 2/4] gpio: rockchip: get irq support for both dt and acpi Date: Tue, 8 Mar 2022 14:19:33 +0800 Message-Id: <20220308061935.2441447-3-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308061935.2441447-1-jay.xu@rock-chips.com> References: <20220308061935.2441447-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1 kWDxoPAgseWUFZKDYvK1lXWShZQUlKS0tKN1dZLVlBSVdZDwkaFQgSH1lBWRlCGEhWGE4ZGkNITU odSEsYVRMBExYaEhckFA4PWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NzI6EQw4Sz4CSjI9LBAIKz4r FRkwCxFVSlVKTU9NTElLSExDT0xIVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhKS0w3Bg++ X-HM-Tid: 0a7f682ee593da2bkuws18f8a1df400 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220307_221940_620523_5BC3326B X-CRM114-Status: GOOD ( 12.84 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Get the irq of gpio controller with fwnode apis, support for both dt node and acpi. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index b67038572285..3703c3d71809 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -5,7 +5,7 @@ * * Copyright (c) 2021 Rockchip Electronics Co. Ltd. */ - +#include #include #include #include @@ -639,10 +639,6 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) { int id = 0; - bank->irq = irq_of_parse_and_map(bank->of_node, 0); - if (!bank->irq) - return -EINVAL; - bank->clk = of_clk_get(bank->of_node, 0); if (IS_ERR(bank->clk)) return PTR_ERR(bank->clk); @@ -668,6 +664,24 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) return 0; } +static int rockchip_gpio_get_irq(struct rockchip_pin_bank *bank) +{ + struct device *dev = bank->dev; + struct fwnode_handle *fwnode = dev_fwnode(dev); + struct device_node *np = NULL; + int irq = 0; + + if (fwnode_property_read_bool(fwnode, "interrupt-controller")) + np = to_of_node(fwnode); + + if (np) + irq = irq_of_parse_and_map(np, 0); + else if (has_acpi_companion(dev)) + irq = platform_get_irq_optional(to_platform_device(dev), 0); + + return irq; +} + static struct rockchip_pin_bank * rockchip_gpio_find_bank(struct pinctrl_dev *pctldev, int id) { @@ -721,6 +735,10 @@ static int rockchip_gpio_probe(struct platform_device *pdev) if (IS_ERR(bank->reg_base)) return PTR_ERR(bank->reg_base); + bank->irq = rockchip_gpio_get_irq(bank); + if (bank->irq < 0) + return bank->irq; + ret = rockchip_get_bank_data(bank); if (ret) return ret; From patchwork Tue Mar 8 06:19:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12773041 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 B2B34C43217 for ; Tue, 8 Mar 2022 06:19:49 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=7vIXXZmDNltjOJIfObhPVYyCU52Stgy3pGJcAf1cn9c=; b=BHsKLQmgxin7Od Nc3YfuKzi1yhYKfhdc9JpKPMR9hq4wUBauSLpknQ9gLxf4Xx8aDPm8sfAqNgKsjbiCraCwg6gcp9O /2UpwZX6/vasHQInSwPvwp6Lqo719+BiMcIeajRbfg9LngerNtbsAp2Mde567MQK3coMCSg0xF/er jQ3r6jef41iXnFXbjh8lkOgBHsFvXhdFfbqy2aIX/DU3iIkxeXVxHqE0so+W+KbkNH+7bXqNRewVo qnrVPeFqR2zOJPycmZtnutjOrsY5LqyeGrwa4GKnnCndZ+ph/9WuRhpurb7VW6JrviOoJzYW1I3Kw 7EHjcg3Mwa30B7JB1IZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRTCE-002mBK-Hn; Tue, 08 Mar 2022 06:19:46 +0000 Received: from mail-m17661.qiye.163.com ([59.111.176.61]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRTC8-002m8H-D1 for linux-rockchip@lists.infradead.org; Tue, 08 Mar 2022 06:19:44 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m17661.qiye.163.com (Hmail) with ESMTPA id 80C8B1DF344; Tue, 8 Mar 2022 14:19:38 +0800 (CST) From: Jianqun Xu To: heiko@sntech.de Cc: linus.walleij@linaro.org, huangtao@rock-chips.com, kever.yang@rock-chips.com, linux-rockchip@lists.infradead.org, linux-gpio@vger.kernel.org, Jianqun Xu Subject: [PATCH 3/4] gpio: rockchip: support driver to work independs on pinctrl Date: Tue, 8 Mar 2022 14:19:34 +0800 Message-Id: <20220308061935.2441447-4-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308061935.2441447-1-jay.xu@rock-chips.com> References: <20220308061935.2441447-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1 kWDxoPAgseWUFZKDYvK1lXWShZQUlKS0tKN1dZLVlBSVdZDwkaFQgSH1lBWUMeSkpWS0waGBkdTB 8ZQh9MVRMBExYaEhckFA4PWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Nyo6Fjo5Fz5JHTILLBcQKy0u HUtPCjxVSlVKTU9NTElLSExCS0hOVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUpMSUJPNwY+ X-HM-Tid: 0a7f682ee73dda2bkuws80c8b1df344 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220307_221940_794995_C7AD8F48 X-CRM114-Status: GOOD ( 27.12 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Currently, the rockchip_pin_bank is get from pinctrl, that binds the gpio driver to the pinctrl driver. rockchip-pinctrl ->probe ->register pinctrl ->populate gpio platform ... ->rockchip-gpio probe ->register gpio_chip Once the pinctrl device registered, other devices may try to configure pins througth pinctrl_bind_pins before probe, and if it is a gpio operation, that make a failure since gpio not ready. Heiko has provide a output-defer-list to store settings between pinctrl and gpio driver, once gpio register, the list will set activate. With this patch, the gpio can register itself before or without pinctrl, even if pinctrl driver used, we can make the gpio register before pinctrl by another patch to rockchip pinctrl driver. rockchip-pinctrl ->probe ->populate gpio platform ->rockchip-gpio probe ->register gpio_chip ->register pinctrl Since the pinctrl is registered last, other devices will do defer probe. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 197 +++++++++++++---------------------- 1 file changed, 73 insertions(+), 124 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index 3703c3d71809..43364e559081 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -26,6 +26,27 @@ #define GPIO_TYPE_V1 (0) /* GPIO Version ID reserved */ #define GPIO_TYPE_V2 (0x01000C2B) /* GPIO Version ID 0x01000C2B */ +#define GPIO_MAX_PINS (32) + +struct rockchip_gpio { + struct device *dev; + void __iomem *reg_base; + struct gpio_chip gpio_chip; + struct irq_domain *domain; + const struct rockchip_gpio_regs *gpio_regs; + struct device_node *of_node; + struct clk *clk; + struct clk *db_clk; + raw_spinlock_t slock; + u32 saved_masks; + u32 toggle_edge_mode; + int gpio_type; + int irq; + int id; +}; + +#define to_gpio_gpio(_gc) \ + (container_of(_gc, struct rockchip_gpio, gpio_chip)) static const struct rockchip_gpio_regs gpio_regs_v1 = { .port_dr = 0x00, @@ -70,7 +91,7 @@ static inline u32 gpio_readl_v2(void __iomem *reg) return readl(reg + 0x4) << 16 | readl(reg); } -static inline void rockchip_gpio_writel(struct rockchip_pin_bank *bank, +static inline void rockchip_gpio_writel(struct rockchip_gpio *bank, u32 value, unsigned int offset) { void __iomem *reg = bank->reg_base + offset; @@ -81,7 +102,7 @@ static inline void rockchip_gpio_writel(struct rockchip_pin_bank *bank, writel(value, reg); } -static inline u32 rockchip_gpio_readl(struct rockchip_pin_bank *bank, +static inline u32 rockchip_gpio_readl(struct rockchip_gpio *bank, unsigned int offset) { void __iomem *reg = bank->reg_base + offset; @@ -95,7 +116,7 @@ static inline u32 rockchip_gpio_readl(struct rockchip_pin_bank *bank, return value; } -static inline void rockchip_gpio_writel_bit(struct rockchip_pin_bank *bank, +static inline void rockchip_gpio_writel_bit(struct rockchip_gpio *bank, u32 bit, u32 value, unsigned int offset) { @@ -117,7 +138,7 @@ static inline void rockchip_gpio_writel_bit(struct rockchip_pin_bank *bank, } } -static inline u32 rockchip_gpio_readl_bit(struct rockchip_pin_bank *bank, +static inline u32 rockchip_gpio_readl_bit(struct rockchip_gpio *bank, u32 bit, unsigned int offset) { void __iomem *reg = bank->reg_base + offset; @@ -137,7 +158,7 @@ static inline u32 rockchip_gpio_readl_bit(struct rockchip_pin_bank *bank, static int rockchip_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) { - struct rockchip_pin_bank *bank = gpiochip_get_data(chip); + struct rockchip_gpio *bank = gpiochip_get_data(chip); u32 data; data = rockchip_gpio_readl_bit(bank, offset, bank->gpio_regs->port_ddr); @@ -150,7 +171,7 @@ static int rockchip_gpio_get_direction(struct gpio_chip *chip, static int rockchip_gpio_set_direction(struct gpio_chip *chip, unsigned int offset, bool input) { - struct rockchip_pin_bank *bank = gpiochip_get_data(chip); + struct rockchip_gpio *bank = gpiochip_get_data(chip); unsigned long flags; u32 data = input ? 0 : 1; @@ -164,7 +185,7 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip, static void rockchip_gpio_set(struct gpio_chip *gc, unsigned int offset, int value) { - struct rockchip_pin_bank *bank = gpiochip_get_data(gc); + struct rockchip_gpio *bank = gpiochip_get_data(gc); unsigned long flags; raw_spin_lock_irqsave(&bank->slock, flags); @@ -174,7 +195,7 @@ static void rockchip_gpio_set(struct gpio_chip *gc, unsigned int offset, static int rockchip_gpio_get(struct gpio_chip *gc, unsigned int offset) { - struct rockchip_pin_bank *bank = gpiochip_get_data(gc); + struct rockchip_gpio *bank = gpiochip_get_data(gc); u32 data; data = readl(bank->reg_base + bank->gpio_regs->ext_port); @@ -188,8 +209,8 @@ static int rockchip_gpio_set_debounce(struct gpio_chip *gc, unsigned int offset, unsigned int debounce) { - struct rockchip_pin_bank *bank = gpiochip_get_data(gc); - const struct rockchip_gpio_regs *reg = bank->gpio_regs; + struct rockchip_gpio *bank = gpiochip_get_data(gc); + const struct rockchip_gpio_regs *reg = bank->gpio_regs; unsigned long flags, div_reg, freq, max_debounce; bool div_debounce_support; unsigned int cur_div_reg; @@ -295,7 +316,7 @@ static int rockchip_gpio_set_config(struct gpio_chip *gc, unsigned int offset, */ static int rockchip_gpio_to_irq(struct gpio_chip *gc, unsigned int offset) { - struct rockchip_pin_bank *bank = gpiochip_get_data(gc); + struct rockchip_gpio *bank = gpiochip_get_data(gc); unsigned int virq; if (!bank->domain) @@ -322,10 +343,10 @@ static const struct gpio_chip rockchip_gpiolib_chip = { static void rockchip_irq_demux(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); - struct rockchip_pin_bank *bank = irq_desc_get_handler_data(desc); + struct rockchip_gpio *bank = irq_desc_get_handler_data(desc); u32 pend; - dev_dbg(bank->dev, "got irq for bank %s\n", bank->name); + dev_dbg(bank->dev, "got irq\n"); chained_irq_enter(chip, desc); @@ -385,7 +406,7 @@ static void rockchip_irq_demux(struct irq_desc *desc) static int rockchip_irq_set_type(struct irq_data *d, unsigned int type) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); - struct rockchip_pin_bank *bank = gc->private; + struct rockchip_gpio *bank = gc->private; u32 mask = BIT(d->hwirq); u32 polarity; u32 level; @@ -468,7 +489,7 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type) static int rockchip_irq_reqres(struct irq_data *d) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); - struct rockchip_pin_bank *bank = gc->private; + struct rockchip_gpio *bank = gc->private; return gpiochip_reqres_irq(&bank->gpio_chip, d->hwirq); } @@ -476,7 +497,7 @@ static int rockchip_irq_reqres(struct irq_data *d) static void rockchip_irq_relres(struct irq_data *d) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); - struct rockchip_pin_bank *bank = gc->private; + struct rockchip_gpio *bank = gc->private; gpiochip_relres_irq(&bank->gpio_chip, d->hwirq); } @@ -484,7 +505,7 @@ static void rockchip_irq_relres(struct irq_data *d) static void rockchip_irq_suspend(struct irq_data *d) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); - struct rockchip_pin_bank *bank = gc->private; + struct rockchip_gpio *bank = gc->private; bank->saved_masks = irq_reg_readl(gc, bank->gpio_regs->int_mask); irq_reg_writel(gc, ~gc->wake_active, bank->gpio_regs->int_mask); @@ -493,7 +514,7 @@ static void rockchip_irq_suspend(struct irq_data *d) static void rockchip_irq_resume(struct irq_data *d) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); - struct rockchip_pin_bank *bank = gc->private; + struct rockchip_gpio *bank = gc->private; irq_reg_writel(gc, bank->saved_masks, bank->gpio_regs->int_mask); } @@ -508,7 +529,7 @@ static void rockchip_irq_disable(struct irq_data *d) irq_gc_mask_set_bit(d); } -static int rockchip_interrupts_register(struct rockchip_pin_bank *bank) +static int rockchip_interrupts_register(struct rockchip_gpio *bank) { unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN; struct irq_chip_generic *gc; @@ -517,8 +538,7 @@ static int rockchip_interrupts_register(struct rockchip_pin_bank *bank) bank->domain = irq_domain_add_linear(bank->of_node, 32, &irq_generic_chip_ops, NULL); if (!bank->domain) { - dev_warn(bank->dev, "could not init irq domain for bank %s\n", - bank->name); + dev_warn(bank->dev, "could not init irq domain\n"); return -EINVAL; } @@ -527,8 +547,7 @@ static int rockchip_interrupts_register(struct rockchip_pin_bank *bank) handle_level_irq, clr, 0, 0); if (ret) { - dev_err(bank->dev, "could not alloc generic chips for bank %s\n", - bank->name); + dev_err(bank->dev, "could not alloc generic chips\n"); irq_domain_remove(bank->domain); return -EINVAL; } @@ -554,7 +573,7 @@ static int rockchip_interrupts_register(struct rockchip_pin_bank *bank) gc->chip_types[0].chip.irq_set_type = rockchip_irq_set_type; gc->chip_types[0].chip.irq_request_resources = rockchip_irq_reqres; gc->chip_types[0].chip.irq_release_resources = rockchip_irq_relres; - gc->wake_enabled = IRQ_MSK(bank->nr_pins); + gc->wake_enabled = IRQ_MSK(GPIO_MAX_PINS); /* * Linux assumes that all interrupts start out disabled/masked. @@ -572,7 +591,7 @@ static int rockchip_interrupts_register(struct rockchip_pin_bank *bank) return 0; } -static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) +static int rockchip_gpiolib_register(struct rockchip_gpio *bank) { struct gpio_chip *gc; int ret; @@ -580,9 +599,9 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) bank->gpio_chip = rockchip_gpiolib_chip; gc = &bank->gpio_chip; - gc->base = bank->pin_base; - gc->ngpio = bank->nr_pins; - gc->label = bank->name; + gc->base = GPIO_MAX_PINS * bank->id; + gc->ngpio = GPIO_MAX_PINS; + gc->label = kasprintf(GFP_KERNEL, "gpio%d", bank->id); gc->parent = bank->dev; ret = gpiochip_add_data(gc, bank); @@ -592,35 +611,6 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) return ret; } - /* - * For DeviceTree-supported systems, the gpio core checks the - * pinctrl's device node for the "gpio-ranges" property. - * If it is present, it takes care of adding the pin ranges - * for the driver. In this case the driver can skip ahead. - * - * In order to remain compatible with older, existing DeviceTree - * files which don't set the "gpio-ranges" property or systems that - * utilize ACPI the driver has to call gpiochip_add_pin_range(). - */ - if (!of_property_read_bool(bank->of_node, "gpio-ranges")) { - struct device_node *pctlnp = of_get_parent(bank->of_node); - struct pinctrl_dev *pctldev = NULL; - - if (!pctlnp) - return -ENODATA; - - pctldev = of_pinctrl_get(pctlnp); - if (!pctldev) - return -ENODEV; - - ret = gpiochip_add_pin_range(gc, dev_name(pctldev->dev), 0, - gc->base, gc->ngpio); - if (ret) { - dev_err(bank->dev, "Failed to add pin range\n"); - goto fail; - } - } - ret = rockchip_interrupts_register(bank); if (ret) { dev_err(bank->dev, "failed to register interrupt, %d\n", ret); @@ -635,19 +625,14 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) return ret; } -static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) +static int rockchip_gpio_get_type(struct rockchip_gpio *bank) { int id = 0; - bank->clk = of_clk_get(bank->of_node, 0); - if (IS_ERR(bank->clk)) - return PTR_ERR(bank->clk); - - clk_prepare_enable(bank->clk); id = readl(bank->reg_base + gpio_regs_v2.version_id); /* If not gpio v2, that is default to v1. */ - if (id == GPIO_TYPE_V2) { + if (id != GPIO_TYPE_V1) { bank->gpio_regs = &gpio_regs_v2; bank->gpio_type = GPIO_TYPE_V2; bank->db_clk = of_clk_get(bank->of_node, 1); @@ -664,7 +649,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) return 0; } -static int rockchip_gpio_get_irq(struct rockchip_pin_bank *bank) +static int rockchip_gpio_get_irq(struct rockchip_gpio *bank) { struct device *dev = bank->dev; struct fwnode_handle *fwnode = dev_fwnode(dev); @@ -682,55 +667,26 @@ static int rockchip_gpio_get_irq(struct rockchip_pin_bank *bank) return irq; } -static struct rockchip_pin_bank * -rockchip_gpio_find_bank(struct pinctrl_dev *pctldev, int id) -{ - struct rockchip_pinctrl *info; - struct rockchip_pin_bank *bank; - int i, found = 0; - - info = pinctrl_dev_get_drvdata(pctldev); - bank = info->ctrl->pin_banks; - for (i = 0; i < info->ctrl->nr_banks; i++, bank++) { - if (bank->bank_num == id) { - found = 1; - break; - } - } - - return found ? bank : NULL; -} - static int rockchip_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - struct device_node *pctlnp = of_get_parent(np); - struct pinctrl_dev *pctldev = NULL; - struct rockchip_pin_bank *bank = NULL; - struct rockchip_pin_output_deferred *cfg; - static int gpio; + struct rockchip_gpio *bank; + static int static_gpio_id; int id, ret; - if (!np || !pctlnp) - return -ENODEV; - - pctldev = of_pinctrl_get(pctlnp); - if (!pctldev) - return -EPROBE_DEFER; + bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); + if (!bank) + return -ENOMEM; id = of_alias_get_id(np, "gpio"); if (id < 0) - id = gpio++; - - bank = rockchip_gpio_find_bank(pctldev, id); - if (!bank) - return -EINVAL; + id = static_gpio_id++; + bank->id = id; bank->dev = dev; bank->of_node = np; - raw_spin_lock_init(&bank->slock); bank->reg_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(bank->reg_base)) return PTR_ERR(bank->reg_base); @@ -739,46 +695,39 @@ static int rockchip_gpio_probe(struct platform_device *pdev) if (bank->irq < 0) return bank->irq; - ret = rockchip_get_bank_data(bank); - if (ret) - return ret; + bank->clk = of_clk_get(np, 0); + if (IS_ERR(bank->clk)) + return PTR_ERR(bank->clk); - /* - * Prevent clashes with a deferred output setting - * being added right at this moment. - */ - mutex_lock(&bank->deferred_lock); + bank->db_clk = of_clk_get(np, 1); + if (IS_ERR(bank->db_clk)) + bank->db_clk = NULL; - ret = rockchip_gpiolib_register(bank); + clk_prepare_enable(bank->clk); + + ret = rockchip_gpio_get_type(bank); if (ret) { clk_disable_unprepare(bank->clk); - mutex_unlock(&bank->deferred_lock); return ret; } - while (!list_empty(&bank->deferred_output)) { - cfg = list_first_entry(&bank->deferred_output, - struct rockchip_pin_output_deferred, head); - list_del(&cfg->head); - - ret = rockchip_gpio_direction_output(&bank->gpio_chip, cfg->pin, cfg->arg); - if (ret) - dev_warn(dev, "setting output pin %u to %u failed\n", cfg->pin, cfg->arg); + raw_spin_lock_init(&bank->slock); - kfree(cfg); + ret = rockchip_gpiolib_register(bank); + if (ret) { + clk_disable_unprepare(bank->clk); + return ret; } - mutex_unlock(&bank->deferred_lock); - platform_set_drvdata(pdev, bank); - dev_info(dev, "probed %pOF\n", np); + printk("%s: probed %s\n", __func__, dev_name(dev)); return 0; } static int rockchip_gpio_remove(struct platform_device *pdev) { - struct rockchip_pin_bank *bank = platform_get_drvdata(pdev); + struct rockchip_gpio *bank = platform_get_drvdata(pdev); clk_disable_unprepare(bank->clk); gpiochip_remove(&bank->gpio_chip); From patchwork Tue Mar 8 06:19:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12773040 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 AF104C4332F for ; Tue, 8 Mar 2022 06:19:48 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=uELXgFxSX0Tv3JyiZ6qZSJtvt2so/au2yzITxcNpVo8=; b=nWULjwX73tAPyC lnlj+QgPpB5S3PUD26SY2JReJKeEc4Nohad5jxthYHhej28P2BUAVzNAYVjNnraNPSjwW43a+p4co GXSiC6NWgHqHDKX4VNXcos2g1V5YQzG8KnYWUpJjypdudJyeMBzoRvur66181tkmsBi1c3TLBV0/A glZ+8/HXbQRmtMQjQRvsk/pnlT+uxJaMmL/TSe7Z4gNyqJak/ppOzEjK/F83pSbwa2DjqjYgtpB+X LC5s8zglcnTzCYepnu9UGrGE7TrdRB3sGtf04760z2SzhURluep8sZ1HZaoAgoVVHr9DKIjm9pBNs v65YZcMdM/cE/bcJs8uQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRTCD-002mAt-Jr; Tue, 08 Mar 2022 06:19:45 +0000 Received: from mail-m17661.qiye.163.com ([59.111.176.61]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRTC8-002m8K-Uo for linux-rockchip@lists.infradead.org; Tue, 08 Mar 2022 06:19:44 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m17661.qiye.163.com (Hmail) with ESMTPA id 14D2A1DF6C3; Tue, 8 Mar 2022 14:19:39 +0800 (CST) From: Jianqun Xu To: heiko@sntech.de Cc: linus.walleij@linaro.org, huangtao@rock-chips.com, kever.yang@rock-chips.com, linux-rockchip@lists.infradead.org, linux-gpio@vger.kernel.org, Jianqun Xu Subject: [PATCH 4/4] pinctrl: rockchip: register gpio driver before pinctrl driver Date: Tue, 8 Mar 2022 14:19:35 +0800 Message-Id: <20220308061935.2441447-5-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308061935.2441447-1-jay.xu@rock-chips.com> References: <20220308061935.2441447-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1 kWDxoPAgseWUFZKDYvK1lXWShZQUlKS0tKN1dZLVlBSVdZDwkaFQgSH1lBWUNNH0lWQhlLSR5NQk 5NH0NLVRMBExYaEhckFA4PWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NUk6TDo5Tj5RGTI0FhcDKxoi AUowCi5VSlVKTU9NTElLSExCTkhPVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUxOTk83Bg++ X-HM-Tid: 0a7f682ee96cda2bkuws14d2a1df6c3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220307_221941_362065_96CEB8AA X-CRM114-Status: GOOD ( 17.18 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org This patch should co-work with the gpio-rockchip driver patch, it populates the gpio platform first and add gpio_chip after pinctrl register. Signed-off-by: Jianqun Xu --- drivers/pinctrl/pinctrl-rockchip.c | 90 ++++++++++-------------------- drivers/pinctrl/pinctrl-rockchip.h | 2 +- 2 files changed, 29 insertions(+), 63 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index d8dd8415fa81..8e60811b4942 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -2095,30 +2095,13 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl, return false; } -static int rockchip_pinconf_defer_output(struct rockchip_pin_bank *bank, - unsigned int pin, u32 arg) -{ - struct rockchip_pin_output_deferred *cfg; - - cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); - if (!cfg) - return -ENOMEM; - - cfg->pin = pin; - cfg->arg = arg; - - list_add_tail(&cfg->head, &bank->deferred_output); - - return 0; -} - /* set the pin config settings for a specified pin */ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, unsigned long *configs, unsigned num_configs) { struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); struct rockchip_pin_bank *bank = pin_to_bank(info, pin); - struct gpio_chip *gpio = &bank->gpio_chip; + struct gpio_chip *gpio = bank->gpio_chip; enum pin_config_param param; u32 arg; int i; @@ -2156,22 +2139,6 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, if (rc != RK_FUNC_GPIO) return -EINVAL; - /* - * Check for gpio driver not being probed yet. - * The lock makes sure that either gpio-probe has completed - * or the gpio driver hasn't probed yet. - */ - mutex_lock(&bank->deferred_lock); - if (!gpio || !gpio->direction_output) { - rc = rockchip_pinconf_defer_output(bank, pin - bank->pin_base, arg); - mutex_unlock(&bank->deferred_lock); - if (rc) - return rc; - - break; - } - mutex_unlock(&bank->deferred_lock); - rc = gpio->direction_output(gpio, pin - bank->pin_base, arg); if (rc) @@ -2211,7 +2178,7 @@ static int rockchip_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, { struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); struct rockchip_pin_bank *bank = pin_to_bank(info, pin); - struct gpio_chip *gpio = &bank->gpio_chip; + struct gpio_chip *gpio = bank->gpio_chip; enum pin_config_param param = pinconf_to_config_param(*config); u16 arg; int rc; @@ -2484,9 +2451,6 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, pdesc->name = pin_names[pin]; pdesc++; } - - INIT_LIST_HEAD(&pin_bank->deferred_output); - mutex_init(&pin_bank->deferred_lock); } ret = rockchip_pinctrl_parse_dt(pdev, info); @@ -2525,7 +2489,6 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( for (i = 0; i < ctrl->nr_banks; ++i, ++bank) { int bank_pins = 0; - raw_spin_lock_init(&bank->slock); bank->drvdata = d; bank->pin_base = ctrl->nr_pins; ctrl->nr_pins += bank->nr_pins; @@ -2666,6 +2629,13 @@ static int __maybe_unused rockchip_pinctrl_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(rockchip_pinctrl_dev_pm_ops, rockchip_pinctrl_suspend, rockchip_pinctrl_resume); +static int gpiochip_match_name(struct gpio_chip *gc, void *data) +{ + const char *name = data; + + return !strcmp(gc->label, name); +} + static int rockchip_pinctrl_probe(struct platform_device *pdev) { struct rockchip_pinctrl *info; @@ -2674,7 +2644,7 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) struct rockchip_pin_ctrl *ctrl; struct resource *res; void __iomem *base; - int ret; + int ret, i; if (!dev->of_node) return dev_err_probe(dev, -ENODEV, "device tree node not found\n"); @@ -2683,6 +2653,10 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) if (!info) return -ENOMEM; + ret = of_platform_populate(np, NULL, NULL, NULL); + if (ret) + return dev_err_probe(dev, ret, "failed to register gpio device\n"); + info->dev = dev; ctrl = rockchip_pinctrl_get_soc_data(info, pdev); @@ -2733,37 +2707,29 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) if (ret) return ret; - platform_set_drvdata(pdev, info); + for (i = 0; i < ctrl->nr_banks; i++) { + struct gpio_chip *gc; + struct rockchip_pin_bank *bank = &ctrl->pin_banks[i]; - ret = of_platform_populate(np, NULL, NULL, &pdev->dev); - if (ret) - return dev_err_probe(dev, ret, "failed to register gpio device\n"); + gc = gpiochip_find((void *)ctrl->pin_banks[i].name, gpiochip_match_name); + ret = gpiochip_add_pin_range(gc, dev_name(dev), 0, gc->base, gc->ngpio); + if (ret) { + dev_err(dev, "fail to add pin range\n"); + return ret; + } + bank->gpio_chip = gc; + } + + platform_set_drvdata(pdev, info); + dev_info(dev, "probed %s\n", dev_name(dev)); return 0; } static int rockchip_pinctrl_remove(struct platform_device *pdev) { - struct rockchip_pinctrl *info = platform_get_drvdata(pdev); - struct rockchip_pin_bank *bank; - struct rockchip_pin_output_deferred *cfg; - int i; - of_platform_depopulate(&pdev->dev); - for (i = 0; i < info->ctrl->nr_banks; i++) { - bank = &info->ctrl->pin_banks[i]; - - mutex_lock(&bank->deferred_lock); - while (!list_empty(&bank->deferred_output)) { - cfg = list_first_entry(&bank->deferred_output, - struct rockchip_pin_output_deferred, head); - list_del(&cfg->head); - kfree(cfg); - } - mutex_unlock(&bank->deferred_lock); - } - return 0; } diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h index 91f10279d084..b109750ac294 100644 --- a/drivers/pinctrl/pinctrl-rockchip.h +++ b/drivers/pinctrl/pinctrl-rockchip.h @@ -163,7 +163,7 @@ struct rockchip_pin_bank { struct device_node *of_node; struct rockchip_pinctrl *drvdata; struct irq_domain *domain; - struct gpio_chip gpio_chip; + struct gpio_chip *gpio_chip; struct pinctrl_gpio_range grange; raw_spinlock_t slock; const struct rockchip_gpio_regs *gpio_regs;