mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-21 06:31:31 +00:00
board: stm32mp1: adapt MTD partition for BOOT from NOR or NAND
Dynamically adapt the MTD partitions in NAND and SPI-NAND when boot from NOR or NAND/SPI-NAND is detected. This patch avoids to define the save MTD partition name for NOR and NAND devices and issue with latest kernel: only the needed MTD partitions are defined. For boot from NOR 1/ bootloader (TF-A, U-Boot and OP-TE) in NOR 2/ one large UBI partition in NAND For boot from NAND 1/ bootloader (TF-A, U-Boot and OP-TE) in MTD raw partition 2/ one large UBI partition Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
This commit is contained in:
parent
b664a74537
commit
23229d0309
1 changed files with 60 additions and 21 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include <mtd.h>
|
#include <mtd.h>
|
||||||
#include <mtd_node.h>
|
#include <mtd_node.h>
|
||||||
#include <tee.h>
|
#include <tee.h>
|
||||||
|
#include <asm/arch/sys_proto.h>
|
||||||
|
|
||||||
#define MTDPARTS_LEN 256
|
#define MTDPARTS_LEN 256
|
||||||
#define MTDIDS_LEN 128
|
#define MTDIDS_LEN 128
|
||||||
|
@ -22,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
/**
|
/**
|
||||||
* update the variables "mtdids" and "mtdparts" with boot, tee and user strings
|
* update the variables "mtdids" and "mtdparts" with boot, tee and user strings
|
||||||
*/
|
*/
|
||||||
static void board_get_mtdparts(const char *dev,
|
static void board_set_mtdparts(const char *dev,
|
||||||
char *mtdids,
|
char *mtdids,
|
||||||
char *mtdparts,
|
char *mtdparts,
|
||||||
const char *boot,
|
const char *boot,
|
||||||
|
@ -65,7 +66,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
|
||||||
static char parts[3 * MTDPARTS_LEN + 1];
|
static char parts[3 * MTDPARTS_LEN + 1];
|
||||||
static char ids[MTDIDS_LEN + 1];
|
static char ids[MTDIDS_LEN + 1];
|
||||||
static bool mtd_initialized;
|
static bool mtd_initialized;
|
||||||
bool tee = false;
|
bool tee, nor, nand, spinand;
|
||||||
|
|
||||||
if (mtd_initialized) {
|
if (mtd_initialized) {
|
||||||
*mtdids = ids;
|
*mtdids = ids;
|
||||||
|
@ -73,6 +74,28 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tee = false;
|
||||||
|
nor = false;
|
||||||
|
nand = false;
|
||||||
|
spinand = false;
|
||||||
|
|
||||||
|
switch (get_bootmode() & TAMP_BOOT_DEVICE_MASK) {
|
||||||
|
case BOOT_SERIAL_UART:
|
||||||
|
case BOOT_SERIAL_USB:
|
||||||
|
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 (CONFIG_IS_ENABLED(OPTEE) &&
|
if (CONFIG_IS_ENABLED(OPTEE) &&
|
||||||
tee_find_device(NULL, NULL, NULL, NULL))
|
tee_find_device(NULL, NULL, NULL, NULL))
|
||||||
tee = true;
|
tee = true;
|
||||||
|
@ -87,29 +110,45 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
|
||||||
pr_debug("mtd device = %s\n", dev->name);
|
pr_debug("mtd device = %s\n", dev->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nor || nand) {
|
||||||
mtd = get_mtd_device_nm("nand0");
|
mtd = get_mtd_device_nm("nand0");
|
||||||
if (!IS_ERR_OR_NULL(mtd)) {
|
if (!IS_ERR_OR_NULL(mtd)) {
|
||||||
board_get_mtdparts("nand0", ids, parts,
|
const char *mtd_boot = CONFIG_MTDPARTS_NAND0_BOOT;
|
||||||
CONFIG_MTDPARTS_NAND0_BOOT,
|
const char *mtd_tee = CONFIG_MTDPARTS_NAND0_TEE;
|
||||||
tee ? CONFIG_MTDPARTS_NAND0_TEE : NULL,
|
|
||||||
|
board_set_mtdparts("nand0", ids, parts,
|
||||||
|
!nor ? mtd_boot : NULL,
|
||||||
|
!nor && tee ? mtd_tee : NULL,
|
||||||
"-(UBI)");
|
"-(UBI)");
|
||||||
put_mtd_device(mtd);
|
put_mtd_device(mtd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nor || spinand) {
|
||||||
mtd = get_mtd_device_nm("spi-nand0");
|
mtd = get_mtd_device_nm("spi-nand0");
|
||||||
if (!IS_ERR_OR_NULL(mtd)) {
|
if (!IS_ERR_OR_NULL(mtd)) {
|
||||||
board_get_mtdparts("spi-nand0", ids, parts,
|
const char *mtd_boot = CONFIG_MTDPARTS_SPINAND0_BOOT;
|
||||||
CONFIG_MTDPARTS_SPINAND0_BOOT,
|
const char *mtd_tee = CONFIG_MTDPARTS_SPINAND0_TEE;
|
||||||
tee ? CONFIG_MTDPARTS_SPINAND0_TEE : NULL,
|
|
||||||
|
board_set_mtdparts("spi-nand0", ids, parts,
|
||||||
|
!nor ? mtd_boot : NULL,
|
||||||
|
!nor && tee ? mtd_tee : NULL,
|
||||||
"-(UBI)");
|
"-(UBI)");
|
||||||
put_mtd_device(mtd);
|
put_mtd_device(mtd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
|
if (nor) {
|
||||||
board_get_mtdparts("nor0", ids, parts,
|
if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev)) {
|
||||||
CONFIG_MTDPARTS_NOR0_BOOT,
|
const char *mtd_boot = CONFIG_MTDPARTS_NOR0_BOOT;
|
||||||
tee ? CONFIG_MTDPARTS_NOR0_TEE : NULL,
|
const char *mtd_tee = CONFIG_MTDPARTS_NOR0_TEE;
|
||||||
|
|
||||||
|
board_set_mtdparts("nor0", ids, parts,
|
||||||
|
mtd_boot,
|
||||||
|
tee ? mtd_tee : NULL,
|
||||||
"-(nor_user)");
|
"-(nor_user)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mtd_initialized = true;
|
mtd_initialized = true;
|
||||||
*mtdids = ids;
|
*mtdids = ids;
|
||||||
|
|
Loading…
Add table
Reference in a new issue