uboot-d1: add bootloader for upcoming d1 target
[openwrt/staging/mans0n.git] / package / boot / uboot-d1 / patches / 0079-riscv-Add-CONFIG_TARGET_SUN20I_D1.patch
1 From 6b0c83a5c7b9189fb1c5cf56145ec4882d9e5588 Mon Sep 17 00:00:00 2001
2 From: Zoltan HERPAI <wigyori@uid0.hu>
3 Date: Tue, 6 Jun 2023 18:13:34 +0000
4 Subject: [PATCH 79/90] riscv: Add CONFIG_TARGET_SUN20I_D1
5
6 Signed-off-by: Samuel Holland <samuel@sholland.org>
7 Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
8 ---
9 arch/riscv/Kconfig | 5 +++++
10 board/sunxi/Kconfig | 30 +++++++++++++++++++++++++++---
11 common/spl/Kconfig | 1 +
12 drivers/clk/sunxi/Kconfig | 1 +
13 include/configs/sun20i.h | 11 +++++++++++
14 5 files changed, 45 insertions(+), 3 deletions(-)
15 create mode 100644 include/configs/sun20i.h
16
17 --- a/arch/riscv/Kconfig
18 +++ b/arch/riscv/Kconfig
19 @@ -31,6 +31,11 @@ config TARGET_SIPEED_MAIX
20 bool "Support Sipeed Maix Board"
21 select SYS_CACHE_SHIFT_6
22
23 +config TARGET_SUN20I_D1
24 + bool "Support Allwinner D1 Boards"
25 + select BOARD_SUNXI
26 + select SYS_CACHE_SHIFT_6
27 +
28 endchoice
29
30 config SYS_ICACHE_OFF
31 --- a/board/sunxi/Kconfig
32 +++ b/board/sunxi/Kconfig
33 @@ -13,8 +13,18 @@ config BOARD_SUNXI
34 select DM_SERIAL if SERIAL
35 select DM_SPI if SPI
36 select DM_SPI_FLASH if SPI
37 + select GENERIC_RISCV if RISCV
38 select OF_BOARD_SETUP
39 select PINCTRL
40 + select RAM if SPL_DM
41 + select SPL_CLK if SPL_DM
42 + select SPL_DM if RISCV && SPL
43 + select SPL_DM_SPI if SPL_DM && SPL_SPI
44 + select SPL_DM_SPI_FLASH if SPL_DM && SPL_SPI
45 + select SPL_OF_CONTROL if SPL_DM
46 + select SPL_PINCTRL if SPL_DM
47 + select SPL_PINCONF if SPL_DM
48 + select SPL_RAM if SPL_DM
49 select SPL_SEPARATE_BSS if SPL
50 select SUPPORT_SPL
51 select SYS_RELOC_GD_ENV_ADDR
52 @@ -28,12 +38,14 @@ config BOARD_SUNXI
53 imply DISTRO_DEFAULTS
54 imply FAT_WRITE
55 imply FIT
56 + imply MMC
57 imply OF_LIBFDT_OVERLAY
58 imply PRE_CONSOLE_BUFFER
59 imply SPL
60 imply SPL_GPIO
61 imply SPL_LIBCOMMON_SUPPORT
62 imply SPL_LIBGENERIC_SUPPORT
63 + imply SPL_LOAD_FIT
64 imply SPL_MMC if MMC
65 imply SPL_POWER
66 imply SPL_SERIAL
67 @@ -41,6 +53,7 @@ config BOARD_SUNXI
68 imply SYS_I2C_MVTWSI
69 imply SYS_NS16550
70 imply SYSRESET
71 + imply SYSRESET_SBI
72 imply SYSRESET_WATCHDOG
73 imply SYSRESET_WATCHDOG_AUTO
74 imply USB_EHCI_GENERIC
75 @@ -67,6 +80,12 @@ config SPL_BSS_START_ADDR
76 default 0x4ff80000 if SUNXI_MINIMUM_DRAM_MB >= 256
77 default 0x43f80000 if SUNXI_MINIMUM_DRAM_MB >= 64
78
79 +config SPL_OPENSBI_LOAD_ADDR
80 + default 0x40000000 if RISCV
81 +
82 +config SPL_STACK
83 + default 0x48000 if TARGET_SUN20I_D1
84 +
85 config SPL_STACK_R_ADDR
86 default 0x81e00000 if MACH_SUNIV
87 default 0x2fe00000 if MACH_SUN9I
88 @@ -75,13 +94,13 @@ config SPL_STACK_R_ADDR
89
90 config SPL_TEXT_BASE
91 default 0x10060 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5
92 - default 0x20060 if SUN50I_GEN_H6
93 + default 0x20060 if SUN50I_GEN_H6 || TARGET_SUN20I_D1
94 default 0x00060
95
96 config SUNXI_MINIMUM_DRAM_MB
97 int
98 default 32 if MACH_SUNIV
99 - default 64 if MACH_SUN8I_V3S
100 + default 64 if MACH_SUN8I_V3S || TARGET_SUN20I_D1
101 default 256
102 help
103 Minimum DRAM size expected on the board. Traditionally we
104 @@ -94,7 +113,7 @@ config SUNXI_MINIMUM_DRAM_MB
105 config SUNXI_SRAM_ADDRESS
106 hex
107 default 0x10000 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5
108 - default 0x20000 if SUN50I_GEN_H6
109 + default 0x20000 if SUN50I_GEN_H6 || TARGET_SUN20I_D1
110 default 0x0
111 help
112 Older Allwinner SoCs have their boot mask ROM mapped just
113 @@ -113,6 +132,7 @@ config SYS_CLK_FREQ
114 default 912000000 if MACH_SUN7I
115 default 1008000000 if MACH_SUN8I
116 default 1008000000 if MACH_SUN9I
117 + default 1008000000 if TARGET_SUN20I_D1
118 default 816000000 if MACH_SUN50I || MACH_SUN50I_H5
119 default 888000000 if MACH_SUN50I_H6
120 default 1008000000 if MACH_SUN50I_H616
121 @@ -125,10 +145,14 @@ config SYS_CONFIG_NAME
122 default "sun7i" if MACH_SUN7I
123 default "sun8i" if MACH_SUN8I
124 default "sun9i" if MACH_SUN9I
125 + default "sun20i" if TARGET_SUN20I_D1
126 default "sun50i" if MACH_SUN50I
127 default "sun50i" if MACH_SUN50I_H6
128 default "sun50i" if MACH_SUN50I_H616
129
130 +config SYS_CPU
131 + default "generic" if TARGET_SUN20I_D1
132 +
133 config SYS_LOAD_ADDR
134 default 0x81000000 if MACH_SUNIV
135 default 0x22000000 if MACH_SUN9I
136 --- a/common/spl/Kconfig
137 +++ b/common/spl/Kconfig
138 @@ -78,6 +78,7 @@ config SPL_MAX_SIZE
139 hex "Maximum size of the SPL image, excluding BSS"
140 default 0x37fa0 if MACH_SUN50I_H616
141 default 0x30000 if ARCH_MX6 && MX6_OCRAM_256KB
142 + default 0x27fa0 if TARGET_SUN20I_D1
143 default 0x25fa0 if MACH_SUN50I_H6
144 default 0x1b000 if AM33XX && !TI_SECURE_DEVICE
145 default 0x10000 if ARCH_MX6 && !MX6_OCRAM_256KB
146 --- a/drivers/clk/sunxi/Kconfig
147 +++ b/drivers/clk/sunxi/Kconfig
148 @@ -98,6 +98,7 @@ config CLK_SUN8I_H3
149
150 config CLK_SUN20I_D1
151 bool "Clock driver for Allwinner D1"
152 + default TARGET_SUN20I_D1
153 help
154 This enables common clock driver support for platforms based
155 on Allwinner D1 SoC.
156 --- /dev/null
157 +++ b/include/configs/sun20i.h
158 @@ -0,0 +1,11 @@
159 +/* SPDX-License-Identifier: GPL-2.0+ */
160 +/*
161 + * Placeholder wrapper to allow addressing Allwinner D1 (and later) sun20i
162 + * CPU based devices separately. Please do not add anything in here.
163 + */
164 +#ifndef __CONFIG_H
165 +#define __CONFIG_H
166 +
167 +#include <configs/sunxi-common.h>
168 +
169 +#endif /* __CONFIG_H */