aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sparc/include/asm/pci_32.h8
-rw-r--r--arch/sparc/include/asm/pci_64.h8
-rw-r--r--arch/sparc/kernel/leon_pci.c47
-rw-r--r--arch/sparc/kernel/pci.c46
4 files changed, 13 insertions, 96 deletions
diff --git a/arch/sparc/include/asm/pci_32.h b/arch/sparc/include/asm/pci_32.h
index 6de7f7bf956a..6384f30429bb 100644
--- a/arch/sparc/include/asm/pci_32.h
+++ b/arch/sparc/include/asm/pci_32.h
@@ -52,13 +52,7 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
52 * 64Kbytes by the Host controller. 52 * 64Kbytes by the Host controller.
53 */ 53 */
54 54
55extern void 55#define ARCH_HAS_GENERIC_PCI_OFFSETS
56pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
57 struct resource *res);
58
59extern void
60pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
61 struct pci_bus_region *region);
62 56
63static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 57static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
64{ 58{
diff --git a/arch/sparc/include/asm/pci_64.h b/arch/sparc/include/asm/pci_64.h
index 755a4bb6bcd3..2918bd12c19b 100644
--- a/arch/sparc/include/asm/pci_64.h
+++ b/arch/sparc/include/asm/pci_64.h
@@ -73,13 +73,7 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
73 enum pci_mmap_state mmap_state, 73 enum pci_mmap_state mmap_state,
74 int write_combine); 74 int write_combine);
75 75
76extern void 76#define ARCH_HAS_GENERIC_PCI_OFFSETS
77pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
78 struct resource *res);
79
80extern void
81pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
82 struct pci_bus_region *region);
83 77
84static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 78static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
85{ 79{
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index c7bec25fdb1c..aba6b958b2a5 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -15,14 +15,19 @@
15 15
16/* The LEON architecture does not rely on a BIOS or bootloader to setup 16/* The LEON architecture does not rely on a BIOS or bootloader to setup
17 * PCI for us. The Linux generic routines are used to setup resources, 17 * PCI for us. The Linux generic routines are used to setup resources,
18 * reset values of confuration-space registers settings ae preseved. 18 * reset values of configuration-space register settings are preserved.
19 *
20 * PCI Memory and Prefetchable Memory is direct-mapped. However I/O Space is
21 * accessed through a Window which is translated to low 64KB in PCI space, the
22 * first 4KB is not used so 60KB is available.
19 */ 23 */
20void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) 24void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
21{ 25{
22 LIST_HEAD(resources); 26 LIST_HEAD(resources);
23 struct pci_bus *root_bus; 27 struct pci_bus *root_bus;
24 28
25 pci_add_resource(&resources, &info->io_space); 29 pci_add_resource_offset(&resources, &info->io_space,
30 info->io_space.start - 0x1000);
26 pci_add_resource(&resources, &info->mem_space); 31 pci_add_resource(&resources, &info->mem_space);
27 32
28 root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info, 33 root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info,
@@ -38,44 +43,6 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
38 } 43 }
39} 44}
40 45
41/* PCI Memory and Prefetchable Memory is direct-mapped. However I/O Space is
42 * accessed through a Window which is translated to low 64KB in PCI space, the
43 * first 4KB is not used so 60KB is available.
44 *
45 * This function is used by generic code to translate resource addresses into
46 * PCI addresses.
47 */
48void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
49 struct resource *res)
50{
51 struct leon_pci_info *info = dev->bus->sysdata;
52
53 region->start = res->start;
54 region->end = res->end;
55
56 if (res->flags & IORESOURCE_IO) {
57 region->start -= (info->io_space.start - 0x1000);
58 region->end -= (info->io_space.start - 0x1000);
59 }
60}
61EXPORT_SYMBOL(pcibios_resource_to_bus);
62
63/* see pcibios_resource_to_bus() comment */
64void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
65 struct pci_bus_region *region)
66{
67 struct leon_pci_info *info = dev->bus->sysdata;
68
69 res->start = region->start;
70 res->end = region->end;
71
72 if (res->flags & IORESOURCE_IO) {
73 res->start += (info->io_space.start - 0x1000);
74 res->end += (info->io_space.start - 0x1000);
75 }
76}
77EXPORT_SYMBOL(pcibios_bus_to_resource);
78
79void __devinit pcibios_fixup_bus(struct pci_bus *pbus) 46void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
80{ 47{
81 struct leon_pci_info *info = pbus->sysdata; 48 struct leon_pci_info *info = pbus->sysdata;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index bb8bc2e519ac..253e8ac2783f 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -691,8 +691,10 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
691 691
692 printk("PCI: Scanning PBM %s\n", node->full_name); 692 printk("PCI: Scanning PBM %s\n", node->full_name);
693 693
694 pci_add_resource(&resources, &pbm->io_space); 694 pci_add_resource_offset(&resources, &pbm->io_space,
695 pci_add_resource(&resources, &pbm->mem_space); 695 pbm->io_space.start);
696 pci_add_resource_offset(&resources, &pbm->mem_space,
697 pbm->mem_space.start);
696 bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, 698 bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
697 pbm, &resources); 699 pbm, &resources);
698 if (!bus) { 700 if (!bus) {
@@ -755,46 +757,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
755 return 0; 757 return 0;
756} 758}
757 759
758void pcibios_resource_to_bus(struct pci_dev *pdev, struct pci_bus_region *region,
759 struct resource *res)
760{
761 struct pci_pbm_info *pbm = pdev->bus->sysdata;
762 struct resource zero_res, *root;
763
764 zero_res.start = 0;
765 zero_res.end = 0;
766 zero_res.flags = res->flags;
767
768 if (res->flags & IORESOURCE_IO)
769 root = &pbm->io_space;
770 else
771 root = &pbm->mem_space;
772
773 pci_resource_adjust(&zero_res, root);
774
775 region->start = res->start - zero_res.start;
776 region->end = res->end - zero_res.start;
777}
778EXPORT_SYMBOL(pcibios_resource_to_bus);
779
780void pcibios_bus_to_resource(struct pci_dev *pdev, struct resource *res,
781 struct pci_bus_region *region)
782{
783 struct pci_pbm_info *pbm = pdev->bus->sysdata;
784 struct resource *root;
785
786 res->start = region->start;
787 res->end = region->end;
788
789 if (res->flags & IORESOURCE_IO)
790 root = &pbm->io_space;
791 else
792 root = &pbm->mem_space;
793
794 pci_resource_adjust(res, root);
795}
796EXPORT_SYMBOL(pcibios_bus_to_resource);
797
798char * __devinit pcibios_setup(char *str) 760char * __devinit pcibios_setup(char *str)
799{ 761{
800 return str; 762 return str;