1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2012-2015 Panasonic Corporation
4  * Copyright (C) 2015-2016 Socionext Inc.
5  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
6  */
7 
8 /* U-Boot - Common settings for UniPhier Family */
9 
10 #ifndef __CONFIG_UNIPHIER_H__
11 #define __CONFIG_UNIPHIER_H__
12 
13 #ifndef CONFIG_SPL_BUILD
14 #include <config_distro_bootcmd.h>
15 
16 #ifdef CONFIG_CMD_MMC
17 #define BOOT_TARGET_DEVICE_MMC(func)	func(MMC, mmc, 0) func(MMC, mmc, 1)
18 #else
19 #define BOOT_TARGET_DEVICE_MMC(func)
20 #endif
21 
22 #ifdef CONFIG_CMD_UBIFS
23 #define BOOT_TARGET_DEVICE_UBIFS(func)	func(UBIFS, ubifs, 0)
24 #else
25 #define BOOT_TARGET_DEVICE_UBIFS(func)
26 #endif
27 
28 #ifdef CONFIG_CMD_USB
29 #define BOOT_TARGET_DEVICE_USB(func)	func(USB, usb, 0)
30 #else
31 #define BOOT_TARGET_DEVICE_USB(func)
32 #endif
33 
34 #define BOOT_TARGET_DEVICES(func)	\
35 	BOOT_TARGET_DEVICE_MMC(func)	\
36 	BOOT_TARGET_DEVICE_UBIFS(func)	\
37 	BOOT_TARGET_DEVICE_USB(func)
38 #else
39 #define BOOTENV
40 #endif
41 
42 #define CONFIG_SYS_MALLOC_LEN		(4 * 1024 * 1024)
43 
44 #define CONFIG_TIMESTAMP
45 
46 #define CONFIG_SYS_MONITOR_BASE		0
47 #define CONFIG_SYS_MONITOR_LEN		0x00200000	/* 2MB */
48 
49 #define CONFIG_SYS_CBSIZE		1024	/* Console I/O Buffer Size */
50 /* Boot Argument Buffer Size */
51 #define CONFIG_SYS_BARGSIZE		(CONFIG_SYS_CBSIZE)
52 
53 #if !defined(CONFIG_ARM64)
54 /* Time clock 1MHz */
55 #define CONFIG_SYS_TIMER_RATE			1000000
56 #endif
57 
58 #define CONFIG_SYS_MAX_NAND_DEVICE			1
59 #define CONFIG_SYS_NAND_ONFI_DETECTION
60 #define CONFIG_SYS_NAND_REGS_BASE			0x68100000
61 #define CONFIG_SYS_NAND_DATA_BASE			0x68000000
62 #define CONFIG_SYS_NAND_BAD_BLOCK_POS			0
63 
64 /*
65  * Network Configuration
66  */
67 #define CONFIG_SERVERIP			192.168.11.1
68 #define CONFIG_IPADDR			192.168.11.10
69 #define CONFIG_GATEWAYIP		192.168.11.1
70 #define CONFIG_NETMASK			255.255.255.0
71 
72 #define CONFIG_SYS_LOAD_ADDR		0x85000000
73 #define CONFIG_SYS_BOOTM_LEN		(32 << 20)
74 
75 #if defined(CONFIG_ARM64)
76 /* ARM Trusted Firmware */
77 #define BOOT_IMAGES \
78 	"second_image=unph_bl.bin\0" \
79 	"third_image=fip.bin\0"
80 #else
81 #define BOOT_IMAGES \
82 	"second_image=u-boot-spl.bin\0" \
83 	"third_image=u-boot.bin\0"
84 #endif
85 
86 #define CONFIG_ROOTPATH			"/nfs/root/path"
87 #define CONFIG_NFSBOOTCOMMAND						\
88 	"setenv bootargs $bootargs root=/dev/nfs rw "			\
89 	"nfsroot=$serverip:$rootpath "					\
90 	"ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off;" \
91 		"run __nfsboot"
92 
93 #ifdef CONFIG_FIT
94 #define CONFIG_BOOTFILE			"fitImage"
95 #define KERNEL_ADDR_R_OFFSET		"0x05100000"
96 #define LINUXBOOT_ENV_SETTINGS \
97 	"tftpboot=tftpboot $kernel_addr_r $bootfile &&" \
98 		"bootm $kernel_addr_r\0" \
99 	"__nfsboot=run tftpboot\0"
100 #else
101 #ifdef CONFIG_ARM64
102 #define CONFIG_BOOTFILE			"Image"
103 #define LINUXBOOT_CMD			"booti"
104 #define KERNEL_ADDR_R_OFFSET		"0x02080000"
105 #else
106 #define CONFIG_BOOTFILE			"zImage"
107 #define LINUXBOOT_CMD			"bootz"
108 #define KERNEL_ADDR_R_OFFSET		"0x00208000"
109 #endif
110 #define LINUXBOOT_ENV_SETTINGS \
111 	"boot_common=setexpr bootm_low $kernel_addr_r '&' fe000000 && " \
112 		LINUXBOOT_CMD " $kernel_addr_r $ramdisk_addr_r $fdt_addr_r\0" \
113 	"tftpboot=tftpboot $kernel_addr_r $bootfile && " \
114 		"tftpboot $fdt_addr_r $fdtfile &&" \
115 		"tftpboot $ramdisk_addr_r $ramdisk_file &&" \
116 		"setenv ramdisk_addr_r $ramdisk_addr_r:$filesize &&" \
117 		"run boot_common\0" \
118 	"__nfsboot=tftpboot $kernel_addr_load $bootfile && " \
119 		"tftpboot $fdt_addr_r $fdtfile &&" \
120 		"setenv ramdisk_addr_r - &&" \
121 		"run boot_common\0"
122 #endif
123 
124 #define	CONFIG_EXTRA_ENV_SETTINGS				\
125 	"fdt_addr_r_offset=0x05100000\0" \
126 	"kernel_addr_r_offset=" KERNEL_ADDR_R_OFFSET "\0" \
127 	"ramdisk_addr_r_offset=0x06000000\0" \
128 	"ramdisk_file=rootfs.cpio.gz\0" \
129 	"netdev=eth0\0"						\
130 	"initrd_high=0xffffffffffffffff\0"			\
131 	"loadaddr_offset=0x05000000\0" \
132 	"script=boot.scr\0" \
133 	"scriptaddr=0x85000000\0"				\
134 	"nor_base=0x42000000\0"					\
135 	"emmcboot=mmcsetn && run bootcmd_mmc${mmc_first_dev}\0" \
136 	"nandboot=run bootcmd_ubifs0\0" \
137 	"norboot=run tftpboot\0" \
138 	"sdboot=sdsetn && run bootcmd_mmc${sd_first_dev}\0" \
139 	"usbboot=run bootcmd_usb0\0" \
140 	"emmcscript=setenv devtype mmc && " \
141 		"mmcsetn && " \
142 		"setenv devnum ${mmc_first_dev} && " \
143 		"run loadscript_fat\0" \
144 	"nandscript=echo Running ${script} from ubi ... && " \
145 		"ubi part UBI && " \
146 		"ubifsmount ubi0:boot && " \
147 		"ubifsload ${loadaddr} ${script} && " \
148 		"source $loadaddr\0" \
149 	"sdscript=setenv devtype mmc && " \
150 		"sdsetn && " \
151 		"setenv devnum ${sd_first_dev} && " \
152 		"run loadscript_fat\0" \
153 	"norscript=echo Running ${script} from tftp ... && " \
154 		"tftpboot ${script} &&" \
155 		"source $loadaddr\0" \
156 	"usbscript=usb start && " \
157 		"setenv devtype usb && " \
158 		"setenv devnum 0 && " \
159 		"run loadscript_fat\0" \
160 	"loadscript_fat=echo Running ${script} from ${devtype}${devnum} ... && " \
161 		"load ${devtype} ${devnum}:1 ${loadaddr} ${script} && " \
162 		"source $loadaddr\0" \
163 	"sramupdate=setexpr tmp_addr $nor_base + 0x50000 &&"	\
164 		"tftpboot $tmp_addr $second_image && " \
165 		"setexpr tmp_addr $nor_base + 0x70000 && " \
166 		"tftpboot $tmp_addr $third_image\0" \
167 	"emmcupdate=mmcsetn &&"					\
168 		"mmc dev $mmc_first_dev &&"			\
169 		"mmc partconf $mmc_first_dev 0 1 1 &&"		\
170 		"tftpboot $second_image && " \
171 		"mmc write $loadaddr 0 100 && " \
172 		"tftpboot $third_image && " \
173 		"mmc write $loadaddr 100 f00\0" \
174 	"nandupdate=nand erase 0 0x00100000 &&"			\
175 		"tftpboot $second_image && " \
176 		"nand write $loadaddr 0 0x00020000 && " \
177 		"tftpboot $third_image && " \
178 		"nand write $loadaddr 0x00020000 0x001e0000\0" \
179 	"sdupdate=sdsetn &&" \
180 		"mmc dev $sd_first_dev &&" \
181 		"tftpboot $second_image && " \
182 		"mmc write $loadaddr 0 100 && " \
183 		"tftpboot $third_image && " \
184 		"mmc write $loadaddr 100 f00\0" \
185 	"usbupdate=usb start &&" \
186 		"tftpboot $second_image && " \
187 		"usb write $loadaddr 0 100 && " \
188 		"tftpboot $third_image && " \
189 		"usb write $loadaddr 100 f00\0" \
190 	BOOT_IMAGES \
191 	LINUXBOOT_ENV_SETTINGS \
192 	BOOTENV
193 
194 #define CONFIG_SYS_BOOTMAPSZ			0x20000000
195 
196 #define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_TEXT_BASE)
197 
198 /* only for SPL */
199 #define CONFIG_SPL_STACK		(0x00100000)
200 
201 #define CONFIG_SYS_NAND_U_BOOT_OFFS		0x20000
202 
203 /* subtract sizeof(struct image_header) */
204 #define CONFIG_SYS_UBOOT_BASE			(0x130000 - 0x40)
205 
206 #define CONFIG_SPL_TARGET			"u-boot-with-spl.bin"
207 #define CONFIG_SPL_MAX_FOOTPRINT		0x10000
208 #define CONFIG_SPL_MAX_SIZE			0x10000
209 #define CONFIG_SPL_BSS_MAX_SIZE			0x2000
210 
211 #define CONFIG_SPL_PAD_TO			0x20000
212 
213 #endif /* __CONFIG_UNIPHIER_H__ */
214