From: E Shattow <e@freeshell.de>
To: u-boot@lists.u-boot-project.org, Yixun Lan <dlan@kernel.org>,
Tom Rini <trini@konsulko.com>
Cc: E Shattow <e@freeshell.de>
Subject: [PATCH v3 2/2] configs: spacemit: k3: enable mtdparts in main app
Date: Thu, 22 Oct 2026 03:38:53 -0700 [thread overview]
Message-ID: <20261022103907.1415045-3-e@freeshell.de> (raw)
In-Reply-To: <20261022103907.1415045-1-e@freeshell.de>
add default mtdids and mtdparts consistent with Linux v7.3 FSL QSPI "new"
driver .get_name() handler fsl_qspi_get_name() and k3-pico-itx.dts
Signed-off-by: E Shattow <e@freeshell.de>
---
Write-up about testing methodology and the decision of what how
MTDIDS_DEFAULT is written for compatibility, follows.
With Debian 13 Trixie Linux as a baseline distro and build Linux v7.3:
tar Jxf /usr/src/linux-source-7.3.tar.xz && cd linux-source-7.3
xzcat /usr/src/linux-config-7.2/config.riscv64_none_riscv64.xz > .config
scripts/config --enable DEBUG_INFO_NONE --undefine CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
scripts/config --set-val CMDLINE_PARTITION y --set-val MTD y --set-val MTD_BLOCK y --set-val MTD_CMDLINE_PARTS y --set-val MTD_OF_PARTS n
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- olddefconfig
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- KDEB_CHANGELOG_DIST=unreleased -j$(nproc) bindeb-pkg LOCALVERSION=-mtdparts
# K3 append linux cmdline: mtdparts=
Loading Linux 7.3.0-rc7-mtdparts ...
Loading initial ramdisk ...
Removing MTD device #0 (nor0) with use count 1
[ 9.946726] mtd: no mtd-id
$ cat /sys/class/mtd/mtd0/name /proc/mtd
d420c000.spi
dev: size erasesize name
mtd0: 00800000 00001000 "d420c000.spi"
# K3 append linux cmdline: mtdparts=spi0.0:128k(bootinfo),512k(fsbl),64k(env),1024k(esos),384k(opensbi),-(uboot)
Loading Linux 7.3.0-rc7-mtdparts ...
Loading initial ramdisk ...
Removing MTD device #0 (nor0) with use count 1
$ cat /sys/class/mtd/mtd0/name /proc/mtd
d420c000.spi
dev: size erasesize name
mtd0: 00800000 00001000 "d420c000.spi"
# K3 append linux cmdline: mtdparts=d420c000.spi:128k(bootinfo),512k(fsbl),64k(env),1024k(esos),384k(opensbi),-(uboot)
Loading Linux 7.3.0-rc7-mtdparts ...
Loading initial ramdisk ...
Removing MTD device #0 (nor0) with use count 1
$ cat /sys/class/mtd/mtd0/name /proc/mtd
bootinfo
dev: size erasesize name
mtd0: 00020000 00001000 "bootinfo"
mtd1: 00080000 00001000 "fsbl"
mtd2: 00010000 00001000 "env"
mtd3: 00100000 00001000 "esos"
mtd4: 00060000 00001000 "opensbi"
mtd5: 005f0000 00001000 "uboot"
# JH-7110 append linux cmdline: mtdparts=
Loading Linux 7.3.0-rc7-mtdparts ...
Loading initial ramdisk ...
[ 16.626705] mtd: no mtd-id
$ cat /sys/class/mtd/mtd0/name /proc/mtd
13010000.spi.0
dev: size erasesize name
mtd0: 01000000 00001000 "13010000.spi.0"
# JH-7110 append linux cmdline: mtdparts=spi0.0:960k(spl),64k(uboot-env),-(uboot)
Loading Linux 7.3.0-rc7-mtdparts ...
Loading initial ramdisk ...
$ cat /sys/class/mtd/mtd0/name /proc/mtd
13010000.spi.0
dev: size erasesize name
mtd0: 01000000 00001000 "13010000.spi.0"
# JH-7110 append linux cmdline: mtdparts=13010000.spi:960k(spl),64k(uboot-env),-(uboot)
Loading Linux 7.3.0-rc7-mtdparts ...
Loading initial ramdisk ...
$ cat /sys/class/mtd/mtd0/name /proc/mtd
13010000.spi.0
dev: size erasesize name
mtd0: 01000000 00001000 "13010000.spi.0"
# JH-7110 append linux cmdline: mtdparts=13010000.spi.0:960k(spl),64k(uboot-env),-(uboot)
Loading Linux 7.3.0-rc7-mtdparts ...
Loading initial ramdisk ...
$ cat /sys/class/mtd/mtd0/name /proc/mtd
spl
dev: size erasesize name
mtd0: 000f0000 00001000 "spl"
mtd1: 00010000 00001000 "uboot-env"
mtd2: 00f00000 00001000 "uboot"
# K3
$ ls -d /sys/bus/platform/drivers/*/*/spi_master
/sys/bus/platform/drivers/fsl-quadspi/d420c000.spi/spi_master
# JH-7110
$ ls -d /sys/bus/platform/drivers/*/*/spi_master
/sys/bus/platform/drivers/cadence-qspi/13010000.spi/spi_master
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi-fsl-qspi.c?h=v7.3#n840
static const char *fsl_qspi_get_name(struct spi_mem *mem)
{
struct fsl_qspi *q = spi_controller_get_devdata(mem->spi->controller);
struct device *dev = &mem->spi->dev;
const char *name;
/*
* In order to keep mtdparts compatible with the old MTD driver at
* mtd/spi-nor/fsl-quadspi.c, we set a custom name derived from the
* platform_device of the controller.
*/
if (of_get_available_child_count(q->dev->of_node) == 1)
return dev_name(q->dev);
name = devm_kasprintf(dev, GFP_KERNEL,
"%s-%d", dev_name(q->dev),
spi_get_chipselect(mem->spi, 0));
if (!name) {
dev_err(dev, "failed to get memory for custom flash name\n");
return ERR_PTR(-ENOMEM);
}
return name;
}
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi-cadence-quadspi.c?h=v7.3#n1724
static const char *cqspi_get_name(struct spi_mem *mem)
{
struct cqspi_st *cqspi = spi_controller_get_devdata(mem->spi->controller);
struct device *dev = &cqspi->pdev->dev;
return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev),
spi_get_chipselect(mem->spi, 0));
}
In summary of the above, for compatibility with certain non-default use
of 'mtdparts=' on kernel commandline we look to what each Linux driver
returns for its assigned .dev_name() handler, as the mtd-id name.
-E
---
configs/spacemit_k3_defconfig | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/configs/spacemit_k3_defconfig b/configs/spacemit_k3_defconfig
index afe3a3b42939..f9408663619f 100644
--- a/configs/spacemit_k3_defconfig
+++ b/configs/spacemit_k3_defconfig
@@ -26,6 +26,7 @@ CONFIG_SYS_PBSIZE=276
CONFIG_HUSH_PARSER=y
CONFIG_CMD_GPIO=y
CONFIG_CMD_I2C=y
+CONFIG_CMD_MTD=y
CONFIG_CMD_DHCP=y
CONFIG_CMD_DNS=y
CONFIG_CMD_MII=y
@@ -36,6 +37,9 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
CONFIG_CMD_FAT=y
CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_MTDIDS_DEFAULT="nor0=d420c000.spi"
+CONFIG_MTDPARTS_DEFAULT="d420c000.spi:128k(bootinfo),512k(fsbl),64k(env),1024k(esos),384k(opensbi),-(uboot)"
CONFIG_DEVICE_TREE_INCLUDES="spacemit-k3-u-boot.dtsi"
CONFIG_ENV_OVERWRITE=y
CONFIG_ENV_IS_IN_SPI_FLASH=y
@@ -50,6 +54,7 @@ CONFIG_SYS_I2C_SPACEMIT_K1=y
CONFIG_MISC=y
CONFIG_SPI_FLASH_GIGADEVICE=y
CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_MTD=y
CONFIG_PHY_GIGE=y
CONFIG_DWC_ETH_QOS=y
CONFIG_DWC_ETH_QOS_SPACEMIT=y
--
2.53.0
next prev parent reply other threads:[~2026-10-22 10:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 10:38 [PATCH v3 0/2] Enable SPI NOR flash for SpacemiT K3 in main app E Shattow
2026-10-22 10:38 ` [PATCH v3 1/2] configs: spacemit: k3: enable spi nor flash " E Shattow
2026-10-22 10:38 ` E Shattow [this message]
2026-10-22 11:20 ` [PATCH v3 0/2] Enable SPI NOR flash for SpacemiT K3 " Yixun Lan
2026-10-23 1:14 ` Yixun Lan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261022103907.1415045-3-e@freeshell.de \
--to=e@freeshell.de \
--cc=dlan@kernel.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.