blob: 6a9bdc96017bae56f2539dd63c0a2e0cbeb9c1e1 [file] [log] [blame]
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -04001/*
2 * K2HK: secure kernel command file
3 *
4 * (C) Copyright 2012-2014
5 * Texas Instruments Incorporated, <www.ti.com>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9
10#include <common.h>
11#include <command.h>
Tom Rini108ee582016-03-16 09:10:08 -040012#include <mach/mon.h>
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040013asm(".arch_extension sec\n\t");
14
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040015static int do_mon_install(cmd_tbl_t *cmdtp, int flag, int argc,
16 char * const argv[])
17{
18 u32 addr, dpsc_base = 0x1E80000, freq;
19 int rcode = 0;
20
21 if (argc < 2)
22 return CMD_RET_USAGE;
23
Vitaly Andrianov7fd5b642015-09-19 16:26:41 +053024 freq = CONFIG_SYS_HZ_CLOCK;
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040025
26 addr = simple_strtoul(argv[1], NULL, 16);
27
28 rcode = mon_install(addr, dpsc_base, freq);
29 printf("## installed monitor, freq [%d], status %d\n",
30 freq, rcode);
31
32 return 0;
33}
34
35U_BOOT_CMD(mon_install, 2, 0, do_mon_install,
36 "Install boot kernel at 'addr'",
37 ""
38);
39
40static void core_spin(void)
41{
Vitaly Andrianovaa750ed2015-07-08 11:40:14 -040042 while (1) {
43 asm volatile (
44 "dsb\n"
45 "isb\n"
46 "wfi\n"
47 );
48 }
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040049}
50
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040051int do_mon_power(cmd_tbl_t *cmdtp, int flag, int argc,
52 char * const argv[])
53{
54 int rcode = 0, core_id, on;
55 void (*fn)(void);
56
57 fn = core_spin;
58
59 if (argc < 3)
60 return CMD_RET_USAGE;
61
62 core_id = simple_strtoul(argv[1], NULL, 16);
63 on = simple_strtoul(argv[2], NULL, 16);
64
65 if (on)
66 rcode = mon_power_on(core_id, fn);
67 else
68 rcode = mon_power_off(core_id);
69
70 if (on) {
71 if (!rcode)
72 printf("core %d powered on successfully\n", core_id);
73 else
74 printf("core %d power on failure\n", core_id);
75 } else {
76 printf("core %d powered off successfully\n", core_id);
77 }
78
79 return 0;
80}
81
82U_BOOT_CMD(mon_power, 3, 0, do_mon_power,
83 "Power On/Off secondary core",
84 "mon_power <coreid> <oper>\n"
85 "- coreid (1-3) and oper (1 - ON, 0 - OFF)\n"
86 ""
87);