[PATCH 0/4] arm: mach-k3: am64: Add NAND configuration

Hi,
AM64-EVM [1] supports NAND via expansion card.
This series fixes the GPMC memory and NAND drivers and provides NAND configuration for AM642 platform.
The extension card support and NAND DT overlay is still missing so NAND is not yet functional just with this series.
It was tested with NAND overlay [2] manually applied to base AM64-EVM DT.
CI test results are available at https://github.com/u-boot/u-boot/pull/460
[1] https://www.ti.com/tool/TMDS64EVM [2] https://lore.kernel.org/all/20230923080046.5373-2-rogerq@kernel.org/
Roger Quadros (4): memory: ti-gpmc: Fix build mtd: rawnand: omap_gpmc: Use DT provided IO address arm: mach-k3: am642: Define NAND boot device configs: am64x_evm_a53_defconfig: Enable NAND
arch/arm/mach-k3/am642_init.c | 3 +++ arch/arm/mach-k3/include/mach/am64_spl.h | 1 + configs/am64x_evm_a53_defconfig | 32 ++++++++++++++++++++++++ drivers/memory/ti-gpmc.c | 2 +- drivers/mtd/nand/raw/omap_gpmc.c | 19 ++++++++++---- 5 files changed, 51 insertions(+), 6 deletions(-)
base-commit: c2c598e87cfe56f5991730762c00733c5aa9a994 prerequisite-patch-id: e0465f3e924302d1c4bd47f2129b4eb3bd9faead

