From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Cc: Marek Vasut <marex@denx.de>,
Patrick Delaunay <patrick.delaunay@foss.st.com>,
Simon Glass <sjg@chromium.org>
Subject: [PATCH v2 16/23] power_domain: Add power_domain_get_by_name()
Date: Mon, 11 Apr 2022 21:45:36 +0200 [thread overview]
Message-ID: <20220411194543.730647-16-marex@denx.de> (raw)
In-Reply-To: <20220411194543.730647-1-marex@denx.de>
Implement power_domain_get_by_name() convenience function which parses
DT property 'power-domain-names' and looks up power domain by matching
name.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Simon Glass <sjg@chromium.org>
---
drivers/power/domain/power-domain-uclass.c | 14 ++++++++++++++
include/power-domain.h | 21 +++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c
index 0c5823ceddf..74c33d4e2e0 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 113276b5119..2ff6c77cd76 100644
--- a/include/power-domain.h
+++ b/include/power-domain.h
@@ -107,6 +107,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.
*
--
2.35.1
next prev parent reply other threads:[~2022-04-11 19:49 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-11 19:45 [PATCH v2 01/23] mmc: fsl_esdhc_imx: Add i.MX8MP compatible string Marek Vasut
2022-04-11 19:45 ` [PATCH v2 02/23] ARM: dts: net: dwc_eth_qos: Fix " Marek Vasut
2022-04-11 19:45 ` [PATCH v2 03/23] ARM: imx: imx8m: Add 933 MHz PLL settings Marek Vasut
2022-04-12 18:45 ` sbabic
2022-04-11 19:45 ` [PATCH v2 04/23] imx8m: ddrphy_utils: Add 3732 MT/s mode Marek Vasut
2022-04-12 18:46 ` sbabic
2022-04-11 19:45 ` [PATCH v2 05/23] pmic: pca9450: Add PCA9450C compatible string Marek Vasut
2022-04-12 18:43 ` sbabic
2022-04-11 19:45 ` [PATCH v2 06/23] pmic: pca9450: Add upstream regulators subnode match Marek Vasut
2022-04-18 0:10 ` Jaehoon Chung
2022-04-11 19:45 ` [PATCH v2 07/23] pmic: pca9450: Add regulator driver Marek Vasut
2022-04-18 0:13 ` Jaehoon Chung
2022-04-11 19:45 ` [PATCH v2 08/23] spi: nxp_fspi: Add i.MX8MP compatible string Marek Vasut
2022-04-11 19:45 ` [PATCH v2 09/23] ARM: dts: imx: Add flexspi node to i.MX8MP Marek Vasut
2022-04-11 19:45 ` [PATCH v2 10/23] ARM: imx: Decode ECSPI env location from i.MX8M ROMAPI tables Marek Vasut
2022-04-11 19:45 ` [PATCH v2 11/23] ARM: imx: Get rid of only i.MX8M SMCCC arch call Marek Vasut
2022-04-11 19:45 ` [PATCH v2 12/23] power-domain: Return 0 if ops unimplemented and remove empty functions Marek Vasut
2022-04-18 0:14 ` Jaehoon Chung
2022-04-11 19:45 ` [PATCH v2 13/23] imx: power-domain: Descend into pgc subnode if present Marek Vasut
2022-04-11 19:45 ` [PATCH v2 14/23] imx: power-domain: Inline arch-imx8m/power-domain.h Marek Vasut
2022-04-18 0:23 ` Jaehoon Chung
2022-04-11 19:45 ` [PATCH v2 15/23] imx: power-domain: Get rid of SMCCC dependency Marek Vasut
2022-04-11 19:45 ` Marek Vasut [this message]
2022-04-11 19:45 ` [PATCH v2 17/23] imx: power-domain: Add i.MX8MP support Marek Vasut
2022-04-11 19:45 ` [PATCH v3 18/23] imx: power-domain: Add i.MX8MP HSIOMIX driver Marek Vasut
2022-04-11 19:45 ` [PATCH v3 19/23] clk: imx8mp: Fill in DWC3 USB, USB PHY, HSIOMIX clock Marek Vasut
2022-04-11 19:45 ` [PATCH v2 20/23] phy: phy-imx8mq-usb: Add support for i.MX8MP USB PHY Marek Vasut
2022-04-12 18:44 ` sbabic
2022-04-11 19:45 ` [PATCH v2 21/23] usb: dwc3: Rename .select_dr_mode to .glue_configure Marek Vasut
2022-04-11 19:45 ` [PATCH v2 22/23] usb: dwc3: Implement .glue_configure for i.MX8MP Marek Vasut
2022-04-11 19:45 ` [PATCH v2 23/23] arm: dts: imx8mp: Import GPCv2 subset, HSIOMIX and USB PD Marek Vasut
2022-04-12 18:56 ` [PATCH v2 01/23] mmc: fsl_esdhc_imx: Add i.MX8MP compatible string Stefano Babic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220411194543.730647-16-marex@denx.de \
--to=marex@denx.de \
--cc=patrick.delaunay@foss.st.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox