summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2016-09-08 23:40:21 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2016-09-08 23:40:21 +0200
commit5eb769ca8b553b4378a773967f08de20847794db (patch)
treeffb950b5ec6083572df0cbda7aafc8d4cf998944
parentb20b736382280fb522d176273645a7e955a97a60 (diff)
downloadrtems-5eb769ca8b553b4378a773967f08de20847794db.tar.bz2
arm/raspberrypi: define bsp_reset to restart board by watchdog.
Whether the board is restarted after application finish/exit is controlled by BSP_RESET_BOARD_AT_EXIT configure option.
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/Makefile.am4
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h53
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/startup/bspreset.c26
3 files changed, 82 insertions, 1 deletions
diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index f0b8737254..14e04277cb 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -96,7 +96,6 @@ libbsp_a_SOURCES += ../shared/startup/bsp-start-in-hyp-support.S
endif
# Startup
-libbsp_a_SOURCES += ../../shared/bspreset_loop.c
libbsp_a_SOURCES += startup/bspstart.c
libbsp_a_SOURCES += startup/cmdline.c
libbsp_a_SOURCES += startup/bspgetworkarea.c
@@ -105,6 +104,9 @@ libbsp_a_SOURCES += startup/bspsmp.c
libbsp_a_SOURCES += startup/bspsmp_init.c
endif
+# Restart
+libbsp_a_SOURCES += startup/bspreset.c
+
# IRQ
libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c
libbsp_a_SOURCES += ../../shared/src/irq-generic.c
diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h b/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h
index e442d5fca5..4ef5f713ad 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h
+++ b/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h
@@ -85,6 +85,59 @@
/** @} */
/**
+ * @name Power Management and Watchdog Registers
+ *
+ * @{
+ */
+
+#define BCM2835_PM_PASSWD_MAGIC 0x5a000000
+
+#define BCM2835_PM_BASE (RPI_PERIPHERAL_BASE + 0x100000)
+
+#define BCM2835_PM_GNRIC (BCM2835_PM_BASE + 0x00)
+#define BCM2835_PM_GNRIC_POWUP 0x00000001
+#define BCM2835_PM_GNRIC_POWOK 0x00000002
+#define BCM2835_PM_GNRIC_ISPOW 0x00000004
+#define BCM2835_PM_GNRIC_MEMREP 0x00000008
+#define BCM2835_PM_GNRIC_MRDONE 0x00000010
+#define BCM2835_PM_GNRIC_ISFUNC 0x00000020
+#define BCM2835_PM_GNRIC_RSTN 0x00000fc0
+#define BCM2835_PM_GNRIC_ENAB 0x00001000
+#define BCM2835_PM_GNRIC_CFG 0x007f0000
+
+#define BCM2835_PM_AUDIO (BCM2835_PM_BASE + 0x04)
+#define BCM2835_PM_AUDIO_APSM 0x000fffff
+#define BCM2835_PM_AUDIO_CTRLEN 0x00100000
+#define BCM2835_PM_AUDIO_RSTN 0x00200000
+
+#define BCM2835_PM_STATUS (BCM2835_PM_BASE + 0x18)
+
+#define BCM2835_PM_RSTC (BCM2835_PM_BASE + 0x1c)
+#define BCM2835_PM_RSTC_DRCFG 0x00000003
+#define BCM2835_PM_RSTC_WRCFG 0x00000030
+#define BCM2835_PM_RSTC_WRCFG_FULL 0x00000020
+#define BCM2835_PM_RSTC_SRCFG 0x00000300
+#define BCM2835_PM_RSTC_QRCFG 0x00003000
+#define BCM2835_PM_RSTC_FRCFG 0x00030000
+#define BCM2835_PM_RSTC_HRCFG 0x00300000
+
+#define BCM2835_PM_RSTS (BCM2835_PM_BASE + 0x20)
+#define BCM2835_PM_RSTS_HADDRQ 0x00000001
+#define BCM2835_PM_RSTS_HADDRF 0x00000002
+#define BCM2835_PM_RSTS_HADDRH 0x00000004
+#define BCM2835_PM_RSTS_HADWRQ 0x00000010
+#define BCM2835_PM_RSTS_HADWRF 0x00000020
+#define BCM2835_PM_RSTS_HADWRH 0x00000040
+#define BCM2835_PM_RSTS_HADSRQ 0x00000100
+#define BCM2835_PM_RSTS_HADSRF 0x00000200
+#define BCM2835_PM_RSTS_HADSRH 0x00000400
+#define BCM2835_PM_RSTS_HADPOR 0x00001000
+
+#define BCM2835_PM_WDOG (BCM2835_PM_BASE + 0x24)
+
+/** @} */
+
+/**
* @name GPIO Registers
*
* @{
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspreset.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspreset.c
new file mode 100644
index 0000000000..98c28bea9d
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspreset.c
@@ -0,0 +1,26 @@
+/**
+ * @file
+ *
+ * @ingroup raspberrypi
+ *
+ * @brief Raspberry pi restart chip function
+ */
+
+#include <bsp/bootcard.h>
+#include <bsp/raspberrypi.h>
+#include <bsp.h>
+#include <rtems.h>
+
+void bsp_reset(void)
+{
+ uint32_t rstc;
+
+ BCM2835_REG(BCM2835_PM_WDOG) = BCM2835_PM_PASSWD_MAGIC | 20;
+ rstc = BCM2835_REG(BCM2835_PM_RSTC);
+ rstc &= ~BCM2835_PM_RSTC_WRCFG;
+ rstc |= BCM2835_PM_PASSWD_MAGIC | BCM2835_PM_RSTC_WRCFG_FULL;
+ BCM2835_REG(BCM2835_PM_RSTC) = rstc;
+ BCM2835_REG(BCM2835_PM_WDOG) = BCM2835_PM_PASSWD_MAGIC | 1;
+
+ while (1) ;
+}