0005-board-Add-new-Broadcom-Northstar-board.patch 9.6 KB

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