This source file includes following definitions.
- pci_lookup_dev
- pci_strclass
- pci_strvendor
- pci_strdev
- burst_bridge
- sprint_dev_config
- get_pci_list
- pci_malloc
- scan_bus
- pci_init
1
2
3
4
5
6
7
8
9 #include <linux/config.h>
10 #include <linux/ptrace.h>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/bios32.h>
14 #include <linux/pci.h>
15 #include <linux/string.h>
16
17 #include <asm/page.h>
18
19 struct pci_bus pci_root;
20 struct pci_dev *pci_devices = 0;
21
22
23
24
25
26
27
28
29
30
31
32 #define DEVICE(vid,did,name) \
33 {PCI_VENDOR_ID_##vid, PCI_DEVICE_ID_##did, (name), 0xff}
34
35 #define BRIDGE(vid,did,name,bridge) \
36 {PCI_VENDOR_ID_##vid, PCI_DEVICE_ID_##did, (name), (bridge)}
37
38
39
40
41
42
43 struct pci_dev_info dev_info[] = {
44 DEVICE( COMPAQ, COMPAQ_1280, "QVision 1280/p"),
45 DEVICE( COMPAQ, COMPAQ_THUNDER, "ThunderLAN"),
46 DEVICE( NCR, NCR_53C810, "53c810"),
47 DEVICE( NCR, NCR_53C820, "53c820"),
48 DEVICE( NCR, NCR_53C825, "53c825"),
49 DEVICE( NCR, NCR_53C815, "53c815"),
50 DEVICE( ATI, ATI_68800, "68800AX"),
51 DEVICE( ATI, ATI_215CT222, "215CT222"),
52 DEVICE( ATI, ATI_210888CX, "210888CX"),
53 DEVICE( ATI, ATI_210888GX, "210888GX"),
54 DEVICE( VLSI, VLSI_82C592, "82C592-FC1"),
55 DEVICE( VLSI, VLSI_82C593, "82C593-FC1"),
56 DEVICE( VLSI, VLSI_82C594, "82C594-AFC2"),
57 DEVICE( VLSI, VLSI_82C597, "82C597-AFC2"),
58 DEVICE( ADL, ADL_2301, "2301"),
59 DEVICE( NS, NS_87410, "87410"),
60 DEVICE( TSENG, TSENG_W32P_2, "ET4000W32P"),
61 DEVICE( TSENG, TSENG_W32P_b, "ET4000W32P rev B"),
62 DEVICE( TSENG, TSENG_W32P_c, "ET4000W32P rev C"),
63 DEVICE( TSENG, TSENG_W32P_d, "ET4000W32P rev D"),
64 DEVICE( WEITEK, WEITEK_P9000, "P9000"),
65 DEVICE( WEITEK, WEITEK_P9100, "P9100"),
66 BRIDGE( DEC, DEC_BRD, "DC21050", 0x00),
67 DEVICE( DEC, DEC_TULIP, "DC21040"),
68 DEVICE( DEC, DEC_TGA, "DC21030"),
69 DEVICE( DEC, DEC_TULIP_FAST, "DC21140"),
70 DEVICE( DEC, DEC_FDDI, "DEFPA"),
71 DEVICE( DEC, DEC_TULIP_PLUS, "DC21041"),
72 DEVICE( CIRRUS, CIRRUS_5430, "GD 5430"),
73 DEVICE( CIRRUS, CIRRUS_5434_4, "GD 5434"),
74 DEVICE( CIRRUS, CIRRUS_5434_8, "GD 5434"),
75 DEVICE( CIRRUS, CIRRUS_5436, "GD 5436"),
76 DEVICE( CIRRUS, CIRRUS_6729, "CL 6729"),
77 DEVICE( CIRRUS, CIRRUS_7542, "CL 7542"),
78 DEVICE( CIRRUS, CIRRUS_7543, "CL 7543"),
79 DEVICE( IBM, IBM_82G2675, "82G2675"),
80 DEVICE( WD, WD_7197, "WD 7197"),
81 DEVICE( AMD, AMD_LANCE, "79C970"),
82 DEVICE( AMD, AMD_SCSI, "53C974"),
83 DEVICE( TRIDENT, TRIDENT_9420, "TG 9420"),
84 DEVICE( TRIDENT, TRIDENT_9440, "TG 9440"),
85 DEVICE( TRIDENT, TRIDENT_9660, "TG 9660"),
86 DEVICE( AI, AI_M1435, "M1435"),
87 DEVICE( MATROX, MATROX_MGA_2, "Atlas PX2085"),
88 DEVICE( MATROX, MATROX_MIL ,"Millenium"),
89 DEVICE( MATROX, MATROX_MGA_IMP, "MGA Impression"),
90 DEVICE( CT, CT_65545, "65545"),
91 DEVICE( CT, CT_65548, "65548"),
92 DEVICE( MIRO, MIRO_36050, "ZR36050"),
93 DEVICE( FD, FD_36C70, "TMC-18C30"),
94 DEVICE( SI, SI_6201, "6201"),
95 DEVICE( SI, SI_6202, "6202"),
96 DEVICE( SI, SI_503, "85C503"),
97 DEVICE( SI, SI_6205, "6205"),
98 DEVICE( SI, SI_501, "85C501"),
99 DEVICE( SI, SI_496, "85C496"),
100 DEVICE( SI, SI_601, "85C601"),
101 DEVICE( SI, SI_5511, "85C5511"),
102 DEVICE( SI, SI_5513, "85C5513"),
103 DEVICE( HP, HP_J2585A, "J2585A"),
104 DEVICE( PCTECH, PCTECH_RZ1000, "RZ1000 (buggy)"),
105 DEVICE( PCTECH, PCTECH_RZ1001, "RZ1001 (buggy?)"),
106 DEVICE( DPT, DPT, "SmartCache/Raid"),
107 DEVICE( OPTI, OPTI_92C178, "92C178"),
108 DEVICE( OPTI, OPTI_82C557, "82C557"),
109 DEVICE( OPTI, OPTI_82C558, "82C558"),
110 DEVICE( OPTI, OPTI_82C621, "82C621"),
111 DEVICE( OPTI, OPTI_82C822, "82C822"),
112 DEVICE( SGS, SGS_2000, "STG 2000X"),
113 DEVICE( SGS, SGS_1764, "STG 1764X"),
114 DEVICE( BUSLOGIC, BUSLOGIC_946C_2,"BT-946C"),
115 DEVICE( BUSLOGIC, BUSLOGIC_946C, "BT-946C"),
116 DEVICE( BUSLOGIC, BUSLOGIC_930, "BT-930"),
117 DEVICE( OAK, OAK_OTI107, "OTI107"),
118 DEVICE( PROMISE, PROMISE_5300, "DC5030"),
119 DEVICE( N9, N9_I128, "Imagine 128"),
120 DEVICE( N9, N9_I128_2, "Imagine 128v2"),
121 DEVICE( UMC, UMC_UM8673F, "UM8673F"),
122 BRIDGE( UMC, UMC_UM8891A, "UM8891A", 0x01),
123 DEVICE( UMC, UMC_UM8886BF, "UM8886BF"),
124 DEVICE( UMC, UMC_UM8886A, "UM8886A"),
125 BRIDGE( UMC, UMC_UM8881F, "UM8881F", 0x02),
126 DEVICE( UMC, UMC_UM8886F, "UM8886F"),
127 DEVICE( UMC, UMC_UM9017F, "UM9017F"),
128 DEVICE( UMC, UMC_UM8886N, "UM8886N"),
129 DEVICE( UMC, UMC_UM8891N, "UM8891N"),
130 DEVICE( X, X_AGX016, "ITT AGX016"),
131 DEVICE( NEXGEN, NEXGEN_82C501, "82C501"),
132 DEVICE( QLOGIC, QLOGIC_ISP1020, "ISP1020"),
133 DEVICE( QLOGIC, QLOGIC_ISP1022, "ISP1022"),
134 DEVICE( LEADTEK, LEADTEK_805, "S3 805"),
135 DEVICE( CONTAQ, CONTAQ_82C599, "82C599"),
136 DEVICE( CMD, CMD_640, "640 (buggy)"),
137 DEVICE( CMD, CMD_646, "646"),
138 DEVICE( VISION, VISION_QD8500, "QD-8500"),
139 DEVICE( VISION, VISION_QD8580, "QD-8580"),
140 DEVICE( SIERRA, SIERRA_STB, "STB Horizon 64"),
141 DEVICE( ACC, ACC_2056, "2056"),
142 DEVICE( WINBOND, WINBOND_83769, "W83769F"),
143 DEVICE( WINBOND, WINBOND_82C105, "SL82C105"),
144 DEVICE( 3COM, 3COM_3C590, "3C590 10bT"),
145 DEVICE( 3COM, 3COM_3C595TX, "3C595 100bTX"),
146 DEVICE( 3COM, 3COM_3C595T4, "3C595 100bT4"),
147 DEVICE( 3COM, 3COM_3C595MII, "3C595 100b-MII"),
148 DEVICE( AL, AL_M1445, "M1445"),
149 DEVICE( AL, AL_M1449, "M1449"),
150 DEVICE( AL, AL_M1451, "M1451"),
151 DEVICE( AL, AL_M1461, "M1461"),
152 DEVICE( AL, AL_M1489, "M1489"),
153 DEVICE( AL, AL_M1511, "M1511"),
154 DEVICE( AL, AL_M1513, "M1513"),
155 DEVICE( AL, AL_M4803, "M4803"),
156 DEVICE( ASP, ASP_ABP940, "ABP940"),
157 DEVICE( CERN, CERN_SPSB_PMC, "STAR/RD24 SCI-PCI (PMC)"),
158 DEVICE( CERN, CERN_SPSB_PCI, "STAR/RD24 SCI-PCI (PMC)"),
159 DEVICE( IMS, IMS_8849, "8849"),
160 DEVICE( TEKRAM2, TEKRAM2_690c, "DC690c"),
161 DEVICE( AMCC, AMCC_MYRINET, "Myrinet PCI (M2-PCI-32)"),
162 DEVICE( INTERG, INTERG_1680, "IGA-1680"),
163 DEVICE( REALTEK, REALTEK_8029, "8029"),
164 DEVICE( INIT, INIT_320P, "320 P"),
165 DEVICE( VIA, VIA_82C505, "VT 82C505"),
166 DEVICE( VIA, VIA_82C561, "VT 82C561"),
167 DEVICE( VIA, VIA_82C576, "VT 82C576 3V"),
168 DEVICE( VIA, VIA_82C416, "VT 82C416MV"),
169 DEVICE( VORTEX, VORTEX_GDT60x0, "GDT 60x0"),
170 DEVICE( VORTEX, VORTEX_GDT6000B,"GDT 6000b"),
171 DEVICE( VORTEX, VORTEX_GDT6x10, "GDT 6110/6510"),
172 DEVICE( VORTEX, VORTEX_GDT6x20, "GDT 6120/6520"),
173 DEVICE( VORTEX, VORTEX_GDT6530, "GDT 6530"),
174 DEVICE( VORTEX, VORTEX_GDT6550, "GDT 6550"),
175 DEVICE( VORTEX, VORTEX_GDT6x17, "GDT 6117/6517"),
176 DEVICE( VORTEX, VORTEX_GDT6x27, "GDT 6127/6527"),
177 DEVICE( VORTEX, VORTEX_GDT6537, "GDT 6537"),
178 DEVICE( VORTEX, VORTEX_GDT6557, "GDT 6557"),
179 DEVICE( VORTEX, VORTEX_GDT6x15, "GDT 6115/6515"),
180 DEVICE( VORTEX, VORTEX_GDT6x25, "GDT 6125/6525"),
181 DEVICE( VORTEX, VORTEX_GDT6535, "GDT 6535"),
182 DEVICE( VORTEX, VORTEX_GDT6555, "GDT 6555"),
183 DEVICE( EF, EF_ATM_FPGA, "155P-MF1 (FPGA)"),
184 DEVICE( EF, EF_ATM_ASIC, "155P-MF1 (ASIC)"),
185 DEVICE( IMAGINGTECH, IMAGINGTECH_ICPCI, "MVC IC-PCI"),
186 DEVICE( FORE, FORE_PCA200PC, "PCA-200PC"),
187 DEVICE( FORE, FORE_PCA200E, "PCA-200E"),
188 DEVICE( PLX, PLX_9060, "PCI9060 i960 bridge"),
189 DEVICE( ALLIANCE, ALLIANCE_PROMOTIO, "Promotion-6410"),
190 DEVICE( ALLIANCE, ALLIANCE_PROVIDEO, "Provideo"),
191 DEVICE( VMIC, VMIC_VME, "VMIVME-7587"),
192 DEVICE( DIGI, DIGI_RIGHTSWITCH, "Digi RightSwitch SE-6"),
193 DEVICE( MUTECH, MUTECH_MV1000, "MV-1000"),
194 DEVICE( ZEITNET, ZEITNET_1221, "1221"),
195 DEVICE( ZEITNET, ZEITNET_1225, "1225"),
196 DEVICE( SPECIALIX, SPECIALIX_XIO, "XIO/SIO host"),
197 DEVICE( SPECIALIX, SPECIALIX_RIO, "RIO host"),
198 DEVICE( RP, RP8OCTA, "RocketPort 8 Oct"),
199 DEVICE( RP, RP8INTF, "RocketPort 8 Intf"),
200 DEVICE( RP, RP16INTF, "RocketPort 16 Intf"),
201 DEVICE( RP, RP32INTF, "RocketPort 32 Intf"),
202 DEVICE( CYCLADES, CYCLOM_Y_Lo, "Cyclom-Y below 1Mbyte"),
203 DEVICE( CYCLADES, CYCLOM_Y_Hi, "Cyclom-Y above 1Mbyte"),
204 DEVICE( CYCLADES, CYCLOM_Z_Lo, "Cyclom-Z below 1Mbyte"),
205 DEVICE( CYCLADES, CYCLOM_Z_Hi, "Cyclom-Z above 1Mbyte"),
206 DEVICE( SYMPHONY, SYMPHONY_101, "82C101"),
207 DEVICE( TEKRAM, TEKRAM_DC290, "DC-290"),
208 DEVICE( AVANCE, AVANCE_2302, "ALG-2302"),
209 DEVICE( S3, S3_811, "Trio32/Trio64"),
210 DEVICE( S3, S3_868, "Vision 868"),
211 DEVICE( S3, S3_928, "Vision 928-P"),
212 DEVICE( S3, S3_864_1, "Vision 864-P"),
213 DEVICE( S3, S3_864_2, "Vision 864-P"),
214 DEVICE( S3, S3_964_1, "Vision 964-P"),
215 DEVICE( S3, S3_964_2, "Vision 964-P"),
216 DEVICE( S3, S3_968, "Vision 968"),
217 DEVICE( INTEL, INTEL_82375, "82375EB"),
218 BRIDGE( INTEL, INTEL_82424, "82424ZX Saturn", 0x00),
219 DEVICE( INTEL, INTEL_82378, "82378IB"),
220 DEVICE( INTEL, INTEL_82430, "82430ZX Aries"),
221 BRIDGE( INTEL, INTEL_82434, "82434LX Mercury/Neptune", 0x00),
222 DEVICE( INTEL, INTEL_7116, "SAA7116"),
223 DEVICE( INTEL, INTEL_82596, "82596"),
224 DEVICE( INTEL, INTEL_82865, "82865"),
225 DEVICE( INTEL, INTEL_82557, "82557"),
226 DEVICE( INTEL, INTEL_82437, "82437"),
227 DEVICE( INTEL, INTEL_82371_0, "82371 Triton PIIX"),
228 DEVICE( INTEL, INTEL_82371_1, "82371 Triton PIIX"),
229 DEVICE( INTEL, INTEL_P6, "Orion P6"),
230 DEVICE( ADAPTEC, ADAPTEC_7850, "AIC-7850"),
231 DEVICE( ADAPTEC, ADAPTEC_7855, "AIC-7855"),
232 DEVICE( ADAPTEC, ADAPTEC_7870, "AIC-7870"),
233 DEVICE( ADAPTEC, ADAPTEC_7871, "AIC-7871"),
234 DEVICE( ADAPTEC, ADAPTEC_7872, "AIC-7872"),
235 DEVICE( ADAPTEC, ADAPTEC_7873, "AIC-7873"),
236 DEVICE( ADAPTEC, ADAPTEC_7874, "AIC-7874"),
237 DEVICE( ADAPTEC, ADAPTEC_7880, "AIC-7880U"),
238 DEVICE( ADAPTEC, ADAPTEC_7881, "AIC-7881U"),
239 DEVICE( ADAPTEC, ADAPTEC_7882, "AIC-7882U"),
240 DEVICE( ADAPTEC, ADAPTEC_7883, "AIC-7883U"),
241 DEVICE( ADAPTEC, ADAPTEC_7884, "AIC-7884U"),
242 DEVICE( ATRONICS, ATRONICS_2015, "IDE-2015PL"),
243 DEVICE( HER, HER_STING, "Stingray"),
244 DEVICE( HER, HER_STINGARK, "Stingray ARK 2000PV")
245 };
246
247
248 #ifdef CONFIG_PCI_OPTIMIZE
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265 struct optimization_type {
266 const char *type;
267 const char *off;
268 const char *on;
269 } bridge_optimization[] = {
270 {"Cache L2", "write through", "write back"},
271 {"CPU-PCI posted write", "off", "on"},
272 {"CPU-Memory posted write", "off", "on"},
273 {"PCI-Memory posted write", "off", "on"},
274 {"PCI burst", "off", "on"}
275 };
276
277 #define NUM_OPTIMIZATIONS \
278 (sizeof(bridge_optimization) / sizeof(bridge_optimization[0]))
279
280 struct bridge_mapping_type {
281 unsigned char addr;
282 unsigned char mask;
283 unsigned char value;
284 } bridge_mapping[] = {
285
286
287
288
289
290
291
292 {0x0 ,0x02 ,0x02 },
293 {0x53 ,0x02 ,0x02 },
294 {0x53 ,0x01 ,0x01 },
295 {0x54 ,0x01 ,0x01 },
296 {0x54 ,0x02 ,0x02 },
297
298
299
300
301
302 {0x50 ,0x10 ,0x00 },
303 {0x51 ,0x40 ,0x40 },
304 {0x0 ,0x0 ,0x0 },
305 {0x0 ,0x0 ,0x0 },
306 {0x0 ,0x0 ,0x0 },
307
308
309
310
311
312
313 {0x0 ,0x1 ,0x1 },
314 {0x0 ,0x2 ,0x0 },
315 {0x0 ,0x0 ,0x0 },
316 {0x0 ,0x0 ,0x0 },
317 {0x0 ,0x0 ,0x0 }
318 };
319
320 #endif
321
322
323
324
325
326 struct pci_dev_info *pci_lookup_dev(unsigned int vendor, unsigned int dev)
327 {
328 int min = 0,
329 max = sizeof(dev_info)/sizeof(dev_info[0]) - 1;
330
331 for ( ; ; )
332 {
333 int i = (min + max) >> 1;
334 long order;
335
336 order = dev_info[i].vendor - (long) vendor;
337 if (!order)
338 order = dev_info[i].device - (long) dev;
339
340 if (order < 0)
341 {
342 min = i + 1;
343 if ( min > max )
344 return 0;
345 continue;
346 }
347
348 if (order > 0)
349 {
350 max = i - 1;
351 if ( min > max )
352 return 0;
353 continue;
354 }
355
356 return & dev_info[ i ];
357 }
358 }
359
360 const char *pci_strclass (unsigned int class)
361 {
362 switch (class >> 8) {
363 case PCI_CLASS_NOT_DEFINED: return "Non-VGA device";
364 case PCI_CLASS_NOT_DEFINED_VGA: return "VGA compatible device";
365
366 case PCI_CLASS_STORAGE_SCSI: return "SCSI storage controller";
367 case PCI_CLASS_STORAGE_IDE: return "IDE interface";
368 case PCI_CLASS_STORAGE_FLOPPY: return "Floppy disk controller";
369 case PCI_CLASS_STORAGE_IPI: return "IPI bus controller";
370 case PCI_CLASS_STORAGE_RAID: return "RAID bus controller";
371 case PCI_CLASS_STORAGE_OTHER: return "Unknown mass storage controller";
372
373 case PCI_CLASS_NETWORK_ETHERNET: return "Ethernet controller";
374 case PCI_CLASS_NETWORK_TOKEN_RING: return "Token ring network controller";
375 case PCI_CLASS_NETWORK_FDDI: return "FDDI network controller";
376 case PCI_CLASS_NETWORK_ATM: return "ATM network controller";
377 case PCI_CLASS_NETWORK_OTHER: return "Network controller";
378
379 case PCI_CLASS_DISPLAY_VGA: return "VGA compatible controller";
380 case PCI_CLASS_DISPLAY_XGA: return "XGA compatible controller";
381 case PCI_CLASS_DISPLAY_OTHER: return "Display controller";
382
383 case PCI_CLASS_MULTIMEDIA_VIDEO: return "Multimedia video controller";
384 case PCI_CLASS_MULTIMEDIA_AUDIO: return "Multimedia audio controller";
385 case PCI_CLASS_MULTIMEDIA_OTHER: return "Multimedia controller";
386
387 case PCI_CLASS_MEMORY_RAM: return "RAM memory";
388 case PCI_CLASS_MEMORY_FLASH: return "FLASH memory";
389 case PCI_CLASS_MEMORY_OTHER: return "Memory";
390
391 case PCI_CLASS_BRIDGE_HOST: return "Host bridge";
392 case PCI_CLASS_BRIDGE_ISA: return "ISA bridge";
393 case PCI_CLASS_BRIDGE_EISA: return "EISA bridge";
394 case PCI_CLASS_BRIDGE_MC: return "MicroChannel bridge";
395 case PCI_CLASS_BRIDGE_PCI: return "PCI bridge";
396 case PCI_CLASS_BRIDGE_PCMCIA: return "PCMCIA bridge";
397 case PCI_CLASS_BRIDGE_NUBUS: return "NuBus bridge";
398 case PCI_CLASS_BRIDGE_CARDBUS: return "CardBus bridge";
399 case PCI_CLASS_BRIDGE_OTHER: return "Bridge";
400
401 case PCI_CLASS_COMMUNICATION_SERIAL: return "Serial controller";
402 case PCI_CLASS_COMMUNICATION_PARALLEL: return "Parallel controller";
403 case PCI_CLASS_COMMUNICATION_OTHER: return "Communication controller";
404
405 case PCI_CLASS_SYSTEM_PIC: return "PIC";
406 case PCI_CLASS_SYSTEM_DMA: return "DMA controller";
407 case PCI_CLASS_SYSTEM_TIMER: return "Timer";
408 case PCI_CLASS_SYSTEM_RTC: return "RTC";
409 case PCI_CLASS_SYSTEM_OTHER: return "System peripheral";
410
411 case PCI_CLASS_INPUT_KEYBOARD: return "Keyboard controller";
412 case PCI_CLASS_INPUT_PEN: return "Digitizer Pen";
413 case PCI_CLASS_INPUT_MOUSE: return "Mouse controller";
414 case PCI_CLASS_INPUT_OTHER: return "Input device controller";
415
416 case PCI_CLASS_DOCKING_GENERIC: return "Generic Docking Station";
417 case PCI_CLASS_DOCKING_OTHER: return "Docking Station";
418
419 case PCI_CLASS_PROCESSOR_386: return "386";
420 case PCI_CLASS_PROCESSOR_486: return "486";
421 case PCI_CLASS_PROCESSOR_PENTIUM: return "Pentium";
422 case PCI_CLASS_PROCESSOR_ALPHA: return "Alpha";
423 case PCI_CLASS_PROCESSOR_POWERPC: return "Power PC";
424 case PCI_CLASS_PROCESSOR_CO: return "Co-processor";
425
426 case PCI_CLASS_SERIAL_FIREWIRE: return "FireWire (IEEE 1394)";
427 case PCI_CLASS_SERIAL_ACCESS: return "ACCESS Bus";
428 case PCI_CLASS_SERIAL_SSA: return "SSA";
429 case PCI_CLASS_SERIAL_FIBER: return "Fiber Channel";
430
431 default: return "Unknown class";
432 }
433 }
434
435
436 const char *pci_strvendor(unsigned int vendor)
437 {
438 switch (vendor) {
439 case PCI_VENDOR_ID_COMPAQ: return "Compaq";
440 case PCI_VENDOR_ID_NCR: return "NCR";
441 case PCI_VENDOR_ID_ATI: return "ATI";
442 case PCI_VENDOR_ID_VLSI: return "VLSI";
443 case PCI_VENDOR_ID_ADL: return "Advance Logic";
444 case PCI_VENDOR_ID_NS: return "NS";
445 case PCI_VENDOR_ID_TSENG: return "Tseng'Lab";
446 case PCI_VENDOR_ID_WEITEK: return "Weitek";
447 case PCI_VENDOR_ID_DEC: return "DEC";
448 case PCI_VENDOR_ID_CIRRUS: return "Cirrus Logic";
449 case PCI_VENDOR_ID_IBM: return "IBM";
450 case PCI_VENDOR_ID_WD: return "Western Digital";
451 case PCI_VENDOR_ID_AMD: return "AMD";
452 case PCI_VENDOR_ID_TRIDENT: return "Trident";
453 case PCI_VENDOR_ID_AI: return "Acer Incorporated";
454 case PCI_VENDOR_ID_MATROX: return "Matrox";
455 case PCI_VENDOR_ID_CT: return "Chips & Technologies";
456 case PCI_VENDOR_ID_MIRO: return "Miro";
457 case PCI_VENDOR_ID_FD: return "Future Domain";
458 case PCI_VENDOR_ID_SI: return "Silicon Integrated Systems";
459 case PCI_VENDOR_ID_HP: return "Hewlett Packard";
460 case PCI_VENDOR_ID_PCTECH: return "PCTECH";
461 case PCI_VENDOR_ID_DPT: return "DPT";
462 case PCI_VENDOR_ID_OPTI: return "OPTI";
463 case PCI_VENDOR_ID_SGS: return "SGS Thomson";
464 case PCI_VENDOR_ID_BUSLOGIC: return "BusLogic";
465 case PCI_VENDOR_ID_OAK: return "OAK";
466 case PCI_VENDOR_ID_PROMISE: return "Promise Technology";
467 case PCI_VENDOR_ID_N9: return "Number Nine";
468 case PCI_VENDOR_ID_UMC: return "UMC";
469 case PCI_VENDOR_ID_X: return "X TECHNOLOGY";
470 case PCI_VENDOR_ID_NEXGEN: return "Nexgen";
471 case PCI_VENDOR_ID_QLOGIC: return "Q Logic";
472 case PCI_VENDOR_ID_LEADTEK: return "Leadtek Research";
473 case PCI_VENDOR_ID_CONTAQ: return "Contaq";
474 case PCI_VENDOR_ID_FOREX: return "Forex";
475 case PCI_VENDOR_ID_OLICOM: return "Olicom";
476 case PCI_VENDOR_ID_CMD: return "CMD";
477 case PCI_VENDOR_ID_VISION: return "Vision";
478 case PCI_VENDOR_ID_SIERRA: return "Sierra";
479 case PCI_VENDOR_ID_ACC: return "ACC MICROELECTRONICS";
480 case PCI_VENDOR_ID_WINBOND: return "Winbond";
481 case PCI_VENDOR_ID_3COM: return "3Com";
482 case PCI_VENDOR_ID_AL: return "Acer Labs";
483 case PCI_VENDOR_ID_ASP: return "Advanced System Products";
484 case PCI_VENDOR_ID_CERN: return "CERN";
485 case PCI_VENDOR_ID_IMS: return "IMS";
486 case PCI_VENDOR_ID_TEKRAM2: return "Tekram";
487 case PCI_VENDOR_ID_AMCC: return "AMCC";
488 case PCI_VENDOR_ID_INTERG: return "Intergraphics";
489 case PCI_VENDOR_ID_REALTEK: return "Realtek";
490 case PCI_VENDOR_ID_INIT: return "Initio Corp";
491 case PCI_VENDOR_ID_VIA: return "VIA Technologies";
492 case PCI_VENDOR_ID_VORTEX: return "VORTEX";
493 case PCI_VENDOR_ID_EF: return "Efficient Networks";
494 case PCI_VENDOR_ID_FORE: return "Fore Systems";
495 case PCI_VENDOR_ID_IMAGINGTECH: return "Imaging Technology";
496 case PCI_VENDOR_ID_PLX: return "PLX";
497 case PCI_VENDOR_ID_ALLIANCE: return "Alliance";
498 case PCI_VENDOR_ID_VMIC: return "VMIC";
499 case PCI_VENDOR_ID_MUTECH: return "Mutech";
500 case PCI_VENDOR_ID_TOSHIBA: return "Toshiba";
501 case PCI_VENDOR_ID_ZEITNET: return "ZeitNet";
502 case PCI_VENDOR_ID_SPECIALIX: return "Specialix";
503 case PCI_VENDOR_ID_RP: return "Comtrol";
504 case PCI_VENDOR_ID_CYCLADES: return "Cyclades";
505 case PCI_VENDOR_ID_SYMPHONY: return "Symphony";
506 case PCI_VENDOR_ID_TEKRAM: return "Tekram";
507 case PCI_VENDOR_ID_AVANCE: return "Avance";
508 case PCI_VENDOR_ID_S3: return "S3 Inc.";
509 case PCI_VENDOR_ID_INTEL: return "Intel";
510 case PCI_VENDOR_ID_ADAPTEC: return "Adaptec";
511 case PCI_VENDOR_ID_ATRONICS: return "Atronics";
512 case PCI_VENDOR_ID_HER: return "Hercules";
513 default: return "Unknown vendor";
514 }
515 }
516
517
518 const char *pci_strdev(unsigned int vendor, unsigned int device)
519 {
520 struct pci_dev_info *info;
521
522 info = pci_lookup_dev(vendor, device);
523 return info ? info->name : "Unknown device";
524 }
525
526
527
528
529
530
531 static void burst_bridge(unsigned char bus, unsigned char devfn,
532 unsigned char pos, int turn_on)
533 {
534 #ifdef CONFIG_PCI_OPTIMIZE
535 struct bridge_mapping_type *bmap;
536 unsigned char val;
537 int i;
538
539 pos *= NUM_OPTIMIZATIONS;
540 printk("PCI bridge optimization.\n");
541 for (i = 0; i < NUM_OPTIMIZATIONS; i++) {
542 printk(" %s: ", bridge_optimization[i].type);
543 bmap = &bridge_mapping[pos + i];
544 if (!bmap->addr) {
545 printk("Not supported.");
546 } else {
547 pcibios_read_config_byte(bus, devfn, bmap->addr, &val);
548 if ((val & bmap->mask) == bmap->value) {
549 printk("%s.", bridge_optimization[i].on);
550 if (!turn_on) {
551 pcibios_write_config_byte(bus, devfn,
552 bmap->addr,
553 (val | bmap->mask)
554 - bmap->value);
555 printk("Changed! Now %s.", bridge_optimization[i].off);
556 }
557 } else {
558 printk("%s.", bridge_optimization[i].off);
559 if (turn_on) {
560 pcibios_write_config_byte(bus, devfn,
561 bmap->addr,
562 (val & (0xff - bmap->mask))
563 + bmap->value);
564 printk("Changed! Now %s.", bridge_optimization[i].on);
565 }
566 }
567 }
568 printk("\n");
569 }
570 #endif
571 }
572
573
574
575
576
577
578
579
580 static int sprint_dev_config(struct pci_dev *dev, char *buf, int size)
581 {
582 unsigned long base;
583 unsigned int l, class_rev, bus, devfn;
584 unsigned short vendor, device, status;
585 unsigned char bist, latency, min_gnt, max_lat;
586 int reg, len = 0;
587 const char *str;
588
589 bus = dev->bus->number;
590 devfn = dev->devfn;
591
592 pcibios_read_config_dword(bus, devfn, PCI_CLASS_REVISION, &class_rev);
593 pcibios_read_config_word (bus, devfn, PCI_VENDOR_ID, &vendor);
594 pcibios_read_config_word (bus, devfn, PCI_DEVICE_ID, &device);
595 pcibios_read_config_word (bus, devfn, PCI_STATUS, &status);
596 pcibios_read_config_byte (bus, devfn, PCI_BIST, &bist);
597 pcibios_read_config_byte (bus, devfn, PCI_LATENCY_TIMER, &latency);
598 pcibios_read_config_byte (bus, devfn, PCI_MIN_GNT, &min_gnt);
599 pcibios_read_config_byte (bus, devfn, PCI_MAX_LAT, &max_lat);
600 if (len + 80 > size) {
601 return -1;
602 }
603 len += sprintf(buf + len, " Bus %2d, device %3d, function %2d:\n",
604 bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
605
606 if (len + 80 > size) {
607 return -1;
608 }
609 len += sprintf(buf + len, " %s: %s %s (rev %d).\n ",
610 pci_strclass(class_rev >> 8), pci_strvendor(vendor),
611 pci_strdev(vendor, device), class_rev & 0xff);
612
613 if (!pci_lookup_dev(vendor, device)) {
614 len += sprintf(buf + len,
615 "Vendor id=%x. Device id=%x.\n ",
616 vendor, device);
617 }
618
619 str = 0;
620 switch (status & PCI_STATUS_DEVSEL_MASK) {
621 case PCI_STATUS_DEVSEL_FAST: str = "Fast devsel. "; break;
622 case PCI_STATUS_DEVSEL_MEDIUM: str = "Medium devsel. "; break;
623 case PCI_STATUS_DEVSEL_SLOW: str = "Slow devsel. "; break;
624 }
625 if (len + strlen(str) > size) {
626 return -1;
627 }
628 len += sprintf(buf + len, str);
629
630 if (status & PCI_STATUS_FAST_BACK) {
631 # define fast_b2b_capable "Fast back-to-back capable. "
632 if (len + strlen(fast_b2b_capable) > size) {
633 return -1;
634 }
635 len += sprintf(buf + len, fast_b2b_capable);
636 # undef fast_b2b_capable
637 }
638
639 if (bist & PCI_BIST_CAPABLE) {
640 # define BIST_capable "BIST capable. "
641 if (len + strlen(BIST_capable) > size) {
642 return -1;
643 }
644 len += sprintf(buf + len, BIST_capable);
645 # undef BIST_capable
646 }
647
648 if (dev->irq) {
649 if (len + 40 > size) {
650 return -1;
651 }
652 len += sprintf(buf + len, "IRQ %d. ", dev->irq);
653 }
654
655 if (dev->master) {
656 if (len + 80 > size) {
657 return -1;
658 }
659 len += sprintf(buf + len, "Master Capable. ");
660 if (latency)
661 len += sprintf(buf + len, "Latency=%d. ", latency);
662 else
663 len += sprintf(buf + len, "No bursts. ");
664 if (min_gnt)
665 len += sprintf(buf + len, "Min Gnt=%d.", min_gnt);
666 if (max_lat)
667 len += sprintf(buf + len, "Max Lat=%d.", max_lat);
668 }
669
670 for (reg = PCI_BASE_ADDRESS_0; reg <= PCI_BASE_ADDRESS_5; reg += 4) {
671 if (len + 40 > size) {
672 return -1;
673 }
674 pcibios_read_config_dword(bus, devfn, reg, &l);
675 base = l;
676 if (!base) {
677 continue;
678 }
679
680 if (base & PCI_BASE_ADDRESS_SPACE_IO) {
681 len += sprintf(buf + len,
682 "\n I/O at 0x%lx.",
683 base & PCI_BASE_ADDRESS_IO_MASK);
684 } else {
685 const char *pref, *type = "unknown";
686
687 if (base & PCI_BASE_ADDRESS_MEM_PREFETCH) {
688 pref = "P";
689 } else {
690 pref = "Non-p";
691 }
692 switch (base & PCI_BASE_ADDRESS_MEM_TYPE_MASK) {
693 case PCI_BASE_ADDRESS_MEM_TYPE_32:
694 type = "32 bit"; break;
695 case PCI_BASE_ADDRESS_MEM_TYPE_1M:
696 type = "20 bit"; break;
697 case PCI_BASE_ADDRESS_MEM_TYPE_64:
698 type = "64 bit";
699
700 reg += 4;
701 pcibios_read_config_dword(bus, devfn, reg, &l);
702 base |= ((u64) l) << 32;
703 break;
704 }
705 len += sprintf(buf + len,
706 "\n %srefetchable %s memory at "
707 "0x%lx.", pref, type,
708 base & PCI_BASE_ADDRESS_MEM_MASK);
709 }
710 }
711
712 len += sprintf(buf + len, "\n");
713 return len;
714 }
715
716
717
718
719
720
721 int get_pci_list(char *buf)
722 {
723 int nprinted, len, size;
724 struct pci_dev *dev;
725 # define MSG "\nwarning: page-size limit reached!\n"
726
727
728 size = PAGE_SIZE - (strlen(MSG) + 1);
729 len = sprintf(buf, "PCI devices found:\n");
730
731 for (dev = pci_devices; dev; dev = dev->next) {
732 nprinted = sprint_dev_config(dev, buf + len, size - len);
733 if (nprinted < 0) {
734 return len + sprintf(buf + len, MSG);
735 }
736 len += nprinted;
737 }
738 return len;
739 }
740
741
742
743
744
745
746 static void *pci_malloc(long size, unsigned long *mem_startp)
747 {
748 void *mem;
749
750 #ifdef DEBUG
751 printk("...pci_malloc(size=%ld,mem=%p)", size, *mem_startp);
752 #endif
753 mem = (void*) *mem_startp;
754 *mem_startp += (size + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
755 memset(mem, 0, size);
756 return mem;
757 }
758
759
760 static unsigned int scan_bus(struct pci_bus *bus, unsigned long *mem_startp)
761 {
762 unsigned int devfn, l, max;
763 unsigned char cmd, tmp, hdr_type = 0;
764 struct pci_dev_info *info;
765 struct pci_dev *dev;
766 struct pci_bus *child;
767
768 #ifdef DEBUG
769 printk("...scan_bus(busno=%d,mem=%p)\n", bus->number, *mem_startp);
770 #endif
771
772 max = bus->secondary;
773 for (devfn = 0; devfn < 0xff; ++devfn) {
774 if (PCI_FUNC(devfn) == 0) {
775 pcibios_read_config_byte(bus->number, devfn,
776 PCI_HEADER_TYPE, &hdr_type);
777 } else if (!(hdr_type & 0x80)) {
778
779 continue;
780 }
781
782 pcibios_read_config_dword(bus->number, devfn, PCI_VENDOR_ID,
783 &l);
784
785 if (l == 0xffffffff || l == 0x00000000) {
786 hdr_type = 0;
787 continue;
788 }
789
790 dev = pci_malloc(sizeof(*dev), mem_startp);
791 dev->bus = bus;
792
793
794
795
796
797 dev->next = pci_devices;
798 pci_devices = dev;
799
800 dev->devfn = devfn;
801 dev->vendor = l & 0xffff;
802 dev->device = (l >> 16) & 0xffff;
803
804
805
806
807
808
809 info = pci_lookup_dev(dev->vendor, dev->device);
810 if (!info) {
811 printk("Warning : Unknown PCI device (%x:%x). Please read include/linux/pci.h \n",
812 dev->vendor, dev->device);
813 } else {
814
815 if (info->bridge_type != 0xff) {
816 burst_bridge(bus->number, devfn,
817 info->bridge_type, 1);
818 }
819 }
820
821
822 pcibios_read_config_byte(bus->number, devfn, PCI_COMMAND,
823 &cmd);
824 pcibios_write_config_byte(bus->number, devfn, PCI_COMMAND,
825 cmd | PCI_COMMAND_MASTER);
826 pcibios_read_config_byte(bus->number, devfn, PCI_COMMAND,
827 &tmp);
828 dev->master = ((tmp & PCI_COMMAND_MASTER) != 0);
829 pcibios_write_config_byte(bus->number, devfn, PCI_COMMAND,
830 cmd);
831
832
833 pcibios_read_config_byte(bus->number, devfn,
834 PCI_INTERRUPT_LINE, &dev->irq);
835
836
837 pcibios_read_config_dword(bus->number, devfn,
838 PCI_CLASS_REVISION, &l);
839 l = l >> 8;
840 dev->class = l;
841
842
843
844
845 dev->sibling = bus->devices;
846 bus->devices = dev;
847
848 if (dev->class >> 8 == PCI_CLASS_BRIDGE_PCI) {
849 unsigned int buses;
850 unsigned short cr;
851
852
853
854
855 child = pci_malloc(sizeof(*child), mem_startp);
856 child->next = bus->children;
857 bus->children = child;
858 child->self = dev;
859 child->parent = bus;
860
861
862
863
864
865 child->number = child->secondary = ++max;
866 child->primary = bus->secondary;
867 child->subordinate = 0xff;
868
869
870
871
872 pcibios_read_config_word(bus->number, devfn,
873 PCI_COMMAND, &cr);
874 pcibios_write_config_word(bus->number, devfn,
875 PCI_COMMAND, 0x0000);
876 pcibios_write_config_word(bus->number, devfn,
877 PCI_STATUS, 0xffff);
878
879
880
881 pcibios_read_config_dword(bus->number, devfn, 0x18,
882 &buses);
883 buses &= 0xff000000;
884 buses |= (((unsigned int)(child->primary) << 0) |
885 ((unsigned int)(child->secondary) << 8) |
886 ((unsigned int)(child->subordinate) << 16));
887 pcibios_write_config_dword(bus->number, devfn, 0x18,
888 buses);
889
890
891
892 max = scan_bus(child, mem_startp);
893
894
895
896
897 child->subordinate = max;
898 buses = (buses & 0xff00ffff)
899 | ((unsigned int)(child->subordinate) << 16);
900 pcibios_write_config_dword(bus->number, devfn, 0x18,
901 buses);
902 pcibios_write_config_word(bus->number, devfn,
903 PCI_COMMAND, cr);
904 }
905 }
906
907
908
909
910
911
912
913 return max;
914 }
915
916
917 unsigned long pci_init (unsigned long mem_start, unsigned long mem_end)
918 {
919 mem_start = pcibios_init(mem_start, mem_end);
920
921 if (!pcibios_present()) {
922 printk("pci_init: no BIOS32 detected\n");
923 return mem_start;
924 }
925
926 printk("Probing PCI hardware.\n");
927
928 memset(&pci_root, 0, sizeof(pci_root));
929 pci_root.subordinate = scan_bus(&pci_root, &mem_start);
930
931
932 mem_start = pcibios_fixup(mem_start, mem_end);
933
934 #ifdef DEBUG
935 {
936 int len = get_pci_list((char*)mem_start);
937 if (len) {
938 ((char *) mem_start)[len] = '\0';
939 printk("%s\n", (char *) mem_start);
940 }
941 }
942 #endif
943 return mem_start;
944 }