aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/include/asm/io.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/tile/include/asm/io.h')
-rw-r--r--arch/tile/include/asm/io.h126
1 files changed, 117 insertions, 9 deletions
diff --git a/arch/tile/include/asm/io.h b/arch/tile/include/asm/io.h
index 31672918064c..73b319e39a3b 100644
--- a/arch/tile/include/asm/io.h
+++ b/arch/tile/include/asm/io.h
@@ -19,7 +19,8 @@
19#include <linux/bug.h> 19#include <linux/bug.h>
20#include <asm/page.h> 20#include <asm/page.h>
21 21
22#define IO_SPACE_LIMIT 0xfffffffful 22/* Maximum PCI I/O space address supported. */
23#define IO_SPACE_LIMIT 0xffffffff
23 24
24/* 25/*
25 * Convert a physical pointer to a virtual kernel pointer for /dev/mem 26 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
@@ -281,8 +282,108 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src,
281 282
282#endif 283#endif
283 284
285#if CHIP_HAS_MMIO() && defined(CONFIG_TILE_PCI_IO)
286
287static inline u8 inb(unsigned long addr)
288{
289 return readb((volatile void __iomem *) addr);
290}
291
292static inline u16 inw(unsigned long addr)
293{
294 return readw((volatile void __iomem *) addr);
295}
296
297static inline u32 inl(unsigned long addr)
298{
299 return readl((volatile void __iomem *) addr);
300}
301
302static inline void outb(u8 b, unsigned long addr)
303{
304 writeb(b, (volatile void __iomem *) addr);
305}
306
307static inline void outw(u16 b, unsigned long addr)
308{
309 writew(b, (volatile void __iomem *) addr);
310}
311
312static inline void outl(u32 b, unsigned long addr)
313{
314 writel(b, (volatile void __iomem *) addr);
315}
316
317static inline void insb(unsigned long addr, void *buffer, int count)
318{
319 if (count) {
320 u8 *buf = buffer;
321 do {
322 u8 x = inb(addr);
323 *buf++ = x;
324 } while (--count);
325 }
326}
327
328static inline void insw(unsigned long addr, void *buffer, int count)
329{
330 if (count) {
331 u16 *buf = buffer;
332 do {
333 u16 x = inw(addr);
334 *buf++ = x;
335 } while (--count);
336 }
337}
338
339static inline void insl(unsigned long addr, void *buffer, int count)
340{
341 if (count) {
342 u32 *buf = buffer;
343 do {
344 u32 x = inl(addr);
345 *buf++ = x;
346 } while (--count);
347 }
348}
349
350static inline void outsb(unsigned long addr, const void *buffer, int count)
351{
352 if (count) {
353 const u8 *buf = buffer;
354 do {
355 outb(*buf++, addr);
356 } while (--count);
357 }
358}
359
360static inline void outsw(unsigned long addr, const void *buffer, int count)
361{
362 if (count) {
363 const u16 *buf = buffer;
364 do {
365 outw(*buf++, addr);
366 } while (--count);
367 }
368}
369
370static inline void outsl(unsigned long addr, const void *buffer, int count)
371{
372 if (count) {
373 const u32 *buf = buffer;
374 do {
375 outl(*buf++, addr);
376 } while (--count);
377 }
378}
379
380extern void __iomem *ioport_map(unsigned long port, unsigned int len);
381extern void ioport_unmap(void __iomem *addr);
382
383#else
384
284/* 385/*
285 * The Tile architecture does not support IOPORT, even with PCI. 386 * The TilePro architecture does not support IOPORT, even with PCI.
286 * Unfortunately we can't yet simply not declare these methods, 387 * Unfortunately we can't yet simply not declare these methods,
287 * since some generic code that compiles into the kernel, but 388 * since some generic code that compiles into the kernel, but
288 * we never run, uses them unconditionally. 389 * we never run, uses them unconditionally.
@@ -290,7 +391,12 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src,
290 391
291static inline long ioport_panic(void) 392static inline long ioport_panic(void)
292{ 393{
394#ifdef __tilegx__
395 panic("PCI IO space support is disabled. Configure the kernel with"
396 " CONFIG_TILE_PCI_IO to enable it");
397#else
293 panic("inb/outb and friends do not exist on tile"); 398 panic("inb/outb and friends do not exist on tile");
399#endif
294 return 0; 400 return 0;
295} 401}
296 402
@@ -335,13 +441,6 @@ static inline void outl(u32 b, unsigned long addr)
335 ioport_panic(); 441 ioport_panic();
336} 442}
337 443
338#define inb_p(addr) inb(addr)
339#define inw_p(addr) inw(addr)
340#define inl_p(addr) inl(addr)
341#define outb_p(x, addr) outb((x), (addr))
342#define outw_p(x, addr) outw((x), (addr))
343#define outl_p(x, addr) outl((x), (addr))
344
345static inline void insb(unsigned long addr, void *buffer, int count) 444static inline void insb(unsigned long addr, void *buffer, int count)
346{ 445{
347 ioport_panic(); 446 ioport_panic();
@@ -372,6 +471,15 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
372 ioport_panic(); 471 ioport_panic();
373} 472}
374 473
474#endif /* CHIP_HAS_MMIO() && defined(CONFIG_TILE_PCI_IO) */
475
476#define inb_p(addr) inb(addr)
477#define inw_p(addr) inw(addr)
478#define inl_p(addr) inl(addr)
479#define outb_p(x, addr) outb((x), (addr))
480#define outw_p(x, addr) outw((x), (addr))
481#define outl_p(x, addr) outl((x), (addr))
482
375#define ioread16be(addr) be16_to_cpu(ioread16(addr)) 483#define ioread16be(addr) be16_to_cpu(ioread16(addr))
376#define ioread32be(addr) be32_to_cpu(ioread32(addr)) 484#define ioread32be(addr) be32_to_cpu(ioread32(addr))
377#define iowrite16be(v, addr) iowrite16(be16_to_cpu(v), (addr)) 485#define iowrite16be(v, addr) iowrite16(be16_to_cpu(v), (addr))