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, Raymond Mao <raymond.mao@riscstar.com>,
	Rick Chen <rick@andestech.com>, Leo <ycliang@andestech.com>,
	Tom Rini <trini@konsulko.com>, Lukasz Majewski <lukma@denx.de>,
	Heiko Schocher <hs@nabladev.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Peng Fan <peng.fan@nxp.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Randolph Sheng-Kai Lin <randolph@andestech.com>,
	Yixun Lan <dlan@gentoo.org>,
	Junhui Liu <junhui.liu@pigmoral.tech>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	Samuel Holland <samuel@sholland.org>
Subject: Re: [PATCH 14/17] spacemit: k1: Add DDR firmware support to SPL
Date: Mon, 19 Jan 2026 09:40:48 +0000	[thread overview]
Message-ID: <aWyryi4ZPNgNIejE@pie> (raw)
In-Reply-To: <20260117190231.977686-15-raymondmaoca@gmail.com>

(My mail provider complains about the huge list of recipients, so I
reduced it a little.)

On Sat, Jan 17, 2026 at 02:01:48PM -0500, Raymond Mao wrote:
> From: Raymond Mao <raymond.mao@riscstar.com>
> 
> Include DDR initialization firmware in the SPL image. The firmware
> path can be specified via the DDR_FW_FILE environment variable. If
> the firmware is not found, an empty placeholder file is created to
> allow the build to proceed without DDR initialization support.
> 
> Signed-off-by: Raymond Mao <raymond.mao@riscstar.com>
> ---
>  arch/riscv/dts/k1-spl.dts      |  34 ++++++++++++++++++++++++++++++++-
>  board/spacemit/k1/Kconfig      |   8 ++++++++
>  board/spacemit/k1/Makefile     |  19 ++++++++++++++++++
>  board/spacemit/k1/spl.c        |  30 +++++++++++++++++++++++++++++
>  include/configs/k1.h           |   3 +++
>  lib/vendor/spacemit/ddr_fw.bin | Bin 0 -> 19416 bytes

It's unusual to ship binary firmware in U-Boot repository. Please place
the firmware somewhere else, and give a clear instruction in the
board/architecture documentation explaining how to obtain/build it.

>  6 files changed, 93 insertions(+), 1 deletion(-)
>  create mode 100644 lib/vendor/spacemit/ddr_fw.bin

...

> diff --git a/board/spacemit/k1/Kconfig b/board/spacemit/k1/Kconfig
> index 9f9c806d00d..a5fa788f660 100644
> --- a/board/spacemit/k1/Kconfig
> +++ b/board/spacemit/k1/Kconfig
> @@ -15,6 +15,14 @@ config SYS_CONFIG_NAME
>  config TEXT_BASE
>  	default 0x00200000
>  
> +config SPL_DDR_FIRMWARE_OFFSET
> +	hex "DDR firmware offset in SPL image"
> +	depends on SPL
> +	default 0x20000
> +	help
> +	  Offset where DDR firmware should be placed in the SPL
> +	  image.
> +
>  config SPL_OPENSBI_LOAD_ADDR
>  	default 0x00000000
>  
> diff --git a/board/spacemit/k1/Makefile b/board/spacemit/k1/Makefile
> index 7bce47bac8c..ebe6e55867c 100644
> --- a/board/spacemit/k1/Makefile
> +++ b/board/spacemit/k1/Makefile
> @@ -5,3 +5,22 @@
>  
>  obj-y := board.o
>  obj-$(CONFIG_SPL_BUILD) += spl.o
> +
> +DDR_FW_SRC ?= $(DDR_FW_FILE)
> +FW_TARGET = $(srctree)/lib/vendor/spacemit/ddr_fw.bin
> +
> +DDR_FW_HEADER = $(objtree)/include/generated/ddr_fw_info.h
> +
> +$(obj)/spl.o: $(DDR_FW_HEADER)
> +
> +$(DDR_FW_HEADER): $(FW_TARGET)
> +	@echo "/* DDR firmware info - $$(date) */" > $@
> +	@if [ -f "$(FW_TARGET)" ]; then \
> +		SIZE=$$(stat -c%s "$(FW_TARGET)" 2>/dev/null || echo 0); \
> +	else \
> +		SIZE=0; \
> +	fi; \
> +	echo "#define DDR_FW_FILE_SIZE	$$SIZE" >> $@
> +	@echo "/* Note: Update ADDR if binman layout changes */" >> $@
> +
> +clean-files += $(FW_TARGET) $(DDR_FW_HEADER)

Please make use of existing binman[1] facibilities to avoid the extra
Kconfig and Makefile pieces. binman_sym() could be used for obtaining
both size and offset of a binman entry.

