This source file includes following definitions.
- mk_conf_addr
- conf_read
- conf_write
- pcibios_read_config_byte
- pcibios_read_config_word
- pcibios_read_config_dword
- pcibios_write_config_byte
- pcibios_write_config_word
- pcibios_write_config_dword
- lca_init
- lca_machine_check
1
2
3
4
5
6
7
8 #include <linux/kernel.h>
9 #include <linux/config.h>
10 #include <linux/types.h>
11 #include <linux/bios32.h>
12 #include <linux/pci.h>
13
14 #include <asm/ptrace.h>
15 #include <asm/system.h>
16 #include <asm/io.h>
17
18
19
20
21
22 #ifdef CONFIG_ALPHA_LCA
23
24 #define vulp volatile unsigned long *
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 static int mk_conf_addr(unsigned char bus, unsigned char device_fn,
68 unsigned char where, unsigned long *pci_addr)
69 {
70 unsigned long addr;
71
72 if (bus == 0) {
73 int device = device_fn >> 3;
74 int func = device_fn & 0x7;
75
76
77
78 if (device > 12) {
79 return -1;
80 }
81
82 *((volatile unsigned long*) LCA_IOC_CONF) = 0;
83 addr = (1 << (11 + device)) | (func << 8) | where;
84 } else {
85
86 *((volatile unsigned long*) LCA_IOC_CONF) = 1;
87 addr = (bus << 16) | (device_fn << 8) | where;
88 }
89 *pci_addr = addr;
90 return 0;
91 }
92
93
94 static unsigned int conf_read(unsigned long addr)
95 {
96 unsigned long flags, code, stat0;
97 unsigned int value;
98
99 save_flags(flags);
100 cli();
101
102
103 stat0 = *((volatile unsigned long*)LCA_IOC_STAT0);
104 *((volatile unsigned long*)LCA_IOC_STAT0) = stat0;
105 mb();
106
107
108
109 value = *((volatile unsigned int*)addr);
110 draina();
111
112 stat0 = *((unsigned long*)LCA_IOC_STAT0);
113 if (stat0 & LCA_IOC_STAT0_ERR) {
114 code = ((stat0 >> LCA_IOC_STAT0_CODE_SHIFT)
115 & LCA_IOC_STAT0_CODE_MASK);
116 if (code != 1) {
117 printk("lca.c:conf_read: got stat0=%lx\n", stat0);
118 }
119
120
121 *((volatile unsigned long*)LCA_IOC_STAT0) = stat0;
122 mb();
123 wrmces(0x7);
124
125 value = 0xffffffff;
126 }
127 restore_flags(flags);
128 return value;
129 }
130
131
132 static void conf_write(unsigned long addr, unsigned int value)
133 {
134 unsigned long flags, code, stat0;
135
136 save_flags(flags);
137 cli();
138
139
140 stat0 = *((volatile unsigned long*)LCA_IOC_STAT0);
141 *((volatile unsigned long*)LCA_IOC_STAT0) = stat0;
142 mb();
143
144
145
146 *((volatile unsigned int*)addr) = value;
147 draina();
148
149 stat0 = *((unsigned long*)LCA_IOC_STAT0);
150 if (stat0 & LCA_IOC_STAT0_ERR) {
151 code = ((stat0 >> LCA_IOC_STAT0_CODE_SHIFT)
152 & LCA_IOC_STAT0_CODE_MASK);
153 if (code != 1) {
154 printk("lca.c:conf_write: got stat0=%lx\n", stat0);
155 }
156
157
158 *((volatile unsigned long*)LCA_IOC_STAT0) = stat0;
159 mb();
160 wrmces(0x7);
161 }
162 restore_flags(flags);
163 }
164
165
166 int pcibios_read_config_byte (unsigned char bus, unsigned char device_fn,
167 unsigned char where, unsigned char *value)
168 {
169 unsigned long addr = LCA_CONF;
170 unsigned long pci_addr;
171
172 *value = 0xff;
173
174 if (mk_conf_addr(bus, device_fn, where, &pci_addr) < 0) {
175 return PCIBIOS_SUCCESSFUL;
176 }
177 addr |= (pci_addr << 5) + 0x00;
178 *value = conf_read(addr) >> ((where & 3) * 8);
179 return PCIBIOS_SUCCESSFUL;
180 }
181
182
183 int pcibios_read_config_word (unsigned char bus, unsigned char device_fn,
184 unsigned char where, unsigned short *value)
185 {
186 unsigned long addr = LCA_CONF;
187 unsigned long pci_addr;
188
189 *value = 0xffff;
190
191 if (where & 0x1) {
192 return PCIBIOS_BAD_REGISTER_NUMBER;
193 }
194 if (mk_conf_addr(bus, device_fn, where, &pci_addr)) {
195 return PCIBIOS_SUCCESSFUL;
196 }
197 addr |= (pci_addr << 5) + 0x08;
198 *value = conf_read(addr) >> ((where & 3) * 8);
199 return PCIBIOS_SUCCESSFUL;
200 }
201
202
203 int pcibios_read_config_dword (unsigned char bus, unsigned char device_fn,
204 unsigned char where, unsigned int *value)
205 {
206 unsigned long addr = LCA_CONF;
207 unsigned long pci_addr;
208
209 *value = 0xffffffff;
210 if (where & 0x3) {
211 return PCIBIOS_BAD_REGISTER_NUMBER;
212 }
213 if (mk_conf_addr(bus, device_fn, where, &pci_addr)) {
214 return PCIBIOS_SUCCESSFUL;
215 }
216 addr |= (pci_addr << 5) + 0x18;
217 *value = conf_read(addr);
218 return PCIBIOS_SUCCESSFUL;
219 }
220
221
222 int pcibios_write_config_byte (unsigned char bus, unsigned char device_fn,
223 unsigned char where, unsigned char value)
224 {
225 unsigned long addr = LCA_CONF;
226 unsigned long pci_addr;
227
228 if (mk_conf_addr(bus, device_fn, where, &pci_addr) < 0) {
229 return PCIBIOS_SUCCESSFUL;
230 }
231 addr |= (pci_addr << 5) + 0x00;
232 conf_write(addr, value << ((where & 3) * 8));
233 return PCIBIOS_SUCCESSFUL;
234 }
235
236
237 int pcibios_write_config_word (unsigned char bus, unsigned char device_fn,
238 unsigned char where, unsigned short value)
239 {
240 unsigned long addr = LCA_CONF;
241 unsigned long pci_addr;
242
243 if (mk_conf_addr(bus, device_fn, where, &pci_addr) < 0) {
244 return PCIBIOS_SUCCESSFUL;
245 }
246 addr |= (pci_addr << 5) + 0x08;
247 conf_write(addr, value << ((where & 3) * 8));
248 return PCIBIOS_SUCCESSFUL;
249 }
250
251
252 int pcibios_write_config_dword (unsigned char bus, unsigned char device_fn,
253 unsigned char where, unsigned int value)
254 {
255 unsigned long addr = LCA_CONF;
256 unsigned long pci_addr;
257
258 if (mk_conf_addr(bus, device_fn, where, &pci_addr) < 0) {
259 return PCIBIOS_SUCCESSFUL;
260 }
261 addr |= (pci_addr << 5) + 0x18;
262 conf_write(addr, value << ((where & 3) * 8));
263 return PCIBIOS_SUCCESSFUL;
264 }
265
266
267 unsigned long lca_init(unsigned long mem_start, unsigned long mem_end)
268 {
269
270
271
272
273
274
275 *(vulp)LCA_IOC_W_BASE1 = 0UL<<33;
276 *(vulp)LCA_IOC_W_BASE0 = 1UL<<33 | LCA_DMA_WIN_BASE;
277 *(vulp)LCA_IOC_W_MASK0 = LCA_DMA_WIN_SIZE - 1;
278 *(vulp)LCA_IOC_T_BASE0 = 0;
279 return mem_start;
280 }
281
282
283 void lca_machine_check (unsigned long vector, unsigned long la, struct pt_regs *regs)
284 {
285 unsigned long mces;
286
287 mces = rdmces();
288 wrmces(mces);
289 printk("Machine check (la=0x%lx,mces=0x%lx)\n", la, mces);
290 printk("esr=%lx, ear=%lx, ioc_stat0=%lx, ioc_stat1=%lx\n",
291 *(unsigned long*)LCA_MEM_ESR, *(unsigned long*)LCA_MEM_EAR,
292 *(unsigned long*)LCA_IOC_STAT0, *(unsigned long*)LCA_IOC_STAT1);
293 }
294
295 #endif