pcibr_reg.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved.
  7. */
  8. #include <linux/interrupt.h>
  9. #include <linux/types.h>
  10. #include <asm/sn/io.h>
  11. #include <asm/sn/pcibr_provider.h>
  12. #include <asm/sn/pcibus_provider_defs.h>
  13. #include <asm/sn/pcidev.h>
  14. #include <asm/sn/pic.h>
  15. #include <asm/sn/tiocp.h>
  16. union br_ptr {
  17. struct tiocp tio;
  18. struct pic pic;
  19. };
  20. /*
  21. * Control Register Access -- Read/Write 0000_0020
  22. */
  23. void pcireg_control_bit_clr(struct pcibus_info *pcibus_info, u64 bits)
  24. {
  25. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  26. if (pcibus_info) {
  27. switch (pcibus_info->pbi_bridge_type) {
  28. case PCIBR_BRIDGETYPE_TIOCP:
  29. __sn_clrq_relaxed(&ptr->tio.cp_control, bits);
  30. break;
  31. case PCIBR_BRIDGETYPE_PIC:
  32. __sn_clrq_relaxed(&ptr->pic.p_wid_control, bits);
  33. break;
  34. default:
  35. panic
  36. ("pcireg_control_bit_clr: unknown bridgetype bridge 0x%p",
  37. ptr);
  38. }
  39. }
  40. }
  41. void pcireg_control_bit_set(struct pcibus_info *pcibus_info, u64 bits)
  42. {
  43. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  44. if (pcibus_info) {
  45. switch (pcibus_info->pbi_bridge_type) {
  46. case PCIBR_BRIDGETYPE_TIOCP:
  47. __sn_setq_relaxed(&ptr->tio.cp_control, bits);
  48. break;
  49. case PCIBR_BRIDGETYPE_PIC:
  50. __sn_setq_relaxed(&ptr->pic.p_wid_control, bits);
  51. break;
  52. default:
  53. panic
  54. ("pcireg_control_bit_set: unknown bridgetype bridge 0x%p",
  55. ptr);
  56. }
  57. }
  58. }
  59. /*
  60. * PCI/PCIX Target Flush Register Access -- Read Only 0000_0050
  61. */
  62. u64 pcireg_tflush_get(struct pcibus_info *pcibus_info)
  63. {
  64. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  65. u64 ret = 0;
  66. if (pcibus_info) {
  67. switch (pcibus_info->pbi_bridge_type) {
  68. case PCIBR_BRIDGETYPE_TIOCP:
  69. ret = __sn_readq_relaxed(&ptr->tio.cp_tflush);
  70. break;
  71. case PCIBR_BRIDGETYPE_PIC:
  72. ret = __sn_readq_relaxed(&ptr->pic.p_wid_tflush);
  73. break;
  74. default:
  75. panic
  76. ("pcireg_tflush_get: unknown bridgetype bridge 0x%p",
  77. ptr);
  78. }
  79. }
  80. /* Read of the Target Flush should always return zero */
  81. if (ret != 0)
  82. panic("pcireg_tflush_get:Target Flush failed\n");
  83. return ret;
  84. }
  85. /*
  86. * Interrupt Status Register Access -- Read Only 0000_0100
  87. */
  88. u64 pcireg_intr_status_get(struct pcibus_info * pcibus_info)
  89. {
  90. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  91. u64 ret = 0;
  92. if (pcibus_info) {
  93. switch (pcibus_info->pbi_bridge_type) {
  94. case PCIBR_BRIDGETYPE_TIOCP:
  95. ret = __sn_readq_relaxed(&ptr->tio.cp_int_status);
  96. break;
  97. case PCIBR_BRIDGETYPE_PIC:
  98. ret = __sn_readq_relaxed(&ptr->pic.p_int_status);
  99. break;
  100. default:
  101. panic
  102. ("pcireg_intr_status_get: unknown bridgetype bridge 0x%p",
  103. ptr);
  104. }
  105. }
  106. return ret;
  107. }
  108. /*
  109. * Interrupt Enable Register Access -- Read/Write 0000_0108
  110. */
  111. void pcireg_intr_enable_bit_clr(struct pcibus_info *pcibus_info, u64 bits)
  112. {
  113. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  114. if (pcibus_info) {
  115. switch (pcibus_info->pbi_bridge_type) {
  116. case PCIBR_BRIDGETYPE_TIOCP:
  117. __sn_clrq_relaxed(&ptr->tio.cp_int_enable, bits);
  118. break;
  119. case PCIBR_BRIDGETYPE_PIC:
  120. __sn_clrq_relaxed(&ptr->pic.p_int_enable, bits);
  121. break;
  122. default:
  123. panic
  124. ("pcireg_intr_enable_bit_clr: unknown bridgetype bridge 0x%p",
  125. ptr);
  126. }
  127. }
  128. }
  129. void pcireg_intr_enable_bit_set(struct pcibus_info *pcibus_info, u64 bits)
  130. {
  131. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  132. if (pcibus_info) {
  133. switch (pcibus_info->pbi_bridge_type) {
  134. case PCIBR_BRIDGETYPE_TIOCP:
  135. __sn_setq_relaxed(&ptr->tio.cp_int_enable, bits);
  136. break;
  137. case PCIBR_BRIDGETYPE_PIC:
  138. __sn_setq_relaxed(&ptr->pic.p_int_enable, bits);
  139. break;
  140. default:
  141. panic
  142. ("pcireg_intr_enable_bit_set: unknown bridgetype bridge 0x%p",
  143. ptr);
  144. }
  145. }
  146. }
  147. /*
  148. * Intr Host Address Register (int_addr) -- Read/Write 0000_0130 - 0000_0168
  149. */
  150. void pcireg_intr_addr_addr_set(struct pcibus_info *pcibus_info, int int_n,
  151. u64 addr)
  152. {
  153. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  154. if (pcibus_info) {
  155. switch (pcibus_info->pbi_bridge_type) {
  156. case PCIBR_BRIDGETYPE_TIOCP:
  157. __sn_clrq_relaxed(&ptr->tio.cp_int_addr[int_n],
  158. TIOCP_HOST_INTR_ADDR);
  159. __sn_setq_relaxed(&ptr->tio.cp_int_addr[int_n],
  160. (addr & TIOCP_HOST_INTR_ADDR));
  161. break;
  162. case PCIBR_BRIDGETYPE_PIC:
  163. __sn_clrq_relaxed(&ptr->pic.p_int_addr[int_n],
  164. PIC_HOST_INTR_ADDR);
  165. __sn_setq_relaxed(&ptr->pic.p_int_addr[int_n],
  166. (addr & PIC_HOST_INTR_ADDR));
  167. break;
  168. default:
  169. panic
  170. ("pcireg_intr_addr_addr_get: unknown bridgetype bridge 0x%p",
  171. ptr);
  172. }
  173. }
  174. }
  175. /*
  176. * Force Interrupt Register Access -- Write Only 0000_01C0 - 0000_01F8
  177. */
  178. void pcireg_force_intr_set(struct pcibus_info *pcibus_info, int int_n)
  179. {
  180. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  181. if (pcibus_info) {
  182. switch (pcibus_info->pbi_bridge_type) {
  183. case PCIBR_BRIDGETYPE_TIOCP:
  184. writeq(1, &ptr->tio.cp_force_pin[int_n]);
  185. break;
  186. case PCIBR_BRIDGETYPE_PIC:
  187. writeq(1, &ptr->pic.p_force_pin[int_n]);
  188. break;
  189. default:
  190. panic
  191. ("pcireg_force_intr_set: unknown bridgetype bridge 0x%p",
  192. ptr);
  193. }
  194. }
  195. }
  196. /*
  197. * Device(x) Write Buffer Flush Reg Access -- Read Only 0000_0240 - 0000_0258
  198. */
  199. u64 pcireg_wrb_flush_get(struct pcibus_info *pcibus_info, int device)
  200. {
  201. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  202. u64 ret = 0;
  203. if (pcibus_info) {
  204. switch (pcibus_info->pbi_bridge_type) {
  205. case PCIBR_BRIDGETYPE_TIOCP:
  206. ret =
  207. __sn_readq_relaxed(&ptr->tio.cp_wr_req_buf[device]);
  208. break;
  209. case PCIBR_BRIDGETYPE_PIC:
  210. ret =
  211. __sn_readq_relaxed(&ptr->pic.p_wr_req_buf[device]);
  212. break;
  213. default:
  214. panic("pcireg_wrb_flush_get: unknown bridgetype bridge 0x%p", ptr);
  215. }
  216. }
  217. /* Read of the Write Buffer Flush should always return zero */
  218. return ret;
  219. }
  220. void pcireg_int_ate_set(struct pcibus_info *pcibus_info, int ate_index,
  221. u64 val)
  222. {
  223. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  224. if (pcibus_info) {
  225. switch (pcibus_info->pbi_bridge_type) {
  226. case PCIBR_BRIDGETYPE_TIOCP:
  227. writeq(val, &ptr->tio.cp_int_ate_ram[ate_index]);
  228. break;
  229. case PCIBR_BRIDGETYPE_PIC:
  230. writeq(val, &ptr->pic.p_int_ate_ram[ate_index]);
  231. break;
  232. default:
  233. panic
  234. ("pcireg_int_ate_set: unknown bridgetype bridge 0x%p",
  235. ptr);
  236. }
  237. }
  238. }
  239. u64 __iomem *pcireg_int_ate_addr(struct pcibus_info *pcibus_info, int ate_index)
  240. {
  241. union br_ptr __iomem *ptr = (union br_ptr __iomem *)pcibus_info->pbi_buscommon.bs_base;
  242. u64 __iomem *ret = NULL;
  243. if (pcibus_info) {
  244. switch (pcibus_info->pbi_bridge_type) {
  245. case PCIBR_BRIDGETYPE_TIOCP:
  246. ret = &ptr->tio.cp_int_ate_ram[ate_index];
  247. break;
  248. case PCIBR_BRIDGETYPE_PIC:
  249. ret = &ptr->pic.p_int_ate_ram[ate_index];
  250. break;
  251. default:
  252. panic
  253. ("pcireg_int_ate_addr: unknown bridgetype bridge 0x%p",
  254. ptr);
  255. }
  256. }
  257. return ret;
  258. }