From b1327588146761d10c949d365f3150f9a7504ee4 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 31 Dec 2019 20:10:56 +0100 Subject: define peripherals base --- global.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'global.h') diff --git a/global.h b/global.h index b041a65..6fc19ed 100644 --- a/global.h +++ b/global.h @@ -5,13 +5,15 @@ #define RASPI 2 #if RASPI == 4 -#define GPIO_BASE 0xFE200000 +#define PERIF_BASE 0xFE000000 #else #if RASPI == 3 || RASPI == 2 -#define GPIO_BASE 0x3F200000 +#define PERIF_BASE 0x3F000000 #else -#define GPIO_BASE 0x20200000 +#define PERIF_BASE 0x20000000 #endif // RASPI == 3 || RASPI == 2 #endif // RASPI == 4 +#define GPIO_BASE (PERIF_BASE + 0x200000) + #endif // GLOBAL_H -- cgit v1.2.3 From 3fb88e3c0237379e32bd6d1d27465d5324726684 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 31 Dec 2019 20:21:06 +0100 Subject: make global.h more readable --- global.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'global.h') diff --git a/global.h b/global.h index 6fc19ed..202ca85 100644 --- a/global.h +++ b/global.h @@ -4,16 +4,23 @@ // board type, raspi2 #define RASPI 2 +// conditionally #define PERIF_BASE #if RASPI == 4 + #define PERIF_BASE 0xFE000000 -#else -#if RASPI == 3 || RASPI == 2 + +#elif RASPI == 3 || RASPI == 2 + #define PERIF_BASE 0x3F000000 -#else + +#else // if RASPI == 1 + #define PERIF_BASE 0x20000000 -#endif // RASPI == 3 || RASPI == 2 -#endif // RASPI == 4 +#endif + +// GPIO_BASE is #define'd in terms of PERIF_BASE +// (as in sane kernels - like linux, not like in wiki.osdev codes...) #define GPIO_BASE (PERIF_BASE + 0x200000) #endif // GLOBAL_H -- cgit v1.2.3 From fc852b23608c2162b264302e6f48e5f8b3b0b512 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 31 Dec 2019 23:32:42 +0100 Subject: move ARM_BASE definition to global.h --- bcmclock.h | 4 ---- global.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'global.h') diff --git a/bcmclock.h b/bcmclock.h index 7fd192d..40d0559 100644 --- a/bcmclock.h +++ b/bcmclock.h @@ -15,10 +15,6 @@ #define ST_C2 (ST_BASE + 0x14) // System Timer Compare 2 #define ST_C3 (ST_BASE + 0x18) // System Timer Compare 3 -// ARM control block -// called "base address for the ARM interrupt register" elsewhere -#define ARM_BASE (PERIF_BASE + 0xB000) - #define ARM_IRQ_BASIC_PENDING (ARM_BASE + 0x200) #define ARM_IRQ_PENDING_1 (ARM_BASE + 0x204) #define ARM_IRQ_PENDING_2 (ARM_BASE + 0x208) diff --git a/global.h b/global.h index 202ca85..34867a1 100644 --- a/global.h +++ b/global.h @@ -23,4 +23,8 @@ // (as in sane kernels - like linux, not like in wiki.osdev codes...) #define GPIO_BASE (PERIF_BASE + 0x200000) +// ARM control block +// called "base address for the ARM interrupt register" elsewhere +#define ARM_BASE (PERIF_BASE + 0xB000) + #endif // GLOBAL_H -- cgit v1.2.3 From 7da46d099e1d1909bf5d09ecedfea21481a7a3b9 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Thu, 2 Jan 2020 13:43:06 +0100 Subject: move general irq register definitions to global.h --- armclock.h | 7 ++----- bcmclock.h | 20 ++++---------------- global.h | 11 +++++++++++ 3 files changed, 17 insertions(+), 21 deletions(-) (limited to 'global.h') diff --git a/armclock.h b/armclock.h index bf225b0..3e65d27 100644 --- a/armclock.h +++ b/armclock.h @@ -16,9 +16,6 @@ #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) -#define BCMCLK_DISABLE_BASIC_IRQS (ARM_BASE + 0x224) - typedef union armclk_control { uint32_t raw; @@ -50,12 +47,12 @@ static inline void armclk_init(void) static inline void armclk_enable_timer_irq(void) { - *(uint32_t volatile*) BCMCLK_ENABLE_BASIC_IRQS = 1; + *(uint32_t volatile*) ARM_ENABLE_BASIC_IRQS = 1; } static inline void armclk_disable_timer_irq(void) { - *(uint32_t volatile*) BCMCLK_DISABLE_BASIC_IRQS = 1; + *(uint32_t volatile*) ARM_DISABLE_BASIC_IRQS = 1; } static inline void armclk_irq_settimeout(uint32_t timeout) diff --git a/bcmclock.h b/bcmclock.h index 75a3b07..b54c39a 100644 --- a/bcmclock.h +++ b/bcmclock.h @@ -15,28 +15,16 @@ #define ST_C2 (ST_BASE + 0x14) // System Timer Compare 2 #define ST_C3 (ST_BASE + 0x18) // System Timer Compare 3 -#define BCMCLK_IRQ_BASIC_PENDING (ARM_BASE + 0x200) -#define BCMCLK_IRQ_PENDING_1 (ARM_BASE + 0x204) -#define BCMCLK_IRQ_PENDING_2 (ARM_BASE + 0x208) -#define BCMCLK_FIQ_CONTROL (ARM_BASE + 0x20C) -#define BCMCLK_ENABLE_IRQS_1 (ARM_BASE + 0x210) -#define BCMCLK_ENABLE_IRQS_2 (ARM_BASE + 0x214) -#define BCMCLK_ENABLE_BASIC_IRQS (ARM_BASE + 0x218) -#define BCMCLK_DISABLE_IRQS_1 (ARM_BASE + 0x21C) -#define BCMCLK_DISABLE_IRQS_2 (ARM_BASE + 0x220) -#define BCMCLK_DISABLE_BASIC_IRQS (ARM_BASE + 0x224) - - static inline void bcmclk_enable_timer_irq(void) { - *(uint32_t volatile*) BCMCLK_ENABLE_BASIC_IRQS = 1; - *(uint32_t volatile*) BCMCLK_ENABLE_IRQS_1 = 1 << 2; + *(uint32_t volatile*) ARM_ENABLE_BASIC_IRQS = 1; + *(uint32_t volatile*) ARM_ENABLE_IRQS_1 = 1 << 2; } static inline void bcmclk_disable_timer_irq(void) { - *(uint32_t volatile*) BCMCLK_DISABLE_BASIC_IRQS = 1; - *(uint32_t volatile*) BCMCLK_DISABLE_IRQS_1 = 1 << 2; + *(uint32_t volatile*) ARM_DISABLE_BASIC_IRQS = 1; + *(uint32_t volatile*) ARM_DISABLE_IRQS_1 = 1 << 2; } static inline void bcmclk_irq_settimeout(uint32_t timeout) diff --git a/global.h b/global.h index 34867a1..f5fe9a6 100644 --- a/global.h +++ b/global.h @@ -27,4 +27,15 @@ // called "base address for the ARM interrupt register" elsewhere #define ARM_BASE (PERIF_BASE + 0xB000) +#define ARM_IRQ_BASIC_PENDING (ARM_BASE + 0x200) +#define ARM_IRQ_PENDING_1 (ARM_BASE + 0x204) +#define ARM_IRQ_PENDING_2 (ARM_BASE + 0x208) +#define ARM_FIQ_CONTROL (ARM_BASE + 0x20C) +#define ARM_ENABLE_IRQS_1 (ARM_BASE + 0x210) +#define ARM_ENABLE_IRQS_2 (ARM_BASE + 0x214) +#define ARM_ENABLE_BASIC_IRQS (ARM_BASE + 0x218) +#define ARM_DISABLE_IRQS_1 (ARM_BASE + 0x21C) +#define ARM_DISABLE_IRQS_2 (ARM_BASE + 0x220) +#define ARM_DISABLE_BASIC_IRQS (ARM_BASE + 0x224) + #endif // GLOBAL_H -- cgit v1.2.3