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