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
32 #define CONFIG_SYS_CBSIZE SZ_1K
33 #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
34 sizeof(CONFIG_SYS_PROMPT) + 16)
35 #define CONFIG_SYS_MAXARGS 64
36 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
39 * Increase max uncompressed/gunzip size, keeping size same as EMMC linux
42 #define CONFIG_SYS_BOOTM_LEN 0x01800000
44 /* Access eMMC Boot_1 and Boot_2 partitions */
46 /* enable 64-bit PCI resources */
47 #define CONFIG_SYS_PCI_64BIT 1
49 #define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
50 #define MAX_CPUS "max_cpus=maxcpus=8\0"
51 #define OS_LOG_LEVEL "log_level=loglevel=7\0"
52 #define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x68A10000 " \
53 "earlyelog=" __stringify(ELOG_AP_UART_LOG_BASE) ",0x10000 " \
54 "crashkernel=512M reboot=w\0"
56 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
58 #ifdef CONFIG_BCM_SF2_ETH
59 #define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0"
60 #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \
61 "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off"
67 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
69 #define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
70 " ${max_cpus} ${log_level} ${reserved_mem}"
71 #define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS " " NET_ARGS "\0"
73 #define UPDATEME_FLASH_PARAMS "bcm_compat_level=4\0" \
74 "bcm_need_recovery_rootfs=0\0" \
75 "bcm_bl_flash_pending_rfs_imgs=0\0"
77 #define KERNEL_LOADADDR_CFG \
78 "fit_image_loadaddr=0x90000000\0" \
79 "dtb_loadaddr=0x82000000\0"
81 #define INITRD_ARGS "initrd_args=root=/dev/ram rw\0"
82 #define INITRD_LOADADDR "initrd_loadaddr=0x92000000\0"
83 #define INITRD_IMAGE "initrd_image=rootfs-lake-bcm958742t.cpio.gz\0"
84 #define MMC_DEV "sd_device_number=0\0"
85 #define EXEC_STATE "exec_state=normal\0"
87 #define EXT4RD_ARGS "ext4rd_args="\
88 "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
90 #define WDT_CNTRL "wdt_enable=1\0" \
94 "mbox0_addr=0x66424024\0"\
96 "if logsetup -s ${mbox0_addr}; then "\
98 "echo ELOG is not supported by this version of the MCU patch.;"\
101 "if logsetup -c ${mbox0_addr}; then "\
102 "echo ELOG is ready;"\
104 "echo ELOG is supported, but is not set up.;"\
105 "echo Getting setup file from the server ${serverip}...;"\
106 "if tftp ${tftp_dir}elog_src.txt; then "\
107 "echo Setting up ELOG. Please wait...;"\
108 "if logsetup ${loadaddr} ${mbox0_addr} ${filesize}; "\
111 "echo [logsetup] ERROR.;"\
113 "if logsetup -c ${mbox0_addr}; then "\
114 "echo ELOG is READY.;"\
116 "echo ELOG is NOT SET UP.;"\
119 "echo ELOG setup file is not available on the server.;"\
123 /* eMMC partition for FIT images */
124 #define FIT_MMC_PARTITION \
126 "uuid_disk=${uuid_gpt_disk};" \
127 "name=env,size=512K,uuid=${uuid_gpt_env};" \
128 "name=Image_rsa.img,size=24MiB,uuid=${uuid_gpt_linux};" \
129 "name=Image1_rsa.img,size=24MiB,uuid=${uuid_gpt_linux1};" \
130 "name=Image2_rsa.img,size=24MiB,uuid=${uuid_gpt_linux2};" \
131 "name=nitro,size=8MiB,uuid=${uuid_gpt_nitro};" \
132 "name=recovery,size=940MiB,uuid=${uuid_gpt_recovery};" \
133 "name=rootfs,size=-,uuid=${uuid_gpt_prootfs}\0"
135 #define QSPI_FLASH_NITRO_PARAMS \
136 "spi_nitro_img_bin_start=0x400000\0" \
137 "spi_nitro_img_bin_mirror_start=0x580000\0" \
138 "spi_nitro_bspd_cfg_start=0x700000\0" \
139 "spi_nitro_bspd_mirror_cfg_start=0x710000\0" \
141 #define QSPI_ACCESS_ENABLE \
150 #define FUNC_QSPI_PROBE \
152 "if run qspi_access_en; then "\
154 "echo ${errstr} run qspi_access_en ** FAILED **;"\
157 "if sf probe 0; then "\
159 "echo echo ${errstr} sf probe command ** FAILED **;"\
163 #define NITRO_FW_IMAGES \
164 "nitro_bin=nitro.img\0" \
165 "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
167 #define FASTBOOT_NITRO_SETUP \
168 "nitro_fastboot_type=1\0" \
169 "nitro_fastboot_secure=1\0" \
170 "nitro_fastboot_img_buffer=0\0" \
171 "nitro_fit_img_loc=0x90000000\0"
173 #define FASTBOOT_SETUP \
174 "fastboot_nitro_setup=" \
175 "setenv errstr fastboot_setup;" \
176 "run func_qspi_probe;" \
177 /* first load header only */ \
178 "if sf read ${nitro_fit_img_loc} "\
179 "${spi_nitro_img_bin_start} 0x18; then "\
181 "echo [fastboot_nitro_setup] sf read "\
182 "${spi_nitro_img_bin_start} ** FAILED **;"\
185 "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
186 "${spi_nitro_img_bin_start}; then "\
188 "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
193 #define CHECK_CHIMP_HS\
194 "check_chimp_hs=chimp_hs"\
197 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
199 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
200 #define BOOTCMD_MMC_FIT \
202 "mmc dev ${sd_device_number};"\
203 "if test $exec_state = normal; then " \
204 "setenv use_rootfs rootfs;"\
206 "setenv use_rootfs recovery;"\
208 "echo used filesystem :${use_rootfs};"\
209 "gpt setenv mmc ${sd_device_number} ${use_rootfs};"\
210 "setenv bootargs_fs ${setbootargs} ${ext4rd_args}; run bootargs_fs;"\
211 "gpt setenv mmc ${sd_device_number} ${fit_image};"\
212 "mmc read ${fit_image_loadaddr} ${gpt_partition_addr} "\
213 "${gpt_partition_size};"\
214 "bootm ${fit_image_loadaddr}\0"
216 #define BOOTCMD_MMC_FITS \
219 "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
221 "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
223 "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
224 "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
226 #define USBDEV "usbdev=0\0"
229 "setenv usb_image_loadaddr 90000000;"\
230 "setenv fit_image Image_rsa.img;"\
231 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
232 "if usb dev ${usbdev}; && usb start; then "\
233 "echo Booting from USB...;"\
234 "fatload usb ${usbdev} ${usb_image_loadaddr} ${fit_image};"\
235 "fatload usb ${usbdev} ${initrd_loadaddr} ${initrd_image};"\
236 "bootm ${usb_image_loadaddr} ${initrd_loadaddr}:${filesize};"\
245 "bnxt_load=bnxt 0 probe "\
250 "run check_chimp_hs && "\
253 "setenv ethact bnxt_eth0;"\
254 "setenv autoload no;"\
255 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
257 "setenv pxefile_addr_r ${loadaddr};"\
259 "setenv ramdisk_addr_r ${initrd_loadaddr};"\
260 "setenv kernel_addr_r ${fit_image_loadaddr};"\
266 #define FLASH_PENDING_RFS_IMGS \
267 "flash_pending_rfs_imgs=" \
268 "if test $bcm_bl_flash_pending_rfs_imgs = 1; then " \
269 "if test $bl_flash_pending_rfs_imgs = rootfs; then " \
271 "run mmc_flash_rootfs;" \
273 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
275 "run mmc_flash_recovery;" \
277 "setenv bl_flash_pending_rfs_imgs;" \
280 /* Flashing commands */
281 #define TFTP_QSPI_PARAM \
282 "fip_qspi_addr=0x0\0"\
283 "fip_qspi_mirror_addr=0x200000\0"\
284 "loadaddr=0x90000000\0"\
285 "tftpblocksize=1468\0"\
286 "qspi_flash_fip=fip\0"\
288 /* Flash fit_GPT partition to eMMC */
289 #define MMC_FLASH_FIT_GPT \
291 "if mmc dev ${sd_device_number}; then "\
293 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
297 "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
299 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
304 #define MMC_FLASH_IMAGE_RSA \
305 "mmc_flash_image_rsa="\
306 "if mmc dev ${sd_device_number}; then "\
308 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
312 "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
314 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
318 "if tftp ${loadaddr} ${tftp_dir}${fit_image}; then "\
319 "if test ${fit_image} = Image_rsa.img; then "\
320 "if setenv tftp_fit_image yes; then "\
322 "echo [mmc_flash_image_rsa] "\
323 "setenv tftp_fit_image to yes"\
329 "if test ${fit_image} = Image_rsa.img; then "\
330 "echo [mmc_flash_image_rsa] tftp "\
331 "${tftp_dir}${fit_image} ** FAILED **;"\
333 "if test ${tftp_fit_image} = yes; then "\
334 "if mmc write ${loadaddr} "\
335 "${gpt_partition_addr} "\
336 "${fileblocks}; then "\
339 "[mmc_flash_image_rsa] "\
341 "${gpt_partition_addr} "\
346 "echo [mmc_flash_image_rsa] tftp "\
347 "${tftp_dir}${fit_image} "\
353 "if math add filesize filesize 1FF; then "\
355 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
358 "if math div fileblocks filesize 200; then "\
360 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
363 "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
365 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
369 "if setenv image_sz_blk_cnt ${fileblocks}; then "\
371 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
377 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
381 #define MMC_FLASH_RECOVERY \
382 "mmc_flash_recovery="\
383 "if mmc dev ${sd_device_number}; then "\
385 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
389 "if gpt setenv mmc ${sd_device_number} recovery; then "\
391 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
395 "while tftp ${loadaddr} "\
396 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
397 "if math add filesize filesize 1FF; then "\
399 "echo [mmc_flash_recovery] math add command "\
403 "if math div fileblocks filesize 200; then "\
405 "echo [mmc_flash_recovery] math div command "\
409 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
410 "${fileblocks}; then "\
412 "echo [mmc_flash_recovery] mmc write "\
413 "${gpt_partition_addr} ** FAILED **;"\
416 "if math add index index 1; then "\
418 "echo [mmc_flash_recovery] math add command "\
422 "if math add gpt_partition_addr gpt_partition_addr"\
423 " ${fileblocks}; then "\
425 "echo [mmc_flash_recovery] math add command"\
430 "if itest ${index} -ne 1; then "\
432 "echo [mmc_flash_recovery] "\
433 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
434 "not found ** FAILED **;"\
438 #define MMC_FLASH_ROOTFS \
440 "if mmc dev ${sd_device_number}; then "\
442 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
446 "if gpt setenv mmc ${sd_device_number} rootfs; then "\
448 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
452 "while tftp ${loadaddr} "\
453 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
454 "if math add filesize filesize 1FF; then "\
456 "echo [mmc_flash_rootfs] math add command "\
460 "if math div fileblocks filesize 200; then "\
462 "echo [mmc_flash_rootfs] math div command "\
466 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
467 "${fileblocks}; then "\
469 "echo [mmc_flash_rootfs] mmc write "\
470 "${gpt_partition_addr} ** FAILED **;"\
473 "if math add index index 1; then "\
475 "echo [mmc_flash_rootfs] math add command "\
479 "if math add gpt_partition_addr gpt_partition_addr"\
480 " ${fileblocks}; then "\
482 "echo [mmc_flash_rootfs] math add command"\
487 "if itest ${index} -ne 1; then "\
489 "echo [mmc_flash_rootfs] "\
490 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
491 "not found ** FAILED **;"\
496 * For individual flash commands like mmc_flash_gpt, it is not
497 * necessary to check for errors.
498 * If any of its intermediate commands fails, then next commands
499 * will not execute. Script will exit from the failure command.
500 * For uniformity, checking for mmc_flash_gpt, mmc_flash_image_rsa
501 * mmc_flash_nitro and mmc_flash_rootfs
505 "if run mmc_flash_gpt; then "\
507 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
510 "if setenv tftp_fit_image no; then "\
512 "echo [flash_mmc] setenv tftp_fit_image to no "\
516 "if setenv fit_image Image_rsa.img; then "\
518 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
522 "if run mmc_flash_image_rsa; then "\
524 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
527 "if setenv fit_image Image1_rsa.img; then "\
529 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
533 "if run mmc_flash_image_rsa; then "\
535 "echo [flash_mmc] run mmc_flash_image_rsa "\
536 "for Image1_rsa.img ** FAILED **;"\
539 "if setenv fit_image Image2_rsa.img; then "\
541 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
545 "if run mmc_flash_image_rsa; then "\
547 "echo [flash_mmc] run mmc_flash_image_rsa "\
548 "for Image2_rsa.img ** FAILED **;"\
551 "if run mmc_flash_recovery; then "\
553 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
556 "if run mmc_flash_rootfs; then "\
558 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
562 #define FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
563 "align_erase_blk_size=" \
564 "setenv fl_write_size 0;" \
565 "if math add fl_write_size filesize FFFF; then "\
567 "echo ${errstr} math add command ** FAILED **;"\
570 "if math div fl_write_size fl_write_size 10000; then "\
572 "echo ${errstr} math div command ** FAILED **;"\
575 "if math mul fl_write_size fl_write_size 10000; then "\
577 "echo ${errstr} math mul command ** FAILED **;"\
581 #define QSPI_FLASH_FIP \
583 "if run qspi_access_en; then "\
585 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
588 "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
590 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
594 "if math add tmpsize filesize FFFF; then "\
596 "echo [flash_fip] math add command ** FAILED **;"\
599 "if math div tmpsize tmpsize 10000; then "\
601 "echo [flash_fip] math div command ** FAILED **;"\
604 "if math mul tmpsize tmpsize 10000; then "\
606 "echo [flash_fip] math mul command ** FAILED **;"\
609 "if sf probe 0; then "\
611 "echo [flash_fip] sf probe command ** FAILED **;"\
614 "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
616 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
619 "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
621 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
624 /* Flash mirror FIP image */ \
625 "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
627 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
631 "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
633 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
638 #define QSPI_FLASH_NITRO \
640 "run func_qspi_probe; "\
641 "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
643 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
647 "setenv errstr flash_nitro;" \
648 "run align_erase_blk_size;" \
649 /* Flash Nitro fw fit + configuration */ \
650 "if sf erase ${spi_nitro_img_bin_start} ${fl_write_size}; then "\
652 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
656 "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
657 " ${fl_write_size}; then "\
659 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
663 /* Mirror of Flash Nitro fw fit + configuration */ \
664 "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
666 "echo [flash_nitro] sf erase "\
667 "${spi_nitro_img_bin_mirror_start} "\
671 "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
672 " ${fl_write_size}; then "\
674 "echo [flash_nitro] sf write "\
675 "${spi_nitro_img_bin_mirror_start} "\
680 #define QSPI_FLASH_NITRO_BSPD_CONFIG \
681 "flash_nitro_bspd_config="\
682 "run func_qspi_probe; "\
683 /* Flash BSPD configuration */ \
684 "if tftp ${loadaddr} ${tftp_dir}${nitro_bspd_cfg}; then "\
685 "setenv bspd_cfg_avialable 1; "\
686 "setenv errstr flash_nitro_bspd_config; "\
687 "run align_erase_blk_size;" \
688 "if sf erase ${spi_nitro_bspd_cfg_start} "\
689 "${fl_write_size}; then "\
691 "echo [flash_nitro] sf erase "\
692 "${spi_nitro_bspd_cfg_start} "\
696 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
697 "${fl_write_size}; then "\
699 "echo [flash_nitro] sf write "\
700 "${spi_nitro_bspd_cfg_start} "\
704 /* Flash BSPD mirror configuration */ \
705 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
706 "${fl_write_size}; then "\
708 "echo [flash_nitro] sf erase "\
709 "${spi_nitro_bspd_mirror_cfg_start} "\
713 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
714 "${fl_write_size}; then "\
716 "echo [flash_nitro] sf write "\
717 "${spi_nitro_bspd_mirror_cfg_start} "\
722 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
723 "** Skip flashing bspd config file **;"\
728 "if run qspi_access_en; then "\
730 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
733 "if run flash_fip; then "\
735 "echo [flash_qspi] run flash_fip ** FAILED **;"\
738 "if run flash_nitro; then "\
740 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
744 #define FLASH_IMAGES \
746 "if run flash_qspi; then "\
748 "echo [flash_images] run flash_qspi ** FAILED **;"\
751 "if run flash_mmc; then "\
753 "echo [flash_images] run flash_mmc ** FAILED **;"\
757 #define ARCH_ENV_SETTINGS \
766 UPDATEME_FLASH_PARAMS \
777 QSPI_FLASH_NITRO_PARAMS \
781 FASTBOOT_NITRO_SETUP \
793 FLASH_PENDING_RFS_IMGS \
796 MMC_FLASH_IMAGE_RSA \
800 FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
803 QSPI_FLASH_NITRO_BSPD_CONFIG \
807 #define CONFIG_EXTRA_ENV_SETTINGS \
810 #endif /* __BCM_NS3_H */