]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/ia64/sn/pci/pcibr/pcibr_provider.c
Linux-2.6.12-rc2
[mirror_ubuntu-artful-kernel.git] / arch / ia64 / sn / pci / pcibr / pcibr_provider.c
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) 2001-2004 Silicon Graphics, Inc. All rights reserved.
7 */
8
9 #include <linux/types.h>
10 #include <linux/interrupt.h>
11 #include <linux/pci.h>
12 #include <asm/sn/sn_sal.h>
13 #include "xtalk/xwidgetdev.h"
14 #include <asm/sn/geo.h>
15 #include "xtalk/hubdev.h"
16 #include "pci/pcibus_provider_defs.h"
17 #include "pci/pcidev.h"
18 #include "pci/pcibr_provider.h"
19 #include <asm/sn/addrs.h>
20
21
22 static int sal_pcibr_error_interrupt(struct pcibus_info *soft)
23 {
24 struct ia64_sal_retval ret_stuff;
25 uint64_t busnum;
26 int segment;
27 ret_stuff.status = 0;
28 ret_stuff.v0 = 0;
29
30 segment = 0;
31 busnum = soft->pbi_buscommon.bs_persist_busnum;
32 SAL_CALL_NOLOCK(ret_stuff,
33 (u64) SN_SAL_IOIF_ERROR_INTERRUPT,
34 (u64) segment, (u64) busnum, 0, 0, 0, 0, 0);
35
36 return (int)ret_stuff.v0;
37 }
38
39 /*
40 * PCI Bridge Error interrupt handler. Gets invoked whenever a PCI
41 * bridge sends an error interrupt.
42 */
43 static irqreturn_t
44 pcibr_error_intr_handler(int irq, void *arg, struct pt_regs *regs)
45 {
46 struct pcibus_info *soft = (struct pcibus_info *)arg;
47
48 if (sal_pcibr_error_interrupt(soft) < 0) {
49 panic("pcibr_error_intr_handler(): Fatal Bridge Error");
50 }
51 return IRQ_HANDLED;
52 }
53
54 void *
55 pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft)
56 {
57 int nasid, cnode, j;
58 struct hubdev_info *hubdev_info;
59 struct pcibus_info *soft;
60 struct sn_flush_device_list *sn_flush_device_list;
61
62 if (! IS_PCI_BRIDGE_ASIC(prom_bussoft->bs_asic_type)) {
63 return NULL;
64 }
65
66 /*
67 * Allocate kernel bus soft and copy from prom.
68 */
69
70 soft = kmalloc(sizeof(struct pcibus_info), GFP_KERNEL);
71 if (!soft) {
72 return NULL;
73 }
74
75 memcpy(soft, prom_bussoft, sizeof(struct pcibus_info));
76 soft->pbi_buscommon.bs_base =
77 (((u64) soft->pbi_buscommon.
78 bs_base << 4) >> 4) | __IA64_UNCACHED_OFFSET;
79
80 spin_lock_init(&soft->pbi_lock);
81
82 /*
83 * register the bridge's error interrupt handler
84 */
85 if (request_irq(SGI_PCIBR_ERROR, (void *)pcibr_error_intr_handler,
86 SA_SHIRQ, "PCIBR error", (void *)(soft))) {
87 printk(KERN_WARNING
88 "pcibr cannot allocate interrupt for error handler\n");
89 }
90
91 /*
92 * Update the Bridge with the "kernel" pagesize
93 */
94 if (PAGE_SIZE < 16384) {
95 pcireg_control_bit_clr(soft, PCIBR_CTRL_PAGE_SIZE);
96 } else {
97 pcireg_control_bit_set(soft, PCIBR_CTRL_PAGE_SIZE);
98 }
99
100 nasid = NASID_GET(soft->pbi_buscommon.bs_base);
101 cnode = nasid_to_cnodeid(nasid);
102 hubdev_info = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
103
104 if (hubdev_info->hdi_flush_nasid_list.widget_p) {
105 sn_flush_device_list = hubdev_info->hdi_flush_nasid_list.
106 widget_p[(int)soft->pbi_buscommon.bs_xid];
107 if (sn_flush_device_list) {
108 for (j = 0; j < DEV_PER_WIDGET;
109 j++, sn_flush_device_list++) {
110 if (sn_flush_device_list->sfdl_slot == -1)
111 continue;
112 if (sn_flush_device_list->
113 sfdl_persistent_busnum ==
114 soft->pbi_buscommon.bs_persist_busnum)
115 sn_flush_device_list->sfdl_pcibus_info =
116 soft;
117 }
118 }
119 }
120
121 /* Setup the PMU ATE map */
122 soft->pbi_int_ate_resource.lowest_free_index = 0;
123 soft->pbi_int_ate_resource.ate =
124 kmalloc(soft->pbi_int_ate_size * sizeof(uint64_t), GFP_KERNEL);
125 memset(soft->pbi_int_ate_resource.ate, 0,
126 (soft->pbi_int_ate_size * sizeof(uint64_t)));
127
128 return soft;
129 }
130
131 void pcibr_force_interrupt(struct sn_irq_info *sn_irq_info)
132 {
133 struct pcidev_info *pcidev_info;
134 struct pcibus_info *pcibus_info;
135 int bit = sn_irq_info->irq_int_bit;
136
137 pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
138 if (pcidev_info) {
139 pcibus_info =
140 (struct pcibus_info *)pcidev_info->pdi_host_pcidev_info->
141 pdi_pcibus_info;
142 pcireg_force_intr_set(pcibus_info, bit);
143 }
144 }
145
146 void pcibr_change_devices_irq(struct sn_irq_info *sn_irq_info)
147 {
148 struct pcidev_info *pcidev_info;
149 struct pcibus_info *pcibus_info;
150 int bit = sn_irq_info->irq_int_bit;
151 uint64_t xtalk_addr = sn_irq_info->irq_xtalkaddr;
152
153 pcidev_info = (struct pcidev_info *)sn_irq_info->irq_pciioinfo;
154 if (pcidev_info) {
155 pcibus_info =
156 (struct pcibus_info *)pcidev_info->pdi_host_pcidev_info->
157 pdi_pcibus_info;
158
159 /* Disable the device's IRQ */
160 pcireg_intr_enable_bit_clr(pcibus_info, bit);
161
162 /* Change the device's IRQ */
163 pcireg_intr_addr_addr_set(pcibus_info, bit, xtalk_addr);
164
165 /* Re-enable the device's IRQ */
166 pcireg_intr_enable_bit_set(pcibus_info, bit);
167
168 pcibr_force_interrupt(sn_irq_info);
169 }
170 }