summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-09-05 09:04:48 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-09-13 12:07:55 +0200
commit579a72e317362ca2e1d4d9692c1b082c535203b5 (patch)
tree2c4c1d5cfc95749bb219cb4dc34a3b6a99bbcb8e
parent6dd56795a1e6686bb11891777070f41e12a4545a (diff)
downloadbarebox-579a72e317362ca2e1d4d9692c1b082c535203b5.tar.gz
barebox-579a72e317362ca2e1d4d9692c1b082c535203b5.tar.xz
commands: add pm_domain for listing power domains
Like the regulator command, this new pm_domain command gives an easy way for listing registered power domains and whether barebox had them activated. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905070448.539531-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--commands/Kconfig8
-rw-r--r--commands/Makefile1
-rw-r--r--commands/pm_domain.c18
-rw-r--r--drivers/base/power.c10
-rw-r--r--include/pm_domain.h2
5 files changed, 39 insertions, 0 deletions
diff --git a/commands/Kconfig b/commands/Kconfig
index 3e21dc4c05..9894ecb9aa 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -240,6 +240,14 @@ config CMD_REGULATOR
the regulator command lists the currently registered regulators and
their current state.
+config CMD_PM_DOMAIN
+ bool
+ depends on PM_GENERIC_DOMAINS
+ prompt "pm_domain command"
+ help
+ The pm_domain command lists the currently registered power domains and
+ their current state.
+
config CMD_NVMEM
bool
depends on NVMEM
diff --git a/commands/Makefile b/commands/Makefile
index 0aae8893d6..068fbb32da 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -116,6 +116,7 @@ obj-$(CONFIG_CMD_READF) += readf.o
obj-$(CONFIG_CMD_MENUTREE) += menutree.o
obj-$(CONFIG_CMD_2048) += 2048.o
obj-$(CONFIG_CMD_REGULATOR) += regulator.o
+obj-$(CONFIG_CMD_PM_DOMAIN) += pm_domain.o
obj-$(CONFIG_CMD_LSPCI) += lspci.o
obj-$(CONFIG_CMD_IMD) += imd.o
obj-$(CONFIG_CMD_HWCLOCK) += hwclock.o
diff --git a/commands/pm_domain.c b/commands/pm_domain.c
new file mode 100644
index 0000000000..ec8b769df1
--- /dev/null
+++ b/commands/pm_domain.c
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <common.h>
+#include <command.h>
+#include <pm_domain.h>
+
+static int do_pm_domain(int argc, char *argv[])
+{
+ pm_genpd_print();
+
+ return 0;
+}
+
+BAREBOX_CMD_START(pm_domain)
+ .cmd = do_pm_domain,
+ BAREBOX_CMD_DESC("list power domains")
+ BAREBOX_CMD_GROUP(CMD_GRP_INFO)
+BAREBOX_CMD_END
diff --git a/drivers/base/power.c b/drivers/base/power.c
index 4a206051b1..3eabf3c897 100644
--- a/drivers/base/power.c
+++ b/drivers/base/power.c
@@ -266,3 +266,13 @@ int genpd_dev_pm_attach(struct device_d *dev)
return __genpd_dev_pm_attach(dev, dev->device_node, 0, true);
}
EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);
+
+void pm_genpd_print(void)
+{
+ struct generic_pm_domain *genpd;
+
+ printf("%-20s %6s\n", "name", "active");
+ list_for_each_entry(genpd, &gpd_list, gpd_list_node)
+ printf("%-20s %6s\n", genpd->name,
+ genpd->status == GPD_STATE_ACTIVE ? "on" : "off");
+}
diff --git a/include/pm_domain.h b/include/pm_domain.h
index 48fd170007..ff1aa37511 100644
--- a/include/pm_domain.h
+++ b/include/pm_domain.h
@@ -54,6 +54,8 @@ int pm_genpd_init(struct generic_pm_domain *genpd, void *gov, bool is_off);
int of_genpd_add_provider_simple(struct device_node *np,
struct generic_pm_domain *genpd);
+void pm_genpd_print(void);
+
#else
static inline int pm_genpd_init(struct generic_pm_domain *genpd,