io.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #define PCI_IOBASE ((void __iomem *)0)
  14. extern void __iomem *ioremap(unsigned long physaddr, unsigned long size);
  15. extern void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
  16. unsigned long flags);
  17. extern void iounmap(const void __iomem *addr);
  18. #define ioremap_nocache(phy, sz) ioremap(phy, sz)
  19. #define ioremap_wc(phy, sz) ioremap(phy, sz)
  20. /* Change struct page to physical address */
  21. #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
  22. #define __raw_readb __raw_readb
  23. static inline u8 __raw_readb(const volatile void __iomem *addr)
  24. {
  25. u8 b;
  26. __asm__ __volatile__(
  27. " ldb%U1 %0, %1 \n"
  28. : "=r" (b)
  29. : "m" (*(volatile u8 __force *)addr)
  30. : "memory");
  31. return b;
  32. }
  33. #define __raw_readw __raw_readw
  34. static inline u16 __raw_readw(const volatile void __iomem *addr)
  35. {
  36. u16 s;
  37. __asm__ __volatile__(
  38. " ldw%U1 %0, %1 \n"
  39. : "=r" (s)
  40. : "m" (*(volatile u16 __force *)addr)
  41. : "memory");
  42. return s;
  43. }
  44. #define __raw_readl __raw_readl
  45. static inline u32 __raw_readl(const volatile void __iomem *addr)
  46. {
  47. u32 w;
  48. __asm__ __volatile__(
  49. " ld%U1 %0, %1 \n"
  50. : "=r" (w)
  51. : "m" (*(volatile u32 __force *)addr)
  52. : "memory");
  53. return w;
  54. }
  55. #define __raw_writeb __raw_writeb
  56. static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
  57. {
  58. __asm__ __volatile__(
  59. " stb%U1 %0, %1 \n"
  60. :
  61. : "r" (b), "m" (*(volatile u8 __force *)addr)
  62. : "memory");
  63. }
  64. #define __raw_writew __raw_writew
  65. static inline void __raw_writew(u16 s, volatile void __iomem *addr)
  66. {
  67. __asm__ __volatile__(
  68. " stw%U1 %0, %1 \n"
  69. :
  70. : "r" (s), "m" (*(volatile u16 __force *)addr)
  71. : "memory");
  72. }
  73. #define __raw_writel __raw_writel
  74. static inline void __raw_writel(u32 w, volatile void __iomem *addr)
  75. {
  76. __asm__ __volatile__(
  77. " st%U1 %0, %1 \n"
  78. :
  79. : "r" (w), "m" (*(volatile u32 __force *)addr)
  80. : "memory");
  81. }
  82. #include <asm-generic/io.h>
  83. #endif /* _ASM_ARC_IO_H */