|
@@ -95,3 +95,164 @@ static inline void io_insw(unsigned long addr, void *buf, int len)
|
|
|
*bp++ = __builtin_read16((volatile void __iomem *) addr);
|
|
|
}
|
|
|
|
|
|
+extern void __insl_ns(unsigned long addr, void *buf, int len);
|
|
|
+extern void __insl_sw(unsigned long addr, void *buf, int len);
|
|
|
+static inline void __insl(unsigned long addr, void *buf, int len, int swap)
|
|
|
+{
|
|
|
+ if (!swap)
|
|
|
+ __insl_ns(addr, buf, len);
|
|
|
+ else
|
|
|
+ __insl_sw(addr, buf, len);
|
|
|
+}
|
|
|
+
|
|
|
+#define mmiowb() mb()
|
|
|
+
|
|
|
+/*
|
|
|
+ * make the short names macros so specific devices
|
|
|
+ * can override them as required
|
|
|
+ */
|
|
|
+
|
|
|
+static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
|
|
|
+{
|
|
|
+ memset((void __force *) addr, val, count);
|
|
|
+}
|
|
|
+
|
|
|
+static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
|
|
|
+{
|
|
|
+ memcpy(dst, (void __force *) src, count);
|
|
|
+}
|
|
|
+
|
|
|
+static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
|
|
|
+{
|
|
|
+ memcpy((void __force *) dst, src, count);
|
|
|
+}
|
|
|
+
|
|
|
+static inline uint8_t inb(unsigned long addr)
|
|
|
+{
|
|
|
+ return __builtin_read8((void __iomem *)addr);
|
|
|
+}
|
|
|
+
|
|
|
+static inline uint16_t inw(unsigned long addr)
|
|
|
+{
|
|
|
+ uint16_t ret = __builtin_read16((void __iomem *)addr);
|
|
|
+
|
|
|
+ if (__is_PCI_IO(addr))
|
|
|
+ ret = _swapw(ret);
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+static inline uint32_t inl(unsigned long addr)
|
|
|
+{
|
|
|
+ uint32_t ret = __builtin_read32((void __iomem *)addr);
|
|
|
+
|
|
|
+ if (__is_PCI_IO(addr))
|
|
|
+ ret = _swapl(ret);
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+static inline void outb(uint8_t datum, unsigned long addr)
|
|
|
+{
|
|
|
+ __builtin_write8((void __iomem *)addr, datum);
|
|
|
+}
|
|
|
+
|
|
|
+static inline void outw(uint16_t datum, unsigned long addr)
|
|
|
+{
|
|
|
+ if (__is_PCI_IO(addr))
|
|
|
+ datum = _swapw(datum);
|
|
|
+ __builtin_write16((void __iomem *)addr, datum);
|
|
|
+}
|
|
|
+
|
|
|
+static inline void outl(uint32_t datum, unsigned long addr)
|
|
|
+{
|
|
|
+ if (__is_PCI_IO(addr))
|
|
|
+ datum = _swapl(datum);
|
|
|
+ __builtin_write32((void __iomem *)addr, datum);
|
|
|
+}
|
|
|
+
|
|
|
+#define inb_p(addr) inb(addr)
|
|
|
+#define inw_p(addr) inw(addr)
|
|
|
+#define inl_p(addr) inl(addr)
|
|
|
+#define outb_p(x,addr) outb(x,addr)
|
|
|
+#define outw_p(x,addr) outw(x,addr)
|
|
|
+#define outl_p(x,addr) outl(x,addr)
|
|
|
+
|
|
|
+#define outsb(a,b,l) io_outsb(a,b,l)
|
|
|
+#define outsw(a,b,l) io_outsw(a,b,l)
|
|
|
+#define outsl(a,b,l) __outsl(a,b,l,0)
|
|
|
+
|
|
|
+#define insb(a,b,l) io_insb(a,b,l)
|
|
|
+#define insw(a,b,l) io_insw(a,b,l)
|
|
|
+#define insl(a,b,l) __insl(a,b,l,0)
|
|
|
+
|
|
|
+#define IO_SPACE_LIMIT 0xffffffff
|
|
|
+
|
|
|
+static inline uint8_t readb(const volatile void __iomem *addr)
|
|
|
+{
|
|
|
+ return __builtin_read8((__force void volatile __iomem *) addr);
|
|
|
+}
|
|
|
+
|
|
|
+static inline uint16_t readw(const volatile void __iomem *addr)
|
|
|
+{
|
|
|
+ uint16_t ret = __builtin_read16((__force void volatile __iomem *)addr);
|
|
|
+
|
|
|
+ if (__is_PCI_MEM(addr))
|
|
|
+ ret = _swapw(ret);
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+static inline uint32_t readl(const volatile void __iomem *addr)
|
|
|
+{
|
|
|
+ uint32_t ret = __builtin_read32((__force void volatile __iomem *)addr);
|
|
|
+
|
|
|
+ if (__is_PCI_MEM(addr))
|
|
|
+ ret = _swapl(ret);
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+#define readb_relaxed readb
|
|
|
+#define readw_relaxed readw
|
|
|
+#define readl_relaxed readl
|
|
|
+
|
|
|
+static inline void writeb(uint8_t datum, volatile void __iomem *addr)
|
|
|
+{
|
|
|
+ __builtin_write8(addr, datum);
|
|
|
+ if (__is_PCI_MEM(addr))
|
|
|
+ __flush_PCI_writes();
|
|
|
+}
|
|
|
+
|
|
|
+static inline void writew(uint16_t datum, volatile void __iomem *addr)
|
|
|
+{
|
|
|
+ if (__is_PCI_MEM(addr))
|
|
|
+ datum = _swapw(datum);
|
|
|
+
|
|
|
+ __builtin_write16(addr, datum);
|
|
|
+ if (__is_PCI_MEM(addr))
|
|
|
+ __flush_PCI_writes();
|
|
|
+}
|
|
|
+
|
|
|
+static inline void writel(uint32_t datum, volatile void __iomem *addr)
|
|
|
+{
|
|
|
+ if (__is_PCI_MEM(addr))
|
|
|
+ datum = _swapl(datum);
|
|
|
+
|
|
|
+ __builtin_write32(addr, datum);
|
|
|
+ if (__is_PCI_MEM(addr))
|
|
|
+ __flush_PCI_writes();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/* Values for nocacheflag and cmode */
|
|
|
+#define IOMAP_FULL_CACHING 0
|
|
|
+#define IOMAP_NOCACHE_SER 1
|
|
|
+#define IOMAP_NOCACHE_NONSER 2
|
|
|
+#define IOMAP_WRITETHROUGH 3
|
|
|
+
|
|
|
+extern void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag);
|
|
|
+
|
|
|
+static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)
|
|
|
+{
|
|
|
+ return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
|
|
|
+}
|