645b7801c8b8e02e65bd839d724e156497a648ee
[openwrt/staging/mans0n.git] /
1 From 63336ec7fd7d480ac58a91f3b20d08bf1b3a13ad Mon Sep 17 00:00:00 2001
2 From: Weijie Gao <weijie.gao@mediatek.com>
3 Date: Wed, 19 Jul 2023 17:15:41 +0800
4 Subject: [PATCH 01/29] arm: mediatek: retrieve ram_base from dts node for
5 armv8 platform
6
7 Now we use fdtdec_setup_mem_size_base() to get DRAM base from fdt ram node
8 and update gd->ram_base. CFG_SYS_SDRAM_BASE is unused and will be removed.
9
10 Also, since mt7622 always passes fdt to linux kernel, there's no need to
11 assign value to gd->bd->bi_boot_params.
12
13 Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
14 ---
15 arch/arm/dts/mt7981-emmc-rfb.dts | 5 +++++
16 arch/arm/dts/mt7981-rfb.dts | 5 +++++
17 arch/arm/dts/mt7981-sd-rfb.dts | 5 +++++
18 arch/arm/dts/mt7986a-bpi-r3-sd.dts | 5 +++++
19 arch/arm/dts/mt7986a-rfb.dts | 5 +++++
20 arch/arm/dts/mt7986a-sd-rfb.dts | 5 +++++
21 arch/arm/dts/mt7986b-rfb.dts | 5 +++++
22 arch/arm/dts/mt7986b-sd-rfb.dts | 5 +++++
23 arch/arm/mach-mediatek/mt7622/init.c | 13 +++++++++----
24 arch/arm/mach-mediatek/mt7981/init.c | 11 +++++++++--
25 arch/arm/mach-mediatek/mt7986/init.c | 11 +++++++++--
26 board/mediatek/mt7622/mt7622_rfb.c | 1 -
27 include/configs/mt7622.h | 10 ----------
28 include/configs/mt7981.h | 9 ---------
29 include/configs/mt7986.h | 9 ---------
30 15 files changed, 67 insertions(+), 37 deletions(-)
31
32 --- a/arch/arm/dts/mt7981-emmc-rfb.dts
33 +++ b/arch/arm/dts/mt7981-emmc-rfb.dts
34 @@ -18,6 +18,11 @@
35 tick-timer = &timer0;
36 };
37
38 + memory@40000000 {
39 + device_type = "memory";
40 + reg = <0x40000000 0x10000000>;
41 + };
42 +
43 reg_3p3v: regulator-3p3v {
44 compatible = "regulator-fixed";
45 regulator-name = "fixed-3.3V";
46 --- a/arch/arm/dts/mt7981-rfb.dts
47 +++ b/arch/arm/dts/mt7981-rfb.dts
48 @@ -17,6 +17,11 @@
49 stdout-path = &uart0;
50 tick-timer = &timer0;
51 };
52 +
53 + memory@40000000 {
54 + device_type = "memory";
55 + reg = <0x40000000 0x10000000>;
56 + };
57 };
58
59 &uart0 {
60 --- a/arch/arm/dts/mt7981-sd-rfb.dts
61 +++ b/arch/arm/dts/mt7981-sd-rfb.dts
62 @@ -18,6 +18,11 @@
63 tick-timer = &timer0;
64 };
65
66 + memory@40000000 {
67 + device_type = "memory";
68 + reg = <0x40000000 0x10000000>;
69 + };
70 +
71 reg_3p3v: regulator-3p3v {
72 compatible = "regulator-fixed";
73 regulator-name = "fixed-3.3V";
74 --- a/arch/arm/dts/mt7986a-bpi-r3-sd.dts
75 +++ b/arch/arm/dts/mt7986a-bpi-r3-sd.dts
76 @@ -19,6 +19,11 @@
77 tick-timer = &timer0;
78 };
79
80 + memory@40000000 {
81 + device_type = "memory";
82 + reg = <0x40000000 0x80000000>;
83 + };
84 +
85 reg_3p3v: regulator-3p3v {
86 compatible = "regulator-fixed";
87 regulator-name = "fixed-3.3V";
88 --- a/arch/arm/dts/mt7986a-rfb.dts
89 +++ b/arch/arm/dts/mt7986a-rfb.dts
90 @@ -18,6 +18,11 @@
91 tick-timer = &timer0;
92 };
93
94 + memory@40000000 {
95 + device_type = "memory";
96 + reg = <0x40000000 0x10000000>;
97 + };
98 +
99 reg_1p8v: regulator-1p8v {
100 compatible = "regulator-fixed";
101 regulator-name = "fixed-1.8V";
102 --- a/arch/arm/dts/mt7986a-sd-rfb.dts
103 +++ b/arch/arm/dts/mt7986a-sd-rfb.dts
104 @@ -19,6 +19,11 @@
105 tick-timer = &timer0;
106 };
107
108 + memory@40000000 {
109 + device_type = "memory";
110 + reg = <0x40000000 0x10000000>;
111 + };
112 +
113 reg_3p3v: regulator-3p3v {
114 compatible = "regulator-fixed";
115 regulator-name = "fixed-3.3V";
116 --- a/arch/arm/dts/mt7986b-rfb.dts
117 +++ b/arch/arm/dts/mt7986b-rfb.dts
118 @@ -18,6 +18,11 @@
119 tick-timer = &timer0;
120 };
121
122 + memory@40000000 {
123 + device_type = "memory";
124 + reg = <0x40000000 0x10000000>;
125 + };
126 +
127 reg_3p3v: regulator-3p3v {
128 compatible = "regulator-fixed";
129 regulator-name = "fixed-3.3V";
130 --- a/arch/arm/dts/mt7986b-sd-rfb.dts
131 +++ b/arch/arm/dts/mt7986b-sd-rfb.dts
132 @@ -19,6 +19,11 @@
133 tick-timer = &timer0;
134 };
135
136 + memory@40000000 {
137 + device_type = "memory";
138 + reg = <0x40000000 0x10000000>;
139 + };
140 +
141 reg_3p3v: regulator-3p3v {
142 compatible = "regulator-fixed";
143 regulator-name = "fixed-3.3V";
144 --- a/arch/arm/mach-mediatek/mt7622/init.c
145 +++ b/arch/arm/mach-mediatek/mt7622/init.c
146 @@ -4,11 +4,14 @@
147 * Author: Sam Shih <sam.shih@mediatek.com>
148 */
149
150 -#include <common.h>
151 #include <fdtdec.h>
152 #include <init.h>
153 #include <asm/armv8/mmu.h>
154 -#include <asm/cache.h>
155 +#include <asm/global_data.h>
156 +#include <asm/u-boot.h>
157 +#include <linux/sizes.h>
158 +
159 +DECLARE_GLOBAL_DATA_PTR;
160
161 int print_cpuinfo(void)
162 {
163 @@ -20,11 +23,13 @@ int dram_init(void)
164 {
165 int ret;
166
167 - ret = fdtdec_setup_memory_banksize();
168 + ret = fdtdec_setup_mem_size_base();
169 if (ret)
170 return ret;
171 - return fdtdec_setup_mem_size_base();
172
173 + gd->ram_size = get_ram_size((void *)gd->ram_base, SZ_2G);
174 +
175 + return 0;
176 }
177
178 void reset_cpu(void)
179 --- a/arch/arm/mach-mediatek/mt7981/init.c
180 +++ b/arch/arm/mach-mediatek/mt7981/init.c
181 @@ -4,18 +4,25 @@
182 * Author: Sam Shih <sam.shih@mediatek.com>
183 */
184
185 -#include <cpu_func.h>
186 +#include <fdtdec.h>
187 #include <init.h>
188 #include <asm/armv8/mmu.h>
189 #include <asm/system.h>
190 #include <asm/global_data.h>
191 +#include <asm/u-boot.h>
192 #include <linux/sizes.h>
193
194 DECLARE_GLOBAL_DATA_PTR;
195
196 int dram_init(void)
197 {
198 - gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE, SZ_2G);
199 + int ret;
200 +
201 + ret = fdtdec_setup_mem_size_base();
202 + if (ret)
203 + return ret;
204 +
205 + gd->ram_size = get_ram_size((void *)gd->ram_base, SZ_1G);
206
207 return 0;
208 }
209 --- a/arch/arm/mach-mediatek/mt7986/init.c
210 +++ b/arch/arm/mach-mediatek/mt7986/init.c
211 @@ -4,18 +4,25 @@
212 * Author: Sam Shih <sam.shih@mediatek.com>
213 */
214
215 -#include <cpu_func.h>
216 +#include <fdtdec.h>
217 #include <init.h>
218 #include <asm/armv8/mmu.h>
219 #include <asm/system.h>
220 #include <asm/global_data.h>
221 +#include <asm/u-boot.h>
222 #include <linux/sizes.h>
223
224 DECLARE_GLOBAL_DATA_PTR;
225
226 int dram_init(void)
227 {
228 - gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE, SZ_2G);
229 + int ret;
230 +
231 + ret = fdtdec_setup_mem_size_base();
232 + if (ret)
233 + return ret;
234 +
235 + gd->ram_size = get_ram_size((void *)gd->ram_base, SZ_2G);
236
237 return 0;
238 }
239 --- a/board/mediatek/mt7622/mt7622_rfb.c
240 +++ b/board/mediatek/mt7622/mt7622_rfb.c
241 @@ -19,7 +19,6 @@ DECLARE_GLOBAL_DATA_PTR;
242
243 int board_init(void)
244 {
245 - gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
246 return 0;
247 }
248
249 --- a/include/configs/mt7622.h
250 +++ b/include/configs/mt7622.h
251 @@ -9,14 +9,4 @@
252 #ifndef __MT7622_H
253 #define __MT7622_H
254
255 -/* Uboot definition */
256 -#define CFG_SYS_UBOOT_BASE CONFIG_TEXT_BASE
257 -
258 -/* SPL -> Uboot */
259 -#define CFG_SYS_UBOOT_START CONFIG_TEXT_BASE
260 -/* DRAM */
261 -#define CFG_SYS_SDRAM_BASE 0x40000000
262 -
263 -/* Ethernet */
264 -
265 #endif
266 --- a/include/configs/mt7981.h
267 +++ b/include/configs/mt7981.h
268 @@ -9,13 +9,4 @@
269 #ifndef __MT7981_H
270 #define __MT7981_H
271
272 -/* Uboot definition */
273 -#define CFG_SYS_UBOOT_BASE CONFIG_TEXT_BASE
274 -
275 -/* SPL -> Uboot */
276 -#define CFG_SYS_UBOOT_START CONFIG_TEXT_BASE
277 -
278 -/* DRAM */
279 -#define CFG_SYS_SDRAM_BASE 0x40000000
280 -
281 #endif
282 --- a/include/configs/mt7986.h
283 +++ b/include/configs/mt7986.h
284 @@ -9,13 +9,4 @@
285 #ifndef __MT7986_H
286 #define __MT7986_H
287
288 -/* Uboot definition */
289 -#define CFG_SYS_UBOOT_BASE CONFIG_TEXT_BASE
290 -
291 -/* SPL -> Uboot */
292 -#define CFG_SYS_UBOOT_START CONFIG_TEXT_BASE
293 -
294 -/* DRAM */
295 -#define CFG_SYS_SDRAM_BASE 0x40000000
296 -
297 #endif