2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License along
13 * with this program; If not, see <http://www.gnu.org/licenses/>.
16 #ifndef __CARL9170FW_IO_H
17 #define __CARL9170FW_IO_H
23 static inline __inline uint8_t readb(const volatile void *addr)
25 return *(const volatile uint8_t *) addr;
28 static inline __inline uint16_t readw(const volatile void *addr)
30 return *(const volatile uint16_t *) addr;
33 static inline __inline volatile void *readp(const volatile void *addr)
35 return *(volatile void **) addr;
38 static inline __inline uint32_t readl(const volatile void *addr)
40 return *(const volatile unsigned int *) addr;
43 static inline __inline void writeb(volatile void *addr, const volatile uint8_t val)
45 *(volatile uint8_t *) addr = val;
48 static inline __inline void writew(volatile void *addr, const volatile uint16_t val)
50 *(volatile uint16_t *) addr = val;
53 static inline __inline void writel(volatile void *addr, const volatile uint32_t val)
55 *(volatile uint32_t *) addr = val;
58 static inline __inline void __orl(volatile void *addr, const volatile uint32_t val)
60 *(volatile uint32_t *) addr |= val;
63 static inline __inline void __andl(volatile void *addr, const volatile uint32_t val)
65 *(volatile uint32_t *) addr &= val;
68 static inline __inline void __xorl(volatile void *addr, const volatile uint32_t val)
70 *(volatile uint32_t *) addr ^= val;
73 static inline __inline void __incl(volatile void *addr)
75 (*(volatile uint32_t *)addr)++;
78 static inline __inline uint32_t readl_async(const volatile void *addr)
80 uint32_t i = 0, read, tmp;
87 } while (tmp != read && i <= 10);
92 static inline __inline void set(const volatile uint32_t addr, const volatile uint32_t val)
94 writel((volatile void *) addr, val);
97 static inline __inline void orl(volatile uint32_t addr, const volatile uint32_t val)
99 __orl((volatile void *) addr, val);
102 static inline __inline void xorl(const volatile uint32_t addr, const volatile uint32_t val)
104 __xorl((volatile void *) addr, val);
107 static inline __inline void andl(const volatile uint32_t addr, const volatile uint32_t val)
109 __andl((volatile void *) addr, val);
112 static inline __inline void incl(const volatile uint32_t addr)
114 __incl((volatile void *) addr);
117 static inline __inline uint32_t get(const volatile uint32_t addr)
119 return readl((volatile void *) addr);
122 static inline __inline volatile void *getp(const volatile uint32_t addr)
124 return readp((const volatile void *) addr);
127 static inline __inline uint32_t get_async(const volatile uint32_t addr)
129 return readl_async((const volatile void *) addr);
132 static inline __inline void setb(const volatile uint32_t addr, const volatile uint8_t val)
134 writeb((volatile void *) addr, val);
137 static inline __inline uint8_t getb(const volatile uint32_t addr)
139 return readb((const volatile void *) addr);
142 static inline __inline void andb(const volatile uint32_t addr, const volatile uint8_t val)
144 setb(addr, getb(addr) & val);
147 static inline __inline void orb(const volatile uint32_t addr, const volatile uint32_t val)
149 setb(addr, getb(addr) | val);
152 static inline __inline uint16_t getw(const volatile uint32_t addr)
154 return readw((const volatile void *) addr);
157 #endif /* __CARL9170FW_IO_H */