2 * IO definitions for the Hexagon architecture
4 * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include <linux/types.h>
27 #include <linux/delay.h>
28 #include <linux/vmalloc.h>
29 #include <asm/string.h>
30 #include <asm/mem-layout.h>
31 #include <asm/iomap.h>
33 #include <asm/cacheflush.h>
34 #include <asm/tlbflush.h>
37 * We don't have PCI yet.
38 * _IO_BASE is pointing at what should be unused virtual space.
40 #define IO_SPACE_LIMIT 0xffff
41 #define _IO_BASE ((void __iomem *)0xfe000000)
43 #define IOMEM(x) ((void __force __iomem *)(x))
45 extern int remap_area_pages(unsigned long start
, unsigned long phys_addr
,
46 unsigned long end
, unsigned long flags
);
48 extern void __iounmap(const volatile void __iomem
*addr
);
50 /* Defined in lib/io.c, needed for smc91x driver. */
51 extern void __raw_readsw(const void __iomem
*addr
, void *data
, int wordlen
);
52 extern void __raw_writesw(void __iomem
*addr
, const void *data
, int wordlen
);
54 extern void __raw_readsl(const void __iomem
*addr
, void *data
, int wordlen
);
55 extern void __raw_writesl(void __iomem
*addr
, const void *data
, int wordlen
);
57 #define readsw(p, d, l) __raw_readsw(p, d, l)
58 #define writesw(p, d, l) __raw_writesw(p, d, l)
60 #define readsl(p, d, l) __raw_readsl(p, d, l)
61 #define writesl(p, d, l) __raw_writesl(p, d, l)
64 * virt_to_phys - map virtual address to physical
65 * @address: address to map
67 static inline unsigned long virt_to_phys(volatile void *address
)
73 * phys_to_virt - map physical address to virtual
74 * @address: address to map
76 static inline void *phys_to_virt(unsigned long address
)
82 * convert a physical pointer to a virtual kernel pointer for
85 #define xlate_dev_kmem_ptr(p) __va(p)
86 #define xlate_dev_mem_ptr(p) __va(p)
89 * IO port access primitives. Hexagon doesn't have special IO access
90 * instructions; all I/O is memory mapped.
92 * in/out are used for "ports", but we don't have "port instructions",
93 * so these are really just memory mapped too.
97 * readb - read byte from memory mapped device
98 * @addr: pointer to memory
100 * Operates on "I/O bus memory space"
102 static inline u8
readb(const volatile void __iomem
*addr
)
113 static inline u16
readw(const volatile void __iomem
*addr
)
124 static inline u32
readl(const volatile void __iomem
*addr
)
136 * writeb - write a byte to a memory location
137 * @data: data to write to
138 * @addr: pointer to memory
141 static inline void writeb(u8 data
, volatile void __iomem
*addr
)
146 : "r" (addr
), "r" (data
)
151 static inline void writew(u16 data
, volatile void __iomem
*addr
)
156 : "r" (addr
), "r" (data
)
162 static inline void writel(u32 data
, volatile void __iomem
*addr
)
167 : "r" (addr
), "r" (data
)
172 #define __raw_writeb writeb
173 #define __raw_writew writew
174 #define __raw_writel writel
176 #define __raw_readb readb
177 #define __raw_readw readw
178 #define __raw_readl readl
181 * http://comments.gmane.org/gmane.linux.ports.arm.kernel/117626
184 #define readb_relaxed __raw_readb
185 #define readw_relaxed __raw_readw
186 #define readl_relaxed __raw_readl
188 #define writeb_relaxed __raw_writeb
189 #define writew_relaxed __raw_writew
190 #define writel_relaxed __raw_writel
195 * Need an mtype somewhere in here, for cache type deals?
196 * This is probably too long for an inline.
198 void __iomem
*ioremap_nocache(unsigned long phys_addr
, unsigned long size
);
200 static inline void __iomem
*ioremap(unsigned long phys_addr
, unsigned long size
)
202 return ioremap_nocache(phys_addr
, size
);
205 static inline void iounmap(volatile void __iomem
*addr
)
210 #define __raw_writel writel
212 static inline void memcpy_fromio(void *dst
, const volatile void __iomem
*src
,
215 memcpy(dst
, (void *) src
, count
);
218 static inline void memcpy_toio(volatile void __iomem
*dst
, const void *src
,
221 memcpy((void *) dst
, src
, count
);
224 #define PCI_IO_ADDR (volatile void __iomem *)
227 * inb - read byte from I/O port or something
228 * @port: address in I/O space
230 * Operates on "I/O bus I/O space"
232 static inline u8
inb(unsigned long port
)
234 return readb(_IO_BASE
+ (port
& IO_SPACE_LIMIT
));
237 static inline u16
inw(unsigned long port
)
239 return readw(_IO_BASE
+ (port
& IO_SPACE_LIMIT
));
242 static inline u32
inl(unsigned long port
)
244 return readl(_IO_BASE
+ (port
& IO_SPACE_LIMIT
));
248 * outb - write a byte to a memory location
249 * @data: data to write to
250 * @addr: address in I/O space
252 static inline void outb(u8 data
, unsigned long port
)
254 writeb(data
, _IO_BASE
+ (port
& IO_SPACE_LIMIT
));
257 static inline void outw(u16 data
, unsigned long port
)
259 writew(data
, _IO_BASE
+ (port
& IO_SPACE_LIMIT
));
262 static inline void outl(u32 data
, unsigned long port
)
264 writel(data
, _IO_BASE
+ (port
& IO_SPACE_LIMIT
));
275 static inline void insb(unsigned long port
, void *buffer
, int count
)
286 static inline void insw(unsigned long port
, void *buffer
, int count
)
297 static inline void insl(unsigned long port
, void *buffer
, int count
)
308 static inline void outsb(unsigned long port
, const void *buffer
, int count
)
311 const u8
*buf
= buffer
;
318 static inline void outsw(unsigned long port
, const void *buffer
, int count
)
321 const u16
*buf
= buffer
;
328 static inline void outsl(unsigned long port
, const void *buffer
, int count
)
331 const u32
*buf
= buffer
;
338 #define flush_write_buffers() do { } while (0)
340 #endif /* __KERNEL__ */