1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * IO definitions for the Hexagon architecture
5 * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
13 #include <linux/types.h>
14 #include <asm/iomap.h>
16 #include <asm/cacheflush.h>
19 * We don't have PCI yet.
20 * _IO_BASE is pointing at what should be unused virtual space.
22 #define IO_SPACE_LIMIT 0xffff
23 #define _IO_BASE ((void __iomem *)0xfe000000)
25 #define IOMEM(x) ((void __force __iomem *)(x))
27 extern int remap_area_pages(unsigned long start
, unsigned long phys_addr
,
28 unsigned long end
, unsigned long flags
);
30 extern void iounmap(const volatile void __iomem
*addr
);
32 /* Defined in lib/io.c, needed for smc91x driver. */
33 extern void __raw_readsw(const void __iomem
*addr
, void *data
, int wordlen
);
34 extern void __raw_writesw(void __iomem
*addr
, const void *data
, int wordlen
);
36 extern void __raw_readsl(const void __iomem
*addr
, void *data
, int wordlen
);
37 extern void __raw_writesl(void __iomem
*addr
, const void *data
, int wordlen
);
39 #define readsw(p, d, l) __raw_readsw(p, d, l)
40 #define writesw(p, d, l) __raw_writesw(p, d, l)
42 #define readsl(p, d, l) __raw_readsl(p, d, l)
43 #define writesl(p, d, l) __raw_writesl(p, d, l)
46 * virt_to_phys - map virtual address to physical
47 * @address: address to map
49 static inline unsigned long virt_to_phys(volatile void *address
)
55 * phys_to_virt - map physical address to virtual
56 * @address: address to map
58 static inline void *phys_to_virt(unsigned long address
)
64 * convert a physical pointer to a virtual kernel pointer for
67 #define xlate_dev_kmem_ptr(p) __va(p)
68 #define xlate_dev_mem_ptr(p) __va(p)
71 * IO port access primitives. Hexagon doesn't have special IO access
72 * instructions; all I/O is memory mapped.
74 * in/out are used for "ports", but we don't have "port instructions",
75 * so these are really just memory mapped too.
79 * readb - read byte from memory mapped device
80 * @addr: pointer to memory
82 * Operates on "I/O bus memory space"
84 static inline u8
readb(const volatile void __iomem
*addr
)
95 static inline u16
readw(const volatile void __iomem
*addr
)
106 static inline u32
readl(const volatile void __iomem
*addr
)
118 * writeb - write a byte to a memory location
119 * @data: data to write to
120 * @addr: pointer to memory
123 static inline void writeb(u8 data
, volatile void __iomem
*addr
)
128 : "r" (addr
), "r" (data
)
133 static inline void writew(u16 data
, volatile void __iomem
*addr
)
138 : "r" (addr
), "r" (data
)
144 static inline void writel(u32 data
, volatile void __iomem
*addr
)
149 : "r" (addr
), "r" (data
)
154 #define __raw_writeb writeb
155 #define __raw_writew writew
156 #define __raw_writel writel
158 #define __raw_readb readb
159 #define __raw_readw readw
160 #define __raw_readl readl
163 * http://comments.gmane.org/gmane.linux.ports.arm.kernel/117626
166 #define readb_relaxed __raw_readb
167 #define readw_relaxed __raw_readw
168 #define readl_relaxed __raw_readl
170 #define writeb_relaxed __raw_writeb
171 #define writew_relaxed __raw_writew
172 #define writel_relaxed __raw_writel
174 void __iomem
*ioremap(unsigned long phys_addr
, unsigned long size
);
175 #define ioremap_uc(X, Y) ioremap((X), (Y))
178 #define __raw_writel writel
180 static inline void memcpy_fromio(void *dst
, const volatile void __iomem
*src
,
183 memcpy(dst
, (void *) src
, count
);
186 static inline void memcpy_toio(volatile void __iomem
*dst
, const void *src
,
189 memcpy((void *) dst
, src
, count
);
192 static inline void memset_io(volatile void __iomem
*addr
, int value
,
195 memset((void __force
*)addr
, value
, size
);
198 #define PCI_IO_ADDR (volatile void __iomem *)
201 * inb - read byte from I/O port or something
202 * @port: address in I/O space
204 * Operates on "I/O bus I/O space"
206 static inline u8
inb(unsigned long port
)
208 return readb(_IO_BASE
+ (port
& IO_SPACE_LIMIT
));
211 static inline u16
inw(unsigned long port
)
213 return readw(_IO_BASE
+ (port
& IO_SPACE_LIMIT
));
216 static inline u32
inl(unsigned long port
)
218 return readl(_IO_BASE
+ (port
& IO_SPACE_LIMIT
));
222 * outb - write a byte to a memory location
223 * @data: data to write to
224 * @addr: address in I/O space
226 static inline void outb(u8 data
, unsigned long port
)
228 writeb(data
, _IO_BASE
+ (port
& IO_SPACE_LIMIT
));
231 static inline void outw(u16 data
, unsigned long port
)
233 writew(data
, _IO_BASE
+ (port
& IO_SPACE_LIMIT
));
236 static inline void outl(u32 data
, unsigned long port
)
238 writel(data
, _IO_BASE
+ (port
& IO_SPACE_LIMIT
));
249 static inline void insb(unsigned long port
, void *buffer
, int count
)
260 static inline void insw(unsigned long port
, void *buffer
, int count
)
271 static inline void insl(unsigned long port
, void *buffer
, int count
)
282 static inline void outsb(unsigned long port
, const void *buffer
, int count
)
285 const u8
*buf
= buffer
;
292 static inline void outsw(unsigned long port
, const void *buffer
, int count
)
295 const u16
*buf
= buffer
;
302 static inline void outsl(unsigned long port
, const void *buffer
, int count
)
305 const u32
*buf
= buffer
;
312 #endif /* __KERNEL__ */