]>
Commit | Line | Data |
---|---|---|
f225d39d JMT |
1 | /* |
2 | * (C) Copyright 2016 Linaro | |
3 | * Jon Medhurst <tixy@linaro.org> | |
4 | * | |
5 | * TC2 specific code for Versatile Express. | |
6 | * | |
7 | * SPDX-License-Identifier: GPL-2.0+ | |
8 | */ | |
9 | ||
03ab5d13 | 10 | #include <asm/armv7.h> |
f225d39d | 11 | #include <asm/io.h> |
03ab5d13 SH |
12 | #include <asm/u-boot.h> |
13 | #include <common.h> | |
14 | #include <libfdt.h> | |
f225d39d JMT |
15 | |
16 | #define SCC_BASE 0x7fff0000 | |
17 | ||
18 | bool armv7_boot_nonsec_default(void) | |
19 | { | |
20 | #ifdef CONFIG_ARMV7_BOOT_SEC_DEFAULT | |
21 | return false | |
22 | #else | |
23 | /* | |
24 | * The Serial Configuration Controller (SCC) register at address 0x700 | |
25 | * contains flags for configuring the behaviour of the Boot Monitor | |
26 | * (which CPUs execute from reset). Two of these bits are of interest: | |
27 | * | |
28 | * bit 12 = Use per-cpu mailboxes for power management | |
29 | * bit 13 = Power down the non-boot cluster | |
30 | * | |
31 | * It is only when both of these are false that U-Boot's current | |
32 | * implementation of 'nonsec' mode can work as expected because we | |
33 | * rely on getting all CPUs to execute _nonsec_init, so let's check that. | |
34 | */ | |
35 | return (readl((u32 *)(SCC_BASE + 0x700)) & ((1 << 12) | (1 << 13))) == 0; | |
36 | #endif | |
37 | } | |
03ab5d13 SH |
38 | |
39 | #ifdef CONFIG_OF_BOARD_SETUP | |
40 | int ft_board_setup(void *fdt, bd_t *bd) | |
41 | { | |
42 | int offset, tmp, len; | |
43 | const struct fdt_property *prop; | |
44 | const char *cci_compatible = "arm,cci-400-ctrl-if"; | |
45 | ||
46 | #ifdef CONFIG_ARMV7_NONSEC | |
47 | if (!armv7_boot_nonsec()) | |
48 | return 0; | |
49 | #else | |
50 | return 0; | |
51 | #endif | |
52 | /* Booting in nonsec mode, disable CCI access */ | |
53 | offset = fdt_path_offset(fdt, "/cpus"); | |
54 | if (offset < 0) { | |
55 | printf("couldn't find /cpus\n"); | |
56 | return offset; | |
57 | } | |
58 | ||
59 | /* delete cci-control-port in each cpu node */ | |
60 | for (tmp = fdt_first_subnode(fdt, offset); tmp >= 0; | |
61 | tmp = fdt_next_subnode(fdt, tmp)) | |
62 | fdt_delprop(fdt, tmp, "cci-control-port"); | |
63 | ||
64 | /* disable all ace cci slave ports */ | |
65 | offset = fdt_node_offset_by_prop_value(fdt, offset, "compatible", | |
66 | cci_compatible, 20); | |
67 | while (offset > 0) { | |
68 | prop = fdt_get_property(fdt, offset, "interface-type", | |
69 | &len); | |
70 | if (!prop) | |
71 | continue; | |
72 | if (len < 4) | |
73 | continue; | |
74 | if (strcmp(prop->data, "ace")) | |
75 | continue; | |
76 | ||
77 | fdt_setprop_string(fdt, offset, "status", "disabled"); | |
78 | ||
79 | offset = fdt_node_offset_by_prop_value(fdt, offset, "compatible", | |
80 | cci_compatible, 20); | |
81 | } | |
82 | ||
83 | return 0; | |
84 | } | |
85 | #endif /* CONFIG_OF_BOARD_SETUP */ |