All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yao Zi <me@ziyao.cc>
To: Raymond Mao <raymondmaoca@gmail.com>, u-boot@lists.denx.de
Cc: uboot@riscstar.com, u-boot-spacemit@groups.io,
	raymond.mao@riscstar.com, rick@andestech.com,
	ycliang@andestech.com, trini@konsulko.com, lukma@denx.de,
	hs@nabladev.com, jh80.chung@samsung.com, peng.fan@nxp.com,
	xypron.glpk@gmx.de, randolph@andestech.com, dlan@gentoo.org,
	junhui.liu@pigmoral.tech, neil.armstrong@linaro.org,
	quentin.schulz@cherry.de, samuel@sholland.org,
	Guodong Xu <guodong@riscstar.com>, Yao Zi <me@ziyao.cc>
Subject: Re: [PATCH 1/8] spacemit: k1: select boot device via config registers
Date: Sat, 13 Jun 2026 03:50:52 +0000	[thread overview]
Message-ID: <aizTnMlko1Pg9pMb@pie> (raw)
In-Reply-To: <20260612201901.73657-2-raymondmaoca@gmail.com>

On Fri, Jun 12, 2026 at 04:18:54PM -0400, Raymond Mao wrote:
> From: Guodong Xu <guodong@riscstar.com>
> 
> Add logic to determine the current boot device by reading the
> SoC's configuration registers, rather than using a hardcoded
> default.
> 
> Signed-off-by: Guodong Xu <guodong@riscstar.com>
> Signed-off-by: Raymond Mao <raymond.mao@riscstar.com>
> ---
>  board/spacemit/k1/spl.c | 77 ++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 76 insertions(+), 1 deletion(-)
> 
> diff --git a/board/spacemit/k1/spl.c b/board/spacemit/k1/spl.c
> index 0db362130e4..d5e87d79fa2 100644
> --- a/board/spacemit/k1/spl.c
> +++ b/board/spacemit/k1/spl.c

...

> @@ -379,7 +401,60 @@ 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 = readl(boot_strap);
> +		sel >>= BOOT_STRAP_MODE_OFFSET;
> +		sel &= BOOT_STRAP_MODE_MASK;

Is FIELD_GET() helpful here?

> +		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;
> +		}
> +	}
> +	/* TODO:
> +	 *   The current upstream DTS file only contains the eMMC node. When
> +	 *   the SD node is added via an overlay, the eMMC device ends up as
> +	 *   MMC1 in SPL.

Why not fix this with an extra alias in the overlay dt?

> +	 *   However, the SD device should be the first device (MMC1).
> +	 *   This sequence needs to be corrected once the SD node is merged
> +	 *   into the upstream U-Boot DTS file.
> +	 */
> +	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;
> +	}
> +	return ret;
>  }
>  
>  void spl_board_init(void)
> -- 
> 2.25.1
> 

Regards,
Yao Zi

  reply	other threads:[~2026-06-13  3:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12 20:18 [PATCH 0/8] Add SD card and eMMC support for SpacemiT K1 Raymond Mao
2026-06-12 20:18 ` [PATCH 1/8] spacemit: k1: select boot device via config registers Raymond Mao
2026-06-13  3:50   ` Yao Zi [this message]
2026-06-12 20:18 ` [PATCH 2/8] mmc: k1: add sdhci platform driver Raymond Mao
2026-06-13  6:43   ` Yao Zi
2026-06-12 20:18 ` [PATCH 3/8] dts: k1: add SD card support in u-boot overlay Raymond Mao
2026-06-12 20:18 ` [PATCH 4/8] configs: k1: enable SD and eMMC support Raymond Mao
2026-06-12 20:18 ` [PATCH 5/8] doc: spacemit: flash on K1 SoC based boards Raymond Mao
2026-06-12 20:18 ` [PATCH 6/8] cmd: meminfo: widen memory map addresses to phys_addr_t Raymond Mao
2026-06-12 20:19 ` [PATCH 7/8] cmd: meminfo: fix the lmb info for large DRAM Raymond Mao
2026-06-12 20:19 ` [PATCH 8/8] cmd: tlv_eeprom: fix accessing invalid parameter Raymond Mao

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=aizTnMlko1Pg9pMb@pie \
    --to=me@ziyao.cc \
    --cc=dlan@gentoo.org \
    --cc=guodong@riscstar.com \
    --cc=hs@nabladev.com \
    --cc=jh80.chung@samsung.com \
    --cc=junhui.liu@pigmoral.tech \
    --cc=lukma@denx.de \
    --cc=neil.armstrong@linaro.org \
    --cc=peng.fan@nxp.com \
    --cc=quentin.schulz@cherry.de \
    --cc=randolph@andestech.com \
    --cc=raymond.mao@riscstar.com \
    --cc=raymondmaoca@gmail.com \
    --cc=rick@andestech.com \
    --cc=samuel@sholland.org \
    --cc=trini@konsulko.com \
    --cc=u-boot-spacemit@groups.io \
    --cc=u-boot@lists.denx.de \
    --cc=uboot@riscstar.com \
    --cc=xypron.glpk@gmx.de \
    --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.