All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 5/6] rockchip: back-to-bootrom: rk3188: chain from SPL via TPL to the BROM
Date: Thu, 21 Sep 2017 10:19:28 +0200	[thread overview]
Message-ID: <1505981969-49480-6-git-send-email-philipp.tomsich@theobroma-systems.com> (raw)
In-Reply-To: <1505981969-49480-1-git-send-email-philipp.tomsich@theobroma-systems.com>

The RK3188 implementation previously passed the address of the stack
frame created during save_boot_params via pmu->os_reg[2]. This was not
strictly necessary, as the save_boot_params() function was called
twice (first: for TPL, saving the context for the BROM; next: for SPL,
saving the context for the TPL) and a back-to-bootrom from the SPL
would thus return to TPL.

To simplify things, we now assume that the state of the TPL is not
corrupted during SPL (the binaries are non-overlapping) and that the
SPL can safely return to TPL using the back-to-bootrom mechanism.
Consequently, the TPL should expect the SPL to return control and then
further return to the actual bootrom by performing another
back-to-bootrom transition.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
---

Changes in v3: None
Changes in v2:
- [added in v2] chain back_to_bootrom calls for SPL, first returning
  to the TPL (using the same mechanism) and the to the BROM from the
  TPL

 arch/arm/mach-rockchip/rk3188-board-spl.c | 10 ----------
 arch/arm/mach-rockchip/rk3188-board-tpl.c | 17 ++++++++++-------
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-rockchip/rk3188-board-spl.c b/arch/arm/mach-rockchip/rk3188-board-spl.c
index d3866bf..05d4ae6 100644
--- a/arch/arm/mach-rockchip/rk3188-board-spl.c
+++ b/arch/arm/mach-rockchip/rk3188-board-spl.c
@@ -101,7 +101,6 @@ static int setup_arm_clock(void)
 void board_init_f(ulong dummy)
 {
 	struct udevice *pinctrl, *dev;
-	struct rk3188_pmu *pmu;
 	int ret;
 
 	/* Example code showing how to enable the debug UART on RK3188 */
@@ -145,15 +144,6 @@ void board_init_f(ulong dummy)
 		return;
 	}
 
-	/*
-	 * Recover the bootrom's stackpointer.
-	 * For whatever reason needs to run after rockchip_get_clk.
-	 */
-	pmu = syscon_get_first_range(ROCKCHIP_SYSCON_PMU);
-	if (IS_ERR(pmu))
-		error("pmu syscon returned %ld\n", PTR_ERR(pmu));
-	SAVE_SP_ADDR = readl(&pmu->sys_reg[2]);
-
 	ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
 	if (ret) {
 		debug("Pinctrl init failed: %d\n", ret);
diff --git a/arch/arm/mach-rockchip/rk3188-board-tpl.c b/arch/arm/mach-rockchip/rk3188-board-tpl.c
index b458ef6..c714278 100644
--- a/arch/arm/mach-rockchip/rk3188-board-tpl.c
+++ b/arch/arm/mach-rockchip/rk3188-board-tpl.c
@@ -21,15 +21,16 @@ static int rk3188_num_entries __attribute__ ((section(".data")));
 
 static void jump_to_spl(void)
 {
-	typedef void __noreturn (*image_entry_noargs_t)(void);
+	typedef void (*image_entry_noargs_t)(void);
 
-	struct rk3188_pmu * const pmu = (void *)PMU_BASE;
 	image_entry_noargs_t tpl_entry =
 		(image_entry_noargs_t)(unsigned long)SPL_ENTRY;
 
-	/* Store the SAVE_SP_ADDR in a location shared with SPL. */
-	writel(SAVE_SP_ADDR, &pmu->sys_reg[2]);
 	tpl_entry();
+	/*
+	 * If the SPL stage triggers a 'return to bootrom', it will
+	 * return to here.
+	 */
 }
 
 void board_init_f(ulong dummy)
@@ -77,10 +78,12 @@ void board_init_f(ulong dummy)
 		back_to_bootrom();
 	} else {
 		/*
-		 * TPL part of the loader should now wait for us
-		 * at offset 0xC00 in the sram. Should never return
-		 * from there.
+		 * SPL part of the loader should now wait for us at
+		 * offset 0xC00 in the sram. If the SPL returns to us,
+		 * we should in turn return to the BROM (i.e. chain
+		 * through).
 		 */
 		jump_to_spl();
+		back_to_bootrom();
 	}
 }
-- 
2.1.4

  parent reply	other threads:[~2017-09-21  8:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21  8:19 [U-Boot] [PATCH v3 0/6] rockchip: back-to-bootrom: replace assembly-implementation with C-code Philipp Tomsich
2017-09-21  8:19 ` [U-Boot] [PATCH v3 1/6] arm: make save_boot_params_ret prototype visible for AArch64 Philipp Tomsich
2017-09-21  8:19 ` [U-Boot] [PATCH v3 2/6] arm: mark save_boot_params_ret as a function Philipp Tomsich
2017-09-21  8:19 ` [U-Boot] [PATCH v3 3/6] arm: provide a PCS-compliant setjmp implementation Philipp Tomsich
2017-09-23  0:48   ` Alexander Graf
2017-09-21  8:19 ` [U-Boot] [PATCH v3 4/6] rockchip: back-to-bootrom: replace assembly-implementation with C-code Philipp Tomsich
2017-09-21  8:19 ` Philipp Tomsich [this message]
2017-09-21  8:19 ` [U-Boot] [PATCH v3 6/6] rockchip: back-to-bootrom: allow passing a cmd to the bootrom Philipp Tomsich
2017-09-21  9:09 ` [U-Boot] [PATCH v3 0/6] rockchip: back-to-bootrom: replace assembly-implementation with C-code Heiko Stuebner
2017-09-21  9:44   ` Heiko Stuebner
2017-09-21 10:25     ` Dr. Philipp Tomsich
2017-09-21 10:39       ` Dr. Philipp Tomsich
2017-09-21 10:44       ` Heiko Stübner
2017-09-25  8:46         ` Andy Yan
2017-09-25  8:49           ` Dr. Philipp Tomsich
2017-09-21 10:27   ` Dr. Philipp Tomsich

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=1505981969-49480-6-git-send-email-philipp.tomsich@theobroma-systems.com \
    --to=philipp.tomsich@theobroma-systems.com \
    --cc=u-boot@lists.denx.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.