aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mn10300/unit-asb2305/pci.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2012-02-23 22:19:02 -0500
committerBjorn Helgaas <bhelgaas@google.com>2012-02-23 22:19:02 -0500
commit4b84b6e9b43cab04099ba7055322d31dbd789475 (patch)
tree94d185dbce89b1cf9c7f14e1318e38a0e990df9f /arch/mn10300/unit-asb2305/pci.c
parent96a6b9ad05a2d5654f168d3ad9d9696d3b03a7c2 (diff)
mn10300/PCI: get rid of device resource fixups
Tell the PCI core about host bridge address translation so it can take care of bus-to-resource conversion for us. CC: David Howells <dhowells@redhat.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'arch/mn10300/unit-asb2305/pci.c')
-rw-r--r--arch/mn10300/unit-asb2305/pci.c62
1 files changed, 9 insertions, 53 deletions
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index a7c5f08ca9f5..6dce9fc2cf3c 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -32,8 +32,7 @@ struct pci_ops *pci_root_ops;
32 * insert specific PCI bus resources instead of using the platform-level bus 32 * insert specific PCI bus resources instead of using the platform-level bus
33 * resources directly for the PCI root bus. 33 * resources directly for the PCI root bus.
34 * 34 *
35 * These are configured and inserted by pcibios_init() and are attached to the 35 * These are configured and inserted by pcibios_init().
36 * root bus by pcibios_fixup_bus().
37 */ 36 */
38static struct resource pci_ioport_resource = { 37static struct resource pci_ioport_resource = {
39 .name = "PCI IO", 38 .name = "PCI IO",
@@ -78,52 +77,6 @@ static inline int __query(const struct pci_bus *bus, unsigned int devfn)
78} 77}
79 78
80/* 79/*
81 * translate Linuxcentric addresses to PCI bus addresses
82 */
83void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
84 struct resource *res)
85{
86 if (res->flags & IORESOURCE_IO) {
87 region->start = (res->start & 0x00ffffff);
88 region->end = (res->end & 0x00ffffff);
89 }
90
91 if (res->flags & IORESOURCE_MEM) {
92 region->start = (res->start & 0x03ffffff) | MEM_PAGING_REG;
93 region->end = (res->end & 0x03ffffff) | MEM_PAGING_REG;
94 }
95
96#if 0
97 printk(KERN_DEBUG "RES->BUS: %lx-%lx => %lx-%lx\n",
98 res->start, res->end, region->start, region->end);
99#endif
100}
101EXPORT_SYMBOL(pcibios_resource_to_bus);
102
103/*
104 * translate PCI bus addresses to Linuxcentric addresses
105 */
106void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
107 struct pci_bus_region *region)
108{
109 if (res->flags & IORESOURCE_IO) {
110 res->start = (region->start & 0x00ffffff) | 0xbe000000;
111 res->end = (region->end & 0x00ffffff) | 0xbe000000;
112 }
113
114 if (res->flags & IORESOURCE_MEM) {
115 res->start = (region->start & 0x03ffffff) | 0xb8000000;
116 res->end = (region->end & 0x03ffffff) | 0xb8000000;
117 }
118
119#if 0
120 printk(KERN_INFO "BUS->RES: %lx-%lx => %lx-%lx\n",
121 region->start, region->end, res->start, res->end);
122#endif
123}
124EXPORT_SYMBOL(pcibios_bus_to_resource);
125
126/*
127 * 80 *
128 */ 81 */
129static int pci_ampci_read_config_byte(struct pci_bus *bus, unsigned int devfn, 82static int pci_ampci_read_config_byte(struct pci_bus *bus, unsigned int devfn,
@@ -364,9 +317,6 @@ static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
364 if (!dev->resource[i].flags) 317 if (!dev->resource[i].flags)
365 continue; 318 continue;
366 319
367 region.start = dev->resource[i].start;
368 region.end = dev->resource[i].end;
369 pcibios_bus_to_resource(dev, &dev->resource[i], &region);
370 if (is_valid_resource(dev, i)) 320 if (is_valid_resource(dev, i))
371 pci_claim_resource(dev, i); 321 pci_claim_resource(dev, i);
372 } 322 }
@@ -397,6 +347,7 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
397 */ 347 */
398static int __init pcibios_init(void) 348static int __init pcibios_init(void)
399{ 349{
350 resource_size_t io_offset, mem_offset;
400 LIST_HEAD(resources); 351 LIST_HEAD(resources);
401 352
402 ioport_resource.start = 0xA0000000; 353 ioport_resource.start = 0xA0000000;
@@ -420,8 +371,13 @@ static int __init pcibios_init(void)
420 printk(KERN_INFO "PCI: Probing PCI hardware [mempage %08x]\n", 371 printk(KERN_INFO "PCI: Probing PCI hardware [mempage %08x]\n",
421 MEM_PAGING_REG); 372 MEM_PAGING_REG);
422 373
423 pci_add_resource(&resources, &pci_ioport_resource); 374 io_offset = pci_ioport_resource.start -
424 pci_add_resource(&resources, &pci_iomem_resource); 375 (pci_ioport_resource.start & 0x00ffffff);
376 mem_offset = pci_iomem_resource.start -
377 ((pci_iomem_resource.start & 0x03ffffff) | MEM_PAGING_REG);
378
379 pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
380 pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
425 pci_root_bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, 381 pci_root_bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL,
426 &resources); 382 &resources);
427 383