1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_METAG_IO_H
3 #define _ASM_METAG_IO_H
5 #include <linux/types.h>
6 #include <asm/pgtable-bits.h>
8 #define IO_SPACE_LIMIT 0
10 #define page_to_bus page_to_phys
11 #define bus_to_page phys_to_page
17 #define __raw_readb __raw_readb
18 static inline u8 __raw_readb(const volatile void __iomem *addr)
21 asm volatile("GETB %0,[%1]"
28 #define __raw_readw __raw_readw
29 static inline u16 __raw_readw(const volatile void __iomem *addr)
32 asm volatile("GETW %0,[%1]"
39 #define __raw_readl __raw_readl
40 static inline u32 __raw_readl(const volatile void __iomem *addr)
43 asm volatile("GETD %0,[%1]"
50 #define __raw_readq __raw_readq
51 static inline u64 __raw_readq(const volatile void __iomem *addr)
54 asm volatile("GETL %0,%t0,[%1]"
61 #define __raw_writeb __raw_writeb
62 static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
64 asm volatile("SETB [%0],%1"
71 #define __raw_writew __raw_writew
72 static inline void __raw_writew(u16 b, volatile void __iomem *addr)
74 asm volatile("SETW [%0],%1"
81 #define __raw_writel __raw_writel
82 static inline void __raw_writel(u32 b, volatile void __iomem *addr)
84 asm volatile("SETD [%0],%1"
91 #define __raw_writeq __raw_writeq
92 static inline void __raw_writeq(u64 b, volatile void __iomem *addr)
94 asm volatile("SETL [%0],%1,%t1"
102 * The generic io.h can define all the other generic accessors
105 #include <asm-generic/io.h>
108 * Despite being a 32bit architecture, Meta can do 64bit memory accesses
109 * (assuming the bus supports it).
112 #define readq __raw_readq
113 #define writeq __raw_writeq
116 * Meta specific I/O for accessing non-MMU areas.
118 * These can be provided with a physical address rather than an __iomem pointer
119 * and should only be used by core architecture code for accessing fixed core
120 * registers. Generic drivers should use ioremap and the generic I/O accessors.
123 #define metag_in8(addr) __raw_readb((volatile void __iomem *)(addr))
124 #define metag_in16(addr) __raw_readw((volatile void __iomem *)(addr))
125 #define metag_in32(addr) __raw_readl((volatile void __iomem *)(addr))
126 #define metag_in64(addr) __raw_readq((volatile void __iomem *)(addr))
128 #define metag_out8(b, addr) __raw_writeb(b, (volatile void __iomem *)(addr))
129 #define metag_out16(b, addr) __raw_writew(b, (volatile void __iomem *)(addr))
130 #define metag_out32(b, addr) __raw_writel(b, (volatile void __iomem *)(addr))
131 #define metag_out64(b, addr) __raw_writeq(b, (volatile void __iomem *)(addr))
134 * io remapping functions
137 extern void __iomem *__ioremap(unsigned long offset,
138 size_t size, unsigned long flags);
139 extern void __iounmap(void __iomem *addr);
142 * ioremap - map bus memory into CPU space
143 * @offset: bus address of the memory
144 * @size: size of the resource to map
146 * ioremap performs a platform specific sequence of operations to
147 * make bus memory CPU accessible via the readb/readw/readl/writeb/
148 * writew/writel functions and the other mmio helpers. The returned
149 * address is not guaranteed to be usable directly as a virtual
152 #define ioremap(offset, size) \
153 __ioremap((offset), (size), 0)
155 #define ioremap_nocache(offset, size) \
156 __ioremap((offset), (size), 0)
158 #define ioremap_cached(offset, size) \
159 __ioremap((offset), (size), _PAGE_CACHEABLE)
161 #define ioremap_wc(offset, size) \
162 __ioremap((offset), (size), _PAGE_WR_COMBINE)
164 #define ioremap_wt(offset, size) \
165 __ioremap((offset), (size), 0)
167 #define iounmap(addr) \
170 #endif /* _ASM_METAG_IO_H */