1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright (C) 2017 4 * Lukasz Majewski, DENX Software Engineering, lukma@denx.de 5 */ 6 7 #ifndef __CONFIG_H 8 #define __CONFIG_H 9 10 #include "mx6_common.h" 11 12 /* Falcon Mode */ 13 #define CONFIG_SYS_SPL_ARGS_ADDR 0x18000000 14 15 /* Falcon Mode - MMC support */ 16 #define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR 0x3F00 17 #define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS \ 18 (CONFIG_CMD_SPL_WRITE_SIZE / 512) 19 #define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR 0x100 /* 128KiB */ 20 21 /* 22 * display5 SPI-NOR memory layout 23 * 24 * The definition can be found in Kconfig's 25 * CONFIG_MTDIDS_DEFAULT and CONFIG_MTDPARTS_DEFAULT 26 * 27 * 0x000000 - 0x020000 : SPI.SPL (128KiB) 28 * 0x020000 - 0x120000 : SPI.u-boot (1MiB) 29 * 0x120000 - 0x130000 : SPI.u-boot-env1 (64KiB) 30 * 0x130000 - 0x140000 : SPI.u-boot-env2 (64KiB) 31 * 0x140000 - 0x740000 : SPI.swupdate-kernel-FIT (6MiB) 32 * 0x740000 - 0x1B40000 : SPI.swupdate-initramfs (20MiB) 33 * 0x1B40000 - 0x1F00000 : SPI.reserved (3840KiB) 34 * 0x1F00000 - 0x2000000 : SPI.factory (1MiB) 35 */ 36 37 /* SPI Flash Configs */ 38 #if defined(CONFIG_SPL_BUILD) 39 #undef CONFIG_DM_SPI 40 #undef CONFIG_DM_SPI_FLASH 41 #endif 42 43 /* Below values are "dummy" - only to avoid build break */ 44 #define CONFIG_SYS_SPI_KERNEL_OFFS 0x150000 45 #define CONFIG_SYS_SPI_ARGS_OFFS 0x140000 46 #define CONFIG_SYS_SPI_ARGS_SIZE 0x10000 47 48 #include "imx6_spl.h" 49 50 #define CONFIG_CMDLINE_TAG 51 #define CONFIG_SETUP_MEMORY_TAGS 52 #define CONFIG_INITRD_TAG 53 #define CONFIG_REVISION_TAG 54 55 /* Size of malloc() pool */ 56 #define CONFIG_SYS_MALLOC_LEN (16 * 1024 * 1024) 57 58 #define CONFIG_MXC_UART_BASE UART5_BASE 59 60 /* I2C Configs */ 61 #define CONFIG_I2C_MULTI_BUS 62 63 /* MMC Configs */ 64 #define CONFIG_SYS_FSL_ESDHC_ADDR 0 65 #define CONFIG_SYS_FSL_USDHC_NUM 2 66 67 #ifndef CONFIG_BOOTCOMMAND 68 #define CONFIG_BOOTCOMMAND "if run check_em_pad; then " \ 69 "run recovery;" \ 70 "else if test ${BOOT_FROM} = FACTORY; then " \ 71 "run factory_nfs;" \ 72 "else " \ 73 "run boot_mmc;" \ 74 "fi;fi" 75 #endif 76 77 #define PARTS_DEFAULT \ 78 /* Linux partitions */ \ 79 "partitions=" \ 80 "uuid_disk=${uuid_gpt_disk};" \ 81 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \ 82 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \ 83 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \ 84 "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \ 85 "name=data,size=-,uuid=${uuid_gpt_data}\0" 86 87 #define SWUPDATE_RECOVERY_PROCEDURE \ 88 "echo '#######################';" \ 89 "echo '# RECOVERY SWUupdate #';" \ 90 "echo '#######################';" \ 91 "echo '#######################';" \ 92 "echo '# GPT verify #';" \ 93 "if gpt verify mmc ${mmcdev} ${partitions}; then " \ 94 "echo '# OK ! #';" \ 95 "else " \ 96 "echo '# FAILED ! #';" \ 97 "echo '# GPT RESTORATION #';" \ 98 "gpt write mmc ${mmcdev} ${partitions};" \ 99 "fi;" \ 100 "echo '#######################';" \ 101 "setenv loadaddr_swu_initramfs 0x14000000;" \ 102 "setenv bootargs console=${console} " \ 103 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \ 104 ":${hostname}::off root=/dev/ram rw;" \ 105 "sf probe;" \ 106 "sf read ${loadaddr} swu-kernel;" \ 107 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \ 108 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;" 109 110 #define SETUP_BOOTARGS \ 111 "run set_rootfs_part;" \ 112 "setenv bootargs ${bootargs} console=${console} " \ 113 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \ 114 "rootwait rootfstype=ext4 rw; " \ 115 "run set_kernel_part;" \ 116 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \ 117 "mmc read ${loadaddr} ${lba_start} ${fitImg_fw_sz}; " \ 118 "setenv fdt_conf imx6q-${board}-${display}.dtb; " 119 120 /* All the numbers are in LBAs */ 121 #define __TFTP_UPDATE_KERNEL \ 122 "tftp_mmc_fitImg=" \ 123 "if test ! -n ${kernel_part}; then " \ 124 "setenv kernel_part ${kernel_part_active};" \ 125 "fi;" \ 126 "if tftp ${loadaddr} ${kernel_file}; then " \ 127 "setexpr fw_sz ${filesize} / 0x200; " \ 128 "setexpr fw_sz ${fw_sz} + 1; " \ 129 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \ 130 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \ 131 "; fi\0" \ 132 133 #define TFTP_UPDATE_KERNEL \ 134 "setenv kernel_part ${kernel_part_active};" \ 135 "run tftp_mmc_fitImg;" \ 136 "setenv kernel_part ${kernel_part_backup};" \ 137 "run tftp_mmc_fitImg;" \ 138 139 #define __TFTP_UPDATE_ROOTFS \ 140 "tftp_mmc_rootfs=" \ 141 "if test ! -n ${rootfs_part}; then " \ 142 "setenv rootfs_part ${rootfs_part_active};" \ 143 "fi;" \ 144 "if tftp ${loadaddr} ${rootfs_file}; then " \ 145 "setexpr fw_sz ${filesize} / 0x200; " \ 146 "setexpr fw_sz ${fw_sz} + 1; " \ 147 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \ 148 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \ 149 "; fi\0" \ 150 151 #define TFTP_UPDATE_ROOTFS \ 152 "setenv rootfs_part ${rootfs_part_active};" \ 153 "run tftp_mmc_rootfs;" \ 154 "run tftp_mmc_rootfs_bkp;" \ 155 156 157 #define TFTP_UPDATE_RECOVERY_SWU_KERNEL \ 158 "tftp_sf_fitImg_SWU=" \ 159 "if tftp ${loadaddr} ${kernel_file}; then " \ 160 "sf probe;" \ 161 "sf erase swu-kernel +${filesize};" \ 162 "sf write ${loadaddr} swu-kernel ${filesize};" \ 163 "; fi\0" \ 164 165 #define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \ 166 "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \ 167 "tftp_sf_initramfs_SWU=" \ 168 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \ 169 "sf probe;" \ 170 "sf erase swu-initramfs +${filesize};" \ 171 "sf write ${loadaddr} swu-initramfs ${filesize};" \ 172 "; fi\0" \ 173 174 #define TFTP_UPDATE_BOOTLOADER \ 175 "ubootfile=u-boot.img\0" \ 176 "ubootfileSPL=SPL\0" \ 177 "tftp_sf_uboot=" \ 178 "if tftp ${loadaddr} ${ubootfile}; then " \ 179 "sf probe;" \ 180 "sf erase u-boot +${filesize};" \ 181 "sf write ${loadaddr} u-boot ${filesize}" \ 182 "; fi\0" \ 183 "tftp_sf_SPL=" \ 184 "if tftp ${loadaddr} ${ubootfileSPL}; then " \ 185 "sf probe;" \ 186 "setexpr uboot_SPL_size ${filesize} + 0x400;" \ 187 "sf erase 0x0 +${uboot_SPL_size};" \ 188 "sf write ${loadaddr} 0x400 ${filesize};" \ 189 "fi\0" \ 190 191 #define TFTP_UPDATE_SPINOR \ 192 "spinorfile=core-image-lwn-display5.spinor\0" \ 193 "spinorsize=0x2000000\0" \ 194 "tftp_sf_img=" \ 195 "if tftp ${loadaddr} ${spinorfile}; then " \ 196 "sf probe;" \ 197 "sf erase 0x0 ${spinorsize};" \ 198 "sf write ${loadaddr} 0x0 ${filesize};" \ 199 "fi\0" \ 200 201 #define CONFIG_EXTRA_ENV_SETTINGS \ 202 PARTS_DEFAULT \ 203 "gpio_recovery=93\0" \ 204 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \ 205 "display=tianma-tm070-800x480\0" \ 206 "board=display5\0" \ 207 "mmcdev=0\0" \ 208 "altbootcmd=run recovery\0" \ 209 "bootdelay=1\0" \ 210 "baudrate=115200\0" \ 211 "bootcmd=" CONFIG_BOOTCOMMAND "\0" \ 212 "ethact=FEC\0" \ 213 "netdev=eth0\0" \ 214 "boot_os=y\0" \ 215 "hostname=display5\0" \ 216 "loadaddr=0x12000000\0" \ 217 "fdtaddr=0x12800000\0" \ 218 "console=ttymxc4,115200 quiet cma=256M\0" \ 219 "fdtfile=imx6q-display5.dtb\0" \ 220 "fdt_high=0xffffffff\0" \ 221 "initrd_high=0xffffffff\0" \ 222 "kernel_file=fitImage\0" \ 223 "fitImg_fw_sz=0x2200\0" \ 224 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \ 225 "download_kernel=" \ 226 "tftpboot ${loadaddr} ${kernel_file};\0" \ 227 "factory_nfs=" \ 228 "setenv ipaddr 192.168.1.102;" \ 229 "setenv gatewayip 192.168.1.1;" \ 230 "setenv netmask 255.255.255.0;" \ 231 "setenv serverip 192.168.1.2;" \ 232 "echo BOOT: FACTORY (LEG);" \ 233 "run boot_nfs\0" \ 234 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \ 235 "recovery=" \ 236 "echo BOOT: RECOVERY: SWU;" \ 237 "run boot_swu_recovery\0" \ 238 "boot_tftp=" \ 239 "if run download_kernel; then " \ 240 "setenv bootargs console=${console} " \ 241 "root=/dev/mmcblk0p2 rootwait;" \ 242 "bootm ${loadaddr} - ${fdtaddr};reset;" \ 243 "fi\0" \ 244 "addip=setenv bootargs ${bootargs} " \ 245 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \ 246 "${hostname}:eth0:on" \ 247 "\0" \ 248 "nfsargs=setenv bootargs " \ 249 "root=/dev/nfs rw " \ 250 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \ 251 "\0" \ 252 "rootpath=/srv/tftp/DISP5/rootfs\0" \ 253 "boot_nfs=" \ 254 "if run download_kernel; then " \ 255 "run nfsargs;" \ 256 "run addip;" \ 257 "setenv bootargs ${bootargs} console=${console};" \ 258 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \ 259 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \ 260 "fi\0" \ 261 "falcon_setup=" \ 262 "if mmc dev ${mmcdev}; then " \ 263 SETUP_BOOTARGS \ 264 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \ 265 "setexpr fw_sz ${fdtargslen} / 0x200; " \ 266 "setexpr fw_sz ${fw_sz} + 1; " \ 267 "mmc write ${fdtargsaddr} " \ 268 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \ 269 "fi\0" \ 270 "boot_mmc=" \ 271 "if mmc dev ${mmcdev}; then " \ 272 SETUP_BOOTARGS \ 273 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \ 274 "fi\0" \ 275 "set_kernel_part=" \ 276 "if test ${BOOT_FROM} = ACTIVE; then " \ 277 "setenv kernel_part ${kernel_part_active};" \ 278 "echo BOOT: ACTIVE;" \ 279 "else if test ${BOOT_FROM} = BACKUP; then " \ 280 "setenv kernel_part ${kernel_part_backup};" \ 281 "echo BOOT: BACKUP;" \ 282 "else " \ 283 "run recovery;" \ 284 "fi;fi\0" \ 285 "set_rootfs_part=" \ 286 "if test ${BOOT_FROM} = ACTIVE; then " \ 287 "setenv rootfs_part ${rootfs_part_active};" \ 288 "else if test ${BOOT_FROM} = BACKUP; then " \ 289 "setenv rootfs_part ${rootfs_part_backup};" \ 290 "else " \ 291 "run recovery;" \ 292 "fi;fi\0" \ 293 "BOOT_FROM=ACTIVE\0" \ 294 TFTP_UPDATE_BOOTLOADER \ 295 TFTP_UPDATE_SPINOR \ 296 "kernel_part_active=1\0" \ 297 "kernel_part_backup=3\0" \ 298 __TFTP_UPDATE_KERNEL \ 299 "rootfs_part_active=2\0" \ 300 "rootfs_part_backup=4\0" \ 301 "rootfs_file=core-image-lwn-display5.ext4\0" \ 302 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \ 303 __TFTP_UPDATE_ROOTFS \ 304 "tftp_mmc_rootfs_bkp=" \ 305 "setenv rootfs_part ${rootfs_part_backup};" \ 306 "setenv rootfs_file ${rootfs_file_backup};" \ 307 "run tftp_mmc_rootfs\0" \ 308 TFTP_UPDATE_RECOVERY_SWU_KERNEL \ 309 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \ 310 "\0" \ 311 312 /* Miscellaneous configurable options */ 313 #undef CONFIG_SYS_CBSIZE 314 #define CONFIG_SYS_CBSIZE 2048 315 316 /* Print Buffer Size */ 317 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ 318 sizeof(CONFIG_SYS_PROMPT) + 16) 319 #define CONFIG_SYS_MAXARGS 32 320 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE 321 322 #define CONFIG_STANDALONE_LOAD_ADDR 0x10001000 323 #define CONFIG_SYS_HZ 1000 324 325 /* Physical Memory Map */ 326 #define PHYS_SDRAM MMDC0_ARB_BASE_ADDR 327 #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM 328 329 #define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR 330 #define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE 331 332 #define CONFIG_SYS_INIT_SP_OFFSET \ 333 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE) 334 #define CONFIG_SYS_INIT_SP_ADDR \ 335 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET) 336 337 /* Watchdog */ 338 #if defined(CONFIG_SPL_BUILD) 339 #undef CONFIG_WDT 340 #undef CONFIG_WATCHDOG 341 #define CONFIG_HW_WATCHDOG 342 #endif 343 344 /* ENV config */ 345 #ifdef CONFIG_ENV_IS_IN_SPI_FLASH 346 /* The 0x120000 value corresponds to above SPI-NOR memory MAP */ 347 #endif 348 349 #define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW) 350 #endif /* __CONFIG_H */ 351