summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/power/domain/power-domain-uclass.c14
-rw-r--r--include/power-domain.h21
2 files changed, 35 insertions, 0 deletions
diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c
index 0c5823cedd..74c33d4e2e 100644
--- a/drivers/power/domain/power-domain-uclass.c
+++ b/drivers/power/domain/power-domain-uclass.c
@@ -80,6 +80,20 @@ int power_domain_get_by_index(struct udevice *dev,
return 0;
}
+int power_domain_get_by_name(struct udevice *dev,
+ struct power_domain *power_domain, const char *name)
+{
+ int index;
+
+ index = dev_read_stringlist_search(dev, "power-domain-names", name);
+ if (index < 0) {
+ debug("fdt_stringlist_search() failed: %d\n", index);
+ return index;
+ }
+
+ return power_domain_get_by_index(dev, power_domain, index);
+}
+
int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
{
return power_domain_get_by_index(dev, power_domain, 0);
diff --git a/include/power-domain.h b/include/power-domain.h
index 113276b511..2ff6c77cd7 100644
--- a/include/power-domain.h
+++ b/include/power-domain.h
@@ -108,6 +108,27 @@ int power_domain_get_by_index(struct udevice *dev,
#endif
/**
+ * power_domain_get_by_name - Get the named power domain for a device.
+ *
+ * @dev: The client device.
+ * @power_domain: A pointer to a power domain struct to initialize.
+ * @name: Power domain name to be powered on.
+ *
+ * Return: 0 if OK, or a negative error code.
+ */
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)
+int power_domain_get_by_name(struct udevice *dev,
+ struct power_domain *power_domain, const char *name);
+#else
+static inline
+int power_domain_get_by_name(struct udevice *dev,
+ struct power_domain *power_domain, const char *name)
+{
+ return -ENOSYS;
+}
+#endif
+
+/**
* power_domain_free - Free a previously requested power domain.
*
* @power_domain: A power domain struct that was previously successfully