arm: mach-rockchip: bind sub-nodes for rk3399_syscon
[oweals/u-boot.git] / arch / arm / mach-imx / mkimage_fit_atf.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0+
3 #
4 # script to generate FIT image source for i.MX8MQ boards with
5 # ARM Trusted Firmware and multiple device trees (given on the command line)
6 #
7 # usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
8
9 [ -z "$BL31" ] && BL31="bl31.bin"
10 [ -z "$TEE_LOAD_ADDR" ] && TEE_LOAD_ADDR="0xfe000000"
11 [ -z "$ATF_LOAD_ADDR" ] && ATF_LOAD_ADDR="0x00910000"
12 [ -z "$BL33_LOAD_ADDR" ] && BL33_LOAD_ADDR="0x40200000"
13
14 if [ ! -f $BL31 ]; then
15         echo "ERROR: BL31 file $BL31 NOT found" >&2
16         exit 0
17 else
18         echo "$BL31 size: " >&2
19         ls -lct $BL31 | awk '{print $5}' >&2
20 fi
21
22 BL32="tee.bin"
23
24 if [ ! -f $BL32 ]; then
25         BL32=/dev/null
26 else
27         echo "Building with TEE support, make sure your $BL31 is compiled with spd. If you do not want tee, please delete $BL31" >&2
28         echo "$BL32 size: " >&2
29         ls -lct $BL32 | awk '{print $5}' >&2
30 fi
31
32 BL33="u-boot-nodtb.bin"
33
34 if [ ! -f $BL33 ]; then
35         echo "ERROR: $BL33 file NOT found" >&2
36         exit 0
37 else
38         echo "u-boot-nodtb.bin size: " >&2
39         ls -lct u-boot-nodtb.bin | awk '{print $5}' >&2
40 fi
41
42 for dtname in $*
43 do
44         echo "$dtname size: " >&2
45         ls -lct $dtname | awk '{print $5}' >&2
46 done
47
48
49 cat << __HEADER_EOF
50 /dts-v1/;
51
52 / {
53         description = "Configuration to load ATF before U-Boot";
54
55         images {
56                 uboot@1 {
57                         description = "U-Boot (64-bit)";
58                         os = "u-boot";
59                         data = /incbin/("$BL33");
60                         type = "standalone";
61                         arch = "arm64";
62                         compression = "none";
63                         load = <$BL33_LOAD_ADDR>;
64                 };
65                 atf@1 {
66                         description = "ARM Trusted Firmware";
67                         os = "arm-trusted-firmware";
68                         data = /incbin/("$BL31");
69                         type = "firmware";
70                         arch = "arm64";
71                         compression = "none";
72                         load = <$ATF_LOAD_ADDR>;
73                         entry = <$ATF_LOAD_ADDR>;
74                 };
75 __HEADER_EOF
76
77 if [ -f $BL32 ]; then
78 cat << __HEADER_EOF
79                 tee@1 {
80                         description = "TEE firmware";
81                         data = /incbin/("$BL32");
82                         type = "firmware";
83                         arch = "arm64";
84                         compression = "none";
85                         load = <$TEE_LOAD_ADDR>;
86                         entry = <$TEE_LOAD_ADDR>;
87                 };
88 __HEADER_EOF
89 fi
90
91 cnt=1
92 for dtname in $*
93 do
94         cat << __FDT_IMAGE_EOF
95                 fdt@$cnt {
96                         description = "$(basename $dtname .dtb)";
97                         data = /incbin/("$dtname");
98                         type = "flat_dt";
99                         compression = "none";
100                 };
101 __FDT_IMAGE_EOF
102 cnt=$((cnt+1))
103 done
104
105 cat << __CONF_HEADER_EOF
106         };
107         configurations {
108                 default = "config@1";
109
110 __CONF_HEADER_EOF
111
112 cnt=1
113 for dtname in $*
114 do
115 if [ -f $BL32 ]; then
116 cat << __CONF_SECTION_EOF
117                 config@$cnt {
118                         description = "$(basename $dtname .dtb)";
119                         firmware = "uboot@1";
120                         loadables = "atf@1", "tee@1";
121                         fdt = "fdt@$cnt";
122                 };
123 __CONF_SECTION_EOF
124 else
125 cat << __CONF_SECTION1_EOF
126                 config@$cnt {
127                         description = "$(basename $dtname .dtb)";
128                         firmware = "uboot@1";
129                         loadables = "atf@1";
130                         fdt = "fdt@$cnt";
131                 };
132 __CONF_SECTION1_EOF
133 fi
134 cnt=$((cnt+1))
135 done
136
137 cat << __ITS_EOF
138         };
139 };
140 __ITS_EOF