diff mbox series

[U-Boot,v2,13/24] power domain: Add support for multiple powerdomains per device

Message ID 20180827102755.5784-14-lokeshvutla@ti.com
State Accepted
Delegated to: Tom Rini
Headers show
Series Initial support Texas Instrument's AM654 Platform | expand

Commit Message

Lokesh Vutla Aug. 27, 2018, 10:27 a.m. UTC
There are cases where there are more than one power domain
attached to the device inorder to get the device functional.
So add support for enabling power domain based on the index.

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 drivers/power/domain/power-domain-uclass.c | 11 +++++++++--
 include/power-domain.h                     | 21 +++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

Comments

Tom Rini Sept. 12, 2018, 12:41 a.m. UTC | #1
On Mon, Aug 27, 2018 at 03:57:44PM +0530, Lokesh Vutla wrote:

> There are cases where there are more than one power domain
> attached to the device inorder to get the device functional.
> So add support for enabling power domain based on the index.
> 
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c
index 9e9ec4f419..2ea0ff24c7 100644
--- a/drivers/power/domain/power-domain-uclass.c
+++ b/drivers/power/domain/power-domain-uclass.c
@@ -28,7 +28,8 @@  static int power_domain_of_xlate_default(struct power_domain *power_domain,
 	return 0;
 }
 
-int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
+int power_domain_get_by_index(struct udevice *dev,
+			      struct power_domain *power_domain, int index)
 {
 	struct ofnode_phandle_args args;
 	int ret;
@@ -38,7 +39,8 @@  int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
 	debug("%s(dev=%p, power_domain=%p)\n", __func__, dev, power_domain);
 
 	ret = dev_read_phandle_with_args(dev, "power-domains",
-					 "#power-domain-cells", 0, 0, &args);
+					 "#power-domain-cells", 0, index,
+					 &args);
 	if (ret) {
 		debug("%s: dev_read_phandle_with_args failed: %d\n",
 		      __func__, ret);
@@ -73,6 +75,11 @@  int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
 	return 0;
 }
 
+int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
+{
+	return power_domain_get_by_index(dev, power_domain, 0);
+}
+
 int power_domain_free(struct power_domain *power_domain)
 {
 	struct power_domain_ops *ops = power_domain_dev_ops(power_domain->dev);
diff --git a/include/power-domain.h b/include/power-domain.h
index a558fbbdb2..00996057b0 100644
--- a/include/power-domain.h
+++ b/include/power-domain.h
@@ -97,6 +97,27 @@  int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
 }
 #endif
 
+/**
+ * power_domain_get_by_index - Get the indexed power domain for a device.
+ *
+ * @dev:		The client device.
+ * @power_domain:	A pointer to a power domain struct to initialize.
+ * @index:		Power domain index to be powered on.
+ *
+ * @return 0 if OK, or a negative error code.
+ */
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)
+int power_domain_get_by_index(struct udevice *dev,
+			      struct power_domain *power_domain, int index);
+#else
+static inline
+int power_domain_get_by_index(struct udevice *dev,
+			      struct power_domain *power_domain, int index)
+{
+	return -ENOSYS;
+}
+#endif
+
 /**
  * power_domain_free - Free a previously requested power domain.
  *