sys_proto.h no longer exists for K3 platform so drop it. Include sizes.h to so SZ_16M is visible.
Signed-off-by: Roger Quadros rogerq@kernel.org --- drivers/memory/ti-gpmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/memory/ti-gpmc.c b/drivers/memory/ti-gpmc.c index 775e78c9a5..0b8674339e 100644 --- a/drivers/memory/ti-gpmc.c +++ b/drivers/memory/ti-gpmc.c @@ -6,7 +6,6 @@ */
#include <asm/io.h> -#include <asm/arch/sys_proto.h> #include <clk.h> #include <common.h> #include <dm.h> @@ -17,6 +16,7 @@ #include <linux/mtd/omap_gpmc.h> #include <linux/ioport.h> #include <linux/io.h> +#include <linux/sizes.h> #include "ti-gpmc.h"
enum gpmc_clk_domain {

For DM case we can get the NAND chip's IO address from DT so we don't need to rely on CFG_SYS_NAND_BASE.
Signed-off-by: Roger Quadros rogerq@kernel.org --- drivers/mtd/nand/raw/omap_gpmc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/raw/omap_gpmc.c b/drivers/mtd/nand/raw/omap_gpmc.c index 0e25bd5dc2..f827c578d9 100644 --- a/drivers/mtd/nand/raw/omap_gpmc.c +++ b/drivers/mtd/nand/raw/omap_gpmc.c @@ -8,13 +8,15 @@ #include <log.h> #include <system-constants.h> #include <asm/io.h> -#include <dm/uclass.h> +#include <dm.h> #include <linux/errno.h>
#ifdef CONFIG_ARCH_OMAP2PLUS #include <asm/arch/mem.h> #endif
+#include <linux/io.h> +#include <linux/ioport.h> #include <linux/mtd/omap_gpmc.h> #include <linux/mtd/nand_ecc.h> #include <linux/mtd/rawnand.h> @@ -1124,7 +1126,7 @@ int __maybe_unused omap_nand_switch_ecc(uint32_t hardware, uint32_t eccstrength) * nand_scan about special functionality. See the defines for further * explanation */ -int gpmc_nand_init(struct nand_chip *nand) +int gpmc_nand_init(struct nand_chip *nand, void __iomem *nand_base) { int32_t gpmc_config = 0; int cs = cs_next++; @@ -1164,7 +1166,7 @@ int gpmc_nand_init(struct nand_chip *nand) info->control = NULL; info->cs = cs; info->ws = wscfg[cs]; - info->fifo = (void __iomem *)CFG_SYS_NAND_BASE; + info->fifo = nand_base; nand_set_controller_data(nand, &omap_nand_info[cs]); nand->cmd_ctrl = omap_nand_hwcontrol; nand->options |= NAND_NO_PADDING | NAND_CACHEPRG; @@ -1214,9 +1216,16 @@ static int gpmc_nand_probe(struct udevice *dev) { struct nand_chip *nand = dev_get_priv(dev); struct mtd_info *mtd = nand_to_mtd(nand); + struct resource res; + void __iomem *base; int ret;
- gpmc_nand_init(nand); + ret = dev_read_resource(dev, 0, &res); + if (ret) + return ret; + + base = devm_ioremap(dev, res.start, resource_size(&res)); + gpmc_nand_init(nand, base);
ret = nand_scan(mtd, CONFIG_SYS_NAND_MAX_CHIPS); if (ret) @@ -1270,7 +1279,7 @@ void board_nand_init(void)
int board_nand_init(struct nand_chip *nand) { - return gpmc_nand_init(nand); + return gpmc_nand_init(nand, (void __iomem *)CFG_SYS_NAND_BASE); }
#endif /* CONFIG_SYS_NAND_SELF_INIT */

AM642 SoC supports booting from GPMC NAND device. Define boot device for it.
Signed-off-by: Roger Quadros rogerq@kernel.org --- arch/arm/mach-k3/am642_init.c | 3 +++ arch/arm/mach-k3/include/mach/am64_spl.h | 1 + 2 files changed, 4 insertions(+)
diff --git a/arch/arm/mach-k3/am642_init.c b/arch/arm/mach-k3/am642_init.c index 6085379f1d..ddf47ef0a9 100644 --- a/arch/arm/mach-k3/am642_init.c +++ b/arch/arm/mach-k3/am642_init.c @@ -348,6 +348,9 @@ static u32 __get_primary_bootmedia(u32 main_devstat) case BOOT_DEVICE_EMMC: return BOOT_DEVICE_MMC1;
+ case BOOT_DEVICE_NAND: + return BOOT_DEVICE_NAND; + case BOOT_DEVICE_MMC: if ((bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_PORT_MASK) >> MAIN_DEVSTAT_PRIMARY_MMC_PORT_SHIFT) diff --git a/arch/arm/mach-k3/include/mach/am64_spl.h b/arch/arm/mach-k3/include/mach/am64_spl.h index b4f396b2c0..a0a517019c 100644 --- a/arch/arm/mach-k3/include/mach/am64_spl.h +++ b/arch/arm/mach-k3/include/mach/am64_spl.h @@ -22,6 +22,7 @@
#define BOOT_DEVICE_USB 0x2A #define BOOT_DEVICE_DFU 0x0A +#define BOOT_DEVICE_NAND 0x0B #define BOOT_DEVICE_GPMC_NOR 0x0C #define BOOT_DEVICE_PCIE 0x0D #define BOOT_DEVICE_XSPI 0x0E

Enables configuration required for NAND in SPL and u-boot.
Enable MTD Driver model and MTD + UBI command line utilities.
Add mtdids/mtdparts for NAND as it is required for u-boot's MTD subsystem commands to recognize NAND partitions.
Add u-boot partition location.
Signed-off-by: Roger Quadros rogerq@kernel.org --- configs/am64x_evm_a53_defconfig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/configs/am64x_evm_a53_defconfig b/configs/am64x_evm_a53_defconfig index 05e35a8db6..e22153a958 100644 --- a/configs/am64x_evm_a53_defconfig +++ b/configs/am64x_evm_a53_defconfig @@ -66,10 +66,15 @@ CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_MTD=y CONFIG_CMD_USB=y CONFIG_CMD_TIME=y CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:2m(NAND.tiboot3),2m(NAND.tispl),2m(NAND.tiboot3.backup),4m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup),-(NAND.file-system)" +CONFIG_CMD_UBI=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIST="k3-am642-evm k3-am642-sk" @@ -107,6 +112,9 @@ CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ADMA=y CONFIG_SPL_MMC_SDHCI_ADMA=y CONFIG_MMC_SDHCI_AM654=y +CONFIG_MTD=y +CONFIG_SPL_MTD=y +CONFIG_DM_MTD=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y @@ -161,3 +169,27 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_MASS_STORAGE=y CONFIG_SPL_DFU=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_MEMORY=y +CONFIG_SPL_MEMORY=y +CONFIG_TI_GPMC=y +CONFIG_MTD_RAW_NAND=y +CONFIG_NAND_OMAP_GPMC=y +CONFIG_CMD_NAND=y +CONFIG_NAND_OMAP_ELM=y +CONFIG_NAND_OMAP_ECCSCHEME_BCH8_CODE_HW=y +CONFIG_SYS_NAND_BLOCK_SIZE=0x40000 +CONFIG_SYS_NAND_ONFI_DETECTION=y +CONFIG_SYS_NAND_PAGE_SIZE=0x1000 +CONFIG_SYS_NAND_PAGE_COUNT=0x40 +CONFIG_SYS_NAND_OOBSIZE=0x100 +CONFIG_SPL_NAND_SUPPORT=y +CONFIG_SPL_NAND_DRIVERS=y +CONFIG_SPL_NAND_BASE=y +CONFIG_SPL_NAND_IDENT=y +CONFIG_SPL_NAND_ECC=y +CONFIG_SYS_NAND_MAX_CHIPS=1 +CONFIG_SYS_MAX_NAND_DEVICE=1 +# CONFIG_SPL_NAND_AM33XX_BCH is not set +CONFIG_SPL_MTD_SUPPORT=y +CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y +CONFIG_SYS_NAND_U_BOOT_OFFS=0x600000

