blob: 295ea17cffa7a4bdd5806932f9e044ff7f4e7be6 [file] [log] [blame]
Bo Lv72d0e902023-01-02 14:27:34 +00001// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
4 */
5
6#include <common.h>
7#include <asm/amlogic/arch/pwr_ctrl.h>
8#include <command.h>
9
10#ifndef PM_MAX
11#define PM_MAX 0
12static char *domain_name[PM_MAX];
13#else
14extern char* domain_name[];
15#endif
16extern unsigned long pwr_ctrl_status_psci_smc(unsigned int power_domain);
17
18static int do_powershow(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
19{
20 int i;
21 int ret=0;
22
23 if (argc > 1) {
24 return CMD_RET_USAGE;
25 }
26
27 if (PM_MAX == 0) {
28 printf("Don't support this feature now!\n");
29 return ret;
30 }
31
32 for (i = 0; i < PM_MAX; i++) {
33 /*
34 * The features of each board are different, ignore cov weak cryptor report.
35 */
36 /* coverity[overrun-local] */
37 if (strcmp("", domain_name[i]) != 0)
38 printf("%s[%d]: %lx\n", domain_name[i], i,
39 pwr_ctrl_status_psci_smc(i));
40 }
41
42 return ret;
43}
44
45U_BOOT_CMD(
46 powershow, 1, 1, do_powershow,
47 "show the power domain status , 0: on; 1: off",
48 "\n arg[0]: cmd\n"
49);
50
51static int do_powerset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
52{
53 unsigned int domain_id;
54 bool domain_status;
55 int ret=0;
56
57 if (argc <= 1) {
58 printf("plese input power set args: domain ID, domain status!\n");
59 return CMD_RET_USAGE;
60 }
61
62 domain_id = simple_strtoul(argv[1], NULL, 10);
63 domain_status = simple_strtoul(argv[2], NULL, 10);
64
65 pwr_ctrl_psci_smc(domain_id, !domain_status);
66
67 return ret;
68}
69
70U_BOOT_CMD(
71 powerset, 3, 1, do_powerset,
72 "power on/off a certain power domain",
73 "\n arg[0]: cmd\n"
74 "arg[1]: power domain ID \n"
75 "arg[2]: power status to set, 0: on, 1: off\n"
76);