summaryrefslogtreecommitdiff
path: root/arch/arm
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@st.com>2020-03-18 09:24:55 +0100
committerPatrick Delaunay <patrick.delaunay@st.com>2020-05-14 09:02:12 +0200
commit8f035f7b48f79460d296824b37b69dd5cc0b9567 (patch)
tree4c8213413b0ba24698fa641bc5ed752280b5463e /arch/arm
parenteb845d6f8b72c5c12ecc8a455418e0dd7b8b79a1 (diff)
stm32mp: stm32prog: adapt the MTD partitions
Dynamically adapt the MTD partitions in NOR/NAND/SPI-NAND when stm32prog command detects in the parsed flash layout files: - a fsbl partition in NOR. - a tee partition in NOR/NAND/SPI-NAND Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c17
-rw-r--r--arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c17
-rw-r--r--arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h2
-rw-r--r--arch/arm/mach-stm32mp/include/mach/stm32prog.h4
4 files changed, 40 insertions, 0 deletions
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
index 3e8b426444..581f97e0b5 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <command.h>
#include <dfu.h>
+#include <asm/arch/stm32prog.h>
#include "stm32prog.h"
struct stm32prog_data *stm32prog_data;
@@ -94,3 +95,19 @@ U_BOOT_CMD(stm32prog, 5, 0, do_stm32prog,
"<addr> = address of flashlayout\n"
"<size> = size of flashlayout\n"
);
+
+bool stm32prog_get_tee_partitions(void)
+{
+ if (stm32prog_data)
+ return stm32prog_data->tee_detected;
+
+ return false;
+}
+
+bool stm32prog_get_fsbl_nor(void)
+{
+ if (stm32prog_data)
+ return stm32prog_data->fsbl_nor_detected;
+
+ return false;
+}
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 93ee6a55a1..0140fd479d 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -762,6 +762,8 @@ static int treat_partition_list(struct stm32prog_data *data)
INIT_LIST_HEAD(&data->dev[j].part_list);
}
+ data->tee_detected = false;
+ data->fsbl_nor_detected = false;
for (i = 0; i < data->part_nb; i++) {
part = &data->part_array[i];
part->alt_id = -1;
@@ -806,6 +808,21 @@ static int treat_partition_list(struct stm32prog_data *data)
stm32prog_err("Layout: too many device");
return -EINVAL;
}
+ switch (part->target) {
+ case STM32PROG_NOR:
+ if (!data->fsbl_nor_detected &&
+ !strncmp(part->name, "fsbl", 4))
+ data->fsbl_nor_detected = true;
+ /* fallthrough */
+ case STM32PROG_NAND:
+ case STM32PROG_SPI_NAND:
+ if (!data->tee_detected &&
+ !strncmp(part->name, "tee", 3))
+ data->tee_detected = true;
+ break;
+ default:
+ break;
+ }
part->dev = &data->dev[j];
if (!IS_SELECT(part))
part->dev->full_update = false;
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
index 8e635da3a4..7f06627ebc 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
@@ -107,6 +107,8 @@ struct stm32prog_data {
struct stm32prog_dev_t dev[STM32PROG_MAX_DEV]; /* array of device */
int part_nb; /* nb of partition */
struct stm32prog_part_t *part_array; /* array of partition */
+ bool tee_detected;
+ bool fsbl_nor_detected;
/* command internal information */
unsigned int phase;
diff --git a/arch/arm/mach-stm32mp/include/mach/stm32prog.h b/arch/arm/mach-stm32mp/include/mach/stm32prog.h
index c10bff09c8..c080b9cc42 100644
--- a/arch/arm/mach-stm32mp/include/mach/stm32prog.h
+++ b/arch/arm/mach-stm32mp/include/mach/stm32prog.h
@@ -10,3 +10,7 @@ int stm32prog_write_medium_virt(struct dfu_entity *dfu, u64 offset,
int stm32prog_read_medium_virt(struct dfu_entity *dfu, u64 offset,
void *buf, long *len);
int stm32prog_get_medium_size_virt(struct dfu_entity *dfu, u64 *size);
+
+bool stm32prog_get_tee_partitions(void);
+
+bool stm32prog_get_fsbl_nor(void);