io.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef _ASM_ARC_IO_H
  9. #define _ASM_ARC_IO_H
  10. #include <linux/types.h>
  11. #include <asm/byteorder.h>
  12. #include <asm/page.h>
  13. extern void __iomem *ioremap(unsigned long physaddr, unsigned long size);
  14. extern void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
  15. unsigned long flags);
  16. extern void iounmap(const void __iomem *addr);
  17. #define ioremap_nocache(phy, sz) ioremap(phy, sz)
  18. #define ioremap_wc(phy, sz) ioremap(phy, sz)
  19. /* Change struct page to physical address */
  20. #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
  21. #define __raw_readb __raw_readb
  22. static inline u8 __raw_readb(const volatile void __iomem *addr)
  23. {
  24. u8 b;
  25. __asm__ __volatile__(
  26. " ldb%U1 %0, %1 \n"
  27. : "=r" (b)
  28. : "m" (*(volatile u8 __force *)addr)
  29. : "memory");
  30. return b;
  31. }
  32. #define __raw_readw __raw_readw
  33. static inline u16 __raw_readw(const volatile void __iomem *addr)
  34. {
  35. u16 s;
  36. __asm__ __volatile__(
  37. " ldw%U1 %0, %1 \n"
  38. : "=r" (s)
  39. : "m" (*(volatile u16 __force *)addr)
  40. : "memory");
  41. return s;
  42. }
  43. #define __raw_readl __raw_readl
  44. static inline u32 __raw_readl(const volatile void __iomem *addr)
  45. {
  46. u32 w;
  47. __asm__ __volatile__(
  48. " ld%U1 %0, %1 \n"
  49. : "=r" (w)
  50. : "m" (*(volatile u32 __force *)addr)
  51. : "memory");
  52. return w;
  53. }
  54. #define __raw_writeb __raw_writeb
  55. static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
  56. {
  57. __asm__ __volatile__(
  58. " stb%U1 %0, %1 \n"
  59. :
  60. : "r" (b), "m" (*(volatile u8 __force *)addr)
  61. : "memory");
  62. }
  63. #define __raw_writew __raw_writew
  64. static inline void __raw_writew(u16 s, volatile void __iomem *addr)
  65. {
  66. __asm__ __volatile__(
  67. " stw%U1 %0, %1 \n"
  68. :
  69. : "r" (s), "m" (*(volatile u16 __force *)addr)
  70. : "memory");
  71. }
  72. #define __raw_writel __raw_writel
  73. static inline void __raw_writel(u32 w, volatile void __iomem *addr)
  74. {
  75. __asm__ __volatile__(
  76. " st%U1 %0, %1 \n"
  77. :
  78. : "r" (w), "m" (*(volatile u32 __force *)addr)
  79. : "memory");
  80. }
  81. #define readb_relaxed readb
  82. #define readw_relaxed readw
  83. #define readl_relaxed readl
  84. #include <asm-generic/io.h>
  85. #endif /* _ASM_ARC_IO_H */