···11/*22 * Support for PCI bridges found on Power Macintoshes.33- * At present the "bandit" and "chaos" bridges are supported.44- * Fortunately you access configuration space in the same55- * way with either bridge.63 *74 * Copyright (C) 2003 Benjamin Herrenschmuidt (benh@kernel.crashing.org)85 * Copyright (C) 1997 Paul Mackerras (paulus@samba.org)···2326#include <asm/pci-bridge.h>2427#include <asm/machdep.h>2528#include <asm/pmac_feature.h>2929+#ifdef CONFIG_PPC643030+#include <asm/iommu.h>3131+#include <asm/ppc-pci.h>3232+#endif26332734#undef DEBUG2835···161160static int macrisc_read_config(struct pci_bus *bus, unsigned int devfn,162161 int offset, int len, u32 *val)163162{164164- struct pci_controller *hose = bus->sysdata;163163+ struct pci_controller *hose;165164 unsigned long addr;165165+166166+ hose = pci_bus_to_host(bus);167167+ if (hose == NULL)168168+ return PCIBIOS_DEVICE_NOT_FOUND;166169167170 addr = macrisc_cfg_access(hose, bus->number, devfn, offset);168171 if (!addr)···192187static int macrisc_write_config(struct pci_bus *bus, unsigned int devfn,193188 int offset, int len, u32 val)194189{195195- struct pci_controller *hose = bus->sysdata;190190+ struct pci_controller *hose;196191 unsigned long addr;192192+193193+ hose = pci_bus_to_host(bus);194194+ if (hose == NULL)195195+ return PCIBIOS_DEVICE_NOT_FOUND;197196198197 addr = macrisc_cfg_access(hose, bus->number, devfn, offset);199198 if (!addr)···230221};231222232223/*233233- * Verifiy that a specific (bus, dev_fn) exists on chaos224224+ * Verify that a specific (bus, dev_fn) exists on chaos234225 */235226static int236227chaos_validate_dev(struct pci_bus *bus, int devfn, int offset)···283274};284275285276#ifdef CONFIG_POWER4286286-287277/*288278 * These versions of U3 HyperTransport config space access ops do not289279 * implement self-view of the HT host yet···350342static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,351343 int offset, int len, u32 *val)352344{353353- struct pci_controller *hose = bus->sysdata;345345+ struct pci_controller *hose;354346 unsigned long addr;355347356356- struct device_node *np = pci_busdev_to_OF_node(bus, devfn);357357- if (np == NULL)348348+ hose = pci_bus_to_host(bus);349349+ if (hose == NULL)358350 return PCIBIOS_DEVICE_NOT_FOUND;359351360352 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);···365357 case 0:366358 break;367359 case 1:368368- switch (len) {369369- case 1:370370- *val = 0xff; break;371371- case 2:372372- *val = 0xffff; break;373373- default:374374- *val = 0xfffffffful; break;375375- }376376- return PCIBIOS_SUCCESSFUL;360360+ switch (len) {361361+ case 1:362362+ *val = 0xff; break;363363+ case 2:364364+ *val = 0xffff; break;365365+ default:366366+ *val = 0xfffffffful; break;367367+ }368368+ return PCIBIOS_SUCCESSFUL;377369 default:378370 return PCIBIOS_DEVICE_NOT_FOUND;379379- }380380-371371+ }372372+381373 /*382374 * Note: the caller has already checked that offset is383375 * suitably aligned and that len is 1, 2 or 4.···399391static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn,400392 int offset, int len, u32 val)401393{402402- struct pci_controller *hose = bus->sysdata;394394+ struct pci_controller *hose;403395 unsigned long addr;404396405405- struct device_node *np = pci_busdev_to_OF_node(bus, devfn);406406- if (np == NULL)397397+ hose = pci_bus_to_host(bus);398398+ if (hose == NULL)407399 return PCIBIOS_DEVICE_NOT_FOUND;408400409401 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);···445437 u3_ht_read_config,446438 u3_ht_write_config447439};448448-449440#endif /* CONFIG_POWER4 */450441451442/*452443 * For a bandit bridge, turn on cache coherency if necessary.453444 * N.B. we could clean this up using the hose ops directly.454445 */455455-static void __init456456-init_bandit(struct pci_controller *bp)446446+static void __init init_bandit(struct pci_controller *bp)457447{458448 unsigned int vendev, magic;459449 int rev;···491485/*492486 * Tweak the PCI-PCI bridge chip on the blue & white G3s.493487 */494494-static void __init495495-init_p2pbridge(void)488488+static void __init init_p2pbridge(void)496489{497490 struct device_node *p2pbridge;498491 struct pci_controller* hose;···531526 * EHCI part of it so it behaves like a pair of OHCI's. This fixup532527 * code re-enables it ;)533528 */534534-static void __init535535-fixup_nec_usb2(void)529529+static void __init fixup_nec_usb2(void)536530{537531 struct device_node *nec;538532···569565 nec->intrs[0].line);570566 }571567 }572572-}573573-574574-void __init575575-pmac_find_bridges(void)576576-{577577- struct device_node *np, *root;578578- struct device_node *ht = NULL;579579-580580- root = of_find_node_by_path("/");581581- if (root == NULL) {582582- printk(KERN_CRIT "pmac_find_bridges: can't find root of device tree\n");583583- return;584584- }585585- for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) {586586- if (np->name == NULL)587587- continue;588588- if (strcmp(np->name, "bandit") == 0589589- || strcmp(np->name, "chaos") == 0590590- || strcmp(np->name, "pci") == 0) {591591- if (add_bridge(np) == 0)592592- of_node_get(np);593593- }594594- if (strcmp(np->name, "ht") == 0) {595595- of_node_get(np);596596- ht = np;597597- }598598- }599599- of_node_put(root);600600-601601- /* Probe HT last as it relies on the agp resources to be already602602- * setup603603- */604604- if (ht && add_bridge(ht) != 0)605605- of_node_put(ht);606606-607607- init_p2pbridge();608608- fixup_nec_usb2();609609-610610- /* We are still having some issues with the Xserve G4, enabling611611- * some offset between bus number and domains for now when we612612- * assign all busses should help for now613613- */614614- if (pci_assign_all_busses)615615- pcibios_assign_bus_offset = 0x10;616616-617617-#ifdef CONFIG_POWER4 618618- /* There is something wrong with DMA on U3/HT. I haven't figured out619619- * the details yet, but if I set the cache line size to 128 bytes like620620- * it should, I'm getting memory corruption caused by devices like621621- * sungem (even without the MWI bit set, but maybe sungem doesn't622622- * care). Right now, it appears that setting up a 64 bytes line size623623- * works properly, 64 bytes beeing the max transfer size of HT, I624624- * suppose this is related the way HT/PCI are hooked together. I still625625- * need to dive into more specs though to be really sure of what's626626- * going on. --BenH.627627- *628628- * Ok, apparently, it's just that HT can't do more than 64 bytes629629- * transactions. MWI seem to be meaningless there as well, it may630630- * be worth nop'ing out pci_set_mwi too though I haven't done that631631- * yet.632632- *633633- * Note that it's a bit different for whatever is in the AGP slot.634634- * For now, I don't care, but this can become a real issue, we635635- * should probably hook pci_set_mwi anyway to make sure it sets636636- * the real cache line size in there.637637- */638638- if (machine_is_compatible("MacRISC4"))639639- pci_cache_line_size = 16; /* 64 bytes */640640-641641- pmac_check_ht_link();642642-#endif /* CONFIG_POWER4 */643568}644569645570#define GRACKLE_CFA(b, d, o) (0x80 | ((b) << 8) | ((d) << 16) \···636703}637704638705#ifdef CONFIG_POWER4639639-640706static void __init setup_u3_agp(struct pci_controller* hose)641707{642708 /* On G5, we move AGP up to high bus number so we don't need···647715 * the reg address cell, we shall fix that by killing struct648716 * reg_property and using some accessor functions instead649717 */650650- hose->first_busno = 0xf0;718718+ hose->first_busno = 0xf0;651719 hose->last_busno = 0xff;652720 has_uninorth = 1;653721 hose->ops = ¯isc_pci_ops;···680748 */681749 hose->io_base_phys = 0xf4000000;682750 hose->io_base_virt = ioremap(hose->io_base_phys, 0x00400000);683683- isa_io_base = (unsigned long) hose->io_base_virt;751751+ isa_io_base = pci_io_base = (unsigned long) hose->io_base_virt;684752 hose->io_resource.name = np->full_name;685753 hose->io_resource.start = 0;686754 hose->io_resource.end = 0x003fffff;···726794 }727795 /* No, it's not the case, we need a hole */728796 if (cur == 2) {729729- /* not enough resources to make a hole, we drop part of the range */797797+ /* not enough resources for a hole, we drop part of the range */730798 printk(KERN_WARNING "Running out of resources for /ht host !\n");731799 hose->mem_resources[cur].end = res->start - 1;732800 continue;733801 } 734802 cur++;735735- DBG("U3/HT: hole, %d end at %08lx, %d start at %08lx\n",803803+ DBG("U3/HT: hole, %d end at %08lx, %d start at %08lx\n",736804 cur-1, res->start - 1, cur, res->end + 1);737805 hose->mem_resources[cur].name = np->full_name;738806 hose->mem_resources[cur].flags = IORESOURCE_MEM;···913981 if (device_is_compatible(dev, "uni-north")) {914982 primary = setup_uninorth(hose, addr);915983 disp_name = "UniNorth";916916- } else if (strcmp(dev->name, "pci") == 0) {984984+ } else if (strcmp(dev->name, "pci") == 0) {917985 /* XXX assume this is a mpc106 (grackle) */918986 setup_grackle(hose);919987 disp_name = "Grackle (MPC106)";···925993 disp_name = "Chaos";926994 primary = 0;927995 }928928- printk(KERN_INFO "Found %s PCI host bridge at 0x%08x. Firmware bus number: %d->%d\n",996996+ printk(KERN_INFO "Found %s PCI host bridge at 0x%08lx. Firmware bus number: %d->%d\n",929997 disp_name, addr->address, hose->first_busno, hose->last_busno);930998 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",931999 hose, hose->cfg_addr, hose->cfg_data);···9661034{9671035 /* Fixup interrupts according to OF tree */9681036 pcibios_fixup_OF_interrupts();10371037+}10381038+10391039+void __init pmac_find_bridges(void)10401040+{10411041+ struct device_node *np, *root;10421042+ struct device_node *ht = NULL;10431043+10441044+ root = of_find_node_by_path("/");10451045+ if (root == NULL) {10461046+ printk(KERN_CRIT "pmac_find_bridges: can't find root of device tree\n");10471047+ return;10481048+ }10491049+ for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) {10501050+ if (np->name == NULL)10511051+ continue;10521052+ if (strcmp(np->name, "bandit") == 010531053+ || strcmp(np->name, "chaos") == 010541054+ || strcmp(np->name, "pci") == 0) {10551055+ if (add_bridge(np) == 0)10561056+ of_node_get(np);10571057+ }10581058+ if (strcmp(np->name, "ht") == 0) {10591059+ of_node_get(np);10601060+ ht = np;10611061+ }10621062+ }10631063+ of_node_put(root);10641064+10651065+ /* Probe HT last as it relies on the agp resources to be already10661066+ * setup10671067+ */10681068+ if (ht && add_bridge(ht) != 0)10691069+ of_node_put(ht);10701070+10711071+ init_p2pbridge();10721072+ fixup_nec_usb2();10731073+10741074+ /* We are still having some issues with the Xserve G4, enabling10751075+ * some offset between bus number and domains for now when we10761076+ * assign all busses should help for now10771077+ */10781078+ if (pci_assign_all_busses)10791079+ pcibios_assign_bus_offset = 0x10;10801080+9691081}97010829711083int
+21-11
arch/powerpc/platforms/powermac/pic.c
···2525#include <linux/sysdev.h>2626#include <linux/adb.h>2727#include <linux/pmu.h>2828+#include <linux/module.h>28292930#include <asm/sections.h>3031#include <asm/io.h>···3332#include <asm/prom.h>3433#include <asm/pci-bridge.h>3534#include <asm/time.h>3636-#include <asm/open_pic.h>3735#include <asm/xmon.h>3836#include <asm/pmac_feature.h>3937#include <asm/mpic.h>40384141-#include "pmac_pic.h"3939+#include "pmac.h"42404341/*4442 * XXX this should be in xmon.h, but putting it there means xmon.h···4646 */4747extern irqreturn_t xmon_irq(int, void *, struct pt_regs *);48484949+#ifdef CONFIG_PPC324950struct pmac_irq_hw {5051 unsigned int event;5152 unsigned int enable;···72717372static DEFINE_SPINLOCK(pmac_pic_lock);74737474+/* XXX here for now, should move to arch/powerpc/kernel/irq.c */7575+int ppc_do_canonicalize_irqs;7676+EXPORT_SYMBOL(ppc_do_canonicalize_irqs);75777678#define GATWICK_IRQ_POOL_SIZE 107779static struct interrupt_info gatwick_int_pool[GATWICK_IRQ_POOL_SIZE];···381377 return irqctrler->intrs[0].line;382378}383379384384-static int pmac_u3_cascade(struct pt_regs *regs, void *data)385385-{386386- return mpic_get_one_irq((struct mpic *)data, regs);387387-}388388-389380#ifdef CONFIG_XMON390381static struct irqaction xmon_action = {391382 .handler = xmon_irq,···396397 .mask = CPU_MASK_NONE,397398 .name = "cascade",398399};400400+#endif /* CONFIG_PPC32 */401401+402402+static int pmac_u3_cascade(struct pt_regs *regs, void *data)403403+{404404+ return mpic_get_one_irq((struct mpic *)data, regs);405405+}399406400407void __init pmac_pic_init(void)401408{402402- int i;403409 struct device_node *irqctrler = NULL;404410 struct device_node *irqctrler2 = NULL;405411 struct device_node *np;412412+#ifdef CONFIG_PPC32413413+ int i;406414 unsigned long addr;407415 int irq_cascade = -1;416416+#endif408417 struct mpic *mpic1, *mpic2;409418410419 /* We first try to detect Apple's new Core99 chipset, since mac-io···462455 mpic_setup_cascade(irqctrler2->intrs[0].line,463456 pmac_u3_cascade, mpic2);464457 }465465-#ifdef CONFIG_XMON458458+#if defined(CONFIG_XMON) && defined(CONFIG_PPC32)466459 {467460 struct device_node* pswitch;468461 int nmi_irq;···470463 pswitch = find_devices("programmer-switch");471464 if (pswitch && pswitch->n_intrs) {472465 nmi_irq = pswitch->intrs[0].line;473473- openpic_init_nmi_irq(nmi_irq);466466+ mpic_irq_set_priority(nmi_irq, 9);474467 setup_irq(nmi_irq, &xmon_action);475468 }476469 }···479472 }480473 irqctrler = NULL;481474475475+#ifdef CONFIG_PPC32482476 /* Get the level/edge settings, assume if it's not483477 * a Grand Central nor an OHare, then it's an Heathrow484478 * (or Paddington).···578570#ifdef CONFIG_XMON579571 setup_irq(20, &xmon_action);580572#endif /* CONFIG_XMON */573573+#endif /* CONFIG_PPC32 */581574}582575583576#ifdef CONFIG_PM···668659669660static int __init init_pmacpic_sysfs(void)670661{662662+#ifdef CONFIG_PPC32671663 if (max_irqs == 0)672664 return -ENODEV;673673-665665+#endif674666 printk(KERN_DEBUG "Registering pmac pic with sysfs...\n");675667 sysdev_class_register(&pmacpic_sysclass);676668 sysdev_register(&device_pmacpic);
+21-4
arch/powerpc/platforms/powermac/pmac.h
···3344#include <linux/pci.h>55#include <linux/ide.h>66+#include <linux/irq.h>6778/*89 * Declaration for the various functions exported by the910 * pmac_* files. Mostly for use by pmac_setup1011 */11121212-extern void pmac_get_boot_time(struct rtc_time *tm);1313-extern void pmac_get_rtc_time(struct rtc_time *tm);1414-extern int pmac_set_rtc_time(struct rtc_time *tm);1313+extern long pmac_time_init(void);1414+extern unsigned long pmac_get_rtc_time(void);1515+extern int pmac_set_rtc_time(unsigned long nowtime);1516extern void pmac_read_rtc_time(void);1617extern void pmac_calibrate_decr(void);1717-1818extern void pmac_pcibios_fixup(void);1919+extern void pmac_find_bridges(void);2020+extern unsigned long pmac_ide_get_base(int index);2121+extern void pmac_ide_init_hwif_ports(hw_regs_t *hw,2222+ unsigned long data_port, unsigned long ctrl_port, int *irq);2323+2424+extern void pmac_nvram_update(void);2525+extern unsigned char pmac_nvram_read_byte(int addr);2626+extern void pmac_nvram_write_byte(int addr, unsigned char val);2727+extern int pmac_pci_enable_device_hook(struct pci_dev *dev, int initial);2828+extern void pmac_pcibios_after_init(void);2929+extern int of_show_percpuinfo(struct seq_file *m, int i);3030+1931extern void pmac_pci_init(void);2032extern void pmac_setup_pci_dma(void);2133extern void pmac_check_ht_link(void);···3927 unsigned long data_port, unsigned long ctrl_port, int *irq);40284129extern void pmac_nvram_init(void);3030+3131+extern struct hw_interrupt_type pmac_pic;3232+3333+void pmac_pic_init(void);3434+int pmac_get_irq(struct pt_regs *regs);42354336#endif /* __PMAC_H__ */
+1-19
arch/powerpc/platforms/powermac/setup.c
···7373#include <asm/of_device.h>7474#include <asm/mmu_context.h>75757676-#include "pmac_pic.h"7676+#include "pmac.h"77777878#undef SHOW_GATWICK_IRQS7979-8080-extern long pmac_time_init(void);8181-extern unsigned long pmac_get_rtc_time(void);8282-extern int pmac_set_rtc_time(unsigned long nowtime);8383-extern void pmac_read_rtc_time(void);8484-extern void pmac_calibrate_decr(void);8585-extern void pmac_pcibios_fixup(void);8686-extern void pmac_find_bridges(void);8787-extern unsigned long pmac_ide_get_base(int index);8888-extern void pmac_ide_init_hwif_ports(hw_regs_t *hw,8989- unsigned long data_port, unsigned long ctrl_port, int *irq);9090-9191-extern void pmac_nvram_update(void);9292-extern unsigned char pmac_nvram_read_byte(int addr);9393-extern void pmac_nvram_write_byte(int addr, unsigned char val);9494-extern int pmac_pci_enable_device_hook(struct pci_dev *dev, int initial);9595-extern void pmac_pcibios_after_init(void);9696-extern int of_show_percpuinfo(struct seq_file *m, int i);97799880unsigned char drive_info;9981