diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2012-02-23 22:19:04 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-02-23 22:19:04 -0500 |
commit | ac1edcc579b6554211221ee5eeac7dfc15a6da17 (patch) | |
tree | fff5aa13f8f046d0cc5564e8da013491993f8758 /arch/sparc | |
parent | 7fa6a50eb3625638d5c8fec6187d3da9d1733dca (diff) |
sparc/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.
N.B. Leon apparently never uses initial BAR values, so it didn't matter
that we never fixed up the I/O resources from bus address to CPU addresses.
Other sparc uses pci_of_scan_bus(), which sets device resources directly
to CPU addresses, not bus addresses, so it didn't need pcibios_fixup_bus()
either. But by telling the core about the offsets, we can nuke
pcibios_resource_to_bus().
CC: "David S. Miller" <davem@davemloft.net>
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/include/asm/pci_32.h | 8 | ||||
-rw-r--r-- | arch/sparc/include/asm/pci_64.h | 8 | ||||
-rw-r--r-- | arch/sparc/kernel/leon_pci.c | 47 | ||||
-rw-r--r-- | arch/sparc/kernel/pci.c | 46 |
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 6de7f7bf956..6384f30429b 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 | ||
55 | extern void | 55 | #define ARCH_HAS_GENERIC_PCI_OFFSETS |
56 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | ||
57 | struct resource *res); | ||
58 | |||
59 | extern void | ||
60 | pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
61 | struct pci_bus_region *region); | ||
62 | 56 | ||
63 | static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) | 57 | static 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 755a4bb6bcd..2918bd12c19 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 | ||
76 | extern void | 76 | #define ARCH_HAS_GENERIC_PCI_OFFSETS |
77 | pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | ||
78 | struct resource *res); | ||
79 | |||
80 | extern void | ||
81 | pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | ||
82 | struct pci_bus_region *region); | ||
83 | 77 | ||
84 | static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) | 78 | static 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 c7bec25fdb1..aba6b958b2a 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 | */ |
20 | void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) | 24 | void 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 | */ | ||
48 | void 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 | } | ||
61 | EXPORT_SYMBOL(pcibios_resource_to_bus); | ||
62 | |||
63 | /* see pcibios_resource_to_bus() comment */ | ||
64 | void 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 | } | ||
77 | EXPORT_SYMBOL(pcibios_bus_to_resource); | ||
78 | |||
79 | void __devinit pcibios_fixup_bus(struct pci_bus *pbus) | 46 | void __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 bb8bc2e519a..253e8ac2783 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 | ||
758 | void 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 | } | ||
778 | EXPORT_SYMBOL(pcibios_resource_to_bus); | ||
779 | |||
780 | void 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 | } | ||
796 | EXPORT_SYMBOL(pcibios_bus_to_resource); | ||
797 | |||
798 | char * __devinit pcibios_setup(char *str) | 760 | char * __devinit pcibios_setup(char *str) |
799 | { | 761 | { |
800 | return str; | 762 | return str; |