4 * Copyright (C) 2001 Dave Engebretsen, IBM Corporation
6 * pSeries specific routines for PCI.
8 * Based on code from pci.c and chrp_pci.c
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <linux/kernel.h>
26 #include <linux/pci.h>
27 #include <linux/delay.h>
28 #include <linux/string.h>
29 #include <linux/init.h>
30 #include <linux/bootmem.h>
33 #include <asm/pgtable.h>
36 #include <asm/machdep.h>
38 #include <asm/pci-bridge.h>
39 #include <asm/ppcdebug.h>
41 #include <asm/pci_dma.h>
47 extern struct device_node *allnodes;
49 /*******************************************************************
50 * Forward declares of prototypes.
51 *******************************************************************/
52 unsigned long find_and_init_phbs(void);
53 struct pci_controller* alloc_phb(struct device_node *dev, char *model, unsigned int addr_size_words) ;
54 void pSeries_pcibios_fixup(void);
55 static int rtas_fake_read(struct device_node *dn, int offset, int nbytes, unsigned long *returnval);
58 static int read_pci_config;
59 static int write_pci_config;
60 static int ibm_read_pci_config;
61 static int ibm_write_pci_config;
63 static int s7a_workaround;
65 /******************************************************************************
67 * pSeries I/O Operations to access the PCI configuration space.
69 *****************************************************************************/
70 #define RTAS_PCI_READ_OP(size, type, nbytes) \
72 rtas_read_config_##size(struct device_node *dn, int offset, type val) { \
73 unsigned long returnval = ~0L; \
80 } else if (dn->status) { \
83 addr = (dn->busno << 16) | (dn->devfn << 8) | offset; \
84 buid = dn->phb->buid; \
86 ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval, addr, buid >> 32, buid & 0xffffffff, nbytes); \
87 if (ret < 0 || (returnval == 0xffffffff)) \
88 ret = rtas_fake_read(dn, offset, nbytes, &returnval); \
90 ret = rtas_call(read_pci_config, 2, 2, &returnval, addr, nbytes); \
97 rtas_pci_read_config_##size(struct pci_dev *dev, int offset, type val) { \
98 struct device_node *dn = pci_device_to_OF_node(dev); \
99 int ret = rtas_read_config_##size(dn, offset, val); \
100 /* udbg_printf("read bus=%x, devfn=%x, ret=%d phb=%lx, dn=%lx\n", dev->bus->number, dev->devfn, ret, dn ? dn->phb : 0, dn); */ \
101 return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; \
104 #define RTAS_PCI_WRITE_OP(size, type, nbytes) \
106 rtas_write_config_##size(struct device_node *dn, int offset, type val) { \
107 unsigned long buid; \
113 } else if (dn->status) { \
116 buid = dn->phb->buid; \
117 addr = (dn->busno << 16) | (dn->devfn << 8) | offset; \
119 ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr, buid >> 32, buid & 0xffffffff, nbytes, (ulong) val); \
121 ret = rtas_call(write_pci_config, 3, 1, NULL, addr, nbytes, (ulong)val); \
127 rtas_pci_write_config_##size(struct pci_dev *dev, int offset, type val) { \
128 struct device_node* dn = pci_device_to_OF_node(dev); \
129 int ret = rtas_write_config_##size(dn, offset, val); \
130 /* udbg_printf("write bus=%x, devfn=%x, ret=%d phb=%lx, dn=%lx\n", dev->bus->number, dev->devfn, ret, dn ? dn->phb : 0, dn); */ \
131 return ret ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; \
134 RTAS_PCI_READ_OP(byte, u8 *, 1)
135 RTAS_PCI_READ_OP(word, u16 *, 2)
136 RTAS_PCI_READ_OP(dword, u32 *, 4)
137 RTAS_PCI_WRITE_OP(byte, u8, 1)
138 RTAS_PCI_WRITE_OP(word, u16, 2)
139 RTAS_PCI_WRITE_OP(dword, u32, 4)
141 struct pci_ops rtas_pci_ops = {
142 rtas_pci_read_config_byte,
143 rtas_pci_read_config_word,
144 rtas_pci_read_config_dword,
145 rtas_pci_write_config_byte,
146 rtas_pci_write_config_word,
147 rtas_pci_write_config_dword,
151 * Handle the case where rtas refuses to do a pci config read.
152 * This currently only happens with some PHBs in which case we totally fake
153 * out the values (and call it a speedwagaon -- something we could look up
154 * in the device tree).
157 rtas_fake_read(struct device_node *dn, int offset, int nbytes, unsigned long *returnval)
159 char *device_type = (char *)get_property(dn, "device_type", 0);
160 u32 *class_code = (u32 *)get_property(dn, "class-code", 0);
162 *returnval = ~0; /* float by default */
164 /* udbg_printf("rtas_fake_read dn=%p, offset=0x%02x, nbytes=%d, device_type=%s\n", dn, offset, nbytes, device_type ? device_type : "<none>"); */
165 if (device_type && strcmp(device_type, "pci") != 0)
166 return -3; /* Not a phb or bridge */
168 /* NOTE: class_code != NULL => EADS pci bridge. Else a PHB */
170 if (offset == PCI_HEADER_TYPE)
171 *returnval = 0x80; /* multifunction */
172 else if (offset == PCI_INTERRUPT_PIN || offset == PCI_INTERRUPT_LINE)
174 } else if (nbytes == 2) {
175 if (offset == PCI_SUBSYSTEM_VENDOR_ID || offset == PCI_SUBSYSTEM_ID)
177 else if (offset == PCI_COMMAND)
178 *returnval = PCI_COMMAND_PARITY|PCI_COMMAND_MASTER|PCI_COMMAND_MEMORY;
179 } else if (nbytes == 4) {
180 if (offset == PCI_VENDOR_ID)
181 *returnval = 0x1014 | ((class_code ? 0x8b : 0x102) << 16); /* a phb */
182 else if (offset == PCI_REVISION_ID)
183 *returnval = (class_code ? PCI_CLASS_BRIDGE_PCI : PCI_CLASS_BRIDGE_HOST) << 16; /* revs are zero */
184 else if ((offset >= PCI_BASE_ADDRESS_0 && offset <= PCI_BASE_ADDRESS_5) || offset == PCI_ROM_ADDRESS)
188 /* printk("fake: %s nbytes=%d, offset=%lx ret=%lx\n", class_code ? "EADS" : "PHB", nbytes, offset, *returnval); */
192 /******************************************************************
195 * Reads the Interrupt Pin to determine if interrupt is use by card.
196 * If the interrupt is used, then gets the interrupt line from the
197 * openfirmware and sets it in the pci_dev and pci_config line.
199 ******************************************************************/
201 pci_read_irq_line(struct pci_dev *Pci_Dev)
204 struct device_node *Node;
206 pci_read_config_byte(Pci_Dev, PCI_INTERRUPT_PIN, &InterruptPin);
207 if (InterruptPin == 0) {
208 PPCDBG(PPCDBG_BUSWALK,"\tDevice: %s No Interrupt used by device.\n",Pci_Dev->slot_name);
211 Node = pci_device_to_OF_node(Pci_Dev);
213 PPCDBG(PPCDBG_BUSWALK,"\tDevice: %s Device Node not found.\n",Pci_Dev->slot_name);
216 if (Node->n_intrs == 0) {
217 PPCDBG(PPCDBG_BUSWALK,"\tDevice: %s No Device OF interrupts defined.\n",Pci_Dev->slot_name);
220 Pci_Dev->irq = Node->intrs[0].line;
222 if (s7a_workaround) {
223 if (Pci_Dev->irq > 16)
227 pci_write_config_byte(Pci_Dev, PCI_INTERRUPT_LINE, Pci_Dev->irq);
229 PPCDBG(PPCDBG_BUSWALK,"\tDevice: %s pci_dev->irq = 0x%02X\n",Pci_Dev->slot_name,Pci_Dev->irq);
233 /******************************************************************
234 * Find all PHBs in the system and initialize a set of data
235 * structures to represent them.
236 ******************************************************************/
238 find_and_init_phbs(void)
240 struct device_node *Pci_Node;
241 struct pci_controller *phb;
242 unsigned int root_addr_size_words = 0, this_addr_size_words = 0;
243 unsigned int this_addr_count = 0, range_stride;
244 unsigned int *ui_ptr = NULL, *ranges;
246 struct pci_range64 range;
247 struct resource *res;
248 unsigned int memno, rlen, i, index;
249 unsigned int *opprop;
251 PPCDBG(PPCDBG_PHBINIT, "find_and_init_phbs\n");
253 read_pci_config = rtas_token("read-pci-config");
254 write_pci_config = rtas_token("write-pci-config");
255 ibm_read_pci_config = rtas_token("ibm,read-pci-config");
256 ibm_write_pci_config = rtas_token("ibm,write-pci-config");
258 if (naca->interrupt_controller == IC_OPEN_PIC) {
259 opprop = (unsigned int *)get_property(find_path_device("/"),
260 "platform-open-pic", NULL);
263 /* Get the root address word size. */
264 ui_ptr = (unsigned int *) get_property(find_path_device("/"),
265 "#size-cells", NULL);
267 root_addr_size_words = *ui_ptr;
269 PPCDBG(PPCDBG_PHBINIT, "\tget #size-cells failed.\n");
273 if (find_type_devices("isa")) {
275 PPCDBG(PPCDBG_PHBINIT, "\tFound an ISA bus.\n");
280 /******************************************************************
281 * Find all PHB devices and create an object for them.
282 ******************************************************************/
283 for (Pci_Node = find_devices("pci"); Pci_Node != NULL; Pci_Node = Pci_Node->next) {
284 model = (char *) get_property(Pci_Node, "model", NULL);
286 phb = alloc_phb(Pci_Node, model, root_addr_size_words);
287 if (phb == NULL) return(-1);
293 /* Get this node's address word size. */
294 ui_ptr = (unsigned int *) get_property(Pci_Node, "#size-cells", NULL);
296 this_addr_size_words = *ui_ptr;
298 this_addr_size_words = 1;
299 /* Get this node's address word count. */
300 ui_ptr = (unsigned int *) get_property(Pci_Node, "#address-cells", NULL);
302 this_addr_count = *ui_ptr;
306 range_stride = this_addr_count + root_addr_size_words + this_addr_size_words;
309 phb->io_base_phys = 0;
311 ranges = (unsigned int *) get_property(Pci_Node, "ranges", &rlen);
312 PPCDBG(PPCDBG_PHBINIT, "\trange_stride = 0x%lx, rlen = 0x%x\n", range_stride, rlen);
314 for (i = 0; i < (rlen/sizeof(*ranges)); i+=range_stride) {
315 /* Put the PCI addr part of the current element into a
318 range = *((struct pci_range64 *)(ranges + i));
320 /* If this is a '32' element, map into a 64 struct. */
321 if ((range_stride * sizeof(int)) ==
322 sizeof(struct pci_range32)) {
324 (unsigned long)(*(ranges + i + 3));
326 (((unsigned long)(*(ranges + i + 4)))<<32) |
330 (((unsigned long)(*(ranges + i + 3)))<<32) |
333 (((unsigned long)(*(ranges + i + 5)))<<32) |
337 PPCDBG(PPCDBG_PHBINIT, "\trange.parent_addr = 0x%lx\n",
339 PPCDBG(PPCDBG_PHBINIT, "\trange.child_addr.hi = 0x%lx\n",
340 range.child_addr.a_hi);
341 PPCDBG(PPCDBG_PHBINIT, "\trange.child_addr.mid = 0x%lx\n",
342 range.child_addr.a_mid);
343 PPCDBG(PPCDBG_PHBINIT, "\trange.child_addr.lo = 0x%lx\n",
344 range.child_addr.a_lo);
345 PPCDBG(PPCDBG_PHBINIT, "\trange.size = 0x%lx\n",
349 switch ((range.child_addr.a_hi >> 24) & 0x3) {
350 case 1: /* I/O space */
351 PPCDBG(PPCDBG_PHBINIT, "\tIO Space\n");
352 phb->io_base_phys = range.parent_addr;
353 res = &phb->io_resource;
354 res->name = Pci_Node->full_name;
355 res->flags = IORESOURCE_IO;
356 phb->io_base_virt = __ioremap(phb->io_base_phys, range.size, _PAGE_NO_CACHE);
358 pci_io_base = (unsigned long)phb->io_base_virt;
360 isa_io_base = pci_io_base;
362 res->start = ((((unsigned long) range.child_addr.a_mid) << 32) | (range.child_addr.a_lo));
363 res->start += (unsigned long)phb->io_base_virt - pci_io_base;
364 res->end = res->start + range.size - 1;
368 phb->pci_io_offset = range.parent_addr -
370 range.child_addr.a_mid) << 32) |
371 (range.child_addr.a_lo));
372 PPCDBG(PPCDBG_PHBINIT, "\tpci_io_offset = 0x%lx\n",
375 case 2: /* mem space */
376 PPCDBG(PPCDBG_PHBINIT, "\tMem Space\n");
377 phb->pci_mem_offset = range.parent_addr -
379 range.child_addr.a_mid) << 32) |
380 (range.child_addr.a_lo));
381 PPCDBG(PPCDBG_PHBINIT, "\tpci_mem_offset = 0x%lx\n",
382 phb->pci_mem_offset);
383 if (memno < sizeof(phb->mem_resources)/sizeof(phb->mem_resources[0])) {
384 res = &(phb->mem_resources[memno]);
386 res->name = Pci_Node->full_name;
387 res->flags = IORESOURCE_MEM;
388 res->start = range.parent_addr;
389 res->end = range.parent_addr + range.size - 1;
397 PPCDBG(PPCDBG_PHBINIT, "\tphb->io_base_phys = 0x%lx\n",
399 PPCDBG(PPCDBG_PHBINIT, "\tphb->pci_mem_offset = 0x%lx\n",
400 phb->pci_mem_offset);
402 if (naca->interrupt_controller == IC_OPEN_PIC) {
403 int addr = root_addr_size_words * (index + 2) - 1;
404 openpic_setup_ISU(index, opprop[addr]);
409 return 0; /*Success */
412 /******************************************************************
414 * Allocate and partially initialize a structure to represent a PHB.
416 ******************************************************************/
417 struct pci_controller *
418 alloc_phb(struct device_node *dev, char *model, unsigned int addr_size_words)
420 struct pci_controller *phb;
421 unsigned int *ui_ptr = NULL, len;
422 struct reg_property64 reg_struct;
423 struct property *of_prop;
427 PPCDBG(PPCDBG_PHBINIT, "alloc_phb: %s\n", dev->full_name);
428 PPCDBG(PPCDBG_PHBINIT, "\tdev = 0x%lx\n", dev);
429 PPCDBG(PPCDBG_PHBINIT, "\tmodel = 0x%lx\n", model);
430 PPCDBG(PPCDBG_PHBINIT, "\taddr_size_words = 0x%lx\n", addr_size_words);
432 /* Found a PHB, now figure out where his registers are mapped. */
433 ui_ptr = (unsigned int *) get_property(dev, "reg", &len);
434 if (ui_ptr == NULL) {
435 PPCDBG(PPCDBG_PHBINIT, "\tget reg failed.\n");
439 if (addr_size_words == 1) {
440 reg_struct.address = ((struct reg_property32 *)ui_ptr)->address;
441 reg_struct.size = ((struct reg_property32 *)ui_ptr)->size;
443 reg_struct = *((struct reg_property64 *)ui_ptr);
446 PPCDBG(PPCDBG_PHBINIT, "\treg_struct.address = 0x%lx\n", reg_struct.address);
447 PPCDBG(PPCDBG_PHBINIT, "\treg_struct.size = 0x%lx\n", reg_struct.size);
449 /***************************************************************
450 * Set chip specific data in the phb, including types &
452 ***************************************************************/
454 /****************************************************************
456 ***************************************************************/
457 if (strstr(model, "Python")) {
458 PPCDBG(PPCDBG_PHBINIT, "\tCreate python\n");
459 phb = pci_alloc_pci_controller("PHB PY",phb_type_python);
460 if (phb == NULL) return NULL;
462 phb->cfg_addr = (volatile unsigned long *)
463 ioremap(reg_struct.address + 0xf8000, PAGE_SIZE);
464 PPCDBG(PPCDBG_PHBINIT, "\tcfg_addr_r = 0x%lx\n",
465 reg_struct.address + 0xf8000);
466 PPCDBG(PPCDBG_PHBINIT, "\tcfg_addr_v = 0x%lx\n",
468 phb->cfg_data = (char*)(phb->cfg_addr + 0x02);
469 phb->phb_regs = (volatile unsigned long *)
470 ioremap(reg_struct.address + 0xf7000, PAGE_SIZE);
471 /* Python's register file is 1 MB in size. */
472 phb->chip_regs = ioremap(reg_struct.address & ~(0xfffffUL),
476 * Firmware doesn't always clear this bit which is critical
477 * for good performance - Anton
480 volatile u32 *tmp, i;
482 #define PRG_CL_RESET_VALID 0x00010000
484 tmp = (u32 *)((unsigned long)phb->chip_regs + 0xf6030);
486 if (*tmp & PRG_CL_RESET_VALID) {
487 printk("Python workaround: ");
488 *tmp &= ~PRG_CL_RESET_VALID;
490 * We must read it back for changes to
494 printk("reg0: %x\n", i);
498 /***************************************************************
500 * include Winnipeg as well for the time being.
501 ***************************************************************/
502 } else if ((strstr(model, "Speedwagon")) ||
503 (strstr(model, "Winnipeg"))) {
504 PPCDBG(PPCDBG_PHBINIT, "\tCreate speedwagon\n");
505 phb = pci_alloc_pci_controller("PHB SW",phb_type_speedwagon);
506 if (phb == NULL) return NULL;
508 if (systemcfg->platform == PLATFORM_PSERIES) {
509 phb->cfg_addr = (volatile unsigned long *)
510 ioremap(reg_struct.address + 0x140, PAGE_SIZE);
511 phb->cfg_data = (char*)(phb->cfg_addr - 0x02); /* minus is correct */
512 phb->phb_regs = (volatile unsigned long *)
513 ioremap(reg_struct.address, PAGE_SIZE);
514 /* Speedwagon's register file is 1 MB in size. */
515 phb->chip_regs = ioremap(reg_struct.address & ~(0xfffffUL),
517 PPCDBG(PPCDBG_PHBINIT, "\tmapping chip_regs from 0x%lx -> 0x%lx\n",
518 reg_struct.address & 0xfffff, phb->chip_regs);
520 phb->cfg_addr = NULL;
521 phb->cfg_data = NULL;
522 phb->phb_regs = NULL;
523 phb->chip_regs = NULL;
526 phb->local_number = ((reg_struct.address >> 12) & 0xf) - 0x8;
527 /***************************************************************
528 * Trying to build a known just gets the code in trouble.
529 ***************************************************************/
531 PPCDBG(PPCDBG_PHBINIT, "\tUnknown PHB Type!\n");
532 printk("PCI: Unknown Phb Type!\n");
536 /* Add a linux,phbnum property to the device tree so user code
537 * can translate bus numbers.
539 of_prop = (struct property *) alloc_bootmem(sizeof(struct property) +
540 sizeof(phb->global_number));
542 memset(of_prop, 0, sizeof(struct property));
543 of_prop->name = "linux,phbnum";
544 of_prop->length = sizeof(phb->global_number);
545 of_prop->value = (unsigned char *)&of_prop[1];
546 memcpy(of_prop->value, &phb->global_number,
547 sizeof(phb->global_number));
548 prom_add_property(dev, of_prop);
551 bus_range = (int *) get_property(dev, "bus-range", &len);
552 if (bus_range == NULL || len < 2 * sizeof(int)) {
553 PPCDBG(PPCDBG_PHBINIT, "Can't get bus-range for %s\n", dev->full_name);
558 /***************************************************************
559 * Finished with the initialization
560 ***************************************************************/
561 phb->first_busno = bus_range[0];
562 phb->last_busno = bus_range[1];
564 phb->arch_data = dev;
565 phb->ops = &rtas_pci_ops;
567 buid_vals = (int *) get_property(dev, "ibm,fw-phb-id", &len);
569 if (buid_vals == NULL) {
573 struct pci_bus check;
574 if (sizeof(check.number) == 1 || sizeof(check.primary) == 1 ||
575 sizeof(check.secondary) == 1 || sizeof(check.subordinate) == 1) {
576 udbg_printf("pSeries_pci: this system has large bus numbers and the kernel was not\n"
577 "built with the patch that fixes include/linux/pci.h struct pci_bus so\n"
578 "number, primary, secondary and subordinate are ints.\n");
579 panic("pSeries_pci: this system has large bus numbers and the kernel was not\n"
580 "built with the patch that fixes include/linux/pci.h struct pci_bus so\n"
581 "number, primary, secondary and subordinate are ints.\n");
584 if (len < 2 * sizeof(int))
585 phb->buid = (unsigned long)buid_vals[0]; // Support for new OF that only has 1 integer for buid.
587 phb->buid = (((unsigned long)buid_vals[0]) << 32UL) |
588 (((unsigned long)buid_vals[1]) & 0xffffffff);
590 phb->first_busno += (phb->global_number << 8);
591 phb->last_busno += (phb->global_number << 8);
594 /* Dump PHB information for Debug */
595 PPCDBGCALL(PPCDBG_PHBINIT,dumpPci_Controller(phb) );
601 fixup_resources(struct pci_dev *dev)
604 struct pci_controller *phb = PCI_GET_PHB_PTR(dev);
605 struct device_node *dn;
607 /* Add IBM loc code (slot) as a prefix to the device names for service */
608 dn = pci_device_to_OF_node(dev);
610 char *loc_code = get_property(dn, "ibm,loc-code", 0);
612 int loc_len = strlen(loc_code);
613 if (loc_len < sizeof(dev->name)) {
614 memmove(dev->name+loc_len+1, dev->name, sizeof(dev->name)-loc_len-1);
615 memcpy(dev->name, loc_code, loc_len);
616 dev->name[loc_len] = ' ';
617 dev->name[sizeof(dev->name)-1] = '\0';
622 PPCDBG(PPCDBG_PHBINIT, "fixup_resources:\n");
623 PPCDBG(PPCDBG_PHBINIT, "\tphb = 0x%016LX\n", phb);
624 PPCDBG(PPCDBG_PHBINIT, "\tphb->pci_io_offset = 0x%016LX\n", phb->pci_io_offset);
625 PPCDBG(PPCDBG_PHBINIT, "\tphb->pci_mem_offset = 0x%016LX\n", phb->pci_mem_offset);
627 PPCDBG(PPCDBG_PHBINIT, "\tdev->name = %s\n", dev->name);
628 PPCDBG(PPCDBG_PHBINIT, "\tdev->vendor:device = 0x%04X : 0x%04X\n", dev->vendor, dev->device);
633 for (i = 0; i < DEVICE_COUNT_RESOURCE; ++i) {
634 PPCDBG(PPCDBG_PHBINIT, "\tdevice %x.%x[%d] (flags %x) [%lx..%lx]\n",
635 dev->bus->number, dev->devfn, i,
636 dev->resource[i].flags,
637 dev->resource[i].start,
638 dev->resource[i].end);
640 if ((dev->resource[i].start == 0) && (dev->resource[i].end == 0)) {
644 if (dev->resource[i].start > dev->resource[i].end) {
645 /* Bogus resource. Just clear it out. */
646 dev->resource[i].start = dev->resource[i].end = 0;
651 if (dev->resource[i].flags & IORESOURCE_IO) {
652 unsigned long offset = (unsigned long)phb->io_base_virt - pci_io_base;
653 dev->resource[i].start += offset;
654 dev->resource[i].end += offset;
655 PPCDBG(PPCDBG_PHBINIT, "\t\t-> now [%lx .. %lx]\n",
656 dev->resource[i].start, dev->resource[i].end);
657 } else if (dev->resource[i].flags & IORESOURCE_MEM) {
658 if (dev->resource[i].start == 0) {
659 /* Bogus. Probably an unused bridge. */
660 dev->resource[i].end = 0;
662 dev->resource[i].start += phb->pci_mem_offset;
663 dev->resource[i].end += phb->pci_mem_offset;
665 PPCDBG(PPCDBG_PHBINIT, "\t\t-> now [%lx..%lx]\n",
666 dev->resource[i].start, dev->resource[i].end);
672 /* zap the 2nd function of the winbond chip */
673 if (dev->resource[i].flags & IORESOURCE_IO
674 && dev->bus->number == 0 && dev->devfn == 0x81)
675 dev->resource[i].flags &= ~IORESOURCE_IO;
679 static void check_s7a(void)
681 struct device_node *root;
684 root = find_path_device("/");
686 model = get_property(root, "model", NULL);
687 if (model && !strcmp(model, "IBM,7013-S7A"))
693 pSeries_pcibios_fixup(void)
697 PPCDBG(PPCDBG_PHBINIT, "pSeries_pcibios_fixup: start\n");
698 pci_assign_all_busses = 0;
702 pci_for_each_dev(dev) {
703 pci_read_irq_line(dev);
704 PPCDBGCALL(PPCDBG_PHBINIT, dumpPci_Dev(dev) );
707 if (naca->interrupt_controller == IC_PPC_XIC) {
712 /***********************************************************************
713 * pci_find_hose_for_OF_device
715 * This function finds the PHB that matching device_node in the
716 * OpenFirmware by scanning all the pci_controllers.
718 ***********************************************************************/
719 struct pci_controller*
720 pci_find_hose_for_OF_device(struct device_node *node)
723 struct pci_controller *hose;
724 for (hose=hose_head;hose;hose=hose->next)
725 if (hose->arch_data == node)
732 /***********************************************************************
735 * Chance to initialize and structures or variable before PCI Bus walk.
737 ***********************************************************************/
739 pSeries_pcibios_init(void)
741 PPCDBG(PPCDBG_PHBINIT, "\tppc64_pcibios_init Entry.\n");
743 if (get_property(find_path_device("/rtas"),"ibm,fw-phb-id",NULL) != NULL) {
744 PPCDBG(PPCDBG_PHBINIT, "\tFound: ibm,fw-phb-id\n");
745 Pci_Large_Bus_System = 1;
750 * This is called very early before the page table is setup.
753 pSeries_pcibios_init_early(void)
755 ppc_md.pcibios_read_config_byte = rtas_read_config_byte;
756 ppc_md.pcibios_read_config_word = rtas_read_config_word;
757 ppc_md.pcibios_read_config_dword = rtas_read_config_dword;
758 ppc_md.pcibios_write_config_byte = rtas_write_config_byte;
759 ppc_md.pcibios_write_config_word = rtas_write_config_word;
760 ppc_md.pcibios_write_config_dword = rtas_write_config_dword;
762 /************************************************************************/
763 /* Get a char* of the device physical location(U0.3-P1-I8) */
764 /* See the Product Topology in the RS/6000 Architecture. */
765 /************************************************************************/
766 int device_Location(struct pci_dev *PciDev, char *BufPtr)
768 struct device_node *DevNode = (struct device_node *)PciDev->sysdata;
769 return sprintf(BufPtr,"PCI: Bus%3d, Device%3d, Vendor %04X, Location %-12s",
771 PCI_SLOT(PciDev->devfn),
773 (char*)get_property(DevNode,"ibm,loc-code",0));
775 /************************************************************************/
776 /* Set the slot reset line to the state passed in. */
777 /* This is the platform specific for code for the pci_reset_device */
779 /************************************************************************/
780 int pci_set_reset(struct pci_dev *PciDev, int state)