📄 pmac_smp.c
字号:
set_bit(msg, &psurge_smp_message[i]); psurge_set_ipi(i); } }}/* * Determine a quad card presence. We read the board ID register, we * force the data bus to change to something else, and we read it again. * It it's stable, then the register probably exist (ugh !) */static int __init psurge_quad_probe(void){ int type; unsigned int i; type = PSURGE_QUAD_IN(PSURGE_QUAD_BOARD_ID); if (type < PSURGE_QUAD_OKEE || type > PSURGE_QUAD_ICEGRASS || type != PSURGE_QUAD_IN(PSURGE_QUAD_BOARD_ID)) return PSURGE_DUAL; /* looks OK, try a slightly more rigorous test */ /* bogus is not necessarily cacheline-aligned, though I don't suppose that really matters. -- paulus */ for (i = 0; i < 100; i++) { volatile u32 bogus[8]; bogus[(0+i)%8] = 0x00000000; bogus[(1+i)%8] = 0x55555555; bogus[(2+i)%8] = 0xFFFFFFFF; bogus[(3+i)%8] = 0xAAAAAAAA; bogus[(4+i)%8] = 0x33333333; bogus[(5+i)%8] = 0xCCCCCCCC; bogus[(6+i)%8] = 0xCCCCCCCC; bogus[(7+i)%8] = 0x33333333; wmb(); asm volatile("dcbf 0,%0" : : "r" (bogus) : "memory"); mb(); if (type != PSURGE_QUAD_IN(PSURGE_QUAD_BOARD_ID)) return PSURGE_DUAL; } return type;}static void __init psurge_quad_init(void){ int procbits; if (ppc_md.progress) ppc_md.progress("psurge_quad_init", 0x351); procbits = ~PSURGE_QUAD_IN(PSURGE_QUAD_WHICH_CPU); if (psurge_type == PSURGE_QUAD_ICEGRASS) PSURGE_QUAD_BIS(PSURGE_QUAD_RESET_CTL, procbits); else PSURGE_QUAD_BIC(PSURGE_QUAD_CKSTOP_CTL, procbits); mdelay(33); out_8(psurge_sec_intr, ~0); PSURGE_QUAD_OUT(PSURGE_QUAD_IRQ_CLR, procbits); PSURGE_QUAD_BIS(PSURGE_QUAD_RESET_CTL, procbits); if (psurge_type != PSURGE_QUAD_ICEGRASS) PSURGE_QUAD_BIS(PSURGE_QUAD_CKSTOP_CTL, procbits); PSURGE_QUAD_BIC(PSURGE_QUAD_PRIMARY_ARB, procbits); mdelay(33); PSURGE_QUAD_BIC(PSURGE_QUAD_RESET_CTL, procbits); mdelay(33); PSURGE_QUAD_BIS(PSURGE_QUAD_PRIMARY_ARB, procbits); mdelay(33);}static int __init smp_psurge_probe(void){ int i, ncpus; /* We don't do SMP on the PPC601 -- paulus */ if (PVR_VER(mfspr(PVR)) == 1) return 1; /* * The powersurge cpu board can be used in the generation * of powermacs that have a socket for an upgradeable cpu card, * including the 7500, 8500, 9500, 9600. * The device tree doesn't tell you if you have 2 cpus because * OF doesn't know anything about the 2nd processor. * Instead we look for magic bits in magic registers, * in the hammerhead memory controller in the case of the * dual-cpu powersurge board. -- paulus. */ if (find_devices("hammerhead") == NULL) return 1; hhead_base = ioremap(HAMMERHEAD_BASE, 0x800); quad_base = ioremap(PSURGE_QUAD_REG_ADDR, 1024); psurge_sec_intr = hhead_base + HHEAD_SEC_INTR; psurge_type = psurge_quad_probe(); if (psurge_type != PSURGE_DUAL) { psurge_quad_init(); /* All released cards using this HW design have 4 CPUs */ ncpus = 4; } else { iounmap((void *) quad_base); if ((in_8(hhead_base + HHEAD_CONFIG) & 0x02) == 0) { /* not a dual-cpu card */ iounmap((void *) hhead_base); return 1; } ncpus = 2; } psurge_start = ioremap(PSURGE_START, 4); psurge_pri_intr = ioremap(PSURGE_PRI_INTR, 4); /* this is not actually strictly necessary -- paulus. */ for (i = 1; i < ncpus; ++i) smp_hw_index[i] = i; if (ppc_md.progress) ppc_md.progress("smp_psurge_probe - done", 0x352); return ncpus;}static void __init smp_psurge_kick_cpu(int nr){ void (*start)(void) = __secondary_start_psurge; unsigned long a; /* may need to flush here if secondary bats aren't setup */ for (a = KERNELBASE; a < KERNELBASE + 0x800000; a += 32) asm volatile("dcbf 0,%0" : : "r" (a) : "memory"); asm volatile("sync"); if (ppc_md.progress) ppc_md.progress("smp_psurge_kick_cpu", 0x353); /* setup entry point of secondary processor */ switch (nr) { case 2: start = __secondary_start_psurge2; break; case 3: start = __secondary_start_psurge3; break; } out_be32(psurge_start, __pa(start)); mb(); psurge_set_ipi(nr); udelay(10); psurge_clr_ipi(nr); if (ppc_md.progress) ppc_md.progress("smp_psurge_kick_cpu - done", 0x354);}/* * With the dual-cpu powersurge board, the decrementers and timebases * of both cpus are frozen after the secondary cpu is started up, * until we give the secondary cpu another interrupt. This routine * uses this to get the timebases synchronized. * -- paulus. */static void __init psurge_dual_sync_tb(int cpu_nr){ static volatile int sec_tb_reset = 0; int t; set_dec(tb_ticks_per_jiffy); set_tb(0, 0); last_jiffy_stamp(cpu_nr) = 0; if (cpu_nr > 0) { mb(); sec_tb_reset = 1; return; } /* wait for the secondary to have reset its TB before proceeding */ for (t = 10000000; t > 0 && !sec_tb_reset; --t) ; /* now interrupt the secondary, starting both TBs */ psurge_set_ipi(1); smp_tb_synchronized = 1;}static void __initsmp_psurge_setup_cpu(int cpu_nr){ if (cpu_nr == 0) { if (smp_num_cpus < 2) return; /* reset the entry point so if we get another intr we won't * try to startup again */ out_be32(psurge_start, 0x100); if (request_irq(30, psurge_primary_intr, 0, "primary IPI", 0)) printk(KERN_ERR "Couldn't get primary IPI interrupt"); } if (psurge_type == PSURGE_DUAL) psurge_dual_sync_tb(cpu_nr);}static int __initsmp_core99_probe(void){ struct device_node *cpus; int i, ncpus = 1; extern int powersave_nap; if (ppc_md.progress) ppc_md.progress("smp_core99_probe", 0x345); cpus = find_type_devices("cpu"); if (cpus) while ((cpus = cpus->next) != NULL) ++ncpus; printk("smp_core99_probe: found %d cpus\n", ncpus); if (ncpus > 1) { openpic_request_IPIs(); for (i = 1; i < ncpus; ++i) smp_hw_index[i] = i; powersave_nap = 0; cpu_setup_grab(); } return ncpus;}static void __initsmp_core99_kick_cpu(int nr){ unsigned long save_vector, new_vector; unsigned long flags; volatile unsigned long *vector = ((volatile unsigned long *)(KERNELBASE+0x100)); if (nr < 1 || nr > 3) return; if (ppc_md.progress) ppc_md.progress("smp_core99_kick_cpu", 0x346); local_irq_save(flags); local_irq_disable(); /* Save reset vector */ save_vector = *vector; /* Setup fake reset vector that does * b __secondary_start_psurge - KERNELBASE */ switch(nr) { case 1: new_vector = (unsigned long)__secondary_start_psurge; break; case 2: new_vector = (unsigned long)__secondary_start_psurge2; break; case 3: new_vector = (unsigned long)__secondary_start_psurge3; break; } *vector = 0x48000002 + new_vector - KERNELBASE; /* flush data cache and inval instruction cache */ flush_icache_range((unsigned long) vector, (unsigned long) vector + 4); /* Put some life in our friend */ pmac_call_feature(PMAC_FTR_RESET_CPU, NULL, nr, 0); /* FIXME: We wait a bit for the CPU to take the exception, I should * instead wait for the entry code to set something for me. Well, * ideally, all that crap will be done in prom.c and the CPU left * in a RAM-based wait loop like CHRP. */ mdelay(1); /* Restore our exception vector */ *vector = save_vector; flush_icache_range((unsigned long) vector, (unsigned long) vector + 4); local_irq_restore(flags); if (ppc_md.progress) ppc_md.progress("smp_core99_kick_cpu done", 0x347);}static void __initsmp_core99_setup_cpu(int cpu_nr){ /* Setup some registers */ if (cpu_nr != 0) cpu_setup_apply(cpu_nr); /* Setup openpic */ do_openpic_setup_cpu(); /* Setup L2/L3 */ if (cpu_nr == 0) if (ppc_md.progress) ppc_md.progress("core99_setup_cpu 0 done", 0x349);}/* PowerSurge-style Macs */struct smp_ops_t psurge_smp_ops __pmacdata = { smp_psurge_message_pass, smp_psurge_probe, smp_psurge_kick_cpu, smp_psurge_setup_cpu,};/* Core99 Macs (dual G4s) */struct smp_ops_t core99_smp_ops __pmacdata = { smp_openpic_message_pass, smp_core99_probe, smp_core99_kick_cpu, smp_core99_setup_cpu,};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -