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 /* Env configuration */
47 #define CONFIG_SYS_MMC_ENV_DEV 0
48 #define CONFIG_SYS_MMC_ENV_PART 0
50 /* Access eMMC Boot_1 and Boot_2 partitions */
51 #define CONFIG_SUPPORT_EMMC_BOOT
53 /* enable 64-bit PCI resources */
54 #define CONFIG_SYS_PCI_64BIT 1
56 #define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
57 #define MAX_CPUS "max_cpus=maxcpus=8\0"
58 #define OS_LOG_LEVEL "log_level=loglevel=7\0"
59 #define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x68A10000 " \
60 "earlyelog=" __stringify(ELOG_AP_UART_LOG_BASE) ",0x10000 " \
61 "crashkernel=512M reboot=w\0"
63 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
65 #ifdef CONFIG_BCM_SF2_ETH
66 #define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0"
67 #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \
68 "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off"
74 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
76 #define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
77 " ${max_cpus} ${log_level} ${reserved_mem}"
78 #define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS " " NET_ARGS "\0"
80 #define UPDATEME_FLASH_PARAMS "bcm_compat_level=4\0" \
81 "bcm_need_recovery_rootfs=0\0" \
82 "bcm_bl_flash_pending_rfs_imgs=0\0"
84 #define KERNEL_LOADADDR_CFG \
85 "fit_image_loadaddr=0x90000000\0" \
86 "dtb_loadaddr=0x82000000\0"
88 #define INITRD_ARGS "initrd_args=root=/dev/ram rw\0"
89 #define INITRD_LOADADDR "initrd_loadaddr=0x92000000\0"
90 #define INITRD_IMAGE "initrd_image=rootfs-lake-bcm958742t.cpio.gz\0"
91 #define MMC_DEV "sd_device_number=0\0"
92 #define EXEC_STATE "exec_state=normal\0"
94 #define EXT4RD_ARGS "ext4rd_args="\
95 "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
97 #define WDT_CNTRL "wdt_enable=1\0" \
101 "mbox0_addr=0x66424024\0"\
103 "if logsetup -s ${mbox0_addr}; then "\
105 "echo ELOG is not supported by this version of the MCU patch.;"\
108 "if logsetup -c ${mbox0_addr}; then "\
109 "echo ELOG is ready;"\
111 "echo ELOG is supported, but is not set up.;"\
112 "echo Getting setup file from the server ${serverip}...;"\
113 "if tftp ${tftp_dir}elog_src.txt; then "\
114 "echo Setting up ELOG. Please wait...;"\
115 "if logsetup ${loadaddr} ${mbox0_addr} ${filesize}; "\
118 "echo [logsetup] ERROR.;"\
120 "if logsetup -c ${mbox0_addr}; then "\
121 "echo ELOG is READY.;"\
123 "echo ELOG is NOT SET UP.;"\
126 "echo ELOG setup file is not available on the server.;"\
130 /* eMMC partition for FIT images */
131 #define FIT_MMC_PARTITION \
133 "uuid_disk=${uuid_gpt_disk};" \
134 "name=env,size=512K,uuid=${uuid_gpt_env};" \
135 "name=Image_rsa.img,size=24MiB,uuid=${uuid_gpt_linux};" \
136 "name=Image1_rsa.img,size=24MiB,uuid=${uuid_gpt_linux1};" \
137 "name=Image2_rsa.img,size=24MiB,uuid=${uuid_gpt_linux2};" \
138 "name=nitro,size=8MiB,uuid=${uuid_gpt_nitro};" \
139 "name=recovery,size=940MiB,uuid=${uuid_gpt_recovery};" \
140 "name=rootfs,size=-,uuid=${uuid_gpt_prootfs}\0"
142 #define QSPI_FLASH_NITRO_PARAMS \
143 "spi_nitro_img_bin_start=0x400000\0" \
144 "spi_nitro_img_bin_mirror_start=0x580000\0" \
145 "spi_nitro_bspd_cfg_start=0x700000\0" \
146 "spi_nitro_bspd_mirror_cfg_start=0x710000\0" \
148 #define QSPI_ACCESS_ENABLE \
157 #define FUNC_QSPI_PROBE \
159 "if run qspi_access_en; then "\
161 "echo ${errstr} run qspi_access_en ** FAILED **;"\
164 "if sf probe 0; then "\
166 "echo echo ${errstr} sf probe command ** FAILED **;"\
170 #define NITRO_FW_IMAGES \
171 "nitro_bin=nitro.img\0" \
172 "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
174 #define FASTBOOT_NITRO_SETUP \
175 "nitro_fastboot_type=1\0" \
176 "nitro_fastboot_secure=1\0" \
177 "nitro_fastboot_img_buffer=0\0" \
178 "nitro_fit_img_loc=0x90000000\0"
180 #define FASTBOOT_SETUP \
181 "fastboot_nitro_setup=" \
182 "setenv errstr fastboot_setup;" \
183 "run func_qspi_probe;" \
184 /* first load header only */ \
185 "if sf read ${nitro_fit_img_loc} "\
186 "${spi_nitro_img_bin_start} 0x18; then "\
188 "echo [fastboot_nitro_setup] sf read "\
189 "${spi_nitro_img_bin_start} ** FAILED **;"\
192 "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
193 "${spi_nitro_img_bin_start}; then "\
195 "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
200 #define CHECK_CHIMP_HS\
201 "check_chimp_hs=chimp_hs"\
204 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
206 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
207 #define BOOTCMD_MMC_FIT \
209 "mmc dev ${sd_device_number};"\
210 "if test $exec_state = normal; then " \
211 "setenv use_rootfs rootfs;"\
213 "setenv use_rootfs recovery;"\
215 "echo used filesystem :${use_rootfs};"\
216 "gpt setenv mmc ${sd_device_number} ${use_rootfs};"\
217 "setenv bootargs_fs ${setbootargs} ${ext4rd_args}; run bootargs_fs;"\
218 "gpt setenv mmc ${sd_device_number} ${fit_image};"\
219 "mmc read ${fit_image_loadaddr} ${gpt_partition_addr} "\
220 "${gpt_partition_size};"\
221 "bootm ${fit_image_loadaddr}\0"
223 #define BOOTCMD_MMC_FITS \
226 "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
228 "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
230 "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
231 "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
233 #define USBDEV "usbdev=0\0"
236 "setenv usb_image_loadaddr 90000000;"\
237 "setenv fit_image Image_rsa.img;"\
238 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
239 "if usb dev ${usbdev}; && usb start; then "\
240 "echo Booting from USB...;"\
241 "fatload usb ${usbdev} ${usb_image_loadaddr} ${fit_image};"\
242 "fatload usb ${usbdev} ${initrd_loadaddr} ${initrd_image};"\
243 "bootm ${usb_image_loadaddr} ${initrd_loadaddr}:${filesize};"\
252 "bnxt_load=bnxt 0 probe "\
257 "run check_chimp_hs && "\
260 "setenv ethact bnxt_eth0;"\
261 "setenv autoload no;"\
262 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
264 "setenv pxefile_addr_r ${loadaddr};"\
266 "setenv ramdisk_addr_r ${initrd_loadaddr};"\
267 "setenv kernel_addr_r ${fit_image_loadaddr};"\
273 #define FLASH_PENDING_RFS_IMGS \
274 "flash_pending_rfs_imgs=" \
275 "if test $bcm_bl_flash_pending_rfs_imgs = 1; then " \
276 "if test $bl_flash_pending_rfs_imgs = rootfs; then " \
278 "run mmc_flash_rootfs;" \
280 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
282 "run mmc_flash_recovery;" \
284 "setenv bl_flash_pending_rfs_imgs;" \
287 #define CONFIG_BOOTCOMMAND "run flash_pending_rfs_imgs;" \
288 "run fastboot_nitro && "\
289 "run bootcmd_mmc_fits || "\
290 "run bootcmd_usb || "\
293 /* Flashing commands */
294 #define TFTP_QSPI_PARAM \
295 "fip_qspi_addr=0x0\0"\
296 "fip_qspi_mirror_addr=0x200000\0"\
297 "loadaddr=0x90000000\0"\
298 "tftpblocksize=1468\0"\
299 "qspi_flash_fip=fip\0"\
301 /* Flash fit_GPT partition to eMMC */
302 #define MMC_FLASH_FIT_GPT \
304 "if mmc dev ${sd_device_number}; then "\
306 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
310 "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
312 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
317 #define MMC_FLASH_IMAGE_RSA \
318 "mmc_flash_image_rsa="\
319 "if mmc dev ${sd_device_number}; then "\
321 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
325 "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
327 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
331 "if tftp ${loadaddr} ${tftp_dir}${fit_image}; then "\
332 "if test ${fit_image} = Image_rsa.img; then "\
333 "if setenv tftp_fit_image yes; then "\
335 "echo [mmc_flash_image_rsa] "\
336 "setenv tftp_fit_image to yes"\
342 "if test ${fit_image} = Image_rsa.img; then "\
343 "echo [mmc_flash_image_rsa] tftp "\
344 "${tftp_dir}${fit_image} ** FAILED **;"\
346 "if test ${tftp_fit_image} = yes; then "\
347 "if mmc write ${loadaddr} "\
348 "${gpt_partition_addr} "\
349 "${fileblocks}; then "\
352 "[mmc_flash_image_rsa] "\
354 "${gpt_partition_addr} "\
359 "echo [mmc_flash_image_rsa] tftp "\
360 "${tftp_dir}${fit_image} "\
366 "if math add filesize filesize 1FF; then "\
368 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
371 "if math div fileblocks filesize 200; then "\
373 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
376 "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
378 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
382 "if setenv image_sz_blk_cnt ${fileblocks}; then "\
384 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
390 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
394 #define MMC_FLASH_RECOVERY \
395 "mmc_flash_recovery="\
396 "if mmc dev ${sd_device_number}; then "\
398 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
402 "if gpt setenv mmc ${sd_device_number} recovery; then "\
404 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
408 "while tftp ${loadaddr} "\
409 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
410 "if math add filesize filesize 1FF; then "\
412 "echo [mmc_flash_recovery] math add command "\
416 "if math div fileblocks filesize 200; then "\
418 "echo [mmc_flash_recovery] math div command "\
422 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
423 "${fileblocks}; then "\
425 "echo [mmc_flash_recovery] mmc write "\
426 "${gpt_partition_addr} ** FAILED **;"\
429 "if math add index index 1; then "\
431 "echo [mmc_flash_recovery] math add command "\
435 "if math add gpt_partition_addr gpt_partition_addr"\
436 " ${fileblocks}; then "\
438 "echo [mmc_flash_recovery] math add command"\
443 "if itest ${index} -ne 1; then "\
445 "echo [mmc_flash_recovery] "\
446 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
447 "not found ** FAILED **;"\
451 #define MMC_FLASH_ROOTFS \
453 "if mmc dev ${sd_device_number}; then "\
455 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
459 "if gpt setenv mmc ${sd_device_number} rootfs; then "\
461 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
465 "while tftp ${loadaddr} "\
466 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
467 "if math add filesize filesize 1FF; then "\
469 "echo [mmc_flash_rootfs] math add command "\
473 "if math div fileblocks filesize 200; then "\
475 "echo [mmc_flash_rootfs] math div command "\
479 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
480 "${fileblocks}; then "\
482 "echo [mmc_flash_rootfs] mmc write "\
483 "${gpt_partition_addr} ** FAILED **;"\
486 "if math add index index 1; then "\
488 "echo [mmc_flash_rootfs] math add command "\
492 "if math add gpt_partition_addr gpt_partition_addr"\
493 " ${fileblocks}; then "\
495 "echo [mmc_flash_rootfs] math add command"\
500 "if itest ${index} -ne 1; then "\
502 "echo [mmc_flash_rootfs] "\
503 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
504 "not found ** FAILED **;"\
509 * For individual flash commands like mmc_flash_gpt, it is not
510 * necessary to check for errors.
511 * If any of its intermediate commands fails, then next commands
512 * will not execute. Script will exit from the failure command.
513 * For uniformity, checking for mmc_flash_gpt, mmc_flash_image_rsa
514 * mmc_flash_nitro and mmc_flash_rootfs
518 "if run mmc_flash_gpt; then "\
520 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
523 "if setenv tftp_fit_image no; then "\
525 "echo [flash_mmc] setenv tftp_fit_image to no "\
529 "if setenv fit_image Image_rsa.img; then "\
531 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
535 "if run mmc_flash_image_rsa; then "\
537 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
540 "if setenv fit_image Image1_rsa.img; then "\
542 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
546 "if run mmc_flash_image_rsa; then "\
548 "echo [flash_mmc] run mmc_flash_image_rsa "\
549 "for Image1_rsa.img ** FAILED **;"\
552 "if setenv fit_image Image2_rsa.img; then "\
554 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
558 "if run mmc_flash_image_rsa; then "\
560 "echo [flash_mmc] run mmc_flash_image_rsa "\
561 "for Image2_rsa.img ** FAILED **;"\
564 "if run mmc_flash_recovery; then "\
566 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
569 "if run mmc_flash_rootfs; then "\
571 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
575 #define FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
576 "align_erase_blk_size=" \
577 "setenv fl_write_size 0;" \
578 "if math add fl_write_size filesize FFFF; then "\
580 "echo ${errstr} math add command ** FAILED **;"\
583 "if math div fl_write_size fl_write_size 10000; then "\
585 "echo ${errstr} math div command ** FAILED **;"\
588 "if math mul fl_write_size fl_write_size 10000; then "\
590 "echo ${errstr} math mul command ** FAILED **;"\
594 #define QSPI_FLASH_FIP \
596 "if run qspi_access_en; then "\
598 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
601 "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
603 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
607 "if math add tmpsize filesize FFFF; then "\
609 "echo [flash_fip] math add command ** FAILED **;"\
612 "if math div tmpsize tmpsize 10000; then "\
614 "echo [flash_fip] math div command ** FAILED **;"\
617 "if math mul tmpsize tmpsize 10000; then "\
619 "echo [flash_fip] math mul command ** FAILED **;"\
622 "if sf probe 0; then "\
624 "echo [flash_fip] sf probe command ** FAILED **;"\
627 "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
629 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
632 "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
634 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
637 /* Flash mirror FIP image */ \
638 "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
640 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
644 "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
646 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
651 #define QSPI_FLASH_NITRO \
653 "run func_qspi_probe; "\
654 "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
656 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
660 "setenv errstr flash_nitro;" \
661 "run align_erase_blk_size;" \
662 /* Flash Nitro fw fit + configuration */ \
663 "if sf erase ${spi_nitro_img_bin_start} ${fl_write_size}; then "\
665 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
669 "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
670 " ${fl_write_size}; then "\
672 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
676 /* Mirror of Flash Nitro fw fit + configuration */ \
677 "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
679 "echo [flash_nitro] sf erase "\
680 "${spi_nitro_img_bin_mirror_start} "\
684 "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
685 " ${fl_write_size}; then "\
687 "echo [flash_nitro] sf write "\
688 "${spi_nitro_img_bin_mirror_start} "\
693 #define QSPI_FLASH_NITRO_BSPD_CONFIG \
694 "flash_nitro_bspd_config="\
695 "run func_qspi_probe; "\
696 /* Flash BSPD configuration */ \
697 "if tftp ${loadaddr} ${tftp_dir}${nitro_bspd_cfg}; then "\
698 "setenv bspd_cfg_avialable 1; "\
699 "setenv errstr flash_nitro_bspd_config; "\
700 "run align_erase_blk_size;" \
701 "if sf erase ${spi_nitro_bspd_cfg_start} "\
702 "${fl_write_size}; then "\
704 "echo [flash_nitro] sf erase "\
705 "${spi_nitro_bspd_cfg_start} "\
709 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
710 "${fl_write_size}; then "\
712 "echo [flash_nitro] sf write "\
713 "${spi_nitro_bspd_cfg_start} "\
717 /* Flash BSPD mirror configuration */ \
718 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
719 "${fl_write_size}; then "\
721 "echo [flash_nitro] sf erase "\
722 "${spi_nitro_bspd_mirror_cfg_start} "\
726 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
727 "${fl_write_size}; then "\
729 "echo [flash_nitro] sf write "\
730 "${spi_nitro_bspd_mirror_cfg_start} "\
735 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
736 "** Skip flashing bspd config file **;"\
741 "if run qspi_access_en; then "\
743 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
746 "if run flash_fip; then "\
748 "echo [flash_qspi] run flash_fip ** FAILED **;"\
751 "if run flash_nitro; then "\
753 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
757 #define FLASH_IMAGES \
759 "if run flash_qspi; then "\
761 "echo [flash_images] run flash_qspi ** FAILED **;"\
764 "if run flash_mmc; then "\
766 "echo [flash_images] run flash_mmc ** FAILED **;"\
770 #define ARCH_ENV_SETTINGS \
779 UPDATEME_FLASH_PARAMS \
790 QSPI_FLASH_NITRO_PARAMS \
794 FASTBOOT_NITRO_SETUP \
806 FLASH_PENDING_RFS_IMGS \
809 MMC_FLASH_IMAGE_RSA \
813 FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
816 QSPI_FLASH_NITRO_BSPD_CONFIG \
820 #define CONFIG_EXTRA_ENV_SETTINGS \
823 #endif /* __BCM_NS3_H */