diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-03-09 00:55:49 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 04:55:11 -0400 |
commit | 9fd8b64761d3fe7e4ef567161be57e4234af5c1c (patch) | |
tree | 39eb4744d6f36c003bb4e9fea77c7c9921bbef2b /arch/sparc64/kernel/pci_sun4v.c | |
parent | 01f94c4a6ced476ce69b895426fc29bfc48c69bd (diff) |
[SPARC64]: Consolidate PCI mem/io resource determination.
It can be done for every PCI configuration using OF properties.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/pci_sun4v.c')
-rw-r--r-- | arch/sparc64/kernel/pci_sun4v.c | 71 |
1 files changed, 2 insertions, 69 deletions
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c index eec7def379dc..e1af009617cf 100644 --- a/arch/sparc64/kernel/pci_sun4v.c +++ b/arch/sparc64/kernel/pci_sun4v.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* pci_sun4v.c: SUN4V specific PCI controller support. | 1 | /* pci_sun4v.c: SUN4V specific PCI controller support. |
2 | * | 2 | * |
3 | * Copyright (C) 2006 David S. Miller (davem@davemloft.net) | 3 | * Copyright (C) 2006, 2007 David S. Miller (davem@davemloft.net) |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
@@ -751,72 +751,6 @@ static void pci_sun4v_resource_adjust(struct pci_dev *pdev, | |||
751 | res->end += root->start; | 751 | res->end += root->start; |
752 | } | 752 | } |
753 | 753 | ||
754 | /* Use ranges property to determine where PCI MEM, I/O, and Config | ||
755 | * space are for this PCI bus module. | ||
756 | */ | ||
757 | static void pci_sun4v_determine_mem_io_space(struct pci_pbm_info *pbm) | ||
758 | { | ||
759 | int i, saw_mem, saw_io; | ||
760 | |||
761 | saw_mem = saw_io = 0; | ||
762 | for (i = 0; i < pbm->num_pbm_ranges; i++) { | ||
763 | struct linux_prom_pci_ranges *pr = &pbm->pbm_ranges[i]; | ||
764 | unsigned long a; | ||
765 | int type; | ||
766 | |||
767 | type = (pr->child_phys_hi >> 24) & 0x3; | ||
768 | a = (((unsigned long)pr->parent_phys_hi << 32UL) | | ||
769 | ((unsigned long)pr->parent_phys_lo << 0UL)); | ||
770 | |||
771 | switch (type) { | ||
772 | case 1: | ||
773 | /* 16-bit IO space, 16MB */ | ||
774 | pbm->io_space.start = a; | ||
775 | pbm->io_space.end = a + ((16UL*1024UL*1024UL) - 1UL); | ||
776 | pbm->io_space.flags = IORESOURCE_IO; | ||
777 | saw_io = 1; | ||
778 | break; | ||
779 | |||
780 | case 2: | ||
781 | /* 32-bit MEM space, 2GB */ | ||
782 | pbm->mem_space.start = a; | ||
783 | pbm->mem_space.end = a + (0x80000000UL - 1UL); | ||
784 | pbm->mem_space.flags = IORESOURCE_MEM; | ||
785 | saw_mem = 1; | ||
786 | break; | ||
787 | |||
788 | case 3: | ||
789 | /* XXX 64-bit MEM handling XXX */ | ||
790 | |||
791 | default: | ||
792 | break; | ||
793 | }; | ||
794 | } | ||
795 | |||
796 | if (!saw_io || !saw_mem) { | ||
797 | prom_printf("%s: Fatal error, missing %s PBM range.\n", | ||
798 | pbm->name, | ||
799 | (!saw_io ? "IO" : "MEM")); | ||
800 | prom_halt(); | ||
801 | } | ||
802 | |||
803 | printk("%s: PCI IO[%lx] MEM[%lx]\n", | ||
804 | pbm->name, | ||
805 | pbm->io_space.start, | ||
806 | pbm->mem_space.start); | ||
807 | } | ||
808 | |||
809 | static void pbm_register_toplevel_resources(struct pci_controller_info *p, | ||
810 | struct pci_pbm_info *pbm) | ||
811 | { | ||
812 | pbm->io_space.name = pbm->mem_space.name = pbm->name; | ||
813 | |||
814 | request_resource(&ioport_resource, &pbm->io_space); | ||
815 | request_resource(&iomem_resource, &pbm->mem_space); | ||
816 | pci_register_legacy_regions(&pbm->io_space, | ||
817 | &pbm->mem_space); | ||
818 | } | ||
819 | |||
820 | static unsigned long probe_existing_entries(struct pci_pbm_info *pbm, | 754 | static unsigned long probe_existing_entries(struct pci_pbm_info *pbm, |
821 | struct pci_iommu *iommu) | 755 | struct pci_iommu *iommu) |
822 | { | 756 | { |
@@ -1396,8 +1330,7 @@ static void pci_sun4v_pbm_init(struct pci_controller_info *p, struct device_node | |||
1396 | for (i = 0; i < pbm->num_pbm_ranges; i++) | 1330 | for (i = 0; i < pbm->num_pbm_ranges; i++) |
1397 | pbm->pbm_ranges[i].parent_phys_hi &= 0x0fffffff; | 1331 | pbm->pbm_ranges[i].parent_phys_hi &= 0x0fffffff; |
1398 | 1332 | ||
1399 | pci_sun4v_determine_mem_io_space(pbm); | 1333 | pci_determine_mem_io_space(pbm); |
1400 | pbm_register_toplevel_resources(p, pbm); | ||
1401 | 1334 | ||
1402 | prop = of_find_property(dp, "interrupt-map", &len); | 1335 | prop = of_find_property(dp, "interrupt-map", &len); |
1403 | pbm->pbm_intmap = prop->value; | 1336 | pbm->pbm_intmap = prop->value; |