From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 623E2C54EE9 for ; Tue, 20 Sep 2022 10:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbiITKb0 (ORCPT ); Tue, 20 Sep 2022 06:31:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230122AbiITKbO (ORCPT ); Tue, 20 Sep 2022 06:31:14 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C09176F264 for ; Tue, 20 Sep 2022 03:31:12 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCQ0hLVk5OQ00eSkNLSx4dH1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Mhw6MCo6Qj0dURw3FxRCLykf SQEwFExVSlVKTU1ITU1CQ0xKTktNVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhCS083Bg++ X-HM-Tid: 0a835a73a2102eb1kusnd42c4280b58 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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); =20 +/** + * 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 =3D 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 namespac= e. * @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) } =20 bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, co= nst char *uid2); +int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer); =20 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; } =20 +static inline int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *i= nteger) +{ + return -ENODEV; +} + static inline struct acpi_device * acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv) { --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF577ECAAD8 for ; Tue, 20 Sep 2022 10:31:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230500AbiITKbX (ORCPT ); Tue, 20 Sep 2022 06:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbiITKbO (ORCPT ); Tue, 20 Sep 2022 06:31:14 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71CDB6F267 for ; Tue, 20 Sep 2022 03:31:13 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDSkpOVh5PQ0xPTUxJSUlOSFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktPSElVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NTY6Djo4Fz0qTRw2VgsuLyxI TDJPFChVSlVKTU1ITU1CQ0xJSUtOVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlOSks3Bg++ X-HM-Tid: 0a835a73a4c42eb1kusn88f27280b5e Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-r= ockchip.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_de= vice *pdev) if (!dev->of_node) return dev_err_probe(dev, -ENODEV, "device tree node not found\n"); =20 + ret =3D of_platform_populate(np, NULL, NULL, dev); + if (ret) + return dev_err_probe(dev, ret, "failed to register gpio device\n"); + info =3D devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; @@ -3360,10 +3364,6 @@ static int rockchip_pinctrl_probe(struct platform_de= vice *pdev) =20 platform_set_drvdata(pdev, info); =20 - ret =3D of_platform_populate(np, NULL, NULL, &pdev->dev); - if (ret) - return dev_err_probe(dev, ret, "failed to register gpio device\n"); - return 0; } =20 --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AC62ECAAD8 for ; Tue, 20 Sep 2022 10:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231144AbiITKbb (ORCPT ); Tue, 20 Sep 2022 06:31:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230337AbiITKbP (ORCPT ); Tue, 20 Sep 2022 06:31:15 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26A026F275 for ; Tue, 20 Sep 2022 03:31:14 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZTh5IVkpIGU9KT0pITkxLH1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6ORg6ARw6ED0YURxCLQpNLyhD PhVPFD5VSlVKTU1ITU1CQ0xJQ0JNVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhJT083Bg++ X-HM-Tid: 0a835a73a7882eb1kusn3f483280ab7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-r= ockchip.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 =3D &pdev->dev; - struct device_node *np =3D dev->of_node; - struct device_node *child; + struct fwnode_handle *fwnode =3D dev_fwnode(dev); + struct device_node *np =3D to_of_node(fwnode), *child; int ret; int i; =20 @@ -3129,7 +3129,8 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get= _soc_data( struct platform_device *pdev) { struct device *dev =3D &pdev->dev; - struct device_node *node =3D dev->of_node; + struct fwnode_handle *fwnode =3D dev_fwnode(dev); + struct device_node *node =3D 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_op= s, rockchip_pinctrl_suspend, =20 static int rockchip_pinctrl_probe(struct platform_device *pdev) { - struct rockchip_pinctrl *info; struct device *dev =3D &pdev->dev; - struct device_node *np =3D dev->of_node, *node; + struct fwnode_handle *fwnode =3D dev_fwnode(dev); + struct device_node *np =3D to_of_node(fwnode), *node; + struct rockchip_pinctrl *info; struct rockchip_pin_ctrl *ctrl; struct resource *res; void __iomem *base; int ret; =20 - if (!dev->of_node) + if (!is_of_node(fwnode)) return dev_err_probe(dev, -ENODEV, "device tree node not found\n"); =20 ret =3D of_platform_populate(np, NULL, NULL, dev); --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FA33C54EE9 for ; Tue, 20 Sep 2022 10:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231135AbiITKbf (ORCPT ); Tue, 20 Sep 2022 06:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbiITKbQ (ORCPT ); Tue, 20 Sep 2022 06:31:16 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F9B4DF0C for ; Tue, 20 Sep 2022 03:31:14 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaHksZVk9MT0JMTU1NHkpOSFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PlE6Njo4ND0ZEBwxVgoVLxoO MBUwCTRVSlVKTU1ITU1CQ0xITUpOVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlPTUo3Bg++ X-HM-Tid: 0a835a73aa352eb1kusne8a98280b70 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-r= ockchip.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_g= et_soc_data( struct platform_device *pdev) { struct device *dev =3D &pdev->dev; - struct fwnode_handle *fwnode =3D dev_fwnode(dev); - struct device_node *node =3D 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; =20 - match =3D of_match_node(rockchip_pinctrl_dt_match, node); - ctrl =3D (struct rockchip_pin_ctrl *)match->data; - + ctrl =3D (struct rockchip_pin_ctrl *)device_get_match_data(dev); grf_offs =3D ctrl->grf_mux_offset; pmu_offs =3D ctrl->pmu_mux_offset; drv_pmu_offs =3D ctrl->pmu_drv_offset; --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35306C6FA8B for ; Tue, 20 Sep 2022 10:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230243AbiITKbp (ORCPT ); Tue, 20 Sep 2022 06:31:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230461AbiITKbT (ORCPT ); Tue, 20 Sep 2022 06:31:19 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D6C34AD59 for ; Tue, 20 Sep 2022 03:31:15 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDHk4ZVkxKQh4aGRlOS0lIT1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PQg6SSo*ST0hDBxPLQsSLyEs Kz0wFElVSlVKTU1ITU1CQ0xPSEpCVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlPSUs3Bg++ X-HM-Tid: 0a835a73ad052eb1kusna4626280b8f Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-r= ockchip.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_d= evice *pdev) void __iomem *base; int ret; =20 - if (!is_of_node(fwnode)) - return dev_err_probe(dev, -ENODEV, "device tree node not found\n"); - - ret =3D 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 =3D of_platform_populate(np, NULL, NULL, dev); + if (ret) + return dev_err_probe(dev, ret, "failed to register gpio device\n"); + } =20 info =3D devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); if (!info) --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FD45ECAAD8 for ; Tue, 20 Sep 2022 10:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230442AbiITKbm (ORCPT ); Tue, 20 Sep 2022 06:31:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbiITKbT (ORCPT ); Tue, 20 Sep 2022 06:31:19 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E35F6E2C2 for ; Tue, 20 Sep 2022 03:31:16 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCGhhKVkhNGkhJHkgeSENDSVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OQg6OCo4Sj0YKhwtLQowLxpP LjBPCw9VSlVKTU1ITU1CQ0xOS0tLVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlLSEs3Bg++ X-HM-Tid: 0a835a73afbf2eb1kusn5b7da280b9c Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-r= ockchip.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; =20 + if (!is_of_node(fwnode)) + return 0; + rockchip_pinctrl_child_count(info, np); =20 dev_dbg(dev, "nfunctions =3D %d\n", info->nfunctions); --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21886ECAAD8 for ; Tue, 20 Sep 2022 10:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231180AbiITKbi (ORCPT ); Tue, 20 Sep 2022 06:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230238AbiITKbS (ORCPT ); Tue, 20 Sep 2022 06:31:18 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E1BB4DF0C for ; Tue, 20 Sep 2022 03:31:16 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaTklNVhgdSUJJS0hOQk0fGVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MBg6DAw5Tz0ZIhwiPRQRLyoK GE0aCxpVSlVKTU1ITU1CQ0xOTEtIVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUpCTUI3Bg++ X-HM-Tid: 0a835a73b26c2eb1kusn0d6aa280b9f Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-r= ockchip.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_dev= ice *pdev) return ret; =20 platform_set_drvdata(pdev, info); + dev_info(dev, "probed %pfw\n", fwnode); =20 return 0; } --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78710ECAAD8 for ; Tue, 20 Sep 2022 10:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230252AbiITKbt (ORCPT ); Tue, 20 Sep 2022 06:31:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbiITKbT (ORCPT ); Tue, 20 Sep 2022 06:31:19 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0B386FA36 for ; Tue, 20 Sep 2022 03:31:17 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCGEMeVkIZTR4eSR5NT0lMTVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MAg6Ixw*Kz0pNhwrFxQ8LxgO FwswCipVSlVKTU1ITU1CQ0xNT0pIVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhMSEw3Bg++ X-HM-Tid: 0a835a73b52a2eb1kusnb93fe280ba6 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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); =20 -static int gpiochip_match_name(struct gpio_chip *gc, void *data) -{ - const char *name =3D 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 =20 /* @@ -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 =3D find_chip_by_name(hog->chip_label); + gc =3D 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 *de= v, const char *con_id, return ERR_PTR(-EPROBE_DEFER); } =20 - gc =3D find_chip_by_name(p->key); + gc =3D gpiochip_find_by_name(p->key); =20 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 devi= ce *dev, struct gpio_chip extern struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *gc, void *data)); =20 +static int gpiochip_match_name(struct gpio_chip *gc, void *data) +{ + const char *name =3D 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); --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03A33ECAAD8 for ; Tue, 20 Sep 2022 10:32:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231252AbiITKb7 (ORCPT ); Tue, 20 Sep 2022 06:31:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbiITKbU (ORCPT ); Tue, 20 Sep 2022 06:31:20 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F205B62ABD for ; Tue, 20 Sep 2022 03:31:18 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCGUpJVh4eSU4fS01IHx5MSVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NzI6Ogw5GD0eFBxLPQk6Lx8s FBZPCzFVSlVKTU1ITU1CQ0xMSkNIVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhKTEs3Bg++ X-HM-Tid: 0a835a73b7f12eb1kusn71c22280b29 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D irq_desc_get_handler_data(desc); u32 pend; =20 - dev_dbg(bank->dev, "got irq for bank %s\n", bank->name); + dev_dbg(bank->dev, "got irq\n"); =20 chained_irq_enter(chip, desc); =20 @@ -521,8 +521,7 @@ static int rockchip_interrupts_register(struct rockchip= _pin_bank *bank) bank->domain =3D 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; } =20 @@ -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_p= in_bank *bank) gc =3D &bank->gpio_chip; gc->base =3D bank->pin_base; gc->ngpio =3D bank->nr_pins; - gc->label =3D bank->name; gc->parent =3D bank->dev; + gc->label =3D devm_kasprintf(bank->dev, GFP_KERNEL, "gpio%d", bank->bank_= num); + if (!gc->label) + return -ENOMEM; =20 ret =3D gpiochip_add_data(gc, bank); if (ret) { --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89AC5C54EE9 for ; Tue, 20 Sep 2022 10:31:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230520AbiITKb4 (ORCPT ); Tue, 20 Sep 2022 06:31:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230473AbiITKbV (ORCPT ); Tue, 20 Sep 2022 06:31:21 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C5CC6F264 for ; Tue, 20 Sep 2022 03:31:19 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZT0pIVkIaTxpIH0odSktDGFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PRQ6Lzo5Tj0sLhw2FwkoLxka CA4aCj1VSlVKTU1ITU1CQ0xMQkNCVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUNPTEg3Bg++ X-HM-Tid: 0a835a73baf02eb1kusn3a561280baf Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =20 #include "../pinctrl/core.h" @@ -708,7 +707,6 @@ static int rockchip_gpio_probe(struct platform_device *= pdev) struct device_node *pctlnp =3D of_get_parent(np); struct pinctrl_dev *pctldev =3D NULL; struct rockchip_pin_bank *bank =3D NULL; - struct rockchip_pin_deferred *cfg; static int gpio; int id, ret; =20 @@ -736,45 +734,12 @@ static int rockchip_gpio_probe(struct platform_device= *pdev) if (ret) return ret; =20 - /* - * Prevent clashes with a deferred output setting - * being added right at this moment. - */ - mutex_lock(&bank->deferred_lock); - ret =3D rockchip_gpiolib_register(bank); if (ret) { clk_disable_unprepare(bank->clk); - mutex_unlock(&bank->deferred_lock); return ret; } =20 - while (!list_empty(&bank->deferred_pins)) { - cfg =3D list_first_entry(&bank->deferred_pins, - struct rockchip_pin_deferred, head); - list_del(&cfg->head); - - switch (cfg->param) { - case PIN_CONFIG_OUTPUT: - ret =3D 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 =3D 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); =20 diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-r= ockchip.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 rock= chip_pin_ctrl *ctrl, return false; } =20 -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; =20 cfg =3D kzalloc(sizeof(*cfg), GFP_KERNEL); if (!cfg) return -ENOMEM; =20 cfg->pin =3D pin; - cfg->param =3D param; cfg->arg =3D arg; =20 - list_add_tail(&cfg->head, &bank->deferred_pins); + list_add_tail(&cfg->head, &bank->deferred_output); =20 return 0; } @@ -2736,25 +2735,6 @@ static int rockchip_pinconf_set(struct pinctrl_dev *= pctldev, unsigned int pin, param =3D pinconf_to_config_param(configs[i]); arg =3D pinconf_to_config_argument(configs[i]); =20 - if (param =3D=3D PIN_CONFIG_OUTPUT || param =3D=3D PIN_CONFIG_INPUT_ENAB= LE) { - /* - * 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 =3D 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 =3D 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 !=3D RK_FUNC_GPIO) return -EINVAL; =20 + /* + * 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 =3D 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 =3D 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++; } =20 - INIT_LIST_HEAD(&pin_bank->deferred_pins); + INIT_LIST_HEAD(&pin_bank->deferred_output); mutex_init(&pin_bank->deferred_lock); } =20 @@ -3371,7 +3367,7 @@ static int rockchip_pinctrl_remove(struct platform_de= vice *pdev) { struct rockchip_pinctrl *info =3D platform_get_drvdata(pdev); struct rockchip_pin_bank *bank; - struct rockchip_pin_deferred *cfg; + struct rockchip_pin_output_deferred *cfg; int i; =20 of_platform_depopulate(&pdev->dev); @@ -3380,9 +3376,9 @@ static int rockchip_pinctrl_remove(struct platform_de= vice *pdev) bank =3D &info->ctrl->pin_banks[i]; =20 mutex_lock(&bank->deferred_lock); - while (!list_empty(&bank->deferred_pins)) { - cfg =3D list_first_entry(&bank->deferred_pins, - struct rockchip_pin_deferred, head); + while (!list_empty(&bank->deferred_output)) { + cfg =3D 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-r= ockchip.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; }; =20 @@ -414,12 +414,9 @@ struct rockchip_pin_config { unsigned int nconfigs; }; =20 -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; }; =20 --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F121C54EE9 for ; Tue, 20 Sep 2022 10:32:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230055AbiITKcD (ORCPT ); Tue, 20 Sep 2022 06:32:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbiITKbV (ORCPT ); Tue, 20 Sep 2022 06:31:21 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C9D16F275 for ; Tue, 20 Sep 2022 03:31:20 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaTh9KVk4eQkxKS01CQ00fSlUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITkhVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NAw6Eio6FT0sCBwhPQpLLx9D SS0KCjNVSlVKTU1ITU1CQ0xDQ0lLVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlLTUw3Bg++ X-HM-Tid: 0a835a73be182eb1kusn0a3b8280b96 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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_p= in_bank *bank) if (!gc->label) return -ENOMEM; =20 +#ifdef CONFIG_OF_GPIO + gc->of_node =3D of_node_get(bank->dev->of_node); +#endif + ret =3D gpiochip_add_data(gc, bank); if (ret) { dev_err(bank->dev, "failed to add gpiochip %s, %d\n", --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47B6CC54EE9 for ; Tue, 20 Sep 2022 10:32:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbiITKcJ (ORCPT ); Tue, 20 Sep 2022 06:32:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbiITKbW (ORCPT ); Tue, 20 Sep 2022 06:31:22 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F03E971737 for ; Tue, 20 Sep 2022 03:31:20 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDSElNVh5DGENIHh8fTUNJSlUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Kyo6PDo4OT0dURwfFwkTLy8B PwMwFBlVSlVKTU1ITU1CQ0xCTk5IVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlLTU03Bg++ X-HM-Tid: 0a835a73c1602eb1kusnd6990280ae2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D=3D GPIO_TYPE_V2 && !IS_ERR(bank->db_clk)) { div_debounce_support =3D true; freq =3D clk_get_rate(bank->db_clk); + if (!freq) + return -EINVAL; + max_debounce =3D (GENMASK(23, 0) + 1) * 2 * 1000000 / freq; if (debounce > max_debounce) return -EINVAL; --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3673AC54EE9 for ; Tue, 20 Sep 2022 10:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231223AbiITKcO (ORCPT ); Tue, 20 Sep 2022 06:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbiITKbX (ORCPT ); Tue, 20 Sep 2022 06:31:23 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E86EA4AD59 for ; Tue, 20 Sep 2022 03:31:21 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZTxhMVh5OTktKT00aGU9KTFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktPSEhVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6My46Ghw4Vj0fDBwMFwoMLx8d IR4KCTpVSlVKTU1ITU1CQ0NLTk1MVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlLSUI3Bg++ X-HM-Tid: 0a835a73c4362eb1kusn94edc280bbe Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D platform_get_drvdata(pdev); =20 + 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); =20 return 0; --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AA85C6FA8B for ; Tue, 20 Sep 2022 10:32:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229490AbiITKcT (ORCPT ); Tue, 20 Sep 2022 06:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230509AbiITKbX (ORCPT ); Tue, 20 Sep 2022 06:31:23 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF3C862ABD for ; Tue, 20 Sep 2022 03:31:22 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDTBpCVh9NSxofSB9ISU5PQlUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NC46DDo4SD0eDBxNPQpPLy0* CjlPCxxVSlVKTU1ITU1CQ0NKSUNKVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlMTEM3Bg++ X-HM-Tid: 0a835a73c82c2eb1kusn9870b280ba9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 */ =20 +#define GPIO_MAX_PINS (32) + static const struct rockchip_gpio_regs gpio_regs_v1 =3D { .port_dr =3D 0x00, .port_ddr =3D 0x04, @@ -520,14 +522,15 @@ static int rockchip_interrupts_register(struct rockch= ip_pin_bank *bank) struct irq_chip_generic *gc; int ret; =20 - bank->domain =3D irq_domain_add_linear(bank->of_node, 32, - &irq_generic_chip_ops, NULL); + bank->domain =3D 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; } =20 - ret =3D irq_alloc_domain_generic_chips(bank->domain, 32, 1, + ret =3D irq_alloc_domain_generic_chips(bank->domain, GPIO_MAX_PINS, 1, "rockchip_gpio_irq", handle_level_irq, clr, 0, 0); --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AEA1ECAAD8 for ; Tue, 20 Sep 2022 10:32:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230102AbiITKcX (ORCPT ); Tue, 20 Sep 2022 06:32:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230510AbiITKbZ (ORCPT ); Tue, 20 Sep 2022 06:31:25 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2E716F560 for ; Tue, 20 Sep 2022 03:31:23 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZTx9IVkodH01PSR9OQ0pPSFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PCo6Fxw5PT0oKhwJLRQDLyMR DQowCQhVSlVKTU1ITU1CQ0NJS0hMVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUlITkI3Bg++ X-HM-Tid: 0a835a73cafe2eb1kusn52f51280bc7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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) =20 ret =3D 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; } =20 platform_set_drvdata(pdev, bank); dev_info(dev, "probed %pOF\n", np); =20 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; } =20 static int rockchip_gpio_remove(struct platform_device *pdev) --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4F5AC54EE9 for ; Tue, 20 Sep 2022 10:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231202AbiITKcb (ORCPT ); Tue, 20 Sep 2022 06:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230514AbiITKbZ (ORCPT ); Tue, 20 Sep 2022 06:31:25 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DE1770E73 for ; Tue, 20 Sep 2022 03:31:24 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCSxpDVktDSUweTx5IGBhDSVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktITUpVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MzY6Lyo6ST0qPhwyFxRDLy4N ThcKChlVSlVKTU1ITU1CQ0NJTElNVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhNQkw3Bg++ X-HM-Tid: 0a835a73cdea2eb1kusn16680280bcb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. */ =20 +#include #include #include #include @@ -710,6 +711,29 @@ rockchip_gpio_find_bank(struct pinctrl_dev *pctldev, i= nt id) return found ? bank : NULL; } =20 +static int rockchip_gpio_get_bank_id(struct device *dev) +{ + struct fwnode_handle *fwnode =3D dev_fwnode(dev); + int bank_id =3D -EINVAL; + u64 uid; + int ret; + static int gpio; + + if (is_acpi_node(fwnode)) { + ret =3D acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid); + if (ret < 0) + return ret; + + bank_id =3D uid; + } else { + bank_id =3D of_alias_get_id(to_of_node(fwnode), "gpio"); + if (bank_id < 0) + bank_id =3D gpio++; + } + + return bank_id; +} + static int rockchip_gpio_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; @@ -717,8 +741,7 @@ static int rockchip_gpio_probe(struct platform_device *= pdev) struct device_node *pctlnp =3D of_get_parent(np); struct pinctrl_dev *pctldev =3D NULL; struct rockchip_pin_bank *bank =3D NULL; - static int gpio; - int id, ret; + int ret; =20 if (!np || !pctlnp) return -ENODEV; @@ -727,13 +750,11 @@ static int rockchip_gpio_probe(struct platform_device= *pdev) if (!pctldev) return -EPROBE_DEFER; =20 - id =3D of_alias_get_id(np, "gpio"); - if (id < 0) - id =3D gpio++; - - bank =3D rockchip_gpio_find_bank(pctldev, id); - if (!bank) - return -EINVAL; + ret =3D rockchip_gpio_get_bank_id(dev); + if (ret >=3D 0) + bank->bank_num =3D ret; + else + goto err; =20 bank->dev =3D dev; bank->of_node =3D 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: =20 return ret; } --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CBE0C54EE9 for ; Tue, 20 Sep 2022 10:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231334AbiITKcg (ORCPT ); Tue, 20 Sep 2022 06:32:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230518AbiITKb0 (ORCPT ); Tue, 20 Sep 2022 06:31:26 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08D946F555 for ; Tue, 20 Sep 2022 03:31:24 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCHkpJVkxJS01CTUhJSBofH1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OCI6Mjo6TD0oURwZVhRJLxcM OjEaCwFVSlVKTU1ITU1CQ0NITklLVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUpCQ083Bg++ X-HM-Tid: 0a835a73d0be2eb1kusnbfb82280bd1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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) } =20 platform_set_drvdata(pdev, bank); - dev_info(dev, "probed %pOF\n", np); + dev_info(dev, "probed %pfw\n", dev_fwnode(dev)); =20 return 0; err_put_clk: --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CA97ECAAD8 for ; Tue, 20 Sep 2022 10:32:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231343AbiITKck (ORCPT ); Tue, 20 Sep 2022 06:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230498AbiITKb1 (ORCPT ); Tue, 20 Sep 2022 06:31:27 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED1816E2C2 for ; Tue, 20 Sep 2022 03:31:25 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkZSU9NVkgfShlPQxhLSEpMT1UTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MVE6Eio6DD0vOhwCLRRJLw9N MU8aCQlVSlVKTU1ITU1CQ0NPSUpDVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUhISEI3Bg++ X-HM-Tid: 0a835a73d3b82eb1kusn8d360280bd5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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_p= in_bank *bank) =20 static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) { - struct resource res; int id =3D 0; =20 - 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 =3D devm_ioremap_resource(bank->dev, &res); - if (IS_ERR(bank->reg_base)) - return PTR_ERR(bank->reg_base); - - bank->irq =3D irq_of_parse_and_map(bank->of_node, 0); - if (!bank->irq) - return -EINVAL; - bank->clk =3D 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; =20 + bank->reg_base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(bank->reg_base)) + return PTR_ERR(bank->reg_base); + + bank->irq =3D platform_get_irq(pdev, 0); + if (bank->irq < 0) + return bank->irq; + ret =3D rockchip_gpiolib_register(bank); if (ret) { dev_err(bank->dev, "Failed to register gpio %d\n", ret); --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C3A2ECAAD8 for ; Tue, 20 Sep 2022 10:32:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230348AbiITKco (ORCPT ); Tue, 20 Sep 2022 06:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230526AbiITKb2 (ORCPT ); Tue, 20 Sep 2022 06:31:28 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD2006F275 for ; Tue, 20 Sep 2022 03:31:26 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVkaSUpJVh5DSUpOGkgeTEtDSFUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NzY6Fxw4TD0fFBwpVgodLxIy GkgaCRpVSlVKTU1ITU1CQ0NPQk1DVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQUpLT0lNNwY+ X-HM-Tid: 0a835a73d67c2eb1kusn42e5d280bd8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =20 -#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 */ =20 #define GPIO_MAX_PINS (32) =20 +/** + * 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 =3D 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 =3D { .port_dr =3D 0x00, .port_ddr =3D 0x04, @@ -607,35 +675,6 @@ static int rockchip_gpiolib_register(struct rockchip_p= in_bank *bank) return ret; } =20 - /* - * 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 =3D of_get_parent(bank->of_node); - struct pinctrl_dev *pctldev =3D NULL; - - if (!pctlnp) - return -ENODATA; - - pctldev =3D of_pinctrl_get(pctlnp); - if (!pctldev) - return -ENODEV; - - ret =3D 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 =3D 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; } =20 -static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) +static int rockchip_gpio_set_regs(struct rockchip_pin_bank *bank) { - int id =3D 0; + struct device *dev =3D bank->dev; + struct fwnode_handle *fwnode =3D dev_fwnode(dev); + int version_id; + int ret; =20 - bank->clk =3D of_clk_get(bank->of_node, 0); - if (IS_ERR(bank->clk)) - return PTR_ERR(bank->clk); + if (is_of_node(fwnode)) { + bank->clk =3D of_clk_get(to_of_node(fwnode), 0); + if (IS_ERR(bank->clk)) + return PTR_ERR(bank->clk); =20 - clk_prepare_enable(bank->clk); - id =3D readl(bank->reg_base + gpio_regs_v2.version_id); + ret =3D clk_prepare_enable(bank->clk); + if (ret < 0) + goto put_clk; + } =20 - /* If not gpio v2, that is default to v1. */ - if (id =3D=3D GPIO_TYPE_V2 || id =3D=3D GPIO_TYPE_V2_1) { + version_id =3D readl(bank->reg_base + gpio_regs_v2.version_id); + if (version_id =3D=3D GPIO_TYPE_V2 || version_id =3D=3D GPIO_TYPE_V2_1) { bank->gpio_regs =3D &gpio_regs_v2; bank->gpio_type =3D GPIO_TYPE_V2; - bank->db_clk =3D 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 =3D &gpio_regs_v1; bank->gpio_type =3D GPIO_TYPE_V1; } =20 - 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 =3D 0; + if (bank->gpio_type =3D=3D GPIO_TYPE_V2 && is_of_node(fwnode)) { + bank->db_clk =3D of_clk_get(to_of_node(fwnode), 1); + if (IS_ERR(bank->db_clk)) { + ret =3D PTR_ERR(bank->db_clk); + goto unprepare_clk; + } =20 - info =3D pinctrl_dev_get_drvdata(pctldev); - bank =3D info->ctrl->pin_banks; - for (i =3D 0; i < info->ctrl->nr_banks; i++, bank++) { - if (bank->bank_num =3D=3D id) { - found =3D 1; - break; + ret =3D clk_prepare_enable(bank->db_clk); + if (ret < 0) { + clk_put(bank->db_clk); + goto unprepare_clk; } } =20 - return found ? bank : NULL; + return 0; +unprepare_clk: + clk_disable_unprepare(bank->clk); +put_clk: + clk_put(bank->clk); + + return ret; } =20 static int rockchip_gpio_get_bank_id(struct device *dev) @@ -724,18 +764,20 @@ static int rockchip_gpio_get_bank_id(struct device *d= ev) static int rockchip_gpio_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; - struct device_node *np =3D dev->of_node; - struct device_node *pctlnp =3D of_get_parent(np); - struct pinctrl_dev *pctldev =3D NULL; - struct rockchip_pin_bank *bank =3D NULL; + struct rockchip_pin_bank *bank; int ret; =20 - if (!np || !pctlnp) - return -ENODEV; + bank =3D devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); + if (!bank) + return -ENOMEM; + + bank->reg_base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(bank->reg_base)) + return PTR_ERR(bank->reg_base); =20 - pctldev =3D of_pinctrl_get(pctlnp); - if (!pctldev) - return -EPROBE_DEFER; + bank->irq =3D platform_get_irq(pdev, 0); + if (bank->irq < 0) + return bank->irq; =20 ret =3D rockchip_gpio_get_bank_id(dev); if (ret >=3D 0) @@ -744,22 +786,15 @@ static int rockchip_gpio_probe(struct platform_device= *pdev) goto err; =20 bank->dev =3D dev; - bank->of_node =3D np; + bank->pin_base =3D GPIO_MAX_PINS * bank->bank_num; + bank->nr_pins =3D GPIO_MAX_PINS; =20 raw_spin_lock_init(&bank->slock); =20 - ret =3D rockchip_get_bank_data(bank); + ret =3D rockchip_gpio_set_regs(bank); if (ret) return ret; =20 - bank->reg_base =3D devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(bank->reg_base)) - return PTR_ERR(bank->reg_base); - - bank->irq =3D platform_get_irq(pdev, 0); - if (bank->irq < 0) - return bank->irq; - ret =3D rockchip_gpiolib_register(bank); if (ret) { dev_err(bank->dev, "Failed to register gpio %d\n", ret); --=20 2.25.1 From nobody Thu Apr 2 21:33:43 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 125A2ECAAD8 for ; Tue, 20 Sep 2022 10:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229896AbiITKct (ORCPT ); Tue, 20 Sep 2022 06:32:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230527AbiITKb2 (ORCPT ); Tue, 20 Sep 2022 06:31:28 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A33D6F254 for ; Tue, 20 Sep 2022 03:31:27 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJSktLSjdXWS1ZQUlXWQ8JGhUIEh9ZQVlDSRhMVkMeTBgeGh1OGU4YSVUTARMWGhIXJB QOD1lXWRgSC1lBWU5DVUlJVUxVSkpPWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Ky46Ohw5HD0tSRwiPQoPLxRJ DxQwCRlVSlVKTU1ITU1CQ0NOQ0hOVTMWGhIXVREaAlUDDjsJFBgQVhgTEgsIVRgUFkVZV1kSC1lB WU5DVUlJVUxVSkpPWVdZCAFZQU9PSUo3Bg++ X-HM-Tid: 0a835a73d9e42eb1kusn05d0a280bdb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-r= ockchip.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 *p= ctldev, unsigned int pin, { struct rockchip_pinctrl *info =3D pinctrl_dev_get_drvdata(pctldev); struct rockchip_pin_bank *bank =3D pin_to_bank(info, pin); - struct gpio_chip *gpio =3D &bank->gpio_chip; + struct gpio_chip *gpio =3D bank->gpio_chip; enum pin_config_param param; u32 arg; int i; @@ -2828,7 +2828,7 @@ static int rockchip_pinconf_get(struct pinctrl_dev *p= ctldev, unsigned int pin, { struct rockchip_pinctrl *info =3D pinctrl_dev_get_drvdata(pctldev); struct rockchip_pin_bank *bank =3D pin_to_bank(info, pin); - struct gpio_chip *gpio =3D &bank->gpio_chip; + struct gpio_chip *gpio =3D bank->gpio_chip; enum pin_config_param param =3D pinconf_to_config_param(*config); u16 arg; int rc; @@ -3293,7 +3293,7 @@ static int rockchip_pinctrl_probe(struct platform_dev= ice *pdev) struct rockchip_pin_ctrl *ctrl; struct resource *res; void __iomem *base; - int ret; + int ret, i; =20 if (is_of_node(fwnode)) { ret =3D of_platform_populate(np, NULL, NULL, dev); @@ -3357,6 +3357,24 @@ static int rockchip_pinctrl_probe(struct platform_de= vice *pdev) if (ret) return ret; =20 + for (i =3D 0; i < ctrl->nr_banks; i++) { + struct gpio_chip *gc; + struct rockchip_pin_bank *bank =3D &ctrl->pin_banks[i]; + + gc =3D gpiochip_find_by_name((void *)ctrl->pin_banks[i].name); + if (!gc) { + dev_err(dev, "fail to find gpiochip\n"); + return ret; + } + + ret =3D 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 =3D gc; + } + platform_set_drvdata(pdev, info); dev_info(dev, "probed %pfw\n", fwnode); =20 diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-r= ockchip.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; --=20 2.25.1