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
6 * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved.
9 #include <linux/interrupt.h>
10 #include <linux/types.h>
11 #include <asm/sn/io.h>
12 #include <asm/sn/pcibr_provider.h>
13 #include <asm/sn/pcibus_provider_defs.h>
14 #include <asm/sn/pcidev.h>
15 #include <asm/sn/pic.h>
16 #include <asm/sn/tiocp.h>
24 * Control Register Access -- Read/Write 0000_0020
26 void pcireg_control_bit_clr(struct pcibus_info *pcibus_info, uint64_t bits)
28 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
31 switch (pcibus_info->pbi_bridge_type) {
32 case PCIBR_BRIDGETYPE_TIOCP:
33 __sn_clrq_relaxed(&ptr->tio.cp_control, bits);
35 case PCIBR_BRIDGETYPE_PIC:
36 __sn_clrq_relaxed(&ptr->pic.p_wid_control, bits);
40 ("pcireg_control_bit_clr: unknown bridgetype bridge 0x%p",
46 void pcireg_control_bit_set(struct pcibus_info *pcibus_info, uint64_t bits)
48 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
51 switch (pcibus_info->pbi_bridge_type) {
52 case PCIBR_BRIDGETYPE_TIOCP:
53 __sn_setq_relaxed(&ptr->tio.cp_control, bits);
55 case PCIBR_BRIDGETYPE_PIC:
56 __sn_setq_relaxed(&ptr->pic.p_wid_control, bits);
60 ("pcireg_control_bit_set: unknown bridgetype bridge 0x%p",
67 * PCI/PCIX Target Flush Register Access -- Read Only 0000_0050
69 uint64_t pcireg_tflush_get(struct pcibus_info *pcibus_info)
71 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
75 switch (pcibus_info->pbi_bridge_type) {
76 case PCIBR_BRIDGETYPE_TIOCP:
77 ret = __sn_readq_relaxed(&ptr->tio.cp_tflush);
79 case PCIBR_BRIDGETYPE_PIC:
80 ret = __sn_readq_relaxed(&ptr->pic.p_wid_tflush);
84 ("pcireg_tflush_get: unknown bridgetype bridge 0x%p",
89 /* Read of the Target Flush should always return zero */
91 panic("pcireg_tflush_get:Target Flush failed\n");
97 * Interrupt Status Register Access -- Read Only 0000_0100
99 uint64_t pcireg_intr_status_get(struct pcibus_info * pcibus_info)
101 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
105 switch (pcibus_info->pbi_bridge_type) {
106 case PCIBR_BRIDGETYPE_TIOCP:
107 ret = __sn_readq_relaxed(&ptr->tio.cp_int_status);
109 case PCIBR_BRIDGETYPE_PIC:
110 ret = __sn_readq_relaxed(&ptr->pic.p_int_status);
114 ("pcireg_intr_status_get: unknown bridgetype bridge 0x%p",
122 * Interrupt Enable Register Access -- Read/Write 0000_0108
124 void pcireg_intr_enable_bit_clr(struct pcibus_info *pcibus_info, uint64_t bits)
126 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
129 switch (pcibus_info->pbi_bridge_type) {
130 case PCIBR_BRIDGETYPE_TIOCP:
131 __sn_clrq_relaxed(&ptr->tio.cp_int_enable, bits);
133 case PCIBR_BRIDGETYPE_PIC:
134 __sn_clrq_relaxed(&ptr->pic.p_int_enable, ~bits);
138 ("pcireg_intr_enable_bit_clr: unknown bridgetype bridge 0x%p",
144 void pcireg_intr_enable_bit_set(struct pcibus_info *pcibus_info, uint64_t bits)
146 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
149 switch (pcibus_info->pbi_bridge_type) {
150 case PCIBR_BRIDGETYPE_TIOCP:
151 __sn_setq_relaxed(&ptr->tio.cp_int_enable, bits);
153 case PCIBR_BRIDGETYPE_PIC:
154 __sn_setq_relaxed(&ptr->pic.p_int_enable, bits);
158 ("pcireg_intr_enable_bit_set: unknown bridgetype bridge 0x%p",
165 * Intr Host Address Register (int_addr) -- Read/Write 0000_0130 - 0000_0168
167 void pcireg_intr_addr_addr_set(struct pcibus_info *pcibus_info, int int_n,
170 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
173 switch (pcibus_info->pbi_bridge_type) {
174 case PCIBR_BRIDGETYPE_TIOCP:
175 __sn_clrq_relaxed(&ptr->tio.cp_int_addr[int_n],
176 TIOCP_HOST_INTR_ADDR);
177 __sn_setq_relaxed(&ptr->tio.cp_int_addr[int_n],
178 (addr & TIOCP_HOST_INTR_ADDR));
180 case PCIBR_BRIDGETYPE_PIC:
181 __sn_clrq_relaxed(&ptr->pic.p_int_addr[int_n],
183 __sn_setq_relaxed(&ptr->pic.p_int_addr[int_n],
184 (addr & PIC_HOST_INTR_ADDR));
188 ("pcireg_intr_addr_addr_get: unknown bridgetype bridge 0x%p",
195 * Force Interrupt Register Access -- Write Only 0000_01C0 - 0000_01F8
197 void pcireg_force_intr_set(struct pcibus_info *pcibus_info, int int_n)
199 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
202 switch (pcibus_info->pbi_bridge_type) {
203 case PCIBR_BRIDGETYPE_TIOCP:
204 writeq(1, &ptr->tio.cp_force_pin[int_n]);
206 case PCIBR_BRIDGETYPE_PIC:
207 writeq(1, &ptr->pic.p_force_pin[int_n]);
211 ("pcireg_force_intr_set: unknown bridgetype bridge 0x%p",
218 * Device(x) Write Buffer Flush Reg Access -- Read Only 0000_0240 - 0000_0258
220 uint64_t pcireg_wrb_flush_get(struct pcibus_info *pcibus_info, int device)
222 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
226 switch (pcibus_info->pbi_bridge_type) {
227 case PCIBR_BRIDGETYPE_TIOCP:
229 __sn_readq_relaxed(&ptr->tio.cp_wr_req_buf[device]);
231 case PCIBR_BRIDGETYPE_PIC:
233 __sn_readq_relaxed(&ptr->pic.p_wr_req_buf[device]);
236 panic("pcireg_wrb_flush_get: unknown bridgetype bridge 0x%p", (void *)ptr);
240 /* Read of the Write Buffer Flush should always return zero */
244 void pcireg_int_ate_set(struct pcibus_info *pcibus_info, int ate_index,
247 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
250 switch (pcibus_info->pbi_bridge_type) {
251 case PCIBR_BRIDGETYPE_TIOCP:
252 writeq(val, &ptr->tio.cp_int_ate_ram[ate_index]);
254 case PCIBR_BRIDGETYPE_PIC:
255 writeq(val, &ptr->pic.p_int_ate_ram[ate_index]);
259 ("pcireg_int_ate_set: unknown bridgetype bridge 0x%p",
265 uint64_t *pcireg_int_ate_addr(struct pcibus_info *pcibus_info, int ate_index)
267 union br_ptr *ptr = (union br_ptr *)pcibus_info->pbi_buscommon.bs_base;
268 uint64_t *ret = (uint64_t *) 0;
271 switch (pcibus_info->pbi_bridge_type) {
272 case PCIBR_BRIDGETYPE_TIOCP:
273 ret = &ptr->tio.cp_int_ate_ram[ate_index];
275 case PCIBR_BRIDGETYPE_PIC:
276 ret = &ptr->pic.p_int_ate_ram[ate_index];
280 ("pcireg_int_ate_addr: unknown bridgetype bridge 0x%p",