1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright 2019 Google LLC
11 #include <power/acpi_pmc.h>
13 static int get_pmc_dev(struct udevice **devp)
18 ret = uclass_first_device_err(UCLASS_ACPI_PMC, &dev);
20 printf("Could not find device (err=%d)\n", ret);
25 printf("Could not init device (err=%d)\n", ret);
33 static int do_pmc_init(struct cmd_tbl *cmdtp, int flag, int argc,
39 ret = get_pmc_dev(&dev);
41 return CMD_RET_FAILURE;
46 static int do_pmc_info(struct cmd_tbl *cmdtp, int flag, int argc,
52 ret = get_pmc_dev(&dev);
54 return CMD_RET_FAILURE;
60 static struct cmd_tbl cmd_pmc_sub[] = {
61 U_BOOT_CMD_MKENT(init, 0, 1, do_pmc_init, "", ""),
62 U_BOOT_CMD_MKENT(info, 0, 1, do_pmc_info, "", ""),
65 static int do_pmc(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
67 const struct cmd_tbl *cp;
69 if (argc < 2) /* no subcommand */
70 return cmd_usage(cmdtp);
72 cp = find_cmd_tbl(argv[1], &cmd_pmc_sub[0], ARRAY_SIZE(cmd_pmc_sub));
76 return cp->cmd(cmdtp, flag, argc, argv);
80 pmc, 2, 1, do_pmc, "Power-management controller info",
81 "info - read state and show info about the PMC\n"
82 "pmc init - read state from the PMC\n"