normalDataOperation.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * arch/arm/include/asm/io.h
  3. *
  4. * Copyright (C) 1996-2000 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Modifications:
  11. * 16-Sep-1996 RMK Inlined the inx/outx functions & optimised for both
  12. * constant addresses and variable addresses.
  13. * 04-Dec-1997 RMK Moved a lot of this stuff to the new architecture
  14. * specific IO header files.
  15. * 27-Mar-1999 PJB Second parameter of memcpy_toio is const..
  16. * 04-Apr-1999 PJB Added check_signature.
  17. * 12-Dec-1999 RMK More cleanups
  18. * 18-Jun-2000 RMK Removed virt_to_* and friends definitions
  19. * 05-Oct-2004 BJD Moved memory string functions to use void __iomem
  20. */
  21. #ifndef __ASM_ARM_IO_H
  22. #define __ASM_ARM_IO_H
  23. #ifdef __KERNEL__
  24. #include <linux/types.h>
  25. #include <asm/byteorder.h>
  26. #include <asm/memory.h>
  27. #include <asm-generic/pci_iomap.h>
  28. /*
  29. * ISA I/O bus memory addresses are 1:1 with the physical address.
  30. */
  31. #define isa_virt_to_bus virt_to_phys
  32. #define isa_page_to_bus page_to_phys
  33. #define isa_bus_to_virt phys_to_virt
  34. /*
  35. * Generic IO read/write. These perform native-endian accesses. Note
  36. * that some architectures will want to re-define __raw_{read,write}w.
  37. */
  38. extern void __raw_writesb(void __iomem *addr, const void *data, int bytelen);
  39. extern void __raw_writesw(void __iomem *addr, const void *data, int wordlen);
  40. extern void __raw_writesl(void __iomem *addr, const void *data, int longlen);
  41. extern void __raw_readsb(const void __iomem *addr, void *data, int bytelen);
  42. extern void __raw_readsw(const void __iomem *addr, void *data, int wordlen);
  43. extern void __raw_readsl(const void __iomem *addr, void *data, int longlen);
  44. #if __LINUX_ARM_ARCH__ < 6
  45. /*
  46. * Half-word accesses are problematic with RiscPC due to limitations of
  47. * the bus. Rather than special-case the machine, just let the compiler
  48. * generate the access for CPUs prior to ARMv6.
  49. */
  50. #define __raw_readw(a) (__chk_io_ptr(a), *(volatile unsigned short __force *)(a))
  51. #define __raw_writew(v,a) ((void)(__chk_io_ptr(a), *(volatile unsigned short __force *)(a) = (v)))
  52. #else
  53. /*
  54. * When running under a hypervisor, we want to avoid I/O accesses with
  55. * writeback addressing modes as these incur a significant performance
  56. * overhead (the address generation must be emulated in software).
  57. */
  58. static inline void __raw_writew(u16 val, volatile void __iomem *addr)
  59. {
  60. asm volatile("strh %1, %0"
  61. : "+Q" (*(volatile u16 __force *)addr)
  62. : "r" (val));
  63. }
  64. static inline u16 __raw_readw(const volatile void __iomem *addr)
  65. {
  66. u16 val;
  67. asm volatile("ldrh %1, %0"
  68. : "+Q" (*(volatile u16 __force *)addr),
  69. "=r" (val));
  70. return val;
  71. }
  72. #endif
  73. static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
  74. {
  75. asm volatile("strb %1, %0"
  76. : "+Qo" (*(volatile u8 __force *)addr)
  77. : "r" (val));
  78. }
  79. static inline void __raw_writel(u32 val, volatile void __iomem *addr)
  80. {
  81. asm volatile("str %1, %0"
  82. : "+Qo" (*(volatile u32 __force *)addr)
  83. : "r" (val));
  84. }
  85. static inline u8 __raw_readb(const volatile void __iomem *addr)
  86. {
  87. u8 val;
  88. asm volatile("ldrb %1, %0"
  89. : "+Qo" (*(volatile u8 __force *)addr),
  90. "=r" (val));
  91. return val;
  92. }
  93. static inline u32 __raw_readl(const volatile void __iomem *addr)
  94. {
  95. u32 val;
  96. asm volatile("ldr %1, %0"
  97. : "+Qo" (*(volatile u32 __force *)addr),
  98. "=r" (val));
  99. return val;
  100. }
  101. /*
  102. * Architecture ioremap implementation.
  103. */
  104. #define MT_DEVICE 0
  105. #define MT_DEVICE_NONSHARED 1
  106. #define MT_DEVICE_CACHED 2
  107. #define MT_DEVICE_WC 3
  108. /*
  109. * types 4 onwards can be found in asm/mach/map.h and are undefined
  110. * for ioremap
  111. */
  112. /*
  113. * __arm_ioremap takes CPU physical address.
  114. * __arm_ioremap_pfn takes a Page Frame Number and an offset into that page
  115. * The _caller variety takes a __builtin_return_address(0) value for
  116. * /proc/vmalloc to use - and should only be used in non-inline functions.
  117. */
  118. extern void __iomem *__arm_ioremap_pfn_caller(unsigned long, unsigned long,
  119. size_t, unsigned int, void *);
  120. extern void __iomem *__arm_ioremap_caller(unsigned long, size_t, unsigned int,
  121. void *);
  122. extern void __iomem *__arm_ioremap_pfn(unsigned long, unsigned long, size_t, unsigned int);
  123. extern void __iomem *__arm_ioremap(unsigned long, size_t, unsigned int);
  124. extern void __iomem *__arm_ioremap_exec(unsigned long, size_t, bool cached);
  125. extern void __iounmap(volatile void __iomem *addr);
  126. extern void __arm_iounmap(volatile void __iomem *addr);
  127. extern void __iomem * (*arch_ioremap_caller)(unsigned long, size_t,
  128. unsigned int, void *);
  129. extern void (*arch_iounmap)(volatile void __iomem *);
  130. /*
  131. * Bad read/write accesses...
  132. */
  133. extern void __readwrite_bug(const char *fn);
  134. /*
  135. * A typesafe __io() helper
  136. */
  137. static inline void __iomem *__typesafe_io(unsigned long addr)
  138. {
  139. return (void __iomem *)addr;
  140. }
  141. #define IOMEM(x) ((void __force __iomem *)(x))
  142. /* IO barriers */
  143. #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
  144. #include <asm/barrier.h>
  145. #define __iormb() rmb()
  146. #define __iowmb() wmb()
  147. #else
  148. #define __iormb() do { } while (0)
  149. #define __iowmb() do { } while (0)
  150. #endif
  151. /* PCI fixed i/o mapping */
  152. #define PCI_IO_VIRT_BASE 0xfee00000
  153. extern int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr);