All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: "Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Tom Rini" <trini@konsulko.com>,
	"François Ozog" <francois.ozog@linaro.org>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Bill Mills" <bill.mills@linaro.org>,
	"Simon Glass" <sjg@chromium.org>,
	"Alexandru Gagniuc" <mr.nuke.me@gmail.com>,
	"Anatolij Gustschin" <agust@denx.de>,
	"Artem Lapkin" <email2tema@gmail.com>,
	"Bin Meng" <bmeng.cn@gmail.com>, "Heiko Schocher" <hs@denx.de>,
	"Joel Peshkin" <joel.peshkin@broadcom.com>,
	"Jorge Ramirez-Ortiz" <jorge@foundries.io>,
	"Marek Vasut" <marex@denx.de>,
	"Michal Simek" <michal.simek@xilinx.com>,
	"Pali Rohár" <pali@kernel.org>,
	"Patrick Delaunay" <patrick.delaunay@foss.st.com>,
	"Peng Fan" <peng.fan@nxp.com>,
	"Ricardo Salveti" <ricardo@foundries.io>,
	"Stefan Roese" <sr@denx.de>
Subject: [PATCH v2 07/16] passage: spl: Support adding the dtb to the passage bloblist
Date: Mon, 17 Jan 2022 08:04:19 -0700	[thread overview]
Message-ID: <20220117080353.v2.7.Id6acd05e6730b3301ddc62b415a155202ddba74b@changeid> (raw)
In-Reply-To: <20220117150428.1580273-1-sjg@chromium.org>

Add an option for SPL to add a devicetree to the passage bloblist, so
SPL can provide the devicetree to U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/Kconfig   | 20 ++++++++++++++++++++
 common/spl/spl.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
 include/spl.h    |  2 ++
 3 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 59783d66cb8..bf6bff22e71 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -881,6 +881,26 @@ config SPL_PASSAGE_IN
 	  firmware phases to communicate state and settings to following
 	  phases.
 
+config SPL_PASSAGE_OUT
+	bool "Support the standard-passage protocol in SPL (out)"
+	depends on SPL_BLOBLIST
+	default y if PASSAGE_IN
+	help
+	  This enables a standard protocol for entering U-Boot, providing
+	  parameters in a bloblist and a devicetree. It allows the various
+	  firmware stages to communicate state and settings to following
+	  stages.
+
+config SPL_PASSAGE_ADD_DTB
+	bool "Add devicetree to the outgoing passage"
+	depends on SPL_PASSAGE_OUT
+	default y if SPL_PASSAGE_OUT && !SPL_PASSAGE_IN
+	help
+	  Add the devicetree into the bloblist in SPL (it is assumed to not
+	  already be there) so that the next phase (U-Boot) can find it.
+
+	  This option should be enabled in the phase that sets up the passage.
+
 source "common/spl/Kconfig"
 
 config IMAGE_SIGN_INFO
diff --git a/common/spl/spl.c b/common/spl/spl.c
index d54356b6a28..be770d0226c 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -56,6 +56,11 @@ binman_sym_declare(ulong, spl, image_pos);
 binman_sym_declare(ulong, spl, size);
 #endif
 
+#if CONFIG_IS_ENABLED(PASSAGE_ADD_DTB)
+binman_sym_declare(ulong, u_boot_dtb, image_pos);
+binman_sym_declare(ulong, u_boot_dtb, size);
+#endif
+
 /* Define board data structure */
 static struct bd_info bdata __attribute__ ((section(".data")));
 
@@ -406,7 +411,8 @@ static int setup_spl_handoff(void)
 {
 	struct spl_handoff *ho;
 
-	ho = bloblist_ensure(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(struct spl_handoff));
+	ho = bloblist_ensure(BLOBLISTT_U_BOOT_SPL_HANDOFF,
+			     sizeof(struct spl_handoff));
 	if (!ho)
 		return -ENOENT;
 
@@ -423,7 +429,8 @@ static int write_spl_handoff(void)
 	struct spl_handoff *ho;
 	int ret;
 
-	ho = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF, sizeof(struct spl_handoff));
+	ho = bloblist_find(BLOBLISTT_U_BOOT_SPL_HANDOFF,
+			   sizeof(struct spl_handoff));
 	if (!ho)
 		return -ENOENT;
 	handoff_save_dram(ho);
@@ -440,6 +447,33 @@ static inline int write_spl_handoff(void) { return 0; }
 
 #endif /* HANDOFF */
 
