ins.S 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * File: arch/blackfin/lib/ins.S
  3. * Based on:
  4. * Author: Bas Vermeulen <bas@buyways.nl>
  5. *
  6. * Created: Tue Mar 22 15:27:24 CEST 2005
  7. * Description: Implementation of ins{bwl} for BlackFin processors using zero overhead loops.
  8. *
  9. * Modified:
  10. * Copyright 2004-2008 Analog Devices Inc.
  11. * Copyright (C) 2005 Bas Vermeulen, BuyWays BV <bas@buyways.nl>
  12. *
  13. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, see the file COPYING, or write
  27. * to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #include <linux/linkage.h>
  31. #include <asm/blackfin.h>
  32. .align 2
  33. /*
  34. * Reads on the Blackfin are speculative. In Blackfin terms, this means they
  35. * can be interrupted at any time (even after they have been issued on to the
  36. * external bus), and re-issued after the interrupt occurs.
  37. *
  38. * If a FIFO is sitting on the end of the read, it will see two reads,
  39. * when the core only sees one. The FIFO receives the read which is cancelled,
  40. * and not delivered to the core.
  41. *
  42. * To solve this, interrupts are turned off before reads occur to I/O space.
  43. * There are 3 versions of all these functions
  44. * - turns interrupts off every read (higher overhead, but lower latency)
  45. * - turns interrupts off every loop (low overhead, but longer latency)
  46. * - DMA version, which do not suffer from this issue. DMA versions have
  47. * different name (prefixed by dma_ ), and are located in
  48. * ../kernel/bfin_dma_5xx.c
  49. * Using the dma related functions are recommended for transfering large
  50. * buffers in/out of FIFOs.
  51. */
  52. ENTRY(_insl)
  53. #ifdef CONFIG_BFIN_INS_LOWOVERHEAD
  54. P0 = R0; /* P0 = port */
  55. cli R3;
  56. P1 = R1; /* P1 = address */
  57. P2 = R2; /* P2 = count */
  58. SSYNC;
  59. LSETUP( .Llong_loop_s, .Llong_loop_e) LC0 = P2;
  60. .Llong_loop_s: R0 = [P0];
  61. [P1++] = R0;
  62. NOP;
  63. .Llong_loop_e: NOP;
  64. sti R3;
  65. RTS;
  66. #else
  67. P0 = R0; /* P0 = port */
  68. P1 = R1; /* P1 = address */
  69. P2 = R2; /* P2 = count */
  70. SSYNC;
  71. LSETUP( .Llong_loop_s, .Llong_loop_e) LC0 = P2;
  72. .Llong_loop_s:
  73. CLI R3;
  74. NOP; NOP; NOP;
  75. R0 = [P0];
  76. [P1++] = R0;
  77. .Llong_loop_e:
  78. STI R3;
  79. RTS;
  80. #endif
  81. ENDPROC(_insl)
  82. ENTRY(_insw)
  83. #ifdef CONFIG_BFIN_INS_LOWOVERHEAD
  84. P0 = R0; /* P0 = port */
  85. cli R3;
  86. P1 = R1; /* P1 = address */
  87. P2 = R2; /* P2 = count */
  88. SSYNC;
  89. LSETUP( .Lword_loop_s, .Lword_loop_e) LC0 = P2;
  90. .Lword_loop_s: R0 = W[P0];
  91. W[P1++] = R0;
  92. NOP;
  93. .Lword_loop_e: NOP;
  94. sti R3;
  95. RTS;
  96. #else
  97. P0 = R0; /* P0 = port */
  98. P1 = R1; /* P1 = address */
  99. P2 = R2; /* P2 = count */
  100. SSYNC;
  101. LSETUP( .Lword_loop_s, .Lword_loop_e) LC0 = P2;
  102. .Lword_loop_s:
  103. CLI R3;
  104. NOP; NOP; NOP;
  105. R0 = W[P0];
  106. W[P1++] = R0;
  107. .Lword_loop_e:
  108. STI R3;
  109. RTS;
  110. #endif
  111. ENDPROC(_insw)
  112. ENTRY(_insw_8)
  113. #ifdef CONFIG_BFIN_INS_LOWOVERHEAD
  114. P0 = R0; /* P0 = port */
  115. cli R3;
  116. P1 = R1; /* P1 = address */
  117. P2 = R2; /* P2 = count */
  118. SSYNC;
  119. LSETUP( .Lword8_loop_s, .Lword8_loop_e) LC0 = P2;
  120. .Lword8_loop_s: R0 = W[P0];
  121. B[P1++] = R0;
  122. R0 = R0 >> 8;
  123. B[P1++] = R0;
  124. NOP;
  125. .Lword8_loop_e: NOP;
  126. sti R3;
  127. RTS;
  128. #else
  129. P0 = R0; /* P0 = port */
  130. P1 = R1; /* P1 = address */
  131. P2 = R2; /* P2 = count */
  132. SSYNC;
  133. LSETUP( .Lword8_loop_s, .Lword8_loop_e) LC0 = P2;
  134. .Lword8_loop_s:
  135. CLI R3;
  136. NOP; NOP; NOP;
  137. R0 = W[P0];
  138. B[P1++] = R0;
  139. R0 = R0 >> 8;
  140. B[P1++] = R0;
  141. NOP;
  142. .Lword8_loop_e:
  143. STI R3;
  144. RTS;
  145. #endif
  146. ENDPROC(_insw_8)
  147. ENTRY(_insb)
  148. #ifdef CONFIG_BFIN_INS_LOWOVERHEAD
  149. P0 = R0; /* P0 = port */
  150. cli R3;
  151. P1 = R1; /* P1 = address */
  152. P2 = R2; /* P2 = count */
  153. SSYNC;
  154. LSETUP( .Lbyte_loop_s, .Lbyte_loop_e) LC0 = P2;
  155. .Lbyte_loop_s: R0 = B[P0];
  156. B[P1++] = R0;
  157. NOP;
  158. .Lbyte_loop_e: NOP;
  159. sti R3;
  160. RTS;
  161. #else
  162. P0 = R0; /* P0 = port */
  163. P1 = R1; /* P1 = address */
  164. P2 = R2; /* P2 = count */
  165. SSYNC;
  166. LSETUP( .Lbyte_loop_s, .Lbyte_loop_e) LC0 = P2;
  167. .Lbyte_loop_s:
  168. CLI R3;
  169. NOP; NOP; NOP;
  170. R0 = B[P0];
  171. B[P1++] = R0;
  172. .Lbyte_loop_e:
  173. STI R3;
  174. RTS;
  175. #endif
  176. ENDPROC(_insb)
  177. ENTRY(_insl_16)
  178. #ifdef CONFIG_BFIN_INS_LOWOVERHEAD
  179. P0 = R0; /* P0 = port */
  180. cli R3;
  181. P1 = R1; /* P1 = address */
  182. P2 = R2; /* P2 = count */
  183. SSYNC;
  184. LSETUP( .Llong16_loop_s, .Llong16_loop_e) LC0 = P2;
  185. .Llong16_loop_s: R0 = [P0];
  186. W[P1++] = R0;
  187. R0 = R0 >> 16;
  188. W[P1++] = R0;
  189. NOP;
  190. .Llong16_loop_e: NOP;
  191. sti R3;
  192. RTS;
  193. #else
  194. P0 = R0; /* P0 = port */
  195. P1 = R1; /* P1 = address */
  196. P2 = R2; /* P2 = count */
  197. SSYNC;
  198. LSETUP( .Llong16_loop_s, .Llong16_loop_e) LC0 = P2;
  199. .Llong16_loop_s:
  200. CLI R3;
  201. NOP; NOP; NOP;
  202. R0 = [P0];
  203. W[P1++] = R0;
  204. R0 = R0 >> 16;
  205. W[P1++] = R0;
  206. .Llong16_loop_e:
  207. STI R3;
  208. RTS;
  209. #endif
  210. ENDPROC(_insl_16)