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
21 * Initial SP before reloaction is placed at end of first DRAM bank,
22 * which is 0x1_0000_0000.
23 * Just before re-loaction, new SP is updated and re-location happens.
24 * So pointing the initial SP to end of 2GB DDR is not a problem
26 #define CONFIG_SYS_INIT_SP_ADDR (PHYS_SDRAM_1 + 0x80000000)
27 /* 12MB Malloc size */
29 /* console configuration */
30 #define CONFIG_SYS_NS16550_CLK 25000000
33 * Increase max uncompressed/gunzip size, keeping size same as EMMC linux
36 #define CONFIG_SYS_BOOTM_LEN 0x01800000
38 /* Access eMMC Boot_1 and Boot_2 partitions */
40 /* enable 64-bit PCI resources */
42 #define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
43 #define MAX_CPUS "max_cpus=maxcpus=8\0"
44 #define OS_LOG_LEVEL "log_level=loglevel=7\0"
45 #define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x68A10000 " \
46 "earlyelog=" __stringify(ELOG_AP_UART_LOG_BASE) ",0x10000 " \
47 "crashkernel=512M reboot=w\0"
49 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
51 #ifdef CONFIG_BCM_SF2_ETH
52 #define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0"
53 #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \
54 "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off"
60 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
62 #define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
63 " ${max_cpus} ${log_level} ${reserved_mem}"
64 #define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS " " NET_ARGS "\0"
66 #define UPDATEME_FLASH_PARAMS "bcm_compat_level=4\0" \
67 "bcm_need_recovery_rootfs=0\0" \
68 "bcm_bl_flash_pending_rfs_imgs=0\0"
70 #define KERNEL_LOADADDR_CFG \
71 "fit_image_loadaddr=0x90000000\0" \
72 "dtb_loadaddr=0x82000000\0"
74 #define INITRD_ARGS "initrd_args=root=/dev/ram rw\0"
75 #define INITRD_LOADADDR "initrd_loadaddr=0x92000000\0"
76 #define INITRD_IMAGE "initrd_image=rootfs-lake-bcm958742t.cpio.gz\0"
77 #define MMC_DEV "sd_device_number=0\0"
78 #define EXEC_STATE "exec_state=normal\0"
80 #define EXT4RD_ARGS "ext4rd_args="\
81 "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
83 #define WDT_CNTRL "wdt_enable=1\0" \
87 "mbox0_addr=0x66424024\0"\
89 "if logsetup -s ${mbox0_addr}; then "\
91 "echo ELOG is not supported by this version of the MCU patch.;"\
94 "if logsetup -c ${mbox0_addr}; then "\
95 "echo ELOG is ready;"\
97 "echo ELOG is supported, but is not set up.;"\
98 "echo Getting setup file from the server ${serverip}...;"\
99 "if tftp ${tftp_dir}elog_src.txt; then "\
100 "echo Setting up ELOG. Please wait...;"\
101 "if logsetup ${loadaddr} ${mbox0_addr} ${filesize}; "\
104 "echo [logsetup] ERROR.;"\
106 "if logsetup -c ${mbox0_addr}; then "\
107 "echo ELOG is READY.;"\
109 "echo ELOG is NOT SET UP.;"\
112 "echo ELOG setup file is not available on the server.;"\
116 /* eMMC partition for FIT images */
117 #define FIT_MMC_PARTITION \
119 "uuid_disk=${uuid_gpt_disk};" \
120 "name=env,size=512K,uuid=${uuid_gpt_env};" \
121 "name=Image_rsa.img,size=24MiB,uuid=${uuid_gpt_linux};" \
122 "name=Image1_rsa.img,size=24MiB,uuid=${uuid_gpt_linux1};" \
123 "name=Image2_rsa.img,size=24MiB,uuid=${uuid_gpt_linux2};" \
124 "name=nitro,size=8MiB,uuid=${uuid_gpt_nitro};" \
125 "name=recovery,size=940MiB,uuid=${uuid_gpt_recovery};" \
126 "name=rootfs,size=-,uuid=${uuid_gpt_prootfs}\0"
128 #define QSPI_FLASH_NITRO_PARAMS \
129 "spi_nitro_img_bin_start=0x400000\0" \
130 "spi_nitro_img_bin_mirror_start=0x580000\0" \
131 "spi_nitro_bspd_cfg_start=0x700000\0" \
132 "spi_nitro_bspd_mirror_cfg_start=0x710000\0" \
134 #define QSPI_ACCESS_ENABLE \
143 #define FUNC_QSPI_PROBE \
145 "if run qspi_access_en; then "\
147 "echo ${errstr} run qspi_access_en ** FAILED **;"\
150 "if sf probe 0; then "\
152 "echo echo ${errstr} sf probe command ** FAILED **;"\
156 #define NITRO_FW_IMAGES \
157 "nitro_bin=nitro.img\0" \
158 "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
160 #define FASTBOOT_NITRO_SETUP \
161 "nitro_fastboot_type=1\0" \
162 "nitro_fastboot_secure=1\0" \
163 "nitro_fastboot_img_buffer=0\0" \
164 "nitro_fit_img_loc=0x90000000\0"
166 #define FASTBOOT_SETUP \
167 "fastboot_nitro_setup=" \
168 "setenv errstr fastboot_setup;" \
169 "run func_qspi_probe;" \
170 /* first load header only */ \
171 "if sf read ${nitro_fit_img_loc} "\
172 "${spi_nitro_img_bin_start} 0x18; then "\
174 "echo [fastboot_nitro_setup] sf read "\
175 "${spi_nitro_img_bin_start} ** FAILED **;"\
178 "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
179 "${spi_nitro_img_bin_start}; then "\
181 "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
186 #define CHECK_CHIMP_HS\
187 "check_chimp_hs=chimp_hs"\
190 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
192 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
193 #define BOOTCMD_MMC_FIT \
195 "mmc dev ${sd_device_number};"\
196 "if test $exec_state = normal; then " \
197 "setenv use_rootfs rootfs;"\
199 "setenv use_rootfs recovery;"\
201 "echo used filesystem :${use_rootfs};"\
202 "gpt setenv mmc ${sd_device_number} ${use_rootfs};"\
203 "setenv bootargs_fs ${setbootargs} ${ext4rd_args}; run bootargs_fs;"\
204 "gpt setenv mmc ${sd_device_number} ${fit_image};"\
205 "mmc read ${fit_image_loadaddr} ${gpt_partition_addr} "\
206 "${gpt_partition_size};"\
207 "bootm ${fit_image_loadaddr}\0"
209 #define BOOTCMD_MMC_FITS \
212 "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
214 "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
216 "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
217 "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
219 #define USBDEV "usbdev=0\0"
222 "setenv usb_image_loadaddr 90000000;"\
223 "setenv fit_image Image_rsa.img;"\
224 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
225 "if usb dev ${usbdev}; && usb start; then "\
226 "echo Booting from USB...;"\
227 "fatload usb ${usbdev} ${usb_image_loadaddr} ${fit_image};"\
228 "fatload usb ${usbdev} ${initrd_loadaddr} ${initrd_image};"\
229 "bootm ${usb_image_loadaddr} ${initrd_loadaddr}:${filesize};"\
238 "bnxt_load=bnxt 0 probe "\
243 "run check_chimp_hs && "\
246 "setenv ethact bnxt_eth0;"\
247 "setenv autoload no;"\
248 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
250 "setenv pxefile_addr_r ${loadaddr};"\
252 "setenv ramdisk_addr_r ${initrd_loadaddr};"\
253 "setenv kernel_addr_r ${fit_image_loadaddr};"\
259 #define FLASH_PENDING_RFS_IMGS \
260 "flash_pending_rfs_imgs=" \
261 "if test $bcm_bl_flash_pending_rfs_imgs = 1; then " \
262 "if test $bl_flash_pending_rfs_imgs = rootfs; then " \
264 "run mmc_flash_rootfs;" \
266 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
268 "run mmc_flash_recovery;" \
270 "setenv bl_flash_pending_rfs_imgs;" \
273 /* Flashing commands */
274 #define TFTP_QSPI_PARAM \
275 "fip_qspi_addr=0x0\0"\
276 "fip_qspi_mirror_addr=0x200000\0"\
277 "loadaddr=0x90000000\0"\
278 "tftpblocksize=1468\0"\
279 "qspi_flash_fip=fip\0"\
281 /* Flash fit_GPT partition to eMMC */
282 #define MMC_FLASH_FIT_GPT \
284 "if mmc dev ${sd_device_number}; then "\
286 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
290 "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
292 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
297 #define MMC_FLASH_IMAGE_RSA \
298 "mmc_flash_image_rsa="\
299 "if mmc dev ${sd_device_number}; then "\
301 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
305 "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
307 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
311 "if tftp ${loadaddr} ${tftp_dir}${fit_image}; then "\
312 "if test ${fit_image} = Image_rsa.img; then "\
313 "if setenv tftp_fit_image yes; then "\
315 "echo [mmc_flash_image_rsa] "\
316 "setenv tftp_fit_image to yes"\
322 "if test ${fit_image} = Image_rsa.img; then "\
323 "echo [mmc_flash_image_rsa] tftp "\
324 "${tftp_dir}${fit_image} ** FAILED **;"\
326 "if test ${tftp_fit_image} = yes; then "\
327 "if mmc write ${loadaddr} "\
328 "${gpt_partition_addr} "\
329 "${fileblocks}; then "\
332 "[mmc_flash_image_rsa] "\
334 "${gpt_partition_addr} "\
339 "echo [mmc_flash_image_rsa] tftp "\
340 "${tftp_dir}${fit_image} "\
346 "if math add filesize filesize 1FF; then "\
348 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
351 "if math div fileblocks filesize 200; then "\
353 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
356 "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
358 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
362 "if setenv image_sz_blk_cnt ${fileblocks}; then "\
364 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
370 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
374 #define MMC_FLASH_RECOVERY \
375 "mmc_flash_recovery="\
376 "if mmc dev ${sd_device_number}; then "\
378 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
382 "if gpt setenv mmc ${sd_device_number} recovery; then "\
384 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
388 "while tftp ${loadaddr} "\
389 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
390 "if math add filesize filesize 1FF; then "\
392 "echo [mmc_flash_recovery] math add command "\
396 "if math div fileblocks filesize 200; then "\
398 "echo [mmc_flash_recovery] math div command "\
402 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
403 "${fileblocks}; then "\
405 "echo [mmc_flash_recovery] mmc write "\
406 "${gpt_partition_addr} ** FAILED **;"\
409 "if math add index index 1; then "\
411 "echo [mmc_flash_recovery] math add command "\
415 "if math add gpt_partition_addr gpt_partition_addr"\
416 " ${fileblocks}; then "\
418 "echo [mmc_flash_recovery] math add command"\
423 "if itest ${index} -ne 1; then "\
425 "echo [mmc_flash_recovery] "\
426 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
427 "not found ** FAILED **;"\
431 #define MMC_FLASH_ROOTFS \
433 "if mmc dev ${sd_device_number}; then "\
435 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
439 "if gpt setenv mmc ${sd_device_number} rootfs; then "\
441 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
445 "while tftp ${loadaddr} "\
446 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
447 "if math add filesize filesize 1FF; then "\
449 "echo [mmc_flash_rootfs] math add command "\
453 "if math div fileblocks filesize 200; then "\
455 "echo [mmc_flash_rootfs] math div command "\
459 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
460 "${fileblocks}; then "\
462 "echo [mmc_flash_rootfs] mmc write "\
463 "${gpt_partition_addr} ** FAILED **;"\
466 "if math add index index 1; then "\
468 "echo [mmc_flash_rootfs] math add command "\
472 "if math add gpt_partition_addr gpt_partition_addr"\
473 " ${fileblocks}; then "\
475 "echo [mmc_flash_rootfs] math add command"\
480 "if itest ${index} -ne 1; then "\
482 "echo [mmc_flash_rootfs] "\
483 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
484 "not found ** FAILED **;"\
489 * For individual flash commands like mmc_flash_gpt, it is not
490 * necessary to check for errors.
491 * If any of its intermediate commands fails, then next commands
492 * will not execute. Script will exit from the failure command.
493 * For uniformity, checking for mmc_flash_gpt, mmc_flash_image_rsa
494 * mmc_flash_nitro and mmc_flash_rootfs
498 "if run mmc_flash_gpt; then "\
500 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
503 "if setenv tftp_fit_image no; then "\
505 "echo [flash_mmc] setenv tftp_fit_image to no "\
509 "if setenv fit_image Image_rsa.img; then "\
511 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
515 "if run mmc_flash_image_rsa; then "\
517 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
520 "if setenv fit_image Image1_rsa.img; then "\
522 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
526 "if run mmc_flash_image_rsa; then "\
528 "echo [flash_mmc] run mmc_flash_image_rsa "\
529 "for Image1_rsa.img ** FAILED **;"\
532 "if setenv fit_image Image2_rsa.img; then "\
534 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
538 "if run mmc_flash_image_rsa; then "\
540 "echo [flash_mmc] run mmc_flash_image_rsa "\
541 "for Image2_rsa.img ** FAILED **;"\
544 "if run mmc_flash_recovery; then "\
546 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
549 "if run mmc_flash_rootfs; then "\
551 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
555 #define FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
556 "align_erase_blk_size=" \
557 "setenv fl_write_size 0;" \
558 "if math add fl_write_size filesize FFFF; then "\
560 "echo ${errstr} math add command ** FAILED **;"\
563 "if math div fl_write_size fl_write_size 10000; then "\
565 "echo ${errstr} math div command ** FAILED **;"\
568 "if math mul fl_write_size fl_write_size 10000; then "\
570 "echo ${errstr} math mul command ** FAILED **;"\
574 #define QSPI_FLASH_FIP \
576 "if run qspi_access_en; then "\
578 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
581 "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
583 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
587 "if math add tmpsize filesize FFFF; then "\
589 "echo [flash_fip] math add command ** FAILED **;"\
592 "if math div tmpsize tmpsize 10000; then "\
594 "echo [flash_fip] math div command ** FAILED **;"\
597 "if math mul tmpsize tmpsize 10000; then "\
599 "echo [flash_fip] math mul command ** FAILED **;"\
602 "if sf probe 0; then "\
604 "echo [flash_fip] sf probe command ** FAILED **;"\
607 "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
609 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
612 "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
614 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
617 /* Flash mirror FIP image */ \
618 "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
620 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
624 "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
626 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
631 #define QSPI_FLASH_NITRO \
633 "run func_qspi_probe; "\
634 "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
636 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
640 "setenv errstr flash_nitro;" \
641 "run align_erase_blk_size;" \
642 /* Flash Nitro fw fit + configuration */ \
643 "if sf erase ${spi_nitro_img_bin_start} ${fl_write_size}; then "\
645 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
649 "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
650 " ${fl_write_size}; then "\
652 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
656 /* Mirror of Flash Nitro fw fit + configuration */ \
657 "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
659 "echo [flash_nitro] sf erase "\
660 "${spi_nitro_img_bin_mirror_start} "\
664 "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
665 " ${fl_write_size}; then "\
667 "echo [flash_nitro] sf write "\
668 "${spi_nitro_img_bin_mirror_start} "\
673 #define QSPI_FLASH_NITRO_BSPD_CONFIG \
674 "flash_nitro_bspd_config="\
675 "run func_qspi_probe; "\
676 /* Flash BSPD configuration */ \
677 "if tftp ${loadaddr} ${tftp_dir}${nitro_bspd_cfg}; then "\
678 "setenv bspd_cfg_avialable 1; "\
679 "setenv errstr flash_nitro_bspd_config; "\
680 "run align_erase_blk_size;" \
681 "if sf erase ${spi_nitro_bspd_cfg_start} "\
682 "${fl_write_size}; then "\
684 "echo [flash_nitro] sf erase "\
685 "${spi_nitro_bspd_cfg_start} "\
689 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
690 "${fl_write_size}; then "\
692 "echo [flash_nitro] sf write "\
693 "${spi_nitro_bspd_cfg_start} "\
697 /* Flash BSPD mirror configuration */ \
698 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
699 "${fl_write_size}; then "\
701 "echo [flash_nitro] sf erase "\
702 "${spi_nitro_bspd_mirror_cfg_start} "\
706 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
707 "${fl_write_size}; then "\
709 "echo [flash_nitro] sf write "\
710 "${spi_nitro_bspd_mirror_cfg_start} "\
715 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
716 "** Skip flashing bspd config file **;"\
721 "if run qspi_access_en; then "\
723 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
726 "if run flash_fip; then "\
728 "echo [flash_qspi] run flash_fip ** FAILED **;"\
731 "if run flash_nitro; then "\
733 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
737 #define FLASH_IMAGES \
739 "if run flash_qspi; then "\
741 "echo [flash_images] run flash_qspi ** FAILED **;"\
744 "if run flash_mmc; then "\
746 "echo [flash_images] run flash_mmc ** FAILED **;"\
750 #define ARCH_ENV_SETTINGS \
759 UPDATEME_FLASH_PARAMS \
770 QSPI_FLASH_NITRO_PARAMS \
774 FASTBOOT_NITRO_SETUP \
786 FLASH_PENDING_RFS_IMGS \
789 MMC_FLASH_IMAGE_RSA \
793 FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
796 QSPI_FLASH_NITRO_BSPD_CONFIG \
800 #define CONFIG_EXTRA_ENV_SETTINGS \
803 #endif /* __BCM_NS3_H */