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 */
45 #define CONFIG_SUPPORT_EMMC_BOOT
47 /* enable 64-bit PCI resources */
48 #define CONFIG_SYS_PCI_64BIT 1
50 #define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
51 #define MAX_CPUS "max_cpus=maxcpus=8\0"
52 #define OS_LOG_LEVEL "log_level=loglevel=7\0"
53 #define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x68A10000 " \
54 "earlyelog=" __stringify(ELOG_AP_UART_LOG_BASE) ",0x10000 " \
55 "crashkernel=512M reboot=w\0"
57 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
59 #ifdef CONFIG_BCM_SF2_ETH
60 #define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0"
61 #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \
62 "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off"
68 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
70 #define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
71 " ${max_cpus} ${log_level} ${reserved_mem}"
72 #define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS " " NET_ARGS "\0"
74 #define UPDATEME_FLASH_PARAMS "bcm_compat_level=4\0" \
75 "bcm_need_recovery_rootfs=0\0" \
76 "bcm_bl_flash_pending_rfs_imgs=0\0"
78 #define KERNEL_LOADADDR_CFG \
79 "fit_image_loadaddr=0x90000000\0" \
80 "dtb_loadaddr=0x82000000\0"
82 #define INITRD_ARGS "initrd_args=root=/dev/ram rw\0"
83 #define INITRD_LOADADDR "initrd_loadaddr=0x92000000\0"
84 #define INITRD_IMAGE "initrd_image=rootfs-lake-bcm958742t.cpio.gz\0"
85 #define MMC_DEV "sd_device_number=0\0"
86 #define EXEC_STATE "exec_state=normal\0"
88 #define EXT4RD_ARGS "ext4rd_args="\
89 "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
91 #define WDT_CNTRL "wdt_enable=1\0" \
95 "mbox0_addr=0x66424024\0"\
97 "if logsetup -s ${mbox0_addr}; then "\
99 "echo ELOG is not supported by this version of the MCU patch.;"\
102 "if logsetup -c ${mbox0_addr}; then "\
103 "echo ELOG is ready;"\
105 "echo ELOG is supported, but is not set up.;"\
106 "echo Getting setup file from the server ${serverip}...;"\
107 "if tftp ${tftp_dir}elog_src.txt; then "\
108 "echo Setting up ELOG. Please wait...;"\
109 "if logsetup ${loadaddr} ${mbox0_addr} ${filesize}; "\
112 "echo [logsetup] ERROR.;"\
114 "if logsetup -c ${mbox0_addr}; then "\
115 "echo ELOG is READY.;"\
117 "echo ELOG is NOT SET UP.;"\
120 "echo ELOG setup file is not available on the server.;"\
124 /* eMMC partition for FIT images */
125 #define FIT_MMC_PARTITION \
127 "uuid_disk=${uuid_gpt_disk};" \
128 "name=env,size=512K,uuid=${uuid_gpt_env};" \
129 "name=Image_rsa.img,size=24MiB,uuid=${uuid_gpt_linux};" \
130 "name=Image1_rsa.img,size=24MiB,uuid=${uuid_gpt_linux1};" \
131 "name=Image2_rsa.img,size=24MiB,uuid=${uuid_gpt_linux2};" \
132 "name=nitro,size=8MiB,uuid=${uuid_gpt_nitro};" \
133 "name=recovery,size=940MiB,uuid=${uuid_gpt_recovery};" \
134 "name=rootfs,size=-,uuid=${uuid_gpt_prootfs}\0"
136 #define QSPI_FLASH_NITRO_PARAMS \
137 "spi_nitro_img_bin_start=0x400000\0" \
138 "spi_nitro_img_bin_mirror_start=0x580000\0" \
139 "spi_nitro_bspd_cfg_start=0x700000\0" \
140 "spi_nitro_bspd_mirror_cfg_start=0x710000\0" \
142 #define QSPI_ACCESS_ENABLE \
151 #define FUNC_QSPI_PROBE \
153 "if run qspi_access_en; then "\
155 "echo ${errstr} run qspi_access_en ** FAILED **;"\
158 "if sf probe 0; then "\
160 "echo echo ${errstr} sf probe command ** FAILED **;"\
164 #define NITRO_FW_IMAGES \
165 "nitro_bin=nitro.img\0" \
166 "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
168 #define FASTBOOT_NITRO_SETUP \
169 "nitro_fastboot_type=1\0" \
170 "nitro_fastboot_secure=1\0" \
171 "nitro_fastboot_img_buffer=0\0" \
172 "nitro_fit_img_loc=0x90000000\0"
174 #define FASTBOOT_SETUP \
175 "fastboot_nitro_setup=" \
176 "setenv errstr fastboot_setup;" \
177 "run func_qspi_probe;" \
178 /* first load header only */ \
179 "if sf read ${nitro_fit_img_loc} "\
180 "${spi_nitro_img_bin_start} 0x18; then "\
182 "echo [fastboot_nitro_setup] sf read "\
183 "${spi_nitro_img_bin_start} ** FAILED **;"\
186 "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
187 "${spi_nitro_img_bin_start}; then "\
189 "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
194 #define CHECK_CHIMP_HS\
195 "check_chimp_hs=chimp_hs"\
198 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
200 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
201 #define BOOTCMD_MMC_FIT \
203 "mmc dev ${sd_device_number};"\
204 "if test $exec_state = normal; then " \
205 "setenv use_rootfs rootfs;"\
207 "setenv use_rootfs recovery;"\
209 "echo used filesystem :${use_rootfs};"\
210 "gpt setenv mmc ${sd_device_number} ${use_rootfs};"\
211 "setenv bootargs_fs ${setbootargs} ${ext4rd_args}; run bootargs_fs;"\
212 "gpt setenv mmc ${sd_device_number} ${fit_image};"\
213 "mmc read ${fit_image_loadaddr} ${gpt_partition_addr} "\
214 "${gpt_partition_size};"\
215 "bootm ${fit_image_loadaddr}\0"
217 #define BOOTCMD_MMC_FITS \
220 "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
222 "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
224 "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
225 "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
227 #define USBDEV "usbdev=0\0"
230 "setenv usb_image_loadaddr 90000000;"\
231 "setenv fit_image Image_rsa.img;"\
232 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
233 "if usb dev ${usbdev}; && usb start; then "\
234 "echo Booting from USB...;"\
235 "fatload usb ${usbdev} ${usb_image_loadaddr} ${fit_image};"\
236 "fatload usb ${usbdev} ${initrd_loadaddr} ${initrd_image};"\
237 "bootm ${usb_image_loadaddr} ${initrd_loadaddr}:${filesize};"\
246 "bnxt_load=bnxt 0 probe "\
251 "run check_chimp_hs && "\
254 "setenv ethact bnxt_eth0;"\
255 "setenv autoload no;"\
256 "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
258 "setenv pxefile_addr_r ${loadaddr};"\
260 "setenv ramdisk_addr_r ${initrd_loadaddr};"\
261 "setenv kernel_addr_r ${fit_image_loadaddr};"\
267 #define FLASH_PENDING_RFS_IMGS \
268 "flash_pending_rfs_imgs=" \
269 "if test $bcm_bl_flash_pending_rfs_imgs = 1; then " \
270 "if test $bl_flash_pending_rfs_imgs = rootfs; then " \
272 "run mmc_flash_rootfs;" \
274 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
276 "run mmc_flash_recovery;" \
278 "setenv bl_flash_pending_rfs_imgs;" \
281 #define CONFIG_BOOTCOMMAND "run flash_pending_rfs_imgs;" \
282 "run fastboot_nitro && "\
283 "run bootcmd_mmc_fits || "\
284 "run bootcmd_usb || "\
287 /* Flashing commands */
288 #define TFTP_QSPI_PARAM \
289 "fip_qspi_addr=0x0\0"\
290 "fip_qspi_mirror_addr=0x200000\0"\
291 "loadaddr=0x90000000\0"\
292 "tftpblocksize=1468\0"\
293 "qspi_flash_fip=fip\0"\
295 /* Flash fit_GPT partition to eMMC */
296 #define MMC_FLASH_FIT_GPT \
298 "if mmc dev ${sd_device_number}; then "\
300 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
304 "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
306 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
311 #define MMC_FLASH_IMAGE_RSA \
312 "mmc_flash_image_rsa="\
313 "if mmc dev ${sd_device_number}; then "\
315 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
319 "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
321 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
325 "if tftp ${loadaddr} ${tftp_dir}${fit_image}; then "\
326 "if test ${fit_image} = Image_rsa.img; then "\
327 "if setenv tftp_fit_image yes; then "\
329 "echo [mmc_flash_image_rsa] "\
330 "setenv tftp_fit_image to yes"\
336 "if test ${fit_image} = Image_rsa.img; then "\
337 "echo [mmc_flash_image_rsa] tftp "\
338 "${tftp_dir}${fit_image} ** FAILED **;"\
340 "if test ${tftp_fit_image} = yes; then "\
341 "if mmc write ${loadaddr} "\
342 "${gpt_partition_addr} "\
343 "${fileblocks}; then "\
346 "[mmc_flash_image_rsa] "\
348 "${gpt_partition_addr} "\
353 "echo [mmc_flash_image_rsa] tftp "\
354 "${tftp_dir}${fit_image} "\
360 "if math add filesize filesize 1FF; then "\
362 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
365 "if math div fileblocks filesize 200; then "\
367 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
370 "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
372 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
376 "if setenv image_sz_blk_cnt ${fileblocks}; then "\
378 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
384 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
388 #define MMC_FLASH_RECOVERY \
389 "mmc_flash_recovery="\
390 "if mmc dev ${sd_device_number}; then "\
392 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
396 "if gpt setenv mmc ${sd_device_number} recovery; then "\
398 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
402 "while tftp ${loadaddr} "\
403 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
404 "if math add filesize filesize 1FF; then "\
406 "echo [mmc_flash_recovery] math add command "\
410 "if math div fileblocks filesize 200; then "\
412 "echo [mmc_flash_recovery] math div command "\
416 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
417 "${fileblocks}; then "\
419 "echo [mmc_flash_recovery] mmc write "\
420 "${gpt_partition_addr} ** FAILED **;"\
423 "if math add index index 1; then "\
425 "echo [mmc_flash_recovery] math add command "\
429 "if math add gpt_partition_addr gpt_partition_addr"\
430 " ${fileblocks}; then "\
432 "echo [mmc_flash_recovery] math add command"\
437 "if itest ${index} -ne 1; then "\
439 "echo [mmc_flash_recovery] "\
440 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
441 "not found ** FAILED **;"\
445 #define MMC_FLASH_ROOTFS \
447 "if mmc dev ${sd_device_number}; then "\
449 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
453 "if gpt setenv mmc ${sd_device_number} rootfs; then "\
455 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
459 "while tftp ${loadaddr} "\
460 "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
461 "if math add filesize filesize 1FF; then "\
463 "echo [mmc_flash_rootfs] math add command "\
467 "if math div fileblocks filesize 200; then "\
469 "echo [mmc_flash_rootfs] math div command "\
473 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
474 "${fileblocks}; then "\
476 "echo [mmc_flash_rootfs] mmc write "\
477 "${gpt_partition_addr} ** FAILED **;"\
480 "if math add index index 1; then "\
482 "echo [mmc_flash_rootfs] math add command "\
486 "if math add gpt_partition_addr gpt_partition_addr"\
487 " ${fileblocks}; then "\
489 "echo [mmc_flash_rootfs] math add command"\
494 "if itest ${index} -ne 1; then "\
496 "echo [mmc_flash_rootfs] "\
497 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
498 "not found ** FAILED **;"\
503 * For individual flash commands like mmc_flash_gpt, it is not
504 * necessary to check for errors.
505 * If any of its intermediate commands fails, then next commands
506 * will not execute. Script will exit from the failure command.
507 * For uniformity, checking for mmc_flash_gpt, mmc_flash_image_rsa
508 * mmc_flash_nitro and mmc_flash_rootfs
512 "if run mmc_flash_gpt; then "\
514 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
517 "if setenv tftp_fit_image no; then "\
519 "echo [flash_mmc] setenv tftp_fit_image to no "\
523 "if setenv fit_image Image_rsa.img; then "\
525 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
529 "if run mmc_flash_image_rsa; then "\
531 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
534 "if setenv fit_image Image1_rsa.img; then "\
536 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
540 "if run mmc_flash_image_rsa; then "\
542 "echo [flash_mmc] run mmc_flash_image_rsa "\
543 "for Image1_rsa.img ** FAILED **;"\
546 "if setenv fit_image Image2_rsa.img; then "\
548 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
552 "if run mmc_flash_image_rsa; then "\
554 "echo [flash_mmc] run mmc_flash_image_rsa "\
555 "for Image2_rsa.img ** FAILED **;"\
558 "if run mmc_flash_recovery; then "\
560 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
563 "if run mmc_flash_rootfs; then "\
565 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
569 #define FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
570 "align_erase_blk_size=" \
571 "setenv fl_write_size 0;" \
572 "if math add fl_write_size filesize FFFF; then "\
574 "echo ${errstr} math add command ** FAILED **;"\
577 "if math div fl_write_size fl_write_size 10000; then "\
579 "echo ${errstr} math div command ** FAILED **;"\
582 "if math mul fl_write_size fl_write_size 10000; then "\
584 "echo ${errstr} math mul command ** FAILED **;"\
588 #define QSPI_FLASH_FIP \
590 "if run qspi_access_en; then "\
592 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
595 "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
597 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
601 "if math add tmpsize filesize FFFF; then "\
603 "echo [flash_fip] math add command ** FAILED **;"\
606 "if math div tmpsize tmpsize 10000; then "\
608 "echo [flash_fip] math div command ** FAILED **;"\
611 "if math mul tmpsize tmpsize 10000; then "\
613 "echo [flash_fip] math mul command ** FAILED **;"\
616 "if sf probe 0; then "\
618 "echo [flash_fip] sf probe command ** FAILED **;"\
621 "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
623 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
626 "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
628 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
631 /* Flash mirror FIP image */ \
632 "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
634 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
638 "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
640 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
645 #define QSPI_FLASH_NITRO \
647 "run func_qspi_probe; "\
648 "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
650 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
654 "setenv errstr flash_nitro;" \
655 "run align_erase_blk_size;" \
656 /* Flash Nitro fw fit + configuration */ \
657 "if sf erase ${spi_nitro_img_bin_start} ${fl_write_size}; then "\
659 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
663 "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
664 " ${fl_write_size}; then "\
666 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
670 /* Mirror of Flash Nitro fw fit + configuration */ \
671 "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
673 "echo [flash_nitro] sf erase "\
674 "${spi_nitro_img_bin_mirror_start} "\
678 "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
679 " ${fl_write_size}; then "\
681 "echo [flash_nitro] sf write "\
682 "${spi_nitro_img_bin_mirror_start} "\
687 #define QSPI_FLASH_NITRO_BSPD_CONFIG \
688 "flash_nitro_bspd_config="\
689 "run func_qspi_probe; "\
690 /* Flash BSPD configuration */ \
691 "if tftp ${loadaddr} ${tftp_dir}${nitro_bspd_cfg}; then "\
692 "setenv bspd_cfg_avialable 1; "\
693 "setenv errstr flash_nitro_bspd_config; "\
694 "run align_erase_blk_size;" \
695 "if sf erase ${spi_nitro_bspd_cfg_start} "\
696 "${fl_write_size}; then "\
698 "echo [flash_nitro] sf erase "\
699 "${spi_nitro_bspd_cfg_start} "\
703 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
704 "${fl_write_size}; then "\
706 "echo [flash_nitro] sf write "\
707 "${spi_nitro_bspd_cfg_start} "\
711 /* Flash BSPD mirror configuration */ \
712 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
713 "${fl_write_size}; then "\
715 "echo [flash_nitro] sf erase "\
716 "${spi_nitro_bspd_mirror_cfg_start} "\
720 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
721 "${fl_write_size}; then "\
723 "echo [flash_nitro] sf write "\
724 "${spi_nitro_bspd_mirror_cfg_start} "\
729 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
730 "** Skip flashing bspd config file **;"\
735 "if run qspi_access_en; then "\
737 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
740 "if run flash_fip; then "\
742 "echo [flash_qspi] run flash_fip ** FAILED **;"\
745 "if run flash_nitro; then "\
747 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
751 #define FLASH_IMAGES \
753 "if run flash_qspi; then "\
755 "echo [flash_images] run flash_qspi ** FAILED **;"\
758 "if run flash_mmc; then "\
760 "echo [flash_images] run flash_mmc ** FAILED **;"\
764 #define ARCH_ENV_SETTINGS \
773 UPDATEME_FLASH_PARAMS \
784 QSPI_FLASH_NITRO_PARAMS \
788 FASTBOOT_NITRO_SETUP \
800 FLASH_PENDING_RFS_IMGS \
803 MMC_FLASH_IMAGE_RSA \
807 FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
810 QSPI_FLASH_NITRO_BSPD_CONFIG \
814 #define CONFIG_EXTRA_ENV_SETTINGS \
817 #endif /* __BCM_NS3_H */