Merge branch 'master' of git://git.denx.de/u-boot
[platform/kernel/u-boot.git] / include / configs / turris_omnia.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2017 Marek Behun <marek.behun@nic.cz>
4  * Copyright (C) 2016 Tomas Hlavacek <tomas.hlavacek@nic.cz>
5  */
6
7 #ifndef _CONFIG_TURRIS_OMNIA_H
8 #define _CONFIG_TURRIS_OMNIA_H
9
10 /*
11  * High Level Configuration Options (easy to change)
12  */
13
14 /*
15  * TEXT_BASE needs to be below 16MiB, since this area is scrubbed
16  * for DDR ECC byte filling in the SPL before loading the main
17  * U-Boot into it.
18  */
19
20 /* Environment in SPI NOR flash */
21
22 #define PHY_ANEG_TIMEOUT        8000    /* PHY needs a longer aneg time */
23
24 /* Keep device tree and initrd in lower memory so the kernel can access them */
25 #define RELOCATION_LIMITS_ENV_SETTINGS  \
26         "fdt_high=0x10000000\0"         \
27         "initrd_high=0x10000000\0"
28
29 /* Defines for SPL */
30 #define CONFIG_SPL_SIZE                 (140 << 10)
31 #define CONFIG_SPL_MAX_SIZE             (CONFIG_SPL_SIZE - 0x0030)
32
33 #define CONFIG_SPL_BSS_START_ADDR       (0x40000000 + CONFIG_SPL_SIZE)
34 #define CONFIG_SPL_BSS_MAX_SIZE         (16 << 10)
35
36 #ifdef CONFIG_SPL_BUILD
37 #define CONFIG_SYS_MALLOC_SIMPLE
38 #endif
39
40 #define CONFIG_SPL_STACK                (0x40000000 + ((192 - 16) << 10))
41 #define CONFIG_SPL_BOOTROM_SAVE         (CONFIG_SPL_STACK + 4)
42 #define CONFIG_SPL_DRIVERS_MISC
43
44 #ifdef CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC
45 /* SPL related MMC defines */
46 # ifdef CONFIG_SPL_BUILD
47 #  define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER     0x00180000      /* in SDRAM */
48 # endif
49 #endif
50
51 /*
52  * mv-common.h should be defined after CMD configs since it used them
53  * to enable certain macros
54  */
55 #include "mv-common.h"
56
57 /* Include the common distro boot environment */
58 #ifndef CONFIG_SPL_BUILD
59
60 #ifdef CONFIG_MMC
61 #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
62 #else
63 #define BOOT_TARGET_DEVICES_MMC(func)
64 #endif
65
66 #ifdef CONFIG_USB_STORAGE
67 #define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0)
68 #else
69 #define BOOT_TARGET_DEVICES_USB(func)
70 #endif
71
72 #ifdef CONFIG_SCSI
73 #define BOOT_TARGET_DEVICES_SCSI(func) func(SCSI, scsi, 0)
74 #else
75 #define BOOT_TARGET_DEVICES_SCSI(func)
76 #endif
77
78 #define BOOT_TARGET_DEVICES(func) \
79         BOOT_TARGET_DEVICES_MMC(func) \
80         BOOT_TARGET_DEVICES_SCSI(func) \
81         BOOT_TARGET_DEVICES_USB(func) \
82         func(PXE, pxe, na) \
83         func(DHCP, dhcp, na)
84
85 #define KERNEL_ADDR_R   __stringify(0x1000000)
86 #define FDT_ADDR_R      __stringify(0x2000000)
87 #define RAMDISK_ADDR_R  __stringify(0x2200000)
88 #define SCRIPT_ADDR_R   __stringify(0x1800000)
89 #define PXEFILE_ADDR_R  __stringify(0x1900000)
90
91 #define LOAD_ADDRESS_ENV_SETTINGS \
92         "kernel_addr_r=" KERNEL_ADDR_R "\0" \
93         "fdt_addr_r=" FDT_ADDR_R "\0" \
94         "ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
95         "scriptaddr=" SCRIPT_ADDR_R "\0" \
96         "pxefile_addr_r=" PXEFILE_ADDR_R "\0"
97
98 #include <config_distro_bootcmd.h>
99
100 /*
101  * The factory reset bootcommand on Omnia first sets all the front LEDs to green
102  * and then tries to load the rescue image from SPI flash memory and boot it
103  */
104 #define TURRIS_OMNIA_BOOTCMD_RESCUE \
105         "i2c dev 2; " \
106         "i2c mw 0x2a.1 0x3 0x1c 1; " \
107         "i2c mw 0x2a.1 0x4 0x1c 1; " \
108         "mw.l 0x01000000 0x00ff000c; " \
109         "i2c write 0x01000000 0x2a.1 0x5 4 -s; " \
110         "setenv bootargs \"earlyprintk console=ttyS0,115200" \
111                 " omniarescue=$omnia_reset rescue_mode=$omnia_reset\"; " \
112         "sf probe; " \
113         "sf read 0x1000000 0x100000 0x700000; " \
114         "lzmadec 0x1000000 0x1700000; " \
115         "if gpio input gpio@71_4; then " \
116                 "bootm 0x1700000#sfp; " \
117         "else " \
118                 "bootm 0x1700000; " \
119         "fi; " \
120         "bootz 0x1000000"
121
122 #define CONFIG_EXTRA_ENV_SETTINGS \
123         RELOCATION_LIMITS_ENV_SETTINGS \
124         LOAD_ADDRESS_ENV_SETTINGS \
125         "fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
126         "console=ttyS0,115200\0" \
127         "ethact=ethernet@34000\0" \
128         "bootcmd_rescue=" TURRIS_OMNIA_BOOTCMD_RESCUE "\0" \
129         BOOTENV
130
131 #endif /* CONFIG_SPL_BUILD */
132
133 #endif /* _CONFIG_TURRIS_OMNIA_H */