Merge tag 'next-20220328' of https://source.denx.de/u-boot/custodians/u-boot-video...
[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
20 /*
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
25  */
26 #define CONFIG_SYS_INIT_SP_ADDR         (PHYS_SDRAM_1 + 0x80000000)
27 /* 12MB Malloc size */
28
29 /* console configuration */
30 #define CONFIG_SYS_NS16550_CLK          25000000
31
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
37
38 /*
39  * Increase max uncompressed/gunzip size, keeping size same as EMMC linux
40  * partition.
41  */
42 #define CONFIG_SYS_BOOTM_LEN            0x01800000
43
44 /* Access eMMC Boot_1 and Boot_2 partitions */
45
46 /* enable 64-bit PCI resources */
47
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"
54
55 #define PCIE_ARGS "pcie_args=pci=pcie_bus_safe pcie_ports=native vfio_pci.disable_idle_d3=1\0"
56
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"
61 #else
62 #define ETH_ADDR
63 #define NET_ARGS
64 #endif
65
66 #define RESERVED_MEM "reserved_mem=memmap=0xff000000$0x1000000\0"
67
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"
71
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"
75
76 #define KERNEL_LOADADDR_CFG \
77         "fit_image_loadaddr=0x90000000\0" \
78         "dtb_loadaddr=0x82000000\0"
79
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"
85
86 #define EXT4RD_ARGS "ext4rd_args="\
87         "root=/dev/mmcblk${sd_device_number}p${gpt_partition_entry} rw rootwait\0"
88
89 #define WDT_CNTRL "wdt_enable=1\0" \
90                   "wdt_timeout_sec=0\0"
91
92 #define ELOG_SETUP \
93         "mbox0_addr=0x66424024\0"\
94         "elog_setup="\
95         "if logsetup -s ${mbox0_addr}; then "\
96         "else "\
97                 "echo ELOG is not supported by this version of the MCU patch.;"\
98                 "exit;"\
99         "fi;"\
100         "if logsetup -c ${mbox0_addr}; then "\
101                 "echo ELOG is ready;"\
102         "else "\
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}; "\
108                                 "then "\
109                         "else "\
110                                 "echo [logsetup] ERROR.;"\
111                         "fi;"\
112                         "if logsetup -c ${mbox0_addr}; then "\
113                                 "echo ELOG is READY.;"\
114                         "else "\
115                                 "echo ELOG is NOT SET UP.;"\
116                         "fi;"\
117                 "else "\
118                         "echo ELOG setup file is not available on the server.;"\
119                 "fi;"\
120         "fi \0"
121
122 /* eMMC partition for FIT images */
123 #define FIT_MMC_PARTITION \
124         "fit_partitions=" \
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"
133
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" \
139
140 #define QSPI_ACCESS_ENABLE \
141         "qspi_access_en=" \
142         "mw 0x68a403e8 1;" \
143         "mw 0x68a403ec 1;" \
144         "mw 0x68a403f0 1;" \
145         "mw 0x68a403f4 1;" \
146         "mw 0x68a403f8 1;" \
147         "mw 0x68a403fc 1 \0"
148
149 #define FUNC_QSPI_PROBE \
150         "func_qspi_probe="\
151         "if run qspi_access_en; then "\
152         "else "\
153                 "echo ${errstr} run qspi_access_en ** FAILED **;"\
154                 "exit;"\
155         "fi;"\
156         "if sf probe 0; then "\
157         "else "\
158                 "echo echo ${errstr} sf probe command ** FAILED **;"\
159                 "exit;"\
160         "fi \0"
161
162 #define NITRO_FW_IMAGES \
163         "nitro_bin=nitro.img\0" \
164         "nitro_bspd_cfg=nitro_fb_bspd_config.bin\0"
165
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"
171
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 "\
179         "else "\
180                 "echo [fastboot_nitro_setup] sf read "\
181                       "${spi_nitro_img_bin_start} ** FAILED **;"\
182                 "exit;"\
183         "fi;"\
184         "if spi_nitro_images_addr ${nitro_fit_img_loc} "\
185                                  "${spi_nitro_img_bin_start}; then "\
186         "else "\
187                  "echo [fastboot_nitro_setup] spi_nitro_images_addr "\
188                        "** FAILED **;"\
189                 "exit;"\
190         "fi \0"
191
192 #define CHECK_CHIMP_HS\
193         "check_chimp_hs=chimp_hs"\
194         "\0"
195
196 #define FASTBOOT_NITRO "fastboot_nitro=chimp_ld_secure\0"
197
198 #define FIT_IMAGE "fit_image=Image_rsa.img\0"
199 #define BOOTCMD_MMC_FIT \
200         "bootcmd_mmc_fit="\
201         "mmc dev ${sd_device_number};"\
202         "if test $exec_state = normal; then " \
203                 "setenv use_rootfs rootfs;"\
204         "else " \
205                 "setenv use_rootfs recovery;"\
206         "fi;" \
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"
214
215 #define BOOTCMD_MMC_FITS \
216         "bootcmd_mmc_fits="\
217         "setenv mmc_fit0 " \
218         "'setenv fit_image Image_rsa.img; run bootcmd_mmc_fit';"\
219         "setenv mmc_fit1 " \
220         "'setenv fit_image Image1_rsa.img; run bootcmd_mmc_fit';"\
221         "setenv mmc_fit2 " \
222         "'setenv fit_image Image2_rsa.img; run bootcmd_mmc_fit';"\
223         "run mmc_fit0 || run mmc_fit1 || run mmc_fit2\0"
224
225 #define USBDEV "usbdev=0\0"
226 #define BOOTCMD_USB\
227         "bootcmd_usb="\
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};"\
236         "fi;"\
237         "\0"
238
239 #define START_PCI\
240         "start_pci=pci e "\
241         "\0"
242
243 #define BNXT_LOAD\
244         "bnxt_load=bnxt 0 probe "\
245         "\0"
246
247 #define BOOTCMD_PXE\
248         "bootcmd_pxe="\
249         "run check_chimp_hs && "\
250         "run start_pci && "\
251         "run bnxt_load;"\
252         "setenv ethact bnxt_eth0;"\
253         "setenv autoload no;"\
254         "setenv bootargs_fs ${setbootargs} ${initrd_args}; run bootargs_fs;"\
255         "if dhcp; then "\
256                 "setenv pxefile_addr_r ${loadaddr};"\
257                 "if pxe get; then "\
258                         "setenv ramdisk_addr_r ${initrd_loadaddr};"\
259                         "setenv kernel_addr_r ${fit_image_loadaddr};"\
260                         "pxe boot; "\
261                 "fi;"\
262         "fi;"\
263         "\0"
264
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 " \
269                         "dhcp;" \
270                         "run mmc_flash_rootfs;" \
271                 "fi;" \
272                 "if test $bl_flash_pending_rfs_imgs = recovery; then " \
273                         "dhcp;" \
274                         "run mmc_flash_recovery;" \
275                 "fi;" \
276                 "setenv bl_flash_pending_rfs_imgs;" \
277         "fi; \0"
278
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"\
286
287 /* Flash fit_GPT partition to eMMC */
288 #define MMC_FLASH_FIT_GPT \
289         "mmc_flash_gpt="\
290         "if mmc dev ${sd_device_number}; then "\
291         "else "\
292                 "echo [mmc_flash_gpt] mmc dev ${sd_device_number} "\
293                 "** FAILED **;"\
294                 "exit;"\
295         "fi;"\
296         "if gpt write mmc ${sd_device_number} ${fit_partitions}; then "\
297         "else "\
298                 "echo [mmc_flash_gpt] gpt write ${fit_partitions} "\
299                 "** FAILED **;"\
300                 "exit;"\
301         "fi \0"
302
303 #define MMC_FLASH_IMAGE_RSA \
304         "mmc_flash_image_rsa="\
305         "if mmc dev ${sd_device_number}; then "\
306         "else "\
307                 "echo [mmc_flash_image_rsa] mmc dev ${sd_device_number} "\
308                 "** FAILED **;"\
309                 "exit;"\
310         "fi;"\
311         "if gpt setenv mmc ${sd_device_number} ${fit_image}; then "\
312         "else "\
313                 "echo [mmc_flash_image_rsa] gpt setenv ${fit_image} "\
314                 "** FAILED **;"\
315                 "exit;"\
316         "fi;"\
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 "\
320                         "else "\
321                                 "echo [mmc_flash_image_rsa] "\
322                                 "setenv tftp_fit_image to yes"\
323                                 "** FAILED **;"\
324                                 "exit;"\
325                         "fi;"\
326                 "fi;"\
327         "else "\
328                 "if test ${fit_image} = Image_rsa.img; then "\
329                         "echo [mmc_flash_image_rsa] tftp "\
330                         "${tftp_dir}${fit_image} ** FAILED **;"\
331                 "else "\
332                         "if test ${tftp_fit_image} = yes; then "\
333                                 "if mmc write ${loadaddr} "\
334                                 "${gpt_partition_addr} "\
335                                 "${fileblocks}; then "\
336                                 "else "\
337                                         "echo "\
338                                         "[mmc_flash_image_rsa] "\
339                                         "mmc write "\
340                                         "${gpt_partition_addr} "\
341                                         "** FAILED **;"\
342                                         "exit;"\
343                                 "fi;"\
344                         "else "\
345                                 "echo [mmc_flash_image_rsa] tftp "\
346                                 "${tftp_dir}${fit_image} "\
347                                 "** FAILED **;"\
348                         "fi;"\
349                 "fi;"\
350                 "exit;"\
351         "fi;"\
352         "if math add filesize filesize 1FF; then "\
353         "else "\
354                 "echo [mmc_flash_image_rsa] math add command ** FAILED **;"\
355                 "exit;"\
356         "fi;"\
357         "if math div fileblocks filesize 200; then "\
358         "else "\
359                 "echo [mmc_flash_image_rsa] math div command ** FAILED **;"\
360                 "exit;"\
361         "fi;"\
362         "if mmc write ${loadaddr} ${gpt_partition_addr} ${fileblocks}; then "\
363         "else "\
364                 "echo [mmc_flash_image_rsa] mmc write ${gpt_partition_addr} "\
365                 "** FAILED **;"\
366                 "exit;"\
367         "fi;"\
368         "if setenv image_sz_blk_cnt ${fileblocks}; then "\
369         "else "\
370                 "echo [mmc_flash_image_rsa] setenv image_sz_blk_cnt ** "\
371                 "FAILED **;"\
372                 "exit;"\
373         "fi;"\
374         "if saveenv; then "\
375         "else "\
376                 "echo [mmc_flash_image_rsa] saveenv command ** FAILED **;"\
377                 "exit;"\
378         "fi \0"
379
380 #define MMC_FLASH_RECOVERY \
381         "mmc_flash_recovery="\
382         "if mmc dev ${sd_device_number}; then "\
383         "else "\
384                 "echo [mmc_flash_recovery] mmc dev ${sd_device_number} "\
385                 "** FAILED **;"\
386                 "exit;"\
387         "fi;"\
388         "if gpt setenv mmc ${sd_device_number} recovery; then "\
389         "else "\
390                 "echo [mmc_flash_recovery] gpt setenv recovery ** FAILED **;"\
391                 "exit;"\
392         "fi;"\
393         "setenv index 1;"\
394         "while tftp ${loadaddr} "\
395         "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
396                 "if math add filesize filesize 1FF; then "\
397                 "else "\
398                         "echo [mmc_flash_recovery] math add command "\
399                         "** FAILED **;"\
400                         "exit;"\
401                 "fi;"\
402                 "if math div fileblocks filesize 200; then "\
403                 "else "\
404                         "echo [mmc_flash_recovery] math div command "\
405                         "** FAILED **;"\
406                         "exit;"\
407                 "fi;"\
408                 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
409                 "${fileblocks}; then "\
410                 "else "\
411                         "echo [mmc_flash_recovery] mmc write "\
412                         "${gpt_partition_addr} ** FAILED **;"\
413                         "exit;"\
414                 "fi;"\
415                 "if math add index index 1; then "\
416                 "else "\
417                         "echo [mmc_flash_recovery] math add command "\
418                         "** FAILED **;"\
419                         "exit;"\
420                 "fi;"\
421                 "if math add gpt_partition_addr gpt_partition_addr"\
422                 " ${fileblocks}; then "\
423                 "else "\
424                         "echo [mmc_flash_recovery] math add command"\
425                         " ** FAILED **;"\
426                         "exit;"\
427                 "fi;"\
428         "done;"\
429         "if itest ${index} -ne 1; then "\
430         "else "\
431                 "echo [mmc_flash_recovery] "\
432                 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
433                 "not found ** FAILED **;"\
434                 "exit;"\
435         "fi \0"
436
437 #define MMC_FLASH_ROOTFS \
438         "mmc_flash_rootfs="\
439         "if mmc dev ${sd_device_number}; then "\
440         "else "\
441                 "echo [mmc_flash_rootfs] mmc dev ${sd_device_number} "\
442                 "** FAILED **;"\
443                 "exit;"\
444         "fi;"\
445         "if gpt setenv mmc ${sd_device_number} rootfs; then "\
446         "else "\
447                 "echo [mmc_flash_rootfs] gpt setenv rootfs ** FAILED **;"\
448                 "exit;"\
449         "fi;"\
450         "setenv index 1;"\
451         "while tftp ${loadaddr} "\
452         "${tftp_dir}${gpt_partition_name}/chunk_00${index}; do "\
453                 "if math add filesize filesize 1FF; then "\
454                 "else "\
455                         "echo [mmc_flash_rootfs] math add command "\
456                         "** FAILED **;"\
457                         "exit;"\
458                 "fi;"\
459                 "if math div fileblocks filesize 200; then "\
460                 "else "\
461                         "echo [mmc_flash_rootfs] math div command "\
462                         "** FAILED **;"\
463                         "exit;"\
464                 "fi;"\
465                 "if mmc write ${loadaddr} ${gpt_partition_addr} "\
466                 "${fileblocks}; then "\
467                 "else "\
468                         "echo [mmc_flash_rootfs] mmc write "\
469                         "${gpt_partition_addr} ** FAILED **;"\
470                         "exit;"\
471                 "fi;"\
472                 "if math add index index 1; then "\
473                 "else "\
474                         "echo [mmc_flash_rootfs] math add command "\
475                         "** FAILED **;"\
476                         "exit;"\
477                 "fi;"\
478                 "if math add gpt_partition_addr gpt_partition_addr"\
479                 " ${fileblocks}; then "\
480                 "else "\
481                         "echo [mmc_flash_rootfs] math add command"\
482                         " ** FAILED **;"\
483                         "exit;"\
484                 "fi;"\
485         "done;"\
486         "if itest ${index} -ne 1; then "\
487         "else "\
488                 "echo [mmc_flash_rootfs] "\
489                 "${tftp_dir}${gpt_partition_name}/chunk_00${index} file "\
490                 "not found ** FAILED **;"\
491                 "exit;"\
492         "fi \0"
493
494 /*
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
501  */
502 #define MMC_FLASH \
503         "flash_mmc="\
504         "if run mmc_flash_gpt; then "\
505         "else "\
506                 "echo [flash_mmc] run mmc_flash_gpt ** FAILED **;"\
507                 "exit;"\
508         "fi;"\
509         "if setenv tftp_fit_image no; then "\
510         "else "\
511                 "echo [flash_mmc] setenv tftp_fit_image to no "\
512                 "** FAILED **;"\
513                 "exit;"\
514         "fi;"\
515         "if setenv fit_image Image_rsa.img; then "\
516         "else "\
517                 "echo [flash_mmc] setenv fit_image to Image_rsa.img "\
518                 "** FAILED **;"\
519                 "exit;"\
520         "fi;"\
521         "if run mmc_flash_image_rsa; then "\
522         "else "\
523                 "echo [flash_mmc] run mmc_flash_image_rsa ** FAILED **;"\
524                 "exit;"\
525         "fi;"\
526         "if setenv fit_image Image1_rsa.img; then "\
527         "else "\
528                 "echo [flash_mmc] setenv fit_image to Image1_rsa.img "\
529                 "** FAILED **;"\
530                 "exit;"\
531         "fi;"\
532         "if run mmc_flash_image_rsa; then "\
533         "else "\
534                 "echo [flash_mmc] run mmc_flash_image_rsa "\
535                 "for Image1_rsa.img ** FAILED **;"\
536                 "exit;"\
537         "fi;"\
538         "if setenv fit_image Image2_rsa.img; then "\
539         "else "\
540                 "echo [flash_mmc] setenv fit_image to Image2_rsa.img "\
541                 "** FAILED **;"\
542                 "exit;"\
543         "fi;"\
544         "if run mmc_flash_image_rsa; then "\
545         "else "\
546                 "echo [flash_mmc] run mmc_flash_image_rsa "\
547                 "for Image2_rsa.img ** FAILED **;"\
548                 "exit;"\
549         "fi;"\
550         "if run mmc_flash_recovery; then "\
551         "else "\
552                 "echo [flash_mmc] run mmc_flash_recovery ** FAILED **;"\
553                 "exit;"\
554         "fi;"\
555         "if run mmc_flash_rootfs; then "\
556         "else "\
557                 "echo [flash_mmc] run mmc_flash_rootfs ** FAILED **;"\
558                 "exit;"\
559         "fi \0"
560
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 "\
565         "else "\
566                 "echo ${errstr} math add command ** FAILED **;"\
567                 "exit;"\
568         "fi;"\
569         "if math div fl_write_size fl_write_size 10000; then "\
570         "else "\
571                 "echo ${errstr} math div command ** FAILED **;"\
572                 "exit;"\
573         "fi;"\
574         "if math mul fl_write_size fl_write_size 10000; then "\
575         "else "\
576                 "echo ${errstr} math mul command ** FAILED **;"\
577                 "exit;"\
578         "fi \0"
579
580 #define QSPI_FLASH_FIP \
581         "flash_fip="\
582         "if run qspi_access_en; then "\
583         "else "\
584                 "echo [flash_fip] run qspi_access_en ** FAILED **;"\
585                 "exit;"\
586         "fi;"\
587         "if tftp ${loadaddr} ${tftp_dir}fip.bin; then "\
588         "else "\
589                 "echo [flash_fip] tftp ${tftp_dir}fip.bin "\
590                 "** FAILED **;"\
591                 "exit;"\
592         "fi;"\
593         "if math add tmpsize filesize FFFF; then "\
594         "else "\
595                 "echo [flash_fip] math add command ** FAILED **;"\
596                 "exit;"\
597         "fi;"\
598         "if math div tmpsize tmpsize 10000; then "\
599         "else "\
600                 "echo [flash_fip] math div command ** FAILED **;"\
601                 "exit;"\
602         "fi;"\
603         "if math mul tmpsize tmpsize 10000; then "\
604         "else "\
605                 "echo [flash_fip] math mul command ** FAILED **;"\
606                 "exit;"\
607         "fi;"\
608         "if sf probe 0; then "\
609         "else "\
610                 "echo [flash_fip] sf probe command ** FAILED **;"\
611                 "exit;"\
612         "fi;"\
613         "if sf erase ${fip_qspi_addr} ${tmpsize}; then "\
614         "else "\
615                 "echo [flash_fip] sf erase ${fip_qspi_addr} ** FAILED **;"\
616                 "exit;"\
617         "fi;"\
618         "if sf write ${loadaddr} ${fip_qspi_addr} ${filesize}; then "\
619         "else "\
620                 "echo [flash_fip] sf write ${fip_qspi_addr} ** FAILED **;"\
621                 "exit;"\
622         "fi;"\
623         /* Flash mirror FIP image */ \
624         "if sf erase ${fip_qspi_mirror_addr} ${tmpsize}; then "\
625         "else "\
626                 "echo [flash_fip] sf erase ${fip_qspi_mirror_addr} "\
627                         "** FAILED **;"\
628                 "exit;"\
629         "fi;"\
630         "if sf write ${loadaddr} ${fip_qspi_mirror_addr} ${filesize}; then "\
631         "else "\
632                 "echo [flash_fip] sf write ${fip_qspi_mirror_addr} "\
633                         "** FAILED **;"\
634                 "exit;"\
635         "fi \0"
636
637 #define QSPI_FLASH_NITRO \
638         "flash_nitro="\
639         "run func_qspi_probe; "\
640         "if tftp ${loadaddr} ${tftp_dir}${nitro_bin}; then "\
641         "else "\
642                 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bin} "\
643                 "** FAILED **;"\
644                 "exit;"\
645         "fi;"\
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 "\
650         "else "\
651                 "echo [flash_nitro] sf erase ${spi_nitro_img_bin_start} "\
652                 "** FAILED **;"\
653                 "exit;"\
654         "fi;"\
655         "if sf write ${loadaddr} ${spi_nitro_img_bin_start}" \
656                      " ${fl_write_size}; then "\
657         "else "\
658                 "echo [flash_nitro] sf write ${spi_nitro_bin_start} "\
659                 "** FAILED **;"\
660                 "exit;"\
661         "fi;"\
662         /* Mirror of Flash Nitro fw fit + configuration */ \
663         "if sf erase ${spi_nitro_img_bin_mirror_start} ${fl_write_size}; then "\
664         "else "\
665                 "echo [flash_nitro] sf erase "\
666                       "${spi_nitro_img_bin_mirror_start} "\
667                 "** FAILED **;"\
668                 "exit;"\
669         "fi;"\
670         "if sf write ${loadaddr} ${spi_nitro_img_bin_mirror_start}" \
671                      " ${fl_write_size}; then "\
672         "else "\
673                 "echo [flash_nitro] sf write "\
674                       "${spi_nitro_img_bin_mirror_start} "\
675                 "** FAILED **;"\
676                 "exit;"\
677         "fi \0"
678
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 "\
689                 "else "\
690                         "echo [flash_nitro] sf erase "\
691                                 "${spi_nitro_bspd_cfg_start} "\
692                                 "** FAILED **;"\
693                         "exit;"\
694                 "fi;"\
695                 "if sf write ${loadaddr} ${spi_nitro_bspd_cfg_start} "\
696                             "${fl_write_size}; then "\
697                 "else "\
698                         "echo [flash_nitro] sf write "\
699                                 "${spi_nitro_bspd_cfg_start} "\
700                                 "** FAILED **;"\
701                         "exit;"\
702                 "fi;" \
703                 /* Flash BSPD mirror configuration */ \
704                 "if sf erase ${spi_nitro_bspd_mirror_cfg_start} "\
705                             "${fl_write_size}; then "\
706                 "else "\
707                         "echo [flash_nitro] sf erase "\
708                                 "${spi_nitro_bspd_mirror_cfg_start} "\
709                                 "** FAILED **;"\
710                         "exit;"\
711                 "fi;"\
712                 "if sf write ${loadaddr} ${spi_nitro_bspd_mirror_cfg_start} "\
713                         "${fl_write_size}; then "\
714                 "else "\
715                         "echo [flash_nitro] sf write "\
716                                 "${spi_nitro_bspd_mirror_cfg_start} "\
717                                 "** FAILED **;"\
718                         "exit;"\
719                 "fi;" \
720         "else "\
721                 "echo [flash_nitro] tftp ${tftp_dir}${nitro_bspd_cfg} "\
722                 "** Skip flashing bspd config file **;"\
723         "fi \0"
724
725 #define QSPI_FLASH \
726         "flash_qspi="\
727         "if run qspi_access_en; then "\
728         "else "\
729                 "echo [flash_qspi] run qspi_access_en ** FAILED **;"\
730                 "exit;"\
731         "fi;"\
732         "if run flash_fip; then "\
733         "else "\
734                 "echo [flash_qspi] run flash_fip ** FAILED **;"\
735                 "exit;"\
736         "fi;"\
737         "if run flash_nitro; then "\
738         "else "\
739                 "echo [flash_qspi] run flash_nitro ** FAILED **;"\
740                 "exit;"\
741         "fi \0"
742
743 #define FLASH_IMAGES \
744         "flash_images=" \
745         "if run flash_qspi; then "\
746         "else "\
747                 "echo [flash_images] run flash_qspi ** FAILED **;"\
748                 "exit;"\
749         "fi;"\
750         "if run flash_mmc; then "\
751         "else "\
752                 "echo [flash_images] run flash_mmc ** FAILED **;"\
753                 "exit;"\
754         "fi \0"
755
756 #define ARCH_ENV_SETTINGS \
757         CONSOLE_ARGS \
758         MAX_CPUS \
759         OS_LOG_LEVEL \
760         EXTRA_ARGS \
761         PCIE_ARGS \
762         ETH_ADDR \
763         RESERVED_MEM \
764         SETBOOTARGS \
765         UPDATEME_FLASH_PARAMS \
766         KERNEL_LOADADDR_CFG\
767         INITRD_ARGS \
768         INITRD_LOADADDR \
769         INITRD_IMAGE \
770         MMC_DEV \
771         EXEC_STATE \
772         EXT4RD_ARGS \
773         WDT_CNTRL \
774         ELOG_SETUP \
775         FIT_MMC_PARTITION \
776         QSPI_FLASH_NITRO_PARAMS \
777         QSPI_ACCESS_ENABLE \
778         FUNC_QSPI_PROBE \
779         NITRO_FW_IMAGES \
780         FASTBOOT_NITRO_SETUP \
781         FASTBOOT_SETUP \
782         CHECK_CHIMP_HS \
783         FASTBOOT_NITRO \
784         FIT_IMAGE \
785         BOOTCMD_MMC_FIT \
786         BOOTCMD_MMC_FITS \
787         USBDEV \
788         BOOTCMD_USB \
789         START_PCI \
790         BNXT_LOAD \
791         BOOTCMD_PXE \
792         FLASH_PENDING_RFS_IMGS \
793         TFTP_QSPI_PARAM \
794         MMC_FLASH_FIT_GPT \
795         MMC_FLASH_IMAGE_RSA \
796         MMC_FLASH_RECOVERY \
797         MMC_FLASH_ROOTFS \
798         MMC_FLASH \
799         FUNC_ALIGN_QSPI_ERASE_BLOCK_SIZE \
800         QSPI_FLASH_FIP \
801         QSPI_FLASH_NITRO \
802         QSPI_FLASH_NITRO_BSPD_CONFIG \
803         QSPI_FLASH \
804         FLASH_IMAGES
805
806 #define CONFIG_EXTRA_ENV_SETTINGS \
807         ARCH_ENV_SETTINGS
808
809 #endif /* __BCM_NS3_H */