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 /* 12MB Malloc size */
28 /* console configuration */
29 #define CONFIG_SYS_NS16550_CLK 25000000
32 * Increase max uncompressed/gunzip size, keeping size same as EMMC linux
36 /* Access eMMC Boot_1 and Boot_2 partitions */
38 /* enable 64-bit PCI resources */
40 #define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
41 #define MAX_CPUS "max_cpus=maxcpus=8\0"
42 #define OS_LOG_LEVEL "log_level=loglevel=7\0"
43 #define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x68A10000 " \
44 "earlyelog=" __stringify(ELOG_AP_UART_LOG_BASE) ",0x10000 " \
45 "crashkernel=512M reboot=w\0"
47 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
49 #ifdef CONFIG_BCM_SF2_ETH
50 #define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0"
51 #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \
52 "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off"
58 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
60 #define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
61 " ${max_cpus} ${log_level} ${reserved_mem}"
62 #define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS " " NET_ARGS "\0"
64 #define UPDATEME_FLASH_PARAMS "bcm_compat_level=4\0" \
65 "bcm_need_recovery_rootfs=0\0" \
66 "bcm_bl_flash_pending_rfs_imgs=0\0"
68 #define KERNEL_LOADADDR_CFG \
69 "fit_image_loadaddr=0x90000000\0" \
70 "dtb_loadaddr=0x82000000\0"
72 #define INITRD_ARGS "initrd_args=root=/dev/ram rw\0"
73 #define INITRD_LOADADDR "initrd_loadaddr=0x92000000\0"
74 #define INITRD_IMAGE "initrd_image=rootfs-lake-bcm958742t.cpio.gz\0"
75 #define MMC_DEV "sd_device_number=0\0"
76 #define EXEC_STATE "exec_state=normal\0"
78 #define EXT4RD_ARGS "ext4rd_args="\
79 "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
81 #define WDT_CNTRL "wdt_enable=1\0" \
85 "mbox0_addr=0x66424024\0"\
87 "if logsetup -s ${mbox0_addr}; then "\
89 "echo ELOG is not supported by this version of the MCU patch.;"\
92 "if logsetup -c ${mbox0_addr}; then "\
93 "echo ELOG is ready;"\
95 "echo ELOG is supported, but is not set up.;"\
96 "echo Getting setup file from the server ${serverip}...;"\
97 "if tftp ${tftp_dir}elog_src.txt; then "\
98 "echo Setting up ELOG. Please wait...;"\
99 "if logsetup ${loadaddr} ${mbox0_addr} ${filesize}; "\
102 "echo [logsetup] ERROR.;"\
104 "if logsetup -c ${mbox0_addr}; then "\
105 "echo ELOG is READY.;"\
107 "echo ELOG is NOT SET UP.;"\
110 "echo ELOG setup file is not available on the server.;"\
114 /* eMMC partition for FIT images */
115 #define FIT_MMC_PARTITION \
117 "uuid_disk=${uuid_gpt_disk};" \
118 "name=env,size=512K,uuid=${uuid_gpt_env};" \
119 "name=Image_rsa.img,size=24MiB,uuid=${uuid_gpt_linux};" \
120 "name=Image1_rsa.img,size=24MiB,uuid=${uuid_gpt_linux1};" \
121 "name=Image2_rsa.img,size=24MiB,uuid=${uuid_gpt_linux2};" \
122 "name=nitro,size=8MiB,uuid=${uuid_gpt_nitro};" \
123 "name=recovery,size=940MiB,uuid=${uuid_gpt_recovery};" \
124 "name=rootfs,size=-,uuid=${uuid_gpt_prootfs}\0"
126 #define QSPI_FLASH_NITRO_PARAMS \
127 "spi_nitro_img_bin_start=0x400000\0" \
128 "spi_nitro_img_bin_mirror_start=0x580000\0" \
129 "spi_nitro_bspd_cfg_start=0x700000\0" \
130 "spi_nitro_bspd_mirror_cfg_start=0x710000\0" \
132 #define QSPI_ACCESS_ENABLE \
141 #define FUNC_QSPI_PROBE \
143 "if run qspi_access_en; then "\
145 "echo ${errstr} run qspi_access_en ** FAILED **;"\
148 "if sf probe 0; then "\
150 "echo echo ${errstr} sf probe command ** FAILED **;"\
154 #define NITRO_FW_IMAGES \
155 "nitro_bin=nitro.img\0" \
156 "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
158 #define FASTBOOT_NITRO_SETUP \
159 "nitro_fastboot_type=1\0" \
160 "nitro_fastboot_secure=1\0" \
161 "nitro_fastboot_img_buffer=0\0" \
162 "nitro_fit_img_loc=0x90000000\0"
164 #define FASTBOOT_SETUP \
165 "fastboot_nitro_setup=" \
166 "setenv errstr fastboot_setup;" \
167 "run func_qspi_probe;" \
168 /* first load header only */ \
169 "if sf read ${nitro_fit_img_loc} "\
170 "${spi_nitro_img_bin_start} 0x18; then "\
172 "echo [fastboot_nitro_setup] sf read "\
173 "${spi_nitro_img_bin_start} ** FAILED **;"\
176 "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
177 "${spi_nitro_img_bin_start}; then "\
179 "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
184 #define CHECK_CHIMP_HS\
185 "check_chimp_hs=chimp_hs"\
188 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
190 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
191 #define BOOTCMD_MMC_FIT \
193 "mmc dev ${sd_device_number};"\
194 "if test $exec_state = normal; then " \
195 "setenv use_rootfs rootfs;"\
197 "setenv use_rootfs recovery;"\
199 "echo used filesystem :${use_rootfs};"\
200 "gpt setenv mmc ${sd_device_number} ${use_rootfs};"\
201 "setenv bootargs_fs ${setbootargs} ${ext4rd_args}; run bootargs_fs;"\
202 "gpt setenv mmc ${sd_device_number} ${fit_image};"\
203 "mmc read ${fit_image_loadaddr} ${gpt_partition_addr} "\
204 "${gpt_partition_size};"\
205 "bootm ${fit_image_loadaddr}\0"
207 #define BOOTCMD_MMC_FITS \
210 "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
212 "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
214 "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
215 "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
217 #define USBDEV "usbdev=0\0"
220 "setenv usb_image_loadaddr 90000000;"\
221 "setenv fit_image Image_rsa.img;"\
222 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
223 "if usb dev ${usbdev}; && usb start; then "\
224 "echo Booting from USB...;"\
225 "fatload usb ${usbdev} ${usb_image_loadaddr} ${fit_image};"\
226 "fatload usb ${usbdev} ${initrd_loadaddr} ${initrd_image};"\
227 "bootm ${usb_image_loadaddr} ${initrd_loadaddr}:${filesize};"\
236 "bnxt_load=bnxt 0 probe "\
241 "run check_chimp_hs && "\
244 "setenv ethact bnxt_eth0;"\
245 "setenv autoload no;"\
246 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
248 "setenv pxefile_addr_r ${loadaddr};"\
250 "setenv ramdisk_addr_r ${initrd_loadaddr};"\
251 "setenv kernel_addr_r ${fit_image_loadaddr};"\
257 #define FLASH_PENDING_RFS_IMGS \
258 "flash_pending_rfs_imgs=" \
259 "if test $bcm_bl_flash_pending_rfs_imgs = 1; then " \
260 "if test $bl_flash_pending_rfs_imgs = rootfs; then " \
262 "run mmc_flash_rootfs;" \
264 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
266 "run mmc_flash_recovery;" \
268 "setenv bl_flash_pending_rfs_imgs;" \
271 /* Flashing commands */
272 #define TFTP_QSPI_PARAM \
273 "fip_qspi_addr=0x0\0"\
274 "fip_qspi_mirror_addr=0x200000\0"\
275 "loadaddr=0x90000000\0"\
276 "tftpblocksize=1468\0"\
277 "qspi_flash_fip=fip\0"\
279 /* Flash fit_GPT partition to eMMC */
280 #define MMC_FLASH_FIT_GPT \
282 "if mmc dev ${sd_device_number}; then "\
284 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
288 "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
290 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
295 #define MMC_FLASH_IMAGE_RSA \
296 "mmc_flash_image_rsa="\
297 "if mmc dev ${sd_device_number}; then "\
299 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
303 "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
305 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
309 "if tftp ${loadaddr} ${tftp_dir}${fit_image}; then "\
310 "if test ${fit_image} = Image_rsa.img; then "\
311 "if setenv tftp_fit_image yes; then "\
313 "echo [mmc_flash_image_rsa] "\
314 "setenv tftp_fit_image to yes"\
320 "if test ${fit_image} = Image_rsa.img; then "\
321 "echo [mmc_flash_image_rsa] tftp "\
322 "${tftp_dir}${fit_image} ** FAILED **;"\
324 "if test ${tftp_fit_image} = yes; then "\
325 "if mmc write ${loadaddr} "\
326 "${gpt_partition_addr} "\
327 "${fileblocks}; then "\
330 "[mmc_flash_image_rsa] "\
332 "${gpt_partition_addr} "\
337 "echo [mmc_flash_image_rsa] tftp "\
338 "${tftp_dir}${fit_image} "\
344 "if math add filesize filesize 1FF; then "\
346 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
349 "if math div fileblocks filesize 200; then "\
351 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
354 "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
356 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
360 "if setenv image_sz_blk_cnt ${fileblocks}; then "\
362 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
368 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
372 #define MMC_FLASH_RECOVERY \
373 "mmc_flash_recovery="\
374 "if mmc dev ${sd_device_number}; then "\
376 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
380 "if gpt setenv mmc ${sd_device_number} recovery; then "\
382 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
386 "while tftp ${loadaddr} "\
387 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
388 "if math add filesize filesize 1FF; then "\
390 "echo [mmc_flash_recovery] math add command "\
394 "if math div fileblocks filesize 200; then "\
396 "echo [mmc_flash_recovery] math div command "\
400 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
401 "${fileblocks}; then "\
403 "echo [mmc_flash_recovery] mmc write "\
404 "${gpt_partition_addr} ** FAILED **;"\
407 "if math add index index 1; then "\
409 "echo [mmc_flash_recovery] math add command "\
413 "if math add gpt_partition_addr gpt_partition_addr"\
414 " ${fileblocks}; then "\
416 "echo [mmc_flash_recovery] math add command"\
421 "if itest ${index} -ne 1; then "\
423 "echo [mmc_flash_recovery] "\
424 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
425 "not found ** FAILED **;"\
429 #define MMC_FLASH_ROOTFS \
431 "if mmc dev ${sd_device_number}; then "\
433 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
437 "if gpt setenv mmc ${sd_device_number} rootfs; then "\
439 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
443 "while tftp ${loadaddr} "\
444 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
445 "if math add filesize filesize 1FF; then "\
447 "echo [mmc_flash_rootfs] math add command "\
451 "if math div fileblocks filesize 200; then "\
453 "echo [mmc_flash_rootfs] math div command "\
457 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
458 "${fileblocks}; then "\
460 "echo [mmc_flash_rootfs] mmc write "\
461 "${gpt_partition_addr} ** FAILED **;"\
464 "if math add index index 1; then "\
466 "echo [mmc_flash_rootfs] math add command "\
470 "if math add gpt_partition_addr gpt_partition_addr"\
471 " ${fileblocks}; then "\
473 "echo [mmc_flash_rootfs] math add command"\
478 "if itest ${index} -ne 1; then "\
480 "echo [mmc_flash_rootfs] "\
481 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
482 "not found ** FAILED **;"\
487 * For individual flash commands like mmc_flash_gpt, it is not
488 * necessary to check for errors.
489 * If any of its intermediate commands fails, then next commands
490 * will not execute. Script will exit from the failure command.
491 * For uniformity, checking for mmc_flash_gpt, mmc_flash_image_rsa
492 * mmc_flash_nitro and mmc_flash_rootfs
496 "if run mmc_flash_gpt; then "\
498 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
501 "if setenv tftp_fit_image no; then "\
503 "echo [flash_mmc] setenv tftp_fit_image to no "\
507 "if setenv fit_image Image_rsa.img; then "\
509 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
513 "if run mmc_flash_image_rsa; then "\
515 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
518 "if setenv fit_image Image1_rsa.img; then "\
520 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
524 "if run mmc_flash_image_rsa; then "\
526 "echo [flash_mmc] run mmc_flash_image_rsa "\
527 "for Image1_rsa.img ** FAILED **;"\
530 "if setenv fit_image Image2_rsa.img; then "\
532 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
536 "if run mmc_flash_image_rsa; then "\
538 "echo [flash_mmc] run mmc_flash_image_rsa "\
539 "for Image2_rsa.img ** FAILED **;"\
542 "if run mmc_flash_recovery; then "\
544 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
547 "if run mmc_flash_rootfs; then "\
549 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
553 #define FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
554 "align_erase_blk_size=" \
555 "setenv fl_write_size 0;" \
556 "if math add fl_write_size filesize FFFF; then "\
558 "echo ${errstr} math add command ** FAILED **;"\
561 "if math div fl_write_size fl_write_size 10000; then "\
563 "echo ${errstr} math div command ** FAILED **;"\
566 "if math mul fl_write_size fl_write_size 10000; then "\
568 "echo ${errstr} math mul command ** FAILED **;"\
572 #define QSPI_FLASH_FIP \
574 "if run qspi_access_en; then "\
576 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
579 "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
581 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
585 "if math add tmpsize filesize FFFF; then "\
587 "echo [flash_fip] math add command ** FAILED **;"\
590 "if math div tmpsize tmpsize 10000; then "\
592 "echo [flash_fip] math div command ** FAILED **;"\
595 "if math mul tmpsize tmpsize 10000; then "\
597 "echo [flash_fip] math mul command ** FAILED **;"\
600 "if sf probe 0; then "\
602 "echo [flash_fip] sf probe command ** FAILED **;"\
605 "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
607 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
610 "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
612 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
615 /* Flash mirror FIP image */ \
616 "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
618 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
622 "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
624 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
629 #define QSPI_FLASH_NITRO \
631 "run func_qspi_probe; "\
632 "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
634 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
638 "setenv errstr flash_nitro;" \
639 "run align_erase_blk_size;" \
640 /* Flash Nitro fw fit + configuration */ \
641 "if sf erase ${spi_nitro_img_bin_start} ${fl_write_size}; then "\
643 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
647 "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
648 " ${fl_write_size}; then "\
650 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
654 /* Mirror of Flash Nitro fw fit + configuration */ \
655 "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
657 "echo [flash_nitro] sf erase "\
658 "${spi_nitro_img_bin_mirror_start} "\
662 "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
663 " ${fl_write_size}; then "\
665 "echo [flash_nitro] sf write "\
666 "${spi_nitro_img_bin_mirror_start} "\
671 #define QSPI_FLASH_NITRO_BSPD_CONFIG \
672 "flash_nitro_bspd_config="\
673 "run func_qspi_probe; "\
674 /* Flash BSPD configuration */ \
675 "if tftp ${loadaddr} ${tftp_dir}${nitro_bspd_cfg}; then "\
676 "setenv bspd_cfg_avialable 1; "\
677 "setenv errstr flash_nitro_bspd_config; "\
678 "run align_erase_blk_size;" \
679 "if sf erase ${spi_nitro_bspd_cfg_start} "\
680 "${fl_write_size}; then "\
682 "echo [flash_nitro] sf erase "\
683 "${spi_nitro_bspd_cfg_start} "\
687 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
688 "${fl_write_size}; then "\
690 "echo [flash_nitro] sf write "\
691 "${spi_nitro_bspd_cfg_start} "\
695 /* Flash BSPD mirror configuration */ \
696 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
697 "${fl_write_size}; then "\
699 "echo [flash_nitro] sf erase "\
700 "${spi_nitro_bspd_mirror_cfg_start} "\
704 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
705 "${fl_write_size}; then "\
707 "echo [flash_nitro] sf write "\
708 "${spi_nitro_bspd_mirror_cfg_start} "\
713 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
714 "** Skip flashing bspd config file **;"\
719 "if run qspi_access_en; then "\
721 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
724 "if run flash_fip; then "\
726 "echo [flash_qspi] run flash_fip ** FAILED **;"\
729 "if run flash_nitro; then "\
731 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
735 #define FLASH_IMAGES \
737 "if run flash_qspi; then "\
739 "echo [flash_images] run flash_qspi ** FAILED **;"\
742 "if run flash_mmc; then "\
744 "echo [flash_images] run flash_mmc ** FAILED **;"\
748 #define ARCH_ENV_SETTINGS \
757 UPDATEME_FLASH_PARAMS \
768 QSPI_FLASH_NITRO_PARAMS \
772 FASTBOOT_NITRO_SETUP \
784 FLASH_PENDING_RFS_IMGS \
787 MMC_FLASH_IMAGE_RSA \
791 FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
794 QSPI_FLASH_NITRO_BSPD_CONFIG \
798 #define CONFIG_EXTRA_ENV_SETTINGS \
801 #endif /* __BCM_NS3_H */