From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 1/6] sifive: fu540: Add runtime boot mode detection
Date: Fri, 5 Jun 2020 02:09:44 +0530 [thread overview]
Message-ID: <20200604203949.550290-2-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20200604203949.550290-1-jagan@amarulasolutions.com>
Add support to detect boot mode at runtime for
SiFive FU540 boards.
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
Changes for v3:
- new patch
board/sifive/fu540/fu540.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c
index fa705dea71..a35b79ace3 100644
--- a/board/sifive/fu540/fu540.c
+++ b/board/sifive/fu540/fu540.c
@@ -10,6 +10,7 @@
#include <env.h>
#include <init.h>
#include <log.h>
+#include <linux/bitops.h>
#include <linux/bug.h>
#include <linux/delay.h>
#include <linux/io.h>
@@ -120,14 +121,26 @@ int board_init(void)
}
#ifdef CONFIG_SPL
+#define MODE_SELECT_REG 0x1000
+#define MODE_SELECT_QSPI 0x6
+#define MODE_SELECT_SD 0xb
+#define MODE_SELECT_MASK GENMASK(3, 0)
+
u32 spl_boot_device(void)
{
-#ifdef CONFIG_SPL_MMC_SUPPORT
- return BOOT_DEVICE_MMC1;
-#else
- puts("Unknown boot device\n");
- hang();
-#endif
+ u32 mode_select = readl((void *)MODE_SELECT_REG);
+ u32 boot_device = mode_select & MODE_SELECT_MASK;
+
+ switch (boot_device) {
+ case MODE_SELECT_QSPI:
+ return BOOT_DEVICE_SPI;
+ case MODE_SELECT_SD:
+ return BOOT_DEVICE_MMC1;
+ default:
+ debug("Unsupported boot device 0x%x but trying MMC1\n",
+ boot_device);
+ return BOOT_DEVICE_MMC1;
+ }
}
#endif
--
2.25.1
next prev parent reply other threads:[~2020-06-04 20:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-04 20:39 [PATCH v3 0/6] riscv: sifive/fu540: SPI boot Jagan Teki
2020-06-04 20:39 ` Jagan Teki [this message]
2020-06-22 13:50 ` [PATCH v3 1/6] sifive: fu540: Add runtime boot mode detection Bin Meng
2020-06-04 20:39 ` [PATCH v3 2/6] sifive: fu540: Add Booting from SPI Jagan Teki
2020-06-22 13:53 ` Bin Meng
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA471F297@ATCPCS16.andestech.com>
2020-06-29 6:29 ` Rick Chen
2020-06-04 20:39 ` [PATCH v3 3/6] env: Enable SPI flash env for SiFive FU540 Jagan Teki
2020-06-22 13:55 ` Bin Meng
2020-06-22 13:57 ` Bin Meng
2020-06-04 20:39 ` [PATCH v3 4/6] sifive: fu540: Mark the default env as SPI flash Jagan Teki
2020-06-22 13:56 ` Bin Meng
2020-06-04 20:39 ` [PATCH v3 5/6] sifive: fu540: Add boot flash script offset, size Jagan Teki
2020-06-22 13:57 ` Bin Meng
2020-06-04 20:39 ` [PATCH v3 6/6] sifive: fu540: Enable SF distro bootcmd Jagan Teki
2020-06-22 14:01 ` Bin Meng
2020-06-11 9:59 ` [PATCH v3 0/6] riscv: sifive/fu540: SPI boot Jagan Teki
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=20200604203949.550290-2-jagan@amarulasolutions.com \
--to=jagan@amarulasolutions.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox