2014-07-09 08:47:59 +00:00
|
|
|
/* mmio.h - access to MMIO registers */
|
|
|
|
|
|
|
|
#ifndef MMIO_H
|
|
|
|
#define MMIO_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
// write to MMIO register
|
2015-10-23 08:24:49 +00:00
|
|
|
static GFXINLINE void mmio_write(uint32_t reg, uint32_t data) {
|
2014-07-09 08:47:59 +00:00
|
|
|
uint32_t *ptr = (uint32_t*)reg;
|
|
|
|
asm volatile("str %[data], [%[reg]]"
|
|
|
|
: : [reg]"r"(ptr), [data]"r"(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
// read from MMIO register
|
2015-10-23 08:24:49 +00:00
|
|
|
static GFXINLINE uint32_t mmio_read(uint32_t reg) {
|
2014-07-09 08:47:59 +00:00
|
|
|
uint32_t *ptr = (uint32_t*)reg;
|
|
|
|
uint32_t data;
|
|
|
|
asm volatile("ldr %[data], [%[reg]]"
|
|
|
|
: [data]"=r"(data) : [reg]"r"(ptr));
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // #ifndef MMIO_H
|