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
35 #define CONFIG_SYS_BOOTM_LEN 0x01800000
37 /* Access eMMC Boot_1 and Boot_2 partitions */
39 /* enable 64-bit PCI resources */
41 #define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
42 #define MAX_CPUS "max_cpus=maxcpus=8\0"
43 #define OS_LOG_LEVEL "log_level=loglevel=7\0"
44 #define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x68A10000 " \
45 "earlyelog=" __stringify(ELOG_AP_UART_LOG_BASE) ",0x10000 " \
46 "crashkernel=512M reboot=w\0"
48 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
50 #ifdef CONFIG_BCM_SF2_ETH
51 #define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0"
52 #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \
53 "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off"
59 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
61 #define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
62 " ${max_cpus} ${log_level} ${reserved_mem}"
63 #define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS " " NET_ARGS "\0"
65 #define UPDATEME_FLASH_PARAMS "bcm_compat_level=4\0" \
66 "bcm_need_recovery_rootfs=0\0" \
67 "bcm_bl_flash_pending_rfs_imgs=0\0"
69 #define KERNEL_LOADADDR_CFG \
70 "fit_image_loadaddr=0x90000000\0" \
71 "dtb_loadaddr=0x82000000\0"
73 #define INITRD_ARGS "initrd_args=root=/dev/ram rw\0"
74 #define INITRD_LOADADDR "initrd_loadaddr=0x92000000\0"
75 #define INITRD_IMAGE "initrd_image=rootfs-lake-bcm958742t.cpio.gz\0"
76 #define MMC_DEV "sd_device_number=0\0"
77 #define EXEC_STATE "exec_state=normal\0"
79 #define EXT4RD_ARGS "ext4rd_args="\
80 "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
82 #define WDT_CNTRL "wdt_enable=1\0" \
86 "mbox0_addr=0x66424024\0"\
88 "if logsetup -s ${mbox0_addr}; then "\
90 "echo ELOG is not supported by this version of the MCU patch.;"\
93 "if logsetup -c ${mbox0_addr}; then "\
94 "echo ELOG is ready;"\
96 "echo ELOG is supported, but is not set up.;"\
97 "echo Getting setup file from the server ${serverip}...;"\
98 "if tftp ${tftp_dir}elog_src.txt; then "\
99 "echo Setting up ELOG. Please wait...;"\
100 "if logsetup ${loadaddr} ${mbox0_addr} ${filesize}; "\
103 "echo [logsetup] ERROR.;"\
105 "if logsetup -c ${mbox0_addr}; then "\
106 "echo ELOG is READY.;"\
108 "echo ELOG is NOT SET UP.;"\
111 "echo ELOG setup file is not available on the server.;"\
115 /* eMMC partition for FIT images */
116 #define FIT_MMC_PARTITION \
118 "uuid_disk=${uuid_gpt_disk};" \
119 "name=env,size=512K,uuid=${uuid_gpt_env};" \
120 "name=Image_rsa.img,size=24MiB,uuid=${uuid_gpt_linux};" \
121 "name=Image1_rsa.img,size=24MiB,uuid=${uuid_gpt_linux1};" \
122 "name=Image2_rsa.img,size=24MiB,uuid=${uuid_gpt_linux2};" \
123 "name=nitro,size=8MiB,uuid=${uuid_gpt_nitro};" \
124 "name=recovery,size=940MiB,uuid=${uuid_gpt_recovery};" \
125 "name=rootfs,size=-,uuid=${uuid_gpt_prootfs}\0"
127 #define QSPI_FLASH_NITRO_PARAMS \
128 "spi_nitro_img_bin_start=0x400000\0" \
129 "spi_nitro_img_bin_mirror_start=0x580000\0" \
130 "spi_nitro_bspd_cfg_start=0x700000\0" \
131 "spi_nitro_bspd_mirror_cfg_start=0x710000\0" \
133 #define QSPI_ACCESS_ENABLE \
142 #define FUNC_QSPI_PROBE \
144 "if run qspi_access_en; then "\
146 "echo ${errstr} run qspi_access_en ** FAILED **;"\
149 "if sf probe 0; then "\
151 "echo echo ${errstr} sf probe command ** FAILED **;"\
155 #define NITRO_FW_IMAGES \
156 "nitro_bin=nitro.img\0" \
157 "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
159 #define FASTBOOT_NITRO_SETUP \
160 "nitro_fastboot_type=1\0" \
161 "nitro_fastboot_secure=1\0" \
162 "nitro_fastboot_img_buffer=0\0" \
163 "nitro_fit_img_loc=0x90000000\0"
165 #define FASTBOOT_SETUP \
166 "fastboot_nitro_setup=" \
167 "setenv errstr fastboot_setup;" \
168 "run func_qspi_probe;" \
169 /* first load header only */ \
170 "if sf read ${nitro_fit_img_loc} "\
171 "${spi_nitro_img_bin_start} 0x18; then "\
173 "echo [fastboot_nitro_setup] sf read "\
174 "${spi_nitro_img_bin_start} ** FAILED **;"\
177 "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
178 "${spi_nitro_img_bin_start}; then "\
180 "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
185 #define CHECK_CHIMP_HS\
186 "check_chimp_hs=chimp_hs"\
189 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
191 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
192 #define BOOTCMD_MMC_FIT \
194 "mmc dev ${sd_device_number};"\
195 "if test $exec_state = normal; then " \
196 "setenv use_rootfs rootfs;"\
198 "setenv use_rootfs recovery;"\
200 "echo used filesystem :${use_rootfs};"\
201 "gpt setenv mmc ${sd_device_number} ${use_rootfs};"\
202 "setenv bootargs_fs ${setbootargs} ${ext4rd_args}; run bootargs_fs;"\
203 "gpt setenv mmc ${sd_device_number} ${fit_image};"\
204 "mmc read ${fit_image_loadaddr} ${gpt_partition_addr} "\
205 "${gpt_partition_size};"\
206 "bootm ${fit_image_loadaddr}\0"
208 #define BOOTCMD_MMC_FITS \
211 "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
213 "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
215 "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
216 "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
218 #define USBDEV "usbdev=0\0"
221 "setenv usb_image_loadaddr 90000000;"\
222 "setenv fit_image Image_rsa.img;"\
223 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
224 "if usb dev ${usbdev}; && usb start; then "\
225 "echo Booting from USB...;"\
226 "fatload usb ${usbdev} ${usb_image_loadaddr} ${fit_image};"\
227 "fatload usb ${usbdev} ${initrd_loadaddr} ${initrd_image};"\
228 "bootm ${usb_image_loadaddr} ${initrd_loadaddr}:${filesize};"\
237 "bnxt_load=bnxt 0 probe "\
242 "run check_chimp_hs && "\
245 "setenv ethact bnxt_eth0;"\
246 "setenv autoload no;"\
247 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
249 "setenv pxefile_addr_r ${loadaddr};"\
251 "setenv ramdisk_addr_r ${initrd_loadaddr};"\
252 "setenv kernel_addr_r ${fit_image_loadaddr};"\
258 #define FLASH_PENDING_RFS_IMGS \
259 "flash_pending_rfs_imgs=" \
260 "if test $bcm_bl_flash_pending_rfs_imgs = 1; then " \
261 "if test $bl_flash_pending_rfs_imgs = rootfs; then " \
263 "run mmc_flash_rootfs;" \
265 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
267 "run mmc_flash_recovery;" \
269 "setenv bl_flash_pending_rfs_imgs;" \
272 /* Flashing commands */
273 #define TFTP_QSPI_PARAM \
274 "fip_qspi_addr=0x0\0"\
275 "fip_qspi_mirror_addr=0x200000\0"\
276 "loadaddr=0x90000000\0"\
277 "tftpblocksize=1468\0"\
278 "qspi_flash_fip=fip\0"\
280 /* Flash fit_GPT partition to eMMC */
281 #define MMC_FLASH_FIT_GPT \
283 "if mmc dev ${sd_device_number}; then "\
285 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
289 "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
291 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
296 #define MMC_FLASH_IMAGE_RSA \
297 "mmc_flash_image_rsa="\
298 "if mmc dev ${sd_device_number}; then "\
300 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
304 "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
306 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
310 "if tftp ${loadaddr} ${tftp_dir}${fit_image}; then "\
311 "if test ${fit_image} = Image_rsa.img; then "\
312 "if setenv tftp_fit_image yes; then "\
314 "echo [mmc_flash_image_rsa] "\
315 "setenv tftp_fit_image to yes"\
321 "if test ${fit_image} = Image_rsa.img; then "\
322 "echo [mmc_flash_image_rsa] tftp "\
323 "${tftp_dir}${fit_image} ** FAILED **;"\
325 "if test ${tftp_fit_image} = yes; then "\
326 "if mmc write ${loadaddr} "\
327 "${gpt_partition_addr} "\
328 "${fileblocks}; then "\
331 "[mmc_flash_image_rsa] "\
333 "${gpt_partition_addr} "\
338 "echo [mmc_flash_image_rsa] tftp "\
339 "${tftp_dir}${fit_image} "\
345 "if math add filesize filesize 1FF; then "\
347 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
350 "if math div fileblocks filesize 200; then "\
352 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
355 "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
357 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
361 "if setenv image_sz_blk_cnt ${fileblocks}; then "\
363 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
369 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
373 #define MMC_FLASH_RECOVERY \
374 "mmc_flash_recovery="\
375 "if mmc dev ${sd_device_number}; then "\
377 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
381 "if gpt setenv mmc ${sd_device_number} recovery; then "\
383 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
387 "while tftp ${loadaddr} "\
388 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
389 "if math add filesize filesize 1FF; then "\
391 "echo [mmc_flash_recovery] math add command "\
395 "if math div fileblocks filesize 200; then "\
397 "echo [mmc_flash_recovery] math div command "\
401 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
402 "${fileblocks}; then "\
404 "echo [mmc_flash_recovery] mmc write "\
405 "${gpt_partition_addr} ** FAILED **;"\
408 "if math add index index 1; then "\
410 "echo [mmc_flash_recovery] math add command "\
414 "if math add gpt_partition_addr gpt_partition_addr"\
415 " ${fileblocks}; then "\
417 "echo [mmc_flash_recovery] math add command"\
422 "if itest ${index} -ne 1; then "\
424 "echo [mmc_flash_recovery] "\
425 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
426 "not found ** FAILED **;"\
430 #define MMC_FLASH_ROOTFS \
432 "if mmc dev ${sd_device_number}; then "\
434 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
438 "if gpt setenv mmc ${sd_device_number} rootfs; then "\
440 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
444 "while tftp ${loadaddr} "\
445 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
446 "if math add filesize filesize 1FF; then "\
448 "echo [mmc_flash_rootfs] math add command "\
452 "if math div fileblocks filesize 200; then "\
454 "echo [mmc_flash_rootfs] math div command "\
458 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
459 "${fileblocks}; then "\
461 "echo [mmc_flash_rootfs] mmc write "\
462 "${gpt_partition_addr} ** FAILED **;"\
465 "if math add index index 1; then "\
467 "echo [mmc_flash_rootfs] math add command "\
471 "if math add gpt_partition_addr gpt_partition_addr"\
472 " ${fileblocks}; then "\
474 "echo [mmc_flash_rootfs] math add command"\
479 "if itest ${index} -ne 1; then "\
481 "echo [mmc_flash_rootfs] "\
482 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
483 "not found ** FAILED **;"\
488 * For individual flash commands like mmc_flash_gpt, it is not
489 * necessary to check for errors.
490 * If any of its intermediate commands fails, then next commands
491 * will not execute. Script will exit from the failure command.
492 * For uniformity, checking for mmc_flash_gpt, mmc_flash_image_rsa
493 * mmc_flash_nitro and mmc_flash_rootfs
497 "if run mmc_flash_gpt; then "\
499 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
502 "if setenv tftp_fit_image no; then "\
504 "echo [flash_mmc] setenv tftp_fit_image to no "\
508 "if setenv fit_image Image_rsa.img; then "\
510 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
514 "if run mmc_flash_image_rsa; then "\
516 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
519 "if setenv fit_image Image1_rsa.img; then "\
521 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
525 "if run mmc_flash_image_rsa; then "\
527 "echo [flash_mmc] run mmc_flash_image_rsa "\
528 "for Image1_rsa.img ** FAILED **;"\
531 "if setenv fit_image Image2_rsa.img; then "\
533 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
537 "if run mmc_flash_image_rsa; then "\
539 "echo [flash_mmc] run mmc_flash_image_rsa "\
540 "for Image2_rsa.img ** FAILED **;"\
543 "if run mmc_flash_recovery; then "\
545 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
548 "if run mmc_flash_rootfs; then "\
550 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
554 #define FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
555 "align_erase_blk_size=" \
556 "setenv fl_write_size 0;" \
557 "if math add fl_write_size filesize FFFF; then "\
559 "echo ${errstr} math add command ** FAILED **;"\
562 "if math div fl_write_size fl_write_size 10000; then "\
564 "echo ${errstr} math div command ** FAILED **;"\
567 "if math mul fl_write_size fl_write_size 10000; then "\
569 "echo ${errstr} math mul command ** FAILED **;"\
573 #define QSPI_FLASH_FIP \
575 "if run qspi_access_en; then "\
577 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
580 "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
582 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
586 "if math add tmpsize filesize FFFF; then "\
588 "echo [flash_fip] math add command ** FAILED **;"\
591 "if math div tmpsize tmpsize 10000; then "\
593 "echo [flash_fip] math div command ** FAILED **;"\
596 "if math mul tmpsize tmpsize 10000; then "\
598 "echo [flash_fip] math mul command ** FAILED **;"\
601 "if sf probe 0; then "\
603 "echo [flash_fip] sf probe command ** FAILED **;"\
606 "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
608 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
611 "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
613 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
616 /* Flash mirror FIP image */ \
617 "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
619 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
623 "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
625 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
630 #define QSPI_FLASH_NITRO \
632 "run func_qspi_probe; "\
633 "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
635 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
639 "setenv errstr flash_nitro;" \
640 "run align_erase_blk_size;" \
641 /* Flash Nitro fw fit + configuration */ \
642 "if sf erase ${spi_nitro_img_bin_start} ${fl_write_size}; then "\
644 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
648 "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
649 " ${fl_write_size}; then "\
651 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
655 /* Mirror of Flash Nitro fw fit + configuration */ \
656 "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
658 "echo [flash_nitro] sf erase "\
659 "${spi_nitro_img_bin_mirror_start} "\
663 "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
664 " ${fl_write_size}; then "\
666 "echo [flash_nitro] sf write "\
667 "${spi_nitro_img_bin_mirror_start} "\
672 #define QSPI_FLASH_NITRO_BSPD_CONFIG \
673 "flash_nitro_bspd_config="\
674 "run func_qspi_probe; "\
675 /* Flash BSPD configuration */ \
676 "if tftp ${loadaddr} ${tftp_dir}${nitro_bspd_cfg}; then "\
677 "setenv bspd_cfg_avialable 1; "\
678 "setenv errstr flash_nitro_bspd_config; "\
679 "run align_erase_blk_size;" \
680 "if sf erase ${spi_nitro_bspd_cfg_start} "\
681 "${fl_write_size}; then "\
683 "echo [flash_nitro] sf erase "\
684 "${spi_nitro_bspd_cfg_start} "\
688 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
689 "${fl_write_size}; then "\
691 "echo [flash_nitro] sf write "\
692 "${spi_nitro_bspd_cfg_start} "\
696 /* Flash BSPD mirror configuration */ \
697 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
698 "${fl_write_size}; then "\
700 "echo [flash_nitro] sf erase "\
701 "${spi_nitro_bspd_mirror_cfg_start} "\
705 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
706 "${fl_write_size}; then "\
708 "echo [flash_nitro] sf write "\
709 "${spi_nitro_bspd_mirror_cfg_start} "\
714 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
715 "** Skip flashing bspd config file **;"\
720 "if run qspi_access_en; then "\
722 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
725 "if run flash_fip; then "\
727 "echo [flash_qspi] run flash_fip ** FAILED **;"\
730 "if run flash_nitro; then "\
732 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
736 #define FLASH_IMAGES \
738 "if run flash_qspi; then "\
740 "echo [flash_images] run flash_qspi ** FAILED **;"\
743 "if run flash_mmc; then "\
745 "echo [flash_images] run flash_mmc ** FAILED **;"\
749 #define ARCH_ENV_SETTINGS \
758 UPDATEME_FLASH_PARAMS \
769 QSPI_FLASH_NITRO_PARAMS \
773 FASTBOOT_NITRO_SETUP \
785 FLASH_PENDING_RFS_IMGS \
788 MMC_FLASH_IMAGE_RSA \
792 FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
795 QSPI_FLASH_NITRO_BSPD_CONFIG \
799 #define CONFIG_EXTRA_ENV_SETTINGS \
802 #endif /* __BCM_NS3_H */