On 14:26-20240109, Roger Quadros wrote:
Enables configuration required for NAND in SPL and u-boot.
Enable MTD Driver model and MTD + UBI command line utilities.
Add mtdids/mtdparts for NAND as it is required for u-boot's MTD subsystem commands to recognize NAND partitions.
Add u-boot partition location.
Signed-off-by: Roger Quadros rogerq@kernel.org
configs/am64x_evm_a53_defconfig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/configs/am64x_evm_a53_defconfig b/configs/am64x_evm_a53_defconfig index 05e35a8db6..e22153a958 100644 --- a/configs/am64x_evm_a53_defconfig +++ b/configs/am64x_evm_a53_defconfig @@ -66,10 +66,15 @@ CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_MTD=y CONFIG_CMD_USB=y CONFIG_CMD_TIME=y CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:2m(NAND.tiboot3),2m(NAND.tispl),2m(NAND.tiboot3.backup),4m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup),-(NAND.file-system)" +CONFIG_CMD_UBI=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIST="k3-am642-evm k3-am642-sk" @@ -107,6 +112,9 @@ CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ADMA=y CONFIG_SPL_MMC_SDHCI_ADMA=y CONFIG_MMC_SDHCI_AM654=y +CONFIG_MTD=y +CONFIG_SPL_MTD=y +CONFIG_DM_MTD=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y @@ -161,3 +169,27 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_MASS_STORAGE=y CONFIG_SPL_DFU=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_MEMORY=y +CONFIG_SPL_MEMORY=y +CONFIG_TI_GPMC=y +CONFIG_MTD_RAW_NAND=y +CONFIG_NAND_OMAP_GPMC=y +CONFIG_CMD_NAND=y +CONFIG_NAND_OMAP_ELM=y +CONFIG_NAND_OMAP_ECCSCHEME_BCH8_CODE_HW=y +CONFIG_SYS_NAND_BLOCK_SIZE=0x40000 +CONFIG_SYS_NAND_ONFI_DETECTION=y +CONFIG_SYS_NAND_PAGE_SIZE=0x1000 +CONFIG_SYS_NAND_PAGE_COUNT=0x40 +CONFIG_SYS_NAND_OOBSIZE=0x100 +CONFIG_SPL_NAND_SUPPORT=y +CONFIG_SPL_NAND_DRIVERS=y +CONFIG_SPL_NAND_BASE=y +CONFIG_SPL_NAND_IDENT=y +CONFIG_SPL_NAND_ECC=y +CONFIG_SYS_NAND_MAX_CHIPS=1 +CONFIG_SYS_MAX_NAND_DEVICE=1 +# CONFIG_SPL_NAND_AM33XX_BCH is not set +CONFIG_SPL_MTD_SUPPORT=y +CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
+CONFIG_SYS_NAND_U_BOOT_OFFS=0x600000
2.34.1
Why not a config fragment?

