1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright 2019 Google LLC
10 #include <power/acpi_pmc.h>
12 static int get_pmc_dev(struct udevice **devp)
17 ret = uclass_first_device_err(UCLASS_ACPI_PMC, &dev);
19 printf("Could not find device (err=%d)\n", ret);
24 printf("Could not init device (err=%d)\n", ret);
32 static int do_pmc_init(struct cmd_tbl *cmdtp, int flag, int argc,
38 ret = get_pmc_dev(&dev);
40 return CMD_RET_FAILURE;
45 static int do_pmc_info(struct cmd_tbl *cmdtp, int flag, int argc,
51 ret = get_pmc_dev(&dev);
53 return CMD_RET_FAILURE;
59 static struct cmd_tbl cmd_pmc_sub[] = {
60 U_BOOT_CMD_MKENT(init, 0, 1, do_pmc_init, "", ""),
61 U_BOOT_CMD_MKENT(info, 0, 1, do_pmc_info, "", ""),
64 static int do_pmc(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
66 const struct cmd_tbl *cp;
68 if (argc < 2) /* no subcommand */
69 return cmd_usage(cmdtp);
71 cp = find_cmd_tbl(argv[1], &cmd_pmc_sub[0], ARRAY_SIZE(cmd_pmc_sub));
75 return cp->cmd(cmdtp, flag, argc, argv);
79 pmc, 2, 1, do_pmc, "Power-management controller info",
80 "info - read state and show info about the PMC\n"
81 "pmc init - read state from the PMC\n"