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_CMD_SPL 14 #define CONFIG_SYS_SPL_ARGS_ADDR 0x18000000 15 #define CONFIG_CMD_SPL_WRITE_SIZE (44 * SZ_1K) 16 17 /* Falcon Mode - MMC support */ 18 #define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR 0x3F00 19 #define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS \ 20 (CONFIG_CMD_SPL_WRITE_SIZE / 512) 21 #define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR 0x100 /* 128KiB */ 22 23 /* 24 * display5 SPI-NOR memory layout 25 * 26 * The definition can be found in Kconfig's 27 * CONFIG_MTDIDS_DEFAULT and CONFIG_MTDPARTS_DEFAULT 28 * 29 * 0x000000 - 0x020000 : SPI.SPL (128KiB) 30 * 0x020000 - 0x120000 : SPI.u-boot (1MiB) 31 * 0x120000 - 0x130000 : SPI.u-boot-env1 (64KiB) 32 * 0x130000 - 0x140000 : SPI.u-boot-env2 (64KiB) 33 * 0x140000 - 0x540000 : SPI.swupdate-kernel-FIT (4MiB) 34 * 0x540000 - 0x1540000 : SPI.swupdate-initramfs (16MiB) 35 * 0x1540000 - 0x1640000 : SPI.factory (1MiB) 36 */ 37 38 #ifndef CONFIG_SPL_BUILD 39 #define CONFIG_MTD_DEVICE 40 #define CONFIG_SPI_FLASH_MTD 41 #define CONFIG_MTD_PARTITIONS 42 #endif 43 44 /* Below values are "dummy" - only to avoid build break */ 45 #define CONFIG_SYS_SPI_KERNEL_OFFS 0x150000 46 #define CONFIG_SYS_SPI_ARGS_OFFS 0x140000 47 #define CONFIG_SYS_SPI_ARGS_SIZE 0x10000 48 49 #include "imx6_spl.h" 50 #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x20000 51 52 #define CONFIG_CMDLINE_TAG 53 #define CONFIG_SETUP_MEMORY_TAGS 54 #define CONFIG_INITRD_TAG 55 #define CONFIG_REVISION_TAG 56 57 /* Size of malloc() pool */ 58 #define CONFIG_SYS_MALLOC_LEN (16 * 1024 * 1024) 59 #define CONFIG_MISC_INIT_R 60 61 /*#define CONFIG_MXC_UART*/ 62 #define CONFIG_MXC_UART_BASE UART5_BASE 63 64 /* SPI NOR Flash */ 65 #ifdef CONFIG_CMD_SF 66 #define CONFIG_SF_DEFAULT_BUS 1 67 #define CONFIG_SF_DEFAULT_CS (0 | (IMX_GPIO_NR(5, 29) << 8)) 68 #define CONFIG_SF_DEFAULT_SPEED 50000000 69 #define CONFIG_SF_DEFAULT_MODE SPI_MODE_0 70 #endif 71 72 /* I2C Configs */ 73 #define CONFIG_SYS_I2C 74 #define CONFIG_SYS_I2C_MXC 75 #define CONFIG_SYS_I2C_MXC_I2C1 76 #define CONFIG_SYS_I2C_MXC_I2C2 77 #define CONFIG_SYS_I2C_MXC_I2C3 78 #define CONFIG_I2C_MULTI_BUS 79 #define CONFIG_SYS_I2C_SPEED 100000 80 #define CONFIG_I2C_EDID 81 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 82 83 /* Ethernet */ 84 #ifdef CONFIG_FEC_MXC 85 #define IMX_FEC_BASE ENET_BASE_ADDR 86 #define CONFIG_FEC_XCV_TYPE RGMII 87 #define CONFIG_ETHPRIME "FEC" 88 #define CONFIG_FEC_MXC_PHYADDR 0 89 #define CONFIG_MII 90 #endif 91 92 /* MMC Configs */ 93 #define CONFIG_FSL_USDHC 94 #define CONFIG_SYS_FSL_ESDHC_ADDR 0 95 #define CONFIG_SYS_FSL_USDHC_NUM 2 96 #define CONFIG_SUPPORT_EMMC_BOOT 97 98 /* allow to overwrite serial and ethaddr */ 99 #define CONFIG_ENV_OVERWRITE 100 #define CONFIG_BAUDRATE 115200 101 102 #ifndef CONFIG_BOOTCOMMAND 103 #define CONFIG_BOOTCOMMAND "if run check_em_pad; then " \ 104 "run recovery;" \ 105 "else if test ${BOOT_FROM} = FACTORY; then " \ 106 "run factory_nfs;" \ 107 "else " \ 108 "run boot_mmc;" \ 109 "fi;fi" 110 #endif 111 112 #define PARTS_DEFAULT \ 113 /* Linux partitions */ \ 114 "partitions=" \ 115 "uuid_disk=${uuid_gpt_disk};" \ 116 "name=kernel_raw1,start=128K,size=8M,uuid=${uuid_gpt_kernel_raw1};" \ 117 "name=rootfs1,size=1528M,uuid=${uuid_gpt_rootfs1};" \ 118 "name=kernel_raw2,size=8M,uuid=${uuid_gpt_kernel_raw2};" \ 119 "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \ 120 "name=data,size=-,uuid=${uuid_gpt_data}\0" 121 122 #define FACTORY_PROCEDURE \ 123 "echo '#######################';" \ 124 "echo '# Factory Boot #';" \ 125 "echo '#######################';" \ 126 "env default -a;" \ 127 "saveenv;" \ 128 "gpt write mmc ${mmcdev} ${partitions};" \ 129 "run tftp_sf_SPL;" \ 130 "run tftp_sf_uboot;" \ 131 TFTP_UPDATE_KERNEL \ 132 "run tftp_sf_fitImg_SWU;" \ 133 "run tftp_sf_initramfs_SWU;" \ 134 TFTP_UPDATE_ROOTFS \ 135 "echo '#######################';" \ 136 "echo '# END - OK #';" \ 137 "echo '#######################';" \ 138 "setenv bootcmd 'env default -a; saveenv; run falcon_setup; reset';" \ 139 "setenv boot_os 'n';" \ 140 "saveenv;" \ 141 "reset;" 142 143 #define SWUPDATE_RECOVERY_PROCEDURE \ 144 "echo '#######################';" \ 145 "echo '# RECOVERY SWUupdate #';" \ 146 "echo '#######################';" \ 147 "echo '#######################';" \ 148 "echo '# GPT verify #';" \ 149 "if gpt verify mmc ${mmcdev} ${partitions}; then " \ 150 "echo '# OK ! #';" \ 151 "else " \ 152 "echo '# FAILED ! #';" \ 153 "echo '# GPT RESTORATION #';" \ 154 "gpt write mmc ${mmcdev} ${partitions};" \ 155 "fi;" \ 156 "echo '#######################';" \ 157 "setenv loadaddr_swu_initramfs 0x14000000;" \ 158 "setenv bootargs console=${console} " \ 159 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \ 160 ":${hostname}::off root=/dev/ram rw;" \ 161 "sf probe;" \ 162 "sf read ${loadaddr} swu-kernel;" \ 163 "sf read ${loadaddr_swu_initramfs} swu-initramfs;" \ 164 "bootm ${loadaddr} ${loadaddr_swu_initramfs};reset;" 165 166 #define SETUP_BOOTARGS \ 167 "run set_rootfs_part;" \ 168 "setenv bootargs ${bootargs} console=${console} " \ 169 "root=/dev/mmcblk${mmcdev}p${rootfs_part} " \ 170 "rootwait rootfstype=ext4 rw; " \ 171 "run set_kernel_part;" \ 172 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \ 173 "mmc read ${loadaddr} ${lba_start} 0x2000; " \ 174 "setenv fdt_conf imx6q-${board}-${display}.dtb; " 175 176 /* All the numbers are in LBAs */ 177 #define __TFTP_UPDATE_KERNEL \ 178 "tftp_mmc_fitImg=" \ 179 "if test ! -n ${kernel_part}; then " \ 180 "setenv kernel_part ${kernel_part_active};" \ 181 "fi;" \ 182 "if tftp ${loadaddr} ${kernel_file}; then " \ 183 "setexpr fw_sz ${filesize} / 0x200; " \ 184 "setexpr fw_sz ${fw_sz} + 1; " \ 185 "part start mmc ${mmcdev} ${kernel_part} lba_start; " \ 186 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \ 187 "; fi\0" \ 188 189 #define TFTP_UPDATE_KERNEL \ 190 "setenv kernel_part ${kernel_part_active};" \ 191 "run tftp_mmc_fitImg;" \ 192 "setenv kernel_part ${kernel_part_backup};" \ 193 "run tftp_mmc_fitImg;" \ 194 195 #define __TFTP_UPDATE_ROOTFS \ 196 "tftp_mmc_rootfs=" \ 197 "if test ! -n ${rootfs_part}; then " \ 198 "setenv rootfs_part ${rootfs_part_active};" \ 199 "fi;" \ 200 "if tftp ${loadaddr} ${rootfs_file}; then " \ 201 "setexpr fw_sz ${filesize} / 0x200; " \ 202 "setexpr fw_sz ${fw_sz} + 1; " \ 203 "part start mmc ${mmcdev} ${rootfs_part} lba_start; " \ 204 "mmc write ${loadaddr} ${lba_start} ${fw_sz}; " \ 205 "; fi\0" \ 206 207 #define TFTP_UPDATE_ROOTFS \ 208 "setenv rootfs_part ${rootfs_part_active};" \ 209 "run tftp_mmc_rootfs;" \ 210 "run tftp_mmc_rootfs_bkp;" \ 211 212 213 #define TFTP_UPDATE_RECOVERY_SWU_KERNEL \ 214 "tftp_sf_fitImg_SWU=" \ 215 "if tftp ${loadaddr} ${kernel_file}; then " \ 216 "sf probe;" \ 217 "sf erase swu-kernel +${filesize};" \ 218 "sf write ${loadaddr} swu-kernel ${filesize};" \ 219 "; fi\0" \ 220 221 #define TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \ 222 "swu_initramfs_file=swupdate-image-display5.ext4.gz.u-boot\0" \ 223 "tftp_sf_initramfs_SWU=" \ 224 "if tftp ${loadaddr} ${swu_initramfs_file}; then " \ 225 "sf probe;" \ 226 "sf erase swu-initramfs +${filesize};" \ 227 "sf write ${loadaddr} swu-initramfs ${filesize};" \ 228 "; fi\0" \ 229 230 #define TFTP_UPDATE_BOOTLOADER \ 231 "ubootfile=u-boot.img\0" \ 232 "ubootfileSPL=SPL\0" \ 233 "tftp_sf_uboot=" \ 234 "if tftp ${loadaddr} ${ubootfile}; then " \ 235 "sf probe;" \ 236 "sf erase u-boot +${filesize};" \ 237 "sf write ${loadaddr} u-boot ${filesize}" \ 238 "; fi\0" \ 239 "tftp_sf_SPL=" \ 240 "if tftp ${loadaddr} ${ubootfileSPL}; then " \ 241 "sf probe;" \ 242 "setexpr uboot_SPL_size ${filesize} + 0x400;" \ 243 "sf erase 0x0 +${uboot_SPL_size};" \ 244 "sf write ${loadaddr} 0x400 ${filesize};" \ 245 "fi\0" \ 246 247 #define TFTP_UPDATE_SPINOR \ 248 "spinorfile=core-image-lwn-display5.spinor\0" \ 249 "spinorsize=0x2000000\0" \ 250 "tftp_sf_img=" \ 251 "if tftp ${loadaddr} ${spinorfile}; then " \ 252 "sf probe;" \ 253 "sf erase 0x0 ${spinorsize};" \ 254 "sf write ${loadaddr} 0x0 ${filesize};" \ 255 "fi\0" \ 256 257 #define CONFIG_EXTRA_ENV_SETTINGS \ 258 PARTS_DEFAULT \ 259 "gpio_recovery=93\0" \ 260 "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \ 261 "display=tianma-tm070-800x480\0" \ 262 "board=display5\0" \ 263 "mmcdev=0\0" \ 264 "altbootcmd=run recovery\0" \ 265 "bootdelay=1\0" \ 266 "baudrate=115200\0" \ 267 "bootcmd=" CONFIG_BOOTCOMMAND "\0" \ 268 "factory=" FACTORY_PROCEDURE "\0" \ 269 "bootlimit=3\0" \ 270 "ethact=FEC\0" \ 271 "netdev=eth0\0" \ 272 "boot_os=y\0" \ 273 "hostname=display5\0" \ 274 "loadaddr=0x12000000\0" \ 275 "fdtaddr=0x12800000\0" \ 276 "console=ttymxc4,115200 quiet cma=256M\0" \ 277 "fdtfile=imx6q-display5.dtb\0" \ 278 "fdt_high=0xffffffff\0" \ 279 "initrd_high=0xffffffff\0" \ 280 "kernel_file=fitImage\0" \ 281 "up=run tftp_sf_SPL; run tftp_sf_uboot\0" \ 282 "download_kernel=" \ 283 "tftpboot ${loadaddr} ${kernel_file};\0" \ 284 "factory_nfs=" \ 285 "setenv ipaddr 192.168.1.102;" \ 286 "setenv gatewayip 192.168.1.1;" \ 287 "setenv netmask 255.255.255.0;" \ 288 "setenv serverip 192.168.1.2;" \ 289 "echo BOOT: FACTORY (LEG);" \ 290 "run boot_nfs\0" \ 291 "boot_swu_recovery=" SWUPDATE_RECOVERY_PROCEDURE "\0" \ 292 "recovery=" \ 293 "echo BOOT: RECOVERY: SWU;" \ 294 "run boot_swu_recovery\0" \ 295 "boot_tftp=" \ 296 "if run download_kernel; then " \ 297 "setenv bootargs console=${console} " \ 298 "root=/dev/mmcblk0p2 rootwait;" \ 299 "bootm ${loadaddr} - ${fdtaddr};reset;" \ 300 "fi\0" \ 301 "addip=setenv bootargs ${bootargs} " \ 302 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:" \ 303 "${hostname}:eth0:on" \ 304 "\0" \ 305 "nfsargs=setenv bootargs " \ 306 "root=/dev/nfs rw " \ 307 "nfsroot=${serverip}:${rootpath},nolock,nfsvers=3" \ 308 "\0" \ 309 "rootpath=/srv/tftp/DISP5/rootfs\0" \ 310 "boot_nfs=" \ 311 "if run download_kernel; then " \ 312 "run nfsargs;" \ 313 "run addip;" \ 314 "setenv bootargs ${bootargs} console=${console};" \ 315 "setenv fdt_conf imx6q-${board}-${display}.dtb; " \ 316 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \ 317 "fi\0" \ 318 "falcon_setup=" \ 319 "if mmc dev ${mmcdev}; then " \ 320 SETUP_BOOTARGS \ 321 "spl export fdt ${loadaddr}#conf@${fdt_conf};" \ 322 "setexpr fw_sz ${fdtargslen} / 0x200; " \ 323 "setexpr fw_sz ${fw_sz} + 1; " \ 324 "mmc write ${fdtargsaddr} " \ 325 __stringify(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)" ${fw_sz}; " \ 326 "fi\0" \ 327 "boot_mmc=" \ 328 "if mmc dev ${mmcdev}; then " \ 329 SETUP_BOOTARGS \ 330 "bootm ${loadaddr}#conf@${fdt_conf};reset;" \ 331 "fi\0" \ 332 "set_kernel_part=" \ 333 "if test ${BOOT_FROM} = ACTIVE; then " \ 334 "setenv kernel_part ${kernel_part_active};" \ 335 "echo BOOT: ACTIVE;" \ 336 "else if test ${BOOT_FROM} = BACKUP; then " \ 337 "setenv kernel_part ${kernel_part_backup};" \ 338 "echo BOOT: BACKUP;" \ 339 "else " \ 340 "run recovery;" \ 341 "fi;fi\0" \ 342 "set_rootfs_part=" \ 343 "if test ${BOOT_FROM} = ACTIVE; then " \ 344 "setenv rootfs_part ${rootfs_part_active};" \ 345 "else if test ${BOOT_FROM} = BACKUP; then " \ 346 "setenv rootfs_part ${rootfs_part_backup};" \ 347 "else " \ 348 "run recovery;" \ 349 "fi;fi\0" \ 350 "BOOT_FROM=ACTIVE\0" \ 351 TFTP_UPDATE_BOOTLOADER \ 352 TFTP_UPDATE_SPINOR \ 353 "kernel_part_active=1\0" \ 354 "kernel_part_backup=3\0" \ 355 __TFTP_UPDATE_KERNEL \ 356 "rootfs_part_active=2\0" \ 357 "rootfs_part_backup=4\0" \ 358 "rootfs_file=core-image-lwn-display5.ext4\0" \ 359 "rootfs_file_backup=core-image-lwn-backup-display5.ext4\0" \ 360 __TFTP_UPDATE_ROOTFS \ 361 "tftp_mmc_rootfs_bkp=" \ 362 "setenv rootfs_part ${rootfs_part_backup};" \ 363 "setenv rootfs_file ${rootfs_file_backup};" \ 364 "run tftp_mmc_rootfs\0" \ 365 TFTP_UPDATE_RECOVERY_SWU_KERNEL \ 366 TFTP_UPDATE_RECOVERY_SWU_INITRAMFS \ 367 "\0" \ 368 369 /* Miscellaneous configurable options */ 370 #undef CONFIG_SYS_CBSIZE 371 #define CONFIG_SYS_CBSIZE 2048 372 373 /* Print Buffer Size */ 374 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \ 375 sizeof(CONFIG_SYS_PROMPT) + 16) 376 #define CONFIG_SYS_MAXARGS 32 377 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE 378 379 #define CONFIG_STANDALONE_LOAD_ADDR 0x10001000 380 #define CONFIG_SYS_HZ 1000 381 382 /* Physical Memory Map */ 383 #define CONFIG_NR_DRAM_BANKS 1 384 #define PHYS_SDRAM MMDC0_ARB_BASE_ADDR 385 #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM 386 387 #define CONFIG_SYS_INIT_RAM_ADDR IRAM_BASE_ADDR 388 #define CONFIG_SYS_INIT_RAM_SIZE IRAM_SIZE 389 390 #define CONFIG_SYS_INIT_SP_OFFSET \ 391 (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE) 392 #define CONFIG_SYS_INIT_SP_ADDR \ 393 (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET) 394 395 /* Commands */ 396 #define CONFIG_MTD_PARTITIONS 397 #define CONFIG_MTD_DEVICE 398 399 /* Watchdog */ 400 #define CONFIG_HW_WATCHDOG 401 #define CONFIG_IMX_WATCHDOG 402 #define CONFIG_WATCHDOG_TIMEOUT_MSECS 15000 403 404 /* ENV config */ 405 #ifdef CONFIG_ENV_IS_IN_SPI_FLASH 406 #define CONFIG_ENV_SIZE (SZ_64K) 407 /* The 0x120000 value corresponds to above SPI-NOR memory MAP */ 408 #define CONFIG_ENV_OFFSET (0x120000) 409 #define CONFIG_ENV_SECT_SIZE (SZ_64K) 410 #define CONFIG_SYS_REDUNDAND_ENVIRONMENT 411 #define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + \ 412 CONFIG_ENV_SECT_SIZE) 413 #define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE 414 415 #define CONFIG_ENV_SPI_BUS CONFIG_SF_DEFAULT_BUS 416 #define CONFIG_ENV_SPI_CS CONFIG_SF_DEFAULT_CS 417 #define CONFIG_ENV_SPI_MODE CONFIG_SF_DEFAULT_MODE 418 #define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED 419 #endif 420 421 #define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW) 422 #endif /* __CONFIG_H */ 423