]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
ef509b90 VA |
2 | /* |
3 | * K2HK: secure kernel command file | |
4 | * | |
5 | * (C) Copyright 2012-2014 | |
6 | * Texas Instruments Incorporated, <www.ti.com> | |
ef509b90 VA |
7 | */ |
8 | ||
9 | #include <common.h> | |
10 | #include <command.h> | |
5d214065 | 11 | #include <image.h> |
aadd3360 | 12 | #include <mach/mon.h> |
ef509b90 VA |
13 | asm(".arch_extension sec\n\t"); |
14 | ||
ef509b90 VA |
15 | static int do_mon_install(cmd_tbl_t *cmdtp, int flag, int argc, |
16 | char * const argv[]) | |
17 | { | |
5d214065 | 18 | u32 addr, dpsc_base = 0x1E80000, freq, load_addr, size; |
ef509b90 | 19 | int rcode = 0; |
5d214065 | 20 | struct image_header *header; |
1d73ce6f | 21 | u32 ecrypt_bm_addr = 0; |
ef509b90 VA |
22 | |
23 | if (argc < 2) | |
24 | return CMD_RET_USAGE; | |
25 | ||
e6d71e1c | 26 | freq = CONFIG_SYS_HZ_CLOCK; |
ef509b90 VA |
27 | |
28 | addr = simple_strtoul(argv[1], NULL, 16); | |
29 | ||
5d214065 LV |
30 | header = (struct image_header *)addr; |
31 | ||
32 | if (image_get_magic(header) != IH_MAGIC) { | |
33 | printf("## Please update monitor image\n"); | |
34 | return -EFAULT; | |
35 | } | |
36 | ||
37 | load_addr = image_get_load(header); | |
38 | size = image_get_data_size(header); | |
39 | memcpy((void *)load_addr, (void *)(addr + sizeof(struct image_header)), | |
40 | size); | |
41 | ||
1d73ce6f MS |
42 | if (argc >= 3) |
43 | ecrypt_bm_addr = simple_strtoul(argv[2], NULL, 16); | |
44 | ||
45 | rcode = mon_install(load_addr, dpsc_base, freq, ecrypt_bm_addr); | |
5d214065 LV |
46 | printf("## installed monitor @ 0x%x, freq [%d], status %d\n", |
47 | load_addr, freq, rcode); | |
ef509b90 VA |
48 | |
49 | return 0; | |
50 | } | |
51 | ||
1d73ce6f | 52 | U_BOOT_CMD(mon_install, 3, 0, do_mon_install, |
ef509b90 VA |
53 | "Install boot kernel at 'addr'", |
54 | "" | |
55 | ); | |
56 | ||
57 | static void core_spin(void) | |
58 | { | |
17c5bda2 VA |
59 | while (1) { |
60 | asm volatile ( | |
61 | "dsb\n" | |
62 | "isb\n" | |
63 | "wfi\n" | |
64 | ); | |
65 | } | |
ef509b90 VA |
66 | } |
67 | ||
ef509b90 VA |
68 | int do_mon_power(cmd_tbl_t *cmdtp, int flag, int argc, |
69 | char * const argv[]) | |
70 | { | |
71 | int rcode = 0, core_id, on; | |
72 | void (*fn)(void); | |
73 | ||
74 | fn = core_spin; | |
75 | ||
76 | if (argc < 3) | |
77 | return CMD_RET_USAGE; | |
78 | ||
79 | core_id = simple_strtoul(argv[1], NULL, 16); | |
80 | on = simple_strtoul(argv[2], NULL, 16); | |
81 | ||
82 | if (on) | |
83 | rcode = mon_power_on(core_id, fn); | |
84 | else | |
85 | rcode = mon_power_off(core_id); | |
86 | ||
87 | if (on) { | |
88 | if (!rcode) | |
89 | printf("core %d powered on successfully\n", core_id); | |
90 | else | |
91 | printf("core %d power on failure\n", core_id); | |
92 | } else { | |
93 | printf("core %d powered off successfully\n", core_id); | |
94 | } | |
95 | ||
96 | return 0; | |
97 | } | |
98 | ||
99 | U_BOOT_CMD(mon_power, 3, 0, do_mon_power, | |
100 | "Power On/Off secondary core", | |
101 | "mon_power <coreid> <oper>\n" | |
102 | "- coreid (1-3) and oper (1 - ON, 0 - OFF)\n" | |
103 | "" | |
104 | ); |