aa38b2745e3d45b70f5afaa6a0aa664da3c6e6b2
[openwrt/staging/robimarko.git] /
1 From 47b386259625061b376f538055a4f3fbd0ab7fef Mon Sep 17 00:00:00 2001
2 From: Weijie Gao <weijie.gao@mediatek.com>
3 Date: Wed, 3 Mar 2021 10:48:53 +0800
4 Subject: [PATCH 17/21] board: mt7629: add support for booting from SPI-NAND
5
6 Add support for mt7629 to boot from SPI-NAND.
7 Add a new defconfig for mt7629+spi-nand configuration.
8
9 Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
10 ---
11 arch/arm/dts/mt7629-rfb-u-boot.dtsi | 8 ++
12 arch/arm/dts/mt7629-rfb.dts | 10 +++
13 arch/arm/dts/mt7629.dtsi | 16 ++++
14 board/mediatek/mt7629/Kconfig | 35 ++++++++-
15 configs/mt7629_nand_rfb_defconfig | 111 ++++++++++++++++++++++++++++
16 include/configs/mt7629.h | 7 ++
17 6 files changed, 186 insertions(+), 1 deletion(-)
18 create mode 100644 configs/mt7629_nand_rfb_defconfig
19
20 --- a/arch/arm/dts/mt7629-rfb-u-boot.dtsi
21 +++ b/arch/arm/dts/mt7629-rfb-u-boot.dtsi
22 @@ -40,3 +40,11 @@
23 &snfi {
24 u-boot,dm-pre-reloc;
25 };
26 +
27 +&pinctrl {
28 + u-boot,dm-pre-reloc;
29 +};
30 +
31 +&snand {
32 + u-boot,dm-pre-reloc;
33 +};
34 --- a/arch/arm/dts/mt7629-rfb.dts
35 +++ b/arch/arm/dts/mt7629-rfb.dts
36 @@ -47,9 +47,12 @@
37 };
38
39 snfi_pins: snfi-pins {
40 + u-boot,dm-pre-reloc;
41 +
42 mux {
43 function = "flash";
44 groups = "snfi";
45 + u-boot,dm-pre-reloc;
46 };
47 };
48
49 @@ -102,6 +105,13 @@
50 };
51 };
52
53 +&snand {
54 + pinctrl-names = "default";
55 + pinctrl-0 = <&snfi_pins>;
56 + status = "okay";
57 + quad-spi;
58 +};
59 +
60 &uart0 {
61 pinctrl-names = "default";
62 pinctrl-0 = <&uart0_pins>;
63 --- a/arch/arm/dts/mt7629.dtsi
64 +++ b/arch/arm/dts/mt7629.dtsi
65 @@ -229,6 +229,22 @@
66 #size-cells = <0>;
67 };
68
69 + snand: snand@1100d000 {
70 + compatible = "mediatek,mt7629-snand";
71 + reg = <0x1100d000 0x1000>,
72 + <0x1100e000 0x1000>;
73 + reg-names = "nfi", "ecc";
74 + clocks = <&pericfg CLK_PERI_NFI_PD>,
75 + <&pericfg CLK_PERI_SNFI_PD>,
76 + <&pericfg CLK_PERI_NFIECC_PD>;
77 + clock-names = "nfi_clk", "pad_clk", "ecc_clk";
78 + assigned-clocks = <&topckgen CLK_TOP_AXI_SEL>,
79 + <&topckgen CLK_TOP_NFI_INFRA_SEL>;
80 + assigned-clock-parents = <&topckgen CLK_TOP_SYSPLL1_D2>,
81 + <&topckgen CLK_TOP_UNIVPLL2_D8>;
82 + status = "disabled";
83 + };
84 +
85 snor: snor@11014000 {
86 compatible = "mediatek,mtk-snor";
87 reg = <0x11014000 0x1000>;
88 --- a/board/mediatek/mt7629/Kconfig
89 +++ b/board/mediatek/mt7629/Kconfig
90 @@ -12,6 +12,39 @@ config MTK_SPL_PAD_SIZE
91
92 config MTK_BROM_HEADER_INFO
93 string
94 - default "media=nor"
95 + default "media=nor" if BOOT_FROM_SNOR
96 + default "media=snand;nandinfo=2k+64" if BOOT_FROM_SNAND_2K_64
97 + default "media=snand;nandinfo=2k+128" if BOOT_FROM_SNAND_2K_128
98 + default "media=snand;nandinfo=4k+128" if BOOT_FROM_SNAND_4K_128
99 + default "media=snand;nandinfo=4k+256" if BOOT_FROM_SNAND_4K_256
100 +
101 +choice
102 + prompt "Boot device"
103 + default BOOT_FROM_SNOR
104 +
105 +config BOOT_FROM_SNOR
106 + bool "SPI-NOR"
107 +
108 +config BOOT_FROM_SNAND_2K_64
109 + bool "SPI-NAND (2K+64)"
110 + select MT7629_BOOT_FROM_SNAND
111 +
112 +config BOOT_FROM_SNAND_2K_128
113 + bool "SPI-NAND (2K+128)"
114 + select MT7629_BOOT_FROM_SNAND
115 +
116 +config BOOT_FROM_SNAND_4K_128
117 + bool "SPI-NAND (4K+128)"
118 + select MT7629_BOOT_FROM_SNAND
119 +
120 +config BOOT_FROM_SNAND_4K_256
121 + bool "SPI-NAND (4K+256)"
122 + select MT7629_BOOT_FROM_SNAND
123 +
124 +endchoice
125 +
126 +config MT7629_BOOT_FROM_SNAND
127 + bool
128 + default n
129
130 endif
131 --- /dev/null
132 +++ b/configs/mt7629_nand_rfb_defconfig
133 @@ -0,0 +1,111 @@
134 +CONFIG_ARM=y
135 +CONFIG_SYS_ARCH_TIMER=y
136 +CONFIG_SYS_THUMB_BUILD=y
137 +CONFIG_ARCH_MEDIATEK=y
138 +CONFIG_SYS_TEXT_BASE=0x41e00000
139 +CONFIG_SYS_MALLOC_F_LEN=0x4000
140 +CONFIG_NR_DRAM_BANKS=1
141 +CONFIG_ENV_SIZE=0x20000
142 +CONFIG_ENV_OFFSET=0x100000
143 +CONFIG_SPL_TEXT_BASE=0x201000
144 +CONFIG_TARGET_MT7629=y
145 +CONFIG_BOOT_FROM_SNAND_2K_64=y
146 +CONFIG_SPL_SERIAL_SUPPORT=y
147 +CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
148 +CONFIG_SPL_STACK_R_ADDR=0x40800000
149 +CONFIG_SPL_PAYLOAD="u-boot.img"
150 +CONFIG_BUILD_TARGET="u-boot-mtk.bin"
151 +CONFIG_DEFAULT_DEVICE_TREE="mt7629-rfb"
152 +CONFIG_SPL_IMAGE="spl/u-boot-spl-mtk.bin"
153 +CONFIG_FIT=y
154 +CONFIG_FIT_VERBOSE=y
155 +CONFIG_BOOTDELAY=3
156 +CONFIG_DEFAULT_FDT_FILE="mt7629-rfb"
157 +CONFIG_SYS_CONSOLE_IS_IN_ENV=y
158 +CONFIG_SYS_STDIO_DEREGISTER=y
159 +# CONFIG_DISPLAY_BOARDINFO is not set
160 +CONFIG_SPL_SYS_MALLOC_SIMPLE=y
161 +CONFIG_SPL_STACK_R=y
162 +CONFIG_SPL_MTD_SUPPORT=y
163 +CONFIG_SPL_NAND_SUPPORT=y
164 +CONFIG_SPL_WATCHDOG_SUPPORT=y
165 +CONFIG_HUSH_PARSER=y
166 +CONFIG_SYS_PROMPT="U-Boot> "
167 +CONFIG_CMD_BOOTMENU=y
168 +# CONFIG_BOOTM_NETBSD is not set
169 +# CONFIG_BOOTM_PLAN9 is not set
170 +# CONFIG_BOOTM_RTEMS is not set
171 +# CONFIG_BOOTM_VXWORKS is not set
172 +# CONFIG_CMD_ELF is not set
173 +# CONFIG_CMD_XIMG is not set
174 +CONFIG_CMD_BIND=y
175 +CONFIG_CMD_DM=y
176 +# CONFIG_CMD_FLASH is not set
177 +CONFIG_CMD_GPIO=y
178 +CONFIG_CMD_MTD=y
179 +CONFIG_CMD_USB=y
180 +# CONFIG_CMD_SETEXPR is not set
181 +# CONFIG_CMD_NFS is not set
182 +CONFIG_CMD_PING=y
183 +CONFIG_CMD_FAT=y
184 +CONFIG_CMD_FS_GENERIC=y
185 +CONFIG_CMD_LOG=y
186 +CONFIG_EFI_PARTITION=y
187 +# CONFIG_SPL_PARTITION_UUIDS is not set
188 +CONFIG_PARTITION_TYPE_GUID=y
189 +CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent assigned-clocks assigned-clock-parents"
190 +CONFIG_ENV_OVERWRITE=y
191 +CONFIG_ENV_IS_IN_MTD=y
192 +CONFIG_ENV_MTD_NAME="spi-nand0"
193 +CONFIG_ENV_SIZE_REDUND=0x40000
194 +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
195 +CONFIG_NET_RANDOM_ETHADDR=y
196 +CONFIG_SPL_DM_SEQ_ALIAS=y
197 +CONFIG_REGMAP=y
198 +CONFIG_SPL_REGMAP=y
199 +CONFIG_SYSCON=y
200 +CONFIG_SPL_SYSCON=y
201 +CONFIG_BLK=y
202 +CONFIG_CLK=y
203 +CONFIG_SPL_CLK=y
204 +# CONFIG_MMC is not set
205 +CONFIG_MTD=y
206 +CONFIG_DM_MTD=y
207 +CONFIG_MTK_SPI_NAND=y
208 +CONFIG_MTK_SPI_NAND_MTD=y
209 +CONFIG_SPL_MTK_SPI_NAND=y
210 +CONFIG_DM_ETH=y
211 +CONFIG_MEDIATEK_ETH=y
212 +CONFIG_PHY=y
213 +CONFIG_PHY_MTK_TPHY=y
214 +CONFIG_PINCTRL=y
215 +CONFIG_PINCONF=y
216 +CONFIG_SPL_PINCTRL=y
217 +CONFIG_SPL_PINCONF=y
218 +CONFIG_PINCTRL_MT7629=y
219 +CONFIG_POWER_DOMAIN=y
220 +CONFIG_MTK_POWER_DOMAIN=y
221 +CONFIG_DM_REGULATOR=y
222 +CONFIG_DM_REGULATOR_FIXED=y
223 +CONFIG_RAM=y
224 +CONFIG_SPL_RAM=y
225 +CONFIG_DM_SERIAL=y
226 +CONFIG_MTK_SERIAL=y
227 +CONFIG_SPI=y
228 +CONFIG_DM_SPI=y
229 +CONFIG_SPI_MEM=y
230 +CONFIG_MTK_SNFI_SPI=y
231 +CONFIG_SYSRESET=y
232 +CONFIG_SPL_SYSRESET=y
233 +CONFIG_SYSRESET_WATCHDOG=y
234 +CONFIG_USB=y
235 +CONFIG_DM_USB=y
236 +# CONFIG_SPL_DM_USB is not set
237 +CONFIG_USB_XHCI_HCD=y
238 +CONFIG_USB_XHCI_MTK=y
239 +CONFIG_USB_STORAGE=y
240 +CONFIG_WDT_MTK=y
241 +CONFIG_FAT_WRITE=y
242 +CONFIG_LZMA=y
243 +CONFIG_SPL_LZMA=y
244 +# CONFIG_EFI_LOADER is not set
245 --- a/include/configs/mt7629.h
246 +++ b/include/configs/mt7629.h
247 @@ -30,12 +30,19 @@
248
249 /* Defines for SPL */
250 #define CONFIG_SPL_STACK 0x106000
251 +#ifdef CONFIG_MT7629_BOOT_FROM_SNAND
252 +#define CONFIG_SPL_MAX_SIZE SZ_128K
253 +#define CONFIG_SPL_MAX_FOOTPRINT SZ_128K
254 +#define CONFIG_SPL_PAD_TO 0x20000
255 +#define CONFIG_SYS_NAND_U_BOOT_OFFS CONFIG_SPL_PAD_TO
256 +#else
257 #define CONFIG_SPL_MAX_SIZE SZ_64K
258 #define CONFIG_SPL_MAX_FOOTPRINT SZ_64K
259 #define CONFIG_SPL_PAD_TO 0x10000
260
261 #define CONFIG_SPI_ADDR 0x30000000
262 #define CONFIG_SYS_UBOOT_BASE (CONFIG_SPI_ADDR + CONFIG_SPL_PAD_TO)
263 +#endif
264
265 /* SPL -> Uboot */
266 #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE + SZ_2M - \