hiddenDangerAnalysis.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. * linux/include/asm-m68k/io.h
  3. *
  4. * 4/1/00 RZ: - rewritten to avoid clashes between ISA/PCI and other
  5. * IO access
  6. * - added Q40 support
  7. * - added skeleton for GG-II and Amiga PCMCIA
  8. * 2/3/01 RZ: - moved a few more defs into raw_io.h
  9. *
  10. * inX/outX should not be used by any driver unless it does
  11. * ISA access. Other drivers should use function defined in raw_io.h
  12. * or define its own macros on top of these.
  13. *
  14. * inX(),outX() are for ISA I/O
  15. * isa_readX(),isa_writeX() are for ISA memory
  16. */
  17. #ifndef _IO_H
  18. #define _IO_H
  19. #ifdef __KERNEL__
  20. #include <linux/compiler.h>
  21. #include <asm/raw_io.h>
  22. #include <asm/virtconvert.h>
  23. #include <asm-generic/iomap.h>
  24. #ifdef CONFIG_ATARI
  25. #include <asm/atarihw.h>
  26. #endif
  27. /*
  28. * IO/MEM definitions for various ISA bridges
  29. */
  30. #ifdef CONFIG_Q40
  31. #define q40_isa_io_base 0xff400000
  32. #define q40_isa_mem_base 0xff800000
  33. #define Q40_ISA_IO_B(ioaddr) (q40_isa_io_base+1+4*((unsigned long)(ioaddr)))
  34. #define Q40_ISA_IO_W(ioaddr) (q40_isa_io_base+ 4*((unsigned long)(ioaddr)))
  35. #define Q40_ISA_MEM_B(madr) (q40_isa_mem_base+1+4*((unsigned long)(madr)))
  36. #define Q40_ISA_MEM_W(madr) (q40_isa_mem_base+ 4*((unsigned long)(madr)))
  37. #define MULTI_ISA 0
  38. #endif /* Q40 */
  39. #ifdef CONFIG_AMIGA_PCMCIA
  40. #include <asm/amigayle.h>
  41. #define AG_ISA_IO_B(ioaddr) ( GAYLE_IO+(ioaddr)+(((ioaddr)&1)*GAYLE_ODD) )
  42. #define AG_ISA_IO_W(ioaddr) ( GAYLE_IO+(ioaddr) )
  43. #ifndef MULTI_ISA
  44. #define MULTI_ISA 0
  45. #else
  46. #undef MULTI_ISA
  47. #define MULTI_ISA 1
  48. #endif
  49. #endif /* AMIGA_PCMCIA */
  50. #if defined(CONFIG_PCI) && defined(CONFIG_COLDFIRE)
  51. #define HAVE_ARCH_PIO_SIZE
  52. #define PIO_OFFSET 0
  53. #define PIO_MASK 0xffff
  54. #define PIO_RESERVED 0x10000
  55. u8 mcf_pci_inb(u32 addr);
  56. u16 mcf_pci_inw(u32 addr);
  57. u32 mcf_pci_inl(u32 addr);
  58. void mcf_pci_insb(u32 addr, u8 *buf, u32 len);
  59. void mcf_pci_insw(u32 addr, u16 *buf, u32 len);
  60. void mcf_pci_insl(u32 addr, u32 *buf, u32 len);
  61. void mcf_pci_outb(u8 v, u32 addr);
  62. void mcf_pci_outw(u16 v, u32 addr);
  63. void mcf_pci_outl(u32 v, u32 addr);
  64. void mcf_pci_outsb(u32 addr, const u8 *buf, u32 len);
  65. void mcf_pci_outsw(u32 addr, const u16 *buf, u32 len);
  66. void mcf_pci_outsl(u32 addr, const u32 *buf, u32 len);
  67. #define inb mcf_pci_inb
  68. #define inb_p mcf_pci_inb
  69. #define inw mcf_pci_inw
  70. #define inw_p mcf_pci_inw
  71. #define inl mcf_pci_inl
  72. #define inl_p mcf_pci_inl
  73. #define insb mcf_pci_insb
  74. #define insw mcf_pci_insw
  75. #define insl mcf_pci_insl
  76. #define outb mcf_pci_outb
  77. #define outb_p mcf_pci_outb
  78. #define outw mcf_pci_outw
  79. #define outw_p mcf_pci_outw
  80. #define outl mcf_pci_outl
  81. #define outl_p mcf_pci_outl
  82. #define outsb mcf_pci_outsb
  83. #define outsw mcf_pci_outsw
  84. #define outsl mcf_pci_outsl
  85. #define readb(addr) in_8(addr)
  86. #define writeb(v, addr) out_8((addr), (v))
  87. #define readw(addr) in_le16(addr)
  88. #define writew(v, addr) out_le16((addr), (v))
  89. #elif defined(CONFIG_ISA)
  90. #if MULTI_ISA == 0
  91. #undef MULTI_ISA
  92. #endif
  93. #define ISA_TYPE_Q40 (1)
  94. #define ISA_TYPE_AG (2)
  95. #if defined(CONFIG_Q40) && !defined(MULTI_ISA)
  96. #define ISA_TYPE ISA_TYPE_Q40
  97. #define ISA_SEX 0
  98. #endif
  99. #if defined(CONFIG_AMIGA_PCMCIA) && !defined(MULTI_ISA)
  100. #define ISA_TYPE ISA_TYPE_AG
  101. #define ISA_SEX 1
  102. #endif
  103. #ifdef MULTI_ISA
  104. extern int isa_type;
  105. extern int isa_sex;
  106. #define ISA_TYPE isa_type
  107. #define ISA_SEX isa_sex
  108. #endif
  109. /*
  110. * define inline addr translation functions. Normally only one variant will
  111. * be compiled in so the case statement will be optimised away
  112. */
  113. static inline u8 __iomem *isa_itb(unsigned long addr)
  114. {
  115. switch(ISA_TYPE)
  116. {
  117. #ifdef CONFIG_Q40
  118. case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
  119. #endif
  120. #ifdef CONFIG_AMIGA_PCMCIA
  121. case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
  122. #endif
  123. default: return NULL; /* avoid warnings, just in case */
  124. }
  125. }
  126. static inline u16 __iomem *isa_itw(unsigned long addr)
  127. {
  128. switch(ISA_TYPE)
  129. {
  130. #ifdef CONFIG_Q40
  131. case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
  132. #endif
  133. #ifdef CONFIG_AMIGA_PCMCIA
  134. case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
  135. #endif
  136. default: return NULL; /* avoid warnings, just in case */
  137. }
  138. }
  139. static inline u32 __iomem *isa_itl(unsigned long addr)
  140. {
  141. switch(ISA_TYPE)
  142. {
  143. #ifdef CONFIG_AMIGA_PCMCIA
  144. case ISA_TYPE_AG: return (u32 __iomem *)AG_ISA_IO_W(addr);
  145. #endif
  146. default: return 0; /* avoid warnings, just in case */
  147. }
  148. }
  149. static inline u8 __iomem *isa_mtb(unsigned long addr)
  150. {
  151. switch(ISA_TYPE)
  152. {
  153. #ifdef CONFIG_Q40
  154. case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
  155. #endif
  156. #ifdef CONFIG_AMIGA_PCMCIA
  157. case ISA_TYPE_AG: return (u8 __iomem *)addr;
  158. #endif
  159. default: return NULL; /* avoid warnings, just in case */
  160. }
  161. }
  162. static inline u16 __iomem *isa_mtw(unsigned long addr)
  163. {
  164. switch(ISA_TYPE)
  165. {
  166. #ifdef CONFIG_Q40
  167. case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
  168. #endif
  169. #ifdef CONFIG_AMIGA_PCMCIA
  170. case ISA_TYPE_AG: return (u16 __iomem *)addr;
  171. #endif
  172. default: return NULL; /* avoid warnings, just in case */
  173. }
  174. }
  175. #define isa_inb(port) in_8(isa_itb(port))
  176. #define isa_inw(port) (ISA_SEX ? in_be16(isa_itw(port)) : in_le16(isa_itw(port)))
  177. #define isa_inl(port) (ISA_SEX ? in_be32(isa_itl(port)) : in_le32(isa_itl(port)))
  178. #define isa_outb(val,port) out_8(isa_itb(port),(val))
  179. #define isa_outw(val,port) (ISA_SEX ? out_be16(isa_itw(port),(val)) : out_le16(isa_itw(port),(val)))
  180. #define isa_outl(val,port) (ISA_SEX ? out_be32(isa_itl(port),(val)) : out_le32(isa_itl(port),(val)))
  181. #define isa_readb(p) in_8(isa_mtb((unsigned long)(p)))
  182. #define isa_readw(p) \
  183. (ISA_SEX ? in_be16(isa_mtw((unsigned long)(p))) \
  184. : in_le16(isa_mtw((unsigned long)(p))))
  185. #define isa_writeb(val,p) out_8(isa_mtb((unsigned long)(p)),(val))
  186. #define isa_writew(val,p) \
  187. (ISA_SEX ? out_be16(isa_mtw((unsigned long)(p)),(val)) \
  188. : out_le16(isa_mtw((unsigned long)(p)),(val)))
  189. static inline void isa_delay(void)
  190. {
  191. switch(ISA_TYPE)