[SPARC64]: Probe PCI bus using OF device tree.
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / sparc64 / kernel / pci_common.c
blob0d3c95df0d95ba2392b17cfc0f6c90032f52f29b
1 /* $Id: pci_common.c,v 1.29 2002/02/01 00:56:03 davem Exp $
2 * pci_common.c: PCI controller common support.
4 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
5 */
7 #include <linux/string.h>
8 #include <linux/slab.h>
9 #include <linux/init.h>
10 #include <linux/pci.h>
11 #include <linux/device.h>
13 #include <asm/pbm.h>
14 #include <asm/prom.h>
15 #include <asm/of_device.h>
17 #include "pci_impl.h"
19 void pci_register_legacy_regions(struct resource *io_res,
20 struct resource *mem_res)
22 struct resource *p;
24 /* VGA Video RAM. */
25 p = kzalloc(sizeof(*p), GFP_KERNEL);
26 if (!p)
27 return;
29 p->name = "Video RAM area";
30 p->start = mem_res->start + 0xa0000UL;
31 p->end = p->start + 0x1ffffUL;
32 p->flags = IORESOURCE_BUSY;
33 request_resource(mem_res, p);
35 p = kzalloc(sizeof(*p), GFP_KERNEL);
36 if (!p)
37 return;
39 p->name = "System ROM";
40 p->start = mem_res->start + 0xf0000UL;
41 p->end = p->start + 0xffffUL;
42 p->flags = IORESOURCE_BUSY;
43 request_resource(mem_res, p);
45 p = kzalloc(sizeof(*p), GFP_KERNEL);
46 if (!p)
47 return;
49 p->name = "Video ROM";
50 p->start = mem_res->start + 0xc0000UL;
51 p->end = p->start + 0x7fffUL;
52 p->flags = IORESOURCE_BUSY;
53 request_resource(mem_res, p);
56 /* Generic helper routines for PCI error reporting. */
57 void pci_scan_for_target_abort(struct pci_controller_info *p,
58 struct pci_pbm_info *pbm,
59 struct pci_bus *pbus)
61 struct pci_dev *pdev;
62 struct pci_bus *bus;
64 list_for_each_entry(pdev, &pbus->devices, bus_list) {
65 u16 status, error_bits;
67 pci_read_config_word(pdev, PCI_STATUS, &status);
68 error_bits =
69 (status & (PCI_STATUS_SIG_TARGET_ABORT |
70 PCI_STATUS_REC_TARGET_ABORT));
71 if (error_bits) {
72 pci_write_config_word(pdev, PCI_STATUS, error_bits);
73 printk("PCI%d(PBM%c): Device [%s] saw Target Abort [%016x]\n",
74 p->index, ((pbm == &p->pbm_A) ? 'A' : 'B'),
75 pci_name(pdev), status);
79 list_for_each_entry(bus, &pbus->children, node)
80 pci_scan_for_target_abort(p, pbm, bus);
83 void pci_scan_for_master_abort(struct pci_controller_info *p,
84 struct pci_pbm_info *pbm,
85 struct pci_bus *pbus)
87 struct pci_dev *pdev;
88 struct pci_bus *bus;
90 list_for_each_entry(pdev, &pbus->devices, bus_list) {
91 u16 status, error_bits;
93 pci_read_config_word(pdev, PCI_STATUS, &status);
94 error_bits =
95 (status & (PCI_STATUS_REC_MASTER_ABORT));
96 if (error_bits) {
97 pci_write_config_word(pdev, PCI_STATUS, error_bits);
98 printk("PCI%d(PBM%c): Device [%s] received Master Abort [%016x]\n",
99 p->index, ((pbm == &p->pbm_A) ? 'A' : 'B'),
100 pci_name(pdev), status);
104 list_for_each_entry(bus, &pbus->children, node)
105 pci_scan_for_master_abort(p, pbm, bus);
108 void pci_scan_for_parity_error(struct pci_controller_info *p,
109 struct pci_pbm_info *pbm,
110 struct pci_bus *pbus)
112 struct pci_dev *pdev;
113 struct pci_bus *bus;
115 list_for_each_entry(pdev, &pbus->devices, bus_list) {
116 u16 status, error_bits;
118 pci_read_config_word(pdev, PCI_STATUS, &status);
119 error_bits =
120 (status & (PCI_STATUS_PARITY |
121 PCI_STATUS_DETECTED_PARITY));
122 if (error_bits) {
123 pci_write_config_word(pdev, PCI_STATUS, error_bits);
124 printk("PCI%d(PBM%c): Device [%s] saw Parity Error [%016x]\n",
125 p->index, ((pbm == &p->pbm_A) ? 'A' : 'B'),
126 pci_name(pdev), status);
130 list_for_each_entry(bus, &pbus->children, node)
131 pci_scan_for_parity_error(p, pbm, bus);