[SPARC64]: Fix sabre pci controllers with new probing scheme.
[deliverable/linux.git] / arch / sparc64 / kernel / pci_common.c
CommitLineData
1da177e4
LT
1/* $Id: pci_common.c,v 1.29 2002/02/01 00:56:03 davem Exp $
2 * pci_common.c: PCI controller common support.
3 *
4 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
5 */
6
7#include <linux/string.h>
8#include <linux/slab.h>
9#include <linux/init.h>
cf69eab2
FMDN
10#include <linux/pci.h>
11#include <linux/device.h>
1da177e4
LT
12
13#include <asm/pbm.h>
de8d28b1 14#include <asm/prom.h>
2b1e5978 15#include <asm/of_device.h>
de8d28b1
DM
16
17#include "pci_impl.h"
1da177e4 18
1da177e4
LT
19void pci_register_legacy_regions(struct resource *io_res,
20 struct resource *mem_res)
21{
22 struct resource *p;
23
24 /* VGA Video RAM. */
9132983a 25 p = kzalloc(sizeof(*p), GFP_KERNEL);
1da177e4
LT
26 if (!p)
27 return;
28
1da177e4
LT
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);
34
9132983a 35 p = kzalloc(sizeof(*p), GFP_KERNEL);
1da177e4
LT
36 if (!p)
37 return;
38
1da177e4
LT
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);
44
9132983a 45 p = kzalloc(sizeof(*p), GFP_KERNEL);
1da177e4
LT
46 if (!p)
47 return;
48
1da177e4
LT
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);
54}
55
56/* Generic helper routines for PCI error reporting. */
57void pci_scan_for_target_abort(struct pci_controller_info *p,
58 struct pci_pbm_info *pbm,
59 struct pci_bus *pbus)
60{
61 struct pci_dev *pdev;
62 struct pci_bus *bus;
63
64 list_for_each_entry(pdev, &pbus->devices, bus_list) {
65 u16 status, error_bits;
66
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);
76 }
77 }
78
79 list_for_each_entry(bus, &pbus->children, node)
80 pci_scan_for_target_abort(p, pbm, bus);
81}
82
83void pci_scan_for_master_abort(struct pci_controller_info *p,
84 struct pci_pbm_info *pbm,
85 struct pci_bus *pbus)
86{
87 struct pci_dev *pdev;
88 struct pci_bus *bus;
89
90 list_for_each_entry(pdev, &pbus->devices, bus_list) {
91 u16 status, error_bits;
92
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);
101 }
102 }
103
104 list_for_each_entry(bus, &pbus->children, node)
105 pci_scan_for_master_abort(p, pbm, bus);
106}
107
108void pci_scan_for_parity_error(struct pci_controller_info *p,
109 struct pci_pbm_info *pbm,
110 struct pci_bus *pbus)
111{
112 struct pci_dev *pdev;
113 struct pci_bus *bus;
114
115 list_for_each_entry(pdev, &pbus->devices, bus_list) {
116 u16 status, error_bits;
117
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);
127 }
128 }
129
130 list_for_each_entry(bus, &pbus->children, node)
131 pci_scan_for_parity_error(p, pbm, bus);
132}
This page took 0.193118 seconds and 5 git commands to generate.