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)
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>
15 #include <asm/of_device.h>
19 void pci_register_legacy_regions(struct resource *io_res,
20 struct resource *mem_res)
25 p = kzalloc(sizeof(*p), GFP_KERNEL);
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);
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);
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,
64 list_for_each_entry(pdev, &pbus->devices, bus_list) {
65 u16 status, error_bits;
67 pci_read_config_word(pdev, PCI_STATUS, &status);
69 (status & (PCI_STATUS_SIG_TARGET_ABORT |
70 PCI_STATUS_REC_TARGET_ABORT));
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,
90 list_for_each_entry(pdev, &pbus->devices, bus_list) {
91 u16 status, error_bits;
93 pci_read_config_word(pdev, PCI_STATUS, &status);
95 (status & (PCI_STATUS_REC_MASTER_ABORT));
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;
115 list_for_each_entry(pdev, &pbus->devices, bus_list) {
116 u16 status, error_bits;
118 pci_read_config_word(pdev, PCI_STATUS, &status);
120 (status & (PCI_STATUS_PARITY |
121 PCI_STATUS_DETECTED_PARITY));
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);