On Tue, Jan 09, 2024 at 01:16:27PM -0600, Nishanth Menon wrote:
On 14:26-20240109, Roger Quadros wrote:
Enables configuration required for NAND in SPL and u-boot.
Enable MTD Driver model and MTD + UBI command line utilities.
Add mtdids/mtdparts for NAND as it is required for u-boot's MTD subsystem commands to recognize NAND partitions.
Add u-boot partition location.
Signed-off-by: Roger Quadros rogerq@kernel.org
configs/am64x_evm_a53_defconfig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/configs/am64x_evm_a53_defconfig b/configs/am64x_evm_a53_defconfig index 05e35a8db6..e22153a958 100644 --- a/configs/am64x_evm_a53_defconfig +++ b/configs/am64x_evm_a53_defconfig @@ -66,10 +66,15 @@ CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_MTD=y CONFIG_CMD_USB=y CONFIG_CMD_TIME=y CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:2m(NAND.tiboot3),2m(NAND.tispl),2m(NAND.tiboot3.backup),4m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup),-(NAND.file-system)" +CONFIG_CMD_UBI=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIST="k3-am642-evm k3-am642-sk" @@ -107,6 +112,9 @@ CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ADMA=y CONFIG_SPL_MMC_SDHCI_ADMA=y CONFIG_MMC_SDHCI_AM654=y +CONFIG_MTD=y +CONFIG_SPL_MTD=y +CONFIG_DM_MTD=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y @@ -161,3 +169,27 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_MASS_STORAGE=y CONFIG_SPL_DFU=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_MEMORY=y +CONFIG_SPL_MEMORY=y +CONFIG_TI_GPMC=y +CONFIG_MTD_RAW_NAND=y +CONFIG_NAND_OMAP_GPMC=y +CONFIG_CMD_NAND=y +CONFIG_NAND_OMAP_ELM=y +CONFIG_NAND_OMAP_ECCSCHEME_BCH8_CODE_HW=y +CONFIG_SYS_NAND_BLOCK_SIZE=0x40000 +CONFIG_SYS_NAND_ONFI_DETECTION=y +CONFIG_SYS_NAND_PAGE_SIZE=0x1000 +CONFIG_SYS_NAND_PAGE_COUNT=0x40 +CONFIG_SYS_NAND_OOBSIZE=0x100 +CONFIG_SPL_NAND_SUPPORT=y +CONFIG_SPL_NAND_DRIVERS=y +CONFIG_SPL_NAND_BASE=y +CONFIG_SPL_NAND_IDENT=y +CONFIG_SPL_NAND_ECC=y +CONFIG_SYS_NAND_MAX_CHIPS=1 +CONFIG_SYS_MAX_NAND_DEVICE=1 +# CONFIG_SPL_NAND_AM33XX_BCH is not set +CONFIG_SPL_MTD_SUPPORT=y +CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
+CONFIG_SYS_NAND_U_BOOT_OFFS=0x600000
2.34.1
Why not a config fragment?
To me, this makes sense to keep in the main config. It can be turned off as needed, and at run time if it's not present, it's safe.

