From patchwork Tue Sep 20 10:30:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981862 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 DD8E7C54EE9 for ; Tue, 20 Sep 2022 10:31:43 +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=1AUodBem7SCWqW+iHfrvq2Kv/Ki0E7PDuD0CNf29/ts=; b=vNK0beCyh2OZ2r ktgbCRPDyahiereWDGcTiheXE++jat43IHPTxggmo4T9/xO/f9rFYPvU1Z6wUJpUI9J9zL/fsi2gO 0Uuj0fYHxVsetR4ha+oo0akjxj/LiPXceab+zZGfHsJaJLyef/WCjvLogTD52uZcTqwt1jcOcKNwj j2QWhlbtQYwIcbdFbQmitg+Y18uXgX/oM5/J4fOuCxmejNzNJM2jrrITlydH6rNwm89a8Or8ZXTJE GveiTx4v1k4XfN/gKcLHRd5/oEGi99/LspItSbgXGOs+EjXoa7/EzkzpGYoiyjrsZmI+YDXX4vUaQ 44LwGUwVDAG9K31M1CvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXJ-002yNg-1g; Tue, 20 Sep 2022 10:31:29 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaX5-002yGO-La for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:26 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id D42C4280B58; Tue, 20 Sep 2022 18:31:10 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Hans de Goede Subject: [PATCH 01/20] ACPI: utils: Add acpi_dev_uid_to_integer() helper to get _UID as integer Date: Tue, 20 Sep 2022 18:30:49 +0800 Message-Id: <20220920103108.23074-2-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCQ0hLVk5OQ00eSkNLSx4dH1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Mhw6MCo6Qj0dURw3FxRCLykf SQEwFExVSlVKTU1ITU1CQ0xKTktNVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhCS083Bg++ X-HM-Tid: 0a835a73a2102eb1kusnd42c4280b58 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033118_716957_A80B04E2 X-CRM114-Status: UNSURE ( 9.06 ) 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 From: Andy Shevchenko Some users interpret _UID only as integer and for them it's easier to have an integer representation of _UID. Add respective helper for that. Signed-off-by: Andy Shevchenko Reviewed-by: Hans de Goede --- drivers/acpi/utils.c | 24 ++++++++++++++++++++++++ include/acpi/acpi_bus.h | 1 + include/linux/acpi.h | 5 +++++ 3 files changed, 30 insertions(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 5a7b8065e77f..febf9b8da3a0 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -793,6 +793,30 @@ bool acpi_dev_hid_uid_match(struct acpi_device *adev, } EXPORT_SYMBOL(acpi_dev_hid_uid_match); +/** + * acpi_dev_uid_to_integer - treat ACPI device _UID as integer + * @adev: ACPI device to get _UID from + * @integer: output buffer for integer + * + * Considers _UID as integer and converts it to @integer. + * + * Returns 0 on success, or negative error code otherwise. + */ +int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer) +{ + const char *uid; + + if (!adev) + return -ENODEV; + + uid = acpi_device_uid(adev); + if (!uid) + return -ENODATA; + + return kstrtou64(uid, 0, integer); +} +EXPORT_SYMBOL(acpi_dev_uid_to_integer); + /** * acpi_dev_found - Detect presence of a given ACPI device in the namespace. * @hid: Hardware ID of the device. diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index e7d27373ff71..bd0db916f330 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -733,6 +733,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev) } bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2); +int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer); void acpi_dev_clear_dependencies(struct acpi_device *supplier); bool acpi_dev_ready_for_enumeration(const struct acpi_device *device); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 6f64b2f3dc54..9434db02cb60 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -798,6 +798,11 @@ acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *u return false; } +static inline int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer) +{ + return -ENODEV; +} + static inline struct acpi_device * acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) { From patchwork Tue Sep 20 10:30:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981861 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 73401C6FA8B for ; Tue, 20 Sep 2022 10:31:40 +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=KQmAd7CI37HF3RFZCHuq+28rccY+QWTnoQUKDZaa6Q8=; b=NhG5WrZlycp8fq cnBzxTvLsZFYkUuYRu6AJZMm/e66QrIhIlJcmVkNP1Ga13LCnzDFtzPetkFGY89oAtdDmol6qB5rs yl1Bpiy2E8TGR+mmRtoV6wPexWvEyuVVQHPoQLuyUnQmyJpDzg72OYlFeaV+6iY3Io9w04idXWUR3 YcWM5IUM7D7Y0wtY7dU1tDwudL6BLr5i3xlNr4RLUwatNco04f5YxMk4NOiy2dfaMdYMI8PKi4o07 4uHCLsLKhFSWZrkOmfbQCvWTAzU1Fz/nlgQVqV84Foglzmsz0AnQmONsjvMRgdFxMvL3M55ZIghNt SltPE9f6FpXEyCE51Dbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXI-002yNM-Hb; Tue, 20 Sep 2022 10:31:28 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaX5-002yHa-LZ for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:26 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 88F27280B5E; Tue, 20 Sep 2022 18:31:11 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 02/20] pinctrl/rockchip: populate GPIO platform early Date: Tue, 20 Sep 2022 18:30:50 +0800 Message-Id: <20220920103108.23074-3-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDSkpOVh5PQ0xPTUxJSUlOSFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktPSElVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NTY6Djo4Fz0qTRw2VgsuLyxI TDJPFChVSlVKTU1ITU1CQ0xJSUtOVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlOSks3Bg++ X-HM-Tid: 0a835a73a4c42eb1kusn88f27280b5e X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033118_690888_08378317 X-CRM114-Status: UNSURE ( 8.61 ) 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 It is better to register GPIO devices before pinctrl device, so move the populate GPIO platform early before pinctrl do really probe. Signed-off-by: Jianqun Xu --- drivers/pinctrl/pinctrl-rockchip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index a91061f9c2ac..25633c7b4244 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -3302,6 +3302,10 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) if (!dev->of_node) return dev_err_probe(dev, -ENODEV, "device tree node not found\n"); + ret = of_platform_populate(np, NULL, NULL, dev); + if (ret) + return dev_err_probe(dev, ret, "failed to register gpio device\n"); + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; @@ -3360,10 +3364,6 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) platform_set_drvdata(pdev, info); - ret = of_platform_populate(np, NULL, NULL, &pdev->dev); - if (ret) - return dev_err_probe(dev, ret, "failed to register gpio device\n"); - return 0; } From patchwork Tue Sep 20 10:30:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981867 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 CC00DC54EE9 for ; Tue, 20 Sep 2022 10:31:52 +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=0pU87buIl3yomtjveKtV+JsVQDCD9tullBXZe11Ksgk=; b=t0w0RGc9D+wB9o /7zX+BG9kfkywpDUbENek09Y5OYbHXkrh52bp1KaPuMnIvMD2rUg+LJCu4ZVaJGjDMWYtn9Zp2f8x tA8W3lbaZCezuaivPsLhNd7OhCA1lkotpwZkWKjBes7L1ZCEWmnAdjC40QyYKGc9AbJ7n5ReriIPA gkkNYWoJypt3y7puB/cZPFx2B394X5ik/xVKt3RWVPfn4a5oLWdapIshMtO1G+8bZMvThkPAG8y5e um+F1vIV4g0EcB5kssFb/ybfZ0njsSm5EnVyFV46FAK57mbdIcHr/7tjA8cv1cqoo1/bh9qcpuTKc JUKQDA4R/MTKLuHXn+ZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXP-002yV0-5P; Tue, 20 Sep 2022 10:31:35 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaX5-002yHd-LZ for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:28 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 3F483280AB7; Tue, 20 Sep 2022 18:31:12 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 03/20] pinctrl/rockchip: use fwnode instead of of_node Date: Tue, 20 Sep 2022 18:30:51 +0800 Message-Id: <20220920103108.23074-4-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZTh5IVkpIGU9KT0pITkxLH1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6ORg6ARw6ED0YURxCLQpNLyhD PhVPFD5VSlVKTU1ITU1CQ0xJQ0JNVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhJT083Bg++ X-HM-Tid: 0a835a73a7882eb1kusn3f483280ab7 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033118_670093_55311BAD X-CRM114-Status: GOOD ( 11.38 ) 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 Switch the pinctrl driver to use fwnode instead of the of_node. Signed-off-by: Jianqun Xu --- drivers/pinctrl/pinctrl-rockchip.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 25633c7b4244..723b44edc1f2 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -3033,8 +3033,8 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev, struct rockchip_pinctrl *info) { struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; - struct device_node *child; + struct fwnode_handle *fwnode = dev_fwnode(dev); + struct device_node *np = to_of_node(fwnode), *child; int ret; int i; @@ -3129,7 +3129,8 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *node = dev->of_node; + struct fwnode_handle *fwnode = dev_fwnode(dev); + struct device_node *node = to_of_node(fwnode); const struct of_device_id *match; struct rockchip_pin_ctrl *ctrl; struct rockchip_pin_bank *bank; @@ -3291,15 +3292,16 @@ static SIMPLE_DEV_PM_OPS(rockchip_pinctrl_dev_pm_ops, rockchip_pinctrl_suspend, static int rockchip_pinctrl_probe(struct platform_device *pdev) { - struct rockchip_pinctrl *info; struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node, *node; + struct fwnode_handle *fwnode = dev_fwnode(dev); + struct device_node *np = to_of_node(fwnode), *node; + struct rockchip_pinctrl *info; struct rockchip_pin_ctrl *ctrl; struct resource *res; void __iomem *base; int ret; - if (!dev->of_node) + if (!is_of_node(fwnode)) return dev_err_probe(dev, -ENODEV, "device tree node not found\n"); ret = of_platform_populate(np, NULL, NULL, dev); From patchwork Tue Sep 20 10:30:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981864 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 B23D8C6FA8E for ; Tue, 20 Sep 2022 10:31:47 +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=MiyoGIQ1Yiw/9Dz0cEOAXmeGUesaMWfkpACE++7U630=; b=pUq3lhkSvYpcVL KpIaUUGGitZi61veF2WcRfu9RjiKVhzTeMivPItsdp3uq+Eixunj3Y+iPM+tJ6leM7eXAYUHvnULG ngYC7X+yHAssoIrUVinOtXVrpdXeZxAQsf1LWIiLqq+Lf8eV+7urqEOf2JgQ6UnLyCHz13IJgiB0w H9CogkwmnvqjUEP1XVzzh6ykUBHzBn/+Jvm9yKU8pJ59ET2lw2uXTWuwCojI62MPcovMlyFdEz+Nx lHI/cBVKxxkygn6H1g5OfoxX8Fxre65JSOA8ZZ7hNnHka2xNHEZTflwPaRs0SXU/6umC5pqOfosnN kPC62Tg5PkhMTdfckwsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXQ-002yVX-0P; Tue, 20 Sep 2022 10:31:36 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaX5-002yHe-Lb for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:28 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id E8A98280B70; Tue, 20 Sep 2022 18:31:12 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 04/20] pinctrl/rockchip: switch to use device_get_match_data Date: Tue, 20 Sep 2022 18:30:52 +0800 Message-Id: <20220920103108.23074-5-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaHksZVk9MT0JMTU1NHkpOSFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PlE6Njo4ND0ZEBwxVgoVLxoO MBUwCTRVSlVKTU1ITU1CQ0xITUpOVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlPTUo3Bg++ X-HM-Tid: 0a835a73aa352eb1kusne8a98280b70 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033124_776810_0A5DFEE9 X-CRM114-Status: UNSURE ( 8.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 Switch to use device_get_match_data to get match data. Signed-off-by: Jianqun Xu --- drivers/pinctrl/pinctrl-rockchip.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 723b44edc1f2..8f102f327af8 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -3129,16 +3129,11 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct fwnode_handle *fwnode = dev_fwnode(dev); - struct device_node *node = to_of_node(fwnode); - const struct of_device_id *match; struct rockchip_pin_ctrl *ctrl; struct rockchip_pin_bank *bank; int grf_offs, pmu_offs, drv_grf_offs, drv_pmu_offs, i, j; - match = of_match_node(rockchip_pinctrl_dt_match, node); - ctrl = (struct rockchip_pin_ctrl *)match->data; - + ctrl = (struct rockchip_pin_ctrl *)device_get_match_data(dev); grf_offs = ctrl->grf_mux_offset; pmu_offs = ctrl->pmu_mux_offset; drv_pmu_offs = ctrl->pmu_drv_offset; From patchwork Tue Sep 20 10:30:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981865 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 43218C6FA91 for ; Tue, 20 Sep 2022 10:31: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=kEnQqD34XxaoBgYau7nFObg3hzKstGHsLXacJ6xuz64=; b=lfJvNlop/J7Pwx 75oVsrhKF66aW/x8ZIcYpzgFRxDjBHpjiZ2sGshFpRinyZqWBbJQZCtOdPROOiGc5YetyZN8UKDol NAA5+oYlO0fv60mNmlPnI4QX6hTTt1lGO5wUAdh+UKYIdoRt5anZmT82Ph09n1gWmg23Cr+HtAiEW l8fordaaTRy3RFYLRb/yjxKHxRh+zX4umixIOzav6iQG01hLz82d1pxsuDUbT2F3PRf3wEnY+4q7x 1WZ5zGflWyeGB7GeFr3T2GEeuE3ZvM7mXWAwffn5uaY4uVbd8i5ANUJz1tCRhBIBz8flsCyzcpuO/ yt9FeUEXz47Nj7IfF7Gw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXS-002yXn-AR; Tue, 20 Sep 2022 10:31:38 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXH-002yLS-Tu for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:29 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id A4626280B8F; Tue, 20 Sep 2022 18:31:13 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 05/20] pinctrl/rockchip: of_populate_platform for gpio only for of node Date: Tue, 20 Sep 2022 18:30:53 +0800 Message-Id: <20220920103108.23074-6-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDHk4ZVkxKQh4aGRlOS0lIT1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PQg6SSo*ST0hDBxPLQsSLyEs Kz0wFElVSlVKTU1ITU1CQ0xPSEpCVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlPSUs3Bg++ X-HM-Tid: 0a835a73ad052eb1kusna4626280b8f X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033128_144672_AE979FD0 X-CRM114-Status: UNSURE ( 9.51 ) 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 As the of_populate_platform named with prefix "of_", it should be done only when the of node is exist. Signed-off-by: Jianqun Xu --- drivers/pinctrl/pinctrl-rockchip.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 8f102f327af8..42aa3552417a 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -3296,12 +3296,11 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) void __iomem *base; int ret; - if (!is_of_node(fwnode)) - return dev_err_probe(dev, -ENODEV, "device tree node not found\n"); - - ret = of_platform_populate(np, NULL, NULL, dev); - if (ret) - return dev_err_probe(dev, ret, "failed to register gpio device\n"); + if (is_of_node(fwnode)) { + ret = of_platform_populate(np, NULL, NULL, dev); + if (ret) + return dev_err_probe(dev, ret, "failed to register gpio device\n"); + } info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info) From patchwork Tue Sep 20 10:30:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981868 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 612C3C54EE9 for ; Tue, 20 Sep 2022 10:31:55 +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=SbA/4KzhUyHZlMPV83OtmnB4bcsjo2fEfwxORL+fQB4=; b=ewHkoWzQYUrm+e cGN6TcFJdPQUT5Pjr6jzWTXc3daO2kRdfQAN98FU09KdVKcIi2T9t7CBawhaR3P8iCAoH+A/Sg8eE CQ+4m+cV5mGOvM8RVu6TLGBgxE1Ce/bhL73BaGegLAjBkDMeu2ScmdM9b70uOedUZppVydnhT/KNs VhdOxRdKMFFfeqUVOW+u8v1+zWWiJGD4Y8kotrj7vVDN/ciPC7NwcnJ7xB02rhDw6ml+k+sTPbZIw uIlMfMSDnwXneqv+SJQzkJHOipBWIufESqwLHyflroEz8/vHdBSs4y32u5gQi+E+hF5sdGb7N6FTj y2yqtLodyopyE0rnmqOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXV-002yat-Jb; Tue, 20 Sep 2022 10:31:41 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXH-002yLR-Tw for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:31 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 5B7DA280B9C; Tue, 20 Sep 2022 18:31:14 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 06/20] pinctrl/rockchip: parse dt only if the fwnode is of node Date: Tue, 20 Sep 2022 18:30:54 +0800 Message-Id: <20220920103108.23074-7-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCGhhKVkhNGkhJHkgeSENDSVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OQg6OCo4Sj0YKhwtLQowLxpP LjBPCw9VSlVKTU1ITU1CQ0xOS0tLVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlLSEs3Bg++ X-HM-Tid: 0a835a73afbf2eb1kusn5b7da280b9c X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033128_249592_6AB9CD43 X-CRM114-Status: UNSURE ( 8.34 ) 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 Check if the fwnode is a of node before parsing dt, otherwise return a '0' to allow driver to continue. Signed-off-by: Jianqun Xu --- drivers/pinctrl/pinctrl-rockchip.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 42aa3552417a..7b8d3bff9721 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -3038,6 +3038,9 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev, int ret; int i; + if (!is_of_node(fwnode)) + return 0; + rockchip_pinctrl_child_count(info, np); dev_dbg(dev, "nfunctions = %d\n", info->nfunctions); From patchwork Tue Sep 20 10:30:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981866 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 BA867C54EE9 for ; Tue, 20 Sep 2022 10:31:50 +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=mjtfI1ObNHN9nEIt771i8Ny8rUjTG0xjT0V8FnaH1mM=; b=A057VBPR/VZEZt RdsTflp52mlPY1afA6XidwH8pV6WvS+GCMh3CJT5jJwecOFosZiMZIFiIsWDkcjDMI4H+PJJ2TDfw A0qHp49wus+uNQBZ8LLLuxIolpq3HrqktSZU9rKTMLGaJQODoz1ahgMazqdSXVMYq+uVKNXPQwjya TGdqU4fABTyBVz6++Y5SlMWibC0pwcuXG1enjYI5uwQgsSpW+mBEtb5MeQGWlYZVpv2IUxR+IkFCL Y24A5x5KeK0C6+CpzIsKneCLsqC0mNGgemZq+KbkgXCi6C8t5BLUOf01Kdx4cOeYXsSNFrGWMMY09 cDeGymDEAd6aMBRI/wPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXR-002yWM-4X; Tue, 20 Sep 2022 10:31:37 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXH-002yLT-Tv for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:29 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 0D6AA280B9F; Tue, 20 Sep 2022 18:31:15 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 07/20] pinctrl/rockchip: print a message if driver probed successfully Date: Tue, 20 Sep 2022 18:30:55 +0800 Message-Id: <20220920103108.23074-8-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaTklNVhgdSUJJS0hOQk0fGVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MBg6DAw5Tz0ZIhwiPRQRLyoK GE0aCxpVSlVKTU1ITU1CQ0xOTEtIVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUpCTUI3Bg++ X-HM-Tid: 0a835a73b26c2eb1kusn0d6aa280b9f X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033128_168016_3A5245AD X-CRM114-Status: UNSURE ( 8.05 ) 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 Add a print for the pinctrl driver to output a message when driver probed successfully. Signed-off-by: Jianqun Xu --- drivers/pinctrl/pinctrl-rockchip.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 7b8d3bff9721..801a1f6ca4db 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -3362,6 +3362,7 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) return ret; platform_set_drvdata(pdev, info); + dev_info(dev, "probed %pfw\n", fwnode); return 0; } From patchwork Tue Sep 20 10:30:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981872 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 BE61BC6FA8B for ; Tue, 20 Sep 2022 10:32:08 +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=fmbSn6mgrPH5CNWtlk9HkRsBeo9sSknFmjtlgQaMJVg=; b=U73sNvMExynxLv BhinQ9CiU3VsRGLZPXwCZzfR02xBpxW58pnRuY2PsePPUi4IvYsqqh3FlCoDz5288D8Fi1IR8Lu31 4VfuVUwJVp+WnkX/2HQQgkVX6bWow4z7u4RWJTyKwC/NvE6/2XQ1CspR9hsUe3KNPgBxfGciZiHwy NzMQ87ao9CNY5VQvS7Phd1PHAfCoG/tTybk2AYXTny02g6iVLFlB+7JcgveEllPLPM3th0WR4/Q3c bPo/kwf3qoQHM5dKDSJHGMjTuk0mSx712XevPFMgKwKLqdzOqyL9KAi5FoIRRwtkAtLeFX7zICeUH CG5HSlwn5B59K0JTTn+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXj-002ypM-0X; Tue, 20 Sep 2022 10:31:55 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXI-002yLV-6g for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:31 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id B93FE280BA6; Tue, 20 Sep 2022 18:31:15 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 08/20] gpiolib: make gpiochip_find_by_name to be common function Date: Tue, 20 Sep 2022 18:30:56 +0800 Message-Id: <20220920103108.23074-9-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCGEMeVkIZTR4eSR5NT0lMTVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MAg6Ixw*Kz0pNhwrFxQ8LxgO FwswCipVSlVKTU1ITU1CQ0xNT0pIVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhMSEw3Bg++ X-HM-Tid: 0a835a73b52a2eb1kusnb93fe280ba6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033128_504976_F0BF9904 X-CRM114-Status: GOOD ( 10.68 ) 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 Move find_chip_by_name from gpiolib to the gpio/driver.h, also rename to gpiochip_find_by_name, make it to be a common function. Signed-off-by: Jianqun Xu --- drivers/gpio/gpiolib.c | 16 ++-------------- include/linux/gpio/driver.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index cc9c0a12259e..c06334772c47 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -935,18 +935,6 @@ struct gpio_chip *gpiochip_find(void *data, } EXPORT_SYMBOL_GPL(gpiochip_find); -static int gpiochip_match_name(struct gpio_chip *gc, void *data) -{ - const char *name = data; - - return !strcmp(gc->label, name); -} - -static struct gpio_chip *find_chip_by_name(const char *name) -{ - return gpiochip_find((void *)name, gpiochip_match_name); -} - #ifdef CONFIG_GPIOLIB_IRQCHIP /* @@ -3660,7 +3648,7 @@ void gpiod_add_hogs(struct gpiod_hog *hogs) * The chip may have been registered earlier, so check if it * exists and, if so, try to hog the line now. */ - gc = find_chip_by_name(hog->chip_label); + gc = gpiochip_find_by_name(hog->chip_label); if (gc) gpiochip_machine_hog(gc, hog); } @@ -3745,7 +3733,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, return ERR_PTR(-EPROBE_DEFER); } - gc = find_chip_by_name(p->key); + gc = gpiochip_find_by_name(p->key); if (!gc) { /* diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 6aeea1071b1b..4ed26a7d98ff 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -618,6 +618,18 @@ extern int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip extern struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *gc, void *data)); +static int gpiochip_match_name(struct gpio_chip *gc, void *data) +{ + const char *name = data; + + return !strcmp(gc->label, name); +} + +static inline struct gpio_chip *gpiochip_find_by_name(const char *name) +{ + return gpiochip_find((void *)name, gpiochip_match_name); +} + bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset); int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset); void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset); From patchwork Tue Sep 20 10:30:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981871 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 39795C6FA8B for ; Tue, 20 Sep 2022 10:32:03 +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=sZO04Tzbt8/iXRMxUYsZsl3ghKgeb5K7GpLof+UJ9Ew=; b=JnvpL0Jm/PkK5X qPHhHgCOBvok68T6ptkmwhBT0gsclioS7Pymo5QrhQsFtDJIUi3c9cvJOhyj7eNwhEgiXI5tMJA0A 3Fw9ECH1NQfHEbO6Td2zBJMcNIJpi0mH7rM0SZLoCDvc15DYN9AUFMztOuWA1k8GGPcpguHIK53wF ohVX+wAKqCqMMlbv6kLvAOuX63ifURrA8shHH9RQe/cX+Jib9AsLaf2tZod1czmmw2bUOktD6ptH4 T53jipjSMTgJA2hcYhL2k18d5tCtNMBpH5C4rQJMVFu8XtJTXtMF4WkRb/dnemOv0ihN4V+54azuU CfplUshiiwSR3NgIcczg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXe-002yiy-DP; Tue, 20 Sep 2022 10:31:51 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXJ-002yN3-6U for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:31 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 71C22280B29; Tue, 20 Sep 2022 18:31:16 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 09/20] gpio/rockchip: drop 'bank->name' from the driver Date: Tue, 20 Sep 2022 18:30:57 +0800 Message-Id: <20220920103108.23074-10-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCGUpJVh4eSU4fS01IHx5MSVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NzI6Ogw5GD0eFBxLPQk6Lx8s FBZPCzFVSlVKTU1ITU1CQ0xMSkNIVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhKTEs3Bg++ X-HM-Tid: 0a835a73b7f12eb1kusn71c22280b29 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033129_421998_C71AF0AE X-CRM114-Status: UNSURE ( 8.40 ) 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 Not to use the 'bank->name' and create 'gc->lable' by the bank number. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index bb50335239ac..dafcc8be1687 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -327,7 +327,7 @@ static void rockchip_irq_demux(struct irq_desc *desc) struct rockchip_pin_bank *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); @@ -521,8 +521,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; } @@ -531,8 +530,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; } @@ -586,8 +584,10 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) gc = &bank->gpio_chip; gc->base = bank->pin_base; gc->ngpio = bank->nr_pins; - gc->label = bank->name; gc->parent = bank->dev; + gc->label = devm_kasprintf(bank->dev, GFP_KERNEL, "gpio%d", bank->bank_num); + if (!gc->label) + return -ENOMEM; ret = gpiochip_add_data(gc, bank); if (ret) { From patchwork Tue Sep 20 10:30:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981876 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 490D3C6FA8B for ; Tue, 20 Sep 2022 10:32:18 +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=Wmm3GOs8CpHbRcdZFZZ4vUQP1X5meQgcXWreYCr9bRg=; b=Gqn//xfz4HsMx8 nxH0k2//Q0Tl3jexHq80hiDQ/g4KYDZGckgK2f3LI4Xj4lQ+ZOP8M9bjUqiOEEdHnsXGorgzKJwuL hFyUimTRNVzHyFKirbY2wlujLRxXkmzB3EZbY+xaUoKxCuKXsjU2PEgm05wuBMCcHOfT8OSv4tgQE 8zsEBXs/cVDj+U2uX/20ivroWee1TTglQFR4k6JGEqWyfk2ra667/+EqCvL+K0L7a0wGboUZ1lZTn Tu/22E8RRK5nOh0OKNlgsliPl7fLdzXqixcZrZq5XJlQjSLVwWnN9Iv6543KuYk7NJjRH0l9DeE5a WVxaE8wz4fvM8F94qSKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXo-002ywc-Do; Tue, 20 Sep 2022 10:32:00 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXJ-002yN4-6Y for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:32 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 3A561280BAF; Tue, 20 Sep 2022 18:31:17 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 10/20] gpio/rockchip: revert deferred output settings on probe Date: Tue, 20 Sep 2022 18:30:58 +0800 Message-Id: <20220920103108.23074-11-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZT0pIVkIaTxpIH0odSktDGFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PRQ6Lzo5Tj0sLhw2FwkoLxka CA4aCj1VSlVKTU1ITU1CQ0xMQkNCVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUNPTEg3Bg++ X-HM-Tid: 0a835a73baf02eb1kusn3a561280baf X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033129_601603_CCB5DA9F X-CRM114-Status: GOOD ( 16.63 ) 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 revert 3 patches: Revert "gpio/rockchip: handle deferring input-enable pinconfs" This reverts commit 7ff11357810fd124825fdd9aaf0df90262b77844. Revert "pinctrl/rockchip: support deferring other gpio params" This reverts commit 8ce5ef64546850294b021497046588a7abcebe96. Revert "gpio/rockchip: fetch deferred output settings on probe" This reverts commit 59dd178e1d7cb6cac03b32aba7ed9bbce6761b6f. A patch for pinctrl-rockchip must be applied to make sure the gpiochips have been registered before the pinctrl to register. --- drivers/gpio/gpio-rockchip.c | 35 ------------------- drivers/pinctrl/pinctrl-rockchip.c | 54 ++++++++++++++---------------- drivers/pinctrl/pinctrl-rockchip.h | 7 ++-- 3 files changed, 27 insertions(+), 69 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index dafcc8be1687..b294ef009daf 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include "../pinctrl/core.h" @@ -708,7 +707,6 @@ static int rockchip_gpio_probe(struct platform_device *pdev) struct device_node *pctlnp = of_get_parent(np); struct pinctrl_dev *pctldev = NULL; struct rockchip_pin_bank *bank = NULL; - struct rockchip_pin_deferred *cfg; static int gpio; int id, ret; @@ -736,45 +734,12 @@ static int rockchip_gpio_probe(struct platform_device *pdev) if (ret) return ret; - /* - * Prevent clashes with a deferred output setting - * being added right at this moment. - */ - mutex_lock(&bank->deferred_lock); - ret = rockchip_gpiolib_register(bank); if (ret) { clk_disable_unprepare(bank->clk); - mutex_unlock(&bank->deferred_lock); return ret; } - while (!list_empty(&bank->deferred_pins)) { - cfg = list_first_entry(&bank->deferred_pins, - struct rockchip_pin_deferred, head); - list_del(&cfg->head); - - switch (cfg->param) { - case PIN_CONFIG_OUTPUT: - 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); - break; - case PIN_CONFIG_INPUT_ENABLE: - ret = rockchip_gpio_direction_input(&bank->gpio_chip, cfg->pin); - if (ret) - dev_warn(dev, "setting input pin %u failed\n", cfg->pin); - break; - default: - dev_warn(dev, "unknown deferred config param %d\n", cfg->param); - break; - } - kfree(cfg); - } - - mutex_unlock(&bank->deferred_lock); - platform_set_drvdata(pdev, bank); dev_info(dev, "probed %pOF\n", np); diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 801a1f6ca4db..97af52bb5481 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -2702,20 +2702,19 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl, return false; } -static int rockchip_pinconf_defer_pin(struct rockchip_pin_bank *bank, - unsigned int pin, u32 param, u32 arg) +static int rockchip_pinconf_defer_output(struct rockchip_pin_bank *bank, + unsigned int pin, u32 arg) { - struct rockchip_pin_deferred *cfg; + struct rockchip_pin_output_deferred *cfg; cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); if (!cfg) return -ENOMEM; cfg->pin = pin; - cfg->param = param; cfg->arg = arg; - list_add_tail(&cfg->head, &bank->deferred_pins); + list_add_tail(&cfg->head, &bank->deferred_output); return 0; } @@ -2736,25 +2735,6 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, param = pinconf_to_config_param(configs[i]); arg = pinconf_to_config_argument(configs[i]); - if (param == PIN_CONFIG_OUTPUT || param == PIN_CONFIG_INPUT_ENABLE) { - /* - * 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_pin(bank, pin - bank->pin_base, param, - arg); - mutex_unlock(&bank->deferred_lock); - if (rc) - return rc; - - break; - } - mutex_unlock(&bank->deferred_lock); - } - switch (param) { case PIN_CONFIG_BIAS_DISABLE: rc = rockchip_set_pull(bank, pin - bank->pin_base, @@ -2783,6 +2763,22 @@ 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) @@ -3109,7 +3105,7 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, pdesc++; } - INIT_LIST_HEAD(&pin_bank->deferred_pins); + INIT_LIST_HEAD(&pin_bank->deferred_output); mutex_init(&pin_bank->deferred_lock); } @@ -3371,7 +3367,7 @@ 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_deferred *cfg; + struct rockchip_pin_output_deferred *cfg; int i; of_platform_depopulate(&pdev->dev); @@ -3380,9 +3376,9 @@ static int rockchip_pinctrl_remove(struct platform_device *pdev) bank = &info->ctrl->pin_banks[i]; mutex_lock(&bank->deferred_lock); - while (!list_empty(&bank->deferred_pins)) { - cfg = list_first_entry(&bank->deferred_pins, - struct rockchip_pin_deferred, head); + 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); } diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h index 4759f336941e..3531633c0397 100644 --- a/drivers/pinctrl/pinctrl-rockchip.h +++ b/drivers/pinctrl/pinctrl-rockchip.h @@ -338,7 +338,7 @@ struct rockchip_pin_bank { u32 toggle_edge_mode; u32 recalced_mask; u32 route_mask; - struct list_head deferred_pins; + struct list_head deferred_output; struct mutex deferred_lock; }; @@ -414,12 +414,9 @@ struct rockchip_pin_config { unsigned int nconfigs; }; -enum pin_config_param; - -struct rockchip_pin_deferred { +struct rockchip_pin_output_deferred { struct list_head head; unsigned int pin; - enum pin_config_param param; u32 arg; }; From patchwork Tue Sep 20 10:30:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981870 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 55875C54EE9 for ; Tue, 20 Sep 2022 10:32:02 +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=zp2Vb6LVMwkQDDd9XyAOSxhV8c1OiVauiROgmWuB9G0=; b=tDeh5I+//k/Blq TIg9+E97bSKYHr7Z9s7YHFa6lu3/dLuZBSR5BlnBy0qIbegCFtJaUW/oYjneN7c1eRtnWWRN7NWKg vmpxkcDzsJMBecTYrQEp2R7nouCVUgDk6ZuDwB7z6fyRUUcyHnBh0bfeEsxrKp+3TdUentWJBcs7S WElvPKb1XXiQKGWam7mladh2kKjKzKScqKoaazG+KqhuNta5nc/ukkRpkHh2pd6dLJsPfFKySC2tf deKUo9TBpb9IbtzcqCU7oXsVo7s5arYVYlFFD/VMZ+KGAkj0CouiAG3lvBs+r0xgVEdNvCRczR9PG 6IgoU/weC1V6yDktZdQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXY-002ye5-Pq; Tue, 20 Sep 2022 10:31:45 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXJ-002yNE-9x for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:31 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 0A3B8280B96; Tue, 20 Sep 2022 18:31:18 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 11/20] gpio/rockchip: add of_node for gpiochip Date: Tue, 20 Sep 2022 18:30:59 +0800 Message-Id: <20220920103108.23074-12-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaTh9KVk4eQkxKS01CQ00fSlUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITkhVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NAw6Eio6FT0sCBwhPQpLLx9D SS0KCjNVSlVKTU1ITU1CQ0xDQ0lLVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlLTUw3Bg++ X-HM-Tid: 0a835a73be182eb1kusn0a3b8280b96 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033129_597402_FB88B780 X-CRM114-Status: UNSURE ( 7.42 ) 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 The Rockchip GPIO driver will probe before pinctrl and has no parent dt node, lack of the of_node will cause the driver probe failure. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index b294ef009daf..e36cdbd4bbef 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -588,6 +588,10 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) if (!gc->label) return -ENOMEM; +#ifdef CONFIG_OF_GPIO + gc->of_node = of_node_get(bank->dev->of_node); +#endif + ret = gpiochip_add_data(gc, bank); if (ret) { dev_err(bank->dev, "failed to add gpiochip %s, %d\n", From patchwork Tue Sep 20 10:31:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981869 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 CE436ECAAD8 for ; Tue, 20 Sep 2022 10:31:56 +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=ZqCjPIWQwfAIq+yWspXQiUm4mQL3Ism2nLn9J8mUWpQ=; b=mluytUBvliMzX0 z3cu/EaB1UgqXCvr6w3MxzyWD/UwrG4fBd5/R3oNgmVLSDVvIDzHZb1aErcczPyqPhC/OaNC7tOOQ WPH3/AQeeWm5rXctvNy7U6KZ+hfwUqzSatmWr1vwFMAvs3tt5MM3ifJ5XFDZ1FtVdPlcKLNTdax3M 4CiJC8y3AVZi6R1YzOKHdy7lY8Eow88kkmH7P6isyav2kmjUaP5Pw1RiuYVHcq6ff5AXXzlK4vcKU s/jTCO1Tl3Vdps1SX2ZhuShEqOn3SvCja9PXDJHj0wcPlqUrlpnlhS8tqcdznPT0Oi0W/MzgVfARW SAmADv4LcOr/RsHR9/AA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXT-002yYi-Ej; Tue, 20 Sep 2022 10:31:39 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXJ-002yNI-CN for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:31 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id D6990280AE2; Tue, 20 Sep 2022 18:31:18 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 12/20] gpio/rockchip: add return check for clock rate set Date: Tue, 20 Sep 2022 18:31:00 +0800 Message-Id: <20220920103108.23074-13-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDSElNVh5DGENIHh8fTUNJSlUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Kyo6PDo4OT0dURwfFwkTLy8B PwMwFBlVSlVKTU1ITU1CQ0xCTk5IVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlLTU03Bg++ X-HM-Tid: 0a835a73c1602eb1kusnd6990280ae2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033129_619109_1B2E0ED8 X-CRM114-Status: UNSURE ( 8.54 ) 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 Check if the clock rate set for the apb clock is successful or not. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index e36cdbd4bbef..511e93a6a429 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -199,6 +199,9 @@ static int rockchip_gpio_set_debounce(struct gpio_chip *gc, if (bank->gpio_type == GPIO_TYPE_V2 && !IS_ERR(bank->db_clk)) { div_debounce_support = true; freq = clk_get_rate(bank->db_clk); + if (!freq) + return -EINVAL; + max_debounce = (GENMASK(23, 0) + 1) * 2 * 1000000 / freq; if (debounce > max_debounce) return -EINVAL; From patchwork Tue Sep 20 10:31:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981874 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 66203ECAAD8 for ; Tue, 20 Sep 2022 10:32:16 +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=K7v61ALUKeebxl6RotDCkdq/9SM/U1eApETSbhqby3k=; b=i9cpSbRF5AMTca QrcrqoPlgS6DlGHANdsgku11L+QrY128esPfwM/jB8G3Znk+ZvMp4vtT3S2Y0F/h8xeKygkiMDULf VoYl9BhIi/psvTYzpIR+nQdeOokFHenCyfpJft8AR8DLlYs67LYO9XsAwDphPKbrOuCMBXa7cs4wD fyZ4KB+qeS4lB6kn828ZkbYFz5Xfynt5pjcdolnjahTfe052pNbiyu0M4oZXkA0w8kacDLuezeovT EVSBm3cSwM7oNCdjNPIJLPj3b7JQc/S38XbjT2ioD663RMM24T9B90xmZTbipzQofMlnSDFphYtqW eclvFZYZ0JEkAjF+O2UA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXl-002ysM-OZ; Tue, 20 Sep 2022 10:31:57 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXJ-002yNH-BC for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:32 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 94EDC280BBE; Tue, 20 Sep 2022 18:31:19 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 13/20] gpio/rockchip: disable and put clocks when remove Date: Tue, 20 Sep 2022 18:31:01 +0800 Message-Id: <20220920103108.23074-14-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZTxhMVh5OTktKT00aGU9KTFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktPSEhVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6My46Ghw4Vj0fDBwMFwoMLx8d IR4KCTpVSlVKTU1ITU1CQ0NLTk1MVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlLSUI3Bg++ X-HM-Tid: 0a835a73c4362eb1kusn94edc280bbe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033129_615577_0ECAD231 X-CRM114-Status: UNSURE ( 7.78 ) 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 Match to the probe, do disable and put the clocks when module to remove. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index 511e93a6a429..1a800f972594 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -757,7 +757,10 @@ static int rockchip_gpio_remove(struct platform_device *pdev) { struct rockchip_pin_bank *bank = platform_get_drvdata(pdev); + clk_put(bank->clk); + clk_put(bank->db_clk); clk_disable_unprepare(bank->clk); + clk_disable_unprepare(bank->db_clk); gpiochip_remove(&bank->gpio_chip); return 0; From patchwork Tue Sep 20 10:31:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981875 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 06282C6FA8E for ; Tue, 20 Sep 2022 10:32:17 +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=Wnbk64164H0y6P1JQlgK83rSq5PIYQB1SBP/wpWhOkw=; b=z3A0J37wuN3smM 3zab6SckF4NlpueMDdokbcPoE/3DIphEF1MyJf6zf1/uNRQxanE1HR4XQEStd7G6yp+hriUp+oXKd 0dFgew5wQV2xfa7khm4vMM1amBfOvao3koE0i1Rhwooz1zhfyFeNVTFSdSLnxtL4rqyEKWWA+SrcW uL08aaXv1D1Ec+7YPcHviBGMmHBfGczRyUoNZl8PHUzvmHd/dMPts54h5MTb/EaPQZRgL7Jg9VICF eAHBGAwHiwd44GQRSYJrXPVgV9ShNNVZfgjAMfygjaMc3/K1xY2ZU8beO1shLAufyvSiJ0GzoCcb8 YJS/nFBX2c7TuKYrej0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXs-002z3B-93; Tue, 20 Sep 2022 10:32:04 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXJ-002yNG-BK for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:33 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 9870B280BA9; Tue, 20 Sep 2022 18:31:20 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 14/20] gpio/rockchip: switch to use irq_domain_create_linear Date: Tue, 20 Sep 2022 18:31:02 +0800 Message-Id: <20220920103108.23074-15-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDTBpCVh9NSxofSB9ISU5PQlUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NC46DDo4SD0eDBxNPQpPLy0* CjlPCxxVSlVKTU1ITU1CQ0NKSUNKVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlMTEM3Bg++ X-HM-Tid: 0a835a73c82c2eb1kusn9870b280ba9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033129_702310_DFAF1E7C X-CRM114-Status: UNSURE ( 8.97 ) 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 Switch to use irq_domain_create_linear to create the irq domain for the Rockchip GPIO bank, whose argument is fwnode istead of of_node. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index 1a800f972594..4fcd75d710c1 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -28,6 +28,8 @@ #define GPIO_TYPE_V2 (0x01000C2B) /* GPIO Version ID 0x01000C2B */ #define GPIO_TYPE_V2_1 (0x0101157C) /* GPIO Version ID 0x0101157C */ +#define GPIO_MAX_PINS (32) + static const struct rockchip_gpio_regs gpio_regs_v1 = { .port_dr = 0x00, .port_ddr = 0x04, @@ -520,14 +522,15 @@ static int rockchip_interrupts_register(struct rockchip_pin_bank *bank) struct irq_chip_generic *gc; int ret; - bank->domain = irq_domain_add_linear(bank->of_node, 32, - &irq_generic_chip_ops, NULL); + bank->domain = irq_domain_create_linear(dev_fwnode(bank->dev), + GPIO_MAX_PINS, + &irq_generic_chip_ops, NULL); if (!bank->domain) { dev_warn(bank->dev, "could not init irq domain\n"); return -EINVAL; } - ret = irq_alloc_domain_generic_chips(bank->domain, 32, 1, + ret = irq_alloc_domain_generic_chips(bank->domain, GPIO_MAX_PINS, 1, "rockchip_gpio_irq", handle_level_irq, clr, 0, 0); From patchwork Tue Sep 20 10:31:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981873 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 7E5EEECAAD8 for ; Tue, 20 Sep 2022 10:32:12 +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=uXnJslaHgQxRaDlZZmQAmCq/nDoB5/VhmRoUSLjCSMo=; b=dNbrLwcyYDlZ+Z ZCD7EVjyBgzvSx3PmzASiEldRkrcR9JMxdsOQ9bbPYw6u8yFJuuD+2fzP/6GwDVpfmmxeXqp88go1 fIxxLr9mk9ibBkILwIliP+ffoOH/zfUyIW1OJMTqwdnOjdX+Jy8zx3Lhy8z0C7u8sgxFudNKGdkGN BqZP6AMN7P8KrukSzQ+Y+KDcLpsLZ93PVvI+JY9Y1/Wqfgjc2w8XOPh8T6seBNj2NY8YhU1GQjQNW S9mHBj8WiNTErBJB5Y5/bvXJ9yM0dqLHiR7ItcPGLqzjOiPLsf+dlxvg1wGba1cYCcQuHB5/80vHH tnZe3Z/OxDE0WVNeE2Yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXq-002yyg-6j; Tue, 20 Sep 2022 10:32:02 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXK-002yP7-M9 for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:32 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 52F51280BC7; Tue, 20 Sep 2022 18:31:21 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 15/20] gpio/rockchip: disable and put clocks when gpiolib register failed Date: Tue, 20 Sep 2022 18:31:03 +0800 Message-Id: <20220920103108.23074-16-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZTx9IVkodH01PSR9OQ0pPSFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PCo6Fxw5PT0oKhwJLRQDLyMR DQowCQhVSlVKTU1ITU1CQ0NJS0hMVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlITkI3Bg++ X-HM-Tid: 0a835a73cafe2eb1kusn52f51280bc7 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033130_893602_AC78AF13 X-CRM114-Status: UNSURE ( 8.37 ) 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 When gpiolib register failed, the clocks should be disabled and put. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index 4fcd75d710c1..09ed5c880dde 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -746,14 +746,21 @@ static int rockchip_gpio_probe(struct platform_device *pdev) ret = rockchip_gpiolib_register(bank); if (ret) { - clk_disable_unprepare(bank->clk); - return ret; + dev_err(bank->dev, "Failed to register gpio %d\n", ret); + goto err_put_clk; } platform_set_drvdata(pdev, bank); dev_info(dev, "probed %pOF\n", np); return 0; +err_put_clk: + clk_put(bank->clk); + clk_put(bank->db_clk); + clk_disable_unprepare(bank->clk); + clk_disable_unprepare(bank->db_clk); + + return ret; } static int rockchip_gpio_remove(struct platform_device *pdev) From patchwork Tue Sep 20 10:31:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981877 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 0DFEDC54EE9 for ; Tue, 20 Sep 2022 10:32:19 +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=jUGmyrr7p58Yh8I3Bqmx8zrVg+0L1Z22F7DUgd2DMyM=; b=FybZgsyNb10lXu RUipzVb0YuJFGBaDg/WqkpZD8NMPpEj4bEsh1D6d2p/zvu0B1nEhQSjT62RpzJRolnc7UHe0DeIAP aBz6MP+ufHSMT1zIPvLUibbdjKffPZ0n8jugOZbhWfMf9KzizlOMg2ajy09PiOmaKSDjci2/ZPy6d nrHoPpeMt3ZQ3Dl1uCMQJK8cCw7C4m+Oc3sZv+96lGp4BNVWn7GM+rZ+89eYET8ei5tqDJ/gwbKiF K+9ZBJW2Z9T3QDUFsFmJAVAcD2EGJTAWc2YkapyPqF2ctWEh2Z7jskTPwHTCyCcir2q+Kjo4hytDh zBmge5zW/ji1vncSc0DA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXr-002z1v-C8; Tue, 20 Sep 2022 10:32:03 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXK-002yP8-L5 for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:33 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 16680280BCB; Tue, 20 Sep 2022 18:31:22 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 16/20] gpio/rockchip: try to get gpio id from uid when ACPI enabled Date: Tue, 20 Sep 2022 18:31:04 +0800 Message-Id: <20220920103108.23074-17-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCSxpDVktDSUweTx5IGBhDSVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MzY6Lyo6ST0qPhwyFxRDLy4N ThcKChlVSlVKTU1ITU1CQ0NJTElNVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhNQkw3Bg++ X-HM-Tid: 0a835a73cdea2eb1kusn16680280bcb X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033130_915529_270B6093 X-CRM114-Status: GOOD ( 13.81 ) 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 When the ACPI is enabled, the GPIO index should be get from the uid, otherwise get it from the dt alias or a static count to the legency dt files. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 40 ++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index 09ed5c880dde..11586d93549b 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -6,6 +6,7 @@ * Copyright (c) 2021 Rockchip Electronics Co. Ltd. */ +#include #include #include #include @@ -710,6 +711,29 @@ rockchip_gpio_find_bank(struct pinctrl_dev *pctldev, int id) return found ? bank : NULL; } +static int rockchip_gpio_get_bank_id(struct device *dev) +{ + struct fwnode_handle *fwnode = dev_fwnode(dev); + int bank_id = -EINVAL; + u64 uid; + int ret; + static int gpio; + + if (is_acpi_node(fwnode)) { + ret = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid); + if (ret < 0) + return ret; + + bank_id = uid; + } else { + bank_id = of_alias_get_id(to_of_node(fwnode), "gpio"); + if (bank_id < 0) + bank_id = gpio++; + } + + return bank_id; +} + static int rockchip_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -717,8 +741,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev) struct device_node *pctlnp = of_get_parent(np); struct pinctrl_dev *pctldev = NULL; struct rockchip_pin_bank *bank = NULL; - static int gpio; - int id, ret; + int ret; if (!np || !pctlnp) return -ENODEV; @@ -727,13 +750,11 @@ static int rockchip_gpio_probe(struct platform_device *pdev) if (!pctldev) return -EPROBE_DEFER; - id = of_alias_get_id(np, "gpio"); - if (id < 0) - id = gpio++; - - bank = rockchip_gpio_find_bank(pctldev, id); - if (!bank) - return -EINVAL; + ret = rockchip_gpio_get_bank_id(dev); + if (ret >= 0) + bank->bank_num = ret; + else + goto err; bank->dev = dev; bank->of_node = np; @@ -759,6 +780,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev) clk_put(bank->db_clk); clk_disable_unprepare(bank->clk); clk_disable_unprepare(bank->db_clk); +err: return ret; } From patchwork Tue Sep 20 10:31:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981878 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 4CF47ECAAD8 for ; Tue, 20 Sep 2022 10:32:19 +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=ZBufMK4CNBupqP6gE7LYUk29Ka3y6NH/JLxtqBzKoWM=; b=FVJ+MzXUr1pzjl 2B5kSLnSdlHlpwjHu70hdsnVqfch5AnRQOvsgvz+rf7WuN02/yFHw0IT2fY/NMnlbGfcbMIqsXVqO 0s4Ig6jdZ1sfNIaNgKAsKK0aCscoeJYGopZes4Cjab3Ub8o5ZlxfbMOkhgpCRR5/HRq5hf1GgqskA 2tOBlcrBeOd2W7pt+t766ZfhgWwnE0Mzj3/Vp5k8EELOQgHp/XFZamqnS2k438lM7aZblL7pRFlSO cLHxC2ZTzsgWgcfIR0pKLaeZGbsddwv1HBl9iMh/BVc+nDmzbh62uFHCqibpdujtfHnx012yz2+kG ddFEOA7A51XfkJh0RNTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXu-002z71-Im; Tue, 20 Sep 2022 10:32:06 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXK-002yPD-Pb for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:34 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id BFB82280BD1; Tue, 20 Sep 2022 18:31:22 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 17/20] gpio/rockchip: print device with fwnode name when probe successful Date: Tue, 20 Sep 2022 18:31:05 +0800 Message-Id: <20220920103108.23074-18-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCHkpJVkxJS01CTUhJSBofH1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OCI6Mjo6TD0oURwZVhRJLxcM OjEaCwFVSlVKTU1ITU1CQ0NITklLVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUpCQ083Bg++ X-HM-Tid: 0a835a73d0be2eb1kusnbfb82280bd1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033131_193599_CAD9D266 X-CRM114-Status: UNSURE ( 9.06 ) 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 Print the device probe message with the fwnode instead of of_node. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index 11586d93549b..d08435619f12 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -772,7 +772,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, bank); - dev_info(dev, "probed %pOF\n", np); + dev_info(dev, "probed %pfw\n", dev_fwnode(dev)); return 0; err_put_clk: From patchwork Tue Sep 20 10:31:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981879 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 1A4A0C6FA92 for ; Tue, 20 Sep 2022 10:32:20 +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=mj+sveVojh5n9zfP53YyQQmOwad5gXSmKnTP3M9MuLE=; b=y9NL308QHBSPY1 mKg8AfRv/bRE5cSdATr2hfYzI49VNGmnbPBoZS7YXea2yia2WCrlg++cdN8HuqDXFW5X9r7DV50Ea 6viu1kCcuCBkF6bi6oY7Qq8JFY1saTTYur4E1aLt3aHmiVU1zqP1S57qZu4/AnoPjro7JJy5W8i5n CvLJjZSHZn94Wdcv9hZOr6yB9D/2pZoqAqPk38Q1ZOd9Ue7nZz73GNahknaQ9QJIU3mdjUrz66YZV Y3g7GAkdlvulbdlDiN3OwzRqt+xaq+5CEyqq4glavdQmA4B2wEIPY9dglFUJcNARU2HvBXOuavbMJ OlN5RpXHMI0zT2y97mKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXt-002z5S-LU; Tue, 20 Sep 2022 10:32:05 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXK-002yPB-Na for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:33 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 8D360280BD5; Tue, 20 Sep 2022 18:31:23 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 18/20] gpio/rockchip: make use of device property Date: Tue, 20 Sep 2022 18:31:06 +0800 Message-Id: <20220920103108.23074-19-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZSU9NVkgfShlPQxhLSEpMT1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MVE6Eio6DD0vOhwCLRRJLw9N MU8aCQlVSlVKTU1ITU1CQ0NPSUpDVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhISEI3Bg++ X-HM-Tid: 0a835a73d3b82eb1kusn8d360280bd5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033130_977575_F0289D98 X-CRM114-Status: GOOD ( 10.77 ) 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 iomem resource by devm_platform_ioremap_resource and get the irq by platform_get_irq. Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index d08435619f12..a94ebd95d285 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -17,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -651,22 +652,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; - bank->clk = of_clk_get(bank->of_node, 0); if (IS_ERR(bank->clk)) return PTR_ERR(bank->clk); @@ -765,6 +752,14 @@ static int rockchip_gpio_probe(struct platform_device *pdev) if (ret) return ret; + bank->reg_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(bank->reg_base)) + return PTR_ERR(bank->reg_base); + + bank->irq = platform_get_irq(pdev, 0); + if (bank->irq < 0) + return bank->irq; + ret = rockchip_gpiolib_register(bank); if (ret) { dev_err(bank->dev, "Failed to register gpio %d\n", ret); From patchwork Tue Sep 20 10:31:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981881 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 6BD88C54EE9 for ; Tue, 20 Sep 2022 10:32:22 +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=xYWjhTVNw70b+3PlxH8ILwsQeSh1VXEmsGsktzasuqI=; b=Q19g2kk3/Q2evS 71ZHXVSLcNAP/gzAE3T1zA13DPF6du86RNTGWUMXZR7xZEr3R2Cd63r8Jteum+Z+yWv6eOSfWcPpC GJ6y5PqcBms0FmHc1UoSm4zkIR2NJbKFXI6fDHlTV0uBY0Ds2pi4PSsEMWcd7l4r2ISXO5d6vG3/B X5qGygms0pbwo4pN7qxxqeU0ELo+Nf2SxTZvGax2XQFu8w/hcoqmngvD3/2QeRlPtUON6yNVSKaYL PHbwApHcX8z82IjYPMESNE7F7ZWvScCKdZsceiAWW3AQMMVf6tZ3g6LTR5OQe6cr1yq1mlcFANf+Q mJqU3G1SMRfHuR8F24rA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXw-002zAH-Ei; Tue, 20 Sep 2022 10:32:08 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXM-002yRG-C5 for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:36 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 42E5D280BD8; Tue, 20 Sep 2022 18:31:24 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 19/20] gpio/rockchip: make GPIO module work well under ACPI enabled Date: Tue, 20 Sep 2022 18:31:07 +0800 Message-Id: <20220920103108.23074-20-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaSUpJVh5DSUpOGkgeTEtDSFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NzY6Fxw4TD0fFBwpVgodLxIy GkgaCRpVSlVKTU1ITU1CQ0NPQk1DVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUpLT0lNNwY+ X-HM-Tid: 0a835a73d67c2eb1kusn42e5d280bd8 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033132_743497_7D39C744 X-CRM114-Status: GOOD ( 28.83 ) 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 The GPIO driver for Rockchip GPIO controller is seperated from rockchip pinctrl driver, at the first version, it keeps things original to make the patch easy to be reviewed, such as the GPIO driver must work with the pinctrl dt node to be its parent node. This patch wants to fix the driver to support ACPI since GPIO controller should work well during ACPI is enabled. This patch do changes including: - only get clocks when is_of_node since ACPI case not need. - use fwnode instead of of_node - use private device structure mostly copy from pinctrl - drop pinctrl related codes, pinctrl self should to find the gpiochip Signed-off-by: Jianqun Xu --- drivers/gpio/gpio-rockchip.c | 205 ++++++++++++++++++++--------------- 1 file changed, 120 insertions(+), 85 deletions(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index a94ebd95d285..01b214b84c71 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -18,20 +18,88 @@ #include #include #include -#include -#include -#include #include -#include "../pinctrl/core.h" -#include "../pinctrl/pinctrl-rockchip.h" - #define GPIO_TYPE_V1 (0) /* GPIO Version ID reserved */ #define GPIO_TYPE_V2 (0x01000C2B) /* GPIO Version ID 0x01000C2B */ #define GPIO_TYPE_V2_1 (0x0101157C) /* GPIO Version ID 0x0101157C */ #define GPIO_MAX_PINS (32) +/** + * struct rockchip_gpio_regs + * @port_dr: data register + * @port_ddr: data direction register + * @int_en: interrupt enable + * @int_mask: interrupt mask + * @int_type: interrupt trigger type, such as high, low, edge trigger type. + * @int_polarity: interrupt polarity enable register + * @int_bothedge: interrupt bothedge enable register + * @int_status: interrupt status register + * @int_rawstatus: int_status = int_rawstatus & int_mask + * @debounce: enable debounce for interrupt signal + * @dbclk_div_en: enable divider for debounce clock + * @dbclk_div_con: setting for divider of debounce clock + * @port_eoi: end of interrupt of the port + * @ext_port: port data from external + * @version_id: controller version register + */ +struct rockchip_gpio_regs { + u32 port_dr; + u32 port_ddr; + u32 int_en; + u32 int_mask; + u32 int_type; + u32 int_polarity; + u32 int_bothedge; + u32 int_status; + u32 int_rawstatus; + u32 debounce; + u32 dbclk_div_en; + u32 dbclk_div_con; + u32 port_eoi; + u32 ext_port; + u32 version_id; +}; + +/** + * struct rockchip_pin_bank + * @dev: the pinctrl device bind to the bank + * @reg_base: register base of the gpio bank + * @clk: clock of the gpio bank + * @db_clk: clock of the gpio debounce + * @irq: interrupt of the gpio bank + * @saved_masks: Saved content of GPIO_INTEN at suspend time. + * @pin_base: first pin number + * @nr_pins: number of pins in this bank + * @name: name of the bank + * @bank_num: number of the bank, to account for holes + * @domain: irqdomain of the gpio bank + * @gpio_chip: gpiolib chip + * @grange: gpio range + * @slock: spinlock for the gpio bank + * @toggle_edge_mode: bit mask to toggle (falling/rising) edge mode + */ +struct rockchip_pin_bank { + struct gpio_chip gpio_chip; + struct device *dev; + void __iomem *reg_base; + struct clk *clk; + struct clk *db_clk; + int irq; + u32 saved_masks; + u32 pin_base; + u8 nr_pins; + char *name; + u8 bank_num; + struct device_node *of_node; + struct irq_domain *domain; + raw_spinlock_t slock; + const struct rockchip_gpio_regs *gpio_regs; + u32 gpio_type; + u32 toggle_edge_mode; +}; + static const struct rockchip_gpio_regs gpio_regs_v1 = { .port_dr = 0x00, .port_ddr = 0x04, @@ -607,35 +675,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); @@ -650,52 +689,53 @@ 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_set_regs(struct rockchip_pin_bank *bank) { - int id = 0; + struct device *dev = bank->dev; + struct fwnode_handle *fwnode = dev_fwnode(dev); + int version_id; + int ret; - bank->clk = of_clk_get(bank->of_node, 0); - if (IS_ERR(bank->clk)) - return PTR_ERR(bank->clk); + if (is_of_node(fwnode)) { + bank->clk = of_clk_get(to_of_node(fwnode), 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); + ret = clk_prepare_enable(bank->clk); + if (ret < 0) + goto put_clk; + } - /* If not gpio v2, that is default to v1. */ - if (id == GPIO_TYPE_V2 || id == GPIO_TYPE_V2_1) { + version_id = readl(bank->reg_base + gpio_regs_v2.version_id); + if (version_id == GPIO_TYPE_V2 || version_id == GPIO_TYPE_V2_1) { bank->gpio_regs = &gpio_regs_v2; bank->gpio_type = GPIO_TYPE_V2; - bank->db_clk = of_clk_get(bank->of_node, 1); - if (IS_ERR(bank->db_clk)) { - dev_err(bank->dev, "cannot find debounce clk\n"); - clk_disable_unprepare(bank->clk); - return -EINVAL; - } } else { bank->gpio_regs = &gpio_regs_v1; bank->gpio_type = GPIO_TYPE_V1; } - return 0; -} - -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; + if (bank->gpio_type == GPIO_TYPE_V2 && is_of_node(fwnode)) { + bank->db_clk = of_clk_get(to_of_node(fwnode), 1); + if (IS_ERR(bank->db_clk)) { + ret = PTR_ERR(bank->db_clk); + goto unprepare_clk; + } - 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; + ret = clk_prepare_enable(bank->db_clk); + if (ret < 0) { + clk_put(bank->db_clk); + goto unprepare_clk; } } - return found ? bank : NULL; + return 0; +unprepare_clk: + clk_disable_unprepare(bank->clk); +put_clk: + clk_put(bank->clk); + + return ret; } static int rockchip_gpio_get_bank_id(struct device *dev) @@ -724,18 +764,20 @@ static int rockchip_gpio_get_bank_id(struct device *dev) 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_bank *bank; int ret; - if (!np || !pctlnp) - return -ENODEV; + bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); + if (!bank) + return -ENOMEM; + + bank->reg_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(bank->reg_base)) + return PTR_ERR(bank->reg_base); - pctldev = of_pinctrl_get(pctlnp); - if (!pctldev) - return -EPROBE_DEFER; + bank->irq = platform_get_irq(pdev, 0); + if (bank->irq < 0) + return bank->irq; ret = rockchip_gpio_get_bank_id(dev); if (ret >= 0) @@ -744,22 +786,15 @@ static int rockchip_gpio_probe(struct platform_device *pdev) goto err; bank->dev = dev; - bank->of_node = np; + bank->pin_base = GPIO_MAX_PINS * bank->bank_num; + bank->nr_pins = GPIO_MAX_PINS; raw_spin_lock_init(&bank->slock); - ret = rockchip_get_bank_data(bank); + ret = rockchip_gpio_set_regs(bank); if (ret) return ret; - bank->reg_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(bank->reg_base)) - return PTR_ERR(bank->reg_base); - - bank->irq = platform_get_irq(pdev, 0); - if (bank->irq < 0) - return bank->irq; - ret = rockchip_gpiolib_register(bank); if (ret) { dev_err(bank->dev, "Failed to register gpio %d\n", ret); From patchwork Tue Sep 20 10:31:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12981880 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 B888BECAAD8 for ; Tue, 20 Sep 2022 10:32:22 +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=lvgAebjkLUKxitN71/RyqCNLp7uDwZyUlF86AaRBPio=; b=aVoYzcuGcQmXaT JB83PBRkFr9+CpPnZaMCpq2LRMLR9ZO2kWoATd7Y4z4CFq3ND0PF/sPWDStDlMC3S+Zmb3gM3HbEz 7qQ3UfX7sSWeG3dKUshsxDgflzO90lAvTGBG9W1MbAJk1nz7VK4SDZT3354MkQNvvkmzIixCLnFzx mEWUqUxR4TVQH15iFGehUTbpyGN/pWiuzejQpl64J88TCJ/uaz+A+U/+kcbMij8S5LBpXjUb3RAz+ L+0LnsdfVG3fYpNejlKtPS9PB5GBjbRbQzBpYXlEzcdG+cf4YiwAszBeGZvmWzIxCer2tU0GipShk LxGrFqPvkz+z0zE4P65w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXv-002z8d-K2; Tue, 20 Sep 2022 10:32:07 +0000 Received: from mail-m11875.qiye.163.com ([115.236.118.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaaXM-002yRH-CF for linux-rockchip@lists.infradead.org; Tue, 20 Sep 2022 10:31:35 +0000 Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id 05D0A280BDB; Tue, 20 Sep 2022 18:31:24 +0800 (CST) From: Jianqun Xu To: linus.walleij@linaro.org, heiko@sntech.de, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: robert.moore@intel.com, robh@kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, lenb@kernel.org, rafael@kernel.org, Jianqun Xu Subject: [PATCH 20/20] pinctrl/rockchip: find existed gpiochip by gpio label Date: Tue, 20 Sep 2022 18:31:08 +0800 Message-Id: <20220920103108.23074-21-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220920103108.23074-1-jay.xu@rock-chips.com> References: <20220920103108.23074-1-jay.xu@rock-chips.com> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDSRhMVkMeTBgeGh1OGU4YSVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Ky46Ohw5HD0tSRwiPQoPLxRJ DxQwCRlVSlVKTU1ITU1CQ0NOQ0hOVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQU9PSUo3Bg++ X-HM-Tid: 0a835a73d9e42eb1kusn05d0a280bdb X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220920_033132_612396_00539568 X-CRM114-Status: GOOD ( 16.05 ) 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 pinctrl device acts as parent for the GPIO devices for Rockchip platform, the pinctrl driver creates the gpiochips and pass to the GPIO driver. This patch makes the member of pinctrl structure from gpiochip to *gpiochip, switch to find existed gpiochips instead of creating them, that requires the GPIO driver to create them and earlier than the pinctrl driver. Signed-off-by: Jianqun Xu --- drivers/pinctrl/pinctrl-rockchip.c | 24 +++++++++++++++++++++--- drivers/pinctrl/pinctrl-rockchip.h | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 97af52bb5481..05e688cd8536 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -2725,7 +2725,7 @@ static int rockchip_pinconf_set(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; u32 arg; int i; @@ -2828,7 +2828,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; @@ -3293,7 +3293,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 (is_of_node(fwnode)) { ret = of_platform_populate(np, NULL, NULL, dev); @@ -3357,6 +3357,24 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev) if (ret) return ret; + for (i = 0; i < ctrl->nr_banks; i++) { + struct gpio_chip *gc; + struct rockchip_pin_bank *bank = &ctrl->pin_banks[i]; + + gc = gpiochip_find_by_name((void *)ctrl->pin_banks[i].name); + if (!gc) { + dev_err(dev, "fail to find gpiochip\n"); + return ret; + } + + 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 %pfw\n", fwnode); diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h index 3531633c0397..8b44e02bce97 100644 --- a/drivers/pinctrl/pinctrl-rockchip.h +++ b/drivers/pinctrl/pinctrl-rockchip.h @@ -330,7 +330,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;