Commit 13fbadcd authored by Bjorn Helgaas's avatar Bjorn Helgaas

Merge branch 'pci/sparc'

  - request legacy VGA framebuffer only for VGA devices to avoid false
    device conflicts (Bjorn Helgaas)

  - turn on PCI_COMMAND_IO & PCI_COMMAND_MEMORY in pci_enable_device() like
    everybody else, not in pcibios_fixup_bus() (Bjorn Helgaas)

* pci/sparc:
  sparc/PCI: Use dev_printk() when possible
  sparc32/PCI/PCIC: Converge device enable path
  sparc32/PCI/LEON: Converge device enable path
  sparc/PCI: Request legacy VGA framebuffer only for VGA devices
parents a7c9d4cf adedc05e
...@@ -60,50 +60,30 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) ...@@ -60,50 +60,30 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
pci_bus_add_devices(root_bus); pci_bus_add_devices(root_bus);
} }
void pcibios_fixup_bus(struct pci_bus *pbus) int pcibios_enable_device(struct pci_dev *dev, int mask)
{ {
struct pci_dev *dev; u16 cmd, oldcmd;
int i, has_io, has_mem; int i;
u16 cmd;
list_for_each_entry(dev, &pbus->devices, bus_list) { pci_read_config_word(dev, PCI_COMMAND, &cmd);
/* oldcmd = cmd;
* We can not rely on that the bootloader has enabled I/O
* or memory access to PCI devices. Instead we enable it here for (i = 0; i < PCI_NUM_RESOURCES; i++) {
* if the device has BARs of respective type. struct resource *res = &dev->resource[i];
*/
has_io = has_mem = 0; /* Only set up the requested stuff */
for (i = 0; i < PCI_ROM_RESOURCE; i++) { if (!(mask & (1<<i)))
unsigned long f = dev->resource[i].flags; continue;
if (f & IORESOURCE_IO)
has_io = 1; if (res->flags & IORESOURCE_IO)
else if (f & IORESOURCE_MEM)
has_mem = 1;
}
/* ROM BARs are mapped into 32-bit memory space */
if (dev->resource[PCI_ROM_RESOURCE].end != 0) {
dev->resource[PCI_ROM_RESOURCE].flags |=
IORESOURCE_ROM_ENABLE;
has_mem = 1;
}
pci_bus_read_config_word(pbus, dev->devfn, PCI_COMMAND, &cmd);
if (has_io && !(cmd & PCI_COMMAND_IO)) {
#ifdef CONFIG_PCI_DEBUG
printk(KERN_INFO "LEONPCI: Enabling I/O for dev %s\n",
pci_name(dev));
#endif
cmd |= PCI_COMMAND_IO; cmd |= PCI_COMMAND_IO;
pci_bus_write_config_word(pbus, dev->devfn, PCI_COMMAND, if (res->flags & IORESOURCE_MEM)
cmd);
}
if (has_mem && !(cmd & PCI_COMMAND_MEMORY)) {
#ifdef CONFIG_PCI_DEBUG
printk(KERN_INFO "LEONPCI: Enabling MEMORY for dev"
"%s\n", pci_name(dev));
#endif
cmd |= PCI_COMMAND_MEMORY; cmd |= PCI_COMMAND_MEMORY;
pci_bus_write_config_word(pbus, dev->devfn, PCI_COMMAND,
cmd);
}
} }
if (cmd != oldcmd) {
pci_info(dev, "enabling device (%04x -> %04x)\n", oldcmd, cmd);
pci_write_config_word(dev, PCI_COMMAND, cmd);
}
return 0;
} }
...@@ -214,8 +214,8 @@ static void pci_parse_of_addrs(struct platform_device *op, ...@@ -214,8 +214,8 @@ static void pci_parse_of_addrs(struct platform_device *op,
if (!addrs) if (!addrs)
return; return;
if (ofpci_verbose) if (ofpci_verbose)
printk(" parse addresses (%d bytes) @ %p\n", pci_info(dev, " parse addresses (%d bytes) @ %p\n",
proplen, addrs); proplen, addrs);
op_res = &op->resource[0]; op_res = &op->resource[0];
for (; proplen >= 20; proplen -= 20, addrs += 5, op_res++) { for (; proplen >= 20; proplen -= 20, addrs += 5, op_res++) {
struct resource *res; struct resource *res;
...@@ -227,8 +227,8 @@ static void pci_parse_of_addrs(struct platform_device *op, ...@@ -227,8 +227,8 @@ static void pci_parse_of_addrs(struct platform_device *op,
continue; continue;
i = addrs[0] & 0xff; i = addrs[0] & 0xff;
if (ofpci_verbose) if (ofpci_verbose)
printk(" start: %llx, end: %llx, i: %x\n", pci_info(dev, " start: %llx, end: %llx, i: %x\n",
op_res->start, op_res->end, i); op_res->start, op_res->end, i);
if (PCI_BASE_ADDRESS_0 <= i && i <= PCI_BASE_ADDRESS_5) { if (PCI_BASE_ADDRESS_0 <= i && i <= PCI_BASE_ADDRESS_5) {
res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2]; res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2];
...@@ -236,13 +236,15 @@ static void pci_parse_of_addrs(struct platform_device *op, ...@@ -236,13 +236,15 @@ static void pci_parse_of_addrs(struct platform_device *op,
res = &dev->resource[PCI_ROM_RESOURCE]; res = &dev->resource[PCI_ROM_RESOURCE];
flags |= IORESOURCE_READONLY | IORESOURCE_SIZEALIGN; flags |= IORESOURCE_READONLY | IORESOURCE_SIZEALIGN;
} else { } else {
printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i); pci_err(dev, "bad cfg reg num 0x%x\n", i);
continue; continue;
} }
res->start = op_res->start; res->start = op_res->start;
res->end = op_res->end; res->end = op_res->end;
res->flags = flags; res->flags = flags;
res->name = pci_name(dev); res->name = pci_name(dev);
pci_info(dev, "reg 0x%x: %pR\n", i, res);
} }
} }
...@@ -289,8 +291,8 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, ...@@ -289,8 +291,8 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
type = ""; type = "";
if (ofpci_verbose) if (ofpci_verbose)
printk(" create device, devfn: %x, type: %s\n", pci_info(bus," create device, devfn: %x, type: %s\n",
devfn, type); devfn, type);
dev->sysdata = node; dev->sysdata = node;
dev->dev.parent = bus->bridge; dev->dev.parent = bus->bridge;
...@@ -323,10 +325,6 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, ...@@ -323,10 +325,6 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus), dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus),
dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
if (ofpci_verbose)
printk(" class: 0x%x device name: %s\n",
dev->class, pci_name(dev));
/* I have seen IDE devices which will not respond to /* I have seen IDE devices which will not respond to
* the bmdma simplex check reads if bus mastering is * the bmdma simplex check reads if bus mastering is
* disabled. * disabled.
...@@ -353,10 +351,13 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, ...@@ -353,10 +351,13 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
dev->irq = PCI_IRQ_NONE; dev->irq = PCI_IRQ_NONE;
} }
pci_info(dev, "[%04x:%04x] type %02x class %#08x\n",
dev->vendor, dev->device, dev->hdr_type, dev->class);
pci_parse_of_addrs(sd->op, node, dev); pci_parse_of_addrs(sd->op, node, dev);
if (ofpci_verbose) if (ofpci_verbose)
printk(" adding to system ...\n"); pci_info(dev, " adding to system ...\n");
pci_device_add(dev, bus); pci_device_add(dev, bus);
...@@ -430,19 +431,19 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm, ...@@ -430,19 +431,19 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
u64 size; u64 size;
if (ofpci_verbose) if (ofpci_verbose)
printk("of_scan_pci_bridge(%s)\n", node->full_name); pci_info(dev, "of_scan_pci_bridge(%s)\n", node->full_name);
/* parse bus-range property */ /* parse bus-range property */
busrange = of_get_property(node, "bus-range", &len); busrange = of_get_property(node, "bus-range", &len);
if (busrange == NULL || len != 8) { if (busrange == NULL || len != 8) {
printk(KERN_DEBUG "Can't get bus-range for PCI-PCI bridge %s\n", pci_info(dev, "Can't get bus-range for PCI-PCI bridge %s\n",
node->full_name); node->full_name);
return; return;
} }
if (ofpci_verbose) if (ofpci_verbose)
printk(" Bridge bus range [%u --> %u]\n", pci_info(dev, " Bridge bus range [%u --> %u]\n",
busrange[0], busrange[1]); busrange[0], busrange[1]);
ranges = of_get_property(node, "ranges", &len); ranges = of_get_property(node, "ranges", &len);
simba = 0; simba = 0;
...@@ -454,8 +455,8 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm, ...@@ -454,8 +455,8 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
bus = pci_add_new_bus(dev->bus, dev, busrange[0]); bus = pci_add_new_bus(dev->bus, dev, busrange[0]);
if (!bus) { if (!bus) {
printk(KERN_ERR "Failed to create pci bus for %s\n", pci_err(dev, "Failed to create pci bus for %s\n",
node->full_name); node->full_name);
return; return;
} }
...@@ -464,8 +465,8 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm, ...@@ -464,8 +465,8 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
bus->bridge_ctl = 0; bus->bridge_ctl = 0;
if (ofpci_verbose) if (ofpci_verbose)
printk(" Bridge ranges[%p] simba[%d]\n", pci_info(dev, " Bridge ranges[%p] simba[%d]\n",
ranges, simba); ranges, simba);
/* parse ranges property, or cook one up by hand for Simba */ /* parse ranges property, or cook one up by hand for Simba */
/* PCI #address-cells == 3 and #size-cells == 2 always */ /* PCI #address-cells == 3 and #size-cells == 2 always */
...@@ -487,10 +488,10 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm, ...@@ -487,10 +488,10 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
u64 start; u64 start;
if (ofpci_verbose) if (ofpci_verbose)
printk(" RAW Range[%08x:%08x:%08x:%08x:%08x:%08x:" pci_info(dev, " RAW Range[%08x:%08x:%08x:%08x:%08x:%08x:"
"%08x:%08x]\n", "%08x:%08x]\n",
ranges[0], ranges[1], ranges[2], ranges[3], ranges[0], ranges[1], ranges[2], ranges[3],
ranges[4], ranges[5], ranges[6], ranges[7]); ranges[4], ranges[5], ranges[6], ranges[7]);
flags = pci_parse_of_flags(ranges[0]); flags = pci_parse_of_flags(ranges[0]);
size = GET_64BIT(ranges, 6); size = GET_64BIT(ranges, 6);
...@@ -510,14 +511,14 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm, ...@@ -510,14 +511,14 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
if (flags & IORESOURCE_IO) { if (flags & IORESOURCE_IO) {
res = bus->resource[0]; res = bus->resource[0];
if (res->flags) { if (res->flags) {
printk(KERN_ERR "PCI: ignoring extra I/O range" pci_err(dev, "ignoring extra I/O range"
" for bridge %s\n", node->full_name); " for bridge %s\n", node->full_name);
continue; continue;
} }
} else { } else {
if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) { if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) {
printk(KERN_ERR "PCI: too many memory ranges" pci_err(dev, "too many memory ranges"
" for bridge %s\n", node->full_name); " for bridge %s\n", node->full_name);
continue; continue;
} }
res = bus->resource[i]; res = bus->resource[i];
...@@ -529,8 +530,8 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm, ...@@ -529,8 +530,8 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
region.end = region.start + size - 1; region.end = region.start + size - 1;
if (ofpci_verbose) if (ofpci_verbose)
printk(" Using flags[%08x] start[%016llx] size[%016llx]\n", pci_info(dev, " Using flags[%08x] start[%016llx] size[%016llx]\n",
flags, start, size); flags, start, size);
pcibios_bus_to_resource(dev->bus, res, &region); pcibios_bus_to_resource(dev->bus, res, &region);
} }
...@@ -538,7 +539,7 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm, ...@@ -538,7 +539,7 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
bus->number); bus->number);
if (ofpci_verbose) if (ofpci_verbose)
printk(" bus name: %s\n", bus->name); pci_info(dev, " bus name: %s\n", bus->name);
pci_of_scan_bus(pbm, node, bus); pci_of_scan_bus(pbm, node, bus);
} }
...@@ -553,14 +554,14 @@ static void pci_of_scan_bus(struct pci_pbm_info *pbm, ...@@ -553,14 +554,14 @@ static void pci_of_scan_bus(struct pci_pbm_info *pbm,
struct pci_dev *dev; struct pci_dev *dev;
if (ofpci_verbose) if (ofpci_verbose)
printk("PCI: scan_bus[%s] bus no %d\n", pci_info(bus, "scan_bus[%s] bus no %d\n",
node->full_name, bus->number); node->full_name, bus->number);
child = NULL; child = NULL;
prev_devfn = -1; prev_devfn = -1;
while ((child = of_get_next_child(node, child)) != NULL) { while ((child = of_get_next_child(node, child)) != NULL) {
if (ofpci_verbose) if (ofpci_verbose)
printk(" * %s\n", child->full_name); pci_info(bus, " * %s\n", child->full_name);
reg = of_get_property(child, "reg", &reglen); reg = of_get_property(child, "reg", &reglen);
if (reg == NULL || reglen < 20) if (reg == NULL || reglen < 20)
continue; continue;
...@@ -581,8 +582,7 @@ static void pci_of_scan_bus(struct pci_pbm_info *pbm, ...@@ -581,8 +582,7 @@ static void pci_of_scan_bus(struct pci_pbm_info *pbm,
if (!dev) if (!dev)
continue; continue;
if (ofpci_verbose) if (ofpci_verbose)
printk("PCI: dev header type: %x\n", pci_info(dev, "dev header type: %x\n", dev->hdr_type);
dev->hdr_type);
if (pci_is_bridge(dev)) if (pci_is_bridge(dev))
of_scan_pci_bridge(pbm, child, dev); of_scan_pci_bridge(pbm, child, dev);
...@@ -624,6 +624,45 @@ static void pci_bus_register_of_sysfs(struct pci_bus *bus) ...@@ -624,6 +624,45 @@ static void pci_bus_register_of_sysfs(struct pci_bus *bus)
pci_bus_register_of_sysfs(child_bus); pci_bus_register_of_sysfs(child_bus);
} }
static void pci_claim_legacy_resources(struct pci_dev *dev)
{
struct pci_bus_region region;
struct resource *p, *root, *conflict;
if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
return;
p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return;
p->name = "Video RAM area";
p->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
region.start = 0xa0000UL;
region.end = region.start + 0x1ffffUL;
pcibios_bus_to_resource(dev->bus, p, &region);
root = pci_find_parent_resource(dev, p);
if (!root) {
pci_info(dev, "can't claim VGA legacy %pR: no compatible bridge window\n", p);
goto err;
}
conflict = request_resource_conflict(root, p);
if (conflict) {
pci_info(dev, "can't claim VGA legacy %pR: address conflict with %s %pR\n",
p, conflict->name, conflict);
goto err;
}
pci_info(dev, "VGA legacy framebuffer %pR\n", p);
return;
err:
kfree(p);
}
static void pci_claim_bus_resources(struct pci_bus *bus) static void pci_claim_bus_resources(struct pci_bus *bus)
{ {
struct pci_bus *child_bus; struct pci_bus *child_bus;
...@@ -639,15 +678,13 @@ static void pci_claim_bus_resources(struct pci_bus *bus) ...@@ -639,15 +678,13 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
continue; continue;
if (ofpci_verbose) if (ofpci_verbose)
printk("PCI: Claiming %s: " pci_info(dev, "Claiming Resource %d: %pR\n",
"Resource %d: %016llx..%016llx [%x]\n", i, r);
pci_name(dev), i,
(unsigned long long)r->start,
(unsigned long long)r->end,
(unsigned int)r->flags);
pci_claim_resource(dev, i); pci_claim_resource(dev, i);
} }
pci_claim_legacy_resources(dev);
} }
list_for_each_entry(child_bus, &bus->children, node) list_for_each_entry(child_bus, &bus->children, node)
...@@ -687,6 +724,7 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, ...@@ -687,6 +724,7 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
pci_bus_register_of_sysfs(bus); pci_bus_register_of_sysfs(bus);
pci_claim_bus_resources(bus); pci_claim_bus_resources(bus);
pci_bus_add_devices(bus); pci_bus_add_devices(bus);
return bus; return bus;
} }
...@@ -713,9 +751,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) ...@@ -713,9 +751,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
} }
if (cmd != oldcmd) { if (cmd != oldcmd) {
printk(KERN_DEBUG "PCI: Enabling device: (%s), cmd %x\n", pci_info(dev, "enabling device (%04x -> %04x)\n", oldcmd, cmd);
pci_name(dev), cmd);
/* Enable the appropriate bits in the PCI command register. */
pci_write_config_word(dev, PCI_COMMAND, cmd); pci_write_config_word(dev, PCI_COMMAND, cmd);
} }
return 0; return 0;
...@@ -1075,8 +1111,8 @@ static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus) ...@@ -1075,8 +1111,8 @@ static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus)
sp = prop->names; sp = prop->names;
if (ofpci_verbose) if (ofpci_verbose)
printk("PCI: Making slots for [%s] mask[0x%02x]\n", pci_info(bus, "Making slots for [%s] mask[0x%02x]\n",
node->full_name, mask); node->full_name, mask);
i = 0; i = 0;
while (mask) { while (mask) {
...@@ -1089,12 +1125,12 @@ static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus) ...@@ -1089,12 +1125,12 @@ static void pci_bus_slot_names(struct device_node *node, struct pci_bus *bus)
} }
if (ofpci_verbose) if (ofpci_verbose)
printk("PCI: Making slot [%s]\n", sp); pci_info(bus, "Making slot [%s]\n", sp);
pci_slot = pci_create_slot(bus, i, sp, NULL); pci_slot = pci_create_slot(bus, i, sp, NULL);
if (IS_ERR(pci_slot)) if (IS_ERR(pci_slot))
printk(KERN_ERR "PCI: pci_create_slot returned %ld\n", pci_err(bus, "pci_create_slot returned %ld\n",
PTR_ERR(pci_slot)); PTR_ERR(pci_slot));
sp += strlen(sp) + 1; sp += strlen(sp) + 1;
mask &= ~this_bit; mask &= ~this_bit;
......
...@@ -329,23 +329,6 @@ void pci_get_pbm_props(struct pci_pbm_info *pbm) ...@@ -329,23 +329,6 @@ void pci_get_pbm_props(struct pci_pbm_info *pbm)
} }
} }
static void pci_register_legacy_regions(struct resource *io_res,
struct resource *mem_res)
{
struct resource *p;
/* VGA Video RAM. */
p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return;
p->name = "Video RAM area";
p->start = mem_res->start + 0xa0000UL;
p->end = p->start + 0x1ffffUL;
p->flags = IORESOURCE_BUSY;
request_resource(mem_res, p);
}
static void pci_register_iommu_region(struct pci_pbm_info *pbm) static void pci_register_iommu_region(struct pci_pbm_info *pbm)
{ {
const u32 *vdma = of_get_property(pbm->op->dev.of_node, "virtual-dma", const u32 *vdma = of_get_property(pbm->op->dev.of_node, "virtual-dma",
...@@ -487,8 +470,6 @@ void pci_determine_mem_io_space(struct pci_pbm_info *pbm) ...@@ -487,8 +470,6 @@ void pci_determine_mem_io_space(struct pci_pbm_info *pbm)
if (pbm->mem64_space.flags) if (pbm->mem64_space.flags)
request_resource(&iomem_resource, &pbm->mem64_space); request_resource(&iomem_resource, &pbm->mem64_space);
pci_register_legacy_regions(&pbm->io_space,
&pbm->mem_space);
pci_register_iommu_region(pbm); pci_register_iommu_region(pbm);
} }
...@@ -508,8 +489,8 @@ void pci_scan_for_target_abort(struct pci_pbm_info *pbm, ...@@ -508,8 +489,8 @@ void pci_scan_for_target_abort(struct pci_pbm_info *pbm,
PCI_STATUS_REC_TARGET_ABORT)); PCI_STATUS_REC_TARGET_ABORT));
if (error_bits) { if (error_bits) {
pci_write_config_word(pdev, PCI_STATUS, error_bits); pci_write_config_word(pdev, PCI_STATUS, error_bits);
printk("%s: Device %s saw Target Abort [%016x]\n", pci_info(pdev, "%s: Device saw Target Abort [%016x]\n",
pbm->name, pci_name(pdev), status); pbm->name, status);
} }
} }
...@@ -531,8 +512,8 @@ void pci_scan_for_master_abort(struct pci_pbm_info *pbm, ...@@ -531,8 +512,8 @@ void pci_scan_for_master_abort(struct pci_pbm_info *pbm,
(status & (PCI_STATUS_REC_MASTER_ABORT)); (status & (PCI_STATUS_REC_MASTER_ABORT));
if (error_bits) { if (error_bits) {
pci_write_config_word(pdev, PCI_STATUS, error_bits); pci_write_config_word(pdev, PCI_STATUS, error_bits);
printk("%s: Device %s received Master Abort [%016x]\n", pci_info(pdev, "%s: Device received Master Abort "
pbm->name, pci_name(pdev), status); "[%016x]\n", pbm->name, status);
} }
} }
...@@ -555,8 +536,8 @@ void pci_scan_for_parity_error(struct pci_pbm_info *pbm, ...@@ -555,8 +536,8 @@ void pci_scan_for_parity_error(struct pci_pbm_info *pbm,
PCI_STATUS_DETECTED_PARITY)); PCI_STATUS_DETECTED_PARITY));
if (error_bits) { if (error_bits) {
pci_write_config_word(pdev, PCI_STATUS, error_bits); pci_write_config_word(pdev, PCI_STATUS, error_bits);
printk("%s: Device %s saw Parity Error [%016x]\n", pci_info(pdev, "%s: Device saw Parity Error [%016x]\n",
pbm->name, pci_name(pdev), status); pbm->name, status);
} }
} }
......
...@@ -191,8 +191,8 @@ static void sparc64_teardown_msi_irq(unsigned int irq, ...@@ -191,8 +191,8 @@ static void sparc64_teardown_msi_irq(unsigned int irq,
break; break;
} }
if (i >= pbm->msi_num) { if (i >= pbm->msi_num) {
printk(KERN_ERR "%s: teardown: No MSI for irq %u\n", pci_err(pdev, "%s: teardown: No MSI for irq %u\n", pbm->name,
pbm->name, irq); irq);
return; return;
} }
...@@ -201,9 +201,9 @@ static void sparc64_teardown_msi_irq(unsigned int irq, ...@@ -201,9 +201,9 @@ static void sparc64_teardown_msi_irq(unsigned int irq,
err = ops->msi_teardown(pbm, msi_num); err = ops->msi_teardown(pbm, msi_num);
if (err) { if (err) {
printk(KERN_ERR "%s: teardown: ops->teardown() on MSI %u, " pci_err(pdev, "%s: teardown: ops->teardown() on MSI %u, "
"irq %u, gives error %d\n", "irq %u, gives error %d\n", pbm->name, msi_num, irq,
pbm->name, msi_num, irq, err); err);
return; return;
} }
......
...@@ -518,10 +518,10 @@ static void pcic_map_pci_device(struct linux_pcic *pcic, ...@@ -518,10 +518,10 @@ static void pcic_map_pci_device(struct linux_pcic *pcic,
* board in a PCI slot. We must remap it * board in a PCI slot. We must remap it
* under 64K but it is not done yet. XXX * under 64K but it is not done yet. XXX
*/ */
printk("PCIC: Skipping I/O space at 0x%lx, " pci_info(dev, "PCIC: Skipping I/O space at "
"this will Oops if a driver attaches " "0x%lx, this will Oops if a driver "
"device '%s' at %02x:%02x)\n", address, "attaches device '%s'\n", address,
namebuf, dev->bus->number, dev->devfn); namebuf);
} }
} }
} }
...@@ -551,8 +551,8 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node) ...@@ -551,8 +551,8 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node)
p++; p++;
} }
if (i >= pcic->pcic_imdim) { if (i >= pcic->pcic_imdim) {
printk("PCIC: device %s devfn %02x:%02x not found in %d\n", pci_info(dev, "PCIC: device %s not found in %d\n", namebuf,
namebuf, dev->bus->number, dev->devfn, pcic->pcic_imdim); pcic->pcic_imdim);
dev->irq = 0; dev->irq = 0;
return; return;
} }
...@@ -565,7 +565,7 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node) ...@@ -565,7 +565,7 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node)
ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI); ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI);
real_irq = ivec >> ((i-4) << 2) & 0xF; real_irq = ivec >> ((i-4) << 2) & 0xF;
} else { /* Corrupted map */ } else { /* Corrupted map */
printk("PCIC: BAD PIN %d\n", i); for (;;) {} pci_info(dev, "PCIC: BAD PIN %d\n", i); for (;;) {}
} }
/* P3 */ /* printk("PCIC: device %s pin %d ivec 0x%x irq %x\n", namebuf, i, ivec, dev->irq); */ /* P3 */ /* printk("PCIC: device %s pin %d ivec 0x%x irq %x\n", namebuf, i, ivec, dev->irq); */
...@@ -574,10 +574,10 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node) ...@@ -574,10 +574,10 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node)
*/ */
if (real_irq == 0 || p->force) { if (real_irq == 0 || p->force) {
if (p->irq == 0 || p->irq >= 15) { /* Corrupted map */ if (p->irq == 0 || p->irq >= 15) { /* Corrupted map */
printk("PCIC: BAD IRQ %d\n", p->irq); for (;;) {} pci_info(dev, "PCIC: BAD IRQ %d\n", p->irq); for (;;) {}
} }
printk("PCIC: setting irq %d at pin %d for device %02x:%02x\n", pci_info(dev, "PCIC: setting irq %d at pin %d\n", p->irq,
p->irq, p->pin, dev->bus->number, dev->devfn); p->pin);
real_irq = p->irq; real_irq = p->irq;
i = p->pin; i = p->pin;
...@@ -602,15 +602,13 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node) ...@@ -602,15 +602,13 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node)
void pcibios_fixup_bus(struct pci_bus *bus) void pcibios_fixup_bus(struct pci_bus *bus)
{ {
struct pci_dev *dev; struct pci_dev *dev;
int i, has_io, has_mem;
unsigned int cmd = 0;
struct linux_pcic *pcic; struct linux_pcic *pcic;
/* struct linux_pbm_info* pbm = &pcic->pbm; */ /* struct linux_pbm_info* pbm = &pcic->pbm; */
int node; int node;
struct pcidev_cookie *pcp; struct pcidev_cookie *pcp;
if (!pcic0_up) { if (!pcic0_up) {
printk("pcibios_fixup_bus: no PCIC\n"); pci_info(bus, "pcibios_fixup_bus: no PCIC\n");
return; return;
} }
pcic = &pcic0; pcic = &pcic0;
...@@ -619,44 +617,12 @@ void pcibios_fixup_bus(struct pci_bus *bus) ...@@ -619,44 +617,12 @@ void pcibios_fixup_bus(struct pci_bus *bus)
* Next crud is an equivalent of pbm = pcic_bus_to_pbm(bus); * Next crud is an equivalent of pbm = pcic_bus_to_pbm(bus);
*/ */
if (bus->number != 0) { if (bus->number != 0) {
printk("pcibios_fixup_bus: nonzero bus 0x%x\n", bus->number); pci_info(bus, "pcibios_fixup_bus: nonzero bus 0x%x\n",
bus->number);
return; return;
} }
list_for_each_entry(dev, &bus->devices, bus_list) { list_for_each_entry(dev, &bus->devices, bus_list) {
/*
* Comment from i386 branch:
* There are buggy BIOSes that forget to enable I/O and memory
* access to PCI devices. We try to fix this, but we need to
* be sure that the BIOS didn't forget to assign an address
* to the device. [mj]
* OBP is a case of such BIOS :-)
*/
has_io = has_mem = 0;
for(i=0; i<6; i++) {
unsigned long f = dev->resource[i].flags;
if (f & IORESOURCE_IO) {
has_io = 1;
} else if (f & IORESOURCE_MEM)
has_mem = 1;
}
pcic_read_config(dev->bus, dev->devfn, PCI_COMMAND, 2, &cmd);
if (has_io && !(cmd & PCI_COMMAND_IO)) {
printk("PCIC: Enabling I/O for device %02x:%02x\n",
dev->bus->number, dev->devfn);
cmd |= PCI_COMMAND_IO;
pcic_write_config(dev->bus, dev->devfn,
PCI_COMMAND, 2, cmd);
}
if (has_mem && !(cmd & PCI_COMMAND_MEMORY)) {
printk("PCIC: Enabling memory for device %02x:%02x\n",
dev->bus->number, dev->devfn);
cmd |= PCI_COMMAND_MEMORY;
pcic_write_config(dev->bus, dev->devfn,
PCI_COMMAND, 2, cmd);
}
node = pdev_to_pnode(&pcic->pbm, dev); node = pdev_to_pnode(&pcic->pbm, dev);
if(node == 0) if(node == 0)
node = -1; node = -1;
...@@ -675,6 +641,34 @@ void pcibios_fixup_bus(struct pci_bus *bus) ...@@ -675,6 +641,34 @@ void pcibios_fixup_bus(struct pci_bus *bus)
} }
} }
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
u16 cmd, oldcmd;
int i;
pci_read_config_word(dev, PCI_COMMAND, &cmd);
oldcmd = cmd;
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *res = &dev->resource[i];
/* Only set up the requested stuff */
if (!(mask & (1<<i)))
continue;
if (res->flags & IORESOURCE_IO)
cmd |= PCI_COMMAND_IO;
if (res->flags & IORESOURCE_MEM)
cmd |= PCI_COMMAND_MEMORY;
}
if (cmd != oldcmd) {
pci_info(dev, "enabling device (%04x -> %04x)\n", oldcmd, cmd);
pci_write_config_word(dev, PCI_COMMAND, cmd);
}
return 0;
}
/* Makes compiler happy */ /* Makes compiler happy */
static volatile int pcic_timer_dummy; static volatile int pcic_timer_dummy;
...@@ -747,17 +741,11 @@ static void watchdog_reset() { ...@@ -747,17 +741,11 @@ static void watchdog_reset() {
} }
#endif #endif
int pcibios_enable_device(struct pci_dev *pdev, int mask)
{
return 0;
}
/* /*
* NMI * NMI
*/ */
void pcic_nmi(unsigned int pend, struct pt_regs *regs) void pcic_nmi(unsigned int pend, struct pt_regs *regs)
{ {
pend = swab32(pend); pend = swab32(pend);
if (!pcic_speculative || (pend & PCI_SYS_INT_PENDING_PIO) == 0) { if (!pcic_speculative || (pend & PCI_SYS_INT_PENDING_PIO) == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment