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
|
2018-11-03 00:51:23 +00:00
|
|
|
static GFXINLINE void mmio_write(gU32 reg, gU32 data) {
|
|
|
|
gU32 *ptr = (gU32*)reg;
|
2014-07-09 08:47:59 +00:00
|
|
|
asm volatile("str %[data], [%[reg]]"
|
|
|
|
: : [reg]"r"(ptr), [data]"r"(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
// read from MMIO register
|
2018-11-03 00:51:23 +00:00
|
|
|
static GFXINLINE gU32 mmio_read(gU32 reg) {
|
|
|
|
gU32 *ptr = (gU32*)reg;
|
|
|
|
gU32 data;
|
2014-07-09 08:47:59 +00:00
|
|
|
asm volatile("ldr %[data], [%[reg]]"
|
|
|
|
: [data]"=r"(data) : [reg]"r"(ptr));
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // #ifndef MMIO_H
|