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