Skip to contentSkip to conversation

core: device: support multiple power domains for one device

PATCH New Peng Fan 2 participants 4 messages Sep 2, 2019 – Sep 17, 2019

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/1 core: device: support multiple power domains for one device

When device has multiple power domains, power_domain_get could not able to support that. So let's iterate each power domain and enable it.

---
 drivers/core/device.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/core/device.c +11 -3
index 474c1642ee..67fcff87fa 100644
@@ -311,7 +311,7 @@ int device_probe(struct udevice *dev)
 	const struct driver *drv;
 	int size = 0;
 	int ret;
-	int seq;
+	int seq, i, count;
 
 	if (!dev)
 		return -EINVAL;
@@ -390,8 +390,16 @@ int device_probe(struct udevice *dev)
 
 	if (CONFIG_IS_ENABLED(POWER_DOMAIN) && dev->parent &&
 	    device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) {
-		if (!power_domain_get(dev, &pd))
-			power_domain_on(&pd);
+		count = dev_count_phandle_with_args(dev, "power-domains",
+						    "#power-domain-cells");
+		for (i = 0; i < count; i++) {
+			ret = power_domain_get_by_index(dev, &pd, i);
+			if (ret)
+				goto fail;
+			ret = power_domain_on(&pd);
+			if (ret)
+				goto fail;
+		}
 	}
 
 	ret = uclass_pre_probe_device(dev);
Signature · 1 line
2.16.4
author
#1 lore raw

PATCH 1/1 core: device: support multiple power domains for one device

Quoted 1 line

Subject: [PATCH] core: device: support multiple power domains for one device

Ping..

Thanks,
Peng.

Quoted 43 lines

When device has multiple power domains, power_domain_get could not able to support that. So let's iterate each power domain and enable it.

---
 drivers/core/device.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/core/device.c index renamed from drivers/core/device.c +0 -0

474c1642ee..67fcff87fa 100644

drivers/core/device.c +11 -4
@@ -311,7 +311,7 @@ int device_probe(struct udevice *dev)
 	const struct driver *drv;
 	int size = 0;
 	int ret;
-	int seq;
+	int seq, i, count;
 
 	if (!dev)
 		return -EINVAL;
@@ -390,8 +390,16 @@ int device_probe(struct udevice *dev)
 
 	if (CONFIG_IS_ENABLED(POWER_DOMAIN) && dev->parent &&
 	    device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) {
-		if (!power_domain_get(dev, &pd))
-			power_domain_on(&pd);
+		count = dev_count_phandle_with_args(dev, "power-domains",
+						    "#power-domain-cells");
+		for (i = 0; i < count; i++) {
+			ret = power_domain_get_by_index(dev, &pd, i);
+			if (ret)
+				goto fail;
+			ret = power_domain_on(&pd);
+			if (ret)
+				goto fail;
+		}
 	}
 
 	ret = uclass_pre_probe_device(dev);
--

2.16.4

#2 lore raw

PATCH 1/1 core: device: support multiple power domains for one device

In reply to Peng Fan

Hi Peng,

Quoted 29 lines · Peng Fan

When device has multiple power domains, power_domain_get could not able to support that. So let's iterate each power domain and enable it.

---
 drivers/core/device.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/core/device.c +1 -3
index 474c1642ee..67fcff87fa 100644
@@ -311,7 +311,7 @@ int device_probe(struct udevice *dev)
        const struct driver *drv;
        int size = 0;
        int ret;
-       int seq;
+       int seq, i, count;
 
        if (!dev)
                return -EINVAL;
@@ -390,8 +390,16 @@ int device_probe(struct udevice *dev)
 
        if (CONFIG_IS_ENABLED(POWER_DOMAIN) && dev->parent &&
            device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) {
-               if (!power_domain_get(dev, &pd))
-                       power_domain_on(&pd);

drivers/core/device.c int device_probe(struct udevice *dev) · line 402

Quoted 10 lines
drivers/core/device.c +10 -0
+               count = dev_count_phandle_with_args(dev, "power-domains",
+                                                   "#power-domain-cells");
+               for (i = 0; i < count; i++) {
+                       ret = power_domain_get_by_index(dev, &pd, i);
+                       if (ret)
+                               goto fail;
+                       ret = power_domain_on(&pd);
+                       if (ret)
+                               goto fail;
+               }

Can you please move this into a new function, perhaps in a new drivers/core/power.c file?

Quoted 6 lines
drivers/core/device.c +0 -1
        }
 
        ret = uclass_pre_probe_device(dev);
--

2.16.4

Regards,
Simon

author
#3 lore raw

PATCH 1/1 core: device: support multiple power domains for one device

Hi Simon,

Quoted 49 lines

Subject: Re: [PATCH] core: device: support multiple power domains for one device

Hi Peng,

Quoted 24 lines · Peng Fan

When device has multiple power domains, power_domain_get could not able to support that. So let's iterate each power domain and enable it.

---
 drivers/core/device.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/core/device.c index renamed from drivers/core/device.c +0 -0

474c1642ee..67fcff87fa 100644

drivers/core/device.c +1 -1
@@ -311,7 +311,7 @@ int device_probe(struct udevice *dev)
        const struct driver *drv;
        int size = 0;
        int ret;
-       int seq;
+       int seq, i, count;
 
        if (!dev)
                return -EINVAL;

drivers/core/device.c int device_probe(struct udevice *dev) · line 393

Quoted 6 lines
drivers/core/device.c +1 -2
@@ -390,8 +390,16 @@ int device_probe(struct udevice *dev)
 
        if (CONFIG_IS_ENABLED(POWER_DOMAIN) && dev->parent &&
            device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) {
-               if (!power_domain_get(dev, &pd))
-                       power_domain_on(&pd);
+               count = dev_count_phandle_with_args(dev,

"power-domains",

drivers/core/device.c int device_probe(struct udevice *dev) · line 394

Quoted 1 line
drivers/core/device.c +1 -0
+

"#power-domain-cells");

drivers/core/device.c int device_probe(struct udevice *dev) · line 396

Quoted 2 lines
drivers/core/device.c +2 -0
+               for (i = 0; i < count; i++) {
+                       ret = power_domain_get_by_index(dev, &pd,

i);

drivers/core/device.c int device_probe(struct udevice *dev) · line 402

Quoted 6 lines
drivers/core/device.c +6 -0
+                       if (ret)
+                               goto fail;
+                       ret = power_domain_on(&pd);
+                       if (ret)
+                               goto fail;
+               }
Quoted 2 lines

Can you please move this into a new function, perhaps in a new drivers/core/power.c file?

ok. Let me fix in v2.

Thanks,
Peng.

Quoted 10 lines
Quoted 7 lines
drivers/core/device.c +0 -1
        }
 
        ret = uclass_pre_probe_device(dev);
--

2.16.4

Regards,
Simon