···140140 .name = "IPI_call"141141};142142143143+static void __init smp_copy_vpe_config(void)144144+{145145+ write_vpe_c0_status(146146+ (read_c0_status() & ~(ST0_IM | ST0_IE | ST0_KSU)) | ST0_CU0);147147+148148+ /* set config to be the same as vpe0, particularly kseg0 coherency alg */149149+ write_vpe_c0_config( read_c0_config());150150+151151+ /* make sure there are no software interrupts pending */152152+ write_vpe_c0_cause(0);153153+154154+ /* Propagate Config7 */155155+ write_vpe_c0_config7(read_c0_config7());156156+}157157+158158+static unsigned int __init smp_vpe_init(unsigned int tc, unsigned int mvpconf0,159159+ unsigned int ncpu)160160+{161161+ if (tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT))162162+ return ncpu;163163+164164+ /* Deactivate all but VPE 0 */165165+ if (tc != 0) {166166+ unsigned long tmp = read_vpe_c0_vpeconf0();167167+168168+ tmp &= ~VPECONF0_VPA;169169+170170+ /* master VPE */171171+ tmp |= VPECONF0_MVP;172172+ write_vpe_c0_vpeconf0(tmp);173173+174174+ /* Record this as available CPU */175175+ cpu_set(tc, phys_cpu_present_map);176176+ __cpu_number_map[tc] = ++ncpu;177177+ __cpu_logical_map[ncpu] = tc;178178+ }179179+180180+ /* Disable multi-threading with TC's */181181+ write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() & ~VPECONTROL_TE);182182+183183+ if (tc != 0)184184+ smp_copy_vpe_config();185185+186186+ return ncpu;187187+}188188+189189+static void __init smp_tc_init(unsigned int tc, unsigned int mvpconf0)190190+{191191+ unsigned long tmp;192192+193193+ if (!tc)194194+ return;195195+196196+ /* bind a TC to each VPE, May as well put all excess TC's197197+ on the last VPE */198198+ if (tc >= (((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)+1))199199+ write_tc_c0_tcbind(read_tc_c0_tcbind() | ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT));200200+ else {201201+ write_tc_c0_tcbind(read_tc_c0_tcbind() | tc);202202+203203+ /* and set XTC */204204+ write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | (tc << VPECONF0_XTC_SHIFT));205205+ }206206+207207+ tmp = read_tc_c0_tcstatus();208208+209209+ /* mark not allocated and not dynamically allocatable */210210+ tmp &= ~(TCSTATUS_A | TCSTATUS_DA);211211+ tmp |= TCSTATUS_IXMT; /* interrupt exempt */212212+ write_tc_c0_tcstatus(tmp);213213+214214+ write_tc_c0_tchalt(TCHALT_H);215215+}216216+143217/*144218 * Common setup before any secondaries are started145219 * Make sure all CPU's are in a sensible state before we boot any of the146220 * secondarys147221 */148148-void plat_smp_setup(void)222222+void __init plat_smp_setup(void)149223{150150- unsigned long val;151151- int i, num;224224+ unsigned int mvpconf0, ntc, tc, ncpu = 0;152225153226#ifdef CONFIG_MIPS_MT_FPAFF154227 /* If we have an FPU, enroll ourselves in the FPU-full mask */···240167 /* Put MVPE's into 'configuration state' */241168 set_c0_mvpcontrol(MVPCONTROL_VPC);242169243243- val = read_c0_mvpconf0();170170+ mvpconf0 = read_c0_mvpconf0();171171+ ntc = (mvpconf0 & MVPCONF0_PTC) >> MVPCONF0_PTC_SHIFT;244172245173 /* we'll always have more TC's than VPE's, so loop setting everything246174 to a sensible state */247247- for (i = 0, num = 0; i <= ((val & MVPCONF0_PTC) >> MVPCONF0_PTC_SHIFT); i++) {248248- settc(i);175175+ for (tc = 0; tc <= ntc; tc++) {176176+ settc(tc);249177250250- /* VPE's */251251- if (i <= ((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)) {252252-253253- /* deactivate all but vpe0 */254254- if (i != 0) {255255- unsigned long tmp = read_vpe_c0_vpeconf0();256256-257257- tmp &= ~VPECONF0_VPA;258258-259259- /* master VPE */260260- tmp |= VPECONF0_MVP;261261- write_vpe_c0_vpeconf0(tmp);262262-263263- /* Record this as available CPU */264264- cpu_set(i, phys_cpu_present_map);265265- __cpu_number_map[i] = ++num;266266- __cpu_logical_map[num] = i;267267- }268268-269269- /* disable multi-threading with TC's */270270- write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() & ~VPECONTROL_TE);271271-272272- if (i != 0) {273273- write_vpe_c0_status((read_c0_status() & ~(ST0_IM | ST0_IE | ST0_KSU)) | ST0_CU0);274274-275275- /* set config to be the same as vpe0, particularly kseg0 coherency alg */276276- write_vpe_c0_config( read_c0_config());277277-278278- /* make sure there are no software interrupts pending */279279- write_vpe_c0_cause(0);280280-281281- /* Propagate Config7 */282282- write_vpe_c0_config7(read_c0_config7());283283- }284284-285285- }286286-287287- /* TC's */288288-289289- if (i != 0) {290290- unsigned long tmp;291291-292292- /* bind a TC to each VPE, May as well put all excess TC's293293- on the last VPE */294294- if ( i >= (((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)+1) )295295- write_tc_c0_tcbind(read_tc_c0_tcbind() | ((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT) );296296- else {297297- write_tc_c0_tcbind( read_tc_c0_tcbind() | i);298298-299299- /* and set XTC */300300- write_vpe_c0_vpeconf0( read_vpe_c0_vpeconf0() | (i << VPECONF0_XTC_SHIFT));301301- }302302-303303- tmp = read_tc_c0_tcstatus();304304-305305- /* mark not allocated and not dynamically allocatable */306306- tmp &= ~(TCSTATUS_A | TCSTATUS_DA);307307- tmp |= TCSTATUS_IXMT; /* interrupt exempt */308308- write_tc_c0_tcstatus(tmp);309309-310310- write_tc_c0_tchalt(TCHALT_H);311311- }178178+ smp_tc_init(tc, mvpconf0);179179+ ncpu = smp_vpe_init(tc, mvpconf0, ncpu);312180 }313181314182 /* Release config state */···257243258244 /* We'll wait until starting the secondaries before starting MVPE */259245260260- printk(KERN_INFO "Detected %i available secondary CPU(s)\n", num);246246+ printk(KERN_INFO "Detected %i available secondary CPU(s)\n", ncpu);261247}262248263249void __init plat_prepare_cpus(unsigned int max_cpus)