io.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_CSKY_IO_H
  3. #define __ASM_CSKY_IO_H
  4. #include <linux/pgtable.h>
  5. #include <linux/types.h>
  6. /*
  7. * I/O memory access primitives. Reads are ordered relative to any
  8. * following Normal memory access. Writes are ordered relative to any prior
  9. * Normal memory access.
  10. *
  11. * For CACHEV1 (807, 810), store instruction could fast retire, so we need
  12. * another mb() to prevent st fast retire.
  13. *
  14. * For CACHEV2 (860), store instruction with PAGE_ATTR_NO_BUFFERABLE won't
  15. * fast retire.
  16. */
  17. #define readb(c) ({ u8 __v = readb_relaxed(c); rmb(); __v; })
  18. #define readw(c) ({ u16 __v = readw_relaxed(c); rmb(); __v; })
  19. #define readl(c) ({ u32 __v = readl_relaxed(c); rmb(); __v; })
  20. #ifdef CONFIG_CPU_HAS_CACHEV2
  21. #define writeb(v,c) ({ wmb(); writeb_relaxed((v),(c)); })
  22. #define writew(v,c) ({ wmb(); writew_relaxed((v),(c)); })
  23. #define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); })
  24. #else
  25. #define writeb(v,c) ({ wmb(); writeb_relaxed((v),(c)); mb(); })
  26. #define writew(v,c) ({ wmb(); writew_relaxed((v),(c)); mb(); })
  27. #define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); mb(); })
  28. #endif
  29. /*
  30. * String version of I/O memory access operations.
  31. */
  32. extern void __memcpy_fromio(void *, const volatile void __iomem *, size_t);
  33. extern void __memcpy_toio(volatile void __iomem *, const void *, size_t);
  34. extern void __memset_io(volatile void __iomem *, int, size_t);
  35. #define memset_io(c,v,l) __memset_io((c),(v),(l))
  36. #define memcpy_fromio(a,c,l) __memcpy_fromio((a),(c),(l))
  37. #define memcpy_toio(c,a,l) __memcpy_toio((c),(a),(l))
  38. /*
  39. * I/O memory mapping functions.
  40. */
  41. #define ioremap_wc(addr, size) \
  42. ioremap_prot((addr), (size), \
  43. (_PAGE_IOREMAP & ~_CACHE_MASK) | _CACHE_UNCACHED)
  44. #include <asm-generic/io.h>
  45. #endif /* __ASM_CSKY_IO_H */