On 14:48-20240109, Tom Rini wrote: [...]
-- 2.34.1
Why not a config fragment?
To me, this makes sense to keep in the main config. It can be turned off as needed, and at run time if it's not present, it's safe.
Three reasons: * There is going to be duplication across multiple boards * It confuses the affair of trying to find the minimal configuration needed to boot the board. * SRAM is limited already - we have been playing all kind of dances around this - NAND is a daughter card addon - while I am not trying to diminish NAND support, we are in a constant struggle to keep SRAM viable and adding additional boot modes to a single config, IMHO is the wrong direction to go.

On Tue, Jan 09, 2024 at 02:00:14PM -0600, Nishanth Menon wrote:
On 14:48-20240109, Tom Rini wrote: [...]
-- 2.34.1
Why not a config fragment?
To me, this makes sense to keep in the main config. It can be turned off as needed, and at run time if it's not present, it's safe.
Three reasons:
- There is going to be duplication across multiple boards
- It confuses the affair of trying to find the minimal configuration needed to boot the board.
- SRAM is limited already - we have been playing all kind of dances around this - NAND is a daughter card addon - while I am not trying to diminish NAND support, we are in a constant struggle to keep SRAM viable and adding additional boot modes to a single config, IMHO is the wrong direction to go.
At the end of the day, I'll leave it to TI folks. I see that drivers/mtd/Kconfig needs a whole lot of help as while I would have hoped that turning off just CONFIG_MTD would undo most of the changes here, it does not.

On 14:26-20240109, Roger Quadros wrote:
Enables configuration required for NAND in SPL and u-boot.
Enable MTD Driver model and MTD + UBI command line utilities.
Add mtdids/mtdparts for NAND as it is required for u-boot's MTD subsystem commands to recognize NAND partitions.
Add u-boot partition location.
Signed-off-by: Roger Quadros rogerq@kernel.org
configs/am64x_evm_a53_defconfig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/configs/am64x_evm_a53_defconfig b/configs/am64x_evm_a53_defconfig index 05e35a8db6..e22153a958 100644 --- a/configs/am64x_evm_a53_defconfig +++ b/configs/am64x_evm_a53_defconfig @@ -66,10 +66,15 @@ CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_MTD=y CONFIG_CMD_USB=y CONFIG_CMD_TIME=y CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:2m(NAND.tiboot3),2m(NAND.tispl),2m(NAND.tiboot3.backup),4m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup),-(NAND.file-system)"
Why not handle this as device tree partitions?
+CONFIG_CMD_UBI=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIST="k3-am642-evm k3-am642-sk" @@ -107,6 +112,9 @@ CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ADMA=y CONFIG_SPL_MMC_SDHCI_ADMA=y CONFIG_MMC_SDHCI_AM654=y +CONFIG_MTD=y +CONFIG_SPL_MTD=y +CONFIG_DM_MTD=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y @@ -161,3 +169,27 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_FUNCTION_MASS_STORAGE=y CONFIG_SPL_DFU=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_MEMORY=y +CONFIG_SPL_MEMORY=y +CONFIG_TI_GPMC=y +CONFIG_MTD_RAW_NAND=y +CONFIG_NAND_OMAP_GPMC=y +CONFIG_CMD_NAND=y +CONFIG_NAND_OMAP_ELM=y +CONFIG_NAND_OMAP_ECCSCHEME_BCH8_CODE_HW=y +CONFIG_SYS_NAND_BLOCK_SIZE=0x40000 +CONFIG_SYS_NAND_ONFI_DETECTION=y +CONFIG_SYS_NAND_PAGE_SIZE=0x1000 +CONFIG_SYS_NAND_PAGE_COUNT=0x40 +CONFIG_SYS_NAND_OOBSIZE=0x100 +CONFIG_SPL_NAND_SUPPORT=y +CONFIG_SPL_NAND_DRIVERS=y +CONFIG_SPL_NAND_BASE=y +CONFIG_SPL_NAND_IDENT=y +CONFIG_SPL_NAND_ECC=y +CONFIG_SYS_NAND_MAX_CHIPS=1 +CONFIG_SYS_MAX_NAND_DEVICE=1 +# CONFIG_SPL_NAND_AM33XX_BCH is not set +CONFIG_SPL_MTD_SUPPORT=y +CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
+CONFIG_SYS_NAND_U_BOOT_OFFS=0x600000
2.34.1

