H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_IO_H |
| 2 | #define _ASM_X86_IO_H |
venkatesh.pallipadi@intel.com | e045fb2 | 2008-03-18 17:00:15 -0700 | [diff] [blame] | 3 | |
venkatesh.pallipadi@intel.com | b310f381d | 2008-03-18 17:00:24 -0700 | [diff] [blame] | 4 | #define ARCH_HAS_IOREMAP_WC |
| 5 | |
Linus Torvalds | c1f64a5 | 2008-05-27 09:47:13 -0700 | [diff] [blame] | 6 | #include <linux/compiler.h> |
Hitoshi Mitake | 2c5643b | 2008-11-30 17:16:04 +0900 | [diff] [blame] | 7 | #include <asm-generic/int-ll64.h> |
Linus Torvalds | c1f64a5 | 2008-05-27 09:47:13 -0700 | [diff] [blame] | 8 | |
| 9 | #define build_mmio_read(name, size, type, reg, barrier) \ |
| 10 | static inline type name(const volatile void __iomem *addr) \ |
Mikael Pettersson | 1c5b0eb | 2008-08-13 21:07:07 +0200 | [diff] [blame] | 11 | { type ret; asm volatile("mov" size " %1,%0":reg (ret) \ |
Linus Torvalds | c1f64a5 | 2008-05-27 09:47:13 -0700 | [diff] [blame] | 12 | :"m" (*(volatile type __force *)addr) barrier); return ret; } |
| 13 | |
| 14 | #define build_mmio_write(name, size, type, reg, barrier) \ |
| 15 | static inline void name(type val, volatile void __iomem *addr) \ |
| 16 | { asm volatile("mov" size " %0,%1": :reg (val), \ |
| 17 | "m" (*(volatile type __force *)addr) barrier); } |
| 18 | |
Mikael Pettersson | 1c5b0eb | 2008-08-13 21:07:07 +0200 | [diff] [blame] | 19 | build_mmio_read(readb, "b", unsigned char, "=q", :"memory") |
| 20 | build_mmio_read(readw, "w", unsigned short, "=r", :"memory") |
| 21 | build_mmio_read(readl, "l", unsigned int, "=r", :"memory") |
Linus Torvalds | c1f64a5 | 2008-05-27 09:47:13 -0700 | [diff] [blame] | 22 | |
Mikael Pettersson | 1c5b0eb | 2008-08-13 21:07:07 +0200 | [diff] [blame] | 23 | build_mmio_read(__readb, "b", unsigned char, "=q", ) |
| 24 | build_mmio_read(__readw, "w", unsigned short, "=r", ) |
| 25 | build_mmio_read(__readl, "l", unsigned int, "=r", ) |
Linus Torvalds | c1f64a5 | 2008-05-27 09:47:13 -0700 | [diff] [blame] | 26 | |
| 27 | build_mmio_write(writeb, "b", unsigned char, "q", :"memory") |
| 28 | build_mmio_write(writew, "w", unsigned short, "r", :"memory") |
| 29 | build_mmio_write(writel, "l", unsigned int, "r", :"memory") |
| 30 | |
| 31 | build_mmio_write(__writeb, "b", unsigned char, "q", ) |
| 32 | build_mmio_write(__writew, "w", unsigned short, "r", ) |
| 33 | build_mmio_write(__writel, "l", unsigned int, "r", ) |
| 34 | |
| 35 | #define readb_relaxed(a) __readb(a) |
| 36 | #define readw_relaxed(a) __readw(a) |
| 37 | #define readl_relaxed(a) __readl(a) |
| 38 | #define __raw_readb __readb |
| 39 | #define __raw_readw __readw |
| 40 | #define __raw_readl __readl |
| 41 | |
| 42 | #define __raw_writeb __writeb |
| 43 | #define __raw_writew __writew |
| 44 | #define __raw_writel __writel |
| 45 | |
| 46 | #define mmiowb() barrier() |
| 47 | |
| 48 | #ifdef CONFIG_X86_64 |
Ingo Molnar | 93093d0 | 2008-11-30 10:20:20 +0100 | [diff] [blame] | 49 | |
Mikael Pettersson | 1c5b0eb | 2008-08-13 21:07:07 +0200 | [diff] [blame] | 50 | build_mmio_read(readq, "q", unsigned long, "=r", :"memory") |
Linus Torvalds | c1f64a5 | 2008-05-27 09:47:13 -0700 | [diff] [blame] | 51 | build_mmio_write(writeq, "q", unsigned long, "r", :"memory") |
Linus Torvalds | c1f64a5 | 2008-05-27 09:47:13 -0700 | [diff] [blame] | 52 | |
Ingo Molnar | 93093d0 | 2008-11-30 10:20:20 +0100 | [diff] [blame] | 53 | #else |
Hitoshi Mitake | 2c5643b | 2008-11-30 17:16:04 +0900 | [diff] [blame] | 54 | |
| 55 | static inline __u64 readq(const volatile void __iomem *addr) |
| 56 | { |
| 57 | const volatile u32 __iomem *p = addr; |
Ingo Molnar | a0b1131 | 2008-11-30 09:33:55 +0100 | [diff] [blame] | 58 | u32 low, high; |
Hitoshi Mitake | 2c5643b | 2008-11-30 17:16:04 +0900 | [diff] [blame] | 59 | |
Ingo Molnar | a0b1131 | 2008-11-30 09:33:55 +0100 | [diff] [blame] | 60 | low = readl(p); |
| 61 | high = readl(p + 1); |
Hitoshi Mitake | 2c5643b | 2008-11-30 17:16:04 +0900 | [diff] [blame] | 62 | |
Ingo Molnar | a0b1131 | 2008-11-30 09:33:55 +0100 | [diff] [blame] | 63 | return low + ((u64)high << 32); |
Hitoshi Mitake | 2c5643b | 2008-11-30 17:16:04 +0900 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | static inline void writeq(__u64 val, volatile void __iomem *addr) |
| 67 | { |
| 68 | writel(val, addr); |
| 69 | writel(val >> 32, addr+4); |
| 70 | } |
| 71 | |
Ingo Molnar | a0b1131 | 2008-11-30 09:33:55 +0100 | [diff] [blame] | 72 | #endif |
| 73 | |
Ingo Molnar | 93093d0 | 2008-11-30 10:20:20 +0100 | [diff] [blame] | 74 | #define readq_relaxed(a) readq(a) |
| 75 | |
| 76 | #define __raw_readq(a) readq(a) |
| 77 | #define __raw_writeq(val, addr) writeq(val, addr) |
| 78 | |
Ingo Molnar | a0b1131 | 2008-11-30 09:33:55 +0100 | [diff] [blame] | 79 | /* Let people know that we have them */ |
Ingo Molnar | 93093d0 | 2008-11-30 10:20:20 +0100 | [diff] [blame] | 80 | #define readq readq |
| 81 | #define writeq writeq |
Hitoshi Mitake | 2c5643b | 2008-11-30 17:16:04 +0900 | [diff] [blame] | 82 | |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 83 | #ifdef CONFIG_X86_32 |
| 84 | # include "io_32.h" |
| 85 | #else |
| 86 | # include "io_64.h" |
| 87 | #endif |
venkatesh.pallipadi@intel.com | e045fb2 | 2008-03-18 17:00:15 -0700 | [diff] [blame] | 88 | |
| 89 | extern void *xlate_dev_mem_ptr(unsigned long phys); |
| 90 | extern void unxlate_dev_mem_ptr(unsigned long phys, void *addr); |
| 91 | |
venkatesh.pallipadi@intel.com | 3a96ce8 | 2008-03-18 17:00:16 -0700 | [diff] [blame] | 92 | extern int ioremap_change_attr(unsigned long vaddr, unsigned long size, |
| 93 | unsigned long prot_val); |
Joe Perches | 1774a5b | 2008-03-23 01:02:25 -0700 | [diff] [blame] | 94 | extern void __iomem *ioremap_wc(unsigned long offset, unsigned long size); |
venkatesh.pallipadi@intel.com | 3a96ce8 | 2008-03-18 17:00:16 -0700 | [diff] [blame] | 95 | |
Jeremy Fitzhardinge | 4583ed5 | 2008-06-25 00:19:03 -0400 | [diff] [blame] | 96 | /* |
| 97 | * early_ioremap() and early_iounmap() are for temporary early boot-time |
| 98 | * mappings, before the real ioremap() is functional. |
| 99 | * A boot-time mapping is currently limited to at most 16 pages. |
| 100 | */ |
| 101 | extern void early_ioremap_init(void); |
| 102 | extern void early_ioremap_clear(void); |
| 103 | extern void early_ioremap_reset(void); |
Harvey Harrison | 1d6cf1f | 2008-10-28 22:46:04 -0700 | [diff] [blame] | 104 | extern void __iomem *early_ioremap(unsigned long offset, unsigned long size); |
| 105 | extern void __iomem *early_memremap(unsigned long offset, unsigned long size); |
| 106 | extern void early_iounmap(void __iomem *addr, unsigned long size); |
Jeremy Fitzhardinge | 4583ed5 | 2008-06-25 00:19:03 -0400 | [diff] [blame] | 107 | extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); |
| 108 | |
Jeremy Fitzhardinge | a448720 | 2009-01-28 15:42:23 -0800 | [diff] [blame^] | 109 | #define IO_SPACE_LIMIT 0xffff |
Jeremy Fitzhardinge | 4583ed5 | 2008-06-25 00:19:03 -0400 | [diff] [blame] | 110 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 111 | #endif /* _ASM_X86_IO_H */ |