gpio:Initial GPIO driver.(ARM)
[minix.git] / drivers / gpio / mmio.h
blobf40262a967ab5459721bad9b45a99fab52590a9e
1 #define REG(x)(*((volatile uint32_t *)(x)))
2 #define BIT(x)(0x1 << x)
4 /* Write a uint32_t value to a memory address. */
5 static inline void
6 write32(uint32_t address, uint32_t value)
8 REG(address) = value;
11 /* Read an uint32_t from a memory address */
12 static inline uint32_t
13 read32(uint32_t address)
16 return REG(address);
19 /* Set a 32 bits value depending on a mask */
20 static inline void
21 set32(uint32_t address, uint32_t mask, uint32_t value)
23 uint32_t val;
24 val = read32(address);
25 /* clear the bits */
26 val &= ~(mask);
27 /* apply the value using the mask */
28 val |= (value & mask);
29 write32(address, val);