io.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. * I/O memory mapping functions.
  31. */
  32. #define ioremap_wc(addr, size) \
  33. ioremap_prot((addr), (size), \
  34. __pgprot((_PAGE_IOREMAP & ~_CACHE_MASK) | _CACHE_UNCACHED))
  35. #include <asm-generic/io.h>
  36. #endif /* __ASM_CSKY_IO_H */