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