From: Lucas Stach <dev@lynxeye.de>
To: barebox@lists.infradead.org
Subject: [PATCH 18/18] ARM: zynq: add bootsource detection
Date: Thu, 7 Nov 2019 22:11:19 +0100 [thread overview]
Message-ID: <20191107211119.68064-19-dev@lynxeye.de> (raw)
In-Reply-To: <20191107211119.68064-1-dev@lynxeye.de>
Implement the bootsource detection by reading the BOOT_MODE SLCR register
which holds the strap values used to select the boot source.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
.../mach-zynq/include/mach/zynq7000-regs.h | 1 +
arch/arm/mach-zynq/zynq.c | 27 +++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-zynq/include/mach/zynq7000-regs.h b/arch/arm/mach-zynq/include/mach/zynq7000-regs.h
index dd02f5b4072a..eeecfe1ded43 100644
--- a/arch/arm/mach-zynq/include/mach/zynq7000-regs.h
+++ b/arch/arm/mach-zynq/include/mach/zynq7000-regs.h
@@ -63,6 +63,7 @@
#define ZYNQ_FPGA3_CLK_CTRL 0x0A0
#define ZYNQ_CLK_621_TRUE 0x0C4
#define ZYNQ_RST_CTRL_BASE (ZYNQ_SLCR_BASE + 0x200)
+#define ZYNQ_SLCR_BOOT_MODE (ZYNQ_SLCR_BASE + 0x25C)
#define ZYNQ_PSS_RST_CTRL (ZYNQ_RST_CTRL_BASE + 0x000)
#define ZYNQ_DDR_RST_CTRL (ZYNQ_RST_CTRL_BASE + 0x004)
#define ZYNQ_TOPSW_RST_CTRL (ZYNQ_RST_CTRL_BASE + 0x008)
diff --git a/arch/arm/mach-zynq/zynq.c b/arch/arm/mach-zynq/zynq.c
index ad06c624d90b..79a6b908e000 100644
--- a/arch/arm/mach-zynq/zynq.c
+++ b/arch/arm/mach-zynq/zynq.c
@@ -14,11 +14,12 @@
*/
#include <asm/system.h>
-#include <io.h>
+#include <bootsource.h>
#include <common.h>
#include <init.h>
-#include <restart.h>
+#include <io.h>
#include <mach/zynq7000-regs.h>
+#include <restart.h>
static void __noreturn zynq_restart_soc(struct restart_handler *rst)
{
@@ -30,6 +31,26 @@ static void __noreturn zynq_restart_soc(struct restart_handler *rst)
hang();
}
+static enum bootsource zynq_bootsource_get(void)
+{
+ u32 boot_mode = readl(ZYNQ_SLCR_BOOT_MODE);
+
+ switch (boot_mode & 0x7) {
+ case 0x0:
+ return BOOTSOURCE_JTAG;
+ case 0x1:
+ return BOOTSOURCE_SPI;
+ case 0x2:
+ return BOOTSOURCE_NOR;
+ case 0x4:
+ return BOOTSOURCE_NAND;
+ case 0x5:
+ return BOOTSOURCE_MMC;
+ default:
+ return BOOTSOURCE_UNKNOWN;
+ }
+}
+
static int zynq_init(void)
{
u32 val;
@@ -50,6 +71,8 @@ static int zynq_init(void)
restart_handler_register_fn(zynq_restart_soc);
+ bootsource_set(zynq_bootsource_get());
+
return 0;
}
postcore_initcall(zynq_init);
--
2.23.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2019-11-07 21:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-07 21:11 [PATCH 00/18] Zynq multi-image conversion and improvements Lucas Stach
2019-11-07 21:11 ` [PATCH 01/18] ARM: zynq: zedboard: enable MACB driver in defconfig Lucas Stach
2019-11-07 21:11 ` [PATCH 02/18] ARM: zynq: add trivial image build mechanism Lucas Stach
2019-11-07 21:11 ` [PATCH 03/18] ARM: zynq: use getopt in zynq_mkimage Lucas Stach
2019-11-07 21:11 ` [PATCH 04/18] ARM: zynq: move header generation to zynq_mkimage Lucas Stach
2019-11-07 21:11 ` [PATCH 05/18] ARM: zynq: add size check in zynq_mkimage Lucas Stach
2019-11-07 21:11 ` [PATCH 06/18] ARM: zynq: zedboard: provide DTB Lucas Stach
2019-11-07 21:11 ` [PATCH 07/18] net: macb: handle more clocks Lucas Stach
2019-11-07 21:11 ` [PATCH 08/18] net: macb: add Zynq compatible Lucas Stach
2019-11-07 21:11 ` [PATCH 09/18] ARM: zynq: move clock controller driver to drivers/clk Lucas Stach
2019-11-07 21:11 ` [PATCH 10/18] clk: zynq: use base address of clock controller Lucas Stach
2019-11-07 21:11 ` [PATCH 11/18] ARM: zynq: fixup SLCR ranges Lucas Stach
2019-11-08 7:16 ` Sascha Hauer
2019-11-07 21:11 ` [PATCH 12/18] clk: zynq: improve PLL enable handling Lucas Stach
2019-11-07 21:11 ` [PATCH 13/18] clk: zynq: partially sync with Linux Lucas Stach
2019-11-07 21:11 ` [PATCH 14/18] ARM: zynq: switch to DT based probing Lucas Stach
2019-11-07 21:11 ` [PATCH 15/18] clk: zynq: remove clkdevs Lucas Stach
2019-11-07 21:11 ` [PATCH 16/18] ARM: zynq: switch to multi-image build Lucas Stach
2019-11-07 21:11 ` [PATCH 17/18] bootsource: add JTAG bootsource Lucas Stach
2019-11-07 21:11 ` Lucas Stach [this message]
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=20191107211119.68064-19-dev@lynxeye.de \
--to=dev@lynxeye.de \
--cc=barebox@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox