io.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright 2004-2010 Analog Devices Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #ifndef _BFIN_IO_H
  7. #define _BFIN_IO_H
  8. #include <linux/compiler.h>
  9. #include <linux/types.h>
  10. #include <asm/byteorder.h>
  11. #define DECLARE_BFIN_RAW_READX(size, type, asm, asm_sign) \
  12. static inline type __raw_read##size(const volatile void __iomem *addr) \
  13. { \
  14. unsigned int val; \
  15. int tmp; \
  16. __asm__ __volatile__ ( \
  17. "cli %1;" \
  18. "NOP; NOP; SSYNC;" \
  19. "%0 = "#asm" [%2] "#asm_sign";" \
  20. "sti %1;" \
  21. : "=d"(val), "=d"(tmp) \
  22. : "a"(addr) \
  23. ); \
  24. return (type) val; \
  25. }
  26. DECLARE_BFIN_RAW_READX(b, u8, b, (z))
  27. #define __raw_readb __raw_readb
  28. DECLARE_BFIN_RAW_READX(w, u16, w, (z))
  29. #define __raw_readw __raw_readw
  30. DECLARE_BFIN_RAW_READX(l, u32, , )
  31. #define __raw_readl __raw_readl
  32. extern void outsb(unsigned long port, const void *addr, unsigned long count);
  33. extern void outsw(unsigned long port, const void *addr, unsigned long count);
  34. extern void outsw_8(unsigned long port, const void *addr, unsigned long count);
  35. extern void outsl(unsigned long port, const void *addr, unsigned long count);
  36. #define outsb outsb
  37. #define outsw outsw
  38. #define outsl outsl
  39. extern void insb(unsigned long port, void *addr, unsigned long count);
  40. extern void insw(unsigned long port, void *addr, unsigned long count);
  41. extern void insw_8(unsigned long port, void *addr, unsigned long count);
  42. extern void insl(unsigned long port, void *addr, unsigned long count);
  43. extern void insl_16(unsigned long port, void *addr, unsigned long count);
  44. #define insb insb
  45. #define insw insw
  46. #define insl insl
  47. extern void dma_outsb(unsigned long port, const void *addr, unsigned short count);
  48. extern void dma_outsw(unsigned long port, const void *addr, unsigned short count);
  49. extern void dma_outsl(unsigned long port, const void *addr, unsigned short count);
  50. extern void dma_insb(unsigned long port, void *addr, unsigned short count);
  51. extern void dma_insw(unsigned long port, void *addr, unsigned short count);
  52. extern void dma_insl(unsigned long port, void *addr, unsigned short count);
  53. /**
  54. * I/O write barrier
  55. *
  56. * Ensure ordering of I/O space writes. This will make sure that writes
  57. * following the barrier will arrive after all previous writes.
  58. */
  59. #define mmiowb() do { SSYNC(); wmb(); } while (0)
  60. #include <asm-generic/io.h>
  61. #endif