[U-Boot] [Uboot-stm32] [PATCH v3 14/15] stm32mp1: board: add spi nand support

Patrice CHOTARD patrice.chotard at st.com
Wed Oct 23 09:20:29 UTC 2019


Hi Patrick

On 10/14/19 9:28 AM, Patrick Delaunay wrote:
> This patch adds the support of the spi nand device in mtdparts command
> and in dfu_alt_info.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  board/st/stm32mp1/stm32mp1.c | 32 +++++++++++++++++++++++++++++---
>  include/configs/stm32mp1.h   | 10 ++++++++--
>  2 files changed, 37 insertions(+), 5 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 62855988e9..e4bdf05cd7 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -862,8 +862,9 @@ static void board_get_mtdparts(const char *dev,
>  
>  void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  {
> +	struct mtd_info *mtd;
>  	struct udevice *dev;
> -	static char parts[2 * MTDPARTS_LEN + 1];
> +	static char parts[3 * MTDPARTS_LEN + 1];
>  	static char ids[MTDIDS_LEN + 1];
>  	static bool mtd_initialized;
>  
> @@ -876,8 +877,24 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
>  	memset(parts, 0, sizeof(parts));
>  	memset(ids, 0, sizeof(ids));
>  
> -	if (!uclass_get_device(UCLASS_MTD, 0, &dev))
> +	/* 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);
> @@ -927,6 +944,7 @@ static void board_get_alt_info(const char *dev, char *buff)
>  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);
>  
> @@ -935,6 +953,9 @@ 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);
>  
>  	if (!uclass_get_device(UCLASS_MMC, 0, &dev))
> @@ -946,9 +967,14 @@ void set_dfu_alt_info(char *interface, char *devstr)
>  	if (!uclass_get_device(UCLASS_SPI_FLASH, 0, &dev))
>  		board_get_alt_info("nor0", buf);
>  
> -	if (!uclass_get_device(UCLASS_MTD, 0, &dev))
> +	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);
> +
>  	env_set("dfu_alt_info", buf);
>  	puts("DFU alt info setting: done\n");
>  }
> diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
> index 4f9024229e..145a644efa 100644
> --- a/include/configs/stm32mp1.h
> +++ b/include/configs/stm32mp1.h
> @@ -124,12 +124,15 @@
>  /* 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_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_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0" \
> +	"mtdparts_spi-nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)\0"
>  
>  #endif /* CONFIG_STM32MP1_OPTEE */
>  
> @@ -152,6 +155,9 @@
>  	"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;" \

Reviewed-by: Patrice Chotard <patrice.chotard at st.com>

Thanks



More information about the U-Boot mailing list