summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-05-14 15:44:06 +0300
committerTom Rini <trini@konsulko.com>2020-05-14 15:44:06 +0300
commite2b86e23cebc9dfaca2e7b7e53b10fa27d09f4e9 (patch)
tree0e8b20ee7e4b9426913dc905392386c1c28ee0f2 /board
parentfe16786149c8f1b2db95ed614a760bc443da6472 (diff)
parent1b28a5e2b00a9bf3523cc63694baa03f23604619 (diff)
downloadu-boot-e2b86e23cebc9dfaca2e7b7e53b10fa27d09f4e9.tar.xz
Merge tag 'u-boot-stm32-20200514' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm
- stm32mp1: migrate MTD and DFU configuration in Kconfig - stm32mp1: add command stm32prog - stm32mp1: several board and arch updates - stm32mp1: activate data cache in SPL and before relocation - Many improvment for AV96 board and DHCOR SoM (add new defconfig, DDR3 coding on DHCOR SoM, split between board and SOM Synchronize DDR setttings on DH SoMs, setting for I2C EEPROM) - clk: stm32mp1: fix CK_MPU calculation - DT alignment of stm32mp1 device tree with Linux 5.7-rc2
Diffstat (limited to 'board')
-rw-r--r--board/dhelectronics/dh_stm32mp1/Kconfig3
-rw-r--r--board/dhelectronics/dh_stm32mp1/MAINTAINERS1
-rw-r--r--board/dhelectronics/dh_stm32mp1/Makefile3
-rw-r--r--board/dhelectronics/dh_stm32mp1/board.c232
-rw-r--r--board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its39
-rw-r--r--board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its39
-rw-r--r--board/st/common/Kconfig64
-rw-r--r--board/st/common/Makefile5
-rw-r--r--board/st/common/stm32mp_dfu.c245
-rw-r--r--board/st/common/stm32mp_mtdparts.c167
-rw-r--r--board/st/stm32mp1/MAINTAINERS1
-rw-r--r--board/st/stm32mp1/stm32mp1.c357
12 files changed, 733 insertions, 423 deletions
diff --git a/board/dhelectronics/dh_stm32mp1/Kconfig b/board/dhelectronics/dh_stm32mp1/Kconfig
index 8eab986640..1fc792c9d1 100644
--- a/board/dhelectronics/dh_stm32mp1/Kconfig
+++ b/board/dhelectronics/dh_stm32mp1/Kconfig
@@ -7,7 +7,7 @@ config SYS_VENDOR
default "dhelectronics"
config SYS_CONFIG_NAME
- default "stm32mp1"
+ default "dh_stm32mp1"
config ENV_SECT_SIZE
default 0x10000 if ENV_IS_IN_SPI_FLASH
@@ -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/dhelectronics/dh_stm32mp1/MAINTAINERS b/board/dhelectronics/dh_stm32mp1/MAINTAINERS
index 1511ecb65d..fd70131f9e 100644
--- a/board/dhelectronics/dh_stm32mp1/MAINTAINERS
+++ b/board/dhelectronics/dh_stm32mp1/MAINTAINERS
@@ -4,4 +4,5 @@ S: Maintained
F: arch/arm/dts/stm32mp15xx-dhcom*
F: board/dhelectronics/dh_stm32mp1/
F: configs/stm32mp15_dhcom_basic_defconfig
+F: configs/stm32mp15_dhcor_basic_defconfig
F: include/configs/stm32mp1.h
diff --git a/board/dhelectronics/dh_stm32mp1/Makefile b/board/dhelectronics/dh_stm32mp1/Makefile
index b42c4e4c04..e8f218da08 100644
--- a/board/dhelectronics/dh_stm32mp1/Makefile
+++ b/board/dhelectronics/dh_stm32mp1/Makefile
@@ -8,3 +8,6 @@ obj-y += ../../st/stm32mp1/spl.o
endif
obj-y += ../../st/stm32mp1/board.o board.o
+
+obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o
+obj-$(CONFIG_SET_DFU_ALT_INFO) += ../../st/common/stm32mp_dfu.o
diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index 322558157e..85d56f6082 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -116,9 +116,7 @@ int checkboard(void)
const char *fdt_compat;
int fdt_compat_len;
- if (IS_ENABLED(CONFIG_STM32MP1_OPTEE))
- mode = "trusted with OP-TEE";
- else if (IS_ENABLED(CONFIG_TFABOOT))
+ if (IS_ENABLED(CONFIG_TFABOOT))
mode = "trusted";
else
mode = "basic";
@@ -133,6 +131,89 @@ int checkboard(void)
return 0;
}
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+static u8 brdcode __section("data");
+static u8 ddr3code __section("data");
+static u8 somcode __section("data");
+
+static void board_get_coding_straps(void)
+{
+ struct gpio_desc gpio[4];
+ ofnode node;
+ int i, ret;
+
+ node = ofnode_path("/config");
+ if (!ofnode_valid(node)) {
+ printf("%s: no /config node?\n", __func__);
+ return;
+ }
+
+ brdcode = 0;
+ ddr3code = 0;
+ somcode = 0;
+
+ ret = gpio_request_list_by_name_nodev(node, "dh,som-coding-gpios",
+ gpio, ARRAY_SIZE(gpio),
+ GPIOD_IS_IN);
+ for (i = 0; i < ret; i++)
+ somcode |= !!dm_gpio_get_value(&(gpio[i])) << i;
+
+ ret = gpio_request_list_by_name_nodev(node, "dh,ddr3-coding-gpios",
+ gpio, ARRAY_SIZE(gpio),
+ GPIOD_IS_IN);
+ for (i = 0; i < ret; i++)
+ ddr3code |= !!dm_gpio_get_value(&(gpio[i])) << i;
+
+ ret = gpio_request_list_by_name_nodev(node, "dh,board-coding-gpios",
+ gpio, ARRAY_SIZE(gpio),
+ GPIOD_IS_IN);
+ for (i = 0; i < ret; i++)
+ brdcode |= !!dm_gpio_get_value(&(gpio[i])) << i;
+
+ printf("Code: SoM:rev=%d,ddr3=%d Board:rev=%d\n",
+ somcode, ddr3code, brdcode);
+}
+
+int board_stm32mp1_ddr_config_name_match(struct udevice *dev,
+ const char *name)
+{
+ if (ddr3code == 1 &&
+ !strcmp(name, "st,ddr3l-dhsom-1066-888-bin-g-2x1gb-533mhz"))
+ return 0;
+
+ if (ddr3code == 2 &&
+ !strcmp(name, "st,ddr3l-dhsom-1066-888-bin-g-2x2gb-533mhz"))
+ return 0;
+
+ if (ddr3code == 3 &&
+ !strcmp(name, "st,ddr3l-dhsom-1066-888-bin-g-2x4gb-533mhz"))
+ return 0;
+
+ return -EINVAL;
+}
+
+int board_early_init_f(void)
+{
+ board_get_coding_straps();
+
+ return 0;
+}
+
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+ char test[20];
+
+ snprintf(test, sizeof(test), "somrev%d_boardrev%d", somcode, brdcode);
+
+ if (!strcmp(name, test))
+ return 0;
+
+ return -EINVAL;
+}
+#endif
+#endif
+
static void board_key_check(void)
{
#if defined(CONFIG_FASTBOOT) || defined(CONFIG_CMD_STM32PROG)
@@ -478,6 +559,12 @@ int board_late_init(void)
if (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb"))
env_set("bootdelay", "0");
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+ env_set_ulong("dh_som_rev", somcode);
+ env_set_ulong("dh_board_rev", brdcode);
+ env_set_ulong("dh_ddr3_code", ddr3code);
+#endif
+
return 0;
}
@@ -570,95 +657,6 @@ enum env_location env_get_location(enum env_operation op, int prio)
#endif
}
-#ifdef CONFIG_SYS_MTDPARTS_RUNTIME
-
-#define MTDPARTS_LEN 256
-#define MTDIDS_LEN 128
-
-/**
- * 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_<dev>
- */
-static void board_get_mtdparts(const char *dev,
- char *mtdids,
- char *mtdparts)
-{
- char env_name[32] = "mtdparts_";
- char tmp_mtdparts[MTDPARTS_LEN];
- const char *tmp;
-
- /* name of env variable to read = mtdparts_<dev> */
- strcat(env_name, dev);
- tmp = env_get_mtdparts(env_name, tmp_mtdparts);
- if (tmp) {
- /* mtdids: "<dev>=<dev>, ...." */
- if (mtdids[0] != '\0')
- strcat(mtdids, ",");
- strcat(mtdids, dev);
- strcat(mtdids, "=");
- strcat(mtdids, dev);
-
- /* mtdparts: "mtdparts=<dev>:<mtdparts_<dev>>;..." */
- 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);
- }
-}
-
-void board_mtdparts_default(const char **mtdids, const char **mtdparts)
-{
- struct udevice *dev;
- static char parts[3 * MTDPARTS_LEN + 1];
- static char ids[MTDIDS_LEN + 1];
- static bool mtd_initialized;
-
- if (mtd_initialized) {
- *mtdids = ids;
- *mtdparts = parts;
- return;
- }
-
- memset(parts, 0, sizeof(parts));
- memset(ids, 0, sizeof(ids));
-
- /* probe all MTD devices */
- for (uclass_first_device(UCLASS_MTD, &dev);
- dev;
- uclass_next_device(&dev)) {
- pr_debug("mtd device = %s\n", dev->name);
- }
-
- if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
- board_get_mtdparts("nor0", ids, parts);
-
- mtd_initialized = true;
- *mtdids = ids;
- *mtdparts = parts;
- debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
-}
-#endif
-
#if defined(CONFIG_OF_BOARD_SETUP)
int ft_board_setup(void *blob, bd_t *bd)
{
@@ -666,56 +664,6 @@ int ft_board_setup(void *blob, bd_t *bd)
}
#endif
-#ifdef CONFIG_SET_DFU_ALT_INFO
-#define DFU_ALT_BUF_LEN SZ_1K
-
-static void board_get_alt_info(const char *dev, char *buff)
-{
- char var_name[32] = "dfu_alt_info_";
- int ret;
-
- ALLOC_CACHE_ALIGN_BUFFER(char, tmp_alt, DFU_ALT_BUF_LEN);
-
- /* name of env variable to read = dfu_alt_info_<dev> */
- 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);
- }
-}
-
-void set_dfu_alt_info(char *interface, char *devstr)
-{
- struct udevice *dev;
-
- ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
-
- if (env_get("dfu_alt_info"))
- return;
-
- memset(buf, 0, sizeof(buf));
-
- /* probe all MTD devices */
- mtd_probe_devices();
-
- board_get_alt_info("ram", buf);
-
- if (!uclass_get_device(UCLASS_MMC, 0, &dev))
- board_get_alt_info("mmc0", 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);
-
- env_set("dfu_alt_info", buf);
- puts("DFU alt info setting: done\n");
-}
-#endif
-
static void board_copro_image_process(ulong fw_image, size_t fw_size)
{
int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */
diff --git a/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its b/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its
new file mode 100644
index 0000000000..2776c41af1
--- /dev/null
+++ b/board/dhelectronics/dh_stm32mp1/u-boot-dhcom.its
@@ -0,0 +1,39 @@
+/dts-v1/;
+
+/ {
+ description = "U-Boot mainline";
+ #address-cells = <1>;
+
+ images {
+ uboot {
+ description = "U-Boot (32-bit)";
+ data = /incbin/("u-boot-nodtb.bin");
+ type = "standalone";
+ os = "U-Boot";
+ arch = "arm";
+ compression = "none";
+ load = <0xc0100000>;
+ entry = <0xc0100000>;
+ };
+
+ fdt-1 {
+ description = ".dtb";
+ data = /incbin/("arch/arm/dts/stm32mp15xx-dhcom-pdk2.dtb");
+ type = "flat_dt";
+ arch = "arm";
+ compression = "none";
+ };
+ };
+
+ configurations {
+ default = "config-1";
+
+ config-1 {
+ description = "somrev0_boardrev0"; /* SoM+board model */
+ loadables = "uboot";
+ fdt = "fdt-1";
+ };
+
+ /* Add 587-100..587-400 with fdt-2..fdt-4 here */
+ };
+};
diff --git a/board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its b/board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its
new file mode 100644
index 0000000000..8844508f1a
--- /dev/null
+++ b/board/dhelectronics/dh_stm32mp1/u-boot-dhcor.its
@@ -0,0 +1,39 @@
+/dts-v1/;
+
+/ {
+ description = "U-Boot mainline";
+ #address-cells = <1>;
+
+ images {
+ uboot {
+ description = "U-Boot (32-bit)";
+ data = /incbin/("u-boot-nodtb.bin");
+ type = "standalone";
+ os = "U-Boot";
+ arch = "arm";
+ compression = "none";
+ load = <0xc0100000>;
+ entry = <0xc0100000>;
+ };
+
+ fdt-1 {
+ description = ".dtb";
+ data = /incbin/("arch/arm/dts/stm32mp15xx-dhcor-avenger96.dtb");
+ type = "flat_dt";
+ arch = "arm";
+ compression = "none";
+ };
+ };
+
+ configurations {
+ default = "config-1";
+
+ config-1 {
+ description = "somrev0_boardrev1"; /* SoM+board model */
+ loadables = "uboot";
+ fdt = "fdt-1";
+ };
+
+ /* Add 586-200..586-400 with fdt-2..fdt-4 here */
+ };
+};
diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig
index af01ca4891..015ba40939 100644
--- a/board/st/common/Kconfig
+++ b/board/st/common/Kconfig
@@ -5,3 +5,67 @@ config CMD_STBOARD
help
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"
+ 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/Makefile b/board/st/common/Makefile
index 8553606b90..aa030bacd8 100644
--- a/board/st/common/Makefile
+++ b/board/st/common/Makefile
@@ -4,3 +4,8 @@
#
obj-$(CONFIG_CMD_STBOARD) += cmd_stboard.o
+
+ifeq ($(CONFIG_ARCH_STM32MP),y)
+obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += stm32mp_mtdparts.o
+obj-$(CONFIG_SET_DFU_ALT_INFO) += stm32mp_dfu.o
+endif
diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
new file mode 100644
index 0000000000..3bd005bb04
--- /dev/null
+++ b/board/st/common/stm32mp_dfu.c
@@ -0,0 +1,245 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
+ */
+
+#include <common.h>
+#include <blk.h>
+#include <dfu.h>
+#include <env.h>
+#include <memalign.h>
+#include <misc.h>
+#include <mtd.h>
+#include <mtd_node.h>
+#include <asm/arch/stm32prog.h>
+
+#define DFU_ALT_BUF_LEN SZ_1K
+
+static void board_get_alt_info_mmc(struct udevice *dev, char *buf)
+{
+ 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;
+ }
+
+ 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);
+ }
+}
+
+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);
+ }
+}
+
+void set_dfu_alt_info(char *interface, char *devstr)
+{
+ struct udevice *dev;
+ struct mtd_info *mtd;
+
+ ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
+
+ if (env_get("dfu_alt_info"))
+ return;
+
+ memset(buf, 0, sizeof(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_mmc(dev, buf);
+
+ if (!uclass_get_device(UCLASS_MMC, 1, &dev))
+ 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);
+
+ if (IS_ENABLED(CONFIG_PMIC_STPMIC1))
+ strncat(buf, "&virt 1=PMIC", DFU_ALT_BUF_LEN);
+#endif
+
+ env_set("dfu_alt_info", buf);
+ puts("DFU alt info setting: done\n");
+}
+
+#if CONFIG_IS_ENABLED(DFU_VIRT)
+#include <dfu.h>
+#include <power/stpmic1.h>
+
+static int dfu_otp_read(u64 offset, u8 *buffer, long *size)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_GET_DRIVER(stm32mp_bsec),
+ &dev);
+ if (ret)
+ return ret;
+
+ ret = misc_read(dev, offset + STM32_BSEC_OTP_OFFSET, buffer, *size);
+ if (ret >= 0) {
+ *size = ret;
+ ret = 0;
+ }
+
+ return 0;
+}
+
+static int dfu_pmic_read(u64 offset, u8 *buffer, long *size)
+{
+ int ret;
+#ifdef CONFIG_PMIC_STPMIC1
+ struct udevice *dev;
+
+ ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_GET_DRIVER(stpmic1_nvm),
+ &dev);
+ if (ret)
+ return ret;
+
+ ret = misc_read(dev, 0xF8 + offset, buffer, *size);
+ if (ret >= 0) {
+ *size = ret;
+ ret = 0;
+ }
+ if (ret == -EACCES) {
+ *size = 0;
+ ret = 0;
+ }
+#else
+ pr_err("PMIC update not supported");
+ ret = -EOPNOTSUPP;
+#endif
+
+ return ret;
+}
+
+int dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
+ void *buf, long *len)
+{
+ switch (dfu->data.virt.dev_num) {
+ case 0x0:
+ return dfu_otp_read(offset, buf, len);
+ case 0x1:
+ return dfu_pmic_read(offset, buf, len);
+ }
+
+ if (CONFIG_IS_ENABLED(CMD_STM32PROG) &&
+ dfu->data.virt.dev_num >= STM32PROG_VIRT_FIRST_DEV_NUM)
+ return stm32prog_read_medium_virt(dfu, offset, buf, len);
+
+ *len = 0;
+ return 0;
+}
+
+int dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset,
+ void *buf, long *len)
+{
+ if (CONFIG_IS_ENABLED(CMD_STM32PROG) &&
+ dfu->data.virt.dev_num >= STM32PROG_VIRT_FIRST_DEV_NUM)
+ return stm32prog_write_medium_virt(dfu, offset, buf, len);
+
+ return -EOPNOTSUPP;
+}
+
+int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size)
+{
+ if (CONFIG_IS_ENABLED(CMD_STM32PROG) &&
+ dfu->data.virt.dev_num >= STM32PROG_VIRT_FIRST_DEV_NUM)
+ return stm32prog_get_medium_size_virt(dfu, size);
+
+ *size = SZ_1K;
+
+ return 0;
+}
+
+#endif
diff --git a/board/st/common/stm32mp_mtdparts.c b/board/st/common/stm32mp_mtdparts.c
new file mode 100644
index 0000000000..9f5897f8c8
--- /dev/null
+++ b/board/st/common/stm32mp_mtdparts.c
@@ -0,0 +1,167 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
+ */
+
+#include <common.h>
+#include <dfu.h>
+#include <dm.h>
+#include <env.h>
+#include <env_internal.h>
+#include <mtd.h>
+#include <mtd_node.h>
+#include <tee.h>
+#include <asm/arch/stm32prog.h>
+#include <asm/arch/sys_proto.h>
+
+#define MTDPARTS_LEN 256
+#define MTDIDS_LEN 128
+
+/*
+ * Get a global data pointer
+ */
+DECLARE_GLOBAL_DATA_PTR;
+
+/**
+ * update the variables "mtdids" and "mtdparts" with boot, tee and user strings
+ */
+static void board_set_mtdparts(const char *dev,
+ char *mtdids,
+ char *mtdparts,
+ const char *boot,
+ const char *tee,
+ const char *user)
+{
+ /* mtdids: "<dev>=<dev>, ...." */
+ if (mtdids[0] != '\0')
+ strcat(mtdids, ",");
+ strcat(mtdids, dev);
+ strcat(mtdids, "=");
+ strcat(mtdids, dev);
+
+ /* mtdparts: "mtdparts=<dev>:<mtdparts_<dev>>;..." */
+ 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 (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)
+{
+ struct mtd_info *mtd;
+ struct udevice *dev;
+ static char parts[3 * MTDPARTS_LEN + 1];
+ static char ids[MTDIDS_LEN + 1];
+ static bool mtd_initialized;
+ bool tee, nor, nand, spinand, serial;
+
+ if (mtd_initialized) {
+ *mtdids = ids;
+ *mtdparts = parts;
+ return;
+ }
+
+ tee = false;
+ nor = false;
+ nand = false;
+ spinand = false;
+ serial = false;
+
+ switch (get_bootmode() & TAMP_BOOT_DEVICE_MASK) {
+ case BOOT_SERIAL_UART:
+ case BOOT_SERIAL_USB:
+ serial = true;
+ if (CONFIG_IS_ENABLED(CMD_STM32PROG)) {
+ tee = stm32prog_get_tee_partitions();
+ nor = stm32prog_get_fsbl_nor();
+ }
+ nand = true;
+ spinand = true;
+ break;
+ case BOOT_FLASH_NAND:
+ nand = true;
+ break;
+ case BOOT_FLASH_SPINAND:
+ spinand = true;
+ break;
+ case BOOT_FLASH_NOR:
+ nor = true;
+ break;
+ default:
+ break;
+ }
+
+ if (!serial && CONFIG_IS_ENABLED(OPTEE) &&
+ tee_find_device(NULL, NULL, NULL, NULL))
+ tee = true;
+
+ memset(parts, 0, sizeof(parts));
+ memset(ids, 0, sizeof(ids));
+
+ /* probe all MTD devices */
+ for (uclass_first_device(UCLASS_MTD, &dev);
+ dev;
+ uclass_next_device(&dev)) {
+ pr_debug("mtd device = %s\n", dev->name);
+ }
+
+ if (nor || nand) {
+ mtd = get_mtd_device_nm("nand0");
+ if (!IS_ERR_OR_NULL(mtd)) {
+ const char *mtd_boot = CONFIG_MTDPARTS_NAND0_BOOT;
+ const char *mtd_tee = CONFIG_MTDPARTS_NAND0_TEE;
+
+ board_set_mtdparts("nand0", ids, parts,
+ !nor ? mtd_boot : NULL,
+ !nor && tee ? mtd_tee : NULL,
+ "-(UBI)");
+ put_mtd_device(mtd);
+ }
+ }
+
+ if (nor || spinand) {
+ mtd = get_mtd_device_nm("spi-nand0");
+ if (!IS_ERR_OR_NULL(mtd)) {
+ const char *mtd_boot = CONFIG_MTDPARTS_SPINAND0_BOOT;
+ const char *mtd_tee = CONFIG_MTDPARTS_SPINAND0_TEE;
+
+ board_set_mtdparts("spi-nand0", ids, parts,
+ !nor ? mtd_boot : NULL,
+ !nor && tee ? mtd_tee : NULL,
+ "-(UBI)");
+ put_mtd_device(mtd);
+ }
+ }
+
+ if (nor) {
+ if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) {
+ const char *mtd_boot = CONFIG_MTDPARTS_NOR0_BOOT;
+ const char *mtd_tee = CONFIG_MTDPARTS_NOR0_TEE;
+
+ board_set_mtdparts("nor0", ids, parts,
+ mtd_boot,
+ tee ? mtd_tee : NULL,
+ "-(nor_user)");
+ }
+ }
+
+ mtd_initialized = true;
+ *mtdids = ids;
+ *mtdparts = parts;
+ debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
+}
diff --git a/board/st/stm32mp1/MAINTAINERS b/board/st/stm32mp1/MAINTAINERS
index 2930947716..96c4559033 100644
--- a/board/st/stm32mp1/MAINTAINERS
+++ b/board/st/stm32mp1/MAINTAINERS
@@ -6,6 +6,5 @@ S: Maintained
F: arch/arm/dts/stm32mp15*
F: board/st/stm32mp1/
F: configs/stm32mp15_basic_defconfig
-F: configs/stm32mp15_optee_defconfig
F: configs/stm32mp15_trusted_defconfig
F: include/configs/stm32mp1.h
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 45068b1cd9..33cb7f6c4d 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -7,7 +7,6 @@
#include <bootm.h>
#include <clk.h>
#include <config.h>
-#include <dfu.h>
#include <dm.h>
#include <env.h>
#include <env_internal.h>
@@ -18,9 +17,7 @@
#include <init.h>
#include <led.h>
#include <malloc.h>
-#include <memalign.h>
#include <misc.h>
-#include <mtd.h>
#include <mtd_node.h>
#include <netdev.h>
#include <phy.h>
@@ -35,6 +32,7 @@
#include <asm/arch/sys_proto.h>
#include <jffs2/load_kernel.h>
#include <linux/err.h>
+#include <linux/iopoll.h>
#include <power/regulator.h>
#include <usb/dwc2_udc.h>
@@ -90,9 +88,7 @@ int checkboard(void)
const char *fdt_compat;
int fdt_compat_len;
- if (IS_ENABLED(CONFIG_STM32MP1_OPTEE))
- mode = "trusted with OP-TEE";
- else if (IS_ENABLED(TFABOOT))
+ if (IS_ENABLED(CONFIG_TFABOOT))
mode = "trusted";
else
mode = "basic";
@@ -260,7 +256,6 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
#endif /* CONFIG_USB_GADGET */
-#ifdef CONFIG_LED
static int get_led(struct udevice **dev, char *led_string)
{
char *led_name;
@@ -286,6 +281,9 @@ static int setup_led(enum led_state_t cmd)
struct udevice *dev;
int ret;
+ if (!CONFIG_IS_ENABLED(LED))
+ return 0;
+
ret = get_led(&dev, "u-boot,boot-led");
if (ret)
return ret;
@@ -293,31 +291,29 @@ static int setup_led(enum led_state_t cmd)
ret = led_set_state(dev, cmd);
return ret;
}
-#endif
static void __maybe_unused led_error_blink(u32 nb_blink)
{
-#ifdef CONFIG_LED
int ret;
struct udevice *led;
u32 i;
-#endif
if (!nb_blink)
return;
-#ifdef CONFIG_LED
- ret = get_led(&led, "u-boot,error-led");
- if (!ret) {
- /* make u-boot,error-led blinking */
- /* if U32_MAX and 125ms interval, for 17.02 years */
- for (i = 0; i < 2 * nb_blink; i++) {
- led_set_state(led, LEDST_TOGGLE);
- mdelay(125);
- WATCHDOG_RESET();
+ if (CONFIG_IS_ENABLED(LED)) {
+ ret = get_led(&led, "u-boot,error-led");
+ if (!ret) {
+ /* make u-boot,error-led blinking */
+ /* if U32_MAX and 125ms interval, for 17.02 years */
+ for (i = 0; i < 2 * nb_blink; i++) {
+ led_set_state(led, LEDST_TOGGLE);
+ mdelay(125);
+ WATCHDOG_RESET();
+ }
+ led_set_state(led, LEDST_ON);
}
}
-#endif
/* infinite: the boot process must be stopped */
if (nb_blink == U32_MAX)
@@ -435,7 +431,7 @@ static int board_check_usb_power(void)
if (max_uV > USB_WARNING_LOW_THRESHOLD_UV &&
max_uV <= USB_START_LOW_THRESHOLD_UV &&
min_uV <= USB_LOW_THRESHOLD_UV) {
- pr_err("* WARNING 1.5mA power supply detected *\n");
+ pr_err("* WARNING 1.5A power supply detected *\n");
nb_blink = 3;
}
@@ -468,10 +464,10 @@ static void sysconf_init(void)
struct udevice *pwr_dev;
struct udevice *pwr_reg;
struct udevice *dev;
- int ret;
u32 otp = 0;
#endif
- u32 bootr;
+ int ret;
+ u32 bootr, val;
syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
@@ -548,8 +544,15 @@ static void sysconf_init(void)
*/
writel(SYSCFG_CMPENSETR_MPU_EN, syscfg + SYSCFG_CMPENSETR);
- while (!(readl(syscfg + SYSCFG_CMPCR) & SYSCFG_CMPCR_READY))
- ;
+ /* poll until ready (1s timeout) */
+ ret = readl_poll_timeout(syscfg + SYSCFG_CMPCR, val,
+ val & SYSCFG_CMPCR_READY,
+ 1000000);
+ if (ret) {
+ pr_err("SYSCFG: I/O compensation failed, timeout.\n");
+ led_error_blink(10);
+ }
+
clrbits_le32(syscfg + SYSCFG_CMPCR, SYSCFG_CMPCR_SW_CTRL);
#endif
}
@@ -621,6 +624,38 @@ static bool board_is_dk2(void)
}
#endif
+static bool board_is_ev1(void)
+{
+ if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
+ (of_machine_is_compatible("st,stm32mp157a-ev1") ||
+ of_machine_is_compatible("st,stm32mp157c-ev1") ||
+ of_machine_is_compatible("st,stm32mp157d-ev1") ||
+ of_machine_is_compatible("st,stm32mp157f-ev1")))
+ return true;
+
+ return false;
+}
+
+/* touchscreen driver: only used for pincontrol configuration */
+static const struct udevice_id goodix_ids[] = {
+ { .compatible = "goodix,gt9147", },
+ { }
+};
+
+U_BOOT_DRIVER(goodix) = {
+ .name = "goodix",
+ .id = UCLASS_NOP,
+ .of_match = goodix_ids,
+};
+
+static void board_ev1_init(void)
+{
+ struct udevice *dev;
+
+ /* configure IRQ line on EV1 for touchscreen before LCD reset */
+ uclass_get_device_by_driver(UCLASS_NOP, DM_GET_DRIVER(goodix), &dev);
+}
+
/* board dependent setup after realloc */
int board_init(void)
{
@@ -638,6 +673,9 @@ int board_init(void)
board_key_check();
+ if (board_is_ev1())
+ board_ev1_init();
+
#ifdef CONFIG_DM_REGULATOR
if (board_is_dk2())
dk2_i2c1_fix();
@@ -650,12 +688,13 @@ int board_init(void)
if (CONFIG_IS_ENABLED(LED))
led_default_state();
+ setup_led(LEDST_ON);
+
return 0;
}
int board_late_init(void)
{
- char *boot_device;
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
const void *fdt_compat;
int fdt_compat_len;
@@ -667,10 +706,19 @@ int board_late_init(void)
fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
&fdt_compat_len);
if (fdt_compat && fdt_compat_len) {
- if (strncmp(fdt_compat, "st,", 3) != 0)
+ if (strncmp(fdt_compat, "st,", 3) != 0) {
env_set("board_name", fdt_compat);
- else
+ } else {
+ char dtb_name[256];
+ int buf_len = sizeof(dtb_name);
+
env_set("board_name", fdt_compat + 3);
+
+ strncpy(dtb_name, fdt_compat + 3, buf_len);
+ buf_len -= strlen(fdt_compat + 3);
+ strncat(dtb_name, ".dtb", buf_len);
+ env_set("fdtfile", dtb_name);
+ }
}
ret = uclass_get_device_by_driver(UCLASS_MISC,
DM_GET_DRIVER(stm32mp_bsec),
@@ -694,19 +742,12 @@ int board_late_init(void)
board_check_usb_power();
#endif /* CONFIG_ADC */
- /* Check the boot-source to disable bootdelay */
- boot_device = env_get("boot_device");
- if (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb"))
- env_set("bootdelay", "0");
-
return 0;
}
void board_quiesce_devices(void)
{
-#ifdef CONFIG_LED
setup_led(LEDST_OFF);
-#endif
}
/* eth init function : weak called in eqos driver */
@@ -794,6 +835,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
@@ -828,114 +870,13 @@ const char *env_ext4_get_dev_part(void)
}
#endif
-#ifdef CONFIG_SYS_MTDPARTS_RUNTIME
-
-#define MTDPARTS_LEN 256
-#define MTDIDS_LEN 128
-
-/**
- * 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_<dev>
- */
-static void board_get_mtdparts(const char *dev,
- char *mtdids,
- char *mtdparts)
-{
- char env_name[32] = "mtdparts_";
- char tmp_mtdparts[MTDPARTS_LEN];
- const char *tmp;
-
- /* name of env variable to read = mtdparts_<dev> */
- strcat(env_name, dev);
- tmp = env_get_mtdparts(env_name, tmp_mtdparts);
- if (tmp) {
- /* mtdids: "<dev>=<dev>, ...." */
- if (mtdids[0] != '\0')
- strcat(mtdids, ",");
- strcat(mtdids, dev);
- strcat(mtdids, "=");
- strcat(mtdids, dev);
-
- /* mtdparts: "mtdparts=<dev>:<mtdparts_<dev>>;..." */
- 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);
- }
-}
-
-void board_mtdparts_default(const char **mtdids, const char **mtdparts)
-{
- struct mtd_info *mtd;
- struct udevice *dev;
- static char parts[3 * MTDPARTS_LEN + 1];
- static char ids[MTDIDS_LEN + 1];
- static bool mtd_initialized;
-
- if (mtd_initialized) {
- *mtdids = ids;
- *mtdparts = parts;
- return;
- }
-
- memset(parts, 0, sizeof(parts));
- memset(ids, 0, sizeof(ids));
-
- /* probe all MTD devices */
- for (uclass_first_device(UCLASS_MTD, &dev);
- dev;
- uclass_next_device(&dev)) {
- pr_debug("mtd device = %s\n", dev->name);
- }
-
- mtd = get_mtd_device_nm("nand0");
- if (!IS_ERR_OR_NULL(mtd)) {
- board_get_mtdparts("nand0", ids, parts);
- put_mtd_device(mtd);
- }
-
- mtd = get_mtd_device_nm("spi-nand0");
- if (!IS_ERR_OR_NULL(mtd)) {
- board_get_mtdparts("spi-nand0", ids, parts);
- put_mtd_device(mtd);
- }
-
- if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
- board_get_mtdparts("nor0", ids, parts);
-
- mtd_initialized = true;
- *mtdids = ids;
- *mtdparts = parts;
- debug("%s:mtdids=%s & mtdparts=%s\n", __func__, ids, parts);
-}
-#endif
-
#if defined(CONFIG_OF_BOARD_SETUP)
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));
@@ -945,148 +886,6 @@ int ft_board_setup(void *blob, bd_t *bd)
}
#endif
-#ifdef CONFIG_SET_DFU_ALT_INFO
-#define DFU_ALT_BUF_LEN SZ_1K
-
-static void board_get_alt_info(const char *dev, char *buff)
-{
- char var_name[32] = "dfu_alt_info_";
- int ret;
-
- ALLOC_CACHE_ALIGN_BUFFER(char, tmp_alt, DFU_ALT_BUF_LEN);
-
- /* name of env variable to read = dfu_alt_info_<dev> */
- 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);
- }
-}
-
-void set_dfu_alt_info(char *interface, char *devstr)
-{
- struct udevice *dev;
- struct mtd_info *mtd;
-
- ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
-
- if (env_get("dfu_alt_info"))
- return;
-
- memset(buf, 0, sizeof(buf));
-
- /* probe all MTD devices */
- mtd_probe_devices();
-
- board_get_alt_info("ram", buf);
-
- if (!uclass_get_device(UCLASS_MMC, 0, &dev))
- board_get_alt_info("mmc0", 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);
-
-#ifdef CONFIG_DFU_VIRT
- strncat(buf, "&virt 0=OTP", DFU_ALT_BUF_LEN);
-
- if (IS_ENABLED(CONFIG_PMIC_STPMIC1))
- strncat(buf, "&virt 1=PMIC", DFU_ALT_BUF_LEN);
-#endif
-
- env_set("dfu_alt_info", buf);
- puts("DFU alt info setting: done\n");
-}
-
-#if CONFIG_IS_ENABLED(DFU_VIRT)
-#include <dfu.h>
-#include <power/stpmic1.h>
-
-static int dfu_otp_read(u64 offset, u8 *buffer, long *size)
-{
- struct udevice *dev;
- int ret;
-
- ret = uclass_get_device_by_driver(UCLASS_MISC,
- DM_GET_DRIVER(stm32mp_bsec),
- &dev);
- if (ret)
- return ret;
-
- ret = misc_read(dev, offset + STM32_BSEC_OTP_OFFSET, buffer, *size);
- if (ret >= 0) {
- *size = ret;
- ret = 0;
- }
-
- return 0;
-}
-
-static int dfu_pmic_read(u64 offset, u8 *buffer, long *size)
-{
- int ret;
-#ifdef CONFIG_PMIC_STPMIC1
- struct udevice *dev;
-
- ret = uclass_get_device_by_driver(UCLASS_MISC,
- DM_GET_DRIVER(stpmic1_nvm),
- &dev);
- if (ret)
- return ret;
-
- ret = misc_read(dev, 0xF8 + offset, buffer, *size);
- if (ret >= 0) {
- *size = ret;
- ret = 0;
- }
- if (ret == -EACCES) {
- *size = 0;
- ret = 0;
- }
-#else
- pr_err("PMIC update not supported");
- ret = -EOPNOTSUPP;
-#endif
-
- return ret;
-}
-
-int dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
- void *buf, long *len)
-{
- switch (dfu->data.virt.dev_num) {
- case 0x0:
- return dfu_otp_read(offset, buf, len);
- case 0x1:
- return dfu_pmic_read(offset, buf, len);
- }
- *len = 0;
- return 0;
-}
-
-int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size)
-{
- *size = SZ_1K;
-
- return 0;
-}
-
-#endif
-
-#endif
-
static void board_copro_image_process(ulong fw_image, size_t fw_size)
{
int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */