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 */
48 #define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
49 #define MAX_CPUS "max_cpus=maxcpus=8\0"
50 #define OS_LOG_LEVEL "log_level=loglevel=7\0"
51 #define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x68A10000 " \
52 "earlyelog=" __stringify(ELOG_AP_UART_LOG_BASE) ",0x10000 " \
53 "crashkernel=512M reboot=w\0"
55 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
57 #ifdef CONFIG_BCM_SF2_ETH
58 #define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0"
59 #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \
60 "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off"
66 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
68 #define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
69 " ${max_cpus} ${log_level} ${reserved_mem}"
70 #define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS " " NET_ARGS "\0"
72 #define UPDATEME_FLASH_PARAMS "bcm_compat_level=4\0" \
73 "bcm_need_recovery_rootfs=0\0" \
74 "bcm_bl_flash_pending_rfs_imgs=0\0"
76 #define KERNEL_LOADADDR_CFG \
77 "fit_image_loadaddr=0x90000000\0" \
78 "dtb_loadaddr=0x82000000\0"
80 #define INITRD_ARGS "initrd_args=root=/dev/ram rw\0"
81 #define INITRD_LOADADDR "initrd_loadaddr=0x92000000\0"
82 #define INITRD_IMAGE "initrd_image=rootfs-lake-bcm958742t.cpio.gz\0"
83 #define MMC_DEV "sd_device_number=0\0"
84 #define EXEC_STATE "exec_state=normal\0"
86 #define EXT4RD_ARGS "ext4rd_args="\
87 "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
89 #define WDT_CNTRL "wdt_enable=1\0" \
93 "mbox0_addr=0x66424024\0"\
95 "if logsetup -s ${mbox0_addr}; then "\
97 "echo ELOG is not supported by this version of the MCU patch.;"\
100 "if logsetup -c ${mbox0_addr}; then "\
101 "echo ELOG is ready;"\
103 "echo ELOG is supported, but is not set up.;"\
104 "echo Getting setup file from the server ${serverip}...;"\
105 "if tftp ${tftp_dir}elog_src.txt; then "\
106 "echo Setting up ELOG. Please wait...;"\
107 "if logsetup ${loadaddr} ${mbox0_addr} ${filesize}; "\
110 "echo [logsetup] ERROR.;"\
112 "if logsetup -c ${mbox0_addr}; then "\
113 "echo ELOG is READY.;"\
115 "echo ELOG is NOT SET UP.;"\
118 "echo ELOG setup file is not available on the server.;"\
122 /* eMMC partition for FIT images */
123 #define FIT_MMC_PARTITION \
125 "uuid_disk=${uuid_gpt_disk};" \
126 "name=env,size=512K,uuid=${uuid_gpt_env};" \
127 "name=Image_rsa.img,size=24MiB,uuid=${uuid_gpt_linux};" \
128 "name=Image1_rsa.img,size=24MiB,uuid=${uuid_gpt_linux1};" \
129 "name=Image2_rsa.img,size=24MiB,uuid=${uuid_gpt_linux2};" \
130 "name=nitro,size=8MiB,uuid=${uuid_gpt_nitro};" \
131 "name=recovery,size=940MiB,uuid=${uuid_gpt_recovery};" \
132 "name=rootfs,size=-,uuid=${uuid_gpt_prootfs}\0"
134 #define QSPI_FLASH_NITRO_PARAMS \
135 "spi_nitro_img_bin_start=0x400000\0" \
136 "spi_nitro_img_bin_mirror_start=0x580000\0" \
137 "spi_nitro_bspd_cfg_start=0x700000\0" \
138 "spi_nitro_bspd_mirror_cfg_start=0x710000\0" \
140 #define QSPI_ACCESS_ENABLE \
149 #define FUNC_QSPI_PROBE \
151 "if run qspi_access_en; then "\
153 "echo ${errstr} run qspi_access_en ** FAILED **;"\
156 "if sf probe 0; then "\
158 "echo echo ${errstr} sf probe command ** FAILED **;"\
162 #define NITRO_FW_IMAGES \
163 "nitro_bin=nitro.img\0" \
164 "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
166 #define FASTBOOT_NITRO_SETUP \
167 "nitro_fastboot_type=1\0" \
168 "nitro_fastboot_secure=1\0" \
169 "nitro_fastboot_img_buffer=0\0" \
170 "nitro_fit_img_loc=0x90000000\0"
172 #define FASTBOOT_SETUP \
173 "fastboot_nitro_setup=" \
174 "setenv errstr fastboot_setup;" \
175 "run func_qspi_probe;" \
176 /* first load header only */ \
177 "if sf read ${nitro_fit_img_loc} "\
178 "${spi_nitro_img_bin_start} 0x18; then "\
180 "echo [fastboot_nitro_setup] sf read "\
181 "${spi_nitro_img_bin_start} ** FAILED **;"\
184 "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
185 "${spi_nitro_img_bin_start}; then "\
187 "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
192 #define CHECK_CHIMP_HS\
193 "check_chimp_hs=chimp_hs"\
196 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
198 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
199 #define BOOTCMD_MMC_FIT \
201 "mmc dev ${sd_device_number};"\
202 "if test $exec_state = normal; then " \
203 "setenv use_rootfs rootfs;"\
205 "setenv use_rootfs recovery;"\
207 "echo used filesystem :${use_rootfs};"\
208 "gpt setenv mmc ${sd_device_number} ${use_rootfs};"\
209 "setenv bootargs_fs ${setbootargs} ${ext4rd_args}; run bootargs_fs;"\
210 "gpt setenv mmc ${sd_device_number} ${fit_image};"\
211 "mmc read ${fit_image_loadaddr} ${gpt_partition_addr} "\
212 "${gpt_partition_size};"\
213 "bootm ${fit_image_loadaddr}\0"
215 #define BOOTCMD_MMC_FITS \
218 "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
220 "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
222 "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
223 "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
225 #define USBDEV "usbdev=0\0"
228 "setenv usb_image_loadaddr 90000000;"\
229 "setenv fit_image Image_rsa.img;"\
230 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
231 "if usb dev ${usbdev}; && usb start; then "\
232 "echo Booting from USB...;"\
233 "fatload usb ${usbdev} ${usb_image_loadaddr} ${fit_image};"\
234 "fatload usb ${usbdev} ${initrd_loadaddr} ${initrd_image};"\
235 "bootm ${usb_image_loadaddr} ${initrd_loadaddr}:${filesize};"\
244 "bnxt_load=bnxt 0 probe "\
249 "run check_chimp_hs && "\
252 "setenv ethact bnxt_eth0;"\
253 "setenv autoload no;"\
254 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
256 "setenv pxefile_addr_r ${loadaddr};"\
258 "setenv ramdisk_addr_r ${initrd_loadaddr};"\
259 "setenv kernel_addr_r ${fit_image_loadaddr};"\
265 #define FLASH_PENDING_RFS_IMGS \
266 "flash_pending_rfs_imgs=" \
267 "if test $bcm_bl_flash_pending_rfs_imgs = 1; then " \
268 "if test $bl_flash_pending_rfs_imgs = rootfs; then " \
270 "run mmc_flash_rootfs;" \
272 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
274 "run mmc_flash_recovery;" \
276 "setenv bl_flash_pending_rfs_imgs;" \
279 /* Flashing commands */
280 #define TFTP_QSPI_PARAM \
281 "fip_qspi_addr=0x0\0"\
282 "fip_qspi_mirror_addr=0x200000\0"\
283 "loadaddr=0x90000000\0"\
284 "tftpblocksize=1468\0"\
285 "qspi_flash_fip=fip\0"\
287 /* Flash fit_GPT partition to eMMC */
288 #define MMC_FLASH_FIT_GPT \
290 "if mmc dev ${sd_device_number}; then "\
292 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
296 "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
298 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
303 #define MMC_FLASH_IMAGE_RSA \
304 "mmc_flash_image_rsa="\
305 "if mmc dev ${sd_device_number}; then "\
307 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
311 "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
313 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
317 "if tftp ${loadaddr} ${tftp_dir}${fit_image}; then "\
318 "if test ${fit_image} = Image_rsa.img; then "\
319 "if setenv tftp_fit_image yes; then "\
321 "echo [mmc_flash_image_rsa] "\
322 "setenv tftp_fit_image to yes"\
328 "if test ${fit_image} = Image_rsa.img; then "\
329 "echo [mmc_flash_image_rsa] tftp "\
330 "${tftp_dir}${fit_image} ** FAILED **;"\
332 "if test ${tftp_fit_image} = yes; then "\
333 "if mmc write ${loadaddr} "\
334 "${gpt_partition_addr} "\
335 "${fileblocks}; then "\
338 "[mmc_flash_image_rsa] "\
340 "${gpt_partition_addr} "\
345 "echo [mmc_flash_image_rsa] tftp "\
346 "${tftp_dir}${fit_image} "\
352 "if math add filesize filesize 1FF; then "\
354 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
357 "if math div fileblocks filesize 200; then "\
359 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
362 "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
364 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
368 "if setenv image_sz_blk_cnt ${fileblocks}; then "\
370 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
376 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
380 #define MMC_FLASH_RECOVERY \
381 "mmc_flash_recovery="\
382 "if mmc dev ${sd_device_number}; then "\
384 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
388 "if gpt setenv mmc ${sd_device_number} recovery; then "\
390 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
394 "while tftp ${loadaddr} "\
395 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
396 "if math add filesize filesize 1FF; then "\
398 "echo [mmc_flash_recovery] math add command "\
402 "if math div fileblocks filesize 200; then "\
404 "echo [mmc_flash_recovery] math div command "\
408 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
409 "${fileblocks}; then "\
411 "echo [mmc_flash_recovery] mmc write "\
412 "${gpt_partition_addr} ** FAILED **;"\
415 "if math add index index 1; then "\
417 "echo [mmc_flash_recovery] math add command "\
421 "if math add gpt_partition_addr gpt_partition_addr"\
422 " ${fileblocks}; then "\
424 "echo [mmc_flash_recovery] math add command"\
429 "if itest ${index} -ne 1; then "\
431 "echo [mmc_flash_recovery] "\
432 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
433 "not found ** FAILED **;"\
437 #define MMC_FLASH_ROOTFS \
439 "if mmc dev ${sd_device_number}; then "\
441 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
445 "if gpt setenv mmc ${sd_device_number} rootfs; then "\
447 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
451 "while tftp ${loadaddr} "\
452 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
453 "if math add filesize filesize 1FF; then "\
455 "echo [mmc_flash_rootfs] math add command "\
459 "if math div fileblocks filesize 200; then "\
461 "echo [mmc_flash_rootfs] math div command "\
465 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
466 "${fileblocks}; then "\
468 "echo [mmc_flash_rootfs] mmc write "\
469 "${gpt_partition_addr} ** FAILED **;"\
472 "if math add index index 1; then "\
474 "echo [mmc_flash_rootfs] math add command "\
478 "if math add gpt_partition_addr gpt_partition_addr"\
479 " ${fileblocks}; then "\
481 "echo [mmc_flash_rootfs] math add command"\
486 "if itest ${index} -ne 1; then "\
488 "echo [mmc_flash_rootfs] "\
489 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
490 "not found ** FAILED **;"\
495 * For individual flash commands like mmc_flash_gpt, it is not
496 * necessary to check for errors.
497 * If any of its intermediate commands fails, then next commands
498 * will not execute. Script will exit from the failure command.
499 * For uniformity, checking for mmc_flash_gpt, mmc_flash_image_rsa
500 * mmc_flash_nitro and mmc_flash_rootfs
504 "if run mmc_flash_gpt; then "\
506 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
509 "if setenv tftp_fit_image no; then "\
511 "echo [flash_mmc] setenv tftp_fit_image to no "\
515 "if setenv fit_image Image_rsa.img; then "\
517 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
521 "if run mmc_flash_image_rsa; then "\
523 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
526 "if setenv fit_image Image1_rsa.img; then "\
528 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
532 "if run mmc_flash_image_rsa; then "\
534 "echo [flash_mmc] run mmc_flash_image_rsa "\
535 "for Image1_rsa.img ** FAILED **;"\
538 "if setenv fit_image Image2_rsa.img; then "\
540 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
544 "if run mmc_flash_image_rsa; then "\
546 "echo [flash_mmc] run mmc_flash_image_rsa "\
547 "for Image2_rsa.img ** FAILED **;"\
550 "if run mmc_flash_recovery; then "\
552 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
555 "if run mmc_flash_rootfs; then "\
557 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
561 #define FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
562 "align_erase_blk_size=" \
563 "setenv fl_write_size 0;" \
564 "if math add fl_write_size filesize FFFF; then "\
566 "echo ${errstr} math add command ** FAILED **;"\
569 "if math div fl_write_size fl_write_size 10000; then "\
571 "echo ${errstr} math div command ** FAILED **;"\
574 "if math mul fl_write_size fl_write_size 10000; then "\
576 "echo ${errstr} math mul command ** FAILED **;"\
580 #define QSPI_FLASH_FIP \
582 "if run qspi_access_en; then "\
584 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
587 "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
589 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
593 "if math add tmpsize filesize FFFF; then "\
595 "echo [flash_fip] math add command ** FAILED **;"\
598 "if math div tmpsize tmpsize 10000; then "\
600 "echo [flash_fip] math div command ** FAILED **;"\
603 "if math mul tmpsize tmpsize 10000; then "\
605 "echo [flash_fip] math mul command ** FAILED **;"\
608 "if sf probe 0; then "\
610 "echo [flash_fip] sf probe command ** FAILED **;"\
613 "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
615 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
618 "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
620 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
623 /* Flash mirror FIP image */ \
624 "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
626 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
630 "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
632 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
637 #define QSPI_FLASH_NITRO \
639 "run func_qspi_probe; "\
640 "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
642 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
646 "setenv errstr flash_nitro;" \
647 "run align_erase_blk_size;" \
648 /* Flash Nitro fw fit + configuration */ \
649 "if sf erase ${spi_nitro_img_bin_start} ${fl_write_size}; then "\
651 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
655 "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
656 " ${fl_write_size}; then "\
658 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
662 /* Mirror of Flash Nitro fw fit + configuration */ \
663 "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
665 "echo [flash_nitro] sf erase "\
666 "${spi_nitro_img_bin_mirror_start} "\
670 "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
671 " ${fl_write_size}; then "\
673 "echo [flash_nitro] sf write "\
674 "${spi_nitro_img_bin_mirror_start} "\
679 #define QSPI_FLASH_NITRO_BSPD_CONFIG \
680 "flash_nitro_bspd_config="\
681 "run func_qspi_probe; "\
682 /* Flash BSPD configuration */ \
683 "if tftp ${loadaddr} ${tftp_dir}${nitro_bspd_cfg}; then "\
684 "setenv bspd_cfg_avialable 1; "\
685 "setenv errstr flash_nitro_bspd_config; "\
686 "run align_erase_blk_size;" \
687 "if sf erase ${spi_nitro_bspd_cfg_start} "\
688 "${fl_write_size}; then "\
690 "echo [flash_nitro] sf erase "\
691 "${spi_nitro_bspd_cfg_start} "\
695 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
696 "${fl_write_size}; then "\
698 "echo [flash_nitro] sf write "\
699 "${spi_nitro_bspd_cfg_start} "\
703 /* Flash BSPD mirror configuration */ \
704 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
705 "${fl_write_size}; then "\
707 "echo [flash_nitro] sf erase "\
708 "${spi_nitro_bspd_mirror_cfg_start} "\
712 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
713 "${fl_write_size}; then "\
715 "echo [flash_nitro] sf write "\
716 "${spi_nitro_bspd_mirror_cfg_start} "\
721 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
722 "** Skip flashing bspd config file **;"\
727 "if run qspi_access_en; then "\
729 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
732 "if run flash_fip; then "\
734 "echo [flash_qspi] run flash_fip ** FAILED **;"\
737 "if run flash_nitro; then "\
739 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
743 #define FLASH_IMAGES \
745 "if run flash_qspi; then "\
747 "echo [flash_images] run flash_qspi ** FAILED **;"\
750 "if run flash_mmc; then "\
752 "echo [flash_images] run flash_mmc ** FAILED **;"\
756 #define ARCH_ENV_SETTINGS \
765 UPDATEME_FLASH_PARAMS \
776 QSPI_FLASH_NITRO_PARAMS \
780 FASTBOOT_NITRO_SETUP \
792 FLASH_PENDING_RFS_IMGS \
795 MMC_FLASH_IMAGE_RSA \
799 FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
802 QSPI_FLASH_NITRO_BSPD_CONFIG \
806 #define CONFIG_EXTRA_ENV_SETTINGS \
809 #endif /* __BCM_NS3_H */