On Tue, Jan 09, 2024 at 01:18:59PM -0600, Nishanth Menon wrote:
On 14:26-20240109, Roger Quadros wrote:
Enables configuration required for NAND in SPL and u-boot.
Enable MTD Driver model and MTD + UBI command line utilities.
Add mtdids/mtdparts for NAND as it is required for u-boot's MTD subsystem commands to recognize NAND partitions.
Add u-boot partition location.
Signed-off-by: Roger Quadros rogerq@kernel.org
configs/am64x_evm_a53_defconfig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/configs/am64x_evm_a53_defconfig b/configs/am64x_evm_a53_defconfig index 05e35a8db6..e22153a958 100644 --- a/configs/am64x_evm_a53_defconfig +++ b/configs/am64x_evm_a53_defconfig @@ -66,10 +66,15 @@ CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_MTD=y CONFIG_CMD_USB=y CONFIG_CMD_TIME=y CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:2m(NAND.tiboot3),2m(NAND.tispl),2m(NAND.tiboot3.backup),4m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup),-(NAND.file-system)"
Why not handle this as device tree partitions?
I honestly forget what the preferred way of defining and passing NAND partition information is these days. It might even be the funny case that passing as cmdline args is "best" rather than fixed-partitions binding?

On Tue, Jan 09, 2024 at 02:54:00PM -0500, Tom Rini wrote:
On Tue, Jan 09, 2024 at 01:18:59PM -0600, Nishanth Menon wrote:
On 14:26-20240109, Roger Quadros wrote:
CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:2m(NAND.tiboot3),2m(NAND.tispl),2m(NAND.tiboot3.backup),4m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup),-(NAND.file-system)"
Why not handle this as device tree partitions?
I honestly forget what the preferred way of defining and passing NAND partition information is these days. It might even be the funny case that passing as cmdline args is "best" rather than fixed-partitions binding?
According to past discussions [1] doing the fixup in U-Boot is not advised.
Using the command line or having the partition fixed in the DT are both valid options.
[1] https://lore.kernel.org/all/20230206224838.75963-1-francesco@dolcini.it/
Francesco

On 21:00-20240109, Francesco Dolcini wrote:
On Tue, Jan 09, 2024 at 02:54:00PM -0500, Tom Rini wrote:
On Tue, Jan 09, 2024 at 01:18:59PM -0600, Nishanth Menon wrote:
On 14:26-20240109, Roger Quadros wrote:
CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:2m(NAND.tiboot3),2m(NAND.tispl),2m(NAND.tiboot3.backup),4m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup),-(NAND.file-system)"
Why not handle this as device tree partitions?
I honestly forget what the preferred way of defining and passing NAND partition information is these days. It might even be the funny case that passing as cmdline args is "best" rather than fixed-partitions binding?
According to past discussions [1] doing the fixup in U-Boot is not advised.
Using the command line or having the partition fixed in the DT are both valid options.
[1] https://lore.kernel.org/all/20230206224838.75963-1-francesco@dolcini.it/
yup - also why I wonder why we cant depend on DT.

