From 731fd50e27fb3e9e55eb508cebebc7a111616a30 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 22 Apr 2020 13:18:11 +0200 Subject: ARM: stm32: Implement board coding on AV96 The AV96 board does exist in multiple variants. To cater for all of them, implement board code handling. There are two GPIOs which code the type of the board, read them out and use the value to pick the correct device tree from an fitImage. Reviewed-by: Patrick Delaunay Signed-off-by: Marek Vasut Cc: Manivannan Sadhasivam Cc: Patrick Delaunay Cc: Patrice Chotard Change-Id: Iddb330b9a66500495885457cbe17edc0eacaaf43 --- include/configs/dh_stm32mp1.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 include/configs/dh_stm32mp1.h (limited to 'include') diff --git a/include/configs/dh_stm32mp1.h b/include/configs/dh_stm32mp1.h new file mode 100644 index 00000000000..89d317ba2bd --- /dev/null +++ b/include/configs/dh_stm32mp1.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/* + * Copyright (C) 2020 Marek Vasut + * + * Configuration settings for the DH STM32MP15x SoMs + */ + +#ifndef __CONFIG_DH_STM32MP1_H__ +#define __CONFIG_DH_STM32MP1_H__ + +#include + +#define CONFIG_SPL_TARGET "u-boot.itb" + +#endif -- cgit v1.3.1 From 31325e1b8b9ce06b34add643f4a9d0b58235434a Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 18 Mar 2020 09:22:46 +0100 Subject: stm32mp1: dynamically build DFU_ALT_INFO This patch reduces the stm32mp1 environment size and builds dynamically the DFU board configuration with gpt and mtd partitions and information from defconfig (CONFIG_DFU_ALT_RAM0). Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- board/dhelectronics/dh_stm32mp1/Kconfig | 1 + board/st/common/Kconfig | 7 ++ board/st/common/stm32mp_dfu.c | 130 +++++++++++++++++++++++++------- include/configs/stm32mp1.h | 33 -------- 4 files changed, 110 insertions(+), 61 deletions(-) (limited to 'include') diff --git a/board/dhelectronics/dh_stm32mp1/Kconfig b/board/dhelectronics/dh_stm32mp1/Kconfig index 0a839f2546e..1fc792c9d1a 100644 --- a/board/dhelectronics/dh_stm32mp1/Kconfig +++ b/board/dhelectronics/dh_stm32mp1/Kconfig @@ -18,4 +18,5 @@ config ENV_OFFSET config ENV_OFFSET_REDUND default 0x1F0000 if ENV_IS_IN_SPI_FLASH +source "board/st/common/Kconfig" endif diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig index af01ca4891c..08df8459827 100644 --- a/board/st/common/Kconfig +++ b/board/st/common/Kconfig @@ -5,3 +5,10 @@ config CMD_STBOARD help This compile the stboard command to read and write the board in the OTP. + +config DFU_ALT_RAM0 + string "dfu for ram0" + default "uImage ram 0xc2000000 0x2000000;devicetree.dtb ram 0xc4000000 0x100000;uramdisk.image.gz ram 0xc4400000 0x10000000" + depends on ARCH_STM32MP && SET_DFU_ALT_INFO + help + This defines the partitions of ram used to build dfu dynamically. diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c index 99ea21ce15f..e129f8c8b5b 100644 --- a/board/st/common/stm32mp_dfu.c +++ b/board/st/common/stm32mp_dfu.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -13,20 +14,86 @@ #define DFU_ALT_BUF_LEN SZ_1K -static void board_get_alt_info(const char *dev, char *buff) +static void board_get_alt_info_mmc(struct udevice *dev, char *buf) { - char var_name[32] = "dfu_alt_info_"; - int ret; + disk_partition_t info; + int p, len, devnum; + bool first = true; + const char *name; + struct mmc *mmc; + struct blk_desc *desc; + + mmc = mmc_get_mmc_dev(dev); + if (!mmc) + return; + + if (mmc_init(mmc)) + return; + + desc = mmc_get_blk_desc(mmc); + if (!desc) + return; + + name = blk_get_if_type_name(desc->if_type); + devnum = desc->devnum; + len = strlen(buf); + + if (buf[0] != '\0') + len += snprintf(buf + len, + DFU_ALT_BUF_LEN - len, "&"); + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "%s %d=", name, devnum); + + if (IS_MMC(mmc) && mmc->capacity_boot) { + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "%s%d_boot1 raw 0x0 0x%llx mmcpart 1;", + name, devnum, mmc->capacity_boot); + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "%s%d_boot2 raw 0x0 0x%llx mmcpart 2", + name, devnum, mmc->capacity_boot); + first = false; + } - ALLOC_CACHE_ALIGN_BUFFER(char, tmp_alt, DFU_ALT_BUF_LEN); + for (p = 1; p < MAX_SEARCH_PARTITIONS; p++) { + if (part_get_info(desc, p, &info)) + continue; + if (!first) + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, ";"); + first = false; + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "%s%d_%s part %d %d", + name, devnum, info.name, devnum, p); + } +} - /* name of env variable to read = dfu_alt_info_ */ - strcat(var_name, dev); - ret = env_get_f(var_name, tmp_alt, DFU_ALT_BUF_LEN); - if (ret) { - if (buff[0] != '\0') - strcat(buff, "&"); - strncat(buff, tmp_alt, DFU_ALT_BUF_LEN); +static void board_get_alt_info_mtd(struct mtd_info *mtd, char *buf) +{ + struct mtd_info *part; + bool first = true; + const char *name; + int len, partnum = 0; + + name = mtd->name; + len = strlen(buf); + + if (buf[0] != '\0') + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, "&"); + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "mtd %s=", name); + + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "%s raw 0x0 0x%llx ", + name, mtd->size); + + list_for_each_entry(part, &mtd->partitions, node) { + partnum++; + if (!first) + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, ";"); + first = false; + + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "%s_%s part %d", + name, part->name, partnum); } } @@ -42,27 +109,34 @@ void set_dfu_alt_info(char *interface, char *devstr) memset(buf, 0, sizeof(buf)); - /* probe all MTD devices */ - mtd_probe_devices(); - - board_get_alt_info("ram", buf); + snprintf(buf, DFU_ALT_BUF_LEN, + "ram 0=%s", CONFIG_DFU_ALT_RAM0); if (!uclass_get_device(UCLASS_MMC, 0, &dev)) - board_get_alt_info("mmc0", buf); + board_get_alt_info_mmc(dev, buf); if (!uclass_get_device(UCLASS_MMC, 1, &dev)) - board_get_alt_info("mmc1", buf); - - if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) - board_get_alt_info("nor0", buf); - - mtd = get_mtd_device_nm("nand0"); - if (!IS_ERR_OR_NULL(mtd)) - board_get_alt_info("nand0", buf); - - mtd = get_mtd_device_nm("spi-nand0"); - if (!IS_ERR_OR_NULL(mtd)) - board_get_alt_info("spi-nand0", buf); + board_get_alt_info_mmc(dev, buf); + + if (CONFIG_IS_ENABLED(MTD)) { + /* probe all MTD devices */ + mtd_probe_devices(); + + /* probe SPI flash device on a bus */ + if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) { + mtd = get_mtd_device_nm("nor0"); + if (!IS_ERR_OR_NULL(mtd)) + board_get_alt_info_mtd(mtd, buf); + } + + mtd = get_mtd_device_nm("nand0"); + if (!IS_ERR_OR_NULL(mtd)) + board_get_alt_info_mtd(mtd, buf); + + mtd = get_mtd_device_nm("spi-nand0"); + if (!IS_ERR_OR_NULL(mtd)) + board_get_alt_info_mtd(mtd, buf); + } #ifdef CONFIG_DFU_VIRT strncat(buf, "&virt 0=OTP", DFU_ALT_BUF_LEN); diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h index be5afe9c6fa..0319ebf4d87 100644 --- a/include/configs/stm32mp1.h +++ b/include/configs/stm32mp1.h @@ -165,37 +165,6 @@ #define STM32MP_MTDPARTS #endif -#define STM32MP_DFU_ALT_RAM \ - "dfu_alt_info_ram=ram 0=" \ - "uImage ram ${kernel_addr_r} 0x2000000;" \ - "devicetree.dtb ram ${fdt_addr_r} 0x100000;" \ - "uramdisk.image.gz ram ${ramdisk_addr_r} 0x10000000\0" - -#ifdef CONFIG_SET_DFU_ALT_INFO -#define STM32MP_DFU_ALT_INFO \ - "dfu_alt_info_nor0=mtd nor0=" \ - "nor_fsbl1 part 1;nor_fsbl2 part 2;" \ - "nor_ssbl part 3;nor_env part 4\0" \ - "dfu_alt_info_nand0=mtd nand0="\ - "nand_fsbl part 1;nand_ssbl1 part 2;" \ - "nand_ssbl2 part 3;nand_UBI partubi 4\0" \ - "dfu_alt_info_spi-nand0=mtd spi-nand0="\ - "spi-nand_fsbl part 1;spi-nand_ssbl1 part 2;" \ - "spi-nand_ssbl2 part 3;spi-nand_UBI partubi 4\0" \ - "dfu_alt_info_mmc0=mmc 0=" \ - "sdcard_fsbl1 part 0 1;sdcard_fsbl2 part 0 2;" \ - "sdcard_ssbl part 0 3;sdcard_bootfs part 0 4;" \ - "sdcard_vendorfs part 0 5;sdcard_rootfs part 0 6;" \ - "sdcard_userfs part 0 7\0" \ - "dfu_alt_info_mmc1=mmc 1=" \ - "emmc_fsbl1 raw 0x0 0x200 mmcpart 1;" \ - "emmc_fsbl2 raw 0x0 0x200 mmcpart 2;emmc_ssbl part 1 1;" \ - "emmc_bootfs part 1 2;emmc_vendorfs part 1 3;" \ - "emmc_rootfs part 1 4;emmc_userfs part 1 5\0" -#else -#define STM32MP_DFU_ALT_INFO -#endif - /* * memory layout for 32M uncompressed/compressed kernel, * 1M fdt, 1M script, 1M pxe and 1M for splashimage @@ -215,8 +184,6 @@ " then env set env_default 0;env save;fi\0" \ STM32MP_BOOTCMD \ STM32MP_MTDPARTS \ - STM32MP_DFU_ALT_RAM \ - STM32MP_DFU_ALT_INFO \ BOOTENV \ "boot_net_usb_start=true\0" -- cgit v1.3.1 From 28a28ba9764d02b1e52938b5f7d322ffd13b01f1 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 18 Mar 2020 09:22:47 +0100 Subject: stm32mp1: move MTDPART configuration in Kconfig This patch reduces the stm32mp1 environment size and builds dynamically the MTD partitions with information from defconfig (CONFIG_MTDPARTS_...). Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- board/st/common/Kconfig | 57 +++++++++++++++++++++++ board/st/common/stm32mp_mtdparts.c | 93 +++++++++++++++++++------------------- include/configs/stm32mp1.h | 22 --------- 3 files changed, 104 insertions(+), 68 deletions(-) (limited to 'include') diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig index 08df8459827..015ba409396 100644 --- a/board/st/common/Kconfig +++ b/board/st/common/Kconfig @@ -6,6 +6,63 @@ config CMD_STBOARD This compile the stboard command to read and write the board in the OTP. +config MTDPARTS_NAND0_BOOT + string "mtd boot partitions for nand0" + default "2m(fsbl),2m(ssbl1),2m(ssbl2)" + depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP + help + This define the partitions of nand0 used to build mtparts dynamically + for boot from nand0. + Each partition need to be aligned with the device erase block size, + 512KB is the max size for the NAND supported by stm32mp1 platform. + +config MTDPARTS_NAND0_TEE + string "mtd tee partitions for nand0" + default "512k(teeh),512k(teed),512k(teex)" + depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP + help + This define the tee partitions added in mtparts dynamically + when tee is supported with boot from nand0. + Each partition need to be aligned with the device erase block size, + 512KB is the max size for the NAND supported by stm32mp1 platform. + +config MTDPARTS_NOR0_BOOT + string "mtd boot partitions for nor0" + default "256k(fsbl1),256k(fsbl2),2m(ssbl),512k(u-boot-env)" + depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP + help + This define the partitions of nand0 used to build mtparts dynamically + for boot from nor0. + Each partition need to be aligned with the device erase block size, + with 256KB we support all the NOR. + U-Boot env partition (512kB) use 2 erase block for redundancy. + +config MTDPARTS_NOR0_TEE + string "mtd tee partitions for nor0" + default "256k(teeh),256k(teed),256k(teex)" + depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP + help + This define the tee partitions added in mtparts dynamically + when tee is supported with boot from nor0. + +config MTDPARTS_SPINAND0_BOOT + string "mtd boot partitions for spi-nand0" + default "2m(fsbl),2m(ssbl1),2m(ssbl2)" + depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP + help + This define the partitions of nand0 used to build mtparts dynamically + for boot from spi-nand0, + 512KB is the max size for the NAND supported by stm32mp1 platform. + +config MTDPARTS_SPINAND0_TEE + string "mtd tee partitions for spi-nand0" + default "512k(teeh),512k(teed),512k(teex)" + depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP + help + This define the tee partitions added in mtparts dynamically + when tee is supported with boot from spi-nand0, + 512KB is the max size for the NAND supported by stm32mp1 platform. + config DFU_ALT_RAM0 string "dfu for ram0" default "uImage ram 0xc2000000 0x2000000;devicetree.dtb ram 0xc4000000 0x100000;uramdisk.image.gz ram 0xc4400000 0x10000000" diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c index d77e075864d..d4c0a7db9fb 100644 --- a/board/st/common/stm32mp_mtdparts.c +++ b/board/st/common/stm32mp_mtdparts.c @@ -19,54 +19,42 @@ DECLARE_GLOBAL_DATA_PTR; /** - * The mtdparts_nand0 and mtdparts_nor0 variable tends to be long. - * If we need to access it before the env is relocated, then we need - * to use our own stack buffer. gd->env_buf will be too small. - * - * @param buf temporary buffer pointer MTDPARTS_LEN long - * @return mtdparts variable string, NULL if not found - */ -static const char *env_get_mtdparts(const char *str, char *buf) -{ - if (gd->flags & GD_FLG_ENV_READY) - return env_get(str); - if (env_get_f(str, buf, MTDPARTS_LEN) != -1) - return buf; - - return NULL; -} - -/** - * update the variables "mtdids" and "mtdparts" with content of mtdparts_ + * update the variables "mtdids" and "mtdparts" with boot, tee and user strings */ static void board_get_mtdparts(const char *dev, char *mtdids, - char *mtdparts) + char *mtdparts, + const char *boot, + const char *tee, + const char *user) { - char env_name[32] = "mtdparts_"; - char tmp_mtdparts[MTDPARTS_LEN]; - const char *tmp; - - /* name of env variable to read = mtdparts_ */ - strcat(env_name, dev); - tmp = env_get_mtdparts(env_name, tmp_mtdparts); - if (tmp) { - /* mtdids: "=, ...." */ - if (mtdids[0] != '\0') - strcat(mtdids, ","); - strcat(mtdids, dev); - strcat(mtdids, "="); - strcat(mtdids, dev); - - /* mtdparts: "mtdparts=:>;..." */ - if (mtdparts[0] != '\0') - strncat(mtdparts, ";", MTDPARTS_LEN); - else - strcat(mtdparts, "mtdparts="); - strncat(mtdparts, dev, MTDPARTS_LEN); - strncat(mtdparts, ":", MTDPARTS_LEN); - strncat(mtdparts, tmp, MTDPARTS_LEN); + /* mtdids: "=, ...." */ + if (mtdids[0] != '\0') + strcat(mtdids, ","); + strcat(mtdids, dev); + strcat(mtdids, "="); + strcat(mtdids, dev); + + /* mtdparts: "mtdparts=:>;..." */ + if (mtdparts[0] != '\0') + strncat(mtdparts, ";", MTDPARTS_LEN); + else + strcat(mtdparts, "mtdparts="); + + strncat(mtdparts, dev, MTDPARTS_LEN); + strncat(mtdparts, ":", MTDPARTS_LEN); + + if (boot) { + strncat(mtdparts, boot, MTDPARTS_LEN); + strncat(mtdparts, ",", MTDPARTS_LEN); + } + + if (CONFIG_IS_ENABLED(STM32MP1_OPTEE) && tee) { + strncat(mtdparts, tee, MTDPARTS_LEN); + strncat(mtdparts, ",", MTDPARTS_LEN); } + + strncat(mtdparts, user, MTDPARTS_LEN); } void board_mtdparts_default(const char **mtdids, const char **mtdparts) @@ -76,6 +64,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) static char parts[3 * MTDPARTS_LEN + 1]; static char ids[MTDIDS_LEN + 1]; static bool mtd_initialized; + bool tee = false; if (mtd_initialized) { *mtdids = ids; @@ -83,6 +72,9 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) return; } + if (CONFIG_IS_ENABLED(STM32MP1_OPTEE)) + tee = true; + memset(parts, 0, sizeof(parts)); memset(ids, 0, sizeof(ids)); @@ -95,18 +87,27 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts) mtd = get_mtd_device_nm("nand0"); if (!IS_ERR_OR_NULL(mtd)) { - board_get_mtdparts("nand0", ids, parts); + board_get_mtdparts("nand0", ids, parts, + CONFIG_MTDPARTS_NAND0_BOOT, + tee ? CONFIG_MTDPARTS_NAND0_TEE : NULL, + "-(UBI)"); put_mtd_device(mtd); } mtd = get_mtd_device_nm("spi-nand0"); if (!IS_ERR_OR_NULL(mtd)) { - board_get_mtdparts("spi-nand0", ids, parts); + board_get_mtdparts("spi-nand0", ids, parts, + CONFIG_MTDPARTS_SPINAND0_BOOT, + tee ? CONFIG_MTDPARTS_SPINAND0_TEE : NULL, + "-(UBI)"); put_mtd_device(mtd); } if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) - board_get_mtdparts("nor0", ids, parts); + board_get_mtdparts("nor0", ids, parts, + CONFIG_MTDPARTS_NOR0_BOOT, + tee ? CONFIG_MTDPARTS_NOR0_TEE : NULL, + "-(nor_user)"); mtd_initialized = true; *mtdids = ids; diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h index 0319ebf4d87..19e2b3b31e0 100644 --- a/include/configs/stm32mp1.h +++ b/include/configs/stm32mp1.h @@ -144,27 +144,6 @@ #include -#ifdef CONFIG_STM32MP1_OPTEE -/* with OPTEE: define specific MTD partitions = teeh, teed, teex */ -#define STM32MP_MTDPARTS \ - "mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),256k(teeh),256k(teed),256k(teex),-(nor_user)\0" \ - "mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),512k(teeh),512k(teed),512k(teex),-(UBI)\0" \ - "mtdparts_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),"\ - "512k(teeh),512k(teed),512k(teex),-(UBI)\0" - -#else /* CONFIG_STM32MP1_OPTEE */ -#define STM32MP_MTDPARTS \ - "mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(u-boot-env),-(nor_user)\0" \ - "mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0" \ - "mtdparts_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0" - -#endif /* CONFIG_STM32MP1_OPTEE */ - -#ifndef CONFIG_SYS_MTDPARTS_RUNTIME -#undef STM32MP_MTDPARTS -#define STM32MP_MTDPARTS -#endif - /* * memory layout for 32M uncompressed/compressed kernel, * 1M fdt, 1M script, 1M pxe and 1M for splashimage @@ -183,7 +162,6 @@ "env_check=if test $env_default -eq 1;"\ " then env set env_default 0;env save;fi\0" \ STM32MP_BOOTCMD \ - STM32MP_MTDPARTS \ BOOTENV \ "boot_net_usb_start=true\0" -- cgit v1.3.1 From 4a1b975dac0270f553f5a58b0e7d809c8c8ef61f Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 18 Mar 2020 09:22:48 +0100 Subject: board: stm32mp1: reserve memory for OP-TEE in device tree Add reserve memory for OP-TEE in U-Boot and in kernel device tree: - no more reduce the DDR size in "memory" node: CONFIG_SYS_MEM_TOP_HIDE is no more used - U-Boot device-tree defines the needed "reserved-memory" for OP-TEE and U-Boot should not use this reserved memory: board_get_usable_ram_top use lmb lib to found the first free region, the not reserved memory, enough to relocate U-Boot: the needed size of U-Boot is estimated with gd->mon_len + CONFIG_SYS_MALLOC_LEN. - the optee node ("optee@...": firmware with compatible "linaro,optee-tz") and the associated "reserved-memory" are deactivated in kernel device tree when OP-TEE is not detected by U-Boot to prevent kernel issue (memory is reserved but not used, optee driver probe failed). Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- arch/arm/dts/stm32mp157c-ed1.dts | 5 +++++ arch/arm/dts/stm32mp15xx-dkx.dtsi | 5 +++++ arch/arm/mach-stm32mp/dram_init.c | 18 ++++++++++++++++++ arch/arm/mach-stm32mp/fdt.c | 23 +++++++++++++++++++++++ include/configs/stm32mp1.h | 4 ---- 5 files changed, 51 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/arch/arm/dts/stm32mp157c-ed1.dts b/arch/arm/dts/stm32mp157c-ed1.dts index 54af7c97b37..05d53264055 100644 --- a/arch/arm/dts/stm32mp157c-ed1.dts +++ b/arch/arm/dts/stm32mp157c-ed1.dts @@ -70,6 +70,11 @@ reg = <0xe8000000 0x8000000>; no-map; }; + + optee@fe000000 { + reg = <0xfe000000 0x02000000>; + no-map; + }; }; aliases { diff --git a/arch/arm/dts/stm32mp15xx-dkx.dtsi b/arch/arm/dts/stm32mp15xx-dkx.dtsi index 42d3f0cb2d7..9ce10a52f06 100644 --- a/arch/arm/dts/stm32mp15xx-dkx.dtsi +++ b/arch/arm/dts/stm32mp15xx-dkx.dtsi @@ -58,6 +58,11 @@ reg = <0xd4000000 0x4000000>; no-map; }; + + optee@de000000 { + reg = <0xde000000 0x02000000>; + no-map; + }; }; led { diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c index 7688b3e315e..3233415eff7 100644 --- a/arch/arm/mach-stm32mp/dram_init.c +++ b/arch/arm/mach-stm32mp/dram_init.c @@ -5,6 +5,7 @@ #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -31,3 +32,20 @@ int dram_init(void) return 0; } + +ulong board_get_usable_ram_top(ulong total_size) +{ + phys_addr_t reg; + struct lmb lmb; + + /* found enough not-reserved memory to relocated U-Boot */ + lmb_init(&lmb); + lmb_add(&lmb, gd->ram_base, gd->ram_size); + boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob); + reg = lmb_alloc(&lmb, CONFIG_SYS_MALLOC_LEN + total_size, SZ_4K); + + if (reg) + return ALIGN(reg + CONFIG_SYS_MALLOC_LEN + total_size, SZ_4K); + + return gd->ram_top; +} diff --git a/arch/arm/mach-stm32mp/fdt.c b/arch/arm/mach-stm32mp/fdt.c index 3ee7d6a8337..ae82270e424 100644 --- a/arch/arm/mach-stm32mp/fdt.c +++ b/arch/arm/mach-stm32mp/fdt.c @@ -218,6 +218,26 @@ static void stm32_fdt_disable(void *fdt, int offset, u32 addr, string, addr, name); } +static void stm32_fdt_disable_optee(void *blob) +{ + int off, node; + + off = fdt_node_offset_by_compatible(blob, -1, "linaro,optee-tz"); + if (off >= 0 && fdtdec_get_is_enabled(blob, off)) + fdt_status_disabled(blob, off); + + /* Disabled "optee@..." reserved-memory node */ + off = fdt_path_offset(blob, "/reserved-memory/"); + if (off < 0) + return; + for (node = fdt_first_subnode(blob, off); + node >= 0; + node = fdt_next_subnode(blob, node)) { + if (!strncmp(fdt_get_name(blob, node, NULL), "optee@", 6)) + fdt_status_disabled(blob, node); + } +} + /* * This function is called right before the kernel is booted. "blob" is the * device tree that will be passed to the kernel. @@ -302,5 +322,8 @@ int ft_system_setup(void *blob, bd_t *bd) "st,package", pkg, false); } + if (!CONFIG_IS_ENABLED(STM32MP1_OPTEE)) + stm32_fdt_disable_optee(blob); + return ret; } diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h index 19e2b3b31e0..feb4cc21a9f 100644 --- a/include/configs/stm32mp1.h +++ b/include/configs/stm32mp1.h @@ -23,10 +23,6 @@ #define CONFIG_SYS_SDRAM_BASE STM32_DDR_BASE #define CONFIG_SYS_INIT_SP_ADDR CONFIG_SYS_TEXT_BASE -#ifdef CONFIG_STM32MP1_OPTEE -#define CONFIG_SYS_MEM_TOP_HIDE SZ_32M -#endif /* CONFIG_STM32MP1_OPTEE */ - /* * Console I/O buffer size */ -- cgit v1.3.1 From b664a74537c9a9a4a50940e4a2ced2428760235b Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 18 Mar 2020 09:22:52 +0100 Subject: board: stm32mp1: support boot from spi-nand Manage BOOT_FLASH_SPINAND, with boot_device="spi-nand" and treat this value in bootcmd_stm32mp. Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- arch/arm/mach-stm32mp/cpu.c | 4 ++++ arch/arm/mach-stm32mp/include/mach/stm32.h | 3 +++ arch/arm/mach-stm32mp/spl.c | 2 ++ board/st/stm32mp1/stm32mp1.c | 2 ++ include/configs/stm32mp1.h | 5 +++-- 5 files changed, 14 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c index 74d03fa7dd8..73d8b753474 100644 --- a/arch/arm/mach-stm32mp/cpu.c +++ b/arch/arm/mach-stm32mp/cpu.c @@ -435,6 +435,10 @@ static void setup_boot_mode(void) env_set("boot_device", "nand"); env_set("boot_instance", "0"); break; + case BOOT_FLASH_SPINAND: + env_set("boot_device", "spi-nand"); + env_set("boot_instance", "0"); + break; case BOOT_FLASH_NOR: env_set("boot_device", "nor"); env_set("boot_instance", "0"); diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h index 76d593d785d..242bacc50b0 100644 --- a/arch/arm/mach-stm32mp/include/mach/stm32.h +++ b/arch/arm/mach-stm32mp/include/mach/stm32.h @@ -80,6 +80,9 @@ enum boot_device { BOOT_SERIAL_USB = 0x60, BOOT_SERIAL_USB_OTG = 0x62, + + BOOT_FLASH_SPINAND = 0x70, + BOOT_FLASH_SPINAND_1 = 0x71, }; /* TAMP registers */ diff --git a/arch/arm/mach-stm32mp/spl.c b/arch/arm/mach-stm32mp/spl.c index 9fbc3ac953d..760fe45f56f 100644 --- a/arch/arm/mach-stm32mp/spl.c +++ b/arch/arm/mach-stm32mp/spl.c @@ -39,6 +39,8 @@ u32 spl_boot_device(void) return BOOT_DEVICE_NAND; case BOOT_FLASH_NOR_QSPI: return BOOT_DEVICE_SPI; + case BOOT_FLASH_SPINAND_1: + return BOOT_DEVICE_NONE; /* SPINAND not supported in SPL */ } return BOOT_DEVICE_MMC1; diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 496ca56a145..fe54947c1c7 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -789,6 +789,7 @@ enum env_location env_get_location(enum env_operation op, int prio) #endif #ifdef CONFIG_ENV_IS_IN_UBI case BOOT_FLASH_NAND: + case BOOT_FLASH_SPINAND: return ENVL_UBI; #endif #ifdef CONFIG_ENV_IS_IN_SPI_FLASH @@ -829,6 +830,7 @@ int ft_board_setup(void *blob, bd_t *bd) #ifdef CONFIG_FDT_FIXUP_PARTITIONS struct node_info nodes[] = { { "st,stm32f469-qspi", MTD_DEV_TYPE_NOR, }, + { "st,stm32f469-qspi", MTD_DEV_TYPE_SPINAND}, { "st,stm32mp15-fmc2", MTD_DEV_TYPE_NAND, }, }; fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes)); diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h index feb4cc21a9f..f271b84a59e 100644 --- a/include/configs/stm32mp1.h +++ b/include/configs/stm32mp1.h @@ -122,7 +122,7 @@ * bootcmd for stm32mp1: * for serial/usb: execute the stm32prog command * for mmc boot (eMMC, SD card), boot only on the same device - * for nand boot, boot with on ubifs partition on nand + * for nand or spi-nand boot, boot with on ubifs partition on UBI partition * for nor boot, use the default order */ #define STM32MP_BOOTCMD "bootcmd_stm32mp=" \ @@ -133,7 +133,8 @@ "run env_check;" \ "if test ${boot_device} = mmc;" \ "then env set boot_targets \"mmc${boot_instance}\"; fi;" \ - "if test ${boot_device} = nand;" \ + "if test ${boot_device} = nand ||" \ + " test ${boot_device} = spi-nand ;" \ "then env set boot_targets ubifs0; fi;" \ "run distro_bootcmd;" \ "fi;\0" -- cgit v1.3.1 From bcd677f246e872c2c945d667ac1044cb735c8e14 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 18 Mar 2020 09:24:46 +0100 Subject: usb: gadget: g_dnl: add function g_dnl_set_product Add a function g_dnl_set_product to change the Product string used in USB enumeration in any command based on download gadget. If the function is called with NULL pointer, the product string is set to the default value (product[] = "USB download gadget"). Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- drivers/usb/gadget/g_dnl.c | 8 ++++++++ include/g_dnl.h | 1 + 2 files changed, 9 insertions(+) (limited to 'include') diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c index e9e1600a1a5..7a51b53f248 100644 --- a/drivers/usb/gadget/g_dnl.c +++ b/drivers/usb/gadget/g_dnl.c @@ -89,6 +89,14 @@ static struct usb_gadget_strings *g_dnl_composite_strings[] = { NULL, }; +void g_dnl_set_product(const char *s) +{ + if (s) + g_dnl_string_defs[1].s = s; + else + g_dnl_string_defs[1].s = product; +} + static int g_dnl_unbind(struct usb_composite_dev *cdev) { struct usb_gadget *gadget = cdev->gadget; diff --git a/include/g_dnl.h b/include/g_dnl.h index 6d461c73d3d..836ee602c8d 100644 --- a/include/g_dnl.h +++ b/include/g_dnl.h @@ -38,6 +38,7 @@ int g_dnl_board_usb_cable_connected(void); int g_dnl_register(const char *s); void g_dnl_unregister(void); void g_dnl_set_serialnumber(char *); +void g_dnl_set_product(const char *s); bool g_dnl_detach(void); void g_dnl_trigger_detach(void); -- cgit v1.3.1 From 5cf39720af39872bef541371cf7c35b96c7f0063 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 18 Mar 2020 09:24:47 +0100 Subject: dfu: add prototype for dfu_transaction_initiate/cleanup Add prototype for function dfu_transaction_initiate and dfu_transaction_cleanup to avoid warning with W=1. Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- include/dfu.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/dfu.h b/include/dfu.h index fb5260d903a..2f0e335ec09 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -209,6 +209,9 @@ void dfu_initiated_callback(struct dfu_entity *dfu); */ void dfu_flush_callback(struct dfu_entity *dfu); +int dfu_transaction_initiate(struct dfu_entity *dfu, bool read); +void dfu_transaction_cleanup(struct dfu_entity *dfu); + /* * dfu_defer_flush - pointer to store dfu_entity for deferred flashing. * It should be NULL when not used. -- cgit v1.3.1