aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/kernel/pci.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2007-03-11 19:42:53 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 04:55:19 -0400
commit97b3cf050b467dda571943ceadff5452bed04549 (patch)
treec5dbb828eb40f84d6203cfd5aaa56f12c4548b71 /arch/sparc64/kernel/pci.c
parentc6e87566ea080bbbe926c0e429fed48e6f680d93 (diff)
[SPARC64]: Add dummy host controller to root of all PCI domains.
We fake up a dummy one in all cases because that is the simplest thing to do and it happens to be necessary for hypervisor systems. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/pci.c')
-rw-r--r--arch/sparc64/kernel/pci.c119
1 files changed, 89 insertions, 30 deletions
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index 914a216da339..ec5f85b030ef 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -368,7 +368,8 @@ static void pci_parse_of_addrs(struct of_device *op,
368 368
369struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, 369struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
370 struct device_node *node, 370 struct device_node *node,
371 struct pci_bus *bus, int devfn) 371 struct pci_bus *bus, int devfn,
372 int host_controller)
372{ 373{
373 struct dev_archdata *sd; 374 struct dev_archdata *sd;
374 struct pci_dev *dev; 375 struct pci_dev *dev;
@@ -400,47 +401,62 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
400 dev->devfn = devfn; 401 dev->devfn = devfn;
401 dev->multifunction = 0; /* maybe a lie? */ 402 dev->multifunction = 0; /* maybe a lie? */
402 403
403 dev->vendor = of_getintprop_default(node, "vendor-id", 0xffff); 404 if (host_controller) {
404 dev->device = of_getintprop_default(node, "device-id", 0xffff); 405 dev->vendor = 0x108e;
405 dev->subsystem_vendor = 406 dev->device = 0x8000;
406 of_getintprop_default(node, "subsystem-vendor-id", 0); 407 dev->subsystem_vendor = 0x0000;
407 dev->subsystem_device = 408 dev->subsystem_device = 0x0000;
408 of_getintprop_default(node, "subsystem-id", 0); 409 dev->cfg_size = 256;
409 410 } else {
410 dev->cfg_size = pci_cfg_space_size(dev); 411 dev->vendor = of_getintprop_default(node, "vendor-id", 0xffff);
411 412 dev->device = of_getintprop_default(node, "device-id", 0xffff);
413 dev->subsystem_vendor =
414 of_getintprop_default(node, "subsystem-vendor-id", 0);
415 dev->subsystem_device =
416 of_getintprop_default(node, "subsystem-id", 0);
417
418 dev->cfg_size = pci_cfg_space_size(dev);
419 }
412 sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus), 420 sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus),
413 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); 421 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
414 422
415 /* dev->class = of_getintprop_default(node, "class-code", 0); */ 423 if (host_controller) {
416 /* We can't actually use the firmware value, we have to read what 424 dev->class = PCI_CLASS_BRIDGE_HOST << 8;
417 * is in the register right now. One reason is that in the case 425 } else {
418 * of IDE interfaces the firmware can sample the value before the 426 /* We can't actually use the firmware value, we have
419 * the IDE interface is programmed into native mode. 427 * to read what is in the register right now. One
420 */ 428 * reason is that in the case of IDE interfaces the
421 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class); 429 * firmware can sample the value before the the IDE
422 dev->class = class >> 8; 430 * interface is programmed into native mode.
423 431 */
432 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class);
433 dev->class = class >> 8;
434 }
424 printk(" class: 0x%x\n", dev->class); 435 printk(" class: 0x%x\n", dev->class);
425 436
426 dev->current_state = 4; /* unknown power state */ 437 dev->current_state = 4; /* unknown power state */
427 dev->error_state = pci_channel_io_normal; 438 dev->error_state = pci_channel_io_normal;
428 439
429 if (!strcmp(type, "pci") || !strcmp(type, "pciex")) { 440 if (host_controller) {
430 /* a PCI-PCI bridge */
431 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE; 441 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
432 dev->rom_base_reg = PCI_ROM_ADDRESS1; 442 dev->rom_base_reg = PCI_ROM_ADDRESS1;
433 } else if (!strcmp(type, "cardbus")) { 443 dev->irq = PCI_IRQ_NONE;
434 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;
435 } else { 444 } else {
436 dev->hdr_type = PCI_HEADER_TYPE_NORMAL; 445 if (!strcmp(type, "pci") || !strcmp(type, "pciex")) {
437 dev->rom_base_reg = PCI_ROM_ADDRESS; 446 /* a PCI-PCI bridge */
447 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
448 dev->rom_base_reg = PCI_ROM_ADDRESS1;
449 } else if (!strcmp(type, "cardbus")) {
450 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;
451 } else {
452 dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
453 dev->rom_base_reg = PCI_ROM_ADDRESS;
438 454
439 dev->irq = sd->op->irqs[0]; 455 dev->irq = sd->op->irqs[0];
440 if (dev->irq == 0xffffffff) 456 if (dev->irq == 0xffffffff)
441 dev->irq = PCI_IRQ_NONE; 457 dev->irq = PCI_IRQ_NONE;
458 }
442 } 459 }
443
444 pci_parse_of_addrs(sd->op, node, dev); 460 pci_parse_of_addrs(sd->op, node, dev);
445 461
446 printk(" adding to system ...\n"); 462 printk(" adding to system ...\n");
@@ -632,7 +648,7 @@ static void __init pci_of_scan_bus(struct pci_pbm_info *pbm,
632 devfn = (reg[0] >> 8) & 0xff; 648 devfn = (reg[0] >> 8) & 0xff;
633 649
634 /* create a new pci_dev for this device */ 650 /* create a new pci_dev for this device */
635 dev = of_create_pci_dev(pbm, child, bus, devfn); 651 dev = of_create_pci_dev(pbm, child, bus, devfn, 0);
636 if (!dev) 652 if (!dev)
637 continue; 653 continue;
638 printk("PCI: dev header type: %x\n", dev->hdr_type); 654 printk("PCI: dev header type: %x\n", dev->hdr_type);
@@ -677,10 +693,49 @@ static void __devinit pci_bus_register_of_sysfs(struct pci_bus *bus)
677 pci_bus_register_of_sysfs(child_bus); 693 pci_bus_register_of_sysfs(child_bus);
678} 694}
679 695
696int pci_host_bridge_read_pci_cfg(struct pci_bus *bus_dev,
697 unsigned int devfn,
698 int where, int size,
699 u32 *value)
700{
701 static u8 fake_pci_config[] = {
702 0x8e, 0x10, /* Vendor: 0x108e (Sun) */
703 0x00, 0x80, /* Device: 0x8000 (PBM) */
704 0x46, 0x01, /* Command: 0x0146 (SERR, PARITY, MASTER, MEM) */
705 0xa0, 0x22, /* Status: 0x02a0 (DEVSEL_MED, FB2B, 66MHZ) */
706 0x00, 0x00, 0x00, 0x06, /* Class: 0x06000000 host bridge */
707 0x00, /* Cacheline: 0x00 */
708 0x40, /* Latency: 0x40 */
709 0x00, /* Header-Type: 0x00 normal */
710 };
711
712 *value = 0;
713 if (where >= 0 && where < sizeof(fake_pci_config) &&
714 (where + size) >= 0 &&
715 (where + size) < sizeof(fake_pci_config) &&
716 size <= sizeof(u32)) {
717 while (size--) {
718 *value <<= 8;
719 *value |= fake_pci_config[where + size];
720 }
721 }
722
723 return PCIBIOS_SUCCESSFUL;
724}
725
726int pci_host_bridge_write_pci_cfg(struct pci_bus *bus_dev,
727 unsigned int devfn,
728 int where, int size,
729 u32 value)
730{
731 return PCIBIOS_SUCCESSFUL;
732}
733
680struct pci_bus * __init pci_scan_one_pbm(struct pci_pbm_info *pbm) 734struct pci_bus * __init pci_scan_one_pbm(struct pci_pbm_info *pbm)
681{ 735{
682 struct pci_controller_info *p = pbm->parent; 736 struct pci_controller_info *p = pbm->parent;
683 struct device_node *node = pbm->prom_node; 737 struct device_node *node = pbm->prom_node;
738 struct pci_dev *host_pdev;
684 struct pci_bus *bus; 739 struct pci_bus *bus;
685 740
686 printk("PCI: Scanning PBM %s\n", node->full_name); 741 printk("PCI: Scanning PBM %s\n", node->full_name);
@@ -698,6 +753,10 @@ struct pci_bus * __init pci_scan_one_pbm(struct pci_pbm_info *pbm)
698 bus->resource[0] = &pbm->io_space; 753 bus->resource[0] = &pbm->io_space;
699 bus->resource[1] = &pbm->mem_space; 754 bus->resource[1] = &pbm->mem_space;
700 755
756 /* Create the dummy host bridge and link it in. */
757 host_pdev = of_create_pci_dev(pbm, node, bus, 0x00, 1);
758 bus->self = host_pdev;
759
701 pci_of_scan_bus(pbm, node, bus); 760 pci_of_scan_bus(pbm, node, bus);
702 pci_bus_add_devices(bus); 761 pci_bus_add_devices(bus);
703 pci_bus_register_of_sysfs(bus); 762 pci_bus_register_of_sysfs(bus);