From: Alexander Graf <agraf@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/3] ARM: bcm283x: Implement EFI RTS reset_system
Date: Wed, 2 Nov 2016 10:36:18 +0100 [thread overview]
Message-ID: <1478079380-176304-2-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1478079380-176304-1-git-send-email-agraf@suse.de>
The rpi has a pretty simple way of resetting the whole system. All it takes
is to poke a few registers at a well defined location in MMIO space.
This patch adds support for the EFI loader implementation to allow an OS to
reset and power off the system when we're outside of boot time.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
v2 -> v3:
- Use new runtime markers
---
arch/arm/mach-bcm283x/include/mach/wdog.h | 2 +-
arch/arm/mach-bcm283x/reset.c | 59 +++++++++++++++++++++++++++----
2 files changed, 54 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-bcm283x/include/mach/wdog.h b/arch/arm/mach-bcm283x/include/mach/wdog.h
index 7741d7b..b4caca1 100644
--- a/arch/arm/mach-bcm283x/include/mach/wdog.h
+++ b/arch/arm/mach-bcm283x/include/mach/wdog.h
@@ -16,7 +16,7 @@
struct bcm2835_wdog_regs {
u32 unknown0[7];
u32 rstc;
- u32 unknown1;
+ u32 rsts;
u32 wdog;
};
diff --git a/arch/arm/mach-bcm283x/reset.c b/arch/arm/mach-bcm283x/reset.c
index 72cdc31..685815c 100644
--- a/arch/arm/mach-bcm283x/reset.c
+++ b/arch/arm/mach-bcm283x/reset.c
@@ -10,19 +10,66 @@
#include <common.h>
#include <asm/io.h>
#include <asm/arch/wdog.h>
+#include <efi_loader.h>
#define RESET_TIMEOUT 10
-void reset_cpu(ulong addr)
+/*
+ * The Raspberry Pi firmware uses the RSTS register to know which partiton
+ * to boot from. The partiton value is spread into bits 0, 2, 4, 6, 8, 10.
+ * Partiton 63 is a special partition used by the firmware to indicate halt.
+ */
+#define BCM2835_WDOG_RSTS_RASPBERRYPI_HALT 0x555
+
+__efi_runtime_data struct bcm2835_wdog_regs *wdog_regs =
+ (struct bcm2835_wdog_regs *)BCM2835_WDOG_PHYSADDR;
+
+void __efi_runtime reset_cpu(ulong addr)
{
- struct bcm2835_wdog_regs *regs =
- (struct bcm2835_wdog_regs *)BCM2835_WDOG_PHYSADDR;
uint32_t rstc;
- rstc = readl(®s->rstc);
+ rstc = readl(&wdog_regs->rstc);
rstc &= ~BCM2835_WDOG_RSTC_WRCFG_MASK;
rstc |= BCM2835_WDOG_RSTC_WRCFG_FULL_RESET;
- writel(BCM2835_WDOG_PASSWORD | RESET_TIMEOUT, ®s->wdog);
- writel(BCM2835_WDOG_PASSWORD | rstc, ®s->rstc);
+ writel(BCM2835_WDOG_PASSWORD | RESET_TIMEOUT, &wdog_regs->wdog);
+ writel(BCM2835_WDOG_PASSWORD | rstc, &wdog_regs->rstc);
+}
+
+#ifdef CONFIG_EFI_LOADER
+
+void __efi_runtime EFIAPI efi_reset_system(
+ enum efi_reset_type reset_type,
+ efi_status_t reset_status,
+ unsigned long data_size, void *reset_data)
+{
+ u32 val;
+
+ switch (reset_type) {
+ case EFI_RESET_COLD:
+ case EFI_RESET_WARM:
+ reset_cpu(0);
+ break;
+ case EFI_RESET_SHUTDOWN:
+ /*
+ * We set the watchdog hard reset bit here to distinguish this reset
+ * from the normal (full) reset. bootcode.bin will not reboot after a
+ * hard reset.
+ */
+ val = readl(&wdog_regs->rsts);
+ val |= BCM2835_WDOG_PASSWORD;
+ val |= BCM2835_WDOG_RSTS_RASPBERRYPI_HALT;
+ writel(val, &wdog_regs->rsts);
+ reset_cpu(0);
+ break;
+ }
+
+ while (1) { }
}
+
+void efi_reset_system_init(void)
+{
+ efi_add_runtime_mmio(&wdog_regs, sizeof(*wdog_regs));
+}
+
+#endif
--
1.8.5.6
next prev parent reply other threads:[~2016-11-02 9:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-02 9:36 [U-Boot] [PATCH v3 0/3] Raspberry Pi EFI enablement Alexander Graf
2016-11-02 9:36 ` Alexander Graf [this message]
2016-11-06 3:01 ` [U-Boot] [PATCH v3 1/3] ARM: bcm283x: Implement EFI RTS reset_system Stephen Warren
2016-11-06 10:24 ` Alexander Graf
2016-11-08 3:26 ` Stephen Warren
2016-11-09 11:43 ` Alexander Graf
2016-11-09 15:50 ` Stephen Warren
2016-11-09 18:09 ` Alexander Graf
2016-11-06 10:32 ` Alexander Graf
2016-11-29 17:38 ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-11-02 9:36 ` [U-Boot] [PATCH v3 2/3] bcm2835 video: Map frame buffer as 32bpp Alexander Graf
2016-11-06 3:04 ` Stephen Warren
2016-11-29 17:39 ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-11-02 9:36 ` [U-Boot] [PATCH v3 3/3] bcm2835: Reserve the spin table in efi memory map Alexander Graf
2016-11-06 3:07 ` Stephen Warren
2016-11-06 10:27 ` Alexander Graf
2016-11-29 18:01 ` [U-Boot] [U-Boot, v3, " Tom Rini
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=1478079380-176304-2-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--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.