1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2020 Broadcom.
10 #include <linux/sizes.h>
12 #define CONFIG_HOSTNAME "NS3"
14 /* Physical Memory Map */
15 #define V2M_BASE 0x80000000
16 #define PHYS_SDRAM_1 V2M_BASE
18 #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
19 #define CONFIG_SYS_LOAD_ADDR (PHYS_SDRAM_1 + 0x80000)
22 * Initial SP before reloaction is placed at end of first DRAM bank,
23 * which is 0x1_0000_0000.
24 * Just before re-loaction, new SP is updated and re-location happens.
25 * So pointing the initial SP to end of 2GB DDR is not a problem
27 #define CONFIG_SYS_INIT_SP_ADDR (PHYS_SDRAM_1 + 0x80000000)
28 /* 12MB Malloc size */
29 #define CONFIG_SYS_MALLOC_LEN (SZ_8M + SZ_4M)
31 /* console configuration */
32 #define CONFIG_SYS_NS16550_CLK 25000000
34 #define CONFIG_SYS_CBSIZE SZ_1K
35 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
36 sizeof(CONFIG_SYS_PROMPT) + 16)
37 #define CONFIG_SYS_MAXARGS 64
38 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
41 * Increase max uncompressed/gunzip size, keeping size same as EMMC linux
44 #define CONFIG_SYS_BOOTM_LEN 0x01800000
46 /* Access eMMC Boot_1 and Boot_2 partitions */
47 #define CONFIG_SUPPORT_EMMC_BOOT
49 /* enable 64-bit PCI resources */
50 #define CONFIG_SYS_PCI_64BIT 1
52 #define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
53 #define MAX_CPUS "max_cpus=maxcpus=8\0"
54 #define OS_LOG_LEVEL "log_level=loglevel=7\0"
55 #define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x68A10000 " \
56 "earlyelog=" __stringify(ELOG_AP_UART_LOG_BASE) ",0x10000 " \
57 "crashkernel=512M reboot=w\0"
59 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
61 #ifdef CONFIG_BCM_SF2_ETH
62 #define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0"
63 #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \
64 "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off"
70 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
72 #define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
73 " ${max_cpus} ${log_level} ${reserved_mem}"
74 #define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS " " NET_ARGS "\0"
76 #define UPDATEME_FLASH_PARAMS "bcm_compat_level=4\0" \
77 "bcm_need_recovery_rootfs=0\0" \
78 "bcm_bl_flash_pending_rfs_imgs=0\0"
80 #define KERNEL_LOADADDR_CFG \
81 "fit_image_loadaddr=0x90000000\0" \
82 "dtb_loadaddr=0x82000000\0"
84 #define INITRD_ARGS "initrd_args=root=/dev/ram rw\0"
85 #define INITRD_LOADADDR "initrd_loadaddr=0x92000000\0"
86 #define INITRD_IMAGE "initrd_image=rootfs-lake-bcm958742t.cpio.gz\0"
87 #define MMC_DEV "sd_device_number=0\0"
88 #define EXEC_STATE "exec_state=normal\0"
90 #define EXT4RD_ARGS "ext4rd_args="\
91 "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
93 #define WDT_CNTRL "wdt_enable=1\0" \
97 "mbox0_addr=0x66424024\0"\
99 "if logsetup -s ${mbox0_addr}; then "\
101 "echo ELOG is not supported by this version of the MCU patch.;"\
104 "if logsetup -c ${mbox0_addr}; then "\
105 "echo ELOG is ready;"\
107 "echo ELOG is supported, but is not set up.;"\
108 "echo Getting setup file from the server ${serverip}...;"\
109 "if tftp ${tftp_dir}elog_src.txt; then "\
110 "echo Setting up ELOG. Please wait...;"\
111 "if logsetup ${loadaddr} ${mbox0_addr} ${filesize}; "\
114 "echo [logsetup] ERROR.;"\
116 "if logsetup -c ${mbox0_addr}; then "\
117 "echo ELOG is READY.;"\
119 "echo ELOG is NOT SET UP.;"\
122 "echo ELOG setup file is not available on the server.;"\
126 /* eMMC partition for FIT images */
127 #define FIT_MMC_PARTITION \
129 "uuid_disk=${uuid_gpt_disk};" \
130 "name=env,size=512K,uuid=${uuid_gpt_env};" \
131 "name=Image_rsa.img,size=24MiB,uuid=${uuid_gpt_linux};" \
132 "name=Image1_rsa.img,size=24MiB,uuid=${uuid_gpt_linux1};" \
133 "name=Image2_rsa.img,size=24MiB,uuid=${uuid_gpt_linux2};" \
134 "name=nitro,size=8MiB,uuid=${uuid_gpt_nitro};" \
135 "name=recovery,size=940MiB,uuid=${uuid_gpt_recovery};" \
136 "name=rootfs,size=-,uuid=${uuid_gpt_prootfs}\0"
138 #define QSPI_FLASH_NITRO_PARAMS \
139 "spi_nitro_img_bin_start=0x400000\0" \
140 "spi_nitro_img_bin_mirror_start=0x580000\0" \
141 "spi_nitro_bspd_cfg_start=0x700000\0" \
142 "spi_nitro_bspd_mirror_cfg_start=0x710000\0" \
144 #define QSPI_ACCESS_ENABLE \
153 #define FUNC_QSPI_PROBE \
155 "if run qspi_access_en; then "\
157 "echo ${errstr} run qspi_access_en ** FAILED **;"\
160 "if sf probe 0; then "\
162 "echo echo ${errstr} sf probe command ** FAILED **;"\
166 #define NITRO_FW_IMAGES \
167 "nitro_bin=nitro.img\0" \
168 "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
170 #define FASTBOOT_NITRO_SETUP \
171 "nitro_fastboot_type=1\0" \
172 "nitro_fastboot_secure=1\0" \
173 "nitro_fastboot_img_buffer=0\0" \
174 "nitro_fit_img_loc=0x90000000\0"
176 #define FASTBOOT_SETUP \
177 "fastboot_nitro_setup=" \
178 "setenv errstr fastboot_setup;" \
179 "run func_qspi_probe;" \
180 /* first load header only */ \
181 "if sf read ${nitro_fit_img_loc} "\
182 "${spi_nitro_img_bin_start} 0x18; then "\
184 "echo [fastboot_nitro_setup] sf read "\
185 "${spi_nitro_img_bin_start} ** FAILED **;"\
188 "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
189 "${spi_nitro_img_bin_start}; then "\
191 "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
196 #define CHECK_CHIMP_HS\
197 "check_chimp_hs=chimp_hs"\
200 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
202 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
203 #define BOOTCMD_MMC_FIT \
205 "mmc dev ${sd_device_number};"\
206 "if test $exec_state = normal; then " \
207 "setenv use_rootfs rootfs;"\
209 "setenv use_rootfs recovery;"\
211 "echo used filesystem :${use_rootfs};"\
212 "gpt setenv mmc ${sd_device_number} ${use_rootfs};"\
213 "setenv bootargs_fs ${setbootargs} ${ext4rd_args}; run bootargs_fs;"\
214 "gpt setenv mmc ${sd_device_number} ${fit_image};"\
215 "mmc read ${fit_image_loadaddr} ${gpt_partition_addr} "\
216 "${gpt_partition_size};"\
217 "bootm ${fit_image_loadaddr}\0"
219 #define BOOTCMD_MMC_FITS \
222 "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
224 "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
226 "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
227 "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
229 #define USBDEV "usbdev=0\0"
232 "setenv usb_image_loadaddr 90000000;"\
233 "setenv fit_image Image_rsa.img;"\
234 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
235 "if usb dev ${usbdev}; && usb start; then "\
236 "echo Booting from USB...;"\
237 "fatload usb ${usbdev} ${usb_image_loadaddr} ${fit_image};"\
238 "fatload usb ${usbdev} ${initrd_loadaddr} ${initrd_image};"\
239 "bootm ${usb_image_loadaddr} ${initrd_loadaddr}:${filesize};"\
248 "bnxt_load=bnxt 0 probe "\
253 "run check_chimp_hs && "\
256 "setenv ethact bnxt_eth0;"\
257 "setenv autoload no;"\
258 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
260 "setenv pxefile_addr_r ${loadaddr};"\
262 "setenv ramdisk_addr_r ${initrd_loadaddr};"\
263 "setenv kernel_addr_r ${fit_image_loadaddr};"\
269 #define FLASH_PENDING_RFS_IMGS \
270 "flash_pending_rfs_imgs=" \
271 "if test $bcm_bl_flash_pending_rfs_imgs = 1; then " \
272 "if test $bl_flash_pending_rfs_imgs = rootfs; then " \
274 "run mmc_flash_rootfs;" \
276 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
278 "run mmc_flash_recovery;" \
280 "setenv bl_flash_pending_rfs_imgs;" \
283 #define CONFIG_BOOTCOMMAND "run flash_pending_rfs_imgs;" \
284 "run fastboot_nitro && "\
285 "run bootcmd_mmc_fits || "\
286 "run bootcmd_usb || "\
289 /* Flashing commands */
290 #define TFTP_QSPI_PARAM \
291 "fip_qspi_addr=0x0\0"\
292 "fip_qspi_mirror_addr=0x200000\0"\
293 "loadaddr=0x90000000\0"\
294 "tftpblocksize=1468\0"\
295 "qspi_flash_fip=fip\0"\
297 /* Flash fit_GPT partition to eMMC */
298 #define MMC_FLASH_FIT_GPT \
300 "if mmc dev ${sd_device_number}; then "\
302 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
306 "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
308 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
313 #define MMC_FLASH_IMAGE_RSA \
314 "mmc_flash_image_rsa="\
315 "if mmc dev ${sd_device_number}; then "\
317 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
321 "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
323 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
327 "if tftp ${loadaddr} ${tftp_dir}${fit_image}; then "\
328 "if test ${fit_image} = Image_rsa.img; then "\
329 "if setenv tftp_fit_image yes; then "\
331 "echo [mmc_flash_image_rsa] "\
332 "setenv tftp_fit_image to yes"\
338 "if test ${fit_image} = Image_rsa.img; then "\
339 "echo [mmc_flash_image_rsa] tftp "\
340 "${tftp_dir}${fit_image} ** FAILED **;"\
342 "if test ${tftp_fit_image} = yes; then "\
343 "if mmc write ${loadaddr} "\
344 "${gpt_partition_addr} "\
345 "${fileblocks}; then "\
348 "[mmc_flash_image_rsa] "\
350 "${gpt_partition_addr} "\
355 "echo [mmc_flash_image_rsa] tftp "\
356 "${tftp_dir}${fit_image} "\
362 "if math add filesize filesize 1FF; then "\
364 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
367 "if math div fileblocks filesize 200; then "\
369 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
372 "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
374 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
378 "if setenv image_sz_blk_cnt ${fileblocks}; then "\
380 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
386 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
390 #define MMC_FLASH_RECOVERY \
391 "mmc_flash_recovery="\
392 "if mmc dev ${sd_device_number}; then "\
394 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
398 "if gpt setenv mmc ${sd_device_number} recovery; then "\
400 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
404 "while tftp ${loadaddr} "\
405 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
406 "if math add filesize filesize 1FF; then "\
408 "echo [mmc_flash_recovery] math add command "\
412 "if math div fileblocks filesize 200; then "\
414 "echo [mmc_flash_recovery] math div command "\
418 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
419 "${fileblocks}; then "\
421 "echo [mmc_flash_recovery] mmc write "\
422 "${gpt_partition_addr} ** FAILED **;"\
425 "if math add index index 1; then "\
427 "echo [mmc_flash_recovery] math add command "\
431 "if math add gpt_partition_addr gpt_partition_addr"\
432 " ${fileblocks}; then "\
434 "echo [mmc_flash_recovery] math add command"\
439 "if itest ${index} -ne 1; then "\
441 "echo [mmc_flash_recovery] "\
442 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
443 "not found ** FAILED **;"\
447 #define MMC_FLASH_ROOTFS \
449 "if mmc dev ${sd_device_number}; then "\
451 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
455 "if gpt setenv mmc ${sd_device_number} rootfs; then "\
457 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
461 "while tftp ${loadaddr} "\
462 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
463 "if math add filesize filesize 1FF; then "\
465 "echo [mmc_flash_rootfs] math add command "\
469 "if math div fileblocks filesize 200; then "\
471 "echo [mmc_flash_rootfs] math div command "\
475 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
476 "${fileblocks}; then "\
478 "echo [mmc_flash_rootfs] mmc write "\
479 "${gpt_partition_addr} ** FAILED **;"\
482 "if math add index index 1; then "\
484 "echo [mmc_flash_rootfs] math add command "\
488 "if math add gpt_partition_addr gpt_partition_addr"\
489 " ${fileblocks}; then "\
491 "echo [mmc_flash_rootfs] math add command"\
496 "if itest ${index} -ne 1; then "\
498 "echo [mmc_flash_rootfs] "\
499 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
500 "not found ** FAILED **;"\
505 * For individual flash commands like mmc_flash_gpt, it is not
506 * necessary to check for errors.
507 * If any of its intermediate commands fails, then next commands
508 * will not execute. Script will exit from the failure command.
509 * For uniformity, checking for mmc_flash_gpt, mmc_flash_image_rsa
510 * mmc_flash_nitro and mmc_flash_rootfs
514 "if run mmc_flash_gpt; then "\
516 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
519 "if setenv tftp_fit_image no; then "\
521 "echo [flash_mmc] setenv tftp_fit_image to no "\
525 "if setenv fit_image Image_rsa.img; then "\
527 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
531 "if run mmc_flash_image_rsa; then "\
533 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
536 "if setenv fit_image Image1_rsa.img; then "\
538 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
542 "if run mmc_flash_image_rsa; then "\
544 "echo [flash_mmc] run mmc_flash_image_rsa "\
545 "for Image1_rsa.img ** FAILED **;"\
548 "if setenv fit_image Image2_rsa.img; then "\
550 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
554 "if run mmc_flash_image_rsa; then "\
556 "echo [flash_mmc] run mmc_flash_image_rsa "\
557 "for Image2_rsa.img ** FAILED **;"\
560 "if run mmc_flash_recovery; then "\
562 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
565 "if run mmc_flash_rootfs; then "\
567 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
571 #define FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
572 "align_erase_blk_size=" \
573 "setenv fl_write_size 0;" \
574 "if math add fl_write_size filesize FFFF; then "\
576 "echo ${errstr} math add command ** FAILED **;"\
579 "if math div fl_write_size fl_write_size 10000; then "\
581 "echo ${errstr} math div command ** FAILED **;"\
584 "if math mul fl_write_size fl_write_size 10000; then "\
586 "echo ${errstr} math mul command ** FAILED **;"\
590 #define QSPI_FLASH_FIP \
592 "if run qspi_access_en; then "\
594 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
597 "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
599 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
603 "if math add tmpsize filesize FFFF; then "\
605 "echo [flash_fip] math add command ** FAILED **;"\
608 "if math div tmpsize tmpsize 10000; then "\
610 "echo [flash_fip] math div command ** FAILED **;"\
613 "if math mul tmpsize tmpsize 10000; then "\
615 "echo [flash_fip] math mul command ** FAILED **;"\
618 "if sf probe 0; then "\
620 "echo [flash_fip] sf probe command ** FAILED **;"\
623 "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
625 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
628 "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
630 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
633 /* Flash mirror FIP image */ \
634 "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
636 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
640 "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
642 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
647 #define QSPI_FLASH_NITRO \
649 "run func_qspi_probe; "\
650 "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
652 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
656 "setenv errstr flash_nitro;" \
657 "run align_erase_blk_size;" \
658 /* Flash Nitro fw fit + configuration */ \
659 "if sf erase ${spi_nitro_img_bin_start} ${fl_write_size}; then "\
661 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
665 "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
666 " ${fl_write_size}; then "\
668 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
672 /* Mirror of Flash Nitro fw fit + configuration */ \
673 "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
675 "echo [flash_nitro] sf erase "\
676 "${spi_nitro_img_bin_mirror_start} "\
680 "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
681 " ${fl_write_size}; then "\
683 "echo [flash_nitro] sf write "\
684 "${spi_nitro_img_bin_mirror_start} "\
689 #define QSPI_FLASH_NITRO_BSPD_CONFIG \
690 "flash_nitro_bspd_config="\
691 "run func_qspi_probe; "\
692 /* Flash BSPD configuration */ \
693 "if tftp ${loadaddr} ${tftp_dir}${nitro_bspd_cfg}; then "\
694 "setenv bspd_cfg_avialable 1; "\
695 "setenv errstr flash_nitro_bspd_config; "\
696 "run align_erase_blk_size;" \
697 "if sf erase ${spi_nitro_bspd_cfg_start} "\
698 "${fl_write_size}; then "\
700 "echo [flash_nitro] sf erase "\
701 "${spi_nitro_bspd_cfg_start} "\
705 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
706 "${fl_write_size}; then "\
708 "echo [flash_nitro] sf write "\
709 "${spi_nitro_bspd_cfg_start} "\
713 /* Flash BSPD mirror configuration */ \
714 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
715 "${fl_write_size}; then "\
717 "echo [flash_nitro] sf erase "\
718 "${spi_nitro_bspd_mirror_cfg_start} "\
722 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
723 "${fl_write_size}; then "\
725 "echo [flash_nitro] sf write "\
726 "${spi_nitro_bspd_mirror_cfg_start} "\
731 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
732 "** Skip flashing bspd config file **;"\
737 "if run qspi_access_en; then "\
739 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
742 "if run flash_fip; then "\
744 "echo [flash_qspi] run flash_fip ** FAILED **;"\
747 "if run flash_nitro; then "\
749 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
753 #define FLASH_IMAGES \
755 "if run flash_qspi; then "\
757 "echo [flash_images] run flash_qspi ** FAILED **;"\
760 "if run flash_mmc; then "\
762 "echo [flash_images] run flash_mmc ** FAILED **;"\
766 #define ARCH_ENV_SETTINGS \
775 UPDATEME_FLASH_PARAMS \
786 QSPI_FLASH_NITRO_PARAMS \
790 FASTBOOT_NITRO_SETUP \
802 FLASH_PENDING_RFS_IMGS \
805 MMC_FLASH_IMAGE_RSA \
809 FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
812 QSPI_FLASH_NITRO_BSPD_CONFIG \
816 #define CONFIG_EXTRA_ENV_SETTINGS \
819 #endif /* __BCM_NS3_H */