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/types.h>
10 #include <linux/interrupt.h>
11 #include <asm/sn/pcibus_provider_defs.h>
12 #include <asm/sn/pcidev.h>
13 #include "pci/tiocp.h"
15 #include "pci/pcibr_provider.h"
23 * Control Register Access -- Read/Write 0000_0020
25 void pcireg_control_bit_clr(struct pcibus_info
*pcibus_info
, uint64_t bits
)
27 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
30 switch (pcibus_info
->pbi_bridge_type
) {
31 case PCIBR_BRIDGETYPE_TIOCP
:
32 ptr
->tio
.cp_control
&= ~bits
;
34 case PCIBR_BRIDGETYPE_PIC
:
35 ptr
->pic
.p_wid_control
&= ~bits
;
39 ("pcireg_control_bit_clr: unknown bridgetype bridge 0x%p",
45 void pcireg_control_bit_set(struct pcibus_info
*pcibus_info
, uint64_t bits
)
47 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
50 switch (pcibus_info
->pbi_bridge_type
) {
51 case PCIBR_BRIDGETYPE_TIOCP
:
52 ptr
->tio
.cp_control
|= bits
;
54 case PCIBR_BRIDGETYPE_PIC
:
55 ptr
->pic
.p_wid_control
|= bits
;
59 ("pcireg_control_bit_set: unknown bridgetype bridge 0x%p",
66 * PCI/PCIX Target Flush Register Access -- Read Only 0000_0050
68 uint64_t pcireg_tflush_get(struct pcibus_info
*pcibus_info
)
70 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
74 switch (pcibus_info
->pbi_bridge_type
) {
75 case PCIBR_BRIDGETYPE_TIOCP
:
76 ret
= ptr
->tio
.cp_tflush
;
78 case PCIBR_BRIDGETYPE_PIC
:
79 ret
= ptr
->pic
.p_wid_tflush
;
83 ("pcireg_tflush_get: unknown bridgetype bridge 0x%p",
88 /* Read of the Target Flush should always return zero */
90 panic("pcireg_tflush_get:Target Flush failed\n");
96 * Interrupt Status Register Access -- Read Only 0000_0100
98 uint64_t pcireg_intr_status_get(struct pcibus_info
* pcibus_info
)
100 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
104 switch (pcibus_info
->pbi_bridge_type
) {
105 case PCIBR_BRIDGETYPE_TIOCP
:
106 ret
= ptr
->tio
.cp_int_status
;
108 case PCIBR_BRIDGETYPE_PIC
:
109 ret
= ptr
->pic
.p_int_status
;
113 ("pcireg_intr_status_get: unknown bridgetype bridge 0x%p",
121 * Interrupt Enable Register Access -- Read/Write 0000_0108
123 void pcireg_intr_enable_bit_clr(struct pcibus_info
*pcibus_info
, uint64_t bits
)
125 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
128 switch (pcibus_info
->pbi_bridge_type
) {
129 case PCIBR_BRIDGETYPE_TIOCP
:
130 ptr
->tio
.cp_int_enable
&= ~bits
;
132 case PCIBR_BRIDGETYPE_PIC
:
133 ptr
->pic
.p_int_enable
&= ~bits
;
137 ("pcireg_intr_enable_bit_clr: unknown bridgetype bridge 0x%p",
143 void pcireg_intr_enable_bit_set(struct pcibus_info
*pcibus_info
, uint64_t bits
)
145 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
148 switch (pcibus_info
->pbi_bridge_type
) {
149 case PCIBR_BRIDGETYPE_TIOCP
:
150 ptr
->tio
.cp_int_enable
|= bits
;
152 case PCIBR_BRIDGETYPE_PIC
:
153 ptr
->pic
.p_int_enable
|= bits
;
157 ("pcireg_intr_enable_bit_set: unknown bridgetype bridge 0x%p",
164 * Intr Host Address Register (int_addr) -- Read/Write 0000_0130 - 0000_0168
166 void pcireg_intr_addr_addr_set(struct pcibus_info
*pcibus_info
, int int_n
,
169 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
172 switch (pcibus_info
->pbi_bridge_type
) {
173 case PCIBR_BRIDGETYPE_TIOCP
:
174 ptr
->tio
.cp_int_addr
[int_n
] &= ~TIOCP_HOST_INTR_ADDR
;
175 ptr
->tio
.cp_int_addr
[int_n
] |=
176 (addr
& TIOCP_HOST_INTR_ADDR
);
178 case PCIBR_BRIDGETYPE_PIC
:
179 ptr
->pic
.p_int_addr
[int_n
] &= ~PIC_HOST_INTR_ADDR
;
180 ptr
->pic
.p_int_addr
[int_n
] |=
181 (addr
& PIC_HOST_INTR_ADDR
);
185 ("pcireg_intr_addr_addr_get: unknown bridgetype bridge 0x%p",
192 * Force Interrupt Register Access -- Write Only 0000_01C0 - 0000_01F8
194 void pcireg_force_intr_set(struct pcibus_info
*pcibus_info
, int int_n
)
196 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
199 switch (pcibus_info
->pbi_bridge_type
) {
200 case PCIBR_BRIDGETYPE_TIOCP
:
201 ptr
->tio
.cp_force_pin
[int_n
] = 1;
203 case PCIBR_BRIDGETYPE_PIC
:
204 ptr
->pic
.p_force_pin
[int_n
] = 1;
208 ("pcireg_force_intr_set: unknown bridgetype bridge 0x%p",
215 * Device(x) Write Buffer Flush Reg Access -- Read Only 0000_0240 - 0000_0258
217 uint64_t pcireg_wrb_flush_get(struct pcibus_info
*pcibus_info
, int device
)
219 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
223 switch (pcibus_info
->pbi_bridge_type
) {
224 case PCIBR_BRIDGETYPE_TIOCP
:
225 ret
= ptr
->tio
.cp_wr_req_buf
[device
];
227 case PCIBR_BRIDGETYPE_PIC
:
228 ret
= ptr
->pic
.p_wr_req_buf
[device
];
231 panic("pcireg_wrb_flush_get: unknown bridgetype bridge 0x%p", (void *)ptr
);
235 /* Read of the Write Buffer Flush should always return zero */
239 void pcireg_int_ate_set(struct pcibus_info
*pcibus_info
, int ate_index
,
242 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
245 switch (pcibus_info
->pbi_bridge_type
) {
246 case PCIBR_BRIDGETYPE_TIOCP
:
247 ptr
->tio
.cp_int_ate_ram
[ate_index
] = (uint64_t) val
;
249 case PCIBR_BRIDGETYPE_PIC
:
250 ptr
->pic
.p_int_ate_ram
[ate_index
] = (uint64_t) val
;
254 ("pcireg_int_ate_set: unknown bridgetype bridge 0x%p",
260 uint64_t *pcireg_int_ate_addr(struct pcibus_info
*pcibus_info
, int ate_index
)
262 union br_ptr
*ptr
= (union br_ptr
*)pcibus_info
->pbi_buscommon
.bs_base
;
263 uint64_t *ret
= (uint64_t *) 0;
266 switch (pcibus_info
->pbi_bridge_type
) {
267 case PCIBR_BRIDGETYPE_TIOCP
:
269 (uint64_t *) & (ptr
->tio
.cp_int_ate_ram
[ate_index
]);
271 case PCIBR_BRIDGETYPE_PIC
:
273 (uint64_t *) & (ptr
->pic
.p_int_ate_ram
[ate_index
]);
277 ("pcireg_int_ate_addr: unknown bridgetype bridge 0x%p",