Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Start merging 64-bit support into powermac files

Signed-off-by: Paul Mackerras <paulus@samba.org>

+128 -143
+85 -109
arch/powerpc/platforms/powermac/pci.c
··· 1 1 /* 2 2 * Support for PCI bridges found on Power Macintoshes. 3 - * At present the "bandit" and "chaos" bridges are supported. 4 - * Fortunately you access configuration space in the same 5 - * way with either bridge. 6 3 * 7 4 * Copyright (C) 2003 Benjamin Herrenschmuidt (benh@kernel.crashing.org) 8 5 * Copyright (C) 1997 Paul Mackerras (paulus@samba.org) ··· 23 26 #include <asm/pci-bridge.h> 24 27 #include <asm/machdep.h> 25 28 #include <asm/pmac_feature.h> 29 + #ifdef CONFIG_PPC64 30 + #include <asm/iommu.h> 31 + #include <asm/ppc-pci.h> 32 + #endif 26 33 27 34 #undef DEBUG 28 35 ··· 161 160 static int macrisc_read_config(struct pci_bus *bus, unsigned int devfn, 162 161 int offset, int len, u32 *val) 163 162 { 164 - struct pci_controller *hose = bus->sysdata; 163 + struct pci_controller *hose; 165 164 unsigned long addr; 165 + 166 + hose = pci_bus_to_host(bus); 167 + if (hose == NULL) 168 + return PCIBIOS_DEVICE_NOT_FOUND; 166 169 167 170 addr = macrisc_cfg_access(hose, bus->number, devfn, offset); 168 171 if (!addr) ··· 192 187 static int macrisc_write_config(struct pci_bus *bus, unsigned int devfn, 193 188 int offset, int len, u32 val) 194 189 { 195 - struct pci_controller *hose = bus->sysdata; 190 + struct pci_controller *hose; 196 191 unsigned long addr; 192 + 193 + hose = pci_bus_to_host(bus); 194 + if (hose == NULL) 195 + return PCIBIOS_DEVICE_NOT_FOUND; 197 196 198 197 addr = macrisc_cfg_access(hose, bus->number, devfn, offset); 199 198 if (!addr) ··· 230 221 }; 231 222 232 223 /* 233 - * Verifiy that a specific (bus, dev_fn) exists on chaos 224 + * Verify that a specific (bus, dev_fn) exists on chaos 234 225 */ 235 226 static int 236 227 chaos_validate_dev(struct pci_bus *bus, int devfn, int offset) ··· 283 274 }; 284 275 285 276 #ifdef CONFIG_POWER4 286 - 287 277 /* 288 278 * These versions of U3 HyperTransport config space access ops do not 289 279 * implement self-view of the HT host yet ··· 350 342 static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn, 351 343 int offset, int len, u32 *val) 352 344 { 353 - struct pci_controller *hose = bus->sysdata; 345 + struct pci_controller *hose; 354 346 unsigned long addr; 355 347 356 - struct device_node *np = pci_busdev_to_OF_node(bus, devfn); 357 - if (np == NULL) 348 + hose = pci_bus_to_host(bus); 349 + if (hose == NULL) 358 350 return PCIBIOS_DEVICE_NOT_FOUND; 359 351 360 352 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset); ··· 365 357 case 0: 366 358 break; 367 359 case 1: 368 - switch (len) { 369 - case 1: 370 - *val = 0xff; break; 371 - case 2: 372 - *val = 0xffff; break; 373 - default: 374 - *val = 0xfffffffful; break; 375 - } 376 - return PCIBIOS_SUCCESSFUL; 360 + switch (len) { 361 + case 1: 362 + *val = 0xff; break; 363 + case 2: 364 + *val = 0xffff; break; 365 + default: 366 + *val = 0xfffffffful; break; 367 + } 368 + return PCIBIOS_SUCCESSFUL; 377 369 default: 378 370 return PCIBIOS_DEVICE_NOT_FOUND; 379 - } 380 - 371 + } 372 + 381 373 /* 382 374 * Note: the caller has already checked that offset is 383 375 * suitably aligned and that len is 1, 2 or 4. ··· 399 391 static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn, 400 392 int offset, int len, u32 val) 401 393 { 402 - struct pci_controller *hose = bus->sysdata; 394 + struct pci_controller *hose; 403 395 unsigned long addr; 404 396 405 - struct device_node *np = pci_busdev_to_OF_node(bus, devfn); 406 - if (np == NULL) 397 + hose = pci_bus_to_host(bus); 398 + if (hose == NULL) 407 399 return PCIBIOS_DEVICE_NOT_FOUND; 408 400 409 401 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset); ··· 445 437 u3_ht_read_config, 446 438 u3_ht_write_config 447 439 }; 448 - 449 440 #endif /* CONFIG_POWER4 */ 450 441 451 442 /* 452 443 * For a bandit bridge, turn on cache coherency if necessary. 453 444 * N.B. we could clean this up using the hose ops directly. 454 445 */ 455 - static void __init 456 - init_bandit(struct pci_controller *bp) 446 + static void __init init_bandit(struct pci_controller *bp) 457 447 { 458 448 unsigned int vendev, magic; 459 449 int rev; ··· 491 485 /* 492 486 * Tweak the PCI-PCI bridge chip on the blue & white G3s. 493 487 */ 494 - static void __init 495 - init_p2pbridge(void) 488 + static void __init init_p2pbridge(void) 496 489 { 497 490 struct device_node *p2pbridge; 498 491 struct pci_controller* hose; ··· 531 526 * EHCI part of it so it behaves like a pair of OHCI's. This fixup 532 527 * code re-enables it ;) 533 528 */ 534 - static void __init 535 - fixup_nec_usb2(void) 529 + static void __init fixup_nec_usb2(void) 536 530 { 537 531 struct device_node *nec; 538 532 ··· 569 565 nec->intrs[0].line); 570 566 } 571 567 } 572 - } 573 - 574 - void __init 575 - pmac_find_bridges(void) 576 - { 577 - struct device_node *np, *root; 578 - struct device_node *ht = NULL; 579 - 580 - root = of_find_node_by_path("/"); 581 - if (root == NULL) { 582 - printk(KERN_CRIT "pmac_find_bridges: can't find root of device tree\n"); 583 - return; 584 - } 585 - for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) { 586 - if (np->name == NULL) 587 - continue; 588 - if (strcmp(np->name, "bandit") == 0 589 - || strcmp(np->name, "chaos") == 0 590 - || strcmp(np->name, "pci") == 0) { 591 - if (add_bridge(np) == 0) 592 - of_node_get(np); 593 - } 594 - if (strcmp(np->name, "ht") == 0) { 595 - of_node_get(np); 596 - ht = np; 597 - } 598 - } 599 - of_node_put(root); 600 - 601 - /* Probe HT last as it relies on the agp resources to be already 602 - * setup 603 - */ 604 - if (ht && add_bridge(ht) != 0) 605 - of_node_put(ht); 606 - 607 - init_p2pbridge(); 608 - fixup_nec_usb2(); 609 - 610 - /* We are still having some issues with the Xserve G4, enabling 611 - * some offset between bus number and domains for now when we 612 - * assign all busses should help for now 613 - */ 614 - if (pci_assign_all_busses) 615 - pcibios_assign_bus_offset = 0x10; 616 - 617 - #ifdef CONFIG_POWER4 618 - /* There is something wrong with DMA on U3/HT. I haven't figured out 619 - * the details yet, but if I set the cache line size to 128 bytes like 620 - * it should, I'm getting memory corruption caused by devices like 621 - * sungem (even without the MWI bit set, but maybe sungem doesn't 622 - * care). Right now, it appears that setting up a 64 bytes line size 623 - * works properly, 64 bytes beeing the max transfer size of HT, I 624 - * suppose this is related the way HT/PCI are hooked together. I still 625 - * need to dive into more specs though to be really sure of what's 626 - * going on. --BenH. 627 - * 628 - * Ok, apparently, it's just that HT can't do more than 64 bytes 629 - * transactions. MWI seem to be meaningless there as well, it may 630 - * be worth nop'ing out pci_set_mwi too though I haven't done that 631 - * yet. 632 - * 633 - * Note that it's a bit different for whatever is in the AGP slot. 634 - * For now, I don't care, but this can become a real issue, we 635 - * should probably hook pci_set_mwi anyway to make sure it sets 636 - * the real cache line size in there. 637 - */ 638 - if (machine_is_compatible("MacRISC4")) 639 - pci_cache_line_size = 16; /* 64 bytes */ 640 - 641 - pmac_check_ht_link(); 642 - #endif /* CONFIG_POWER4 */ 643 568 } 644 569 645 570 #define GRACKLE_CFA(b, d, o) (0x80 | ((b) << 8) | ((d) << 16) \ ··· 636 703 } 637 704 638 705 #ifdef CONFIG_POWER4 639 - 640 706 static void __init setup_u3_agp(struct pci_controller* hose) 641 707 { 642 708 /* On G5, we move AGP up to high bus number so we don't need ··· 647 715 * the reg address cell, we shall fix that by killing struct 648 716 * reg_property and using some accessor functions instead 649 717 */ 650 - hose->first_busno = 0xf0; 718 + hose->first_busno = 0xf0; 651 719 hose->last_busno = 0xff; 652 720 has_uninorth = 1; 653 721 hose->ops = &macrisc_pci_ops; ··· 680 748 */ 681 749 hose->io_base_phys = 0xf4000000; 682 750 hose->io_base_virt = ioremap(hose->io_base_phys, 0x00400000); 683 - isa_io_base = (unsigned long) hose->io_base_virt; 751 + isa_io_base = pci_io_base = (unsigned long) hose->io_base_virt; 684 752 hose->io_resource.name = np->full_name; 685 753 hose->io_resource.start = 0; 686 754 hose->io_resource.end = 0x003fffff; ··· 726 794 } 727 795 /* No, it's not the case, we need a hole */ 728 796 if (cur == 2) { 729 - /* not enough resources to make a hole, we drop part of the range */ 797 + /* not enough resources for a hole, we drop part of the range */ 730 798 printk(KERN_WARNING "Running out of resources for /ht host !\n"); 731 799 hose->mem_resources[cur].end = res->start - 1; 732 800 continue; 733 801 } 734 802 cur++; 735 - DBG("U3/HT: hole, %d end at %08lx, %d start at %08lx\n", 803 + DBG("U3/HT: hole, %d end at %08lx, %d start at %08lx\n", 736 804 cur-1, res->start - 1, cur, res->end + 1); 737 805 hose->mem_resources[cur].name = np->full_name; 738 806 hose->mem_resources[cur].flags = IORESOURCE_MEM; ··· 913 981 if (device_is_compatible(dev, "uni-north")) { 914 982 primary = setup_uninorth(hose, addr); 915 983 disp_name = "UniNorth"; 916 - } else if (strcmp(dev->name, "pci") == 0) { 984 + } else if (strcmp(dev->name, "pci") == 0) { 917 985 /* XXX assume this is a mpc106 (grackle) */ 918 986 setup_grackle(hose); 919 987 disp_name = "Grackle (MPC106)"; ··· 925 993 disp_name = "Chaos"; 926 994 primary = 0; 927 995 } 928 - printk(KERN_INFO "Found %s PCI host bridge at 0x%08x. Firmware bus number: %d->%d\n", 996 + printk(KERN_INFO "Found %s PCI host bridge at 0x%08lx. Firmware bus number: %d->%d\n", 929 997 disp_name, addr->address, hose->first_busno, hose->last_busno); 930 998 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n", 931 999 hose, hose->cfg_addr, hose->cfg_data); ··· 966 1034 { 967 1035 /* Fixup interrupts according to OF tree */ 968 1036 pcibios_fixup_OF_interrupts(); 1037 + } 1038 + 1039 + void __init pmac_find_bridges(void) 1040 + { 1041 + struct device_node *np, *root; 1042 + struct device_node *ht = NULL; 1043 + 1044 + root = of_find_node_by_path("/"); 1045 + if (root == NULL) { 1046 + printk(KERN_CRIT "pmac_find_bridges: can't find root of device tree\n"); 1047 + return; 1048 + } 1049 + for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) { 1050 + if (np->name == NULL) 1051 + continue; 1052 + if (strcmp(np->name, "bandit") == 0 1053 + || strcmp(np->name, "chaos") == 0 1054 + || strcmp(np->name, "pci") == 0) { 1055 + if (add_bridge(np) == 0) 1056 + of_node_get(np); 1057 + } 1058 + if (strcmp(np->name, "ht") == 0) { 1059 + of_node_get(np); 1060 + ht = np; 1061 + } 1062 + } 1063 + of_node_put(root); 1064 + 1065 + /* Probe HT last as it relies on the agp resources to be already 1066 + * setup 1067 + */ 1068 + if (ht && add_bridge(ht) != 0) 1069 + of_node_put(ht); 1070 + 1071 + init_p2pbridge(); 1072 + fixup_nec_usb2(); 1073 + 1074 + /* We are still having some issues with the Xserve G4, enabling 1075 + * some offset between bus number and domains for now when we 1076 + * assign all busses should help for now 1077 + */ 1078 + if (pci_assign_all_busses) 1079 + pcibios_assign_bus_offset = 0x10; 1080 + 969 1081 } 970 1082 971 1083 int
+21 -11
arch/powerpc/platforms/powermac/pic.c
··· 25 25 #include <linux/sysdev.h> 26 26 #include <linux/adb.h> 27 27 #include <linux/pmu.h> 28 + #include <linux/module.h> 28 29 29 30 #include <asm/sections.h> 30 31 #include <asm/io.h> ··· 33 32 #include <asm/prom.h> 34 33 #include <asm/pci-bridge.h> 35 34 #include <asm/time.h> 36 - #include <asm/open_pic.h> 37 35 #include <asm/xmon.h> 38 36 #include <asm/pmac_feature.h> 39 37 #include <asm/mpic.h> 40 38 41 - #include "pmac_pic.h" 39 + #include "pmac.h" 42 40 43 41 /* 44 42 * XXX this should be in xmon.h, but putting it there means xmon.h ··· 46 46 */ 47 47 extern irqreturn_t xmon_irq(int, void *, struct pt_regs *); 48 48 49 + #ifdef CONFIG_PPC32 49 50 struct pmac_irq_hw { 50 51 unsigned int event; 51 52 unsigned int enable; ··· 72 71 73 72 static DEFINE_SPINLOCK(pmac_pic_lock); 74 73 74 + /* XXX here for now, should move to arch/powerpc/kernel/irq.c */ 75 + int ppc_do_canonicalize_irqs; 76 + EXPORT_SYMBOL(ppc_do_canonicalize_irqs); 75 77 76 78 #define GATWICK_IRQ_POOL_SIZE 10 77 79 static struct interrupt_info gatwick_int_pool[GATWICK_IRQ_POOL_SIZE]; ··· 381 377 return irqctrler->intrs[0].line; 382 378 } 383 379 384 - static int pmac_u3_cascade(struct pt_regs *regs, void *data) 385 - { 386 - return mpic_get_one_irq((struct mpic *)data, regs); 387 - } 388 - 389 380 #ifdef CONFIG_XMON 390 381 static struct irqaction xmon_action = { 391 382 .handler = xmon_irq, ··· 396 397 .mask = CPU_MASK_NONE, 397 398 .name = "cascade", 398 399 }; 400 + #endif /* CONFIG_PPC32 */ 401 + 402 + static int pmac_u3_cascade(struct pt_regs *regs, void *data) 403 + { 404 + return mpic_get_one_irq((struct mpic *)data, regs); 405 + } 399 406 400 407 void __init pmac_pic_init(void) 401 408 { 402 - int i; 403 409 struct device_node *irqctrler = NULL; 404 410 struct device_node *irqctrler2 = NULL; 405 411 struct device_node *np; 412 + #ifdef CONFIG_PPC32 413 + int i; 406 414 unsigned long addr; 407 415 int irq_cascade = -1; 416 + #endif 408 417 struct mpic *mpic1, *mpic2; 409 418 410 419 /* We first try to detect Apple's new Core99 chipset, since mac-io ··· 462 455 mpic_setup_cascade(irqctrler2->intrs[0].line, 463 456 pmac_u3_cascade, mpic2); 464 457 } 465 - #ifdef CONFIG_XMON 458 + #if defined(CONFIG_XMON) && defined(CONFIG_PPC32) 466 459 { 467 460 struct device_node* pswitch; 468 461 int nmi_irq; ··· 470 463 pswitch = find_devices("programmer-switch"); 471 464 if (pswitch && pswitch->n_intrs) { 472 465 nmi_irq = pswitch->intrs[0].line; 473 - openpic_init_nmi_irq(nmi_irq); 466 + mpic_irq_set_priority(nmi_irq, 9); 474 467 setup_irq(nmi_irq, &xmon_action); 475 468 } 476 469 } ··· 479 472 } 480 473 irqctrler = NULL; 481 474 475 + #ifdef CONFIG_PPC32 482 476 /* Get the level/edge settings, assume if it's not 483 477 * a Grand Central nor an OHare, then it's an Heathrow 484 478 * (or Paddington). ··· 578 570 #ifdef CONFIG_XMON 579 571 setup_irq(20, &xmon_action); 580 572 #endif /* CONFIG_XMON */ 573 + #endif /* CONFIG_PPC32 */ 581 574 } 582 575 583 576 #ifdef CONFIG_PM ··· 668 659 669 660 static int __init init_pmacpic_sysfs(void) 670 661 { 662 + #ifdef CONFIG_PPC32 671 663 if (max_irqs == 0) 672 664 return -ENODEV; 673 - 665 + #endif 674 666 printk(KERN_DEBUG "Registering pmac pic with sysfs...\n"); 675 667 sysdev_class_register(&pmacpic_sysclass); 676 668 sysdev_register(&device_pmacpic);
+21 -4
arch/powerpc/platforms/powermac/pmac.h
··· 3 3 4 4 #include <linux/pci.h> 5 5 #include <linux/ide.h> 6 + #include <linux/irq.h> 6 7 7 8 /* 8 9 * Declaration for the various functions exported by the 9 10 * pmac_* files. Mostly for use by pmac_setup 10 11 */ 11 12 12 - extern void pmac_get_boot_time(struct rtc_time *tm); 13 - extern void pmac_get_rtc_time(struct rtc_time *tm); 14 - extern int pmac_set_rtc_time(struct rtc_time *tm); 13 + extern long pmac_time_init(void); 14 + extern unsigned long pmac_get_rtc_time(void); 15 + extern int pmac_set_rtc_time(unsigned long nowtime); 15 16 extern void pmac_read_rtc_time(void); 16 17 extern void pmac_calibrate_decr(void); 17 - 18 18 extern void pmac_pcibios_fixup(void); 19 + extern void pmac_find_bridges(void); 20 + extern unsigned long pmac_ide_get_base(int index); 21 + extern void pmac_ide_init_hwif_ports(hw_regs_t *hw, 22 + unsigned long data_port, unsigned long ctrl_port, int *irq); 23 + 24 + extern void pmac_nvram_update(void); 25 + extern unsigned char pmac_nvram_read_byte(int addr); 26 + extern void pmac_nvram_write_byte(int addr, unsigned char val); 27 + extern int pmac_pci_enable_device_hook(struct pci_dev *dev, int initial); 28 + extern void pmac_pcibios_after_init(void); 29 + extern int of_show_percpuinfo(struct seq_file *m, int i); 30 + 19 31 extern void pmac_pci_init(void); 20 32 extern void pmac_setup_pci_dma(void); 21 33 extern void pmac_check_ht_link(void); ··· 39 27 unsigned long data_port, unsigned long ctrl_port, int *irq); 40 28 41 29 extern void pmac_nvram_init(void); 30 + 31 + extern struct hw_interrupt_type pmac_pic; 32 + 33 + void pmac_pic_init(void); 34 + int pmac_get_irq(struct pt_regs *regs); 42 35 43 36 #endif /* __PMAC_H__ */
+1 -19
arch/powerpc/platforms/powermac/setup.c
··· 73 73 #include <asm/of_device.h> 74 74 #include <asm/mmu_context.h> 75 75 76 - #include "pmac_pic.h" 76 + #include "pmac.h" 77 77 78 78 #undef SHOW_GATWICK_IRQS 79 - 80 - extern long pmac_time_init(void); 81 - extern unsigned long pmac_get_rtc_time(void); 82 - extern int pmac_set_rtc_time(unsigned long nowtime); 83 - extern void pmac_read_rtc_time(void); 84 - extern void pmac_calibrate_decr(void); 85 - extern void pmac_pcibios_fixup(void); 86 - extern void pmac_find_bridges(void); 87 - extern unsigned long pmac_ide_get_base(int index); 88 - extern void pmac_ide_init_hwif_ports(hw_regs_t *hw, 89 - unsigned long data_port, unsigned long ctrl_port, int *irq); 90 - 91 - extern void pmac_nvram_update(void); 92 - extern unsigned char pmac_nvram_read_byte(int addr); 93 - extern void pmac_nvram_write_byte(int addr, unsigned char val); 94 - extern int pmac_pci_enable_device_hook(struct pci_dev *dev, int initial); 95 - extern void pmac_pcibios_after_init(void); 96 - extern int of_show_percpuinfo(struct seq_file *m, int i); 97 79 98 80 unsigned char drive_info; 99 81