1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2020 Broadcom.
10 #include <linux/sizes.h>
12 /* Physical Memory Map */
13 #define V2M_BASE 0x80000000
14 #define PHYS_SDRAM_1 V2M_BASE
16 #define CFG_SYS_SDRAM_BASE PHYS_SDRAM_1
19 * Initial SP before reloaction is placed at end of first DRAM bank,
20 * which is 0x1_0000_0000.
21 * Just before re-loaction, new SP is updated and re-location happens.
22 * So pointing the initial SP to end of 2GB DDR is not a problem
24 /* 12MB Malloc size */
26 /* console configuration */
27 #define CFG_SYS_NS16550_CLK 25000000
30 * Increase max uncompressed/gunzip size, keeping size same as EMMC linux
34 /* Access eMMC Boot_1 and Boot_2 partitions */
36 /* enable 64-bit PCI resources */
38 #define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
39 #define MAX_CPUS "max_cpus=maxcpus=8\0"
40 #define OS_LOG_LEVEL "log_level=loglevel=7\0"
41 #define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x68A10000 " \
42 "earlyelog=" __stringify(ELOG_AP_UART_LOG_BASE) ",0x10000 " \
43 "crashkernel=512M reboot=w\0"
45 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
47 #ifdef CONFIG_BCM_SF2_ETH
48 #define BCM_ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0"
49 #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \
50 "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off"
56 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
58 #define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
59 " ${max_cpus} ${log_level} ${reserved_mem}"
60 #define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS " " NET_ARGS "\0"
62 #define UPDATEME_FLASH_PARAMS "bcm_compat_level=4\0" \
63 "bcm_need_recovery_rootfs=0\0" \
64 "bcm_bl_flash_pending_rfs_imgs=0\0"
66 #define KERNEL_LOADADDR_CFG \
67 "fit_image_loadaddr=0x90000000\0" \
68 "dtb_loadaddr=0x82000000\0"
70 #define INITRD_ARGS "initrd_args=root=/dev/ram rw\0"
71 #define INITRD_LOADADDR "initrd_loadaddr=0x92000000\0"
72 #define INITRD_IMAGE "initrd_image=rootfs-lake-bcm958742t.cpio.gz\0"
73 #define MMC_DEV "sd_device_number=0\0"
74 #define EXEC_STATE "exec_state=normal\0"
76 #define EXT4RD_ARGS "ext4rd_args="\
77 "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
79 #define WDT_CNTRL "wdt_enable=1\0" \
83 "mbox0_addr=0x66424024\0"\
85 "if logsetup -s ${mbox0_addr}; then "\
87 "echo ELOG is not supported by this version of the MCU patch.;"\
90 "if logsetup -c ${mbox0_addr}; then "\
91 "echo ELOG is ready;"\
93 "echo ELOG is supported, but is not set up.;"\
94 "echo Getting setup file from the server ${serverip}...;"\
95 "if tftp ${tftp_dir}elog_src.txt; then "\
96 "echo Setting up ELOG. Please wait...;"\
97 "if logsetup ${loadaddr} ${mbox0_addr} ${filesize}; "\
100 "echo [logsetup] ERROR.;"\
102 "if logsetup -c ${mbox0_addr}; then "\
103 "echo ELOG is READY.;"\
105 "echo ELOG is NOT SET UP.;"\
108 "echo ELOG setup file is not available on the server.;"\
112 /* eMMC partition for FIT images */
113 #define FIT_MMC_PARTITION \
115 "uuid_disk=${uuid_gpt_disk};" \
116 "name=env,size=512K,uuid=${uuid_gpt_env};" \
117 "name=Image_rsa.img,size=24MiB,uuid=${uuid_gpt_linux};" \
118 "name=Image1_rsa.img,size=24MiB,uuid=${uuid_gpt_linux1};" \
119 "name=Image2_rsa.img,size=24MiB,uuid=${uuid_gpt_linux2};" \
120 "name=nitro,size=8MiB,uuid=${uuid_gpt_nitro};" \
121 "name=recovery,size=940MiB,uuid=${uuid_gpt_recovery};" \
122 "name=rootfs,size=-,uuid=${uuid_gpt_prootfs}\0"
124 #define QSPI_FLASH_NITRO_PARAMS \
125 "spi_nitro_img_bin_start=0x400000\0" \
126 "spi_nitro_img_bin_mirror_start=0x580000\0" \
127 "spi_nitro_bspd_cfg_start=0x700000\0" \
128 "spi_nitro_bspd_mirror_cfg_start=0x710000\0" \
130 #define QSPI_ACCESS_ENABLE \
139 #define FUNC_QSPI_PROBE \
141 "if run qspi_access_en; then "\
143 "echo ${errstr} run qspi_access_en ** FAILED **;"\
146 "if sf probe 0; then "\
148 "echo echo ${errstr} sf probe command ** FAILED **;"\
152 #define NITRO_FW_IMAGES \
153 "nitro_bin=nitro.img\0" \
154 "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
156 #define FASTBOOT_NITRO_SETUP \
157 "nitro_fastboot_type=1\0" \
158 "nitro_fastboot_secure=1\0" \
159 "nitro_fastboot_img_buffer=0\0" \
160 "nitro_fit_img_loc=0x90000000\0"
162 #define FASTBOOT_SETUP \
163 "fastboot_nitro_setup=" \
164 "setenv errstr fastboot_setup;" \
165 "run func_qspi_probe;" \
166 /* first load header only */ \
167 "if sf read ${nitro_fit_img_loc} "\
168 "${spi_nitro_img_bin_start} 0x18; then "\
170 "echo [fastboot_nitro_setup] sf read "\
171 "${spi_nitro_img_bin_start} ** FAILED **;"\
174 "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
175 "${spi_nitro_img_bin_start}; then "\
177 "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
182 #define CHECK_CHIMP_HS\
183 "check_chimp_hs=chimp_hs"\
186 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
188 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
189 #define BOOTCMD_MMC_FIT \
191 "mmc dev ${sd_device_number};"\
192 "if test $exec_state = normal; then " \
193 "setenv use_rootfs rootfs;"\
195 "setenv use_rootfs recovery;"\
197 "echo used filesystem :${use_rootfs};"\
198 "gpt setenv mmc ${sd_device_number} ${use_rootfs};"\
199 "setenv bootargs_fs ${setbootargs} ${ext4rd_args}; run bootargs_fs;"\
200 "gpt setenv mmc ${sd_device_number} ${fit_image};"\
201 "mmc read ${fit_image_loadaddr} ${gpt_partition_addr} "\
202 "${gpt_partition_size};"\
203 "bootm ${fit_image_loadaddr}\0"
205 #define BOOTCMD_MMC_FITS \
208 "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
210 "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
212 "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
213 "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
215 #define USBDEV "usbdev=0\0"
218 "setenv usb_image_loadaddr 90000000;"\
219 "setenv fit_image Image_rsa.img;"\
220 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
221 "if usb dev ${usbdev}; && usb start; then "\
222 "echo Booting from USB...;"\
223 "fatload usb ${usbdev} ${usb_image_loadaddr} ${fit_image};"\
224 "fatload usb ${usbdev} ${initrd_loadaddr} ${initrd_image};"\
225 "bootm ${usb_image_loadaddr} ${initrd_loadaddr}:${filesize};"\
234 "bnxt_load=bnxt 0 probe "\
239 "run check_chimp_hs && "\
242 "setenv ethact bnxt_eth0;"\
243 "setenv autoload no;"\
244 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
246 "setenv pxefile_addr_r ${loadaddr};"\
248 "setenv ramdisk_addr_r ${initrd_loadaddr};"\
249 "setenv kernel_addr_r ${fit_image_loadaddr};"\
255 #define FLASH_PENDING_RFS_IMGS \
256 "flash_pending_rfs_imgs=" \
257 "if test $bcm_bl_flash_pending_rfs_imgs = 1; then " \
258 "if test $bl_flash_pending_rfs_imgs = rootfs; then " \
260 "run mmc_flash_rootfs;" \
262 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
264 "run mmc_flash_recovery;" \
266 "setenv bl_flash_pending_rfs_imgs;" \
269 /* Flashing commands */
270 #define TFTP_QSPI_PARAM \
271 "fip_qspi_addr=0x0\0"\
272 "fip_qspi_mirror_addr=0x200000\0"\
273 "loadaddr=0x90000000\0"\
274 "tftpblocksize=1468\0"\
275 "qspi_flash_fip=fip\0"\
277 /* Flash fit_GPT partition to eMMC */
278 #define MMC_FLASH_FIT_GPT \
280 "if mmc dev ${sd_device_number}; then "\
282 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
286 "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
288 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
293 #define MMC_FLASH_IMAGE_RSA \
294 "mmc_flash_image_rsa="\
295 "if mmc dev ${sd_device_number}; then "\
297 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
301 "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
303 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
307 "if tftp ${loadaddr} ${tftp_dir}${fit_image}; then "\
308 "if test ${fit_image} = Image_rsa.img; then "\
309 "if setenv tftp_fit_image yes; then "\
311 "echo [mmc_flash_image_rsa] "\
312 "setenv tftp_fit_image to yes"\
318 "if test ${fit_image} = Image_rsa.img; then "\
319 "echo [mmc_flash_image_rsa] tftp "\
320 "${tftp_dir}${fit_image} ** FAILED **;"\
322 "if test ${tftp_fit_image} = yes; then "\
323 "if mmc write ${loadaddr} "\
324 "${gpt_partition_addr} "\
325 "${fileblocks}; then "\
328 "[mmc_flash_image_rsa] "\
330 "${gpt_partition_addr} "\
335 "echo [mmc_flash_image_rsa] tftp "\
336 "${tftp_dir}${fit_image} "\
342 "if math add filesize filesize 1FF; then "\
344 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
347 "if math div fileblocks filesize 200; then "\
349 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
352 "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
354 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
358 "if setenv image_sz_blk_cnt ${fileblocks}; then "\
360 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
366 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
370 #define MMC_FLASH_RECOVERY \
371 "mmc_flash_recovery="\
372 "if mmc dev ${sd_device_number}; then "\
374 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
378 "if gpt setenv mmc ${sd_device_number} recovery; then "\
380 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
384 "while tftp ${loadaddr} "\
385 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
386 "if math add filesize filesize 1FF; then "\
388 "echo [mmc_flash_recovery] math add command "\
392 "if math div fileblocks filesize 200; then "\
394 "echo [mmc_flash_recovery] math div command "\
398 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
399 "${fileblocks}; then "\
401 "echo [mmc_flash_recovery] mmc write "\
402 "${gpt_partition_addr} ** FAILED **;"\
405 "if math add index index 1; then "\
407 "echo [mmc_flash_recovery] math add command "\
411 "if math add gpt_partition_addr gpt_partition_addr"\
412 " ${fileblocks}; then "\
414 "echo [mmc_flash_recovery] math add command"\
419 "if itest ${index} -ne 1; then "\
421 "echo [mmc_flash_recovery] "\
422 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
423 "not found ** FAILED **;"\
427 #define MMC_FLASH_ROOTFS \
429 "if mmc dev ${sd_device_number}; then "\
431 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
435 "if gpt setenv mmc ${sd_device_number} rootfs; then "\
437 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
441 "while tftp ${loadaddr} "\
442 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
443 "if math add filesize filesize 1FF; then "\
445 "echo [mmc_flash_rootfs] math add command "\
449 "if math div fileblocks filesize 200; then "\
451 "echo [mmc_flash_rootfs] math div command "\
455 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
456 "${fileblocks}; then "\
458 "echo [mmc_flash_rootfs] mmc write "\
459 "${gpt_partition_addr} ** FAILED **;"\
462 "if math add index index 1; then "\
464 "echo [mmc_flash_rootfs] math add command "\
468 "if math add gpt_partition_addr gpt_partition_addr"\
469 " ${fileblocks}; then "\
471 "echo [mmc_flash_rootfs] math add command"\
476 "if itest ${index} -ne 1; then "\
478 "echo [mmc_flash_rootfs] "\
479 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
480 "not found ** FAILED **;"\
485 * For individual flash commands like mmc_flash_gpt, it is not
486 * necessary to check for errors.
487 * If any of its intermediate commands fails, then next commands
488 * will not execute. Script will exit from the failure command.
489 * For uniformity, checking for mmc_flash_gpt, mmc_flash_image_rsa
490 * mmc_flash_nitro and mmc_flash_rootfs
494 "if run mmc_flash_gpt; then "\
496 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
499 "if setenv tftp_fit_image no; then "\
501 "echo [flash_mmc] setenv tftp_fit_image to no "\
505 "if setenv fit_image Image_rsa.img; then "\
507 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
511 "if run mmc_flash_image_rsa; then "\
513 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
516 "if setenv fit_image Image1_rsa.img; then "\
518 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
522 "if run mmc_flash_image_rsa; then "\
524 "echo [flash_mmc] run mmc_flash_image_rsa "\
525 "for Image1_rsa.img ** FAILED **;"\
528 "if setenv fit_image Image2_rsa.img; then "\
530 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
534 "if run mmc_flash_image_rsa; then "\
536 "echo [flash_mmc] run mmc_flash_image_rsa "\
537 "for Image2_rsa.img ** FAILED **;"\
540 "if run mmc_flash_recovery; then "\
542 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
545 "if run mmc_flash_rootfs; then "\
547 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
551 #define FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
552 "align_erase_blk_size=" \
553 "setenv fl_write_size 0;" \
554 "if math add fl_write_size filesize FFFF; then "\
556 "echo ${errstr} math add command ** FAILED **;"\
559 "if math div fl_write_size fl_write_size 10000; then "\
561 "echo ${errstr} math div command ** FAILED **;"\
564 "if math mul fl_write_size fl_write_size 10000; then "\
566 "echo ${errstr} math mul command ** FAILED **;"\
570 #define QSPI_FLASH_FIP \
572 "if run qspi_access_en; then "\
574 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
577 "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
579 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
583 "if math add tmpsize filesize FFFF; then "\
585 "echo [flash_fip] math add command ** FAILED **;"\
588 "if math div tmpsize tmpsize 10000; then "\
590 "echo [flash_fip] math div command ** FAILED **;"\
593 "if math mul tmpsize tmpsize 10000; then "\
595 "echo [flash_fip] math mul command ** FAILED **;"\
598 "if sf probe 0; then "\
600 "echo [flash_fip] sf probe command ** FAILED **;"\
603 "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
605 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
608 "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
610 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
613 /* Flash mirror FIP image */ \
614 "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
616 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
620 "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
622 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
627 #define QSPI_FLASH_NITRO \
629 "run func_qspi_probe; "\
630 "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
632 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
636 "setenv errstr flash_nitro;" \
637 "run align_erase_blk_size;" \
638 /* Flash Nitro fw fit + configuration */ \
639 "if sf erase ${spi_nitro_img_bin_start} ${fl_write_size}; then "\
641 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
645 "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
646 " ${fl_write_size}; then "\
648 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
652 /* Mirror of Flash Nitro fw fit + configuration */ \
653 "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
655 "echo [flash_nitro] sf erase "\
656 "${spi_nitro_img_bin_mirror_start} "\
660 "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
661 " ${fl_write_size}; then "\
663 "echo [flash_nitro] sf write "\
664 "${spi_nitro_img_bin_mirror_start} "\
669 #define QSPI_FLASH_NITRO_BSPD_CONFIG \
670 "flash_nitro_bspd_config="\
671 "run func_qspi_probe; "\
672 /* Flash BSPD configuration */ \
673 "if tftp ${loadaddr} ${tftp_dir}${nitro_bspd_cfg}; then "\
674 "setenv bspd_cfg_avialable 1; "\
675 "setenv errstr flash_nitro_bspd_config; "\
676 "run align_erase_blk_size;" \
677 "if sf erase ${spi_nitro_bspd_cfg_start} "\
678 "${fl_write_size}; then "\
680 "echo [flash_nitro] sf erase "\
681 "${spi_nitro_bspd_cfg_start} "\
685 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
686 "${fl_write_size}; then "\
688 "echo [flash_nitro] sf write "\
689 "${spi_nitro_bspd_cfg_start} "\
693 /* Flash BSPD mirror configuration */ \
694 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
695 "${fl_write_size}; then "\
697 "echo [flash_nitro] sf erase "\
698 "${spi_nitro_bspd_mirror_cfg_start} "\
702 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
703 "${fl_write_size}; then "\
705 "echo [flash_nitro] sf write "\
706 "${spi_nitro_bspd_mirror_cfg_start} "\
711 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
712 "** Skip flashing bspd config file **;"\
717 "if run qspi_access_en; then "\
719 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
722 "if run flash_fip; then "\
724 "echo [flash_qspi] run flash_fip ** FAILED **;"\
727 "if run flash_nitro; then "\
729 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
733 #define FLASH_IMAGES \
735 "if run flash_qspi; then "\
737 "echo [flash_images] run flash_qspi ** FAILED **;"\
740 "if run flash_mmc; then "\
742 "echo [flash_images] run flash_mmc ** FAILED **;"\
746 #define ARCH_ENV_SETTINGS \
755 UPDATEME_FLASH_PARAMS \
766 QSPI_FLASH_NITRO_PARAMS \
770 FASTBOOT_NITRO_SETUP \
782 FLASH_PENDING_RFS_IMGS \
785 MMC_FLASH_IMAGE_RSA \
789 FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
792 QSPI_FLASH_NITRO_BSPD_CONFIG \
796 #define CFG_EXTRA_ENV_SETTINGS \
799 #endif /* __BCM_NS3_H */