2 * IO definitions for the Hexagon architecture
4 * Copyright (c) 2010-2011, Code Aurora Forum. 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 extern int remap_area_pages(unsigned long start
, unsigned long phys_addr
,
44 unsigned long end
, unsigned long flags
);
46 extern void __iounmap(const volatile void __iomem
*addr
);
48 /* Defined in lib/io.c, needed for smc91x driver. */
49 extern void __raw_readsw(const void __iomem
*addr
, void *data
, int wordlen
);
50 extern void __raw_writesw(void __iomem
*addr
, const void *data
, int wordlen
);
52 extern void __raw_readsl(const void __iomem
*addr
, void *data
, int wordlen
);
53 extern void __raw_writesl(void __iomem
*addr
, const void *data
, int wordlen
);
55 #define readsw(p, d, l) __raw_readsw(p, d, l)
56 #define writesw(p, d, l) __raw_writesw(p, d, l)
58 #define readsl(p, d, l) __raw_readsl(p, d, l)
59 #define writesl(p, d, l) __raw_writesl(p, d, l)
62 * virt_to_phys - map virtual address to physical
63 * @address: address to map
65 static inline unsigned long virt_to_phys(volatile void *address
)
71 * phys_to_virt - map physical address to virtual
72 * @address: address to map
74 static inline void *phys_to_virt(unsigned long address
)
80 * convert a physical pointer to a virtual kernel pointer for
83 #define xlate_dev_kmem_ptr(p) __va(p)
84 #define xlate_dev_mem_ptr(p) __va(p)
87 * IO port access primitives. Hexagon doesn't have special IO access
88 * instructions; all I/O is memory mapped.
90 * in/out are used for "ports", but we don't have "port instructions",
91 * so these are really just memory mapped too.
95 * readb - read byte from memory mapped device
96 * @addr: pointer to memory
98 * Operates on "I/O bus memory space"
100 static inline u8
readb(const volatile void __iomem
*addr
)
111 static inline u16
readw(const volatile void __iomem
*addr
)
122 static inline u32
readl(const volatile void __iomem
*addr
)
134 * writeb - write a byte to a memory location
135 * @data: data to write to
136 * @addr: pointer to memory
139 static inline void writeb(u8 data
, volatile void __iomem
*addr
)
144 : "r" (addr
), "r" (data
)
149 static inline void writew(u16 data
, volatile void __iomem
*addr
)
154 : "r" (addr
), "r" (data
)
160 static inline void writel(u32 data
, volatile void __iomem
*addr
)
165 : "r" (addr
), "r" (data
)
170 #define __raw_writeb writeb
171 #define __raw_writew writew
172 #define __raw_writel writel
174 #define __raw_readb readb
175 #define __raw_readw readw
176 #define __raw_readl readl
179 * Need an mtype somewhere in here, for cache type deals?
180 * This is probably too long for an inline.
182 void __iomem
*ioremap_nocache(unsigned long phys_addr
, unsigned long size
);
184 static inline void __iomem
*ioremap(unsigned long phys_addr
, unsigned long size
)
186 return ioremap_nocache(phys_addr
, size
);
189 static inline void iounmap(volatile void __iomem
*addr
)
194 #define __raw_writel writel
196 static inline void memcpy_fromio(void *dst
, const volatile void __iomem
*src
,
199 memcpy(dst
, (void *) src
, count
);
202 static inline void memcpy_toio(volatile void __iomem
*dst
, const void *src
,
205 memcpy((void *) dst
, src
, count
);
208 #define PCI_IO_ADDR (volatile void __iomem *)
211 * inb - read byte from I/O port or something
212 * @port: address in I/O space
214 * Operates on "I/O bus I/O space"
216 static inline u8
inb(unsigned long port
)
218 return readb(_IO_BASE
+ (port
& IO_SPACE_LIMIT
));
221 static inline u16
inw(unsigned long port
)
223 return readw(_IO_BASE
+ (port
& IO_SPACE_LIMIT
));
226 static inline u32
inl(unsigned long port
)
228 return readl(_IO_BASE
+ (port
& IO_SPACE_LIMIT
));
232 * outb - write a byte to a memory location
233 * @data: data to write to
234 * @addr: address in I/O space
236 static inline void outb(u8 data
, unsigned long port
)
238 writeb(data
, _IO_BASE
+ (port
& IO_SPACE_LIMIT
));
241 static inline void outw(u16 data
, unsigned long port
)
243 writew(data
, _IO_BASE
+ (port
& IO_SPACE_LIMIT
));
246 static inline void outl(u32 data
, unsigned long port
)
248 writel(data
, _IO_BASE
+ (port
& IO_SPACE_LIMIT
));
259 static inline void insb(unsigned long port
, void *buffer
, int count
)
270 static inline void insw(unsigned long port
, void *buffer
, int count
)
281 static inline void insl(unsigned long port
, void *buffer
, int count
)
292 static inline void outsb(unsigned long port
, const void *buffer
, int count
)
295 const u8
*buf
= buffer
;
302 static inline void outsw(unsigned long port
, const void *buffer
, int count
)
305 const u16
*buf
= buffer
;
312 static inline void outsl(unsigned long port
, const void *buffer
, int count
)
315 const u32
*buf
= buffer
;
322 #define flush_write_buffers() do { } while (0)
324 #endif /* __KERNEL__ */