|
@@ -331,3 +331,153 @@ static inline void pfx##write##bwlq(type val, \
|
|
"dsrl32 %L0, %L0, 0" "\n\t" \
|
|
"dsrl32 %L0, %L0, 0" "\n\t" \
|
|
"dsll32 %M0, %M0, 0" "\n\t" \
|
|
"dsll32 %M0, %M0, 0" "\n\t" \
|
|
"or %L0, %L0, %M0" "\n\t" \
|
|
"or %L0, %L0, %M0" "\n\t" \
|
|
|
|
+ "sd %L0, %2" "\n\t" \
|
|
|
|
+ ".set mips0" "\n" \
|
|
|
|
+ : "=r" (__tmp) \
|
|
|
|
+ : "0" (__val), "m" (*__mem)); \
|
|
|
|
+ if (irq) \
|
|
|
|
+ local_irq_restore(__flags); \
|
|
|
|
+ } else \
|
|
|
|
+ BUG(); \
|
|
|
|
+} \
|
|
|
|
+ \
|
|
|
|
+static inline type pfx##read##bwlq(const volatile void __iomem *mem) \
|
|
|
|
+{ \
|
|
|
|
+ volatile type *__mem; \
|
|
|
|
+ type __val; \
|
|
|
|
+ \
|
|
|
|
+ __mem = (void *)__swizzle_addr_##bwlq((unsigned long)(mem)); \
|
|
|
|
+ \
|
|
|
|
+ if (sizeof(type) != sizeof(u64) || sizeof(u64) == sizeof(long)) \
|
|
|
|
+ __val = *__mem; \
|
|
|
|
+ else if (cpu_has_64bits) { \
|
|
|
|
+ unsigned long __flags; \
|
|
|
|
+ \
|
|
|
|
+ if (irq) \
|
|
|
|
+ local_irq_save(__flags); \
|
|
|
|
+ __asm__ __volatile__( \
|
|
|
|
+ ".set mips3" "\t\t# __readq" "\n\t" \
|
|
|
|
+ "ld %L0, %1" "\n\t" \
|
|
|
|
+ "dsra32 %M0, %L0, 0" "\n\t" \
|
|
|
|
+ "sll %L0, %L0, 0" "\n\t" \
|
|
|
|
+ ".set mips0" "\n" \
|
|
|
|
+ : "=r" (__val) \
|
|
|
|
+ : "m" (*__mem)); \
|
|
|
|
+ if (irq) \
|
|
|
|
+ local_irq_restore(__flags); \
|
|
|
|
+ } else { \
|
|
|
|
+ __val = 0; \
|
|
|
|
+ BUG(); \
|
|
|
|
+ } \
|
|
|
|
+ \
|
|
|
|
+ return pfx##ioswab##bwlq(__mem, __val); \
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, p, slow) \
|
|
|
|
+ \
|
|
|
|
+static inline void pfx##out##bwlq##p(type val, unsigned long port) \
|
|
|
|
+{ \
|
|
|
|
+ volatile type *__addr; \
|
|
|
|
+ type __val; \
|
|
|
|
+ \
|
|
|
|
+ war_octeon_io_reorder_wmb(); \
|
|
|
|
+ \
|
|
|
|
+ __addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port); \
|
|
|
|
+ \
|
|
|
|
+ __val = pfx##ioswab##bwlq(__addr, val); \
|
|
|
|
+ \
|
|
|
|
+ /* Really, we want this to be atomic */ \
|
|
|
|
+ BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
|
|
|
|
+ \
|
|
|
|
+ *__addr = __val; \
|
|
|
|
+ slow; \
|
|
|
|
+} \
|
|
|
|
+ \
|
|
|
|
+static inline type pfx##in##bwlq##p(unsigned long port) \
|
|
|
|
+{ \
|
|
|
|
+ volatile type *__addr; \
|
|
|
|
+ type __val; \
|
|
|
|
+ \
|
|
|
|
+ __addr = (void *)__swizzle_addr_##bwlq(mips_io_port_base + port); \
|
|
|
|
+ \
|
|
|
|
+ BUILD_BUG_ON(sizeof(type) > sizeof(unsigned long)); \
|
|
|
|
+ \
|
|
|
|
+ __val = *__addr; \
|
|
|
|
+ slow; \
|
|
|
|
+ \
|
|
|
|
+ return pfx##ioswab##bwlq(__addr, __val); \
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#define __BUILD_MEMORY_PFX(bus, bwlq, type) \
|
|
|
|
+ \
|
|
|
|
+__BUILD_MEMORY_SINGLE(bus, bwlq, type, 1)
|
|
|
|
+
|
|
|
|
+#define BUILDIO_MEM(bwlq, type) \
|
|
|
|
+ \
|
|
|
|
+__BUILD_MEMORY_PFX(__raw_, bwlq, type) \
|
|
|
|
+__BUILD_MEMORY_PFX(, bwlq, type) \
|
|
|
|
+__BUILD_MEMORY_PFX(__mem_, bwlq, type) \
|
|
|
|
+
|
|
|
|
+BUILDIO_MEM(b, u8)
|
|
|
|
+BUILDIO_MEM(w, u16)
|
|
|
|
+BUILDIO_MEM(l, u32)
|
|
|
|
+BUILDIO_MEM(q, u64)
|
|
|
|
+
|
|
|
|
+#define __BUILD_IOPORT_PFX(bus, bwlq, type) \
|
|
|
|
+ __BUILD_IOPORT_SINGLE(bus, bwlq, type, ,) \
|
|
|
|
+ __BUILD_IOPORT_SINGLE(bus, bwlq, type, _p, SLOW_DOWN_IO)
|
|
|
|
+
|
|
|
|
+#define BUILDIO_IOPORT(bwlq, type) \
|
|
|
|
+ __BUILD_IOPORT_PFX(, bwlq, type) \
|
|
|
|
+ __BUILD_IOPORT_PFX(__mem_, bwlq, type)
|
|
|
|
+
|
|
|
|
+BUILDIO_IOPORT(b, u8)
|
|
|
|
+BUILDIO_IOPORT(w, u16)
|
|
|
|
+BUILDIO_IOPORT(l, u32)
|
|
|
|
+#ifdef CONFIG_64BIT
|
|
|
|
+BUILDIO_IOPORT(q, u64)
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#define __BUILDIO(bwlq, type) \
|
|
|
|
+ \
|
|
|
|
+__BUILD_MEMORY_SINGLE(____raw_, bwlq, type, 0)
|
|
|
|
+
|
|
|
|
+__BUILDIO(q, u64)
|
|
|
|
+
|
|
|
|
+#define readb_relaxed readb
|
|
|
|
+#define readw_relaxed readw
|
|
|
|
+#define readl_relaxed readl
|
|
|
|
+#define readq_relaxed readq
|
|
|
|
+
|
|
|
|
+#define readb_be(addr) \
|
|
|
|
+ __raw_readb((__force unsigned *)(addr))
|
|
|
|
+#define readw_be(addr) \
|
|
|
|
+ be16_to_cpu(__raw_readw((__force unsigned *)(addr)))
|
|
|
|
+#define readl_be(addr) \
|
|
|
|
+ be32_to_cpu(__raw_readl((__force unsigned *)(addr)))
|
|
|
|
+#define readq_be(addr) \
|
|
|
|
+ be64_to_cpu(__raw_readq((__force unsigned *)(addr)))
|
|
|
|
+
|
|
|
|
+#define writeb_be(val, addr) \
|
|
|
|
+ __raw_writeb((val), (__force unsigned *)(addr))
|
|
|
|
+#define writew_be(val, addr) \
|
|
|
|
+ __raw_writew(cpu_to_be16((val)), (__force unsigned *)(addr))
|
|
|
|
+#define writel_be(val, addr) \
|
|
|
|
+ __raw_writel(cpu_to_be32((val)), (__force unsigned *)(addr))
|
|
|
|
+#define writeq_be(val, addr) \
|
|
|
|
+ __raw_writeq(cpu_to_be64((val)), (__force unsigned *)(addr))
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Some code tests for these symbols
|
|
|
|
+ */
|
|
|
|
+#define readq readq
|
|
|
|
+#define writeq writeq
|
|
|
|
+
|
|
|
|
+#define __BUILD_MEMORY_STRING(bwlq, type) \
|
|
|
|
+ \
|
|
|
|
+static inline void writes##bwlq(volatile void __iomem *mem, \
|
|
|
|
+ const void *addr, unsigned int count) \
|
|
|
|
+{ \
|
|
|
|
+ const volatile type *__addr = addr; \
|
|
|
|
+ \
|
|
|
|
+ while (count--) { \
|