aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2020-01-01 00:04:02 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2020-01-01 00:04:02 +0100
commitea465f85cf7a47f488332509a2f6d7ae5c88057c (patch)
tree125d482a3963a01c03c57950359534865d61a5bc
parent0e136bc41b1edcc146a075e0e1e41bfdbd37e572 (diff)
downloadrpi-MMU-example-ea465f85cf7a47f488332509a2f6d7ae5c88057c.tar.gz
rpi-MMU-example-ea465f85cf7a47f488332509a2f6d7ae5c88057c.zip
add messy armclock.h... although messy, it works (with modified setup.c i got an irq on real pi ^^)
-rw-r--r--armclock.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/armclock.h b/armclock.h
new file mode 100644
index 0000000..67a4ab8
--- /dev/null
+++ b/armclock.h
@@ -0,0 +1,49 @@
+#ifndef ARMCLOCK_H
+#define ARMCLOCK_H
+
+#include "global.h"
+
+#define ARMCLK_LOAD (ARM_BASE + 0x400)
+#define ARMCLK_VALUE (ARM_BASE + 0x404)
+#define ARMCLK_CONTROL (ARM_BASE + 0x408)
+#define ARMCLK_IRQ_CLR_ACK (ARM_BASE + 0x40C)
+#define ARMCLK_LOAD_RAW_IRQ (ARM_BASE + 0x410)
+#define ARMCLK_LOAD_MASKED_IRQ (ARM_BASE + 0x414)
+#define ARMCLK_LOAD_RELOAD (ARM_BASE + 0x418)
+// the last 2 are said to not exist on the actual Pi
+#define ARMCLK_LOAD_PRE_DRIVER (ARM_BASE + 0x41C)
+#define ARMCLK_LOAD_FREE_RUNNING_COUNTER (ARM_BASE + 0x420)
+
+#define BCMCLK_ENABLE_BASIC_IRQS (ARM_BASE + 0x218)
+
+static inline void armclk_enable_timer_irq(void)
+{
+ // uint32_t control_reg = *(uint32_t volatile*) ARMCLK_CONTROL;
+ // control_reg |= 1 << 5;
+ // *(uint32_t volatile*) ARMCLK_CONTROL = control_reg;
+ *(uint32_t volatile*) ARMCLK_CONTROL = 0x00000000;
+ *(uint32_t volatile*) ARMCLK_LOAD_PRE_DRIVER = 0x000000f9;
+ *(uint32_t volatile*) ARMCLK_LOAD_RELOAD = 0x4C4B40; //50 times a Sec by 250Mhz
+ *(uint32_t volatile*) ARMCLK_LOAD = 0x4C4B40;//50 times a Sec by 250Mhz
+ *(uint32_t volatile*) ARMCLK_IRQ_CLR_ACK = 0x00000000;
+ *(uint32_t volatile*) ARMCLK_CONTROL = 0x000000a2;
+
+
+
+
+ *(uint32_t volatile*) BCMCLK_ENABLE_BASIC_IRQS = 1;
+}
+
+static inline void armclk_disable_timer_irq(void)
+{
+ uint32_t control_reg = *(uint32_t volatile*) ARMCLK_CONTROL;
+ control_reg &= ~((uint32_t) 1 << 5);
+ *(uint32_t volatile*) ARMCLK_CONTROL = control_reg;
+}
+
+static inline void armclk_set_timer_match_timeout(uint32_t timeout)
+{
+ *(uint32_t volatile*) ARMCLK_LOAD = timeout;
+}
+
+#endif // ARMCLOCK_H