uboot-bcm53xx: Add U-Boot for NorthStar BCM53xx
[openwrt/staging/neocturne.git] / package / boot / uboot-bcm53xx / patches / 0005-board-Add-new-Broadcom-Northstar-board.patch
1 From 652a6fa45b6c9d52dd9685fc12ad662e54a9092e Mon Sep 17 00:00:00 2001
2 From: Linus Walleij <linus.walleij@linaro.org>
3 Date: Mon, 24 Apr 2023 09:38:30 +0200
4 Subject: [PATCH 5/5] board: Add new Broadcom Northstar board
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 This adds a simple Northstar "BRCMNS" board to be used with
10 the BCM4708x and BCM5301x chips.
11
12 The main intention is to use this with the D-Link DIR-890L
13 and DIR-885L routers for loading the kernel into RAM from
14 NAND memory using the BCH-1 ECC and using the separately
15 submitted SEAMA load command, so we are currently not adding
16 support for things such as networking.
17
18 The DTS file is a multiplatform NorthStar board, designed to
19 be usable with several NorthStar designs by avoiding any
20 particulars not related to the operation of U-Boot.
21
22 If other board need other ECC for example, they need to
23 create a separate DTS file and augment the code, but I don't
24 know if any other users will turn up.
25
26 Cc: Rafał Miłecki <rafal@milecki.pl>
27 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
28 ---
29 arch/arm/Kconfig | 1 +
30 arch/arm/dts/Makefile | 2 ++
31 arch/arm/dts/ns-board.dts | 57 ++++++++++++++++++++++++++++++
32 board/broadcom/bcmns/Kconfig | 12 +++++++
33 board/broadcom/bcmns/MAINTAINERS | 6 ++++
34 board/broadcom/bcmns/Makefile | 2 ++
35 board/broadcom/bcmns/ns.c | 60 ++++++++++++++++++++++++++++++++
36 configs/bcmns_defconfig | 41 ++++++++++++++++++++++
37 doc/board/broadcom/index.rst | 1 +
38 doc/board/broadcom/northstar.rst | 44 +++++++++++++++++++++++
39 include/configs/bcmns.h | 49 ++++++++++++++++++++++++++
40 11 files changed, 275 insertions(+)
41 create mode 100644 arch/arm/dts/ns-board.dts
42 create mode 100644 board/broadcom/bcmns/Kconfig
43 create mode 100644 board/broadcom/bcmns/MAINTAINERS
44 create mode 100644 board/broadcom/bcmns/Makefile
45 create mode 100644 board/broadcom/bcmns/ns.c
46 create mode 100644 configs/bcmns_defconfig
47 create mode 100644 doc/board/broadcom/northstar.rst
48 create mode 100644 include/configs/bcmns.h
49
50 --- a/arch/arm/Kconfig
51 +++ b/arch/arm/Kconfig
52 @@ -2286,6 +2286,7 @@ source "board/Marvell/octeontx2/Kconfig"
53 source "board/armltd/vexpress/Kconfig"
54 source "board/armltd/vexpress64/Kconfig"
55 source "board/cortina/presidio-asic/Kconfig"
56 +source "board/broadcom/bcmns/Kconfig"
57 source "board/broadcom/bcmns3/Kconfig"
58 source "board/cavium/thunderx/Kconfig"
59 source "board/eets/pdu001/Kconfig"
60 --- a/arch/arm/dts/Makefile
61 +++ b/arch/arm/dts/Makefile
62 @@ -1185,6 +1185,8 @@ dtb-$(CONFIG_ARCH_BCM283X) += \
63 bcm2837-rpi-cm3-io3.dtb \
64 bcm2711-rpi-4-b.dtb
65
66 +dtb-$(CONFIG_TARGET_BCMNS) += ns-board.dtb
67 +
68 dtb-$(CONFIG_TARGET_BCMNS3) += ns3-board.dtb
69
70 dtb-$(CONFIG_ARCH_BCMSTB) += bcm7xxx.dtb
71 --- /dev/null
72 +++ b/arch/arm/dts/ns-board.dts
73 @@ -0,0 +1,57 @@
74 +// SPDX-License-Identifier: GPL-2.0+
75 +
76 +/dts-v1/;
77 +
78 +#include "bcm5301x.dtsi"
79 +
80 +/ {
81 + /*
82 + * The Northstar does not have a proper fallback compatible, but
83 + * these basic chips will suffice.
84 + */
85 + model = "Northstar model";
86 + compatible = "brcm,bcm47094", "brcm,bcm4708";
87 + #address-cells = <1>;
88 + #size-cells = <1>;
89 + interrupt-parent = <&gic>;
90 +
91 + memory {
92 + device_type = "memory";
93 + reg = <0x00000000 0x08000000>,
94 + <0x88000000 0x08000000>;
95 + };
96 +
97 + aliases {
98 + serial0 = &uart0;
99 + };
100 +
101 + chosen {
102 + stdout-path = "serial0:115200n8";
103 + };
104 +
105 + nand-controller@18028000 {
106 + nandcs: nand@0 {
107 + compatible = "brcm,nandcs";
108 + reg = <0>;
109 + #address-cells = <1>;
110 + #size-cells = <1>;
111 +
112 + /*
113 + * Same as using the bcm5301x-nand-cs0-bch1.dtsi
114 + * include from the Linux kernel.
115 + */
116 + nand-ecc-algo = "bch";
117 + nand-ecc-strength = <1>;
118 + nand-ecc-step-size = <512>;
119 +
120 + partitions {
121 + compatible = "brcm,bcm947xx-cfe-partitions";
122 + };
123 + };
124 + };
125 +};
126 +
127 +&uart0 {
128 + clock-frequency = <125000000>;
129 + status = "okay";
130 +};
131 --- /dev/null
132 +++ b/board/broadcom/bcmns/Kconfig
133 @@ -0,0 +1,12 @@
134 +if TARGET_BCMNS
135 +
136 +config SYS_BOARD
137 + default "bcmns"
138 +
139 +config SYS_VENDOR
140 + default "broadcom"
141 +
142 +config SYS_CONFIG_NAME
143 + default "bcmns"
144 +
145 +endif
146 --- /dev/null
147 +++ b/board/broadcom/bcmns/MAINTAINERS
148 @@ -0,0 +1,6 @@
149 +BCMNS BOARD
150 +M: Linus Walleij <linus.walleij@linaro.org>
151 +S: Maintained
152 +F: board/broadcom/bcmnsp/
153 +F: configs/bcmnsp_defconfig
154 +F: include/configs/bcmnsp.h
155 --- /dev/null
156 +++ b/board/broadcom/bcmns/Makefile
157 @@ -0,0 +1,2 @@
158 +# SPDX-License-Identifier: GPL-2.0-or-later
159 +obj-y := ns.o
160 --- /dev/null
161 +++ b/board/broadcom/bcmns/ns.c
162 @@ -0,0 +1,60 @@
163 +// SPDX-License-Identifier: GPL-2.0+
164 +/*
165 + * Broadcom Northstar generic board set-up code
166 + * Copyright (C) 2023 Linus Walleij <linus.walleij@linaro.org>
167 + */
168 +
169 +#include <common.h>
170 +#include <dm.h>
171 +#include <init.h>
172 +#include <log.h>
173 +#include <ram.h>
174 +#include <serial.h>
175 +#include <asm/global_data.h>
176 +#include <asm/io.h>
177 +#include <asm/armv7m.h>
178 +
179 +DECLARE_GLOBAL_DATA_PTR;
180 +
181 +int dram_init(void)
182 +{
183 + return fdtdec_setup_mem_size_base();
184 +}
185 +
186 +int dram_init_banksize(void)
187 +{
188 + return fdtdec_setup_memory_banksize();
189 +}
190 +
191 +int board_late_init(void)
192 +{
193 + /* LEDs etc can be initialized here */
194 + return 0;
195 +}
196 +
197 +int board_init(void)
198 +{
199 + return 0;
200 +}
201 +
202 +void reset_cpu(void)
203 +{
204 +}
205 +
206 +int print_cpuinfo(void)
207 +{
208 + printf("BCMNS Northstar SoC\n");
209 + return 0;
210 +}
211 +
212 +int misc_init_r(void)
213 +{
214 + return 0;
215 +}
216 +
217 +int ft_board_setup(void *fdt, struct bd_info *bd)
218 +{
219 + printf("Northstar board setup: DTB at 0x%08lx\n", (ulong)fdt);
220 + return 0;
221 +}
222 +
223 --- /dev/null
224 +++ b/configs/bcmns_defconfig
225 @@ -0,0 +1,41 @@
226 +CONFIG_ARM=y
227 +CONFIG_TARGET_BCMNS=y
228 +CONFIG_TEXT_BASE=0x00008000
229 +CONFIG_SYS_MALLOC_LEN=0x2000000
230 +CONFIG_SYS_MALLOC_F_LEN=0x8000
231 +CONFIG_NR_DRAM_BANKS=2
232 +CONFIG_DEFAULT_DEVICE_TREE="ns-board"
233 +CONFIG_IDENT_STRING="Broadcom Northstar"
234 +CONFIG_SYS_LOAD_ADDR=0x00008000
235 +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
236 +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x00100000
237 +# CONFIG_BOOTSTD is not set
238 +CONFIG_AUTOBOOT_KEYED=y
239 +CONFIG_AUTOBOOT_PROMPT="Boot Northstar system in %d seconds\n"
240 +CONFIG_BOOTDELAY=1
241 +CONFIG_USE_BOOTCOMMAND=y
242 +CONFIG_BOOTCOMMAND="run bootcmd_dlink_dir8xxl"
243 +CONFIG_SYS_PROMPT="northstar> "
244 +CONFIG_ENV_VARS_UBOOT_CONFIG=y
245 +CONFIG_OF_BOARD_SETUP=y
246 +CONFIG_OF_STDOUT_VIA_ALIAS=y
247 +CONFIG_DISPLAY_BOARDINFO_LATE=y
248 +CONFIG_HUSH_PARSER=y
249 +CONFIG_SYS_MAXARGS=64
250 +CONFIG_CMD_SEAMA=y
251 +CONFIG_CMD_BOOTZ=y
252 +CONFIG_CMD_CACHE=y
253 +CONFIG_OF_EMBED=y
254 +CONFIG_USE_HOSTNAME=y
255 +CONFIG_HOSTNAME="NS"
256 +CONFIG_CLK=y
257 +CONFIG_MTD=y
258 +CONFIG_DM_MTD=y
259 +CONFIG_MTD_RAW_NAND=y
260 +CONFIG_NAND_BRCMNAND=y
261 +CONFIG_SYS_NAND_ONFI_DETECTION=y
262 +CONFIG_CMD_NAND=y
263 +CONFIG_DM_SERIAL=y
264 +CONFIG_SYS_NS16550=y
265 +# CONFIG_NET is not set
266 +# CONFIG_EFI_LOADER is not set
267 --- a/doc/board/broadcom/index.rst
268 +++ b/doc/board/broadcom/index.rst
269 @@ -9,3 +9,4 @@ Broadcom
270
271 bcm7xxx
272 raspberrypi
273 + northstar
274 --- /dev/null
275 +++ b/doc/board/broadcom/northstar.rst
276 @@ -0,0 +1,44 @@
277 +.. SPDX-License-Identifier: GPL-2.0+
278 +.. Copyright (C) 2023 Linus Walleij <linus.walleij@linaro.org>
279 +
280 +Broadcom Northstar Boards
281 +=========================
282 +
283 +This document describes how to use U-Boot on the Broadcom Northstar
284 +boards, comprised of the Cortex A9 ARM-based BCM470x and BCM5301x SoCs. These
285 +were introduced in 2012-2013 and some of them are also called StrataGX.
286 +
287 +Northstar is part of the iProc SoC family.
288 +
289 +A good overview of these boards can be found in Jon Mason's presentation
290 +"Enabling New Hardware in U-Boot" where the difference between Northstar
291 +and Northstar Plus and Northstar 2 (Aarch64) is addressed.
292 +
293 +The ROM in the Northstar SoC will typically look into NOR flash memory
294 +for a boot loader, and the way this works is undocumented. It should be
295 +possible to execute U-Boot as the first binary from the NOR flash but
296 +this usage path is unexplored. Please add information if you know more.
297 +
298 +D-Link Boards
299 +-------------
300 +
301 +When we use U-Boot with D-Link routers, the NOR flash has a boot loader
302 +and web server that can re-flash the bigger NAND flash memory for object
303 +code in the SEAMA format, so on these platforms U-Boot is converted into
304 +a SEAMA binary and installed in the SoC using the flash tool resident in
305 +the NOR flash. Details can be found in the OpenWrt project codebase.
306 +
307 +Configure
308 +---------
309 +
310 +.. code-block:: console
311 +
312 + $ make CROSS_COMPILE=${CROSS_COMPILE} bcmns_defconfig
313 +
314 +Build
315 +-----
316 +
317 +.. code-block:: console
318 +
319 + $ make CROSS_COMPILE=${CROSS_COMPILE}
320 + $ ${CROSS_COMPILE}strip u-boot
321 --- /dev/null
322 +++ b/include/configs/bcmns.h
323 @@ -0,0 +1,49 @@
324 +/* SPDX-License-Identifier: GPL-2.0+ */
325 +
326 +#ifndef __BCM_NS_H
327 +#define __BCM_NS_H
328 +
329 +#include <linux/sizes.h>
330 +
331 +/* Physical Memory Map */
332 +#define V2M_BASE 0x00000000
333 +#define PHYS_SDRAM_1 V2M_BASE
334 +
335 +#define CFG_SYS_SDRAM_BASE PHYS_SDRAM_1
336 +
337 +/* Called "periph_clk" in Linux, used by the global timer */
338 +#define CFG_SYS_HZ_CLOCK 500000000
339 +
340 +/* Called "iprocslow" in Linux */
341 +#define CFG_SYS_NS16550_CLK 125000000
342 +
343 +/* console configuration */
344 +#define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
345 +#define MAX_CPUS "max_cpus=maxcpus=2\0"
346 +#define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x18000300\0"
347 +
348 +#define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
349 + " ${max_cpus} ${log_level} ${reserved_mem}"
350 +#define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS "\0"
351 +
352 +#define KERNEL_LOADADDR_CFG \
353 + "loadaddr=0x01000000\0" \
354 + "dtb_loadaddr=0x02000000\0"
355 +
356 +/*
357 + * Hardcoded for the only boards we support, if you add more
358 + * boards, add a more clever bootcmd!
359 + */
360 +#define NS_BOOTCMD "bootcmd_dlink_dir8xxl=seama 0x00fe0000; go 0x01000000"
361 +
362 +#define ARCH_ENV_SETTINGS \
363 + CONSOLE_ARGS \
364 + MAX_CPUS \
365 + EXTRA_ARGS \
366 + KERNEL_LOADADDR_CFG \
367 + NS_BOOTCMD
368 +
369 +#define CFG_EXTRA_ENV_SETTINGS \
370 + ARCH_ENV_SETTINGS
371 +
372 +#endif /* __BCM_NS_H */