1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2007-2008
4  * Stelian Pop <stelian@popies.net>
5  * Lead Tech Design <www.leadtechdesign.com>
6  *
7  * (C) Copyright 2010
8  * Achim Ehrlich <aehrlich@taskit.de>
9  * taskit GmbH <www.taskit.de>
10  *
11  * (C) Copyright 2012
12  * Markus Hubig <mhubig@imko.de>
13  * IMKO GmbH <www.imko.de>
14  *
15  * (C) Copyright 2014
16  * Heiko Schocher <hs@denx.de>
17  * DENX Software Engineering GmbH
18  *
19  * Configuation settings for the smartweb.
20  */
21 
22 #ifndef __CONFIG_H
23 #define __CONFIG_H
24 
25 /*
26  * SoC must be defined first, before hardware.h is included.
27  * In this case SoC is defined in boards.cfg.
28  */
29 #include <asm/hardware.h>
30 #include <linux/sizes.h>
31 
32 /*
33  * Warning: changing CONFIG_SYS_TEXT_BASE requires adapting the initial boot
34  * program. Since the linker has to swallow that define, we must use a pure
35  * hex number here!
36  */
37 
38 /* ARM asynchronous clock */
39 #define CONFIG_SYS_AT91_SLOW_CLOCK	32768		/* slow clock xtal */
40 #define CONFIG_SYS_AT91_MAIN_CLOCK	18432000	/* 18.432MHz crystal */
41 
42 /* misc settings */
43 #define CONFIG_CMDLINE_TAG		/* pass commandline to Kernel */
44 #define CONFIG_SETUP_MEMORY_TAGS	/* pass memory defs to kernel */
45 #define CONFIG_INITRD_TAG		/* pass initrd param to kernel */
46 #define CONFIG_SKIP_LOWLEVEL_INIT_ONLY	/* U-Boot is loaded by a bootloader */
47 
48 /* We set the max number of command args high to avoid HUSH bugs. */
49 #define CONFIG_SYS_MAXARGS    32
50 
51 /* setting board specific options */
52 #define CONFIG_MACH_TYPE		MACH_TYPE_SMARTWEB
53 #define CONFIG_SYS_AUTOLOAD "yes"
54 #define CONFIG_RESET_TO_RETRY
55 
56 /* The LED PINs */
57 #define CONFIG_RED_LED			AT91_PIN_PA9
58 #define CONFIG_GREEN_LED		AT91_PIN_PA6
59 
60 /*
61  * SDRAM: 1 bank, 64 MB, base address 0x20000000
62  * Already initialized before u-boot gets started.
63  */
64 #define CONFIG_SYS_SDRAM_BASE		ATMEL_BASE_CS1
65 #define CONFIG_SYS_SDRAM_SIZE		(64 * SZ_1M)
66 
67 /*
68  * Perform a SDRAM Memtest from the start of SDRAM
69  * till the beginning of the U-Boot position in RAM.
70  */
71 
72 /* Size of malloc() pool */
73 #define CONFIG_SYS_MALLOC_LEN \
74 	ROUND(3 * CONFIG_ENV_SIZE + (4 * SZ_1M), 0x1000)
75 
76 /* NAND flash settings */
77 #define CONFIG_SYS_MAX_NAND_DEVICE	1
78 #define CONFIG_SYS_NAND_BASE		ATMEL_BASE_CS3
79 #define CONFIG_SYS_NAND_DBW_8
80 #define CONFIG_SYS_NAND_MASK_ALE	(1 << 21)
81 #define CONFIG_SYS_NAND_MASK_CLE	(1 << 22)
82 #define CONFIG_SYS_NAND_ENABLE_PIN	AT91_PIN_PC14
83 #define CONFIG_SYS_NAND_READY_PIN	AT91_PIN_PC13
84 
85 /* general purpose I/O */
86 #define CONFIG_ATMEL_LEGACY		/* required until (g)pio is fixed */
87 #define CONFIG_AT91_GPIO_PULLUP	1	/* keep pullups on peripheral pins */
88 
89 /* serial console */
90 #define CONFIG_USART_BASE		ATMEL_BASE_DBGU
91 #define CONFIG_USART_ID			ATMEL_ID_SYS
92 
93 /*
94  * Ethernet configuration
95  *
96  */
97 #define CONFIG_MACB
98 #define CONFIG_RMII			/* use reduced MII inteface */
99 #define CONFIG_NET_RETRY_COUNT	20      /* # of DHCP/BOOTP retries */
100 #define CONFIG_AT91_WANTS_COMMON_PHY
101 
102 /* BOOTP and DHCP options */
103 #define CONFIG_BOOTP_BOOTFILESIZE
104 #define CONFIG_NFSBOOTCOMMAND						\
105 	"setenv autoload yes; setenv autoboot yes; "			\
106 	"setenv bootargs ${basicargs} ${mtdparts} "			\
107 	"root=/dev/nfs ip=dhcp nfsroot=${serverip}:/srv/nfs/rootfs; "	\
108 	"dhcp"
109 
110 #if !defined(CONFIG_SPL_BUILD)
111 /* USB configuration */
112 #define CONFIG_USB_ATMEL
113 #define CONFIG_USB_ATMEL_CLK_SEL_PLLB
114 #define CONFIG_USB_OHCI_NEW
115 #define CONFIG_SYS_USB_OHCI_CPU_INIT
116 #define CONFIG_SYS_USB_OHCI_REGS_BASE	ATMEL_UHP_BASE
117 #define CONFIG_SYS_USB_OHCI_SLOT_NAME	"at91sam9260"
118 #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS	2
119 
120 /* USB DFU support */
121 
122 #define CONFIG_USB_GADGET_AT91
123 
124 /* DFU class support */
125 #define CONFIG_SYS_DFU_DATA_BUF_SIZE	SZ_1M
126 #define DFU_MANIFEST_POLL_TIMEOUT	25000
127 #endif
128 
129 /* General Boot Parameter */
130 #define CONFIG_BOOTCOMMAND		"run flashboot"
131 #define CONFIG_SYS_CBSIZE		512
132 
133 /*
134  * RAM Memory address where to put the
135  * Linux Kernel befor starting.
136  */
137 #define CONFIG_SYS_LOAD_ADDR		0x22000000
138 
139 /*
140  * The NAND Flash partitions:
141  */
142 #define CONFIG_ENV_RANGE		(SZ_512K)
143 
144 /*
145  * Predefined environment variables.
146  * Usefull to define some easy to use boot commands.
147  */
148 #define	CONFIG_EXTRA_ENV_SETTINGS					\
149 									\
150 	"basicargs=console=ttyS0,115200\0"				\
151 									\
152 	"mtdparts="CONFIG_MTDPARTS_DEFAULT"\0"
153 
154 #ifdef CONFIG_SPL_BUILD
155 #define CONFIG_SYS_INIT_SP_ADDR		0x301000
156 #define CONFIG_SPL_STACK_R
157 #define CONFIG_SPL_STACK_R_ADDR		CONFIG_SYS_TEXT_BASE
158 #else
159 /*
160  * Initial stack pointer: 4k - GENERATED_GBL_DATA_SIZE in internal SRAM,
161  * leaving the correct space for initial global data structure above that
162  * address while providing maximum stack area below.
163  */
164 #define CONFIG_SYS_INIT_SP_ADDR \
165 	(ATMEL_BASE_SRAM1 + 0x1000 - GENERATED_GBL_DATA_SIZE)
166 #endif
167 
168 /* Defines for SPL */
169 #define CONFIG_SPL_MAX_SIZE		(SZ_4K)
170 
171 #define CONFIG_SPL_BSS_START_ADDR	CONFIG_SYS_SDRAM_BASE
172 #define CONFIG_SPL_BSS_MAX_SIZE		(SZ_16K)
173 #define CONFIG_SYS_SPL_MALLOC_START     (CONFIG_SPL_BSS_START_ADDR + \
174 					CONFIG_SPL_BSS_MAX_SIZE)
175 #define CONFIG_SYS_SPL_MALLOC_SIZE      CONFIG_SYS_MALLOC_LEN
176 
177 #define CONFIG_SYS_NAND_ENABLE_PIN_SPL	(2*32 + 14)
178 #define CONFIG_SYS_USE_NANDFLASH	1
179 #define CONFIG_SPL_NAND_RAW_ONLY
180 #define CONFIG_SPL_NAND_SOFTECC
181 #define CONFIG_SYS_NAND_U_BOOT_OFFS	0x20000
182 #define CONFIG_SYS_NAND_U_BOOT_SIZE	SZ_512K
183 #define	CONFIG_SYS_NAND_U_BOOT_START	CONFIG_SYS_TEXT_BASE
184 #define CONFIG_SYS_NAND_U_BOOT_DST	CONFIG_SYS_TEXT_BASE
185 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
186 
187 #define CONFIG_SYS_NAND_SIZE		(SZ_256M)
188 #define CONFIG_SYS_NAND_PAGE_SIZE	SZ_2K
189 #define CONFIG_SYS_NAND_BLOCK_SIZE	(SZ_128K)
190 #define CONFIG_SYS_NAND_PAGE_COUNT	(CONFIG_SYS_NAND_BLOCK_SIZE / \
191 					 CONFIG_SYS_NAND_PAGE_SIZE)
192 #define CONFIG_SYS_NAND_BAD_BLOCK_POS	NAND_LARGE_BADBLOCK_POS
193 #define CONFIG_SYS_NAND_ECCSIZE		256
194 #define CONFIG_SYS_NAND_ECCBYTES	3
195 #define CONFIG_SYS_NAND_OOBSIZE		64
196 #define CONFIG_SYS_NAND_ECCPOS		{ 40, 41, 42, 43, 44, 45, 46, 47, \
197 					  48, 49, 50, 51, 52, 53, 54, 55, \
198 					  56, 57, 58, 59, 60, 61, 62, 63, }
199 
200 #define CONFIG_SPL_ATMEL_SIZE
201 #define CONFIG_SYS_MASTER_CLOCK		(198656000/2)
202 #define AT91_PLL_LOCK_TIMEOUT		1000000
203 #define CONFIG_SYS_AT91_PLLA		0x2060bf09
204 #define CONFIG_SYS_MCKR			0x100
205 #define CONFIG_SYS_MCKR_CSS		(0x02 | CONFIG_SYS_MCKR)
206 #define CONFIG_SYS_AT91_PLLB		0x10483f0e
207 
208 #define CONFIG_SPL_PAD_TO		CONFIG_SYS_NAND_U_BOOT_OFFS
209 #define CONFIG_SYS_SPL_LEN		CONFIG_SPL_PAD_TO
210 
211 #endif /* __CONFIG_H */
212