> diff --git a/board/spacemit/k1/spl.c b/board/spacemit/k1/spl.c
> index 6fe064bd430..54bad9000fe 100644
> --- a/board/spacemit/k1/spl.c
> +++ b/board/spacemit/k1/spl.c
> @@ -6,10 +6,12 @@
>  #include <asm/io.h>
>  #include <clk.h>
>  #include <clk-uclass.h>
> +#include <cpu_func.h>
>  #include <configs/k1.h>
>  #include <dm/device.h>
>  #include <dm/uclass.h>
>  #include <dt-bindings/pinctrl/k1-pinctrl.h>
> +#include <generated/ddr_fw_info.h>
>  #include <i2c.h>
>  #include <linux/delay.h>
>  #include <log.h>
> @@ -115,6 +117,33 @@ void serial_early_init(void)
>  		panic("Serial uclass init failed: %d\n", ret);
>  }
>  
> +/* Load DDR training firmware */
> +int init_ddr_firmware(void)
> +{
> +	void __iomem *src, *dst;
> +	unsigned long size;
> +
> +	src = (void __iomem *)(CONFIG_SPL_TEXT_BASE +
> +			       CONFIG_SPL_DDR_FIRMWARE_OFFSET);
> +	dst = (void __iomem *)(DDR_TRAINING_DATA_BASE);
> +	memcpy(dst, src, DDR_FW_FILE_SIZE);
> +	size = round_up(DDR_FW_FILE_SIZE, 64);
> +	flush_dcache_range((u32)(u64)dst, (u32)(u64)dst + size);
> +	return 0;
> +}
> +
> +void ddr_early_init(void)
> +{
> +	void __iomem *addr;
> +
> +	init_ddr_firmware();
> +	addr = (void __iomem *)(CONFIG_SPL_TEXT_BASE +
> +				CONFIG_SPL_DDR_FIRMWARE_OFFSET);
> +	// verify DDR firmware header

However, you don't verify it, but only print some of the information.
The comment seems misleading and extra.

> +	log_info("[0x%x]:0x%x, firmware size:%d\n",
> +		 (uint)(u64)addr, readl(addr), DDR_FW_FILE_SIZE);

Regards,
Yao Zi

  reply	other threads:[~2026-01-19  9:41 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-17 19:01 [PATCH 00/17] Add board support for Spacemit K1 SoC in SPL Raymond Mao
2026-01-17 19:01 ` [PATCH 01/17] spacemit: k1: support multi-board infrastructure Raymond Mao
2026-01-23 10:27   ` Heinrich Schuchardt
2026-01-23 10:46     ` Heinrich Schuchardt
2026-01-17 19:01 ` [PATCH 02/17] spacemit: k1: enable SPL with debug UART Raymond Mao
2026-01-18  8:50   ` Yao Zi
2026-01-23 14:51   ` Heinrich Schuchardt
2026-02-03 14:24     ` Raymond Mao
2026-01-17 19:01 ` [PATCH 03/17] configs: k1: enable early timer support Raymond Mao
2026-01-17 19:01 ` [PATCH 04/17] reset: k1: add SPL support and enable TWSI8 reset Raymond Mao
2026-01-18  9:10   ` Yao Zi
2026-01-21 23:17     ` Raymond Mao
2026-01-17 19:01 ` [PATCH 05/17] dt-bindings: clock: import k1-syscon from upstream Raymond Mao
2026-01-17 19:01 ` [PATCH 06/17] dts: k1: import dts file from upstream folder Raymond Mao
2026-01-17 23:03   ` Yixun Lan
2026-01-18  8:56     ` Yao Zi
2026-01-17 19:01 ` [PATCH 07/17] clk: spacemit: Add support for K1 SoC Raymond Mao
2026-01-17 19:01 ` [PATCH 08/17] dts: k1: enable clocks in SPL Raymond Mao
2026-01-17 19:01 ` [PATCH 09/17] board: k1: initialize clock and serial devices " Raymond Mao
2026-01-17 19:01 ` [PATCH 10/17] configs: k1: add default option for clock driver " Raymond Mao
2026-01-17 19:01 ` [PATCH 11/17] i2c: k1: add I2C driver support Raymond Mao
2026-01-19  5:24   ` Heiko Schocher
2026-01-17 19:01 ` [PATCH 12/17] dt-bindings: pinctrl: add k1 support Raymond Mao
2026-01-18  9:26   ` Yao Zi
2026-01-21 23:20     ` Raymond Mao
2026-01-22 14:55       ` Yao Zi
2026-01-17 19:01 ` [PATCH 13/17] spacemit: k1: add TLV EEPROM support in SPL Raymond Mao
2026-01-17 19:01 ` [PATCH 14/17] spacemit: k1: Add DDR firmware support to SPL Raymond Mao
2026-01-19  9:40   ` Yao Zi [this message]
2026-01-21 23:24     ` Raymond Mao
2026-01-22 14:43       ` Yao Zi
2026-01-17 19:01 ` [PATCH 15/17] power: pmic: add support for Spacemit P1 PMIC Raymond Mao
2026-01-17 19:01 ` [PATCH 16/17] power: regulator: add support for Spacemit P1 SoC Raymond Mao
2026-01-17 19:01 ` [PATCH 17/17] board: k1: enable pmic in spl Raymond Mao
2026-01-17 23:13 ` [PATCH 00/17] Add board support for Spacemit K1 SoC in SPL Yixun Lan
2026-01-22  8:29 ` Heinrich Schuchardt
2026-01-23 14:58   ` 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=aWyryi4ZPNgNIejE@pie \
    --to=me@ziyao.cc \
    --cc=dlan@gentoo.org \
    --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@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.