Commit 69e1d8a6 authored by Mike Frysinger's avatar Mike Frysinger

Blackfin: unify MMR helpers

Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
parent f05ede3a
...@@ -25,62 +25,30 @@ ...@@ -25,62 +25,30 @@
# define NOP_PAD_ANOMALY_05000198 # define NOP_PAD_ANOMALY_05000198
#endif #endif
#define bfin_read8(addr) ({ \ #define _bfin_readX(addr, size, asm_size, asm_ext) ({ \
uint32_t __v; \ u32 __v; \
__asm__ __volatile__( \ __asm__ __volatile__( \
NOP_PAD_ANOMALY_05000198 \ NOP_PAD_ANOMALY_05000198 \
"%0 = b[%1] (z);" \ "%0 = " #asm_size "[%1]" #asm_ext ";" \
: "=d" (__v) \ : "=d" (__v) \
: "a" (addr) \ : "a" (addr) \
); \ ); \
__v; }) __v; })
#define _bfin_writeX(addr, val, size, asm_size) \
#define bfin_read16(addr) ({ \
uint32_t __v; \
__asm__ __volatile__( \
NOP_PAD_ANOMALY_05000198 \
"%0 = w[%1] (z);" \
: "=d" (__v) \
: "a" (addr) \
); \
__v; })
#define bfin_read32(addr) ({ \
uint32_t __v; \
__asm__ __volatile__( \
NOP_PAD_ANOMALY_05000198 \
"%0 = [%1];" \
: "=d" (__v) \
: "a" (addr) \
); \
__v; })
#define bfin_write8(addr, val) \
__asm__ __volatile__( \ __asm__ __volatile__( \
NOP_PAD_ANOMALY_05000198 \ NOP_PAD_ANOMALY_05000198 \
"b[%0] = %1;" \ #asm_size "[%0] = %1;" \
: \ : \
: "a" (addr), "d" ((uint8_t)(val)) \ : "a" (addr), "d" ((u##size)(val)) \
: "memory" \ : "memory" \
) )
#define bfin_write16(addr, val) \ #define bfin_read8(addr) _bfin_readX(addr, 8, b, (z))
__asm__ __volatile__( \ #define bfin_read16(addr) _bfin_readX(addr, 16, w, (z))
NOP_PAD_ANOMALY_05000198 \ #define bfin_read32(addr) _bfin_readX(addr, 32, , )
"w[%0] = %1;" \ #define bfin_write8(addr, val) _bfin_writeX(addr, val, 8, b)
: \ #define bfin_write16(addr, val) _bfin_writeX(addr, val, 16, w)
: "a" (addr), "d" ((uint16_t)(val)) \ #define bfin_write32(addr, val) _bfin_writeX(addr, val, 32, )
: "memory" \
)
#define bfin_write32(addr, val) \
__asm__ __volatile__( \
NOP_PAD_ANOMALY_05000198 \
"[%0] = %1;" \
: \
: "a" (addr), "d" (val) \
: "memory" \
)
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment