1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/types.h>
6 #include <linux/pgtable.h>
8 #define virt_to_phys(a) ((unsigned long)__pa(a))
9 #define phys_to_virt(a) __va(a)
11 static inline unsigned long isa_bus_to_virt(unsigned long addr) {
16 static inline unsigned long isa_virt_to_bus(void *addr) {
24 * readX()/writeX() do byteswapping and take an ioremapped address
25 * __raw_readX()/__raw_writeX() don't byteswap and take an ioremapped address.
26 * gsc_*() don't byteswap and operate on physical addresses;
27 * eg dev->hpa or 0xfee00000.
30 static inline unsigned char gsc_readb(unsigned long addr)
39 : "=&r" (flags), "=r" (ret) : "r" (addr), "i" (PSW_SM_D) );
44 static inline unsigned short gsc_readw(unsigned long addr)
53 : "=&r" (flags), "=r" (ret) : "r" (addr), "i" (PSW_SM_D) );
58 static inline unsigned int gsc_readl(unsigned long addr)
64 : "=r" (ret) : "r" (addr) );
69 static inline unsigned long long gsc_readq(unsigned long addr)
71 unsigned long long ret;
76 : "=r" (ret) : "r" (addr) );
78 /* two reads may have side effects.. */
79 ret = ((u64) gsc_readl(addr)) << 32;
80 ret |= gsc_readl(addr+4);
85 static inline void gsc_writeb(unsigned char val, unsigned long addr)
92 : "=&r" (flags) : "r" (val), "r" (addr), "i" (PSW_SM_D) );
95 static inline void gsc_writew(unsigned short val, unsigned long addr)
102 : "=&r" (flags) : "r" (val), "r" (addr), "i" (PSW_SM_D) );
105 static inline void gsc_writel(unsigned int val, unsigned long addr)
107 __asm__ __volatile__(
109 : : "r" (val), "r" (addr) );
112 static inline void gsc_writeq(unsigned long long val, unsigned long addr)
115 __asm__ __volatile__(
117 : : "r" (val), "r" (addr) );
119 /* two writes may have side effects.. */
120 gsc_writel(val >> 32, addr);
121 gsc_writel(val, addr+4);
126 * The standard PCI ioremap interfaces
128 #define ioremap_prot ioremap_prot
130 #define _PAGE_IOREMAP (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \
131 _PAGE_ACCESSED | _PAGE_NO_CACHE)
133 #define ioremap_wc(addr, size) \
134 ioremap_prot((addr), (size), _PAGE_IOREMAP)
136 #define pci_iounmap pci_iounmap
138 void memcpy_fromio(void *dst, const volatile void __iomem *src, int count);
139 #define memcpy_fromio memcpy_fromio
150 extern unsigned char eisa_in8(unsigned short port);
151 extern unsigned short eisa_in16(unsigned short port);
152 extern unsigned int eisa_in32(unsigned short port);
153 extern void eisa_out8(unsigned char data, unsigned short port);
154 extern void eisa_out16(unsigned short data, unsigned short port);
155 extern void eisa_out32(unsigned int data, unsigned short port);
157 #if defined(CONFIG_PCI)
158 extern unsigned char inb(int addr);
159 extern unsigned short inw(int addr);
160 extern unsigned int inl(int addr);
161 extern void outb(unsigned char b, int addr);
162 extern void outw(unsigned short b, int addr);
163 extern void outl(unsigned int b, int addr);
170 #elif defined(CONFIG_EISA)
172 #define inw eisa_in16
173 #define inl eisa_in32
174 #define outb eisa_out8
175 #define outw eisa_out16
176 #define outl eisa_out32
178 static inline char inb(unsigned long addr)
184 static inline short inw(unsigned long addr)
190 static inline int inl(unsigned long addr)
198 #define outb(x, y) ({(void)(x); (void)(y); BUG(); 0;})
199 #define outw(x, y) ({(void)(x); (void)(y); BUG(); 0;})
200 #define outl(x, y) ({(void)(x); (void)(y); BUG(); 0;})
204 * String versions of in/out ops:
206 extern void insb (unsigned long port, void *dst, unsigned long count);
207 extern void insw (unsigned long port, void *dst, unsigned long count);
208 extern void insl (unsigned long port, void *dst, unsigned long count);
209 extern void outsb (unsigned long port, const void *src, unsigned long count);
210 extern void outsw (unsigned long port, const void *src, unsigned long count);
211 extern void outsl (unsigned long port, const void *src, unsigned long count);
219 /* IO Port space is : BBiiii where BB is HBA number. */
220 #define IO_SPACE_LIMIT 0x00ffffff
222 /* PA machines have an MM I/O space from 0xf0000000-0xffffffff in 32
223 * bit mode and from 0xfffffffff0000000-0xfffffffffffffff in 64 bit
224 * mode (essentially just sign extending. This macro takes in a 32
225 * bit I/O address (still with the leading f) and outputs the correct
226 * value for either 32 or 64 bit mode */
227 #define F_EXTEND(x) ((unsigned long)((x) | (0xffffffff00000000ULL)))
230 #define ioread64 ioread64
231 #define ioread64be ioread64be
232 #define iowrite64 iowrite64
233 #define iowrite64be iowrite64be
234 extern u64 ioread64(const void __iomem *addr);
235 extern u64 ioread64be(const void __iomem *addr);
236 extern void iowrite64(u64 val, void __iomem *addr);
237 extern void iowrite64be(u64 val, void __iomem *addr);
240 #include <asm-generic/iomap.h>
242 * These get provided from <asm-generic/iomap.h> since parisc does not
243 * select GENERIC_IOMAP.
245 #define ioport_map ioport_map
246 #define ioport_unmap ioport_unmap
247 #define ioread8 ioread8
248 #define ioread16 ioread16
249 #define ioread32 ioread32
250 #define ioread16be ioread16be
251 #define ioread32be ioread32be
252 #define iowrite8 iowrite8
253 #define iowrite16 iowrite16
254 #define iowrite32 iowrite32
255 #define iowrite16be iowrite16be
256 #define iowrite32be iowrite32be
257 #define ioread8_rep ioread8_rep
258 #define ioread16_rep ioread16_rep
259 #define ioread32_rep ioread32_rep
260 #define iowrite8_rep iowrite8_rep
261 #define iowrite16_rep iowrite16_rep
262 #define iowrite32_rep iowrite32_rep
264 extern int devmem_is_allowed(unsigned long pfn);
266 #include <asm-generic/io.h>