diff options
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 | 106 |
4 files changed, 36 insertions, 133 deletions
diff --git a/arch/sparc/include/asm/pci_32.h b/arch/sparc/include/asm/pci_32.h index 6de7f7bf956a..dc503297481f 100644 --- a/arch/sparc/include/asm/pci_32.h +++ b/arch/sparc/include/asm/pci_32.h | |||
@@ -52,14 +52,6 @@ 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 | ||
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 | |||
63 | static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) | 55 | static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) |
64 | { | 56 | { |
65 | return PCI_IRQ_NONE; | 57 | return PCI_IRQ_NONE; |
diff --git a/arch/sparc/include/asm/pci_64.h b/arch/sparc/include/asm/pci_64.h index 755a4bb6bcd3..1633b718d3bc 100644 --- a/arch/sparc/include/asm/pci_64.h +++ b/arch/sparc/include/asm/pci_64.h | |||
@@ -73,14 +73,6 @@ 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 | ||
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 | |||
84 | static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) | 76 | static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) |
85 | { | 77 | { |
86 | return PCI_IRQ_NONE; | 78 | return PCI_IRQ_NONE; |
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 | */ |
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 bb8bc2e519ac..fdaf21811670 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c | |||
@@ -375,13 +375,6 @@ static void __devinit apb_calc_first_last(u8 map, u32 *first_p, u32 *last_p) | |||
375 | *last_p = last; | 375 | *last_p = last; |
376 | } | 376 | } |
377 | 377 | ||
378 | static void pci_resource_adjust(struct resource *res, | ||
379 | struct resource *root) | ||
380 | { | ||
381 | res->start += root->start; | ||
382 | res->end += root->start; | ||
383 | } | ||
384 | |||
385 | /* For PCI bus devices which lack a 'ranges' property we interrogate | 378 | /* For PCI bus devices which lack a 'ranges' property we interrogate |
386 | * the config space values to set the resources, just like the generic | 379 | * the config space values to set the resources, just like the generic |
387 | * Linux PCI probing code does. | 380 | * Linux PCI probing code does. |
@@ -390,7 +383,8 @@ static void __devinit pci_cfg_fake_ranges(struct pci_dev *dev, | |||
390 | struct pci_bus *bus, | 383 | struct pci_bus *bus, |
391 | struct pci_pbm_info *pbm) | 384 | struct pci_pbm_info *pbm) |
392 | { | 385 | { |
393 | struct resource *res; | 386 | struct pci_bus_region region; |
387 | struct resource *res, res2; | ||
394 | u8 io_base_lo, io_limit_lo; | 388 | u8 io_base_lo, io_limit_lo; |
395 | u16 mem_base_lo, mem_limit_lo; | 389 | u16 mem_base_lo, mem_limit_lo; |
396 | unsigned long base, limit; | 390 | unsigned long base, limit; |
@@ -412,11 +406,14 @@ static void __devinit pci_cfg_fake_ranges(struct pci_dev *dev, | |||
412 | res = bus->resource[0]; | 406 | res = bus->resource[0]; |
413 | if (base <= limit) { | 407 | if (base <= limit) { |
414 | res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; | 408 | res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; |
409 | res2.flags = res->flags; | ||
410 | region.start = base; | ||
411 | region.end = limit + 0xfff; | ||
412 | pcibios_bus_to_resource(dev, &res2, ®ion); | ||
415 | if (!res->start) | 413 | if (!res->start) |
416 | res->start = base; | 414 | res->start = res2.start; |
417 | if (!res->end) | 415 | if (!res->end) |
418 | res->end = limit + 0xfff; | 416 | res->end = res2.end; |
419 | pci_resource_adjust(res, &pbm->io_space); | ||
420 | } | 417 | } |
421 | 418 | ||
422 | pci_read_config_word(dev, PCI_MEMORY_BASE, &mem_base_lo); | 419 | pci_read_config_word(dev, PCI_MEMORY_BASE, &mem_base_lo); |
@@ -428,9 +425,9 @@ static void __devinit pci_cfg_fake_ranges(struct pci_dev *dev, | |||
428 | if (base <= limit) { | 425 | if (base <= limit) { |
429 | res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | | 426 | res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | |
430 | IORESOURCE_MEM); | 427 | IORESOURCE_MEM); |
431 | res->start = base; | 428 | region.start = base; |
432 | res->end = limit + 0xfffff; | 429 | region.end = limit + 0xfffff; |
433 | pci_resource_adjust(res, &pbm->mem_space); | 430 | pcibios_bus_to_resource(dev, res, ®ion); |
434 | } | 431 | } |
435 | 432 | ||
436 | pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo); | 433 | pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo); |
@@ -459,9 +456,9 @@ static void __devinit pci_cfg_fake_ranges(struct pci_dev *dev, | |||
459 | if (base <= limit) { | 456 | if (base <= limit) { |
460 | res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | | 457 | res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | |
461 | IORESOURCE_MEM | IORESOURCE_PREFETCH); | 458 | IORESOURCE_MEM | IORESOURCE_PREFETCH); |
462 | res->start = base; | 459 | region.start = base; |
463 | res->end = limit + 0xfffff; | 460 | region.end = limit + 0xfffff; |
464 | pci_resource_adjust(res, &pbm->mem_space); | 461 | pcibios_bus_to_resource(dev, res, ®ion); |
465 | } | 462 | } |
466 | } | 463 | } |
467 | 464 | ||
@@ -472,6 +469,7 @@ static void __devinit apb_fake_ranges(struct pci_dev *dev, | |||
472 | struct pci_bus *bus, | 469 | struct pci_bus *bus, |
473 | struct pci_pbm_info *pbm) | 470 | struct pci_pbm_info *pbm) |
474 | { | 471 | { |
472 | struct pci_bus_region region; | ||
475 | struct resource *res; | 473 | struct resource *res; |
476 | u32 first, last; | 474 | u32 first, last; |
477 | u8 map; | 475 | u8 map; |
@@ -479,18 +477,18 @@ static void __devinit apb_fake_ranges(struct pci_dev *dev, | |||
479 | pci_read_config_byte(dev, APB_IO_ADDRESS_MAP, &map); | 477 | pci_read_config_byte(dev, APB_IO_ADDRESS_MAP, &map); |
480 | apb_calc_first_last(map, &first, &last); | 478 | apb_calc_first_last(map, &first, &last); |
481 | res = bus->resource[0]; | 479 | res = bus->resource[0]; |
482 | res->start = (first << 21); | ||
483 | res->end = (last << 21) + ((1 << 21) - 1); | ||
484 | res->flags = IORESOURCE_IO; | 480 | res->flags = IORESOURCE_IO; |
485 | pci_resource_adjust(res, &pbm->io_space); | 481 | region.start = (first << 21); |
482 | region.end = (last << 21) + ((1 << 21) - 1); | ||
483 | pcibios_bus_to_resource(dev, res, ®ion); | ||
486 | 484 | ||
487 | pci_read_config_byte(dev, APB_MEM_ADDRESS_MAP, &map); | 485 | pci_read_config_byte(dev, APB_MEM_ADDRESS_MAP, &map); |
488 | apb_calc_first_last(map, &first, &last); | 486 | apb_calc_first_last(map, &first, &last); |
489 | res = bus->resource[1]; | 487 | res = bus->resource[1]; |
490 | res->start = (first << 21); | ||
491 | res->end = (last << 21) + ((1 << 21) - 1); | ||
492 | res->flags = IORESOURCE_MEM; | 488 | res->flags = IORESOURCE_MEM; |
493 | pci_resource_adjust(res, &pbm->mem_space); | 489 | region.start = (first << 21); |
490 | region.end = (last << 21) + ((1 << 21) - 1); | ||
491 | pcibios_bus_to_resource(dev, res, ®ion); | ||
494 | } | 492 | } |
495 | 493 | ||
496 | static void __devinit pci_of_scan_bus(struct pci_pbm_info *pbm, | 494 | static void __devinit pci_of_scan_bus(struct pci_pbm_info *pbm, |
@@ -506,6 +504,7 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm, | |||
506 | struct pci_bus *bus; | 504 | struct pci_bus *bus; |
507 | const u32 *busrange, *ranges; | 505 | const u32 *busrange, *ranges; |
508 | int len, i, simba; | 506 | int len, i, simba; |
507 | struct pci_bus_region region; | ||
509 | struct resource *res; | 508 | struct resource *res; |
510 | unsigned int flags; | 509 | unsigned int flags; |
511 | u64 size; | 510 | u64 size; |
@@ -556,8 +555,6 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm, | |||
556 | } | 555 | } |
557 | i = 1; | 556 | i = 1; |
558 | for (; len >= 32; len -= 32, ranges += 8) { | 557 | for (; len >= 32; len -= 32, ranges += 8) { |
559 | struct resource *root; | ||
560 | |||
561 | flags = pci_parse_of_flags(ranges[0]); | 558 | flags = pci_parse_of_flags(ranges[0]); |
562 | size = GET_64BIT(ranges, 6); | 559 | size = GET_64BIT(ranges, 6); |
563 | if (flags == 0 || size == 0) | 560 | if (flags == 0 || size == 0) |
@@ -569,7 +566,6 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm, | |||
569 | " for bridge %s\n", node->full_name); | 566 | " for bridge %s\n", node->full_name); |
570 | continue; | 567 | continue; |
571 | } | 568 | } |
572 | root = &pbm->io_space; | ||
573 | } else { | 569 | } else { |
574 | if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) { | 570 | if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) { |
575 | printk(KERN_ERR "PCI: too many memory ranges" | 571 | printk(KERN_ERR "PCI: too many memory ranges" |
@@ -578,18 +574,12 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm, | |||
578 | } | 574 | } |
579 | res = bus->resource[i]; | 575 | res = bus->resource[i]; |
580 | ++i; | 576 | ++i; |
581 | root = &pbm->mem_space; | ||
582 | } | 577 | } |
583 | 578 | ||
584 | res->start = GET_64BIT(ranges, 1); | ||
585 | res->end = res->start + size - 1; | ||
586 | res->flags = flags; | 579 | res->flags = flags; |
587 | 580 | region.start = GET_64BIT(ranges, 1); | |
588 | /* Another way to implement this would be to add an of_device | 581 | region.end = region.start + size - 1; |
589 | * layer routine that can calculate a resource for a given | 582 | pcibios_bus_to_resource(dev, res, ®ion); |
590 | * range property value in a PCI device. | ||
591 | */ | ||
592 | pci_resource_adjust(res, root); | ||
593 | } | 583 | } |
594 | after_ranges: | 584 | after_ranges: |
595 | sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), | 585 | sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), |
@@ -691,8 +681,10 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm, | |||
691 | 681 | ||
692 | printk("PCI: Scanning PBM %s\n", node->full_name); | 682 | printk("PCI: Scanning PBM %s\n", node->full_name); |
693 | 683 | ||
694 | pci_add_resource(&resources, &pbm->io_space); | 684 | pci_add_resource_offset(&resources, &pbm->io_space, |
695 | pci_add_resource(&resources, &pbm->mem_space); | 685 | pbm->io_space.start); |
686 | pci_add_resource_offset(&resources, &pbm->mem_space, | ||
687 | pbm->mem_space.start); | ||
696 | bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, | 688 | bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, |
697 | pbm, &resources); | 689 | pbm, &resources); |
698 | if (!bus) { | 690 | if (!bus) { |
@@ -755,46 +747,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) | |||
755 | return 0; | 747 | return 0; |
756 | } | 748 | } |
757 | 749 | ||
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) | 750 | char * __devinit pcibios_setup(char *str) |
799 | { | 751 | { |
800 | return str; | 752 | return str; |