+/**
+ * Write the devicetree for the next phase into the passage
+ *
+ * For now we assume the next phase is U-Boot proper
+ *
+ * @return 0 on success,  -ENOSPC if it is missing and could not be added due to
+ *	lack of space, or -ESPIPE it exists but has the wrong size
+ */
+static int passage_write_dtb(void)
+{
+#if CONFIG_IS_ENABLED(PASSAGE_ADD_DTB)
+	ulong start = binman_sym(ulong, u_boot_dtb, image_pos);
+	ulong size = binman_sym(ulong, u_boot_dtb, size);
+	void *dtb;
+	int ret;
+
+	log_debug("passage: Adding control dtb size %lx\n", size);
+	ret = bloblist_ensure_size(BLOBLISTT_CONTROL_DTB, size, 0,
+				   (void **)&dtb);
+	if (ret)
+		return ret;
+	memcpy(dtb, map_sysmem(start, size), size);
+#endif
+
+	return 0;
+}
+
 /**
  * get_bootstage_id() - Get the bootstage ID to emit
  *
@@ -761,6 +795,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 			printf(SPL_TPL_PROMPT
 			       "SPL hand-off write failed (err=%d)\n", ret);
 	}
+	if (CONFIG_IS_ENABLED(PASSAGE_ADD_DTB)) {
+		ret = passage_write_dtb();
+		if (ret)
+			printf(SPL_TPL_PROMPT
+			       "Write DTB failed (err=%d)\n", ret);
+	}
 	if (CONFIG_IS_ENABLED(BLOBLIST)) {
 		ret = bloblist_finish();
 		if (ret)
diff --git a/include/spl.h b/include/spl.h
index a4d5cedad3a..472b171f5be 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -270,6 +270,8 @@ binman_sym_extern(ulong, u_boot_any, image_pos);
 binman_sym_extern(ulong, u_boot_any, size);
 binman_sym_extern(ulong, spl, image_pos);
 binman_sym_extern(ulong, spl, size);
+binman_sym_extern(ulong, u_boot_dtb, image_pos);
+binman_sym_extern(ulong, u_boot_dtb, size);
 
 /**
  * spl_get_image_pos() - get the image position of the next phase
-- 
2.34.1.703.g22d0c6ccf7-goog


  parent reply	other threads:[~2022-01-17 15:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 15:04 [PATCH v2 00/16] passage: Define a standard for firmware data flow Simon Glass
2022-01-17 15:04 ` [PATCH v2 01/16] spl: Tidy up the header includes Simon Glass
2022-01-17 15:04 ` [PATCH v2 02/16] arm: qemu: Add an SPL build Simon Glass
2022-01-17 15:04 ` [PATCH v2 03/16] spl: Rename jump_to_image_no_args() Simon Glass
2022-01-17 15:04 ` [PATCH v2 04/16] passage: Support an incoming passage Simon Glass
2022-01-17 15:04 ` [PATCH v2 05/16] passage: Support a control devicetree Simon Glass
2022-01-17 15:04 ` [PATCH v2 06/16] passage: arm: Accept a passage from the previous phase Simon Glass
2022-01-17 15:04 ` Simon Glass [this message]
2022-01-17 15:04 ` [PATCH v2 08/16] passage: spl: Support passing the passage to U-Boot Simon Glass
2022-01-17 15:04 ` [PATCH v2 09/16] passage: arm: Add the arch-specific standard passage impl Simon Glass
2022-01-17 15:04 ` [PATCH v2 10/16] passage: Add a qemu test for ARM Simon Glass
2022-01-17 15:04 ` [PATCH v2 11/16] sandbox: Add a way of checking structs for standard passage Simon Glass
2022-01-17 15:04 ` [PATCH v2 12/16] passage: Add documentation Simon Glass
2022-01-17 16:39   ` Mark Kettenis
2022-01-17 15:04 ` [PATCH v2 13/16] passage: Add docs for spl_handoff Simon Glass
2022-01-17 15:04 ` [PATCH v2 14/16] x86: Move Intel GNVS file into the common include directory Simon Glass
2022-01-17 15:04 ` [PATCH v2 15/16] passage: Add checks for pre-existing blobs Simon Glass
2022-01-17 15:04 ` [PATCH v2 16/16] WIP: RFC: Add a gitlab test Simon Glass

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=20220117080353.v2.7.Id6acd05e6730b3301ddc62b415a155202ddba74b@changeid \
    --to=sjg@chromium.org \
    --cc=agust@denx.de \
    --cc=bill.mills@linaro.org \
    --cc=bmeng.cn@gmail.com \
    --cc=email2tema@gmail.com \
    --cc=francois.ozog@linaro.org \
    --cc=hs@denx.de \
    --cc=ilias.apalodimas@linaro.org \
    --cc=joel.peshkin@broadcom.com \
    --cc=jorge@foundries.io \
    --cc=marex@denx.de \
    --cc=michal.simek@xilinx.com \
    --cc=mr.nuke.me@gmail.com \
    --cc=pali@kernel.org \
    --cc=patrick.delaunay@foss.st.com \
    --cc=peng.fan@nxp.com \
    --cc=ricardo@foundries.io \
    --cc=sr@denx.de \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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.