[PATCH] commands: add pm_domain for listing power domains
Sascha Hauer
sha at pengutronix.de
Mon Sep 12 03:12:49 PDT 2022
On Mon, Sep 05, 2022 at 09:04:48AM +0200, Ahmad Fatoum wrote:
> 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 at pengutronix.de>
> ---
> commands/Kconfig | 8 ++++++++
> commands/Makefile | 1 +
> commands/pm_domain.c | 18 ++++++++++++++++++
> drivers/base/power.c | 10 ++++++++++
> include/pm_domain.h | 2 ++
> 5 files changed, 39 insertions(+)
> create mode 100644 commands/pm_domain.c
Applied, thanks
Sascha
>
> diff --git a/commands/Kconfig b/commands/Kconfig
> index 3e21dc4c0500..9894ecb9aa31 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 0aae8893d696..068fbb32dad7 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 000000000000..ec8b769df193
> --- /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 4a206051b137..3eabf3c897b2 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 48fd170007fd..ff1aa3751165 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,
> --
> 2.30.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list