diff options
119 files changed, 665 insertions, 370 deletions
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig index 7edc06d202..546de33b72 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig @@ -469,6 +469,14 @@ config SYS_FSL_SDHC_CLK_DIV help This is the divider that is used to derive SDHC clock from Platform clock, in another word SDHC_clk = Platform_clk / this_divider. + +config SYS_FSL_QMAN_CLK_DIV + int "QMAN clock divider" + default 1 if ARCH_LS1043A + default 2 + help + This is the divider that is used to derive QMAN clock from Platform + clock, in another word QMAN_clk = Platform_clk / this_divider. endmenu config RESV_RAM diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c index 4afc046eea..fc9de73bce 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c @@ -414,8 +414,8 @@ void ft_cpu_setup(void *blob, bd_t *bd) ccsr_sec_t __iomem *sec; #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT - if (fdt_fixup_kaslr(blob)) - fdt_fixup_remove_jr(blob); + fdt_fixup_remove_jr(blob); + fdt_fixup_kaslr(blob); #endif sec = (void __iomem *)CONFIG_SYS_FSL_SEC_ADDR; diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c b/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c index 8386678c46..723d7eac5d 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c @@ -155,7 +155,9 @@ void get_sys_info(struct sys_info *sys_info) CONFIG_SYS_FSL_IFC_CLK_DIV; #endif #ifdef CONFIG_SYS_DPAA_QBMAN - sys_info->freq_qman = sys_info->freq_systembus; + sys_info->freq_qman = (sys_info->freq_systembus / + CONFIG_SYS_FSL_PCLK_DIV) / + CONFIG_SYS_FSL_QMAN_CLK_DIV; #endif } diff --git a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S index e9d373e464..ef3987ea84 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S +++ b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S @@ -233,39 +233,45 @@ ENTRY(lowlevel_init) * NOTE: As per the CCSR map doc, TZASC 3 and TZASC 4 are just * placeholders. */ -#ifdef CONFIG_FSL_TZASC_1 - ldr x1, =TZASC_GATE_KEEPER(0) - ldr w0, [x1] /* Filter 0 Gate Keeper Register */ - orr w0, w0, #1 << 0 /* Set open_request for Filter 0 */ - str w0, [x1] - ldr x1, =TZASC_REGION_ATTRIBUTES_0(0) - ldr w0, [x1] /* Region-0 Attributes Register */ - orr w0, w0, #1 << 31 /* Set Sec global write en, Bit[31] */ - orr w0, w0, #1 << 30 /* Set Sec global read en, Bit[30] */ - str w0, [x1] +.macro tzasc_prog, xreg + + mov x12, TZASC1_BASE + mov x16, #0x10000 + mul x14, \xreg, x16 + add x14, x14,x12 + mov x1, #0x8 + add x1, x1, x14 + + ldr w0, [x1] /* Filter 0 Gate Keeper Register */ + orr w0, w0, #1 << 0 /* Set open_request for Filter 0 */ + str w0, [x1] + + mov x1, #0x110 + add x1, x1, x14 + + ldr w0, [x1] /* Region-0 Attributes Register */ + orr w0, w0, #1 << 31 /* Set Sec global write en, Bit[31] */ + orr w0, w0, #1 << 30 /* Set Sec global read en, Bit[30] */ + str w0, [x1] + + mov x1, #0x114 + add x1, x1, x14 + + ldr w0, [x1] /* Region-0 Access Register */ + mov w0, #0xFFFFFFFF /* Set nsaid_wr_en and nsaid_rd_en */ + str w0, [x1] +.endm + +#ifdef CONFIG_FSL_TZASC_1 + mov x13, #0 + tzasc_prog x13 - ldr x1, =TZASC_REGION_ID_ACCESS_0(0) - ldr w0, [x1] /* Region-0 Access Register */ - mov w0, #0xFFFFFFFF /* Set nsaid_wr_en and nsaid_rd_en */ - str w0, [x1] #endif #ifdef CONFIG_FSL_TZASC_2 - ldr x1, =TZASC_GATE_KEEPER(1) - ldr w0, [x1] /* Filter 0 Gate Keeper Register */ - orr w0, w0, #1 << 0 /* Set open_request for Filter 0 */ - str w0, [x1] - - ldr x1, =TZASC_REGION_ATTRIBUTES_0(1) - ldr w0, [x1] /* Region-1 Attributes Register */ - orr w0, w0, #1 << 31 /* Set Sec global write en, Bit[31] */ - orr w0, w0, #1 << 30 /* Set Sec global read en, Bit[30] */ - str w0, [x1] + mov x13, #1 + tzasc_prog x13 - ldr x1, =TZASC_REGION_ID_ACCESS_0(1) - ldr w0, [x1] /* Region-1 Attributes Register */ - mov w0, #0xFFFFFFFF /* Set nsaid_wr_en and nsaid_rd_en */ - str w0, [x1] #endif isb dsb sy diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c index 06fdd17604..bfd663942a 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c @@ -517,6 +517,7 @@ static void erratum_a010539(void) porsr1 &= ~FSL_CHASSIS2_CCSR_PORSR1_RCW_MASK; out_be32((void *)(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_PORCR1), porsr1); + out_be32((void *)(CONFIG_SYS_FSL_SCFG_ADDR + 0x1a8), 0xffffffff); #endif } diff --git a/arch/arm/cpu/armv8/sec_firmware.c b/arch/arm/cpu/armv8/sec_firmware.c index 6a04eaca3e..a13c92e246 100644 --- a/arch/arm/cpu/armv8/sec_firmware.c +++ b/arch/arm/cpu/armv8/sec_firmware.c @@ -115,25 +115,48 @@ static int sec_firmware_check_copy_loadable(const void *sec_firmware_img, u32 *loadable_l, u32 *loadable_h) { phys_addr_t sec_firmware_loadable_addr = 0; - int conf_node_off, ld_node_off; + int conf_node_off, ld_node_off, images; char *conf_node_name = NULL; const void *data; size_t size; ulong load; + const char *name, *str, *type; + int len; conf_node_name = SEC_FIRMEWARE_FIT_CNF_NAME; conf_node_off = fit_conf_get_node(sec_firmware_img, conf_node_name); if (conf_node_off < 0) { printf("SEC Firmware: %s: no such config\n", conf_node_name); - return -ENOENT; + return -ENOENT; + } + + /* find the node holding the images information */ + images = fdt_path_offset(sec_firmware_img, FIT_IMAGES_PATH); + if (images < 0) { + printf("%s: Cannot find /images node: %d\n", __func__, images); + return -1; + } + + type = FIT_LOADABLE_PROP; + + name = fdt_getprop(sec_firmware_img, conf_node_off, type, &len); + if (!name) { + /* Loadables not present */ + return 0; } - ld_node_off = fit_conf_get_prop_node(sec_firmware_img, conf_node_off, - FIT_LOADABLE_PROP); - if (ld_node_off >= 0) { - printf("SEC Firmware: '%s' present in config\n", - FIT_LOADABLE_PROP); + printf("SEC Firmware: '%s' present in config\n", type); + + for (str = name; str && ((str - name) < len); + str = strchr(str, '\0') + 1) { + printf("%s: '%s'\n", type, str); + ld_node_off = fdt_subnode_offset(sec_firmware_img, images, str); + if (ld_node_off < 0) { + printf("cannot find image node '%s': %d\n", str, + ld_node_off); + return -EINVAL; + } /* Verify secure firmware image */ if (!(fit_image_verify(sec_firmware_img, ld_node_off))) { @@ -163,11 +186,19 @@ static int sec_firmware_check_copy_loadable(const void *sec_firmware_img, memcpy((void *)sec_firmware_loadable_addr, data, size); flush_dcache_range(sec_firmware_loadable_addr, sec_firmware_loadable_addr + size); - } - /* Populate address ptrs for loadable image with loadbale addr */ - out_le32(loadable_l, (sec_firmware_loadable_addr & WORD_MASK)); - out_le32(loadable_h, (sec_firmware_loadable_addr >> WORD_SHIFT)); + /* Populate loadable address only for Trusted OS */ + if (!strcmp(str, "trustedOS@1")) { + /* + * Populate address ptrs for loadable image with + * loadbale addr + */ + out_le32(loadable_l, (sec_firmware_loadable_addr & + WORD_MASK)); + out_le32(loadable_h, (sec_firmware_loadable_addr >> + WORD_SHIFT)); + } + } return 0; } @@ -317,9 +348,7 @@ unsigned int sec_firmware_support_psci_version(void) */ bool sec_firmware_support_hwrng(void) { - uint8_t rand[8]; if (sec_firmware_addr & SEC_FIRMWARE_RUNNING) { - if (!sec_firmware_get_random(rand, 8)) return true; } @@ -428,8 +457,10 @@ int fdt_fixup_kaslr(void *fdt) #if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) /* Check if random seed generation is supported */ - if (sec_firmware_support_hwrng() == false) + if (sec_firmware_support_hwrng() == false) { + printf("WARNING: SEC firmware not running, no kaslr-seed\n"); return 0; + } ret = sec_firmware_get_random(rand, 8); if (ret < 0) { diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index b27266c7a1..c3c1d2fdfa 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -437,7 +437,7 @@ void boot_prep_vxworks(bootm_headers_t *images) if (images->ft_addr) { off = fdt_path_offset(images->ft_addr, "/memory"); - if (off < 0) { + if (off > 0) { if (arch_fixup_fdt(images->ft_addr)) puts("## WARNING: fixup memory failed!\n"); } diff --git a/arch/arm/mach-rmobile/include/mach/ehci-rmobile.h b/arch/arm/mach-rmobile/include/mach/ehci-rmobile.h index 463654efd3..ca8c5f3706 100644 --- a/arch/arm/mach-rmobile/include/mach/ehci-rmobile.h +++ b/arch/arm/mach-rmobile/include/mach/ehci-rmobile.h @@ -1,8 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2013,2014 Renesas Electronics Corporation * Copyright (C) 2014 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> - * - * SPDX-License-Identifier: GPL-2.0 */ #ifndef __EHCI_RMOBILE_H__ diff --git a/arch/arm/mach-socfpga/include/mach/boot0.h b/arch/arm/mach-socfpga/include/mach/boot0.h index 60194231c7..c78def5066 100644 --- a/arch/arm/mach-socfpga/include/mach/boot0.h +++ b/arch/arm/mach-socfpga/include/mach/boot0.h @@ -17,8 +17,8 @@ _start: .word 0xcafec0d3; /* Checksum, zero-pad */ nop; - b reset; /* SoCFPGA jumps here */ - nop; + b reset; /* SoCFPGA Gen5 jumps here */ + b reset; /* SoCFPGA Gen10 trampoline */ nop; nop; #endif diff --git a/arch/arm/mach-socfpga/qts-filter.sh b/arch/arm/mach-socfpga/qts-filter.sh index 02c28be2b7..3a442bc5d8 100755 --- a/arch/arm/mach-socfpga/qts-filter.sh +++ b/arch/arm/mach-socfpga/qts-filter.sh @@ -145,10 +145,10 @@ process_sdram_config() { ( cat << EOF +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Altera SoCFPGA SDRAM configuration * - * SPDX-License-Identifier: BSD-3-Clause */ #ifndef __SOCFPGA_SDRAM_CONFIG_H__ diff --git a/arch/arm/thumb1/include/asm/proc-armv/system.h b/arch/arm/thumb1/include/asm/proc-armv/system.h index 7dfbf3d33d..1324f7efb1 100644 --- a/arch/arm/thumb1/include/asm/proc-armv/system.h +++ b/arch/arm/thumb1/include/asm/proc-armv/system.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Thumb-1 drop-in for the linux/include/asm-arm/proc-armv/system.h * @@ -7,8 +8,6 @@ * The original file does not build in Thumb mode. However, in U-Boot * we don't use interrupt context, so we can redefine these as empty * memory barriers, which makes Thumb-1 compiler happy. - * - * SPDX-License-Identifier: GPL-2.0+ */ /* diff --git a/arch/powerpc/cpu/mpc85xx/release.S b/arch/powerpc/cpu/mpc85xx/release.S index 5d212f35b5..d37e1ccf1e 100644 --- a/arch/powerpc/cpu/mpc85xx/release.S +++ b/arch/powerpc/cpu/mpc85xx/release.S @@ -26,6 +26,13 @@ .globl __secondary_start_page .align 12 __secondary_start_page: +#ifdef CONFIG_SYS_FSL_ERRATUM_A005125 + msync + isync + mfspr r3, SPRN_HDBCR0 + oris r3, r3, 0x0080 + mtspr SPRN_HDBCR0, r3 +#endif /* First do some preliminary setup */ lis r3, HID0_EMCP@h /* enable machine check */ #ifndef CONFIG_E500MC diff --git a/board/freescale/ls1088a/ddr.h b/board/freescale/ls1088a/ddr.h index 764ed7945b..b35c4ae2da 100644 --- a/board/freescale/ls1088a/ddr.h +++ b/board/freescale/ls1088a/ddr.h @@ -30,12 +30,12 @@ static const struct board_specific_parameters udimm0[] = { #if defined(CONFIG_TARGET_LS1088ARDB) {2, 1666, 0, 8, 8, 0x090A0B0E, 0x0F10110D,}, - {2, 1900, 0, 4, 7, 0x09090B0D, 0x0E10120B,}, + {2, 1900, 0, 8, 9, 0x0A0B0C10, 0x1112140E,}, {2, 2300, 0, 8, 9, 0x0A0C0E11, 0x1214160F,}, {} #elif defined(CONFIG_TARGET_LS1088AQDS) {2, 1666, 0, 8, 8, 0x0A0A0C0E, 0x0F10110C,}, - {2, 1900, 0, 4, 7, 0x09090B0D, 0x0E10120B,}, + {2, 1900, 0, 8, 9, 0x0A0B0C10, 0x1112140E,}, {2, 2300, 0, 4, 9, 0x0A0C0D11, 0x1214150E,}, {} diff --git a/board/freescale/ls1088a/eth_ls1088aqds.c b/board/freescale/ls1088a/eth_ls1088aqds.c index 9907fd2a33..40b1a0e631 100644 --- a/board/freescale/ls1088a/eth_ls1088aqds.c +++ b/board/freescale/ls1088a/eth_ls1088aqds.c @@ -4,12 +4,14 @@ */ #include <common.h> +#include <command.h> #include <netdev.h> #include <asm/io.h> #include <asm/arch/fsl_serdes.h> #include <hwconfig.h> #include <fsl_mdio.h> #include <malloc.h> +#include <phy.h> #include <fm_eth.h> #include <i2c.h> #include <miiphy.h> diff --git a/board/freescale/ls2080aqds/MAINTAINERS b/board/freescale/ls2080aqds/MAINTAINERS index 62c8fac09c..f7f1f09513 100644 --- a/board/freescale/ls2080aqds/MAINTAINERS +++ b/board/freescale/ls2080aqds/MAINTAINERS @@ -10,6 +10,6 @@ F: configs/ls2080aqds_qspi_defconfig F: configs/ls2080aqds_sdcard_defconfig LS2080A_SECURE_BOOT BOARD -M: Saksham Jain <saksham.jain@nxp.freescale.com> -S: Maintained +#M: Saksham Jain <saksham.jain@nxp.freescale.com> +S: Orphan (since 2018-05) F: configs/ls2080aqds_SECURE_BOOT_defconfig diff --git a/board/freescale/ls2080ardb/MAINTAINERS b/board/freescale/ls2080ardb/MAINTAINERS index 8da1c6d0ae..bbe56e2052 100644 --- a/board/freescale/ls2080ardb/MAINTAINERS +++ b/board/freescale/ls2080ardb/MAINTAINERS @@ -18,8 +18,8 @@ S: Maintained F: configs/ls2081ardb_defconfig LS2080A_SECURE_BOOT BOARD -M: Saksham Jain <saksham.jain@nxp.freescale.com> -S: Maintained +#M: Saksham Jain <saksham.jain@nxp.freescale.com> +S: Orphan (since 2018-05) F: configs/ls2080ardb_SECURE_BOOT_defconfig LS2088A_QSPI_SECURE_BOOT BOARD diff --git a/board/freescale/mpc8315erdb/MAINTAINERS b/board/freescale/mpc8315erdb/MAINTAINERS index 938c1527e0..5a67b40993 100644 --- a/board/freescale/mpc8315erdb/MAINTAINERS +++ b/board/freescale/mpc8315erdb/MAINTAINERS @@ -1,6 +1,6 @@ MPC8315ERDB BOARD -M: Dave Liu <daveliu@freescale.com> -S: Maintained +#M: Dave Liu <daveliu@freescale.com> +S: Orphan (since 2018-05) F: board/freescale/mpc8315erdb/ F: include/configs/MPC8315ERDB.h F: configs/MPC8315ERDB_defconfig diff --git a/board/freescale/mpc8323erdb/MAINTAINERS b/board/freescale/mpc8323erdb/MAINTAINERS index 05057c0c2d..496ab2af27 100644 --- a/board/freescale/mpc8323erdb/MAINTAINERS +++ b/board/freescale/mpc8323erdb/MAINTAINERS @@ -1,6 +1,6 @@ MPC8323ERDB BOARD -M: Michael Barkowski <michael.barkowski@freescale.com> -S: Maintained +#M: Michael Barkowski <michael.barkowski@freescale.com> +S: Orphan (since 2018-05) F: board/freescale/mpc8323erdb/ F: include/configs/MPC8323ERDB.h F: configs/MPC8323ERDB_defconfig diff --git a/board/freescale/mpc832xemds/MAINTAINERS b/board/freescale/mpc832xemds/MAINTAINERS index 56d70733b4..232658a203 100644 --- a/board/freescale/mpc832xemds/MAINTAINERS +++ b/board/freescale/mpc832xemds/MAINTAINERS @@ -1,6 +1,6 @@ MPC832XEMDS BOARD -M: Dave Liu <daveliu@freescale.com> -S: Maintained +#M: Dave Liu <daveliu@freescale.com> +S: Orphan (since 2018-05) F: board/freescale/mpc832xemds/ F: include/configs/MPC832XEMDS.h F: configs/MPC832XEMDS_defconfig diff --git a/board/freescale/mpc8349emds/MAINTAINERS b/board/freescale/mpc8349emds/MAINTAINERS index 141e77a94e..e6648d66a0 100644 --- a/board/freescale/mpc8349emds/MAINTAINERS +++ b/board/freescale/mpc8349emds/MAINTAINERS @@ -1,6 +1,6 @@ MPC8349EMDS BOARD -M: Kim Phillips <kim.phillips@freescale.com> -S: Maintained +#M: Kim Phillips <kim.phillips@freescale.com> +S: Orphan (since 2018-05) F: board/freescale/mpc8349emds/ F: include/configs/MPC8349EMDS.h F: configs/MPC8349EMDS_defconfig diff --git a/board/freescale/mpc837xemds/MAINTAINERS b/board/freescale/mpc837xemds/MAINTAINERS index 6ff1346206..8386aa7297 100644 --- a/board/freescale/mpc837xemds/MAINTAINERS +++ b/board/freescale/mpc837xemds/MAINTAINERS @@ -1,6 +1,6 @@ MPC837XEMDS BOARD -M: Dave Liu <daveliu@freescale.com> -S: Maintained +#M: Dave Liu <daveliu@freescale.com> +S: Orphan (since 2018-05) F: board/freescale/mpc837xemds/ F: include/configs/MPC837XEMDS.h F: configs/MPC837XEMDS_defconfig diff --git a/board/freescale/p1022ds/MAINTAINERS b/board/freescale/p1022ds/MAINTAINERS index 86aac365d3..62256c3703 100644 --- a/board/freescale/p1022ds/MAINTAINERS +++ b/board/freescale/p1022ds/MAINTAINERS @@ -1,5 +1,5 @@ P1022DS BOARD -M: Timur Tabi <timur@freescale.com> +M: Timur Tabi <timur@tabi.org> S: Maintained F: board/freescale/p1022ds/ F: include/configs/P1022DS.h diff --git a/board/freescale/t102xqds/MAINTAINERS b/board/freescale/t102xqds/MAINTAINERS index 23480e2d71..7e30e5f84b 100644 --- a/board/freescale/t102xqds/MAINTAINERS +++ b/board/freescale/t102xqds/MAINTAINERS @@ -1,6 +1,6 @@ T102XQDS BOARD -M: Shengzhou Liu <Shengzhou.Liu@freescale.com> -S: Maintained +#M: Shengzhou Liu <Shengzhou.Liu@freescale.com> +S: Orphan (since 2018-05) F: board/freescale/t102xqds/ F: include/configs/T102xQDS.h F: configs/T1024QDS_defconfig diff --git a/board/freescale/t102xrdb/MAINTAINERS b/board/freescale/t102xrdb/MAINTAINERS index 297e63a6ee..6c24f7785c 100644 --- a/board/freescale/t102xrdb/MAINTAINERS +++ b/board/freescale/t102xrdb/MAINTAINERS @@ -1,6 +1,6 @@ T102XRDB BOARD -M: Shengzhou Liu <Shengzhou.Liu@freescale.com> -S: Maintained +#M: Shengzhou Liu <Shengzhou.Liu@freescale.com> +S: Orphan (since 2018-05) F: board/freescale/t102xrdb/ F: include/configs/T102xRDB.h F: configs/T1024RDB_defconfig diff --git a/board/freescale/t4qds/MAINTAINERS b/board/freescale/t4qds/MAINTAINERS index b288571c7a..44bb2f5c6d 100644 --- a/board/freescale/t4qds/MAINTAINERS +++ b/board/freescale/t4qds/MAINTAINERS @@ -1,6 +1,6 @@ T4QDS BOARD -M: Shaohui Xie <Shaohui.Xie@freescale.com> -S: Maintained +#M: Shaohui Xie <Shaohui.Xie@freescale.com> +S: Orphan (since 2018-05) F: board/freescale/t4qds/ F: include/configs/T4240QDS.h F: configs/T4160QDS_defconfig diff --git a/board/freescale/t4rdb/MAINTAINERS b/board/freescale/t4rdb/MAINTAINERS index 53ccabc0fb..4ba5c3a546 100644 --- a/board/freescale/t4rdb/MAINTAINERS +++ b/board/freescale/t4rdb/MAINTAINERS @@ -1,6 +1,6 @@ T4RDB BOARD -M: Chunhe Lan <Chunhe.Lan@freescale.com> -S: Maintained +#M: Chunhe Lan <Chunhe.Lan@freescale.com> +S: Orphan (since 2018-05) F: board/freescale/t4rdb/ F: include/configs/T4240RDB.h F: configs/T4160RDB_defconfig diff --git a/board/liebherr/display5/spl.c b/board/liebherr/display5/spl.c index 49bcafef74..6508e0ffa7 100644 --- a/board/liebherr/display5/spl.c +++ b/board/liebherr/display5/spl.c @@ -19,6 +19,7 @@ #include <environment.h> #include <fsl_esdhc.h> #include <netdev.h> +#include <bootcount.h> #include "common.h" DECLARE_GLOBAL_DATA_PTR; @@ -213,7 +214,7 @@ void board_boot_order(u32 *spl_boot_list) env_load(); s = env_get("BOOT_FROM"); - if (s && strcmp(s, "ACTIVE") == 0) { + if (s && !bootcount_error() && strcmp(s, "ACTIVE") == 0) { spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = spl_boot_device(); } diff --git a/board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c b/board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c index 3bd02f3c83..500dcce4da 100644 --- a/board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c +++ b/board/opalkelly/zynq/zynq-syzygy-hub/ps7_init_gpl.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /****************************************************************************** * (c) Copyright 2010-2014 Xilinx, Inc. All rights reserved. * (c) Copyright 2017 Opal Kelly Inc. -* -* SPDX-License-Identifier: GPL-2.0+ *****************************************************************************/ #include <asm/arch/ps7_init_gpl.h> diff --git a/board/xilinx/zynq/zynq-microzed/ps7_init_gpl.c b/board/xilinx/zynq/zynq-microzed/ps7_init_gpl.c index 5cf627d223..39afd82195 100644 --- a/board/xilinx/zynq/zynq-microzed/ps7_init_gpl.c +++ b/board/xilinx/zynq/zynq-microzed/ps7_init_gpl.c @@ -1,9 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /****************************************************************************** * (c) Copyright 2010-2014 Xilinx, Inc. All rights reserved. -* -* SPDX-License-Identifier: GPL-2.0+ -* -* ******************************************************************************/ /****************************************************************************/ /** diff --git a/board/xilinx/zynq/zynq-zc702/ps7_init_gpl.c b/board/xilinx/zynq/zynq-zc702/ps7_init_gpl.c index fc325a6b02..88ff7947f2 100644 --- a/board/xilinx/zynq/zynq-zc702/ps7_init_gpl.c +++ b/board/xilinx/zynq/zynq-zc702/ps7_init_gpl.c @@ -1,9 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /****************************************************************************** * (c) Copyright 2010-2014 Xilinx, Inc. All rights reserved. -* -* SPDX-License-Identifier: GPL-2.0+ -* -* ******************************************************************************/ /****************************************************************************/ /** diff --git a/board/xilinx/zynq/zynq-zc706/ps7_init_gpl.c b/board/xilinx/zynq/zynq-zc706/ps7_init_gpl.c index ca5490f0b0..e9e4e4d077 100644 --- a/board/xilinx/zynq/zynq-zc706/ps7_init_gpl.c +++ b/board/xilinx/zynq/zynq-zc706/ps7_init_gpl.c @@ -1,9 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /****************************************************************************** * (c) Copyright 2010-2014 Xilinx, Inc. All rights reserved. -* -* SPDX-License-Identifier: GPL-2.0+ -* -* ******************************************************************************/ /****************************************************************************/ /** diff --git a/board/xilinx/zynq/zynq-zed/ps7_init_gpl.c b/board/xilinx/zynq/zynq-zed/ps7_init_gpl.c index 54c803cfa6..df7d3535dd 100644 --- a/board/xilinx/zynq/zynq-zed/ps7_init_gpl.c +++ b/board/xilinx/zynq/zynq-zed/ps7_init_gpl.c @@ -1,9 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /****************************************************************************** * (c) Copyright 2010-2014 Xilinx, Inc. All rights reserved. -* -* SPDX-License-Identifier: GPL-2.0+ -* -* ******************************************************************************/ /****************************************************************************/ /** diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 5498a5fccf..11b84c5528 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI application loader * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <charset.h> diff --git a/common/autoboot.c b/common/autoboot.c index 9b9fb534f0..94133eaeda 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -13,6 +13,7 @@ #include <menu.h> #include <post.h> #include <u-boot/sha256.h> +#include <bootcount.h> DECLARE_GLOBAL_DATA_PTR; @@ -290,18 +291,8 @@ const char *bootdelay_process(void) { char *s; int bootdelay; -#ifdef CONFIG_BOOTCOUNT_LIMIT - unsigned long bootcount = 0; - unsigned long bootlimit = 0; -#endif /* CONFIG_BOOTCOUNT_LIMIT */ - -#ifdef CONFIG_BOOTCOUNT_LIMIT - bootcount = bootcount_load(); - bootcount++; - bootcount_store(bootcount); - env_set_ulong("bootcount", bootcount); - bootlimit = env_get_ulong("bootlimit", 10, 0); -#endif /* CONFIG_BOOTCOUNT_LIMIT */ + + bootcount_inc(); s = env_get("bootdelay"); bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY; @@ -323,13 +314,9 @@ const char *bootdelay_process(void) s = env_get("failbootcmd"); } else #endif /* CONFIG_POST */ -#ifdef CONFIG_BOOTCOUNT_LIMIT - if (bootlimit && (bootcount > bootlimit)) { - printf("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n", - (unsigned)bootlimit); + if (bootcount_error()) s = env_get("altbootcmd"); - } else -#endif /* CONFIG_BOOTCOUNT_LIMIT */ + else s = env_get("bootcmd"); process_fdt_options(gd->fdt_blob); diff --git a/common/image.c b/common/image.c index 87d15010c0..214ac33720 100644 --- a/common/image.c +++ b/common/image.c @@ -145,7 +145,8 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_PBLIMAGE, "pblimage", "Freescale PBL Boot Image",}, { IH_TYPE_RAMDISK, "ramdisk", "RAMDisk Image", }, { IH_TYPE_SCRIPT, "script", "Script", }, - { IH_TYPE_SOCFPGAIMAGE, "socfpgaimage", "Altera SOCFPGA preloader",}, + { IH_TYPE_SOCFPGAIMAGE, "socfpgaimage", "Altera SoCFPGA CV/AV preloader",}, + { IH_TYPE_SOCFPGAIMAGE_V1, "socfpgaimage_v1", "Altera SoCFPGA A10 preloader",}, { IH_TYPE_STANDALONE, "standalone", "Standalone Program", }, { IH_TYPE_UBLIMAGE, "ublimage", "Davinci UBL image",}, { IH_TYPE_MXSIMAGE, "mxsimage", "Freescale MXS Boot Image",}, diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 259f96607e..431710a93b 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -54,6 +54,15 @@ config SPL_BOOTROM_SUPPORT BOOT_DEVICE_BOOTROM (or fall-through to the next boot device in the boot device list, if not implemented for a given board) +config SPL_BOOTCOUNT_LIMIT + bool "Support bootcount in SPL" + depends on SPL_ENV_SUPPORT + help + On some boards, which use 'falcon' mode, it is necessary to check + and increment the number of boot attempts. Such boards do not + use proper U-Boot for normal boot flow and hence needs those + adjustments to be done in the SPL. + config SPL_RAW_IMAGE_SUPPORT bool "Support SPL loading and booting of RAW images" default n if (ARCH_MX6 && (SPL_MMC_SUPPORT || SPL_SATA_SUPPORT)) diff --git a/common/spl/spl.c b/common/spl/spl.c index 3dafeaed3a..6606417ff7 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -19,6 +19,7 @@ #include <dm/root.h> #include <linux/compiler.h> #include <fdt_support.h> +#include <bootcount.h> DECLARE_GLOBAL_DATA_PTR; @@ -416,6 +417,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) spl_board_init(); #endif + bootcount_inc(); + memset(&spl_image, '\0', sizeof(spl_image)); #ifdef CONFIG_SYS_SPL_ARGS_ADDR spl_image.arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR; diff --git a/common/xyzModem.c b/common/xyzModem.c index a126e32ed3..830fca8387 100644 --- a/common/xyzModem.c +++ b/common/xyzModem.c @@ -171,7 +171,7 @@ parse_num (char *s, unsigned long *val, char **es, char *delim) } -#ifdef DEBUG +#if defined(DEBUG) && !defined(CONFIG_USE_TINY_PRINTF) /* * Note: this debug setup works by storing the strings in a fixed buffer */ @@ -180,15 +180,16 @@ static char *zm_out = zm_debug_buf; static char *zm_out_start = zm_debug_buf; static int -zm_dprintf (char *fmt, ...) +zm_dprintf(char *fmt, ...) { - int len; - va_list args; - - va_start (args, fmt); - len = diag_vsprintf (zm_out, fmt, args); - zm_out += len; - return len; + int len; + va_list args; + + va_start(args, fmt); + len = diag_vsprintf(zm_out, fmt, args); + va_end(args); + zm_out += len; + return len; } static void diff --git a/configs/display5_defconfig b/configs/display5_defconfig index e52f4e00af..db8212ca7c 100644 --- a/configs/display5_defconfig +++ b/configs/display5_defconfig @@ -16,6 +16,7 @@ CONFIG_SPL_LOAD_FIT=y CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6Q" CONFIG_SUPPORT_RAW_INITRD=y +CONFIG_SPL_BOOTCOUNT_LIMIT=y # CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR is not set CONFIG_SPL_DMA_SUPPORT=y CONFIG_SPL_ENV_SUPPORT=y @@ -53,6 +54,9 @@ CONFIG_EFI_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_FSL_ESDHC=y +CONFIG_BOOTCOUNT_LIMIT=y +CONFIG_SYS_BOOTCOUNT_SINGLEWORD=y +CONFIG_SYS_BOOTCOUNT_ADDR=0x020CC068 CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y CONFIG_SPI_FLASH_SPANSION=y diff --git a/configs/ls1088aqds_defconfig b/configs/ls1088aqds_defconfig index f20dc3e0e5..05dc2ac446 100644 --- a/configs/ls1088aqds_defconfig +++ b/configs/ls1088aqds_defconfig @@ -8,9 +8,12 @@ CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y CONFIG_OF_STDOUT_VIA_ALIAS=y CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4" +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 ramdisk_size=0x3000000 default_hugepagesz=2m hugepagesz=2m hugepages=256" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_HUSH_PARSER=y +CONFIG_CMD_GREPENV=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y diff --git a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig index be3e0981d8..20376be2d1 100644 --- a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig +++ b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig @@ -11,9 +11,12 @@ CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y CONFIG_OF_STDOUT_VIA_ALIAS=y CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT" +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 ramdisk_size=0x3000000 default_hugepagesz=2m hugepagesz=2m hugepages=256" # CONFIG_USE_BOOTCOMMAND is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_CMD_GREPENV=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y diff --git a/configs/ls1088aqds_qspi_defconfig b/configs/ls1088aqds_qspi_defconfig index cea6ca987b..cf2b4e3aba 100644 --- a/configs/ls1088aqds_qspi_defconfig +++ b/configs/ls1088aqds_qspi_defconfig @@ -10,9 +10,12 @@ CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y CONFIG_OF_STDOUT_VIA_ALIAS=y CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT" +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 ramdisk_size=0x3000000 default_hugepagesz=2m hugepagesz=2m hugepages=256" # CONFIG_USE_BOOTCOMMAND is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_CMD_GREPENV=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y diff --git a/configs/ls1088aqds_sdcard_ifc_defconfig b/configs/ls1088aqds_sdcard_ifc_defconfig index 76ee1204bc..39fa3d716f 100644 --- a/configs/ls1088aqds_sdcard_ifc_defconfig +++ b/configs/ls1088aqds_sdcard_ifc_defconfig @@ -13,6 +13,8 @@ CONFIG_DEFAULT_DEVICE_TREE="fsl-ls1088a-qds" CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4" CONFIG_SD_BOOT=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 ramdisk_size=0x3000000 default_hugepagesz=2m hugepagesz=2m hugepages=256" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y @@ -21,6 +23,7 @@ CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y CONFIG_HUSH_PARSER=y +CONFIG_CMD_GREPENV=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y diff --git a/configs/ls1088aqds_sdcard_qspi_defconfig b/configs/ls1088aqds_sdcard_qspi_defconfig index ddb1e04556..8d854da3dd 100644 --- a/configs/ls1088aqds_sdcard_qspi_defconfig +++ b/configs/ls1088aqds_sdcard_qspi_defconfig @@ -15,6 +15,8 @@ CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="SD_BOOT_QSPI" CONFIG_SD_BOOT=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 ramdisk_size=0x3000000 default_hugepagesz=2m hugepagesz=2m hugepages=256" # CONFIG_USE_BOOTCOMMAND is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y @@ -23,6 +25,7 @@ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x8b0 CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y +CONFIG_CMD_GREPENV=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y diff --git a/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig b/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig index 23e064b9e4..db95289733 100644 --- a/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig +++ b/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig @@ -11,9 +11,12 @@ CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y CONFIG_OF_STDOUT_VIA_ALIAS=y CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT" +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 ramdisk_size=0x3000000 default_hugepagesz=2m hugepagesz=2m hugepages=256" # CONFIG_USE_BOOTCOMMAND is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_CMD_GREPENV=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y diff --git a/configs/ls1088ardb_qspi_defconfig b/configs/ls1088ardb_qspi_defconfig index b05d50ade6..fbb75df7a3 100644 --- a/configs/ls1088ardb_qspi_defconfig +++ b/configs/ls1088ardb_qspi_defconfig @@ -10,9 +10,12 @@ CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y CONFIG_OF_STDOUT_VIA_ALIAS=y CONFIG_SYS_EXTRA_OPTIONS="SYS_FSL_DDR4, QSPI_BOOT" +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 ramdisk_size=0x3000000 default_hugepagesz=2m hugepagesz=2m hugepages=256" # CONFIG_USE_BOOTCOMMAND is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_CMD_GREPENV=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y diff --git a/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig b/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig index 43472ac2a1..17791b07eb 100644 --- a/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig +++ b/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig @@ -16,6 +16,8 @@ CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="SD_BOOT_QSPI" CONFIG_SD_BOOT=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 ramdisk_size=0x3000000 default_hugepagesz=2m hugepagesz=2m hugepages=256" # CONFIG_USE_BOOTCOMMAND is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y @@ -26,6 +28,7 @@ CONFIG_SPL_HASH_SUPPORT=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y +CONFIG_CMD_GREPENV=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y diff --git a/configs/ls1088ardb_sdcard_qspi_defconfig b/configs/ls1088ardb_sdcard_qspi_defconfig index 91fae2cd6a..26966aa7a9 100644 --- a/configs/ls1088ardb_sdcard_qspi_defconfig +++ b/configs/ls1088ardb_sdcard_qspi_defconfig @@ -15,6 +15,8 @@ CONFIG_FIT_VERBOSE=y CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="SD_BOOT_QSPI" CONFIG_SD_BOOT=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 ramdisk_size=0x3000000 default_hugepagesz=2m hugepagesz=2m hugepages=256" # CONFIG_USE_BOOTCOMMAND is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y @@ -23,6 +25,7 @@ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x8b0 CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y +CONFIG_CMD_GREPENV=y CONFIG_CMD_MEMTEST=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y diff --git a/doc/README.uefi b/doc/README.uefi index bb89b7ac2f..196e99994a 100644 --- a/doc/README.uefi +++ b/doc/README.uefi @@ -1,7 +1,7 @@ <!-- - Copyright (c) 2018 Heinrich Schuchardt +SPDX-License-Identifier: GPL-2.0+ - SPDX-License-Identifier: GPL-2.0+ +Copyright (c) 2018 Heinrich Schuchardt --> # UEFI on U-Boot diff --git a/doc/uImage.FIT/sec_firmware_ppa.its b/doc/uImage.FIT/sec_firmware_ppa.its new file mode 100644 index 0000000000..a7acde17cf --- /dev/null +++ b/doc/uImage.FIT/sec_firmware_ppa.its @@ -0,0 +1,49 @@ +/dts-v1/; + +/* + * Example FIT image description file demonstrating the usage + * of SEC Firmware and multiple loadable images loaded by the u-boot. + * For booting PPA (SEC Firmware), "firmware" is searched and loaded. + * + * Multiple binaries will be loaded as "loadables" (if present) at their + * respective load offsets from firmware image address. + */ + +/{ + description = "PPA Firmware"; + #address-cells = <1>; + images { + firmware@1 { + description = "PPA Firmware: <version>"; + data = /incbin/("../obj/monitor.bin"); + type = "firmware"; + arch = "arm64"; + compression = "none"; + }; + trustedOS@1 { + description = "Trusted OS"; + data = /incbin/("../../tee.bin"); + type = "OS"; + arch = "arm64"; + compression = "none"; + load = <0x00200000>; + }; + fuse_scr { + description = "Fuse Script"; + data = /incbin/("../../fuse_scr.bin"); + type = "firmware"; + arch = "arm64"; + compression = "none"; + load = <0x00180000>; + }; + }; + + configurations { + default = "config-1"; + config-1 { + description = "PPA Secure firmware"; + firmware = "firmware@1"; + loadables = "trustedOS@1", "fuse_scr"; + }; + }; +}; diff --git a/drivers/Makefile b/drivers/Makefile index edbcadf99b..b3f1b600a5 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_$(SPL_TPL_)TIMER) += timer/ ifndef CONFIG_TPL_BUILD ifdef CONFIG_SPL_BUILD +obj-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/ obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/ obj-$(CONFIG_SPL_GPIO_SUPPORT) += gpio/ diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index a82913cac1..a47226bd21 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c @@ -269,14 +269,9 @@ static int is_blank(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl, /* returns nonzero if entire page is blank */ static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl, - u32 *eccstat, unsigned int bufnum) + u32 eccstat, unsigned int bufnum) { - u32 reg = eccstat[bufnum / 4]; - int errors; - - errors = (reg >> ((3 - bufnum % 4) * 8)) & 15; - - return errors; + return (eccstat >> ((3 - bufnum % 4) * 8)) & 15; } /* @@ -290,7 +285,7 @@ static int fsl_ifc_run_command(struct mtd_info *mtd) struct fsl_ifc_runtime *ifc = ctrl->regs.rregs; u32 timeo = (CONFIG_SYS_HZ * 10) / 1000; u32 time_start; - u32 eccstat[8] = {0}; + u32 eccstat; int i; /* set the chip select for NAND Transaction */ @@ -320,20 +315,17 @@ static int fsl_ifc_run_command(struct mtd_info *mtd) if (ctrl->eccread) { int errors; int bufnum = ctrl->page & priv->bufnum_mask; - int sector = bufnum * chip->ecc.steps; - int sector_end = sector + chip->ecc.steps - 1; - - for (i = sector / 4; i <= sector_end / 4; i++) { - if (i >= ARRAY_SIZE(eccstat)) { - printf("%s: eccstat too small for %d\n", - __func__, i); - return -EIO; - } + int sector_start = bufnum * chip->ecc.steps; + int sector_end = sector_start + chip->ecc.steps - 1; + u32 *eccstat_regs; - eccstat[i] = ifc_in32(&ifc->ifc_nand.nand_eccstat[i]); - } + eccstat_regs = ifc->ifc_nand.nand_eccstat; + eccstat = ifc_in32(&eccstat_regs[sector_start / 4]); + + for (i = sector_start; i <= sector_end; i++) { + if ((i != sector_start) && !(i % 4)) + eccstat = ifc_in32(&eccstat_regs[i / 4]); - for (i = sector; i <= sector_end; i++) { errors = check_read_ecc(mtd, ctrl, eccstat, i); if (errors == 15) { @@ -708,6 +700,7 @@ static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip) struct fsl_ifc_ctrl *ctrl = priv->ctrl; struct fsl_ifc_runtime *ifc = ctrl->regs.rregs; u32 nand_fsr; + int status; if (ctrl->status != IFC_NAND_EVTER_STAT_OPC) return NAND_STATUS_FAIL; @@ -728,10 +721,10 @@ static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip) return NAND_STATUS_FAIL; nand_fsr = ifc_in32(&ifc->ifc_nand.nand_fsr); + status = nand_fsr >> 24; /* Chip sometimes reporting write protect even when it's not */ - nand_fsr = nand_fsr | NAND_STATUS_WP; - return nand_fsr; + return status | NAND_STATUS_WP; } static int fsl_ifc_read_page(struct mtd_info *mtd, struct nand_chip *chip, diff --git a/drivers/net/fsl-mc/dpbp.c b/drivers/net/fsl-mc/dpbp.c index 327bee935a..c609efb9ab 100644 --- a/drivers/net/fsl-mc/dpbp.c +++ b/drivers/net/fsl-mc/dpbp.c @@ -2,7 +2,7 @@ /* * Freescale Layerscape MC I/O wrapper * - * Copyright (C) 2013-2016 Freescale Semiconductor, Inc. + * Copyright 2013-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ #include <fsl-mc/fsl_mc_sys.h> diff --git a/drivers/net/fsl-mc/dpio/dpio.c b/drivers/net/fsl-mc/dpio/dpio.c index 0bbb760728..8884455963 100644 --- a/drivers/net/fsl-mc/dpio/dpio.c +++ b/drivers/net/fsl-mc/dpio/dpio.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (C) 2013-2016 Freescale Semiconductor + * Copyright 2013-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ diff --git a/drivers/net/fsl-mc/dpmac.c b/drivers/net/fsl-mc/dpmac.c index 2aadd4ada2..43a2ff43f8 100644 --- a/drivers/net/fsl-mc/dpmac.c +++ b/drivers/net/fsl-mc/dpmac.c @@ -2,7 +2,7 @@ /* * Freescale Layerscape MC I/O wrapper * - * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. + * Copyright 2015-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP * Author: Prabhakar Kushwaha <prabhakar@freescale.com> */ diff --git a/drivers/net/fsl-mc/dpni.c b/drivers/net/fsl-mc/dpni.c index 5cf5eebea6..443e430695 100644 --- a/drivers/net/fsl-mc/dpni.c +++ b/drivers/net/fsl-mc/dpni.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (C) 2013-2016 Freescale Semiconductor + * Copyright 2013-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ diff --git a/drivers/net/fsl-mc/dprc.c b/drivers/net/fsl-mc/dprc.c index 38d19a4063..e0a2865ab8 100644 --- a/drivers/net/fsl-mc/dprc.c +++ b/drivers/net/fsl-mc/dprc.c @@ -2,7 +2,7 @@ /* * Freescale Layerscape MC I/O wrapper * - * Copyright (C) 2013-2016 Freescale Semiconductor, Inc. + * Copyright 2013-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ diff --git a/drivers/net/fsl-mc/fsl_dpmng_cmd.h b/drivers/net/fsl-mc/fsl_dpmng_cmd.h index 9e6f27afdc..e18c88da09 100644 --- a/drivers/net/fsl-mc/fsl_dpmng_cmd.h +++ b/drivers/net/fsl-mc/fsl_dpmng_cmd.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0+ */ -/* Copyright 2013-2016 Freescale Semiconductor Inc. +/* Copyright 2013-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ #ifndef __FSL_DPMNG_CMD_H diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c index 58612cfca3..982024e31e 100644 --- a/drivers/net/fsl-mc/mc.c +++ b/drivers/net/fsl-mc/mc.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (C) 2017 NXP Semiconductors - * Copyright (C) 2014 Freescale Semiconductor + * Copyright 2014 Freescale Semiconductor, Inc. + * Copyright 2017 NXP */ #include <common.h> #include <errno.h> diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c index 8688dd4419..79facb4a44 100644 --- a/drivers/net/ldpaa_eth/ldpaa_eth.c +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (C) 2014-2016 Freescale Semiconductor + * Copyright 2014-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.h b/drivers/net/ldpaa_eth/ldpaa_eth.h index 54cb633e01..ee784a55ee 100644 --- a/drivers/net/ldpaa_eth/ldpaa_eth.h +++ b/drivers/net/ldpaa_eth/ldpaa_eth.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Copyright (C) 2014-2016 Freescale Semiconductor + * Copyright 2014-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index 2388438d10..5d196cfb3f 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2014 - 2015 Freescale Semiconductor, Inc. * - * SPDX-License-Identifier: GPL-2.0+ - * * Driver for the Vitesse VSC9953 L2 Switch */ diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index 79781b5d4a..3684249484 100644 --- a/drivers/spi/fsl_qspi.c +++ b/drivers/spi/fsl_qspi.c @@ -155,6 +155,25 @@ static void qspi_write32(u32 flags, u32 *addr, u32 val) out_be32(addr, val) : out_le32(addr, val); } +static inline int is_controller_busy(const struct fsl_qspi_priv *priv) +{ + u32 val; + const u32 mask = QSPI_SR_BUSY_MASK | QSPI_SR_AHB_ACC_MASK | + QSPI_SR_IP_ACC_MASK; + unsigned int retry = 5; + + do { + val = qspi_read32(priv->flags, &priv->regs->sr); + + if ((~val & mask) == mask) + return 0; + + udelay(1); + } while (--retry); + + return -ETIMEDOUT; +} + /* QSPI support swapping the flash read/write data * in hardware for LS102xA, but not for VF610 */ static inline u32 qspi_endian_xchg(u32 data) @@ -1017,11 +1036,7 @@ static int fsl_qspi_probe(struct udevice *bus) priv->num_chipselect = plat->num_chipselect; /* make sure controller is not busy anywhere */ - ret = wait_for_bit_le32(&priv->regs->sr, - QSPI_SR_BUSY_MASK | - QSPI_SR_AHB_ACC_MASK | - QSPI_SR_IP_ACC_MASK, - false, 100, false); + ret = is_controller_busy(priv); if (ret) { debug("ERROR : The controller is busy\n"); @@ -1184,11 +1199,7 @@ static int fsl_qspi_claim_bus(struct udevice *dev) priv = dev_get_priv(bus); /* make sure controller is not busy anywhere */ - ret = wait_for_bit_le32(&priv->regs->sr, - QSPI_SR_BUSY_MASK | - QSPI_SR_AHB_ACC_MASK | - QSPI_SR_IP_ACC_MASK, - false, 100, false); + ret = is_controller_busy(priv); if (ret) { debug("ERROR : The controller is busy\n"); diff --git a/drivers/usb/host/ehci-rmobile.c b/drivers/usb/host/ehci-rmobile.c index 7fe79efc17..4868581066 100644 --- a/drivers/usb/host/ehci-rmobile.c +++ b/drivers/usb/host/ehci-rmobile.c @@ -1,10 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * EHCI HCD (Host Controller Driver) for USB. * * Copyright (C) 2013,2014 Renesas Electronics Corporation * Copyright (C) 2014 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> - * - * SPDX-License-Identifier: GPL-2.0 */ #include <common.h> diff --git a/drivers/video/bridge/Makefile b/drivers/video/bridge/Makefile index 2a746c6f8b..45e54ac176 100644 --- a/drivers/video/bridge/Makefile +++ b/drivers/video/bridge/Makefile @@ -1,8 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ # # Copyright (C) 2015 Google, Inc # Written by Simon Glass <sjg@chromium.org> -# -# SPDX-License-Identifier: GPL-2.0+ obj-$(CONFIG_VIDEO_BRIDGE) += video-bridge-uclass.o obj-$(CONFIG_VIDEO_BRIDGE_PARADE_PS862X) += ps862x.o diff --git a/include/asm-generic/pe.h b/include/asm-generic/pe.h index d1683f238a..9a8b5e82e3 100644 --- a/include/asm-generic/pe.h +++ b/include/asm-generic/pe.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Portable Executable and Common Object Constants * @@ -5,8 +6,6 @@ * * based on the "Microsoft Portable Executable and Common Object File Format * Specification", revision 11, 2017-01-23 - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef _ASM_PE_H diff --git a/include/bootcount.h b/include/bootcount.h index 3eb802470a..671adcc410 100644 --- a/include/bootcount.h +++ b/include/bootcount.h @@ -3,11 +3,15 @@ * (C) Copyright 2012 * Stefan Roese, DENX Software Engineering, sr@denx.de. */ +#ifndef _BOOTCOUNT_H__ +#define _BOOTCOUNT_H__ #include <common.h> #include <asm/io.h> #include <asm/byteorder.h> +#if defined(CONFIG_SPL_BOOTCOUNT_LIMIT) || defined(CONFIG_BOOTCOUNT_LIMIT) + #if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE) # if __BYTE_ORDER == __LITTLE_ENDIAN # define CONFIG_SYS_BOOTCOUNT_LE @@ -37,3 +41,49 @@ static inline u32 raw_bootcount_load(volatile u32 *addr) return in_be32(addr); } #endif + +DECLARE_GLOBAL_DATA_PTR; +static inline int bootcount_error(void) +{ + unsigned long bootcount = bootcount_load(); + unsigned long bootlimit = env_get_ulong("bootlimit", 10, 0); + + if (bootlimit && bootcount > bootlimit) { + printf("Warning: Bootlimit (%lu) exceeded.", bootlimit); + if (!(gd->flags & GD_FLG_SPL_INIT)) + printf(" Using altbootcmd."); + printf("\n"); + + return 1; + } + + return 0; +} + +static inline void bootcount_inc(void) +{ + unsigned long bootcount = bootcount_load(); + + if (gd->flags & GD_FLG_SPL_INIT) { + bootcount_store(++bootcount); + return; + } + +#ifndef CONFIG_SPL_BUILD + /* Only increment bootcount when no bootcount support in SPL */ +#ifndef CONFIG_SPL_BOOTCOUNT_LIMIT + bootcount_store(++bootcount); +#endif + env_set_ulong("bootcount", bootcount); +#endif /* !CONFIG_SPL_BUILD */ +} + +#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT) +void bootcount_store(ulong a) {}; +ulong bootcount_load(void) { return 0; } +#endif /* CONFIG_SPL_BUILD && !CONFIG_SPL_BOOTCOUNT_LIMIT */ +#else +static inline int bootcount_error(void) { return 0; } +static inline void bootcount_inc(void) {} +#endif /* CONFIG_SPL_BOOTCOUNT_LIMIT || CONFIG_BOOTCOUNT_LIMIT */ +#endif /* _BOOTCOUNT_H__ */ diff --git a/include/charset.h b/include/charset.h index 2662c2f7c9..11832cbd12 100644 --- a/include/charset.h +++ b/include/charset.h @@ -1,9 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * charset conversion utils * * Copyright (c) 2017 Rob Clark - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef __CHARSET_H_ diff --git a/include/configs/ls1088a_common.h b/include/configs/ls1088a_common.h index 0df90161d7..ea48421bbe 100644 --- a/include/configs/ls1088a_common.h +++ b/include/configs/ls1088a_common.h @@ -148,7 +148,6 @@ unsigned long long get_qixis_addr(void); #define CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE (512UL * 1024 * 1024) #endif /* Command line configuration */ -#define CONFIG_CMD_GREPENV #define CONFIG_CMD_CACHE /* Miscellaneous configurable options */ @@ -195,10 +194,6 @@ unsigned long long get_qixis_addr(void); "mcinitcmd=fsl_mc start mc 0x580a00000" \ " 0x580e00000 \0" -#define CONFIG_BOOTARGS "console=ttyS0,115200 root=/dev/ram0 " \ - "earlycon=uart8250,mmio,0x21c0500 " \ - "ramdisk_size=0x3000000 default_hugepagesz=2m" \ - " hugepagesz=2m hugepages=256" #if defined(CONFIG_QSPI_BOOT) #define CONFIG_BOOTCOMMAND "sf probe 0:0;" \ "sf read 0x80200000 0xd00000 0x100000;"\ diff --git a/include/efi_driver.h b/include/efi_driver.h index 010e55a473..840483a416 100644 --- a/include/efi_driver.h +++ b/include/efi_driver.h @@ -1,9 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * EFI application loader * * Copyright (c) 2017 Heinrich Schuchardt - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef _EFI_DRIVER_H diff --git a/include/efi_loader.h b/include/efi_loader.h index 8d21ba74b1..2868ca25ab 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -1,9 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * EFI application loader * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef _EFI_LOADER_H diff --git a/include/efi_selftest.h b/include/efi_selftest.h index c23bc24bed..d0a76d70ca 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -1,9 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * EFI application loader * * Copyright (c) 2017 Heinrich Schuchardt <xypron.glpk@gmx.de> - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef _EFI_SELFTEST_H diff --git a/include/fsl-mc/fsl_dpbp.h b/include/fsl-mc/fsl_dpbp.h index 8d7c14d97d..2278ac952e 100644 --- a/include/fsl-mc/fsl_dpbp.h +++ b/include/fsl-mc/fsl_dpbp.h @@ -2,7 +2,7 @@ /* * Freescale Layerscape MC I/O wrapper * - * Copyright (C) 2013-2016 Freescale Semiconductor, Inc. + * Copyright 2013-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ /*! diff --git a/include/fsl-mc/fsl_dpio.h b/include/fsl-mc/fsl_dpio.h index c300c94e20..7788e1962e 100644 --- a/include/fsl-mc/fsl_dpio.h +++ b/include/fsl-mc/fsl_dpio.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Copyright (C) 2013-2016 Freescale Semiconductor + * Copyright 2013-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ diff --git a/include/fsl-mc/fsl_dpmac.h b/include/fsl-mc/fsl_dpmac.h index 66cf3bf6a2..1cea123a31 100644 --- a/include/fsl-mc/fsl_dpmac.h +++ b/include/fsl-mc/fsl_dpmac.h @@ -2,7 +2,7 @@ /* * Freescale Layerscape MC I/O wrapper * - * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. + * Copyright 2015-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP * Author: Prabhakar Kushwaha <prabhakar@freescale.com> */ diff --git a/include/fsl-mc/fsl_dpni.h b/include/fsl-mc/fsl_dpni.h index 309d323acf..96d81d9934 100644 --- a/include/fsl-mc/fsl_dpni.h +++ b/include/fsl-mc/fsl_dpni.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Copyright (C) 2013-2016 Freescale Semiconductor + * Copyright 2013-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ #ifndef _FSL_DPNI_H diff --git a/include/fsl-mc/fsl_dprc.h b/include/fsl-mc/fsl_dprc.h index 779d6f9567..950ecb0756 100644 --- a/include/fsl-mc/fsl_dprc.h +++ b/include/fsl-mc/fsl_dprc.h @@ -2,7 +2,7 @@ /* * Freescale Layerscape MC I/O wrapper * - * Copyright (C) 2013-2016 Freescale Semiconductor, Inc. + * Copyright 2013-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ #ifndef _FSL_DPRC_H diff --git a/include/fsl-mc/fsl_mc_cmd.h b/include/fsl-mc/fsl_mc_cmd.h index 179f669828..591cda9685 100644 --- a/include/fsl-mc/fsl_mc_cmd.h +++ b/include/fsl-mc/fsl_mc_cmd.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0+ */ -/* Copyright 2013-2016 Freescale Semiconductor Inc. +/* Copyright 2013-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ #ifndef __FSL_MC_CMD_H diff --git a/include/fsl-mc/fsl_mc_private.h b/include/fsl-mc/fsl_mc_private.h index f4b5a99e15..ba0bc379d5 100644 --- a/include/fsl-mc/fsl_mc_private.h +++ b/include/fsl-mc/fsl_mc_private.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Copyright (C) 2014-2016 Freescale Semiconductor + * Copyright 2014-2016 Freescale Semiconductor, Inc. * Copyright 2017 NXP */ diff --git a/include/fsl_ifc.h b/include/fsl_ifc.h index d051e92ce4..8120ca0de8 100644 --- a/include/fsl_ifc.h +++ b/include/fsl_ifc.h @@ -891,8 +891,8 @@ struct fsl_ifc_nand { u32 nand_erattr1; u32 res19[0x10]; u32 nand_fsr; - u32 res20[0x3]; - u32 nand_eccstat[6]; + u32 res20[0x1]; + u32 nand_eccstat[8]; u32 res21[0x1c]; u32 nanndcr; u32 res22[0x2]; diff --git a/include/image.h b/include/image.h index 8fa75a5a5a..df701e3470 100644 --- a/include/image.h +++ b/include/image.h @@ -259,7 +259,7 @@ enum { IH_TYPE_MXSIMAGE, /* Freescale MXSBoot Image */ IH_TYPE_GPIMAGE, /* TI Keystone GPHeader Image */ IH_TYPE_ATMELIMAGE, /* ATMEL ROM bootable Image */ - IH_TYPE_SOCFPGAIMAGE, /* Altera SOCFPGA Preloader */ + IH_TYPE_SOCFPGAIMAGE, /* Altera SOCFPGA CV/AV Preloader */ IH_TYPE_X86_SETUP, /* x86 setup.bin Image */ IH_TYPE_LPC32XXIMAGE, /* x86 setup.bin Image */ IH_TYPE_LOADABLE, /* A list of typeless images */ @@ -275,6 +275,7 @@ enum { IH_TYPE_FIRMWARE_IVT, /* Firmware Image with HABv4 IVT */ IH_TYPE_PMMC, /* TI Power Management Micro-Controller Firmware */ IH_TYPE_STM32IMAGE, /* STMicroelectronics STM32 Image */ + IH_TYPE_SOCFPGAIMAGE_V1, /* Altera SOCFPGA A10 Preloader */ IH_TYPE_COUNT, /* Number of image types */ }; diff --git a/include/linux/log2.h b/include/linux/log2.h index 4ded5ee68a..d4e32ecfc6 100644 --- a/include/linux/log2.h +++ b/include/linux/log2.h @@ -3,6 +3,11 @@ * * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. */ #ifndef _LINUX_LOG2_H @@ -12,12 +17,6 @@ #include <linux/bitops.h> /* - * deal with unrepresentable constant logarithms - */ -extern __attribute__((const, noreturn)) -int ____ilog2_NaN(void); - -/* * non-constant log of base 2 calculators * - the arch may override these in asm/bitops.h if they can be implemented * more efficiently than using fls() and fls64() @@ -39,19 +38,23 @@ int __ilog2_u64(u64 n) } #endif -/* - * Determine whether some value is a power of two, where zero is +/** + * is_power_of_2() - check if a value is a power of two + * @n: the value to check + * + * Determine whether some value is a power of two, where zero is * *not* considered a power of two. + * Return: true if @n is a power of 2, otherwise false. */ - static inline __attribute__((const)) bool is_power_of_2(unsigned long n) { return (n != 0 && ((n & (n - 1)) == 0)); } -/* - * round up to nearest power of two +/** + * __roundup_pow_of_two() - round up to nearest power of two + * @n: value to round up */ static inline __attribute__((const)) unsigned long __roundup_pow_of_two(unsigned long n) @@ -59,8 +62,9 @@ unsigned long __roundup_pow_of_two(unsigned long n) return 1UL << fls_long(n - 1); } -/* - * round down to nearest power of two +/** + * __rounddown_pow_of_two() - round down to nearest power of two + * @n: value to round down */ static inline __attribute__((const)) unsigned long __rounddown_pow_of_two(unsigned long n) @@ -69,19 +73,19 @@ unsigned long __rounddown_pow_of_two(unsigned long n) } /** - * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value - * @n - parameter + * ilog2 - log base 2 of 32-bit or a 64-bit unsigned value + * @n: parameter * * constant-capable log of base 2 calculation * - this can be used to initialise global variables from constant data, hence - * the massive ternary operator construction + * the massive ternary operator construction * * selects the appropriately-sized optimised version depending on sizeof(n) */ #define ilog2(n) \ ( \ __builtin_constant_p(n) ? ( \ - (n) < 1 ? ____ilog2_NaN() : \ + (n) < 2 ? 0 : \ (n) & (1ULL << 63) ? 63 : \ (n) & (1ULL << 62) ? 62 : \ (n) & (1ULL << 61) ? 61 : \ @@ -144,10 +148,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) (n) & (1ULL << 4) ? 4 : \ (n) & (1ULL << 3) ? 3 : \ (n) & (1ULL << 2) ? 2 : \ - (n) & (1ULL << 1) ? 1 : \ - (n) & (1ULL << 0) ? 0 : \ - ____ilog2_NaN() \ - ) : \ + 1) : \ (sizeof(n) <= 4) ? \ __ilog2_u32(n) : \ __ilog2_u64(n) \ @@ -155,7 +156,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) /** * roundup_pow_of_two - round the given value up to nearest power of two - * @n - parameter + * @n: parameter * * round the given value up to the nearest power of two * - the result is undefined when n == 0 @@ -172,7 +173,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) /** * rounddown_pow_of_two - round the given value down to nearest power of two - * @n - parameter + * @n: parameter * * round the given value down to the nearest power of two * - the result is undefined when n == 0 @@ -185,6 +186,12 @@ unsigned long __rounddown_pow_of_two(unsigned long n) __rounddown_pow_of_two(n) \ ) +static inline __attribute_const__ +int __order_base_2(unsigned long n) +{ + return n > 1 ? ilog2(n - 1) + 1 : 0; +} + /** * order_base_2 - calculate the (rounded up) base 2 order of the argument * @n: parameter @@ -198,7 +205,11 @@ unsigned long __rounddown_pow_of_two(unsigned long n) * ob2(5) = 3 * ... and so on. */ - -#define order_base_2(n) ilog2(roundup_pow_of_two(n)) - +#define order_base_2(n) \ +( \ + __builtin_constant_p(n) ? ( \ + ((n) == 0 || (n) == 1) ? 0 : \ + ilog2((n) - 1) + 1) : \ + __order_base_2(n) \ +) #endif /* _LINUX_LOG2_H */ diff --git a/include/net.h b/include/net.h index 3469811aa0..65f51d77a5 100644 --- a/include/net.h +++ b/include/net.h @@ -1,9 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * LiMon Monitor (LiMon) - Network. * * Copyright 1994 - 2000 Neil Russell. * (See License) - * SPDX-License-Identifier: GPL-2.0 * * History * 9/16/00 bor adapted to TQM823L/STK8xxL board, RARP/TFTP boot added diff --git a/include/pe.h b/include/pe.h index e7845bb7d2..d73eb142cb 100644 --- a/include/pe.h +++ b/include/pe.h @@ -1,11 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Portable Executable binary format structures * * Copyright (c) 2016 Alexander Graf * * Based on wine code - * - * SPDX-License-Identifier: GPL-2.0+ */ #ifndef _PE_H diff --git a/lib/charset.c b/lib/charset.c index 8cd17ea1cb..cd186a5a5a 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * charset conversion utils * * Copyright (c) 2017 Rob Clark - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <charset.h> diff --git a/lib/efi_driver/Makefile b/lib/efi_driver/Makefile index e35529a952..83baa1c9a4 100644 --- a/lib/efi_driver/Makefile +++ b/lib/efi_driver/Makefile @@ -1,8 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ # # (C) Copyright 2017 Heinrich Schuchardt -# -# SPDX-License-Identifier: GPL-2.0+ -# # This file only gets included with CONFIG_EFI_LOADER set, so all # object inclusion implicitly depends on it diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index d9d2b14f61..9c807ff71d 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -1,10 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI block driver * * Copyright (c) 2017 Heinrich Schuchardt * - * SPDX-License-Identifier: GPL-2.0+ - * * The EFI uclass creates a handle for this driver and installs the * driver binding protocol on it. * diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c index 46b69b479c..b484aba072 100644 --- a/lib/efi_driver/efi_uclass.c +++ b/lib/efi_driver/efi_uclass.c @@ -1,10 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Uclass for EFI drivers * * Copyright (c) 2017 Heinrich Schuchardt * - * SPDX-License-Identifier: GPL-2.0+ - * * For each EFI driver the uclass * - creates a handle * - installs the driver binding protocol diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 55c97c0476..c6046e36d2 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -1,8 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ # # (C) Copyright 2016 Alexander Graf # -# SPDX-License-Identifier: GPL-2.0+ -# # This file only gets included with CONFIG_EFI_LOADER set, so all # object inclusion implicitly depends on it diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index c96b9d48c5..153e173757 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI utils * * Copyright (c) 2017 Rob Clark - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 1cfdabf6eb..5715a8b810 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI application boot time services * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 5d1a9a8081..d777db8a3e 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI application console interface * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c index a79e60a4ee..ca8037def2 100644 --- a/lib/efi_loader/efi_device_path_to_text.c +++ b/lib/efi_loader/efi_device_path_to_text.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI device path interface * * Copyright (c) 2017 Heinrich Schuchardt - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_device_path_utilities.c b/lib/efi_loader/efi_device_path_utilities.c index 0ada2111db..94015329c8 100644 --- a/lib/efi_loader/efi_device_path_utilities.c +++ b/lib/efi_loader/efi_device_path_utilities.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI device path interface * * Copyright (c) 2017 Leif Lindholm - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 825a6d86de..5c6ec5258c 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI application disk support * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index cec8347f55..e6a15bcb52 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI utils * * Copyright (c) 2017 Rob Clark - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c index 363ccbb789..1afe8418e1 100644 --- a/lib/efi_loader/efi_gop.c +++ b/lib/efi_loader/efi_gop.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI application disk support * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index 2ccd476e57..e832cde901 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -1,11 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI image loader * * based partly on wine code * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 95f9ff0a14..664c651db5 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI application memory management * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index e3132e6c17..e1139501d1 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI application network access support * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 8558124c0a..52f1301d75 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI application runtime services * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c index 62e9697902..482436e2ad 100644 --- a/lib/efi_loader/efi_smbios.c +++ b/lib/efi_loader/efi_smbios.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI application tables support * * Copyright (c) 2016 Alexander Graf - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 6c177da3a6..7e0e7f020e 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI utils * * Copyright (c) 2017 Rob Clark - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <malloc.h> diff --git a/lib/efi_loader/efi_watchdog.c b/lib/efi_loader/efi_watchdog.c index d12e51da0a..6f69b76e4d 100644 --- a/lib/efi_loader/efi_watchdog.c +++ b/lib/efi_loader/efi_watchdog.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * EFI watchdog * * Copyright (c) 2017 Heinrich Schuchardt - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index 0e4980c8a0..80c4302645 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -1,8 +1,6 @@ -: -# (C) Copyright 2017, Heinrich Schuchardt <xypron.glpk@gmx.de> -# -# SPDX-License-Identifier: GPL-2.0+ +# SPDX-License-Identifier: GPL-2.0+ # +# (C) Copyright 2017, Heinrich Schuchardt <xypron.glpk@gmx.de> # This file only gets included with CONFIG_EFI_LOADER set, so all # object inclusion implicitly depends on it diff --git a/lib/efi_selftest/efi_selftest_disk_image.h b/lib/efi_selftest/efi_selftest_disk_image.h index 9c741ce136..a0e0586608 100644 --- a/lib/efi_selftest/efi_selftest_disk_image.h +++ b/lib/efi_selftest/efi_selftest_disk_image.h @@ -1,9 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Non-zero 8 byte strings of a disk image * * Generated with tools/file2include - * - * SPDX-License-Identifier: GPL-2.0+ */ #define EFI_ST_DISK_IMG { 0x00010000, { \ @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: BSD-2-Clause /* LZ4 - Fast LZ compression algorithm Copyright (C) 2011-2015, Yann Collet. - SPDX-License-Identifier: BSD-2-Clause - You can contact the author at : - LZ4 source repository : https://github.com/Cyan4973/lz4 - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copied from Linux Monitor (LiMon) - Networking. * @@ -6,7 +7,6 @@ * Copyright 2000 Roland Borde * Copyright 2000 Paolo Scaffardi * Copyright 2000-2002 Wolfgang Denk, wd@denx.de - * SPDX-License-Identifier: GPL-2.0 */ #include <common.h> @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copied from Linux Monitor (LiMon) - Networking. * @@ -6,7 +7,6 @@ * Copyright 2000 Roland Borde * Copyright 2000 Paolo Scaffardi * Copyright 2000-2002 Wolfgang Denk, wd@denx.de - * SPDX-License-Identifier: GPL-2.0 */ #ifndef __ARP_H__ @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copied from Linux Monitor (LiMon) - Networking. * @@ -6,7 +7,6 @@ * Copyright 2000 Roland Borde * Copyright 2000 Paolo Scaffardi * Copyright 2000-2002 Wolfgang Denk, wd@denx.de - * SPDX-License-Identifier: GPL-2.0 */ #include <common.h> @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copied from Linux Monitor (LiMon) - Networking. * @@ -6,7 +7,6 @@ * Copyright 2000 Roland Borde * Copyright 2000 Paolo Scaffardi * Copyright 2000-2002 Wolfgang Denk, wd@denx.de - * SPDX-License-Identifier: GPL-2.0 */ #if defined(CONFIG_CMD_CDP) @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copied from Linux Monitor (LiMon) - Networking. * @@ -6,7 +7,6 @@ * Copyright 2000 Roland Borde * Copyright 2000 Paolo Scaffardi * Copyright 2000-2002 Wolfgang Denk, wd@denx.de - * SPDX-License-Identifier: GPL-2.0 */ /* diff --git a/net/ping.c b/net/ping.c index 9508cf1160..5464f2f785 100644 --- a/net/ping.c +++ b/net/ping.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copied from Linux Monitor (LiMon) - Networking. * @@ -6,7 +7,6 @@ * Copyright 2000 Roland Borde * Copyright 2000 Paolo Scaffardi * Copyright 2000-2002 Wolfgang Denk, wd@denx.de - * SPDX-License-Identifier: GPL-2.0 */ #include "ping.h" diff --git a/net/ping.h b/net/ping.h index b672b95739..7b6f4e566d 100644 --- a/net/ping.h +++ b/net/ping.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copied from Linux Monitor (LiMon) - Networking. * @@ -6,7 +7,6 @@ * Copyright 2000 Roland Borde * Copyright 2000 Paolo Scaffardi * Copyright 2000-2002 Wolfgang Denk, wd@denx.de - * SPDX-License-Identifier: GPL-2.0 */ #ifndef __PING_H__ diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 09e7cef96e..057389997d 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -307,7 +307,11 @@ LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE) endif endif +ifdef CONFIG_TARGET_SOCFPGA_ARRIA10 +MKIMAGEFLAGS_$(SPL_BIN).sfp = -T socfpgaimage_v1 +else MKIMAGEFLAGS_$(SPL_BIN).sfp = -T socfpgaimage +endif $(obj)/$(SPL_BIN).sfp: $(obj)/$(SPL_BIN).bin FORCE $(call if_changed,mkimage) diff --git a/test/fs/fs-test.sh b/test/fs/fs-test.sh index 20d5dd8a47..b6b9461a10 100755 --- a/test/fs/fs-test.sh +++ b/test/fs/fs-test.sh @@ -1,9 +1,7 @@ #!/bin/bash +# SPDX-License-Identifier: GPL-2.0+ # # (C) Copyright 2014 Suriyan Ramasami -# -# SPDX-License-Identifier: GPL-2.0+ -# # Invoke this test script from U-Boot base directory as ./test/fs/fs-test.sh # It currently tests the fs/sb and native commands for ext4 and fat partitions diff --git a/tools/file2include.c b/tools/file2include.c index 7ca45c8339..b98af30a72 100644 --- a/tools/file2include.c +++ b/tools/file2include.c @@ -62,12 +62,11 @@ int main(int argc, char *argv[]) count = fread(buf, 1, count, file); /* Generate output */ + printf("/* SPDX-License-Identifier: GPL-2.0+ */\n"); printf("/*\n"); printf(" * Non-zero %u byte strings of a disk image\n", BLOCK_SIZE); printf(" *\n"); printf(" * Generated with tools/file2include\n"); - printf(" *\n"); - printf(" * SPDX-License-Identifier: GPL-2.0+\n"); printf(" */\n\n"); printf("#define EFI_ST_DISK_IMG { 0x%08zx, { \\\n", count); @@ -85,7 +84,7 @@ int main(int argc, char *argv[]) printf("\\x%02x", buf[j]); printf("\"}, /* "); for (j = i; j < i + BLOCK_SIZE && j < count; ++j) { - if (buf[j] >= 0x20 && buf[j] <= 0x7e) + if (buf[j] != '*' && buf[j] >= 0x20 && buf[j] <= 0x7e) printf("%c", buf[j]); else printf("."); diff --git a/tools/ifdtool.c b/tools/ifdtool.c index a576e2fce1..3a39b7bc70 100644 --- a/tools/ifdtool.c +++ b/tools/ifdtool.c @@ -757,7 +757,7 @@ static void print_version(void) { printf("ifdtool v%s -- ", IFDTOOL_VERSION); printf("Copyright (C) 2014 Google Inc.\n\n"); - printf("SPDX-License-Identifier: GPL-2.0+\n"); + printf("SPDX-License-Identifier: GPL-2.0+\n"); } static void print_usage(const char *name) diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c index 7f83b50761..390c9bb402 100644 --- a/tools/socfpgaimage.c +++ b/tools/socfpgaimage.c @@ -2,30 +2,52 @@ /* * Copyright (C) 2014 Charles Manning <cdhmanning@gmail.com> * - * Reference doc http://www.altera.com.cn/literature/hb/cyclone-v/cv_5400A.pdf - * Note this doc is not entirely accurate. Of particular interest to us is the - * "header" length field being in U32s and not bytes. + * Reference documents: + * Cyclone V SoC: https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/hb/cyclone-v/cv_5400a.pdf + * Arria V SoC: https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/hb/arria-v/av_5400a.pdf + * Arria 10 SoC: https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/hb/arria-10/a10_5400a.pdf * - * "Header" is a structure of the following format. - * this is positioned at 0x40. + * Bootable SoCFPGA image requires a structure of the following format + * positioned at offset 0x40 of the bootable image. Endian is LSB. * - * Endian is LSB. + * There are two versions of the SoCFPGA header format, v0 and v1. + * The version 0 is used by Cyclone V SoC and Arria V SoC, while + * the version 1 is used by the Arria 10 SoC. * + * Version 0: * Offset Length Usage * ----------------------- - * 0x40 4 Validation word 0x31305341 - * 0x44 1 Version (whatever, zero is fine) - * 0x45 1 Flags (unused, zero is fine) - * 0x46 2 Length (in units of u32, including the end checksum). - * 0x48 2 Zero + * 0x40 4 Validation word (0x31305341) + * 0x44 1 Version (0x0) + * 0x45 1 Flags (unused, zero is fine) + * 0x46 2 Length (in units of u32, including the end checksum). + * 0x48 2 Zero (0x0) * 0x4A 2 Checksum over the header. NB Not CRC32 * + * Version 1: + * Offset Length Usage + * ----------------------- + * 0x40 4 Validation word (0x31305341) + * 0x44 1 Version (0x1) + * 0x45 1 Flags (unused, zero is fine) + * 0x46 2 Header length (in units of u8). + * 0x48 4 Length (in units of u8). + * 0x4C 4 Image entry offset from standard of header + * 0x50 2 Zero (0x0) + * 0x52 2 Checksum over the header. NB Not CRC32 + * * At the end of the code we have a 32-bit CRC checksum over whole binary * excluding the CRC. * * Note that the CRC used here is **not** the zlib/Adler crc32. It is the * CRC-32 used in bzip2, ethernet and elsewhere. * + * The Image entry offset in version 1 image is relative the the start of + * the header, 0x40, and must not be a negative number. Therefore, it is + * only possible to make the SoCFPGA jump forward. The U-Boot bootloader + * places a trampoline instruction at offset 0x5c, 0x14 bytes from the + * start of the SoCFPGA header, which jumps to the reset vector. + * * The image is padded out to 64k, because that is what is * typically used to write the image to the boot medium. */ @@ -38,32 +60,57 @@ #define HEADER_OFFSET 0x40 #define VALIDATION_WORD 0x31305341 -#define PADDED_SIZE 0x10000 -/* To allow for adding CRC, the max input size is a bit smaller. */ -#define MAX_INPUT_SIZE (PADDED_SIZE - sizeof(uint32_t)) - -static uint8_t buffer[PADDED_SIZE]; +static uint8_t buffer_v0[0x10000]; +static uint8_t buffer_v1[0x40000]; + +struct socfpga_header_v0 { + uint32_t validation; + uint8_t version; + uint8_t flags; + uint16_t length_u32; + uint16_t zero; + uint16_t checksum; +}; + +struct socfpga_header_v1 { + uint32_t validation; + uint8_t version; + uint8_t flags; + uint16_t header_u8; + uint32_t length_u8; + uint32_t entry_offset; + uint16_t zero; + uint16_t checksum; +}; + +static unsigned int sfp_hdr_size(uint8_t ver) +{ + if (ver == 0) + return sizeof(struct socfpga_header_v0); + if (ver == 1) + return sizeof(struct socfpga_header_v1); + return 0; +} -static struct socfpga_header { - uint32_t validation; - uint8_t version; - uint8_t flags; - uint16_t length_u32; - uint16_t zero; - uint16_t checksum; -} header; +static unsigned int sfp_pad_size(uint8_t ver) +{ + if (ver == 0) + return sizeof(buffer_v0); + if (ver == 1) + return sizeof(buffer_v1); + return 0; +} /* * The header checksum is just a very simple checksum over * the header area. * There is still a crc32 over the whole lot. */ -static uint16_t hdr_checksum(struct socfpga_header *header) +static uint16_t sfp_hdr_checksum(uint8_t *buf, unsigned char ver) { - int len = sizeof(*header) - sizeof(header->checksum); - uint8_t *buf = (uint8_t *)header; uint16_t ret = 0; + int len = sfp_hdr_size(ver) - sizeof(ret); while (--len) ret += *buf++; @@ -71,48 +118,93 @@ static uint16_t hdr_checksum(struct socfpga_header *header) return ret; } - -static void build_header(uint8_t *buf, uint8_t version, uint8_t flags, - uint16_t length_bytes) +static void sfp_build_header(uint8_t *buf, uint8_t ver, uint8_t flags, + uint32_t length_bytes) { - header.validation = cpu_to_le32(VALIDATION_WORD); - header.version = version; - header.flags = flags; - header.length_u32 = cpu_to_le16(length_bytes/4); - header.zero = 0; - header.checksum = cpu_to_le16(hdr_checksum(&header)); - - memcpy(buf, &header, sizeof(header)); + struct socfpga_header_v0 header_v0 = { + .validation = cpu_to_le32(VALIDATION_WORD), + .version = 0, + .flags = flags, + .length_u32 = cpu_to_le16(length_bytes / 4), + .zero = 0, + }; + + struct socfpga_header_v1 header_v1 = { + .validation = cpu_to_le32(VALIDATION_WORD), + .version = 1, + .flags = flags, + .header_u8 = cpu_to_le16(sizeof(header_v1)), + .length_u8 = cpu_to_le32(length_bytes), + .entry_offset = cpu_to_le32(0x14), /* Trampoline offset */ + .zero = 0, + }; + + uint16_t csum; + + if (ver == 0) { + csum = sfp_hdr_checksum((uint8_t *)&header_v0, 0); + header_v0.checksum = cpu_to_le16(csum); + memcpy(buf, &header_v0, sizeof(header_v0)); + } else { + csum = sfp_hdr_checksum((uint8_t *)&header_v1, 1); + header_v1.checksum = cpu_to_le16(csum); + memcpy(buf, &header_v1, sizeof(header_v1)); + } } /* * Perform a rudimentary verification of header and return * size of image. */ -static int verify_header(const uint8_t *buf) +static int sfp_verify_header(const uint8_t *buf, uint8_t *ver) { - memcpy(&header, buf, sizeof(header)); + struct socfpga_header_v0 header_v0; + struct socfpga_header_v1 header_v1; + uint16_t hdr_csum, sfp_csum; + uint32_t img_len; - if (le32_to_cpu(header.validation) != VALIDATION_WORD) - return -1; - if (le16_to_cpu(header.checksum) != hdr_checksum(&header)) + /* + * Header v0 is always smaller than Header v1 and the validation + * word and version field is at the same place, so use Header v0 + * to check for version during verifiction and upgrade to Header + * v1 if needed. + */ + memcpy(&header_v0, buf, sizeof(header_v0)); + + if (le32_to_cpu(header_v0.validation) != VALIDATION_WORD) return -1; - return le16_to_cpu(header.length_u32) * 4; + if (header_v0.version == 0) { + hdr_csum = le16_to_cpu(header_v0.checksum); + sfp_csum = sfp_hdr_checksum((uint8_t *)&header_v0, 0); + img_len = le16_to_cpu(header_v0.length_u32) * 4; + } else if (header_v0.version == 1) { + memcpy(&header_v1, buf, sizeof(header_v1)); + hdr_csum = le16_to_cpu(header_v1.checksum); + sfp_csum = sfp_hdr_checksum((uint8_t *)&header_v1, 1); + img_len = le32_to_cpu(header_v1.length_u8); + } else { /* Invalid version */ + return -EINVAL; + } + + /* Verify checksum */ + if (hdr_csum != sfp_csum) + return -EINVAL; + + return img_len; } /* Sign the buffer and return the signed buffer size */ -static int sign_buffer(uint8_t *buf, - uint8_t version, uint8_t flags, - int len, int pad_64k) +static int sfp_sign_buffer(uint8_t *buf, uint8_t ver, uint8_t flags, + int len, int pad_64k) { uint32_t calc_crc; /* Align the length up */ - len = (len + 3) & (~3); + len = (len + 3) & ~3; /* Build header, adding 4 bytes to length to hold the CRC32. */ - build_header(buf + HEADER_OFFSET, version, flags, len + 4); + sfp_build_header(buf + HEADER_OFFSET, ver, flags, len + 4); /* Calculate and apply the CRC */ calc_crc = ~pbl_crc32(0, (char *)buf, len); @@ -122,23 +214,24 @@ static int sign_buffer(uint8_t *buf, if (!pad_64k) return len + 4; - return PADDED_SIZE; + return sfp_pad_size(ver); } /* Verify that the buffer looks sane */ -static int verify_buffer(const uint8_t *buf) +static int sfp_verify_buffer(const uint8_t *buf) { int len; /* Including 32bit CRC */ uint32_t calc_crc; uint32_t buf_crc; + uint8_t ver = 0; - len = verify_header(buf + HEADER_OFFSET); + len = sfp_verify_header(buf + HEADER_OFFSET, &ver); if (len < 0) { debug("Invalid header\n"); return -1; } - if (len < HEADER_OFFSET || len > PADDED_SIZE) { + if (len < HEADER_OFFSET || len > sfp_pad_size(ver)) { debug("Invalid header length (%i)\n", len); return -1; } @@ -164,17 +257,17 @@ static int verify_buffer(const uint8_t *buf) /* mkimage glue functions */ static int socfpgaimage_verify_header(unsigned char *ptr, int image_size, - struct image_tool_params *params) + struct image_tool_params *params) { - if (image_size != PADDED_SIZE) + if (image_size < 0x80) return -1; - return verify_buffer(ptr); + return sfp_verify_buffer(ptr); } static void socfpgaimage_print_header(const void *ptr) { - if (verify_buffer(ptr) == 0) + if (sfp_verify_buffer(ptr) == 0) printf("Looks like a sane SOCFPGA preloader\n"); else printf("Not a sane SOCFPGA preloader\n"); @@ -188,18 +281,25 @@ static int socfpgaimage_check_params(struct image_tool_params *params) (params->lflag && (params->dflag || params->fflag)); } -static int socfpgaimage_check_image_types(uint8_t type) +static int socfpgaimage_check_image_types_v0(uint8_t type) { if (type == IH_TYPE_SOCFPGAIMAGE) return EXIT_SUCCESS; return EXIT_FAILURE; } +static int socfpgaimage_check_image_types_v1(uint8_t type) +{ + if (type == IH_TYPE_SOCFPGAIMAGE_V1) + return EXIT_SUCCESS; + return EXIT_FAILURE; +} + /* * To work in with the mkimage framework, we do some ugly stuff... * * First, socfpgaimage_vrec_header() is called. - * We prepend a fake header big enough to make the file PADDED_SIZE. + * We prepend a fake header big enough to make the file sfp_pad_size(). * This gives us enough space to do what we want later. * * Next, socfpgaimage_set_header() is called. @@ -208,51 +308,94 @@ static int socfpgaimage_check_image_types(uint8_t type) */ static int data_size; -#define FAKE_HEADER_SIZE (PADDED_SIZE - data_size) -static int socfpgaimage_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams) +static int sfp_fake_header_size(unsigned int size, uint8_t ver) +{ + return sfp_pad_size(ver) - size; +} + +static int sfp_vrec_header(struct image_tool_params *params, + struct image_type_params *tparams, uint8_t ver) { struct stat sbuf; if (params->datafile && stat(params->datafile, &sbuf) == 0 && - sbuf.st_size <= MAX_INPUT_SIZE) { + sbuf.st_size <= (sfp_pad_size(ver) - sizeof(uint32_t))) { data_size = sbuf.st_size; - tparams->header_size = FAKE_HEADER_SIZE; + tparams->header_size = sfp_fake_header_size(data_size, ver); } return 0; + +} + +static int socfpgaimage_vrec_header_v0(struct image_tool_params *params, + struct image_type_params *tparams) +{ + return sfp_vrec_header(params, tparams, 0); } -static void socfpgaimage_set_header(void *ptr, struct stat *sbuf, int ifd, - struct image_tool_params *params) +static int socfpgaimage_vrec_header_v1(struct image_tool_params *params, + struct image_type_params *tparams) +{ + return sfp_vrec_header(params, tparams, 1); +} + +static void sfp_set_header(void *ptr, unsigned char ver) { uint8_t *buf = (uint8_t *)ptr; /* * This function is called after vrec_header() has been called. - * At this stage we have the FAKE_HEADER_SIZE dummy bytes followed by - * data_size image bytes. Total = PADDED_SIZE. + * At this stage we have the sfp_fake_header_size() dummy bytes + * followed by data_size image bytes. Total = sfp_pad_size(). * We need to fix the buffer by moving the image bytes back to * the beginning of the buffer, then actually do the signing stuff... */ - memmove(buf, buf + FAKE_HEADER_SIZE, data_size); - memset(buf + data_size, 0, FAKE_HEADER_SIZE); + memmove(buf, buf + sfp_fake_header_size(data_size, ver), data_size); + memset(buf + data_size, 0, sfp_fake_header_size(data_size, ver)); - sign_buffer(buf, 0, 0, data_size, 0); + sfp_sign_buffer(buf, ver, 0, data_size, 0); +} + +static void socfpgaimage_set_header_v0(void *ptr, struct stat *sbuf, int ifd, + struct image_tool_params *params) +{ + sfp_set_header(ptr, 0); +} + +static void socfpgaimage_set_header_v1(void *ptr, struct stat *sbuf, int ifd, + struct image_tool_params *params) +{ + sfp_set_header(ptr, 1); } U_BOOT_IMAGE_TYPE( socfpgaimage, - "Altera SOCFPGA preloader support", + "Altera SoCFPGA Cyclone V / Arria V image support", + 0, /* This will be modified by vrec_header() */ + (void *)buffer_v0, + socfpgaimage_check_params, + socfpgaimage_verify_header, + socfpgaimage_print_header, + socfpgaimage_set_header_v0, + NULL, + socfpgaimage_check_image_types_v0, + NULL, + socfpgaimage_vrec_header_v0 +); + +U_BOOT_IMAGE_TYPE( + socfpgaimage_v1, + "Altera SoCFPGA Arria10 image support", 0, /* This will be modified by vrec_header() */ - (void *)buffer, + (void *)buffer_v1, socfpgaimage_check_params, socfpgaimage_verify_header, socfpgaimage_print_header, - socfpgaimage_set_header, + socfpgaimage_set_header_v1, NULL, - socfpgaimage_check_image_types, + socfpgaimage_check_image_types_v1, NULL, - socfpgaimage_vrec_header + socfpgaimage_vrec_header_v1 ); |