mx28evk: Introduce a new target for saving env vars to NAND
[oweals/u-boot.git] / include / configs / mx28evk.h
1 /*
2  * (C) Copyright 2011 Freescale Semiconductor, Inc.
3  * Author: Fabio Estevam <fabio.estevam@freescale.com>
4  *
5  * Based on m28evk.h:
6  * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
7  * on behalf of DENX Software Engineering GmbH
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  */
19 #ifndef __MX28EVK_CONFIG_H__
20 #define __MX28EVK_CONFIG_H__
21
22 /* SoC configurations */
23 #define CONFIG_MX28                             /* i.MX28 SoC */
24
25 #define CONFIG_MXS_GPIO                 /* GPIO control */
26 #define CONFIG_SYS_HZ           1000            /* Ticks per second */
27
28 #define CONFIG_MACH_TYPE        MACH_TYPE_MX28EVK
29
30 #include <asm/arch/regs-base.h>
31
32 #define CONFIG_SYS_NO_FLASH
33 #define CONFIG_BOARD_EARLY_INIT_F
34 #define CONFIG_ARCH_MISC_INIT
35
36 /* SPL */
37 #define CONFIG_SPL
38 #define CONFIG_SPL_NO_CPU_SUPPORT_CODE
39 #define CONFIG_SPL_START_S_PATH "arch/arm/cpu/arm926ejs/mxs"
40 #define CONFIG_SPL_LDSCRIPT     "arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds"
41 #define CONFIG_SPL_LIBCOMMON_SUPPORT
42 #define CONFIG_SPL_LIBGENERIC_SUPPORT
43 #define CONFIG_SPL_GPIO_SUPPORT
44
45 /* U-Boot Commands */
46 #include <config_cmd_default.h>
47 #define CONFIG_DISPLAY_CPUINFO
48 #define CONFIG_DOS_PARTITION
49
50 #define CONFIG_CMD_CACHE
51 #define CONFIG_CMD_DATE
52 #define CONFIG_CMD_DHCP
53 #define CONFIG_CMD_FAT
54 #define CONFIG_CMD_GPIO
55 #define CONFIG_CMD_MII
56 #define CONFIG_CMD_MMC
57 #define CONFIG_CMD_NET
58 #define CONFIG_CMD_NFS
59 #define CONFIG_CMD_PING
60 #define CONFIG_CMD_SETEXPR
61 #define CONFIG_CMD_SF
62 #define CONFIG_CMD_SPI
63 #define CONFIG_CMD_USB
64 #define CONFIG_CMD_BOOTZ
65 #define CONFIG_CMD_NAND
66
67 /* Memory configurations */
68 #define CONFIG_NR_DRAM_BANKS            1               /* 1 bank of DRAM */
69 #define PHYS_SDRAM_1                    0x40000000      /* Base address */
70 #define PHYS_SDRAM_1_SIZE               0x40000000      /* Max 1 GB RAM */
71 #define CONFIG_SYS_MALLOC_LEN           0x00400000      /* 4 MB for malloc */
72 #define CONFIG_SYS_MEMTEST_START        0x40000000      /* Memtest start adr */
73 #define CONFIG_SYS_MEMTEST_END          0x40400000      /* 4 MB RAM test */
74 #define CONFIG_SYS_SDRAM_BASE           PHYS_SDRAM_1
75 /* Point initial SP in SRAM so SPL can use it too. */
76
77 #define CONFIG_SYS_INIT_RAM_ADDR        0x00000000
78 #define CONFIG_SYS_INIT_RAM_SIZE        (128 * 1024)
79
80 #define CONFIG_SYS_INIT_SP_OFFSET \
81         (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
82 #define CONFIG_SYS_INIT_SP_ADDR \
83         (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
84
85 /*
86  * We need to sacrifice first 4 bytes of RAM here to avoid triggering some
87  * strange BUG in ROM corrupting first 4 bytes of RAM when loading U-Boot
88  * binary. In case there was more of this mess, 0x100 bytes are skipped.
89  */
90 #define CONFIG_SYS_TEXT_BASE    0x40000100
91
92 #define CONFIG_ENV_OVERWRITE
93 /* U-Boot general configurations */
94 #define CONFIG_SYS_LONGHELP
95 #define CONFIG_SYS_PROMPT       "MX28EVK U-Boot > "
96 #define CONFIG_SYS_CBSIZE       1024            /* Console I/O buffer size */
97 #define CONFIG_SYS_PBSIZE       \
98         (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
99                                                 /* Print buffer size */
100 #define CONFIG_SYS_MAXARGS      32              /* Max number of command args */
101 #define CONFIG_SYS_BARGSIZE     CONFIG_SYS_CBSIZE
102                                                 /* Boot argument buffer size */
103 #define CONFIG_VERSION_VARIABLE /* U-BOOT version */
104 #define CONFIG_AUTO_COMPLETE            /* Command auto complete */
105 #define CONFIG_CMDLINE_EDITING          /* Command history etc */
106 #define CONFIG_SYS_HUSH_PARSER
107
108 /* Serial Driver */
109 #define CONFIG_PL011_SERIAL
110 #define CONFIG_PL011_CLOCK              24000000
111 #define CONFIG_PL01x_PORTS              { (void *)MXS_UARTDBG_BASE }
112 #define CONFIG_CONS_INDEX               0
113 #define CONFIG_BAUDRATE                 115200  /* Default baud rate */
114
115 /* DMA */
116 #define CONFIG_APBH_DMA
117
118 /* MMC Driver */
119 #ifdef CONFIG_ENV_IS_IN_MMC
120  #define CONFIG_ENV_OFFSET      (256 * 1024)
121  #define CONFIG_ENV_SIZE        (16 * 1024)
122  #define CONFIG_SYS_MMC_ENV_DEV 0
123 #endif
124 #define CONFIG_CMD_SAVEENV
125 #ifdef  CONFIG_CMD_MMC
126 #define CONFIG_MMC
127 #define CONFIG_GENERIC_MMC
128 #define CONFIG_BOUNCE_BUFFER
129 #define CONFIG_MXS_MMC
130 #endif
131
132 /* NAND Driver */
133 #define CONFIG_ENV_SIZE                 (16 * 1024)
134 #ifdef CONFIG_CMD_NAND
135 #define CONFIG_NAND_MXS
136 #define CONFIG_SYS_MAX_NAND_DEVICE      1
137 #define CONFIG_SYS_NAND_BASE            0x60000000
138 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
139
140 /* Environment is in NAND */
141 #define CONFIG_ENV_SIZE_REDUND          CONFIG_ENV_SIZE
142 #define CONFIG_ENV_SECT_SIZE            (128 * 1024)
143 #define CONFIG_ENV_RANGE                (512 * 1024)
144 #ifndef CONFIG_ENV_OFFSET
145 #define CONFIG_ENV_OFFSET               0x300000
146 #endif
147 #define CONFIG_ENV_OFFSET_REDUND        \
148                 (CONFIG_ENV_OFFSET + CONFIG_ENV_RANGE)
149
150 #define CONFIG_CMD_UBI
151 #define CONFIG_CMD_UBIFS
152 #define CONFIG_CMD_MTDPARTS
153 #define CONFIG_RBTREE
154 #define CONFIG_LZO
155 #define CONFIG_MTD_DEVICE
156 #define CONFIG_MTD_PARTITIONS
157 #define MTDIDS_DEFAULT                  "nand0=gpmi-nand"
158 #define MTDPARTS_DEFAULT                        \
159         "mtdparts=gpmi-nand:"                   \
160                 "3m(bootloader)ro,"             \
161                 "512k(environment),"            \
162                 "512k(redundant-environment),"  \
163                 "4m(kernel),"                   \
164                 "128k(fdt),"                    \
165                 "8m(ramdisk),"                  \
166                 "-(filesystem)"
167 #endif
168
169 /* Ethernet on SOC (FEC) */
170 #ifdef  CONFIG_CMD_NET
171 #define CONFIG_NET_MULTI
172 #define CONFIG_ETHPRIME "FEC0"
173 #define CONFIG_FEC_MXC
174 #define CONFIG_MII
175 #define CONFIG_FEC_XCV_TYPE     RMII
176 #define CONFIG_MX28_FEC_MAC_IN_OCOTP
177 #endif
178
179 /* RTC */
180 #ifdef  CONFIG_CMD_DATE
181 #define CONFIG_RTC_MXS
182 #endif
183
184 /* USB */
185 #ifdef  CONFIG_CMD_USB
186 #define CONFIG_USB_EHCI
187 #define CONFIG_USB_EHCI_MXS
188 #define CONFIG_EHCI_MXS_PORT1
189 #define CONFIG_USB_MAX_CONTROLLER_COUNT 1
190 #define CONFIG_EHCI_IS_TDI
191 #define CONFIG_USB_STORAGE
192 #define CONFIG_USB_HOST_ETHER
193 #define CONFIG_USB_ETHER_ASIX
194 #define CONFIG_USB_ETHER_SMSC95XX
195 #endif
196
197 /* I2C */
198 #ifdef CONFIG_CMD_I2C
199 #define CONFIG_I2C_MXS
200 #define CONFIG_HARD_I2C
201 #define CONFIG_SYS_I2C_SPEED    400000
202 #endif
203
204 /* SPI */
205 #ifdef CONFIG_CMD_SPI
206 #define CONFIG_HARD_SPI
207 #define CONFIG_MXS_SPI
208 #define CONFIG_SPI_HALF_DUPLEX
209 #define CONFIG_DEFAULT_SPI_BUS          2
210 #define CONFIG_DEFAULT_SPI_MODE         SPI_MODE_0
211
212 /* SPI Flash */
213 #ifdef CONFIG_CMD_SF
214 #define CONFIG_SPI_FLASH
215 #define CONFIG_SF_DEFAULT_BUS   2
216 #define CONFIG_SF_DEFAULT_CS    0
217 /* this may vary and depends on the installed chip */
218 #define CONFIG_SPI_FLASH_SST
219 #define CONFIG_SF_DEFAULT_MODE          SPI_MODE_0
220 #define CONFIG_SF_DEFAULT_SPEED         24000000
221
222 /* (redundant) environemnt in SPI flash */
223 #ifdef CONFIG_ENV_IS_IN_SPI_FLASH
224 #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
225 #define CONFIG_ENV_SIZE                 0x1000          /* 4KB */
226 #define CONFIG_ENV_OFFSET               0x40000         /* 256K */
227 #define CONFIG_ENV_OFFSET_REDUND        (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
228 #define CONFIG_ENV_SECT_SIZE            0x1000
229 #define CONFIG_ENV_SPI_CS               0
230 #define CONFIG_ENV_SPI_BUS              2
231 #define CONFIG_ENV_SPI_MAX_HZ           24000000
232 #define CONFIG_ENV_SPI_MODE             SPI_MODE_0
233 #endif
234 #endif
235 #endif
236
237 /* Boot Linux */
238 #define CONFIG_CMDLINE_TAG
239 #define CONFIG_SETUP_MEMORY_TAGS
240 #define CONFIG_BOOTDELAY        1
241 #define CONFIG_BOOTFILE "uImage"
242 #define CONFIG_LOADADDR 0x42000000
243 #define CONFIG_SYS_LOAD_ADDR    CONFIG_LOADADDR
244 #define CONFIG_OF_LIBFDT
245
246 /* Extra Environments */
247 #define CONFIG_EXTRA_ENV_SETTINGS \
248         "update_nand_full_filename=u-boot.nand\0" \
249         "update_nand_firmware_filename=u-boot.sb\0"     \
250         "update_sd_firmware_filename=u-boot.sd\0" \
251         "update_nand_firmware_maxsz=0x100000\0" \
252         "update_nand_stride=0x40\0"     /* MX28 datasheet ch. 12.12 */ \
253         "update_nand_count=0x4\0"       /* MX28 datasheet ch. 12.12 */ \
254         "update_nand_get_fcb_size="     /* Get size of FCB blocks */ \
255                 "nand device 0 ; " \
256                 "nand info ; " \
257                 "setexpr fcb_sz ${update_nand_stride} * ${update_nand_count};" \
258                 "setexpr update_nand_fcb ${fcb_sz} * ${nand_writesize}\0" \
259         "update_nand_full="                 /* Update FCB, DBBT and FW */ \
260                 "if tftp ${update_nand_full_filename} ; then " \
261                 "run update_nand_get_fcb_size ; " \
262                 "nand scrub -y 0x0 ${filesize} ; " \
263                 "nand write.raw ${loadaddr} 0x0 ${fcb_sz} ; " \
264                 "setexpr update_off ${loadaddr} + ${update_nand_fcb} ; " \
265                 "setexpr update_sz ${filesize} - ${update_nand_fcb} ; " \
266                 "nand write ${update_off} ${update_nand_fcb} ${update_sz} ; " \
267                 "fi\0" \
268         "update_nand_firmware="         /* Update only firmware */ \
269                 "if tftp ${update_nand_firmware_filename} ; then " \
270                 "run update_nand_get_fcb_size ; " \
271                 "setexpr fcb_sz ${update_nand_fcb} * 2 ; " /* FCB + DBBT */ \
272                 "setexpr fw_sz ${update_nand_firmware_maxsz} * 2 ; " \
273                 "setexpr fw_off ${fcb_sz} + ${update_nand_firmware_maxsz};" \
274                 "nand erase ${fcb_sz} ${fw_sz} ; " \
275                 "nand write ${loadaddr} ${fcb_sz} ${filesize} ; " \
276                 "nand write ${loadaddr} ${fw_off} ${filesize} ; " \
277                 "fi\0" \
278         "update_sd_firmware="           /* Update the SD firmware partition */ \
279                 "if mmc rescan ; then " \
280                 "if tftp ${update_sd_firmware_filename} ; then " \
281                 "setexpr fw_sz ${filesize} / 0x200 ; "  /* SD block size */ \
282                 "setexpr fw_sz ${fw_sz} + 1 ; " \
283                 "mmc write ${loadaddr} 0x800 ${fw_sz} ; " \
284                 "fi ; " \
285                 "fi\0" \
286         "script=boot.scr\0"     \
287         "uimage=uImage\0" \
288         "console_fsl=ttyAM0\0" \
289         "console_mainline=ttyAMA0\0" \
290         "fdt_file=imx28-evk.dtb\0" \
291         "fdt_addr=0x41000000\0" \
292         "boot_fdt=try\0" \
293         "ip_dyn=yes\0" \
294         "mmcdev=0\0" \
295         "mmcpart=2\0" \
296         "mmcroot=/dev/mmcblk0p3 rw rootwait\0" \
297         "mmcargs=setenv bootargs console=${console_mainline},${baudrate} " \
298                 "root=${mmcroot}\0" \
299         "loadbootscript="  \
300                 "fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
301         "bootscript=echo Running bootscript from mmc ...; "     \
302                 "source\0" \
303         "loaduimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}\0" \
304         "loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
305         "mmcboot=echo Booting from mmc ...; " \
306                 "run mmcargs; " \
307                 "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
308                         "if run loadfdt; then " \
309                                 "bootm ${loadaddr} - ${fdt_addr}; " \
310                         "else " \
311                                 "if test ${boot_fdt} = try; then " \
312                                         "bootm; " \
313                                 "else " \
314                                         "echo WARN: Cannot load the DT; " \
315                                 "fi; " \
316                         "fi; " \
317                 "else " \
318                         "bootm; " \
319                 "fi;\0" \
320         "netargs=setenv bootargs console=${console_mainline},${baudrate} " \
321                 "root=/dev/nfs " \
322                 "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
323         "netboot=echo Booting from net ...; " \
324                 "run netargs; " \
325                 "if test ${ip_dyn} = yes; then " \
326                         "setenv get_cmd dhcp; " \
327                 "else " \
328                         "setenv get_cmd tftp; " \
329                 "fi; " \
330                 "${get_cmd} ${uimage}; " \
331                 "if test ${boot_fdt} = yes; then " \
332                         "if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
333                                 "bootm ${loadaddr} - ${fdt_addr}; " \
334                         "else " \
335                                 "if test ${boot_fdt} = try; then " \
336                                         "bootm; " \
337                                 "else " \
338                                         "echo WARN: Cannot load the DT; " \
339                                 "fi;" \
340                         "fi; " \
341                 "else " \
342                         "bootm; " \
343                 "fi;\0"
344
345 #define CONFIG_BOOTCOMMAND \
346         "mmc dev ${mmcdev}; if mmc rescan; then " \
347                 "if run loadbootscript; then " \
348                         "run bootscript; " \
349                 "else " \
350                         "if run loaduimage; then " \
351                                 "run mmcboot; " \
352                         "else run netboot; " \
353                         "fi; " \
354                 "fi; " \
355         "else run netboot; fi"
356
357 #endif /* __MX28EVK_CONFIG_H__ */