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