From: Yao Zi <me@ziyao.cc>
To: Eric Chung <eric.chung@riscstar.com>,
u-boot-spacemit@groups.io, u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>, Peng Fan <peng.fan@nxp.com>,
Huan Zhou <pericycle.cc@gmail.com>,
Raymond Mao <raymond.mao@riscstar.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Bhimeswararao Matsa <bhimeswararao.matsa@gmail.com>,
Tanmay Kathpalia <tanmay.kathpalia@altera.com>,
Kaustabh Chakraborty <kauschluss@disroot.org>,
Han Xu <han.xu@nxp.com>, Yanir Levin <yanir.levin@tandemg.com>,
Christoph Stoidner <c.stoidner@phytec.de>,
Balsundar Ponnusamy <balsundar.ponnusamy@altera.com>,
Daniel Palmer <daniel@thingy.jp>, Anshul Dalal <anshuld@ti.com>,
Bastien Curutchet <bastien.curutchet@bootlin.com>,
Angelo Dureghello <angelo@kernel-space.org>,
Johan Jonker <jbx6244@gmail.com>, Rick Chen <rick@andestech.com>,
Leo <ycliang@andestech.com>,
Sam Protsenko <semen.protsenko@linaro.org>,
Guodong Xu <guodong.xu@riscstar.com>,
Tim Ouyang <tim609@andestech.com>,
Leo Liang <leo.liang@sifive.com>, Yao Zi <me@ziyao.cc>
Subject: Re: [PATCH v4 01/10] spacemit: k1: select boot device via config registers
Date: Sun, 19 Jul 2026 16:55:51 +0000 [thread overview]
Message-ID: <al0Bl_Uxd3SvfoJR@pie> (raw)
In-Reply-To: <20260707-m4-v4-1-dbd01185f911@riscstar.com>
On Tue, Jul 07, 2026 at 11:21:42PM +0800, Eric Chung wrote:
> Add logic to determine the current boot device by reading the
> SoC's configuration registers, rather than using a hardcoded
> default.
>
> Signed-off-by: Eric Chung <eric.chung@riscstar.com>
>
> ---
> v2:
> - Use FIELD_GET() to parse boot strap mode.
> - Remove comments on hacking. Since the sequence between eMMC
> and SD device is exchanged in the upstream DTS. So it isn't
> a hacking any more.
> ---
> board/spacemit/k1/spl.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 68 insertions(+), 1 deletion(-)
>
> diff --git a/board/spacemit/k1/spl.c b/board/spacemit/k1/spl.c
> index 0db362130e4..70579637b5e 100644
> --- a/board/spacemit/k1/spl.c
> +++ b/board/spacemit/k1/spl.c
...
> @@ -379,7 +402,51 @@ void board_init_f(ulong dummy)
>
> u32 spl_boot_device(void)
> {
> - return BOOT_DEVICE_SPI;
> + void __iomem *boot_dev = (void __iomem *)BOOT_DEV_FLAG_REG;
> + void __iomem *boot_strap = (void __iomem *)BOOT_PIN_SEL_REG;
> + u32 mode, sel, ret = 0;
> +
> + mode = readl(boot_dev);
> + if (mode == BOOT_MODE_NONE || mode > BOOT_MODE_SD) {
> + sel = FIELD_GET(BOOT_STRAP_MODE_MASK << BOOT_STRAP_MODE_OFFSET,
> + readl(boot_strap));
> + switch (sel) {
> + case BOOT_STRAP_MODE_EMMC:
> + mode = BOOT_MODE_EMMC;
> + break;
> + case BOOT_STRAP_MODE_NAND:
> + mode = BOOT_MODE_NAND;
> + break;
> + case BOOT_STRAP_MODE_SPI:
> + mode = BOOT_MODE_SPI;
> + break;
> + case BOOT_STRAP_MODE_SD:
> + default:
> + mode = BOOT_MODE_SD;
> + break;
> + }
> + }
> + switch (mode) {
> + case BOOT_MODE_EMMC:
> + ret = BOOT_DEVICE_MMC1;
> + break;
> + case BOOT_MODE_NAND:
> + ret = BOOT_DEVICE_NAND;
> + break;
> + case BOOT_MODE_SPI:
> + ret = BOOT_DEVICE_SPI;
> + break;
> + case BOOT_MODE_USB:
> + ret = BOOT_DEVICE_USB;
> + break;
> + case BOOT_MODE_SD:
> + ret = BOOT_DEVICE_MMC2;
> + break;
> + default:
> + ret = BOOT_DEVICE_MMC1;
> + break;
> + }
Adding empty lines before and after this switch might make the code a
little cleaner. Though being a little strange to me, checkpatch.pl
doesn't complain about it, so I don't have a strong opinion for this.
Reviewed-by: Yao Zi <me@ziyao.cc>
Best regards,
Yao Zi
next prev parent reply other threads:[~2026-07-19 16:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 15:21 [PATCH v4 00/10] spacemit mmc driver Eric Chung
2026-07-07 15:21 ` [PATCH v4 01/10] spacemit: k1: select boot device via config registers Eric Chung
2026-07-19 16:55 ` Yao Zi [this message]
2026-07-07 15:21 ` [PATCH v4 02/10] pinctrl: k1: add IO power domain configuration support Eric Chung
2026-07-19 17:01 ` Yao Zi
2026-07-07 15:21 ` [PATCH v4 03/10] mmc: enable CMD23 for multi-block transfers Eric Chung
2026-07-19 17:12 ` Yao Zi
2026-07-20 10:42 ` Eric Chung
2026-07-20 10:44 ` Eric Chung
2026-07-20 11:54 ` Kathpalia, Tanmay
2026-07-07 15:21 ` [PATCH v4 04/10] mmc: k1: add sdhci platform driver Eric Chung
2026-07-19 17:46 ` Yao Zi
2026-07-07 15:21 ` [PATCH v4 05/10] dts: k1: add SD card support in u-boot overlay Eric Chung
2026-07-19 17:53 ` Yao Zi
2026-07-07 15:21 ` [PATCH v4 06/10] configs: k1: enable SD and eMMC support Eric Chung
2026-07-07 15:21 ` [PATCH v4 07/10] MAINTAINER: update Spacemit K1 entry Eric Chung
2026-07-07 15:21 ` [PATCH v4 08/10] doc: spacemit: flash on K1 SoC based boards Eric Chung
2026-07-07 15:21 ` [PATCH v4 09/10] config: k1: enable ENV support for eMMC Eric Chung
2026-07-07 15:21 ` [PATCH v4 10/10] spacemit: k1: load product name from environment variable Eric Chung
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=al0Bl_Uxd3SvfoJR@pie \
--to=me@ziyao.cc \
--cc=angelo@kernel-space.org \
--cc=anshuld@ti.com \
--cc=balsundar.ponnusamy@altera.com \
--cc=bastien.curutchet@bootlin.com \
--cc=bhimeswararao.matsa@gmail.com \
--cc=c.stoidner@phytec.de \
--cc=daniel@thingy.jp \
--cc=eric.chung@riscstar.com \
--cc=guodong.xu@riscstar.com \
--cc=han.xu@nxp.com \
--cc=jbx6244@gmail.com \
--cc=jh80.chung@samsung.com \
--cc=kauschluss@disroot.org \
--cc=leo.liang@sifive.com \
--cc=peng.fan@nxp.com \
--cc=pericycle.cc@gmail.com \
--cc=raymond.mao@riscstar.com \
--cc=rick@andestech.com \
--cc=semen.protsenko@linaro.org \
--cc=tanmay.kathpalia@altera.com \
--cc=tim609@andestech.com \
--cc=trini@konsulko.com \
--cc=u-boot-spacemit@groups.io \
--cc=u-boot@lists.denx.de \
--cc=yanir.levin@tandemg.com \
--cc=ycliang@andestech.com \
/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.