xref: /rk3399_rockchip-uboot/include/configs/xtfpga.h (revision 0e13c182e0b4ee5b7e5efee72614cd23f8a5e6fc)
1*7e270ec3SChris Zankel /*
2*7e270ec3SChris Zankel  * Copyright (C) 2007-2013 Tensilica, Inc.
3*7e270ec3SChris Zankel  * Copyright (C) 2014 - 2016 Cadence Design Systems Inc.
4*7e270ec3SChris Zankel  *
5*7e270ec3SChris Zankel  * SPDX-License-Identifier:	GPL-2.0+
6*7e270ec3SChris Zankel  */
7*7e270ec3SChris Zankel 
8*7e270ec3SChris Zankel #ifndef __CONFIG_H
9*7e270ec3SChris Zankel #define __CONFIG_H
10*7e270ec3SChris Zankel 
11*7e270ec3SChris Zankel #include <asm/arch/core.h>
12*7e270ec3SChris Zankel #include <asm/addrspace.h>
13*7e270ec3SChris Zankel #include <asm/config.h>
14*7e270ec3SChris Zankel 
15*7e270ec3SChris Zankel /*
16*7e270ec3SChris Zankel  * The 'xtfpga' board describes a set of very similar boards with only minimal
17*7e270ec3SChris Zankel  * differences.
18*7e270ec3SChris Zankel  */
19*7e270ec3SChris Zankel 
20*7e270ec3SChris Zankel /*=====================*/
21*7e270ec3SChris Zankel /* Board and Processor */
22*7e270ec3SChris Zankel /*=====================*/
23*7e270ec3SChris Zankel 
24*7e270ec3SChris Zankel #define CONFIG_XTFPGA
25*7e270ec3SChris Zankel 
26*7e270ec3SChris Zankel /* FPGA CPU freq after init */
27*7e270ec3SChris Zankel #define CONFIG_SYS_CLK_FREQ		(gd->cpu_clk)
28*7e270ec3SChris Zankel 
29*7e270ec3SChris Zankel /*===================*/
30*7e270ec3SChris Zankel /* RAM Layout        */
31*7e270ec3SChris Zankel /*===================*/
32*7e270ec3SChris Zankel 
33*7e270ec3SChris Zankel #if XCHAL_HAVE_PTP_MMU
34*7e270ec3SChris Zankel #define CONFIG_SYS_MEMORY_BASE		\
35*7e270ec3SChris Zankel 	(XCHAL_VECBASE_RESET_VADDR - XCHAL_VECBASE_RESET_PADDR)
36*7e270ec3SChris Zankel #define CONFIG_SYS_IO_BASE		0xf0000000
37*7e270ec3SChris Zankel #else
38*7e270ec3SChris Zankel #define CONFIG_SYS_MEMORY_BASE		0x60000000
39*7e270ec3SChris Zankel #define CONFIG_SYS_IO_BASE		0x90000000
40*7e270ec3SChris Zankel #define CONFIG_MAX_MEM_MAPPED		0x10000000
41*7e270ec3SChris Zankel #endif
42*7e270ec3SChris Zankel 
43*7e270ec3SChris Zankel /* Onboard RAM sizes:
44*7e270ec3SChris Zankel  *
45*7e270ec3SChris Zankel  * LX60		0x04000000		  64 MB
46*7e270ec3SChris Zankel  * LX110	0x03000000		  48 MB
47*7e270ec3SChris Zankel  * LX200	0x06000000		  96 MB
48*7e270ec3SChris Zankel  * ML605	0x18000000		 384 MB
49*7e270ec3SChris Zankel  * KC705	0x38000000		 896 MB
50*7e270ec3SChris Zankel  *
51*7e270ec3SChris Zankel  * noMMU configurations can only see first 256MB of onboard memory.
52*7e270ec3SChris Zankel  */
53*7e270ec3SChris Zankel 
54*7e270ec3SChris Zankel #if XCHAL_HAVE_PTP_MMU || CONFIG_BOARD_SDRAM_SIZE < 0x10000000
55*7e270ec3SChris Zankel #define CONFIG_SYS_SDRAM_SIZE		CONFIG_BOARD_SDRAM_SIZE
56*7e270ec3SChris Zankel #else
57*7e270ec3SChris Zankel #define CONFIG_SYS_SDRAM_SIZE		0x10000000
58*7e270ec3SChris Zankel #endif
59*7e270ec3SChris Zankel 
60*7e270ec3SChris Zankel #define CONFIG_SYS_SDRAM_BASE		MEMADDR(0x00000000)
61*7e270ec3SChris Zankel 
62*7e270ec3SChris Zankel /* Lx60 can only map 128kb memory (instead of 256kb) when running under OCD */
63*7e270ec3SChris Zankel #ifdef CONFIG_XTFPGA_LX60
64*7e270ec3SChris Zankel # define CONFIG_SYS_MONITOR_LEN		0x00020000	/* 128KB */
65*7e270ec3SChris Zankel #else
66*7e270ec3SChris Zankel # define CONFIG_SYS_MONITOR_LEN		0x00040000	/* 256KB */
67*7e270ec3SChris Zankel #endif
68*7e270ec3SChris Zankel 
69*7e270ec3SChris Zankel #define CONFIG_SYS_MALLOC_LEN		(256 << 10)	/* heap  256KB */
70*7e270ec3SChris Zankel 
71*7e270ec3SChris Zankel /* Linux boot param area in RAM (used only when booting linux) */
72*7e270ec3SChris Zankel #define CONFIG_SYS_BOOTPARAMS_LEN	(64  << 10)
73*7e270ec3SChris Zankel 
74*7e270ec3SChris Zankel /* Memory test is destructive so default must not overlap vectors or U-Boot*/
75*7e270ec3SChris Zankel #define CONFIG_SYS_MEMTEST_START	MEMADDR(0x01000000)
76*7e270ec3SChris Zankel #define CONFIG_SYS_MEMTEST_END		MEMADDR(0x02000000)
77*7e270ec3SChris Zankel 
78*7e270ec3SChris Zankel /* Load address for stand-alone applications.
79*7e270ec3SChris Zankel  * MEMADDR cannot be used here, because the definition needs to be
80*7e270ec3SChris Zankel  * a plain number as it's used as -Ttext argument for ld in standalone
81*7e270ec3SChris Zankel  * example makefile.
82*7e270ec3SChris Zankel  * Handle noMMU vs MMUv2 vs MMUv3 distinction here manually.
83*7e270ec3SChris Zankel  */
84*7e270ec3SChris Zankel #if XCHAL_HAVE_PTP_MMU
85*7e270ec3SChris Zankel #if XCHAL_VECBASE_RESET_VADDR == XCHAL_VECBASE_RESET_PADDR
86*7e270ec3SChris Zankel #define CONFIG_STANDALONE_LOAD_ADDR	0x00800000
87*7e270ec3SChris Zankel #else
88*7e270ec3SChris Zankel #define CONFIG_STANDALONE_LOAD_ADDR	0xd0800000
89*7e270ec3SChris Zankel #endif
90*7e270ec3SChris Zankel #else
91*7e270ec3SChris Zankel #define CONFIG_STANDALONE_LOAD_ADDR	0x60800000
92*7e270ec3SChris Zankel #endif
93*7e270ec3SChris Zankel 
94*7e270ec3SChris Zankel #if defined(CONFIG_MAX_MEM_MAPPED) && \
95*7e270ec3SChris Zankel 	CONFIG_MAX_MEM_MAPPED < CONFIG_SYS_SDRAM_SIZE
96*7e270ec3SChris Zankel #define CONFIG_SYS_MEMORY_SIZE		CONFIG_MAX_MEM_MAPPED
97*7e270ec3SChris Zankel #else
98*7e270ec3SChris Zankel #define CONFIG_SYS_MEMORY_SIZE		CONFIG_SYS_SDRAM_SIZE
99*7e270ec3SChris Zankel #endif
100*7e270ec3SChris Zankel 
101*7e270ec3SChris Zankel #define CONFIG_SYS_MEMORY_TOP		MEMADDR(CONFIG_SYS_MEMORY_SIZE)
102*7e270ec3SChris Zankel #define CONFIG_SYS_TEXT_ADDR		\
103*7e270ec3SChris Zankel 	(CONFIG_SYS_MEMORY_TOP - CONFIG_SYS_MONITOR_LEN)
104*7e270ec3SChris Zankel 
105*7e270ec3SChris Zankel /* Used by tftpboot; env var 'loadaddr' */
106*7e270ec3SChris Zankel #define CONFIG_SYS_LOAD_ADDR		MEMADDR(0x02000000)
107*7e270ec3SChris Zankel 
108*7e270ec3SChris Zankel /*==============================*/
109*7e270ec3SChris Zankel /* U-Boot general configuration */
110*7e270ec3SChris Zankel /*==============================*/
111*7e270ec3SChris Zankel 
112*7e270ec3SChris Zankel #define CONFIG_BOARD_POSTCLK_INIT
113*7e270ec3SChris Zankel #define CONFIG_MISC_INIT_R
114*7e270ec3SChris Zankel 
115*7e270ec3SChris Zankel #define CONFIG_BOOTFILE			"uImage"
116*7e270ec3SChris Zankel 	/* Console I/O Buffer Size  */
117*7e270ec3SChris Zankel #define CONFIG_SYS_CBSIZE		1024
118*7e270ec3SChris Zankel 	/* Boot Argument Buffer Size */
119*7e270ec3SChris Zankel #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE
120*7e270ec3SChris Zankel 
121*7e270ec3SChris Zankel /*==============================*/
122*7e270ec3SChris Zankel /* U-Boot autoboot configuration */
123*7e270ec3SChris Zankel /*==============================*/
124*7e270ec3SChris Zankel 
125*7e270ec3SChris Zankel #define CONFIG_BOOT_RETRY_TIME		60	/* retry after 60 secs */
126*7e270ec3SChris Zankel 
127*7e270ec3SChris Zankel #define CONFIG_AUTO_COMPLETE			/* Support tab autocompletion */
128*7e270ec3SChris Zankel #define CONFIG_CMDLINE_EDITING
129*7e270ec3SChris Zankel #define CONFIG_SYS_LONGHELP
130*7e270ec3SChris Zankel #define CONFIG_MX_CYCLIC
131*7e270ec3SChris Zankel #define CONFIG_SHOW_BOOT_PROGRESS
132*7e270ec3SChris Zankel 
133*7e270ec3SChris Zankel 
134*7e270ec3SChris Zankel /*=========================================*/
135*7e270ec3SChris Zankel /* FPGA Registers (board info and control) */
136*7e270ec3SChris Zankel /*=========================================*/
137*7e270ec3SChris Zankel 
138*7e270ec3SChris Zankel /*
139*7e270ec3SChris Zankel  * These assume FPGA bitstreams from Tensilica release RB and up. Earlier
140*7e270ec3SChris Zankel  * releases may not provide any/all of these registers or at these offsets.
141*7e270ec3SChris Zankel  * Some of the FPGA registers are broken down into bitfields described by
142*7e270ec3SChris Zankel  * SHIFT left amount and field WIDTH (bits), and also by a bitMASK.
143*7e270ec3SChris Zankel  */
144*7e270ec3SChris Zankel 
145*7e270ec3SChris Zankel /* Date of FPGA bitstream build in binary coded decimal (BCD) */
146*7e270ec3SChris Zankel #define CONFIG_SYS_FPGAREG_DATE		IOADDR(0x0D020000)
147*7e270ec3SChris Zankel #define FPGAREG_MTH_SHIFT		24		/* BCD month 1..12 */
148*7e270ec3SChris Zankel #define FPGAREG_MTH_WIDTH		8
149*7e270ec3SChris Zankel #define FPGAREG_MTH_MASK		0xFF000000
150*7e270ec3SChris Zankel #define FPGAREG_DAY_SHIFT		16		/* BCD day 1..31 */
151*7e270ec3SChris Zankel #define FPGAREG_DAY_WIDTH		8
152*7e270ec3SChris Zankel #define FPGAREG_DAY_MASK		0x00FF0000
153*7e270ec3SChris Zankel #define FPGAREG_YEAR_SHIFT		0		/* BCD year 2001..9999*/
154*7e270ec3SChris Zankel #define FPGAREG_YEAR_WIDTH		16
155*7e270ec3SChris Zankel #define FPGAREG_YEAR_MASK		0x0000FFFF
156*7e270ec3SChris Zankel 
157*7e270ec3SChris Zankel /* FPGA core clock frequency in Hz (also input to UART) */
158*7e270ec3SChris Zankel #define CONFIG_SYS_FPGAREG_FREQ	IOADDR(0x0D020004)	/* CPU clock frequency*/
159*7e270ec3SChris Zankel 
160*7e270ec3SChris Zankel /*
161*7e270ec3SChris Zankel  * DIP switch (left=sw1=lsb=bit0, right=sw8=msb=bit7; off=0, on=1):
162*7e270ec3SChris Zankel  *   Bits 0..5 set the lower 6 bits of the default ethernet MAC.
163*7e270ec3SChris Zankel  *   Bit 6 is reserved for future use by Tensilica.
164*7e270ec3SChris Zankel  *   Bit 7 maps the first 128KB of ROM address space at CONFIG_SYS_ROM_BASE to
165*7e270ec3SChris Zankel  *   the base of flash * (when on/1) or to the base of RAM (when off/0).
166*7e270ec3SChris Zankel  */
167*7e270ec3SChris Zankel #define CONFIG_SYS_FPGAREG_DIPSW	IOADDR(0x0D02000C)
168*7e270ec3SChris Zankel #define FPGAREG_MAC_SHIFT		0	/* Ethernet MAC bits 0..5 */
169*7e270ec3SChris Zankel #define FPGAREG_MAC_WIDTH		6
170*7e270ec3SChris Zankel #define FPGAREG_MAC_MASK		0x3f
171*7e270ec3SChris Zankel #define FPGAREG_BOOT_SHIFT		7	/* Boot ROM addr mapping */
172*7e270ec3SChris Zankel #define FPGAREG_BOOT_WIDTH		1
173*7e270ec3SChris Zankel #define FPGAREG_BOOT_MASK		0x80
174*7e270ec3SChris Zankel #define FPGAREG_BOOT_RAM		0
175*7e270ec3SChris Zankel #define FPGAREG_BOOT_FLASH		(1<<FPGAREG_BOOT_SHIFT)
176*7e270ec3SChris Zankel 
177*7e270ec3SChris Zankel /* Force hard reset of board by writing a code to this register */
178*7e270ec3SChris Zankel #define CONFIG_SYS_FPGAREG_RESET	IOADDR(0x0D020010) /* Reset board .. */
179*7e270ec3SChris Zankel #define CONFIG_SYS_FPGAREG_RESET_CODE	0x0000DEAD   /*  by writing this code */
180*7e270ec3SChris Zankel 
181*7e270ec3SChris Zankel /*====================*/
182*7e270ec3SChris Zankel /* Serial Driver Info */
183*7e270ec3SChris Zankel /*====================*/
184*7e270ec3SChris Zankel 
185*7e270ec3SChris Zankel #define CONFIG_SYS_NS16550_SERIAL
186*7e270ec3SChris Zankel #define CONFIG_SYS_NS16550_REG_SIZE	(-4)
187*7e270ec3SChris Zankel #define CONFIG_SYS_NS16550_COM1		IOADDR(0x0D050020) /* Base address */
188*7e270ec3SChris Zankel 
189*7e270ec3SChris Zankel /* Input clk to NS16550 (in Hz; the SYS_CLK_FREQ is in kHz) */
190*7e270ec3SChris Zankel #define CONFIG_SYS_NS16550_CLK		CONFIG_SYS_CLK_FREQ
191*7e270ec3SChris Zankel #define CONFIG_CONS_INDEX		1	/* use UART0 for console */
192*7e270ec3SChris Zankel #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200 }
193*7e270ec3SChris Zankel 
194*7e270ec3SChris Zankel /*======================*/
195*7e270ec3SChris Zankel /* Ethernet Driver Info */
196*7e270ec3SChris Zankel /*======================*/
197*7e270ec3SChris Zankel 
198*7e270ec3SChris Zankel #define CONFIG_ETHBASE			00:50:C2:13:6f:00
199*7e270ec3SChris Zankel #define CONFIG_SYS_ETHOC_BASE		IOADDR(0x0d030000)
200*7e270ec3SChris Zankel #define CONFIG_SYS_ETHOC_BUFFER_ADDR	IOADDR(0x0D800000)
201*7e270ec3SChris Zankel 
202*7e270ec3SChris Zankel /*=====================*/
203*7e270ec3SChris Zankel /* Flash & Environment */
204*7e270ec3SChris Zankel /*=====================*/
205*7e270ec3SChris Zankel 
206*7e270ec3SChris Zankel #define CONFIG_SYS_FLASH_CFI
207*7e270ec3SChris Zankel #define CONFIG_FLASH_CFI_DRIVER			/* use generic CFI driver */
208*7e270ec3SChris Zankel #define CONFIG_SYS_FLASH_CFI_WIDTH	FLASH_CFI_16BIT
209*7e270ec3SChris Zankel #define CONFIG_SYS_MAX_FLASH_BANKS	1
210*7e270ec3SChris Zankel #ifdef CONFIG_XTFPGA_LX60
211*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_SIZE		0x0040000	/* 4MB */
212*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_SECT_SZ	0x10000		/* block size 64KB */
213*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_PARMSECT_SZ	0x2000		/* param size  8KB */
214*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_BASE		IOADDR(0x08000000)
215*7e270ec3SChris Zankel # define CONFIG_SYS_MONITOR_BASE	CONFIG_SYS_FLASH_BASE
216*7e270ec3SChris Zankel #elif defined(CONFIG_XTFPGA_KC705)
217*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_SIZE		0x8000000	/* 128MB */
218*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_SECT_SZ	0x20000		/* block size 128KB */
219*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_PARMSECT_SZ	0x8000		/* param size 32KB */
220*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_BASE		IOADDR(0x00000000)
221*7e270ec3SChris Zankel # define CONFIG_SYS_MONITOR_BASE	IOADDR(0x06000000)
222*7e270ec3SChris Zankel #else
223*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_SIZE		0x1000000	/* 16MB */
224*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_SECT_SZ	0x20000		/* block size 128KB */
225*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_PARMSECT_SZ	0x8000		/* param size 32KB */
226*7e270ec3SChris Zankel # define CONFIG_SYS_FLASH_BASE		IOADDR(0x08000000)
227*7e270ec3SChris Zankel # define CONFIG_SYS_MONITOR_BASE	CONFIG_SYS_FLASH_BASE
228*7e270ec3SChris Zankel #endif
229*7e270ec3SChris Zankel #define CONFIG_SYS_MAX_FLASH_SECT	\
230*7e270ec3SChris Zankel 	(CONFIG_SYS_FLASH_SECT_SZ/CONFIG_SYS_FLASH_PARMSECT_SZ + \
231*7e270ec3SChris Zankel 	 CONFIG_SYS_FLASH_SIZE/CONFIG_SYS_FLASH_SECT_SZ - 1)
232*7e270ec3SChris Zankel #define CONFIG_SYS_FLASH_PROTECTION		/* hw flash protection */
233*7e270ec3SChris Zankel 
234*7e270ec3SChris Zankel /*
235*7e270ec3SChris Zankel  * Put environment in top block (64kB)
236*7e270ec3SChris Zankel  * Another option would be to put env. in 2nd param block offs 8KB, size 8KB
237*7e270ec3SChris Zankel  */
238*7e270ec3SChris Zankel #define CONFIG_ENV_OFFSET    (CONFIG_SYS_FLASH_SIZE - CONFIG_SYS_FLASH_SECT_SZ)
239*7e270ec3SChris Zankel #define CONFIG_ENV_SIZE	     CONFIG_SYS_FLASH_SECT_SZ
240*7e270ec3SChris Zankel 
241*7e270ec3SChris Zankel /* print 'E' for empty sector on flinfo */
242*7e270ec3SChris Zankel #define CONFIG_SYS_FLASH_EMPTY_INFO
243*7e270ec3SChris Zankel 
244*7e270ec3SChris Zankel #endif /* __CONFIG_H */
245