This source file includes following definitions.
- amd756_init
- amd756_getclink
- amd756_get_intr
- amd756_set_intr
- amd756_get_trigger
- amd756_set_trigger
- amd756_pir_dump
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 #include <sys/param.h>
71 #include <sys/systm.h>
72 #include <sys/device.h>
73 #include <sys/malloc.h>
74
75 #include <machine/intr.h>
76 #include <machine/bus.h>
77
78 #include <dev/pci/pcivar.h>
79 #include <dev/pci/pcireg.h>
80 #include <dev/pci/pcidevs.h>
81
82 #include <i386/pci/pcibiosvar.h>
83 #include <i386/pci/amd756reg.h>
84
85 struct viper_handle {
86 bus_space_tag_t ph_iot;
87 bus_space_handle_t ph_regs_ioh;
88 pci_chipset_tag_t ph_pc;
89 pcitag_t ph_tag;
90 };
91
92 int amd756_getclink(pciintr_icu_handle_t, int, int *);
93 int amd756_get_intr(pciintr_icu_handle_t, int, int *);
94 int amd756_set_intr(pciintr_icu_handle_t, int, int);
95 int amd756_get_trigger(pciintr_icu_handle_t, int, int *);
96 int amd756_set_trigger(pciintr_icu_handle_t, int, int);
97 #ifdef VIPER_DEBUG
98 static void amd756_pir_dump(struct viper_handle *);
99 #endif
100
101 const struct pciintr_icu amd756_pci_icu = {
102 amd756_getclink,
103 amd756_get_intr,
104 amd756_set_intr,
105 amd756_get_trigger,
106 amd756_set_trigger,
107 };
108
109
110 int
111 amd756_init(pci_chipset_tag_t pc, bus_space_tag_t iot, pcitag_t tag,
112 pciintr_icu_tag_t *ptagp, pciintr_icu_handle_t *phandp)
113 {
114 struct viper_handle *ph;
115
116 ph = malloc(sizeof(*ph), M_DEVBUF, M_NOWAIT);
117 if (ph == NULL)
118 return (1);
119
120 ph->ph_iot = iot;
121 ph->ph_pc = pc;
122 ph->ph_tag = tag;
123
124 *ptagp = &amd756_pci_icu;
125 *phandp = ph;
126
127 #ifdef VIPER_DEBUG
128 amd756_pir_dump(ph);
129 #endif
130
131 return 0;
132 }
133
134 int
135 amd756_getclink(pciintr_icu_handle_t v, int link, int *clinkp)
136 {
137 if (AMD756_LEGAL_LINK(link - 1) == 0)
138 return (1);
139
140 *clinkp = link - 1;
141 return (0);
142 }
143
144 int
145 amd756_get_intr(pciintr_icu_handle_t v, int clink, int *irqp)
146 {
147 struct viper_handle *ph = v;
148 pcireg_t reg;
149 int val;
150
151 if (AMD756_LEGAL_LINK(clink) == 0)
152 return (1);
153
154 reg = AMD756_GET_PIIRQSEL(ph);
155 val = (reg >> (4*clink)) & 0x0f;
156 *irqp = (val == 0) ?
157 I386_PCI_INTERRUPT_LINE_NO_CONNECTION : val;
158
159 return (0);
160 }
161
162 int
163 amd756_set_intr(pciintr_icu_handle_t v, int clink, int irq)
164 {
165 struct viper_handle *ph = v;
166 int val;
167 pcireg_t reg;
168
169 if (AMD756_LEGAL_LINK(clink) == 0 || AMD756_LEGAL_IRQ(irq) == 0)
170 return (1);
171
172 reg = AMD756_GET_PIIRQSEL(ph);
173 amd756_get_intr(v, clink, &val);
174 reg &= ~(0x000f << (4*clink));
175 reg |= irq << (4*clink);
176 AMD756_SET_PIIRQSEL(ph, reg);
177
178 return 0;
179 }
180
181 int
182 amd756_get_trigger(pciintr_icu_handle_t v, int irq, int *triggerp)
183 {
184 struct viper_handle *ph = v;
185 int i, pciirq;
186 pcireg_t reg;
187
188 if (AMD756_LEGAL_IRQ(irq) == 0)
189 return (1);
190
191 for (i = 0; i <= 3; i++) {
192 amd756_get_intr(v, i, &pciirq);
193 if (pciirq == irq) {
194 reg = AMD756_GET_EDGESEL(ph);
195 if (reg & (1 << i))
196 *triggerp = IST_EDGE;
197 else
198 *triggerp = IST_LEVEL;
199 break;
200 }
201 }
202
203 return 0;
204 }
205
206 int
207 amd756_set_trigger(pciintr_icu_handle_t v, int irq, int trigger)
208 {
209 struct viper_handle *ph = v;
210 int i, pciirq;
211 pcireg_t reg;
212
213 if (AMD756_LEGAL_IRQ(irq) == 0)
214 return (1);
215
216 for (i = 0; i <= 3; i++) {
217 amd756_get_intr(v, i, &pciirq);
218 if (pciirq == irq) {
219 reg = AMD756_GET_PIIRQSEL(ph);
220 if (trigger == IST_LEVEL)
221 reg &= ~(1 << (4*i));
222 else
223 reg |= 1 << (4*i);
224 AMD756_SET_PIIRQSEL(ph, reg);
225 break;
226 }
227 }
228
229 return (0);
230 }
231
232 #ifdef VIPER_DEBUG
233 static void
234 amd756_pir_dump(struct viper_handle *ph)
235 {
236 int a, b;
237
238 printf ("VIPER PCI INTERRUPT ROUTING REGISTERS:\n");
239
240 a = AMD756_GET_EDGESEL(ph);
241 b = AMD756_GET_PIIRQSEL(ph);
242
243 printf ("TRIGGER: %02x, ROUTING: %04x\n", a, b);
244 }
245 #endif