Refactor 32-bit register definitions
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "lp0.h"
|
||||
#include "emc.h"
|
||||
#include "pmc.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef EXOSPHERE_BPMPFW_EMC_H
|
||||
#define EXOSPHERE_BPMPFW_EMC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "utils.h"
|
||||
|
||||
#define EMC_BASE (0x7001B000)
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#define EMC1_BASE (0x7001F000)
|
||||
|
||||
|
||||
#define MAKE_EMC_REG(ofs) ((*((volatile uint32_t *)(EMC_BASE + ofs))))
|
||||
#define MAKE_EMC_REG(ofs) (MAKE_REG32(EMC_BASE + ofs))
|
||||
|
||||
#define MAKE_EMC0_REG(ofs) ((*((volatile uint32_t *)(EMC0_BASE + ofs))))
|
||||
#define MAKE_EMC1_REG(ofs) ((*((volatile uint32_t *)(EMC1_BASE + ofs))))
|
||||
#define MAKE_EMC0_REG(ofs) (MAKE_REG32(EMC0_BASE + ofs))
|
||||
#define MAKE_EMC1_REG(ofs) (MAKE_REG32(EMC1_BASE + ofs))
|
||||
|
||||
#define EMC_CFG_0 MAKE_EMC_REG(0x00C)
|
||||
|
||||
@@ -46,8 +46,6 @@
|
||||
|
||||
#define EMC_FBIO_CFG7_0 MAKE_EMC_REG(0x584)
|
||||
|
||||
|
||||
|
||||
void emc_put_dram_in_self_refresh_mode(void);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef EXOSPHERE_BPMPFW_I2C_H
|
||||
#define EXOSPHERE_BPMPFW_I2C_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "utils.h"
|
||||
|
||||
/* I2C_BASE = I2C4. */
|
||||
#define I2C_BASE (0x7000D000)
|
||||
|
||||
#define MAKE_I2C_REG(ofs) ((*((volatile uint32_t *)(I2C_BASE + ofs))))
|
||||
#define MAKE_I2C_REG(ofs) (MAKE_REG32(I2C_BASE + ofs))
|
||||
|
||||
#define I2C_I2C_CNFG_0 MAKE_I2C_REG(0x000)
|
||||
|
||||
@@ -31,4 +31,4 @@ void i2c_init(void);
|
||||
|
||||
int i2c_send_reset_cmd(void);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "lp0.h"
|
||||
#include "i2c.h"
|
||||
#include "pmc.h"
|
||||
#include "emc.h"
|
||||
#include "timer.h"
|
||||
|
||||
#define CACHE_CTRL (*((volatile uint32_t *)0x50040000))
|
||||
#define CACHE_CTRL MAKE_REG32(0x50040000)
|
||||
|
||||
#define PRI_ICTLR_COP_IER_CLR_0 (*((volatile uint32_t *)0x60004038))
|
||||
#define SEC_ICTLR_COP_IER_CLR_0 (*((volatile uint32_t *)0x60004138))
|
||||
#define TRI_ICTLR_COP_IER_CLR_0 (*((volatile uint32_t *)0x60004238))
|
||||
#define QUAD_ICTLR_COP_IER_CLR_0 (*((volatile uint32_t *)0x60004338))
|
||||
#define PENTA_ICTLR_COP_IER_CLR_0 (*((volatile uint32_t *)0x60004438))
|
||||
#define HEXA_ICTLR_COP_IER_CLR_0 (*((volatile uint32_t *)0x60004538))
|
||||
#define PRI_ICTLR_COP_IER_CLR_0 MAKE_REG32(0x60004038)
|
||||
#define SEC_ICTLR_COP_IER_CLR_0 MAKE_REG32(0x60004138)
|
||||
#define TRI_ICTLR_COP_IER_CLR_0 MAKE_REG32(0x60004238)
|
||||
#define QUAD_ICTLR_COP_IER_CLR_0 MAKE_REG32(0x60004338)
|
||||
#define PENTA_ICTLR_COP_IER_CLR_0 MAKE_REG32(0x60004438)
|
||||
#define HEXA_ICTLR_COP_IER_CLR_0 MAKE_REG32(0x60004538)
|
||||
|
||||
void reboot(void) {
|
||||
/* Write MAIN_RST */
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#ifndef EXOSPHERE_BPMPFW_LP0_H
|
||||
#define EXOSPHERE_BPMPFW_LP0_H
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
void lp0_entry_main(void);
|
||||
|
||||
void reboot(void);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef EXOSPHERE_BPMPFW_PMC_H
|
||||
#define EXOSPHERE_BPMPFW_PMC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "utils.h"
|
||||
|
||||
#define PMC_BASE (0x7000E400)
|
||||
|
||||
#define MAKE_PMC_REG(ofs) ((*((volatile uint32_t *)(PMC_BASE + ofs))))
|
||||
#define MAKE_PMC_REG(ofs) (MAKE_REG32(PMC_BASE + ofs))
|
||||
|
||||
#define APBDEV_PMC_CNTRL_0 MAKE_PMC_REG(0x000)
|
||||
|
||||
@@ -34,4 +34,4 @@
|
||||
|
||||
#define APBDEV_PMC_DDR_CNTRL_0 MAKE_PMC_REG(0x4E4)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef EXOSPHERE_BPMPFW_TIMER_H
|
||||
#define EXOSPHERE_BPMPFW_TIMER_H
|
||||
|
||||
#define TIMERUS_CNTR_1US_0 (*((volatile uint32_t *)(0x60005010)))
|
||||
#include "utils.h"
|
||||
|
||||
#define TIMERUS_CNTR_1US_0 MAKE_REG32(0x60005010)
|
||||
|
||||
static inline void timer_wait(uint32_t microseconds) {
|
||||
uint32_t old_time = TIMERUS_CNTR_1US_0;
|
||||
@@ -12,4 +14,4 @@ static inline void timer_wait(uint32_t microseconds) {
|
||||
|
||||
void spinlock_wait(uint32_t count);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
22
exosphere/bpmpfw/src/utils.h
Normal file
22
exosphere/bpmpfw/src/utils.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef EXOSPHERE_BPMPFW_UTILS_H
|
||||
#define EXOSPHERE_BPMPFW_UTILS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define BIT(n) (1u << (n))
|
||||
#define BITL(n) (1ull << (n))
|
||||
#define MASK(n) (BIT(n) - 1)
|
||||
#define MASKL(n) (BITL(n) - 1)
|
||||
#define MASK2(a,b) (MASK(a) & ~MASK(b))
|
||||
#define MASK2L(a,b) (MASKL(a) & ~MASKL(b))
|
||||
|
||||
#define MAKE_REG32(a) (*(volatile uint32_t *)(a))
|
||||
|
||||
#define ALIGN(m) __attribute__((aligned(m)))
|
||||
#define PACKED __attribute__((packed))
|
||||
|
||||
#define ALINLINE __attribute__((always_inline))
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user