]> git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/mach-keystone/cmd_mon.c
arm: mach-keystone: Updates mon_install for K2G HS
[people/ms/u-boot.git] / arch / arm / mach-keystone / cmd_mon.c
1 /*
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>
12 #include <image.h>
13 #include <mach/mon.h>
14 asm(".arch_extension sec\n\t");
15
16 static int do_mon_install(cmd_tbl_t *cmdtp, int flag, int argc,
17 char * const argv[])
18 {
19 u32 addr, dpsc_base = 0x1E80000, freq, load_addr, size;
20 int rcode = 0;
21 struct image_header *header;
22 u32 ecrypt_bm_addr = 0;
23
24 if (argc < 2)
25 return CMD_RET_USAGE;
26
27 freq = CONFIG_SYS_HZ_CLOCK;
28
29 addr = simple_strtoul(argv[1], NULL, 16);
30
31 header = (struct image_header *)addr;
32
33 if (image_get_magic(header) != IH_MAGIC) {
34 printf("## Please update monitor image\n");
35 return -EFAULT;
36 }
37
38 load_addr = image_get_load(header);
39 size = image_get_data_size(header);
40 memcpy((void *)load_addr, (void *)(addr + sizeof(struct image_header)),
41 size);
42
43 if (argc >= 3)
44 ecrypt_bm_addr = simple_strtoul(argv[2], NULL, 16);
45
46 rcode = mon_install(load_addr, dpsc_base, freq, ecrypt_bm_addr);
47 printf("## installed monitor @ 0x%x, freq [%d], status %d\n",
48 load_addr, freq, rcode);
49
50 return 0;
51 }
52
53 U_BOOT_CMD(mon_install, 3, 0, do_mon_install,
54 "Install boot kernel at 'addr'",
55 ""
56 );
57
58 static void core_spin(void)
59 {
60 while (1) {
61 asm volatile (
62 "dsb\n"
63 "isb\n"
64 "wfi\n"
65 );
66 }
67 }
68
69 int do_mon_power(cmd_tbl_t *cmdtp, int flag, int argc,
70 char * const argv[])
71 {
72 int rcode = 0, core_id, on;
73 void (*fn)(void);
74
75 fn = core_spin;
76
77 if (argc < 3)
78 return CMD_RET_USAGE;
79
80 core_id = simple_strtoul(argv[1], NULL, 16);
81 on = simple_strtoul(argv[2], NULL, 16);
82
83 if (on)
84 rcode = mon_power_on(core_id, fn);
85 else
86 rcode = mon_power_off(core_id);
87
88 if (on) {
89 if (!rcode)
90 printf("core %d powered on successfully\n", core_id);
91 else
92 printf("core %d power on failure\n", core_id);
93 } else {
94 printf("core %d powered off successfully\n", core_id);
95 }
96
97 return 0;
98 }
99
100 U_BOOT_CMD(mon_power, 3, 0, do_mon_power,
101 "Power On/Off secondary core",
102 "mon_power <coreid> <oper>\n"
103 "- coreid (1-3) and oper (1 - ON, 0 - OFF)\n"
104 ""
105 );