On 09/01/2024 22:00, Francesco Dolcini wrote:
On Tue, Jan 09, 2024 at 02:54:00PM -0500, Tom Rini wrote:
On Tue, Jan 09, 2024 at 01:18:59PM -0600, Nishanth Menon wrote:
On 14:26-20240109, Roger Quadros wrote:
CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:2m(NAND.tiboot3),2m(NAND.tispl),2m(NAND.tiboot3.backup),4m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup),-(NAND.file-system)"
Why not handle this as device tree partitions?
I honestly forget what the preferred way of defining and passing NAND partition information is these days. It might even be the funny case that passing as cmdline args is "best" rather than fixed-partitions binding?
According to past discussions [1] doing the fixup in U-Boot is not advised.
Using the command line or having the partition fixed in the DT are both valid options.
[1] https://lore.kernel.org/all/20230206224838.75963-1-francesco@dolcini.it/
Francesco
This was not about passing mtdparts to kernel but about getting 'mtdparts' command to work at u-boot. I need to figure out why OF partition parser didn't work here.
For a start I didn't have CONFIG_MTD_PARTITIONS set. Maybe I'm missing something more.

+Lukasz & Mattijs
On 10/01/2024 11:34, Roger Quadros wrote:
On 09/01/2024 22:00, Francesco Dolcini wrote:
On Tue, Jan 09, 2024 at 02:54:00PM -0500, Tom Rini wrote:
On Tue, Jan 09, 2024 at 01:18:59PM -0600, Nishanth Menon wrote:
On 14:26-20240109, Roger Quadros wrote:
CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:2m(NAND.tiboot3),2m(NAND.tispl),2m(NAND.tiboot3.backup),4m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup),-(NAND.file-system)"
Why not handle this as device tree partitions?
I honestly forget what the preferred way of defining and passing NAND partition information is these days. It might even be the funny case that passing as cmdline args is "best" rather than fixed-partitions binding?
According to past discussions [1] doing the fixup in U-Boot is not advised.
Using the command line or having the partition fixed in the DT are both valid options.
[1] https://lore.kernel.org/all/20230206224838.75963-1-francesco@dolcini.it/
Francesco
This was not about passing mtdparts to kernel but about getting 'mtdparts' command to work at u-boot. I need to figure out why OF partition parser didn't work here.
For a start I didn't have CONFIG_MTD_PARTITIONS set. Maybe I'm missing something more.
The issue was the NAND driver was not setting chip->dev and chip->ofnode correctly. Now 'mtd list' shows partitions from the DT. But, 'dfu 0 nand list' still fails like so. "mtdparts variable not set, see 'help mtdparts'"
Looks like dfu_nand driver doesn't fall back to OF partitions if mtdparts environment is not defined.
Should we add OF partitions support to dfu_nand driver or is it deprecated in favor of dfu_mtd driver?

