blob: c5ad24269b9c12505d49f0e161a34ba6944d48ab [file] [log] [blame]
Googler25e92cf2023-12-13 10:05:01 +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/arch/pwr_ctrl.h>
8#include <command.h>
9
10#ifndef PM_MAX
11#define PM_MAX 0
12static char* domain_name[];
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 printf("%s[%d]: %lx\n", domain_name[i],i, pwr_ctrl_status_psci_smc(i));
34
35 return ret;
36}
37
38U_BOOT_CMD(
39 powershow, 1, 1, do_powershow,
40 "show the power domain status , 0: on; 1: off",
41 "\n arg[0]: cmd\n"
42);
43
44static int do_powerset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
45{
46 unsigned int domain_id;
47 bool domain_status;
48 int ret=0;
49
50 if (argc <= 1) {
51 printf("plese input power set args: domain ID, domain status!\n");
52 return CMD_RET_USAGE;
53 }
54
55 domain_id = simple_strtoul(argv[1], NULL, 10);
56 domain_status = simple_strtoul(argv[2], NULL, 10);
57 printf("domain_id: %d \n",domain_id);
58 printf("domain_status: %d\n",domain_status);
59
60 pwr_ctrl_psci_smc(domain_id, !domain_status);
61
62 return ret;
63}
64
65U_BOOT_CMD(
66 powerset, 3, 1, do_powerset,
67 "power on/off a certain power domain",
68 "\n arg[0]: cmd\n"
69 "arg[1]: power domain ID \n"
70 "arg[2]: power status to set, 0: on, 1: off\n"
71);