Skip to contentSkip to conversation

Restore original GPIO uclass logic

PATCH In review Svyatoslav Ryhel 2 participants 7 messages Dec 9, 2024 – Dec 10, 2024 GPIO

lore
Share & tools
lore
#0 lore raw

cover Restore original GPIO uclass logic

Move PMIC GPIO child handling into PMIC's driver by bounding GPIO driver to parent node. Remove gpio-uclass workaround.

Svyatoslav Ryhel (3):
Revert "drivers: gpio-uclass: support PMIC GPIO children"
pmic: max77663: bind children to parent node
pmic: palmas: bind sysreset to parent node

 drivers/gpio/gpio-uclass.c    | 20 --------------------
 drivers/power/pmic/max77663.c |  9 +++++----
 drivers/power/pmic/palmas.c   |  5 +++--
 3 files changed, 8 insertions(+), 26 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 Revert "drivers: gpio-uclass: support PMIC GPIO children"

Requesting of PMIC's GPIO child should be done by binding GPIO driver to PMIC's node is GPIO driver does not have its own node.

This reverts commit c03cd98d1a163666b4addcdd9a34fc0c77dfd0a5.

---
 drivers/gpio/gpio-uclass.c | 20 --------------------
 1 file changed, 20 deletions(-)
drivers/gpio/gpio-uclass.c +0 -20
index 0213271e3a6..67fc776cada 100644
@@ -1142,29 +1142,9 @@ static int gpio_request_tail(int ret, const char *nodename,
 		ret = uclass_get_device_by_ofnode(UCLASS_GPIO, args->node,
 						  &desc->dev);
 		if (ret) {
-#if CONFIG_IS_ENABLED(MAX77663_GPIO) || CONFIG_IS_ENABLED(PALMAS_GPIO)
-			struct udevice *pmic;
-			ret = uclass_get_device_by_ofnode(UCLASS_PMIC, args->node,
-							  &pmic);
-			if (ret) {
-				log_debug("%s: PMIC device get failed, err %d\n",
-					  __func__, ret);
-				goto err;
-			}
-
-			device_foreach_child(desc->dev, pmic) {
-				if (device_get_uclass_id(desc->dev) == UCLASS_GPIO)
-					break;
-			}
-
-			/* if loop exits without GPIO device return error */
-			if (device_get_uclass_id(desc->dev) != UCLASS_GPIO)
-				goto err;
-#else
 			debug("%s: uclass_get_device_by_ofnode failed\n",
 			      __func__);
 			goto err;
-#endif
 		}
 	}
 	ret = gpio_find_and_xlate(desc, args);
Signature · 1 line
2.43.0
Reviewed-by on v1 1/3
#2 lore raw

RE: [PATCH v1 1/3] Revert "drivers: gpio-uclass: support PMIC GPIO children"

Quoted 6 lines

-----Original Message-----
From: Svyatoslav Ryhel <[email protected]>
Sent: Tuesday, December 10, 2024 1:15 AM

Quoted 7 lines

Requesting of PMIC's GPIO child should be done by binding GPIO driver to PMIC's node is GPIO driver does not have its own node.

This reverts commit c03cd98d1a163666b4addcdd9a34fc0c77dfd0a5.

Best Regards,

Quoted 40 lines
---
 drivers/gpio/gpio-uclass.c | 20 --------------------
 1 file changed, 20 deletions(-)
drivers/gpio/gpio-uclass.c +0 -21
index 0213271e3a6..67fc776cada 100644
@@ -1142,29 +1142,9 @@ static int gpio_request_tail(int ret, const char *nodename,
 		ret = uclass_get_device_by_ofnode(UCLASS_GPIO, args->node,
 						  &desc->dev);
 		if (ret) {
-#if CONFIG_IS_ENABLED(MAX77663_GPIO) || CONFIG_IS_ENABLED(PALMAS_GPIO)
-			struct udevice *pmic;
-			ret = uclass_get_device_by_ofnode(UCLASS_PMIC, args->node,
-							  &pmic);
-			if (ret) {
-				log_debug("%s: PMIC device get failed, err %d\n",
-					  __func__, ret);
-				goto err;
-			}
-
-			device_foreach_child(desc->dev, pmic) {
-				if (device_get_uclass_id(desc->dev) == UCLASS_GPIO)
-					break;
-			}
-
-			/* if loop exits without GPIO device return error */
-			if (device_get_uclass_id(desc->dev) != UCLASS_GPIO)
-				goto err;
-#else
 			debug("%s: uclass_get_device_by_ofnode failed\n",
 			      __func__);
 			goto err;
-#endif
 		}
 	}
 	ret = gpio_find_and_xlate(desc, args);
--

2.43.0

#3 lore raw

PATCH 2/3 pmic: max77663: bind children to parent node

In reply to Svyatoslav Ryhel

Bind GPIO and SYSRESET children to parent node since they do not have their own nodes in the device tree.

---
 drivers/power/pmic/max77663.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/power/pmic/max77663.c +5 -4
