Merge https://gitlab.denx.de/u-boot/custodians/u-boot-imx
[platform/kernel/u-boot.git] / include / configs / bcm_ns3.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright 2020 Broadcom.
4  *
5  */
6
7 #ifndef __BCM_NS3_H
8 #define __BCM_NS3_H
9
10 #include <linux/sizes.h>
11
12 #define CONFIG_HOSTNAME                 "NS3"
13
14 /* Physical Memory Map */
15 #define V2M_BASE                        0x80000000
16 #define PHYS_SDRAM_1                    V2M_BASE
17
18 #define CONFIG_SYS_SDRAM_BASE           PHYS_SDRAM_1
19 #define CONFIG_SYS_LOAD_ADDR            (PHYS_SDRAM_1 + 0x80000)
20
21 /*
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
26  */
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)
30
31 /* console configuration */
32 #define CONFIG_SYS_NS16550_CLK          25000000
33
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
39
40 /*
41  * Increase max uncompressed/gunzip size, keeping size same as EMMC linux
42  * partition.
43  */
44 #define CONFIG_SYS_BOOTM_LEN            0x01800000
45
46 /* Access eMMC Boot_1 and Boot_2 partitions */
47 #define CONFIG_SUPPORT_EMMC_BOOT
48
49 /* enable 64-bit PCI resources */
50 #define CONFIG_SYS_PCI_64BIT            1
51
52 #define CONSOLE_ARGS "console_args=console=ttyS0,115200n8\0"
53 #define MAX_CPUS "max_cpus=maxcpus=8\0"
54 #define OS_LOG_LEVEL "log_level=loglevel=7\0"
55 #define EXTRA_ARGS "extra_args=earlycon=uart8250,mmio32,0x68A10000 " \
56                    "earlyelog=" __stringify(ELOG_AP_UART_LOG_BASE) ",0x10000 " \
57                    "crashkernel=512M reboot=w\0"
58
59 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
60
61 #ifdef CONFIG_BCM_SF2_ETH
62 #define ETH_ADDR "ethaddr=00:0A:F7:95:65:A4\0"
63 #define NET_ARGS "bgmac_platform.ethaddr=${ethaddr} " \
64         "ip=${ipaddr}::${gatewayip}:${netmask}::${ethif}:off"
65 #else
66 #define ETH_ADDR
67 #define NET_ARGS
68 #endif
69
70 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
71
72 #define BASE_ARGS "${console_args} ${extra_args} ${pcie_args}" \
73                   " ${max_cpus}  ${log_level} ${reserved_mem}"
74 #define SETBOOTARGS "setbootargs=setenv bootargs " BASE_ARGS " " NET_ARGS "\0"
75
76 #define UPDATEME_FLASH_PARAMS "bcm_compat_level=4\0" \
77                               "bcm_need_recovery_rootfs=0\0" \
78                               "bcm_bl_flash_pending_rfs_imgs=0\0"
79
80 #define KERNEL_LOADADDR_CFG \
81         "fit_image_loadaddr=0x90000000\0" \
82         "dtb_loadaddr=0x82000000\0"
83
84 #define INITRD_ARGS "initrd_args=root=/dev/ram rw\0"
85 #define INITRD_LOADADDR "initrd_loadaddr=0x92000000\0"
86 #define INITRD_IMAGE "initrd_image=rootfs-lake-bcm958742t.cpio.gz\0"
87 #define MMC_DEV "sd_device_number=0\0"
88 #define EXEC_STATE "exec_state=normal\0"
89
90 #define EXT4RD_ARGS "ext4rd_args="\
91         "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
92
93 #define WDT_CNTRL "wdt_enable=1\0" \
94                   "wdt_timeout_sec=0\0"
95
96 #define ELOG_SETUP \
97         "mbox0_addr=0x66424024\0"\
98         "elog_setup="\
99         "if logsetup -s ${mbox0_addr}; then "\
100         "else "\
101                 "echo ELOG is not supported by this version of the MCU patch.;"\
102                 "exit;"\
103         "fi;"\
104         "if logsetup -c ${mbox0_addr}; then "\
105                 "echo ELOG is ready;"\
106         "else "\
107                 "echo ELOG is supported, but is not set up.;"\
108                 "echo Getting setup file from the server ${serverip}...;"\
109                 "if tftp ${tftp_dir}elog_src.txt; then "\
110                         "echo Setting up ELOG. Please wait...;"\
111                         "if logsetup ${loadaddr} ${mbox0_addr} ${filesize}; "\
112                                 "then "\
113                         "else "\
114                                 "echo [logsetup] ERROR.;"\
115                         "fi;"\
116                         "if logsetup -c ${mbox0_addr}; then "\
117                                 "echo ELOG is READY.;"\
118                         "else "\
119                                 "echo ELOG is NOT SET UP.;"\
120                         "fi;"\
121                 "else "\
122                         "echo ELOG setup file is not available on the server.;"\
123                 "fi;"\
124         "fi \0"
125
126 /* eMMC partition for FIT images */
127 #define FIT_MMC_PARTITION \
128         "fit_partitions=" \
129         "uuid_disk=${uuid_gpt_disk};" \
130         "name=env,size=512K,uuid=${uuid_gpt_env};" \
131         "name=Image_rsa.img,size=24MiB,uuid=${uuid_gpt_linux};" \
132         "name=Image1_rsa.img,size=24MiB,uuid=${uuid_gpt_linux1};" \
133         "name=Image2_rsa.img,size=24MiB,uuid=${uuid_gpt_linux2};" \
134         "name=nitro,size=8MiB,uuid=${uuid_gpt_nitro};" \
135         "name=recovery,size=940MiB,uuid=${uuid_gpt_recovery};" \
136         "name=rootfs,size=-,uuid=${uuid_gpt_prootfs}\0"
137
138 #define QSPI_FLASH_NITRO_PARAMS \
139         "spi_nitro_img_bin_start=0x400000\0" \
140         "spi_nitro_img_bin_mirror_start=0x580000\0" \
141         "spi_nitro_bspd_cfg_start=0x700000\0" \
142         "spi_nitro_bspd_mirror_cfg_start=0x710000\0" \
143
144 #define QSPI_ACCESS_ENABLE \
145         "qspi_access_en=" \
146         "mw 0x68a403e8 1;" \
147         "mw 0x68a403ec 1;" \
148         "mw 0x68a403f0 1;" \
149         "mw 0x68a403f4 1;" \
150         "mw 0x68a403f8 1;" \
151         "mw 0x68a403fc 1 \0"
152
153 #define FUNC_QSPI_PROBE \
154         "func_qspi_probe="\
155         "if run qspi_access_en; then "\
156         "else "\
157                 "echo ${errstr} run qspi_access_en ** FAILED **;"\
158                 "exit;"\
159         "fi;"\
160         "if sf probe 0; then "\
161         "else "\
162                 "echo echo ${errstr} sf probe command ** FAILED **;"\
163                 "exit;"\
164         "fi \0"
165
166 #define NITRO_FW_IMAGES \
167         "nitro_bin=nitro.img\0" \
168         "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
169
170 #define FASTBOOT_NITRO_SETUP \
171         "nitro_fastboot_type=1\0" \
172         "nitro_fastboot_secure=1\0" \
173         "nitro_fastboot_img_buffer=0\0" \
174         "nitro_fit_img_loc=0x90000000\0"
175
176 #define FASTBOOT_SETUP \
177         "fastboot_nitro_setup=" \
178         "setenv errstr fastboot_setup;" \
179         "run func_qspi_probe;" \
180         /* first load header only */ \
181         "if sf read ${nitro_fit_img_loc} "\
182                    "${spi_nitro_img_bin_start} 0x18; then "\
183         "else "\
184                 "echo [fastboot_nitro_setup] sf read "\
185                       "${spi_nitro_img_bin_start} ** FAILED **;"\
186                 "exit;"\
187         "fi;"\
188         "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
189                                  "${spi_nitro_img_bin_start}; then "\
190         "else "\
191                  "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
192                        "** FAILED **;"\
193                 "exit;"\
194         "fi \0"
195
196 #define CHECK_CHIMP_HS\
197         "check_chimp_hs=chimp_hs"\
198         "\0"
199
200 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
201
202 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
203 #define BOOTCMD_MMC_FIT \
204         "bootcmd_mmc_fit="\
205         "mmc dev ${sd_device_number};"\
206         "if test $exec_state = normal; then " \
207                 "setenv use_rootfs rootfs;"\
208         "else " \
209                 "setenv use_rootfs recovery;"\
210         "fi;" \
211         "echo used filesystem :${use_rootfs};"\
212         "gpt setenv mmc ${sd_device_number} ${use_rootfs};"\
213         "setenv bootargs_fs ${setbootargs} ${ext4rd_args}; run bootargs_fs;"\
214         "gpt setenv mmc ${sd_device_number} ${fit_image};"\
215         "mmc read ${fit_image_loadaddr} ${gpt_partition_addr} "\
216         "${gpt_partition_size};"\
217         "bootm ${fit_image_loadaddr}\0"
218
219 #define BOOTCMD_MMC_FITS \
220         "bootcmd_mmc_fits="\
221         "setenv mmc_fit0 " \
222         "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
223         "setenv mmc_fit1 " \
224         "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
225         "setenv mmc_fit2 " \
226         "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
227         "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
228
229 #define USBDEV "usbdev=0\0"
230 #define BOOTCMD_USB\
231         "bootcmd_usb="\
232         "setenv usb_image_loadaddr 90000000;"\
233         "setenv fit_image Image_rsa.img;"\
234         "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
235         "if usb dev ${usbdev}; && usb start; then "\
236                 "echo Booting from USB...;"\
237                 "fatload usb ${usbdev} ${usb_image_loadaddr} ${fit_image};"\
238                 "fatload usb ${usbdev} ${initrd_loadaddr} ${initrd_image};"\
239                 "bootm ${usb_image_loadaddr} ${initrd_loadaddr}:${filesize};"\
240         "fi;"\
241         "\0"
242
243 #define START_PCI\
244         "start_pci=pci e "\
245         "\0"
246
247 #define BNXT_LOAD\
248         "bnxt_load=bnxt 0 probe "\
249         "\0"
250
251 #define BOOTCMD_PXE\
252         "bootcmd_pxe="\
253         "run check_chimp_hs && "\
254         "run start_pci && "\
255         "run bnxt_load;"\
256         "setenv ethact bnxt_eth0;"\
257         "setenv autoload no;"\
258         "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
259         "if dhcp; then "\
260                 "setenv pxefile_addr_r ${loadaddr};"\
261                 "if pxe get; then "\
262                         "setenv ramdisk_addr_r ${initrd_loadaddr};"\
263                         "setenv kernel_addr_r ${fit_image_loadaddr};"\
264                         "pxe boot; "\
265                 "fi;"\
266         "fi;"\
267         "\0"
268
269 #define FLASH_PENDING_RFS_IMGS \
270         "flash_pending_rfs_imgs=" \
271         "if test $bcm_bl_flash_pending_rfs_imgs = 1; then " \
272                 "if test $bl_flash_pending_rfs_imgs = rootfs; then " \
273                         "dhcp;" \
274                         "run mmc_flash_rootfs;" \
275                 "fi;" \
276                 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
277                         "dhcp;" \
278                         "run mmc_flash_recovery;" \
279                 "fi;" \
280                 "setenv bl_flash_pending_rfs_imgs;" \
281         "fi; \0"
282
283 #define CONFIG_BOOTCOMMAND "run flash_pending_rfs_imgs;" \
284                            "run fastboot_nitro && "\
285                            "run bootcmd_mmc_fits || "\
286                            "run bootcmd_usb || "\
287                            "run bootcmd_pxe"
288
289 /* Flashing commands */
290 #define TFTP_QSPI_PARAM \
291         "fip_qspi_addr=0x0\0"\
292         "fip_qspi_mirror_addr=0x200000\0"\
293         "loadaddr=0x90000000\0"\
294         "tftpblocksize=1468\0"\
295         "qspi_flash_fip=fip\0"\
296
297 /* Flash fit_GPT partition to eMMC */
298 #define MMC_FLASH_FIT_GPT \
299         "mmc_flash_gpt="\
300         "if mmc dev ${sd_device_number}; then "\
301         "else "\
302                 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
303                 "** FAILED **;"\
304                 "exit;"\
305         "fi;"\
306         "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
307         "else "\
308                 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
309                 "** FAILED **;"\
310                 "exit;"\
311         "fi \0"
312
313 #define MMC_FLASH_IMAGE_RSA \
314         "mmc_flash_image_rsa="\
315         "if mmc dev ${sd_device_number}; then "\
316         "else "\
317                 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
318                 "** FAILED **;"\
319                 "exit;"\
320         "fi;"\
321         "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
322         "else "\
323                 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
324                 "** FAILED **;"\
325                 "exit;"\
326         "fi;"\
327         "if tftp ${loadaddr} ${tftp_dir}${fit_image}; then "\
328                 "if test ${fit_image} = Image_rsa.img; then "\
329                         "if setenv tftp_fit_image yes; then "\
330                         "else "\
331                                 "echo [mmc_flash_image_rsa] "\
332                                 "setenv tftp_fit_image to yes"\
333                                 "** FAILED **;"\
334                                 "exit;"\
335                         "fi;"\
336                 "fi;"\
337         "else "\
338                 "if test ${fit_image} = Image_rsa.img; then "\
339                         "echo [mmc_flash_image_rsa] tftp "\
340                         "${tftp_dir}${fit_image} ** FAILED **;"\
341                 "else "\
342                         "if test ${tftp_fit_image} = yes; then "\
343                                 "if mmc write ${loadaddr} "\
344                                 "${gpt_partition_addr} "\
345                                 "${fileblocks}; then "\
346                                 "else "\
347                                         "echo "\
348                                         "[mmc_flash_image_rsa] "\
349                                         "mmc write "\
350                                         "${gpt_partition_addr} "\
351                                         "** FAILED **;"\
352                                         "exit;"\
353                                 "fi;"\
354                         "else "\
355                                 "echo [mmc_flash_image_rsa] tftp "\
356                                 "${tftp_dir}${fit_image} "\
357                                 "** FAILED **;"\
358                         "fi;"\
359                 "fi;"\
360                 "exit;"\
361         "fi;"\
362         "if math add filesize filesize 1FF; then "\
363         "else "\
364                 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
365                 "exit;"\
366         "fi;"\
367         "if math div fileblocks filesize 200; then "\
368         "else "\
369                 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
370                 "exit;"\
371         "fi;"\
372         "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
373         "else "\
374                 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
375                 "** FAILED **;"\
376                 "exit;"\
377         "fi;"\
378         "if setenv image_sz_blk_cnt ${fileblocks}; then "\
379         "else "\
380                 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
381                 "FAILED **;"\
382                 "exit;"\
383         "fi;"\
384         "if saveenv; then "\
385         "else "\
386                 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
387                 "exit;"\
388         "fi \0"
389
390 #define MMC_FLASH_RECOVERY \
391         "mmc_flash_recovery="\
392         "if mmc dev ${sd_device_number}; then "\
393         "else "\
394                 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
395                 "** FAILED **;"\
396                 "exit;"\
397         "fi;"\
398         "if gpt setenv mmc ${sd_device_number} recovery; then "\
399         "else "\
400                 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
401                 "exit;"\
402         "fi;"\
403         "setenv index 1;"\
404         "while tftp ${loadaddr} "\
405         "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
406                 "if math add filesize filesize 1FF; then "\
407                 "else "\
408                         "echo [mmc_flash_recovery] math add command "\
409                         "** FAILED **;"\
410                         "exit;"\
411                 "fi;"\
412                 "if math div fileblocks filesize 200; then "\
413                 "else "\
414                         "echo [mmc_flash_recovery] math div command "\
415                         "** FAILED **;"\
416                         "exit;"\
417                 "fi;"\
418                 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
419                 "${fileblocks}; then "\
420                 "else "\
421                         "echo [mmc_flash_recovery] mmc write "\
422                         "${gpt_partition_addr} ** FAILED **;"\
423                         "exit;"\
424                 "fi;"\
425                 "if math add index index 1; then "\
426                 "else "\
427                         "echo [mmc_flash_recovery] math add command "\
428                         "** FAILED **;"\
429                         "exit;"\
430                 "fi;"\
431                 "if math add gpt_partition_addr gpt_partition_addr"\
432                 " ${fileblocks}; then "\
433                 "else "\
434                         "echo [mmc_flash_recovery] math add command"\
435                         " ** FAILED **;"\
436                         "exit;"\
437                 "fi;"\
438         "done;"\
439         "if itest ${index} -ne 1; then "\
440         "else "\
441                 "echo [mmc_flash_recovery] "\
442                 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
443                 "not found ** FAILED **;"\
444                 "exit;"\
445         "fi \0"
446
447 #define MMC_FLASH_ROOTFS \
448         "mmc_flash_rootfs="\
449         "if mmc dev ${sd_device_number}; then "\
450         "else "\
451                 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
452                 "** FAILED **;"\
453                 "exit;"\
454         "fi;"\
455         "if gpt setenv mmc ${sd_device_number} rootfs; then "\
456         "else "\
457                 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
458                 "exit;"\
459         "fi;"\
460         "setenv index 1;"\
461         "while tftp ${loadaddr} "\
462         "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
463                 "if math add filesize filesize 1FF; then "\
464                 "else "\
465                         "echo [mmc_flash_rootfs] math add command "\
466                         "** FAILED **;"\
467                         "exit;"\
468                 "fi;"\
469                 "if math div fileblocks filesize 200; then "\
470                 "else "\
471                         "echo [mmc_flash_rootfs] math div command "\
472                         "** FAILED **;"\
473                         "exit;"\
474                 "fi;"\
475                 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
476                 "${fileblocks}; then "\
477                 "else "\
478                         "echo [mmc_flash_rootfs] mmc write "\
479                         "${gpt_partition_addr} ** FAILED **;"\
480                         "exit;"\
481                 "fi;"\
482                 "if math add index index 1; then "\
483                 "else "\
484                         "echo [mmc_flash_rootfs] math add command "\
485                         "** FAILED **;"\
486                         "exit;"\
487                 "fi;"\
488                 "if math add gpt_partition_addr gpt_partition_addr"\
489                 " ${fileblocks}; then "\
490                 "else "\
491                         "echo [mmc_flash_rootfs] math add command"\
492                         " ** FAILED **;"\
493                         "exit;"\
494                 "fi;"\
495         "done;"\
496         "if itest ${index} -ne 1; then "\
497         "else "\
498                 "echo [mmc_flash_rootfs] "\
499                 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
500                 "not found ** FAILED **;"\
501                 "exit;"\
502         "fi \0"
503
504 /*
505  * For individual flash commands like mmc_flash_gpt, it is not
506  * necessary to check for errors.
507  * If any of its intermediate commands fails, then next commands
508  * will not execute. Script will exit from the failure command.
509  * For uniformity, checking for mmc_flash_gpt, mmc_flash_image_rsa
510  * mmc_flash_nitro and mmc_flash_rootfs
511  */
512 #define MMC_FLASH \
513         "flash_mmc="\
514         "if run mmc_flash_gpt; then "\
515         "else "\
516                 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
517                 "exit;"\
518         "fi;"\
519         "if setenv tftp_fit_image no; then "\
520         "else "\
521                 "echo [flash_mmc] setenv tftp_fit_image to no "\
522                 "** FAILED **;"\
523                 "exit;"\
524         "fi;"\
525         "if setenv fit_image Image_rsa.img; then "\
526         "else "\
527                 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
528                 "** FAILED **;"\
529                 "exit;"\
530         "fi;"\
531         "if run mmc_flash_image_rsa; then "\
532         "else "\
533                 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
534                 "exit;"\
535         "fi;"\
536         "if setenv fit_image Image1_rsa.img; then "\
537         "else "\
538                 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
539                 "** FAILED **;"\
540                 "exit;"\
541         "fi;"\
542         "if run mmc_flash_image_rsa; then "\
543         "else "\
544                 "echo [flash_mmc] run mmc_flash_image_rsa "\
545                 "for Image1_rsa.img ** FAILED **;"\
546                 "exit;"\
547         "fi;"\
548         "if setenv fit_image Image2_rsa.img; then "\
549         "else "\
550                 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
551                 "** FAILED **;"\
552                 "exit;"\
553         "fi;"\
554         "if run mmc_flash_image_rsa; then "\
555         "else "\
556                 "echo [flash_mmc] run mmc_flash_image_rsa "\
557                 "for Image2_rsa.img ** FAILED **;"\
558                 "exit;"\
559         "fi;"\
560         "if run mmc_flash_recovery; then "\
561         "else "\
562                 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
563                 "exit;"\
564         "fi;"\
565         "if run mmc_flash_rootfs; then "\
566         "else "\
567                 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
568                 "exit;"\
569         "fi \0"
570
571 #define FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
572         "align_erase_blk_size=" \
573         "setenv fl_write_size 0;" \
574         "if math add fl_write_size filesize FFFF; then "\
575         "else "\
576                 "echo ${errstr} math add command ** FAILED **;"\
577                 "exit;"\
578         "fi;"\
579         "if math div fl_write_size fl_write_size 10000; then "\
580         "else "\
581                 "echo ${errstr} math div command ** FAILED **;"\
582                 "exit;"\
583         "fi;"\
584         "if math mul fl_write_size fl_write_size 10000; then "\
585         "else "\
586                 "echo ${errstr} math mul command ** FAILED **;"\
587                 "exit;"\
588         "fi \0"
589
590 #define QSPI_FLASH_FIP \
591         "flash_fip="\
592         "if run qspi_access_en; then "\
593         "else "\
594                 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
595                 "exit;"\
596         "fi;"\
597         "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
598         "else "\
599                 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
600                 "** FAILED **;"\
601                 "exit;"\
602         "fi;"\
603         "if math add tmpsize filesize FFFF; then "\
604         "else "\
605                 "echo [flash_fip] math add command ** FAILED **;"\
606                 "exit;"\
607         "fi;"\
608         "if math div tmpsize tmpsize 10000; then "\
609         "else "\
610                 "echo [flash_fip] math div command ** FAILED **;"\
611                 "exit;"\
612         "fi;"\
613         "if math mul tmpsize tmpsize 10000; then "\
614         "else "\
615                 "echo [flash_fip] math mul command ** FAILED **;"\
616                 "exit;"\
617         "fi;"\
618         "if sf probe 0; then "\
619         "else "\
620                 "echo [flash_fip] sf probe command ** FAILED **;"\
621                 "exit;"\
622         "fi;"\
623         "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
624         "else "\
625                 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
626                 "exit;"\
627         "fi;"\
628         "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
629         "else "\
630                 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
631                 "exit;"\
632         "fi;"\
633         /* Flash mirror FIP image */ \
634         "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
635         "else "\
636                 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
637                         "** FAILED **;"\
638                 "exit;"\
639         "fi;"\
640         "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
641         "else "\
642                 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
643                         "** FAILED **;"\
644                 "exit;"\
645         "fi \0"
646
647 #define QSPI_FLASH_NITRO \
648         "flash_nitro="\
649         "run func_qspi_probe; "\
650         "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
651         "else "\
652                 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
653                 "** FAILED **;"\
654                 "exit;"\
655         "fi;"\
656         "setenv errstr flash_nitro;" \
657         "run align_erase_blk_size;" \
658         /* Flash Nitro fw fit + configuration */ \
659         "if sf erase ${spi_nitro_img_bin_start} ${fl_write_size}; then "\
660         "else "\
661                 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
662                 "** FAILED **;"\
663                 "exit;"\
664         "fi;"\
665         "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
666                      " ${fl_write_size}; then "\
667         "else "\
668                 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
669                 "** FAILED **;"\
670                 "exit;"\
671         "fi;"\
672         /* Mirror of Flash Nitro fw fit + configuration */ \
673         "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
674         "else "\
675                 "echo [flash_nitro] sf erase "\
676                       "${spi_nitro_img_bin_mirror_start} "\
677                 "** FAILED **;"\
678                 "exit;"\
679         "fi;"\
680         "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
681                      " ${fl_write_size}; then "\
682         "else "\
683                 "echo [flash_nitro] sf write "\
684                       "${spi_nitro_img_bin_mirror_start} "\
685                 "** FAILED **;"\
686                 "exit;"\
687         "fi \0"
688
689 #define QSPI_FLASH_NITRO_BSPD_CONFIG \
690         "flash_nitro_bspd_config="\
691         "run func_qspi_probe; "\
692         /* Flash BSPD configuration */ \
693         "if tftp ${loadaddr} ${tftp_dir}${nitro_bspd_cfg}; then "\
694                 "setenv bspd_cfg_avialable 1; "\
695                 "setenv errstr flash_nitro_bspd_config; "\
696                 "run align_erase_blk_size;" \
697                 "if sf erase ${spi_nitro_bspd_cfg_start} "\
698                             "${fl_write_size}; then "\
699                 "else "\
700                         "echo [flash_nitro] sf erase "\
701                                 "${spi_nitro_bspd_cfg_start} "\
702                                 "** FAILED **;"\
703                         "exit;"\
704                 "fi;"\
705                 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
706                             "${fl_write_size}; then "\
707                 "else "\
708                         "echo [flash_nitro] sf write "\
709                                 "${spi_nitro_bspd_cfg_start} "\
710                                 "** FAILED **;"\
711                         "exit;"\
712                 "fi;" \
713                 /* Flash BSPD mirror configuration */ \
714                 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
715                             "${fl_write_size}; then "\
716                 "else "\
717                         "echo [flash_nitro] sf erase "\
718                                 "${spi_nitro_bspd_mirror_cfg_start} "\
719                                 "** FAILED **;"\
720                         "exit;"\
721                 "fi;"\
722                 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
723                         "${fl_write_size}; then "\
724                 "else "\
725                         "echo [flash_nitro] sf write "\
726                                 "${spi_nitro_bspd_mirror_cfg_start} "\
727                                 "** FAILED **;"\
728                         "exit;"\
729                 "fi;" \
730         "else "\
731                 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
732                 "** Skip flashing bspd config file **;"\
733         "fi \0"
734
735 #define QSPI_FLASH \
736         "flash_qspi="\
737         "if run qspi_access_en; then "\
738         "else "\
739                 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
740                 "exit;"\
741         "fi;"\
742         "if run flash_fip; then "\
743         "else "\
744                 "echo [flash_qspi] run flash_fip ** FAILED **;"\
745                 "exit;"\
746         "fi;"\
747         "if run flash_nitro; then "\
748         "else "\
749                 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
750                 "exit;"\
751         "fi \0"
752
753 #define FLASH_IMAGES \
754         "flash_images=" \
755         "if run flash_qspi; then "\
756         "else "\
757                 "echo [flash_images] run flash_qspi ** FAILED **;"\
758                 "exit;"\
759         "fi;"\
760         "if run flash_mmc; then "\
761         "else "\
762                 "echo [flash_images] run flash_mmc ** FAILED **;"\
763                 "exit;"\
764         "fi \0"
765
766 #define ARCH_ENV_SETTINGS \
767         CONSOLE_ARGS \
768         MAX_CPUS \
769         OS_LOG_LEVEL \
770         EXTRA_ARGS \
771         PCIE_ARGS \
772         ETH_ADDR \
773         RESERVED_MEM \
774         SETBOOTARGS \
775         UPDATEME_FLASH_PARAMS \
776         KERNEL_LOADADDR_CFG\
777         INITRD_ARGS \
778         INITRD_LOADADDR \
779         INITRD_IMAGE \
780         MMC_DEV \
781         EXEC_STATE \
782         EXT4RD_ARGS \
783         WDT_CNTRL \
784         ELOG_SETUP \
785         FIT_MMC_PARTITION \
786         QSPI_FLASH_NITRO_PARAMS \
787         QSPI_ACCESS_ENABLE \
788         FUNC_QSPI_PROBE \
789         NITRO_FW_IMAGES \
790         FASTBOOT_NITRO_SETUP \
791         FASTBOOT_SETUP \
792         CHECK_CHIMP_HS \
793         FASTBOOT_NITRO \
794         FIT_IMAGE \
795         BOOTCMD_MMC_FIT \
796         BOOTCMD_MMC_FITS \
797         USBDEV \
798         BOOTCMD_USB \
799         START_PCI \
800         BNXT_LOAD \
801         BOOTCMD_PXE \
802         FLASH_PENDING_RFS_IMGS \
803         TFTP_QSPI_PARAM \
804         MMC_FLASH_FIT_GPT \
805         MMC_FLASH_IMAGE_RSA \
806         MMC_FLASH_RECOVERY \
807         MMC_FLASH_ROOTFS \
808         MMC_FLASH \
809         FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
810         QSPI_FLASH_FIP \
811         QSPI_FLASH_NITRO \
812         QSPI_FLASH_NITRO_BSPD_CONFIG \
813         QSPI_FLASH \
814         FLASH_IMAGES
815
816 #define CONFIG_EXTRA_ENV_SETTINGS \
817         ARCH_ENV_SETTINGS
818
819 #endif /* __BCM_NS3_H */