[PATCH] ppc64: Split out generic rtas code from pSeries_pci.c.
[linux-2.6/sactl.git] / arch / ppc64 / kernel / pSeries_pci.c
blobdfa6d3d3e9f0e62ddf93d9c61a08bac9259a8870
1 /*
2 * arch/ppc64/kernel/pSeries_pci.c
4 * Copyright (C) 2001 Dave Engebretsen, IBM Corporation
5 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
7 * pSeries specific routines for PCI.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <linux/init.h>
25 #include <linux/ioport.h>
26 #include <linux/kernel.h>
27 #include <linux/pci.h>
28 #include <linux/string.h>
30 #include <asm/pci-bridge.h>
31 #include <asm/prom.h>
33 #include "pci.h"
35 static int __initdata s7a_workaround;
37 #if 0
38 void pcibios_name_device(struct pci_dev *dev)
40 struct device_node *dn;
43 * Add IBM loc code (slot) as a prefix to the device names for service
45 dn = pci_device_to_OF_node(dev);
46 if (dn) {
47 char *loc_code = get_property(dn, "ibm,loc-code", 0);
48 if (loc_code) {
49 int loc_len = strlen(loc_code);
50 if (loc_len < sizeof(dev->dev.name)) {
51 memmove(dev->dev.name+loc_len+1, dev->dev.name,
52 sizeof(dev->dev.name)-loc_len-1);
53 memcpy(dev->dev.name, loc_code, loc_len);
54 dev->dev.name[loc_len] = ' ';
55 dev->dev.name[sizeof(dev->dev.name)-1] = '\0';
60 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_name_device);
61 #endif
63 static void __init check_s7a(void)
65 struct device_node *root;
66 char *model;
68 root = of_find_node_by_path("/");
69 if (root) {
70 model = get_property(root, "model", NULL);
71 if (model && !strcmp(model, "IBM,7013-S7A"))
72 s7a_workaround = 1;
73 of_node_put(root);
77 static void __init pSeries_request_regions(void)
79 if (!isa_io_base)
80 return;
82 request_region(0x20,0x20,"pic1");
83 request_region(0xa0,0x20,"pic2");
84 request_region(0x00,0x20,"dma1");
85 request_region(0x40,0x20,"timer");
86 request_region(0x80,0x10,"dma page reg");
87 request_region(0xc0,0x20,"dma2");
90 void __init pSeries_final_fixup(void)
92 struct pci_dev *dev = NULL;
94 check_s7a();
96 for_each_pci_dev(dev) {
97 pci_read_irq_line(dev);
98 if (s7a_workaround) {
99 if (dev->irq > 16) {
100 dev->irq -= 3;
101 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
106 phbs_remap_io();
107 pSeries_request_regions();
109 pci_addr_cache_build();
113 * Assume the winbond 82c105 is the IDE controller on a
114 * p610. We should probably be more careful in case
115 * someone tries to plug in a similar adapter.
117 static void fixup_winbond_82c105(struct pci_dev* dev)
119 int i;
120 unsigned int reg;
122 if (!(systemcfg->platform & PLATFORM_PSERIES))
123 return;
125 printk("Using INTC for W82c105 IDE controller.\n");
126 pci_read_config_dword(dev, 0x40, &reg);
127 /* Enable LEGIRQ to use INTC instead of ISA interrupts */
128 pci_write_config_dword(dev, 0x40, reg | (1<<11));
130 for (i = 0; i < DEVICE_COUNT_RESOURCE; ++i) {
131 /* zap the 2nd function of the winbond chip */
132 if (dev->resource[i].flags & IORESOURCE_IO
133 && dev->bus->number == 0 && dev->devfn == 0x81)
134 dev->resource[i].flags &= ~IORESOURCE_IO;
137 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
138 fixup_winbond_82c105);