apalis-tk1: add update_uboot wrapper
[platform/kernel/u-boot.git] / include / configs / bav335x.h
1 /*
2  * bav335x.h
3  *
4  * Copyright (c) 2012-2014 Birdland Audio - http://birdland.com/oem
5  * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation version 2.
10  *
11  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12  * kind, whether express or implied; without even the implied warranty
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  */
16
17 #ifndef __CONFIG_BAV335X_H
18 #define __CONFIG_BAV335X_H
19
20 #include <configs/ti_am335x_common.h>
21
22 #ifndef CONFIG_SPL_BUILD
23 # define CONFIG_TIMESTAMP
24 #endif
25
26 #define CONFIG_SYS_BOOTM_LEN            (16 << 20)
27
28 #define CONFIG_MACH_TYPE                MACH_TYPE_AM335XEVM
29
30 /* Clock Defines */
31 #define V_OSCK                          24000000  /* Clock output from T2 */
32 #define V_SCLK                          (V_OSCK)
33
34 #ifdef CONFIG_MTD_RAW_NAND
35 #define NANDARGS \
36         "mtdids=" CONFIG_MTDIDS_DEFAULT "\0" \
37         "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
38         "nandargs=setenv bootargs console=${console} " \
39                 "${optargs} " \
40                 "root=${nandroot} " \
41                 "rootfstype=${nandrootfstype}\0" \
42         "nandroot=ubi0:rootfs rw ubi.mtd=9,2048\0" \
43         "nandrootfstype=ubifs rootwait=1\0" \
44         "nandboot=echo Booting from nand ...; " \
45                 "run nandargs; " \
46                 "nand read ${fdtaddr} u-boot-spl-os; " \
47                 "nand read ${loadaddr} kernel; " \
48                 "bootz ${loadaddr} - ${fdtaddr}\0"
49 #else
50 #define NANDARGS ""
51 #endif
52
53 #ifndef CONFIG_SPL_BUILD
54 #define CONFIG_EXTRA_ENV_SETTINGS \
55 DEFAULT_LINUX_BOOT_ENV \
56 "boot_fdt=try\0" \
57 "bootpart=0:2\0" \
58 "bootdir=\0" \
59 "fdtdir=/dtbs\0" \
60 "bootfile=zImage\0" \
61 "fdtfile=undefined\0" \
62 "console=ttyO0,115200n8\0" \
63 "loadaddr=0x82000000\0" \
64 "fdtaddr=0x88000000\0" \
65 "rdaddr=0x88080000\0" \
66 "initrd_high=0xffffffff\0" \
67 "fdt_high=0xffffffff\0" \
68 "partitions=" \
69         "uuid_disk=${uuid_gpt_disk};" \
70         "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}\0" \
71 "optargs=\0" \
72 "cmdline=\0" \
73 "mmcdev=0\0" \
74 "mmcpart=1\0" \
75 "mmcroot=/dev/mmcblk0p2 ro\0" \
76 "mmcrootfstype=ext4 rootwait fixrtc\0" \
77 "rootpath=/export/rootfs\0" \
78 "nfsopts=nolock\0" \
79 "static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off\0" \
80 "ramroot=/dev/ram0 rw\0" \
81 "ramrootfstype=ext2\0" \
82 "mmcargs=setenv bootargs console=${console} ${optargs} " \
83         "root=${mmcroot} rootfstype=${mmcrootfstype} ${cmdline}\0" \
84 "server_ip=192.168.1.100\0" \
85 "gw_ip=192.168.1.1\0" \
86 "netmask=255.255.255.0\0" \
87 "hostname=\0" \
88 "device=eth0\0" \
89 "autoconf=off\0" \
90 "root_dir=/home/userid/targetNFS\0" \
91 "nfs_options=,vers=3\0" \
92 "nfsrootfstype=ext4 rootwait fixrtc\0" \
93 "nfsargs=setenv bootargs console=${console} ${optargs} " \
94         "root=/dev/nfs rw rootfstype=${nfsrootfstype} " \
95         "nfsroot=${nfsroot} ip=${ip} ${cmdline}\0" \
96 "netargs=setenv bootargs console=${console} " \
97         "${optargs} root=/dev/nfs " \
98         "nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp\0" \
99 "bootenv=uEnv.txt\0" \
100 "script=boot.scr\0" \
101 "scriptfile=${script}\0" \
102 "loadbootscript=load mmc ${bootpart} ${loadaddr} ${scriptfile};\0" \
103 "bootscript=echo Running bootscript from mmc${bootpart} ...; " \
104         "source ${loadaddr}\0" \
105         "loadbootenv=load mmc ${bootpart} ${loadaddr} ${bootenv}\0" \
106 "importbootenv=echo Importing environment from mmc ...; " \
107         "env import -t -r $loadaddr $filesize\0" \
108 "ramargs=setenv bootargs console=${console} " \
109         "${optargs} root=${ramroot} rootfstype=${ramrootfstype}\0" \
110 "loadramdisk=load mmc ${mmcdev} ${rdaddr} ramdisk.gz\0" \
111 "loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}\0" \
112         "loadrd=load mmc ${bootpart} ${rdaddr} " \
113         "${bootdir}/${rdfile}; setenv rdsize ${filesize}\0" \
114 "loadfdt=echo loading ${fdtdir}/${fdtfile} ...; " \
115         "load mmc ${bootpart} ${fdtaddr} ${fdtdir}/${fdtfile}\0" \
116 "mmcboot=mmc dev ${mmcdev}; " \
117         "if mmc rescan; then " \
118                 "gpio set 54;" \
119                 "setenv bootpart ${mmcdev}:1; " \
120                 "if test -e mmc ${bootpart} /etc/fstab; then " \
121                         "setenv mmcpart 1;" \
122                 "fi; " \
123                 "echo Checking for: /uEnv.txt ...;" \
124                 "if test -e mmc ${bootpart} /uEnv.txt; then " \
125                         "if run loadbootenv; then " \
126                                 "gpio set 55;" \
127                                 "echo Loaded environment from ${bootenv};" \
128                                 "run importbootenv;" \
129                         "fi;" \
130                         "echo Checking if uenvcmd is set ...;" \
131                         "if test -n ${uenvcmd}; then " \
132                                 "gpio set 56; " \
133                                 "echo Running uenvcmd ...;" \
134                                 "run uenvcmd;" \
135                         "fi;" \
136                         "echo Checking if client_ip is set ...;" \
137                         "if test -n ${client_ip}; then " \
138                                 "if test -n ${dtb}; then " \
139                                         "setenv fdtfile ${dtb};" \
140                                         "echo using ${fdtfile} ...;" \
141                                 "fi;" \
142                                 "gpio set 56; " \
143                                 "if test -n ${uname_r}; then " \
144                                         "echo Running nfsboot_uname_r ...;" \
145                                         "run nfsboot_uname_r;" \
146                                 "fi;" \
147                                 "echo Running nfsboot ...;" \
148                                 "run nfsboot;" \
149                         "fi;" \
150                 "fi; " \
151                 "echo Checking for: /${script} ...;" \
152                 "if test -e mmc ${bootpart} /${script}; then " \
153                         "gpio set 55;" \
154                         "setenv scriptfile ${script};" \
155                         "run loadbootscript;" \
156                         "echo Loaded script from ${scriptfile};" \
157                         "gpio set 56; " \
158                         "run bootscript;" \
159                 "fi; " \
160                 "echo Checking for: /boot/${script} ...;" \
161                 "if test -e mmc ${bootpart} /boot/${script}; then " \
162                         "gpio set 55;" \
163                         "setenv scriptfile /boot/${script};" \
164                         "run loadbootscript;" \
165                         "echo Loaded script from ${scriptfile};" \
166                         "gpio set 56; " \
167                         "run bootscript;" \
168                 "fi; " \
169                 "echo Checking for: /boot/uEnv.txt ...;" \
170                 "for i in 1 2 3 4 5 6 7 ; do " \
171                         "setenv mmcpart ${i};" \
172                         "setenv bootpart ${mmcdev}:${mmcpart};" \
173                         "if test -e mmc ${bootpart} /boot/uEnv.txt; then " \
174                                 "gpio set 55;" \
175                                 "load mmc ${bootpart} ${loadaddr} " \
176                                                 "/boot/uEnv.txt;" \
177                                 "env import -t ${loadaddr} ${filesize};" \
178                                 "echo Loaded environment from /boot/uEnv.txt;" \
179                                 "if test -n ${dtb}; then " \
180                                         "setenv fdtfile ${dtb};" \
181                                         "echo Using: dtb=${fdtfile} ...;" \
182                                 "fi;" \
183                                 "echo Checking if uname_r is set in " \
184                                                 "/boot/uEnv.txt...;" \
185                                 "if test -n ${uname_r}; then " \
186                                         "gpio set 56; " \
187                                         "echo Running uname_boot ...;" \
188                                         "setenv mmcroot /dev/mmcblk${mmcdev}" \
189                                                         "p${mmcpart} ro;" \
190                                         "run uname_boot;" \
191                                 "fi;" \
192                         "fi;" \
193                 "done;" \
194         "fi;\0" \
195 "netboot=echo Booting from network ...; " \
196         "setenv autoload no; " \
197         "dhcp; " \
198         "tftp ${loadaddr} ${bootfile}; " \
199         "tftp ${fdtaddr} ${fdtfile}; " \
200         "run netargs; " \
201         "bootz ${loadaddr} - ${fdtaddr}\0" \
202 "nfsboot=echo Booting from ${server_ip} ...; " \
203         "setenv nfsroot ${server_ip}:${root_dir}${nfs_options}; " \
204         "setenv ip ${client_ip}:${server_ip}:${gw_ip}:${netmask}:${hostname}" \
205         ":${device}:${autoconf}; " \
206         "setenv autoload no; " \
207         "setenv serverip ${server_ip}; " \
208         "setenv ipaddr ${client_ip}; " \
209         "tftp ${loadaddr} ${bootfile}; " \
210         "tftp ${fdtaddr} dtbs/${fdtfile}; " \
211         "run nfsargs; " \
212         "bootz ${loadaddr} - ${fdtaddr}\0" \
213 "nfsboot_uname_r=echo Booting from ${server_ip} ...; " \
214         "setenv nfsroot ${server_ip}:${root_dir}${nfs_options}; " \
215         "setenv ip ${client_ip}:${server_ip}:${gw_ip}:${netmask}:${hostname}" \
216                         ":${device}:${autoconf}; " \
217         "setenv autoload no; " \
218         "setenv serverip ${server_ip}; " \
219         "setenv ipaddr ${client_ip}; " \
220         "tftp ${loadaddr} vmlinuz-${uname_r}; " \
221         "tftp ${fdtaddr} dtbs/${uname_r}/${fdtfile}; " \
222         "run nfsargs; " \
223         "bootz ${loadaddr} - ${fdtaddr}\0" \
224 "ramboot=echo Booting from ramdisk ...; " \
225         "run ramargs; " \
226         "bootz ${loadaddr} ${rdaddr} ${fdtaddr}\0" \
227 "findfdt="\
228         "if test $board_rev = B; then " \
229                 "setenv fdtfile birdland_bav335b.dtb; " \
230                 "setenv fdtbase am335x-boneblack; fi; " \
231         "if test $board_rev = A; then " \
232                 "setenv fdtfile birdland_bav335a.dtb; " \
233                 "setenv fdtbase am335x-boneblack; fi; " \
234         "if test $fdtfile = undefined; then " \
235                 "echo WARNING: Could not determine device tree to use; fi; \0" \
236 "uname_boot="\
237         "setenv bootdir /boot; " \
238         "setenv bootfile vmlinuz-${uname_r}; " \
239         "if test -e mmc ${bootpart} ${bootdir}/${bootfile}; then " \
240                 "echo loading ${bootdir}/${bootfile} ...; "\
241                 "run loadimage;" \
242                 "setenv fdtdir /boot/dtbs/${uname_r}; " \
243                 "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \
244                         "run loadfdt;" \
245                 "else " \
246                         "setenv fdtdir /lib/firmware/${uname_r}/device-tree; " \
247                         "if test -e mmc ${bootpart} ${fdtdir}/" \
248                                         "${fdtfile}; then " \
249                                 "run loadfdt;" \
250                         "else " \
251                                 "setenv fdtdir /boot/dtb-${uname_r}; " \
252                                 "if test -e mmc ${bootpart} ${fdtdir}" \
253                                                 "/${fdtfile}; then " \
254                                         "run loadfdt;" \
255                                 "else " \
256                                         "setenv fdtdir /boot/dtbs; " \
257                                         "if test -e mmc ${bootpart} ${fdtdir}" \
258                                                         "/${fdtfile}; then " \
259                                                 "run loadfdt;" \
260                                         "else " \
261                                                 "echo; echo unable to find " \
262                                                         "[${fdtfile}] " \
263                                                 "did you name it correctly?" \
264                                                 "echo booting fallback " \
265                                                         "[/boot/dtbs/" \
266                                                         "${uname_r}" \
267                                                         "/${fdtbase}.dtb]...;" \
268                                                 "setenv fdtdir /boot/dtbs/" \
269                                                         "${uname_r}; " \
270                                                 "setenv fdtfile " \
271                                                         "${fdtbase}.dtb; " \
272                                                 "run loadfdt;" \
273                                         "fi;" \
274                                 "fi;" \
275                         "fi;" \
276                 "fi;" \
277         "fi; " \
278         "setenv rdfile initrd.img-${uname_r}; " \
279         "if test -e mmc ${bootpart} ${bootdir}/${rdfile}; then " \
280                 "echo loading ${bootdir}/${rdfile} ...; "\
281                 "run loadrd;" \
282                 "if test -n ${uuid}; then " \
283                         "setenv mmcroot UUID=${uuid} ro;" \
284                 "fi;" \
285                 "run mmcargs;" \
286                 "echo debug: [${bootargs}] ... ;" \
287                 "echo debug: [bootz ${loadaddr} ${rdaddr}:${rdsize} " \
288                                         "${fdtaddr}] ... ;" \
289                 "bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr}; " \
290         "else " \
291                 "run mmcargs;" \
292                 "echo debug: [${bootargs}] ... ;" \
293                 "echo debug: [bootz ${loadaddr} - ${fdtaddr}] ... ;" \
294                 "bootz ${loadaddr} - ${fdtaddr}; " \
295         "fi;" \
296 "fi;\0" \
297         NANDARGS \
298         DFUARGS
299 #endif
300
301 #define CONFIG_BOOTCOMMAND \
302         "gpio set 53; " \
303         "i2c mw 0x24 1 0x3e; " \
304         "run findfdt; " \
305         "setenv mmcdev 0; " \
306         "setenv bootpart 0:1; " \
307         "run mmcboot;" \
308         "gpio clear 56; " \
309         "gpio clear 55; " \
310         "gpio clear 54; " \
311         "setenv mmcdev 1; " \
312         "setenv bootpart 1:1; " \
313         "run mmcboot;"
314
315 /* NS16550 Configuration */
316 #define CONFIG_SYS_NS16550_COM1         0x44e09000      /* UART0 */
317 #define CONFIG_SYS_NS16550_COM2         0x48022000      /* UART1 */
318 #define CONFIG_SYS_NS16550_COM3         0x48024000      /* UART2 */
319 #define CONFIG_SYS_NS16550_COM4         0x481a6000      /* UART3 */
320 #define CONFIG_SYS_NS16550_COM5         0x481a8000      /* UART4 */
321 #define CONFIG_SYS_NS16550_COM6         0x481aa000      /* UART5 */
322
323 #define CONFIG_ENV_EEPROM_IS_ON_I2C
324 #define CONFIG_SYS_I2C_EEPROM_ADDR      0x50    /* Main EEPROM */
325 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN  2
326
327 /* PMIC support */
328 #define CONFIG_POWER_TPS65217
329 #define CONFIG_POWER_TPS65910
330
331 /* SPL */
332 #ifndef CONFIG_NOR_BOOT
333 /* Bootcount using the RTC block */
334 #define CONFIG_SYS_BOOTCOUNT_BE
335
336 /* USB gadget RNDIS */
337 #endif
338
339 #ifdef CONFIG_MTD_RAW_NAND
340 /* NAND: device related configs */
341 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
342 #define CONFIG_SYS_NAND_PAGE_COUNT      (CONFIG_SYS_NAND_BLOCK_SIZE / \
343                                          CONFIG_SYS_NAND_PAGE_SIZE)
344 #define CONFIG_SYS_NAND_PAGE_SIZE       2048
345 #define CONFIG_SYS_NAND_OOBSIZE         64
346 #define CONFIG_SYS_NAND_BLOCK_SIZE      (128*1024)
347 /* NAND: driver related configs */
348 #define CONFIG_SYS_NAND_BAD_BLOCK_POS   NAND_LARGE_BADBLOCK_POS
349 #define CONFIG_SYS_NAND_ECCPOS  { \
350         2, 3, 4, 5, 6, 7, 8, 9, \
351         10, 11, 12, 13, 14, 15, 16, 17, \
352         18, 19, 20, 21, 22, 23, 24, 25, \
353         26, 27, 28, 29, 30, 31, 32, 33, \
354         34, 35, 36, 37, 38, 39, 40, 41, \
355         42, 43, 44, 45, 46, 47, 48, 49, \
356         50, 51, 52, 53, 54, 55, 56, 57, }
357
358 #define CONFIG_SYS_NAND_ECCSIZE         512
359 #define CONFIG_SYS_NAND_ECCBYTES        14
360 #define CONFIG_SYS_NAND_ONFI_DETECTION
361 #define CONFIG_NAND_OMAP_ECCSCHEME      OMAP_ECC_BCH8_CODE_HW
362 #define CONFIG_SYS_NAND_U_BOOT_OFFS     0x000c0000
363 #define CONFIG_SYS_ENV_SECT_SIZE        CONFIG_SYS_NAND_BLOCK_SIZE
364 /* NAND: SPL related configs */
365 #ifdef CONFIG_SPL_OS_BOOT
366 #define CONFIG_SYS_NAND_SPL_KERNEL_OFFS 0x00200000 /* kernel offset */
367 #endif
368 #endif /* !CONFIG_MTD_RAW_NAND */
369
370 /*
371  * For NOR boot, we must set this to the start of where NOR is mapped
372  * in memory.
373  */
374
375 /*
376  * USB configuration.  We enable MUSB support, both for host and for
377  * gadget.  We set USB0 as peripheral and USB1 as host, based on the
378  * board schematic and physical port wired to each.  Then for host we
379  * add mass storage support and for gadget we add both RNDIS ethernet
380  * and DFU.
381  */
382 #define CONFIG_AM335X_USB0
383 #define CONFIG_AM335X_USB0_MODE MUSB_PERIPHERAL
384 #define CONFIG_AM335X_USB1
385 #define CONFIG_AM335X_USB1_MODE MUSB_HOST
386
387 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USB_ETHER)
388 /* disable host part of MUSB in SPL */
389 /* disable EFI partitions and partition UUID support */
390 #endif
391
392 /* USB Device Firmware Update support */
393 #ifndef CONFIG_SPL_BUILD
394 #define DFU_ALT_INFO_MMC \
395         "dfu_alt_info_mmc=" \
396         "boot part 0 1;" \
397         "rootfs part 0 2;" \
398         "MLO fat 0 1;" \
399         "MLO.raw raw 0x100 0x100;" \
400         "u-boot.img.raw raw 0x300 0x400;" \
401         "spl-os-args.raw raw 0x80 0x80;" \
402         "spl-os-image.raw raw 0x900 0x2000;" \
403         "spl-os-args fat 0 1;" \
404         "spl-os-image fat 0 1;" \
405         "u-boot.img fat 0 1;" \
406         "uEnv.txt fat 0 1\0"
407 #ifdef CONFIG_MTD_RAW_NAND
408 #define DFU_ALT_INFO_NAND \
409         "dfu_alt_info_nand=" \
410         "SPL part 0 1;" \
411         "SPL.backup1 part 0 2;" \
412         "SPL.backup2 part 0 3;" \
413         "SPL.backup3 part 0 4;" \
414         "u-boot part 0 5;" \
415         "u-boot-spl-os part 0 6;" \
416         "kernel part 0 8;" \
417         "rootfs part 0 9\0"
418 #else
419 #define DFU_ALT_INFO_NAND ""
420 #endif
421 #define DFU_ALT_INFO_RAM \
422         "dfu_alt_info_ram=" \
423         "kernel ram 0x80200000 0xD80000;" \
424         "fdt ram 0x80F80000 0x80000;" \
425         "ramdisk ram 0x81000000 0x4000000\0"
426 #define DFUARGS \
427         "dfu_alt_info_emmc=rawemmc raw 0 3751936\0" \
428         DFU_ALT_INFO_MMC \
429         DFU_ALT_INFO_RAM \
430         DFU_ALT_INFO_NAND
431 #endif
432
433 /*
434  * Default to using SPI for environment, etc.
435  * 0x000000 - 0x020000 : SPL (128KiB)
436  * 0x020000 - 0x0A0000 : U-Boot (512KiB)
437  * 0x0A0000 - 0x0BFFFF : First copy of U-Boot Environment (128KiB)
438  * 0x0C0000 - 0x0DFFFF : Second copy of U-Boot Environment (128KiB)
439  * 0x0E0000 - 0x442000 : Linux Kernel
440  * 0x442000 - 0x800000 : Userland
441  */
442 #if defined(CONFIG_SPI_BOOT)
443 /* SPL related */
444 #elif defined(CONFIG_EMMC_BOOT)
445 #define CONFIG_SYS_MMC_ENV_DEV          1
446 #define CONFIG_SYS_MMC_ENV_PART         2
447 #endif
448
449 /* SPI flash. */
450
451 /* Network. */
452 #define CONFIG_PHY_SMSC
453
454 /*
455  * NOR Size = 16 MiB
456  * Number of Sectors/Blocks = 128
457  * Sector Size = 128 KiB
458  * Word length = 16 bits
459  * Default layout:
460  * 0x000000 - 0x07FFFF : U-Boot (512 KiB)
461  * 0x080000 - 0x09FFFF : First copy of U-Boot Environment (128 KiB)
462  * 0x0A0000 - 0x0BFFFF : Second copy of U-Boot Environment (128 KiB)
463  * 0x0C0000 - 0x4BFFFF : Linux Kernel (4 MiB)
464  * 0x4C0000 - 0xFFFFFF : Userland (11 MiB + 256 KiB)
465  */
466 #if defined(CONFIG_NOR)
467 #define CONFIG_SYS_MAX_FLASH_SECT       128
468 #define CONFIG_SYS_MAX_FLASH_BANKS      1
469 #define CONFIG_SYS_FLASH_BASE           (0x08000000)
470 #define CONFIG_SYS_FLASH_CFI_WIDTH      FLASH_CFI_16BIT
471 #define CONFIG_SYS_FLASH_SIZE           0x01000000
472 #define CONFIG_SYS_MONITOR_BASE         CONFIG_SYS_FLASH_BASE
473 /* Reduce SPL size by removing unlikey targets */
474 #endif  /* NOR support */
475
476 #endif  /* ! __CONFIG_AM335X_EVM_H */