index cf08b6a7e1d..c2a7cbf7e40 100644
@@ -47,8 +47,9 @@ static int max77663_bind(struct udevice *dev)
 	int children, ret;
 
 	if (IS_ENABLED(CONFIG_SYSRESET_MAX77663)) {
-		ret = device_bind_driver(dev, MAX77663_RST_DRIVER,
-					 "sysreset", NULL);
+		ret = device_bind_driver_to_node(dev, MAX77663_RST_DRIVER,
+						 "sysreset", dev_ofnode(dev),
+						 NULL);
 		if (ret) {
 			log_err("cannot bind SYSRESET (ret = %d)\n", ret);
 			return ret;
@@ -56,8 +57,8 @@ static int max77663_bind(struct udevice *dev)
 	}
 
 	if (IS_ENABLED(CONFIG_MAX77663_GPIO)) {
-		ret = device_bind_driver(dev, MAX77663_GPIO_DRIVER,
-					 "gpio", NULL);
+		ret = device_bind_driver_to_node(dev, MAX77663_GPIO_DRIVER,
+						 "gpio", dev_ofnode(dev), NULL);
 		if (ret) {
 			log_err("cannot bind GPIOs (ret = %d)\n", ret);
 			return ret;
Signature · 1 line
2.43.0
Reviewed-by on v1 2/3
#4 lore raw

RE: [PATCH v1 2/3] pmic: max77663: bind children to parent node

Quoted 10 lines

-----Original Message-----
From: Svyatoslav Ryhel <[email protected]>
Sent: Tuesday, December 10, 2024 1:15 AM

Bind GPIO and SYSRESET children to parent node since they do not have their own nodes in the device tree.

Best Regards,

Quoted 33 lines
---
 drivers/power/pmic/max77663.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/power/pmic/max77663.c +5 -5
index cf08b6a7e1d..c2a7cbf7e40 100644
@@ -47,8 +47,9 @@ static int max77663_bind(struct udevice *dev)
 	int children, ret;
 
 	if (IS_ENABLED(CONFIG_SYSRESET_MAX77663)) {
-		ret = device_bind_driver(dev, MAX77663_RST_DRIVER,
-					 "sysreset", NULL);
+		ret = device_bind_driver_to_node(dev, MAX77663_RST_DRIVER,
+						 "sysreset", dev_ofnode(dev),
+						 NULL);
 		if (ret) {
 			log_err("cannot bind SYSRESET (ret = %d)\n", ret);
 			return ret;
@@ -56,8 +57,8 @@ static int max77663_bind(struct udevice *dev)
 	}
 
 	if (IS_ENABLED(CONFIG_MAX77663_GPIO)) {
-		ret = device_bind_driver(dev, MAX77663_GPIO_DRIVER,
-					 "gpio", NULL);
+		ret = device_bind_driver_to_node(dev, MAX77663_GPIO_DRIVER,
+						 "gpio", dev_ofnode(dev), NULL);
 		if (ret) {
 			log_err("cannot bind GPIOs (ret = %d)\n", ret);
 			return ret;
--

2.43.0

#5 lore raw

PATCH 3/3 pmic: palmas: bind sysreset to parent node

In reply to Svyatoslav Ryhel

Bind SYSRESET child to parent node since it does not have its own node in the device tree.

---
 drivers/power/pmic/palmas.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/power/pmic/palmas.c +3 -2
index f676bf64169..37d4190fabe 100644
@@ -49,8 +49,9 @@ static int palmas_bind(struct udevice *dev)
 	int children, ret;
 
 	if (IS_ENABLED(CONFIG_SYSRESET_PALMAS)) {
-		ret = device_bind_driver(dev, PALMAS_RST_DRIVER,
-					 "sysreset", NULL);
+		ret = device_bind_driver_to_node(dev, PALMAS_RST_DRIVER,
+						 "sysreset", dev_ofnode(dev),
+						 NULL);
 		if (ret) {
 			log_err("cannot bind SYSRESET (ret = %d)\n", ret);
 			return ret;
Signature · 1 line
2.43.0
Reviewed-by on v1 3/3
#6 lore raw

RE: [PATCH v1 3/3] pmic: palmas: bind sysreset to parent node

Quoted 9 lines

-----Original Message-----
From: Svyatoslav Ryhel <[email protected]>
Sent: Tuesday, December 10, 2024 1:15 AM
Bind SYSRESET child to parent node since it does not have its own node in the device tree.

Best Regards,

Quoted 22 lines
---
 drivers/power/pmic/palmas.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/power/pmic/palmas.c +3 -3
index f676bf64169..37d4190fabe 100644
@@ -49,8 +49,9 @@ static int palmas_bind(struct udevice *dev)
 	int children, ret;
 
 	if (IS_ENABLED(CONFIG_SYSRESET_PALMAS)) {
-		ret = device_bind_driver(dev, PALMAS_RST_DRIVER,
-					 "sysreset", NULL);
+		ret = device_bind_driver_to_node(dev, PALMAS_RST_DRIVER,
+						 "sysreset", dev_ofnode(dev),
+						 NULL);
 		if (ret) {
 			log_err("cannot bind SYSRESET (ret = %d)\n", ret);
 			return ret;
--

2.43.0