On Wed, Jan 10, 2024 at 06:06:45PM +0200, Roger Quadros wrote:
+Lukasz & Mattijs
On 10/01/2024 11:34, Roger Quadros wrote:
On 09/01/2024 22:00, Francesco Dolcini wrote:
On Tue, Jan 09, 2024 at 02:54:00PM -0500, Tom Rini wrote:
On Tue, Jan 09, 2024 at 01:18:59PM -0600, Nishanth Menon wrote:
On 14:26-20240109, Roger Quadros wrote:
CONFIG_CMD_PMIC=y CONFIG_CMD_REGULATOR=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=omap2-nand.0:2m(NAND.tiboot3),2m(NAND.tispl),2m(NAND.tiboot3.backup),4m(NAND.u-boot),256k(NAND.u-boot-env),256k(NAND.u-boot-env.backup),-(NAND.file-system)"
Why not handle this as device tree partitions?
I honestly forget what the preferred way of defining and passing NAND partition information is these days. It might even be the funny case that passing as cmdline args is "best" rather than fixed-partitions binding?
According to past discussions [1] doing the fixup in U-Boot is not advised.
Using the command line or having the partition fixed in the DT are both valid options.
[1] https://lore.kernel.org/all/20230206224838.75963-1-francesco@dolcini.it/
Francesco
This was not about passing mtdparts to kernel but about getting 'mtdparts' command to work at u-boot. I need to figure out why OF partition parser didn't work here.
For a start I didn't have CONFIG_MTD_PARTITIONS set. Maybe I'm missing something more.
The issue was the NAND driver was not setting chip->dev and chip->ofnode correctly. Now 'mtd list' shows partitions from the DT. But, 'dfu 0 nand list' still fails like so. "mtdparts variable not set, see 'help mtdparts'"
Looks like dfu_nand driver doesn't fall back to OF partitions if mtdparts environment is not defined.
Should we add OF partitions support to dfu_nand driver or is it deprecated in favor of dfu_mtd driver?
I would rather not have to populate the env variable as that will lead to confusion later on I fear (make a change and it's not populated onward).

On 14:26-20240109, Roger Quadros wrote:
Hi,
AM64-EVM [1] supports NAND via expansion card.
This series fixes the GPMC memory and NAND drivers and provides NAND configuration for AM642 platform.
The extension card support and NAND DT overlay is still missing so NAND is not yet functional just with this series.
It was tested with NAND overlay [2] manually applied to base AM64-EVM DT.
CI test results are available at https://github.com/u-boot/u-boot/pull/460
[1] https://www.ti.com/tool/TMDS64EVM [2] https://lore.kernel.org/all/20230923080046.5373-2-rogerq@kernel.org/
Roger Quadros (4): memory: ti-gpmc: Fix build mtd: rawnand: omap_gpmc: Use DT provided IO address arm: mach-k3: am642: Define NAND boot device configs: am64x_evm_a53_defconfig: Enable NAND
arch/arm/mach-k3/am642_init.c | 3 +++ arch/arm/mach-k3/include/mach/am64_spl.h | 1 + configs/am64x_evm_a53_defconfig | 32 ++++++++++++++++++++++++ drivers/memory/ti-gpmc.c | 2 +- drivers/mtd/nand/raw/omap_gpmc.c | 19 ++++++++++---- 5 files changed, 51 insertions(+), 6 deletions(-)
Please update am64x documentation as well. People will need to know how to actually build, flash and use it.
base-commit: c2c598e87cfe56f5991730762c00733c5aa9a994 prerequisite-patch-id: e0465f3e924302d1c4bd47f2129b4eb3bd9faead -- 2.34.1

On 09/01/2024 21:17, Nishanth Menon wrote:
On 14:26-20240109, Roger Quadros wrote:
Hi,
AM64-EVM [1] supports NAND via expansion card.
This series fixes the GPMC memory and NAND drivers and provides NAND configuration for AM642 platform.
The extension card support and NAND DT overlay is still missing so NAND is not yet functional just with this series.
It was tested with NAND overlay [2] manually applied to base AM64-EVM DT.
CI test results are available at https://github.com/u-boot/u-boot/pull/460
[1] https://www.ti.com/tool/TMDS64EVM [2] https://lore.kernel.org/all/20230923080046.5373-2-rogerq@kernel.org/
Roger Quadros (4): memory: ti-gpmc: Fix build mtd: rawnand: omap_gpmc: Use DT provided IO address arm: mach-k3: am642: Define NAND boot device configs: am64x_evm_a53_defconfig: Enable NAND
arch/arm/mach-k3/am642_init.c | 3 +++ arch/arm/mach-k3/include/mach/am64_spl.h | 1 + configs/am64x_evm_a53_defconfig | 32 ++++++++++++++++++++++++ drivers/memory/ti-gpmc.c | 2 +- drivers/mtd/nand/raw/omap_gpmc.c | 19 ++++++++++---- 5 files changed, 51 insertions(+), 6 deletions(-)
Please update am64x documentation as well. People will need to know how to actually build, flash and use it.
As NAND is not yet functional till we implement the extension card support and add the NAND overlay. I'll limit this series to platform & driver fixes and leave the defconfig and documentation out for now.
base-commit: c2c598e87cfe56f5991730762c00733c5aa9a994 prerequisite-patch-id: e0465f3e924302d1c4bd47f2129b4eb3bd9faead -- 2.34.1
participants (4)
-
Francesco Dolcini
-
Nishanth Menon
-
Roger Quadros
-
Tom Rini