1b40ce02aSNathan Whitehorn /*- 2925f0a6eSRafal Jaworowski * Copyright (c) 2008-2012 Semihalf. 3b40ce02aSNathan Whitehorn * All rights reserved. 4b40ce02aSNathan Whitehorn * 5b40ce02aSNathan Whitehorn * Redistribution and use in source and binary forms, with or without 6b40ce02aSNathan Whitehorn * modification, are permitted provided that the following conditions 7b40ce02aSNathan Whitehorn * are met: 8b40ce02aSNathan Whitehorn * 9b40ce02aSNathan Whitehorn * 1. Redistributions of source code must retain the above copyright 10b40ce02aSNathan Whitehorn * notice, this list of conditions and the following disclaimer. 11b40ce02aSNathan Whitehorn * 2. Redistributions in binary form must reproduce the above copyright 12b40ce02aSNathan Whitehorn * notice, this list of conditions and the following disclaimer in the 13b40ce02aSNathan Whitehorn * documentation and/or other materials provided with the distribution. 14b40ce02aSNathan Whitehorn * 15b40ce02aSNathan Whitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16b40ce02aSNathan Whitehorn * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17b40ce02aSNathan Whitehorn * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18b40ce02aSNathan Whitehorn * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19b40ce02aSNathan Whitehorn * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20b40ce02aSNathan Whitehorn * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21b40ce02aSNathan Whitehorn * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22b40ce02aSNathan Whitehorn * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23b40ce02aSNathan Whitehorn * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24b40ce02aSNathan Whitehorn * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25b40ce02aSNathan Whitehorn */ 26b40ce02aSNathan Whitehorn 27b40ce02aSNathan Whitehorn #include <sys/cdefs.h> 28b40ce02aSNathan Whitehorn __FBSDID("$FreeBSD$"); 29b40ce02aSNathan Whitehorn 30b40ce02aSNathan Whitehorn #include <sys/param.h> 31b40ce02aSNathan Whitehorn #include <sys/systm.h> 32b40ce02aSNathan Whitehorn #include <sys/kernel.h> 33b40ce02aSNathan Whitehorn #include <sys/bus.h> 34b40ce02aSNathan Whitehorn #include <sys/pcpu.h> 35b40ce02aSNathan Whitehorn #include <sys/proc.h> 36b40ce02aSNathan Whitehorn #include <sys/smp.h> 37b40ce02aSNathan Whitehorn 38b40ce02aSNathan Whitehorn #include <machine/bus.h> 39b40ce02aSNathan Whitehorn #include <machine/cpu.h> 40b40ce02aSNathan Whitehorn #include <machine/hid.h> 41b40ce02aSNathan Whitehorn #include <machine/platform.h> 42b40ce02aSNathan Whitehorn #include <machine/platformvar.h> 43b40ce02aSNathan Whitehorn #include <machine/smp.h> 44b40ce02aSNathan Whitehorn #include <machine/spr.h> 45b40ce02aSNathan Whitehorn #include <machine/vmparam.h> 46b40ce02aSNathan Whitehorn 47d1d3233eSRafal Jaworowski #include <dev/fdt/fdt_common.h> 48d1d3233eSRafal Jaworowski #include <dev/ofw/ofw_bus.h> 49d1d3233eSRafal Jaworowski #include <dev/ofw/ofw_bus_subr.h> 50d1d3233eSRafal Jaworowski #include <dev/ofw/openfirm.h> 51d1d3233eSRafal Jaworowski 52b40ce02aSNathan Whitehorn #include <powerpc/mpc85xx/mpc85xx.h> 53b40ce02aSNathan Whitehorn 54b40ce02aSNathan Whitehorn #include "platform_if.h" 55b40ce02aSNathan Whitehorn 5628bb01e5SRafal Jaworowski #ifdef SMP 5728bb01e5SRafal Jaworowski extern void *ap_pcpu; 584a49da83SMarcel Moolenaar extern vm_paddr_t kernload; /* Kernel physical load address */ 5928bb01e5SRafal Jaworowski extern uint8_t __boot_page[]; /* Boot page body */ 604a49da83SMarcel Moolenaar extern uint32_t bp_ntlb1s; 614a49da83SMarcel Moolenaar extern uint32_t bp_tlb1[]; 624a49da83SMarcel Moolenaar extern uint32_t bp_tlb1_end[]; 6328bb01e5SRafal Jaworowski #endif 6428bb01e5SRafal Jaworowski 65e3d41006SMarcel Moolenaar extern uint32_t *bootinfo; 66e3d41006SMarcel Moolenaar 672b7b2d79SRafal Jaworowski static int cpu, maxcpu; 68b40ce02aSNathan Whitehorn 69b40ce02aSNathan Whitehorn static int bare_probe(platform_t); 70b40ce02aSNathan Whitehorn static void bare_mem_regions(platform_t, struct mem_region **phys, int *physsz, 71b40ce02aSNathan Whitehorn struct mem_region **avail, int *availsz); 72b40ce02aSNathan Whitehorn static u_long bare_timebase_freq(platform_t, struct cpuref *cpuref); 73b40ce02aSNathan Whitehorn static int bare_smp_first_cpu(platform_t, struct cpuref *cpuref); 74b40ce02aSNathan Whitehorn static int bare_smp_next_cpu(platform_t, struct cpuref *cpuref); 75b40ce02aSNathan Whitehorn static int bare_smp_get_bsp(platform_t, struct cpuref *cpuref); 76b40ce02aSNathan Whitehorn static int bare_smp_start_cpu(platform_t, struct pcpu *cpu); 77b40ce02aSNathan Whitehorn 782f6bd241SRafal Jaworowski static void booke_reset(platform_t); 79b2a237beSNathan Whitehorn 80b40ce02aSNathan Whitehorn static platform_method_t bare_methods[] = { 81b40ce02aSNathan Whitehorn PLATFORMMETHOD(platform_probe, bare_probe), 82b40ce02aSNathan Whitehorn PLATFORMMETHOD(platform_mem_regions, bare_mem_regions), 83b40ce02aSNathan Whitehorn PLATFORMMETHOD(platform_timebase_freq, bare_timebase_freq), 84b40ce02aSNathan Whitehorn 85b40ce02aSNathan Whitehorn PLATFORMMETHOD(platform_smp_first_cpu, bare_smp_first_cpu), 86b40ce02aSNathan Whitehorn PLATFORMMETHOD(platform_smp_next_cpu, bare_smp_next_cpu), 87b40ce02aSNathan Whitehorn PLATFORMMETHOD(platform_smp_get_bsp, bare_smp_get_bsp), 88b40ce02aSNathan Whitehorn PLATFORMMETHOD(platform_smp_start_cpu, bare_smp_start_cpu), 89b40ce02aSNathan Whitehorn 902f6bd241SRafal Jaworowski PLATFORMMETHOD(platform_reset, booke_reset), 91b2a237beSNathan Whitehorn 92eaba9848SRui Paulo PLATFORMMETHOD_END 93b40ce02aSNathan Whitehorn }; 94b40ce02aSNathan Whitehorn 95b40ce02aSNathan Whitehorn static platform_def_t bare_platform = { 96b40ce02aSNathan Whitehorn "bare metal", 97b40ce02aSNathan Whitehorn bare_methods, 98b40ce02aSNathan Whitehorn 0 99b40ce02aSNathan Whitehorn }; 100b40ce02aSNathan Whitehorn 101b40ce02aSNathan Whitehorn PLATFORM_DEF(bare_platform); 102b40ce02aSNathan Whitehorn 103b40ce02aSNathan Whitehorn static int 104b40ce02aSNathan Whitehorn bare_probe(platform_t plat) 105b40ce02aSNathan Whitehorn { 106925f0a6eSRafal Jaworowski phandle_t cpus, child; 107925f0a6eSRafal Jaworowski uint32_t sr; 108d1d3233eSRafal Jaworowski int i, law_max, tgt; 1092b7b2d79SRafal Jaworowski 110925f0a6eSRafal Jaworowski if ((cpus = OF_finddevice("/cpus")) != 0) { 111925f0a6eSRafal Jaworowski for (maxcpu = 0, child = OF_child(cpus); child != 0; 112925f0a6eSRafal Jaworowski child = OF_peer(child), maxcpu++) 113925f0a6eSRafal Jaworowski ; 114925f0a6eSRafal Jaworowski } else 1152b7b2d79SRafal Jaworowski maxcpu = 1; 116b40ce02aSNathan Whitehorn 117d1d3233eSRafal Jaworowski /* 118d1d3233eSRafal Jaworowski * Clear local access windows. Skip DRAM entries, so we don't shoot 119d1d3233eSRafal Jaworowski * ourselves in the foot. 120d1d3233eSRafal Jaworowski */ 121d1d3233eSRafal Jaworowski law_max = law_getmax(); 122d1d3233eSRafal Jaworowski for (i = 0; i < law_max; i++) { 123d1d3233eSRafal Jaworowski sr = ccsr_read4(OCP85XX_LAWSR(i)); 124d1d3233eSRafal Jaworowski if ((sr & 0x80000000) == 0) 125d1d3233eSRafal Jaworowski continue; 126d1d3233eSRafal Jaworowski tgt = (sr & 0x01f00000) >> 20; 127d1d3233eSRafal Jaworowski if (tgt == OCP85XX_TGTIF_RAM1 || tgt == OCP85XX_TGTIF_RAM2 || 128d1d3233eSRafal Jaworowski tgt == OCP85XX_TGTIF_RAM_INTL) 129d1d3233eSRafal Jaworowski continue; 130d1d3233eSRafal Jaworowski 131d1d3233eSRafal Jaworowski ccsr_write4(OCP85XX_LAWSR(i), sr & 0x7fffffff); 132d1d3233eSRafal Jaworowski } 133d1d3233eSRafal Jaworowski 134b40ce02aSNathan Whitehorn return (BUS_PROBE_GENERIC); 135b40ce02aSNathan Whitehorn } 136b40ce02aSNathan Whitehorn 137b40ce02aSNathan Whitehorn #define MEM_REGIONS 8 138b40ce02aSNathan Whitehorn static struct mem_region avail_regions[MEM_REGIONS]; 139b40ce02aSNathan Whitehorn 140b40ce02aSNathan Whitehorn void 141b40ce02aSNathan Whitehorn bare_mem_regions(platform_t plat, struct mem_region **phys, int *physsz, 142b40ce02aSNathan Whitehorn struct mem_region **avail, int *availsz) 143b40ce02aSNathan Whitehorn { 144d1d3233eSRafal Jaworowski uint32_t memsize; 145d1d3233eSRafal Jaworowski int i, rv; 146b40ce02aSNathan Whitehorn 147d1d3233eSRafal Jaworowski rv = fdt_get_mem_regions(avail_regions, availsz, &memsize); 148d1d3233eSRafal Jaworowski if (rv != 0) 149691df1a1SRafal Jaworowski panic("%s: could not retrieve mem regions from the 'memory' " 150691df1a1SRafal Jaworowski "node, error: %d", __func__, rv); 151d1d3233eSRafal Jaworowski 152d1d3233eSRafal Jaworowski for (i = 0; i < *availsz; i++) { 153d1d3233eSRafal Jaworowski if (avail_regions[i].mr_start < 1048576) { 154d1d3233eSRafal Jaworowski avail_regions[i].mr_size = 155d1d3233eSRafal Jaworowski avail_regions[i].mr_size - 156d1d3233eSRafal Jaworowski (1048576 - avail_regions[i].mr_start); 157b40ce02aSNathan Whitehorn avail_regions[i].mr_start = 1048576; 158b40ce02aSNathan Whitehorn } 159b40ce02aSNathan Whitehorn } 160b40ce02aSNathan Whitehorn *avail = avail_regions; 161b40ce02aSNathan Whitehorn 162b40ce02aSNathan Whitehorn /* On the bare metal platform phys == avail memory */ 163b40ce02aSNathan Whitehorn *physsz = *availsz; 164b40ce02aSNathan Whitehorn *phys = *avail; 165b40ce02aSNathan Whitehorn } 166b40ce02aSNathan Whitehorn 167b40ce02aSNathan Whitehorn static u_long 168b40ce02aSNathan Whitehorn bare_timebase_freq(platform_t plat, struct cpuref *cpuref) 169b40ce02aSNathan Whitehorn { 170e3d41006SMarcel Moolenaar u_long ticks; 171d1d3233eSRafal Jaworowski phandle_t cpus, child; 172d1d3233eSRafal Jaworowski pcell_t freq; 173b40ce02aSNathan Whitehorn 1745ce36fdbSMarcel Moolenaar if (bootinfo != NULL) { 1752b5bf115SMarcel Moolenaar if (bootinfo[0] == 1) { 176e3d41006SMarcel Moolenaar /* Backward compatibility. See 8-STABLE. */ 177e3d41006SMarcel Moolenaar ticks = bootinfo[3] >> 3; 1782b5bf115SMarcel Moolenaar } else { 1795ce36fdbSMarcel Moolenaar /* Compatibility with Juniper's loader. */ 1802b5bf115SMarcel Moolenaar ticks = bootinfo[5] >> 3; 1815ce36fdbSMarcel Moolenaar } 1827512c508SMarcel Moolenaar } else 1837512c508SMarcel Moolenaar ticks = 0; 184e3d41006SMarcel Moolenaar 18507042befSJayachandran C. if ((cpus = OF_finddevice("/cpus")) == -1) 186d1d3233eSRafal Jaworowski goto out; 187d1d3233eSRafal Jaworowski 188d1d3233eSRafal Jaworowski if ((child = OF_child(cpus)) == 0) 189d1d3233eSRafal Jaworowski goto out; 190d1d3233eSRafal Jaworowski 191*1c02b4c9SNathan Whitehorn switch (OF_getproplen(child, "timebase-frequency")) { 192*1c02b4c9SNathan Whitehorn case 4: 193*1c02b4c9SNathan Whitehorn { 194*1c02b4c9SNathan Whitehorn uint32_t tbase; 195*1c02b4c9SNathan Whitehorn OF_getprop(child, "timebase-frequency", &tbase, sizeof(tbase)); 196*1c02b4c9SNathan Whitehorn ticks = tbase; 197*1c02b4c9SNathan Whitehorn return (ticks); 198*1c02b4c9SNathan Whitehorn } 199*1c02b4c9SNathan Whitehorn case 8: 200*1c02b4c9SNathan Whitehorn { 201*1c02b4c9SNathan Whitehorn uint64_t tbase; 202*1c02b4c9SNathan Whitehorn OF_getprop(child, "timebase-frequency", &tbase, sizeof(tbase)); 203*1c02b4c9SNathan Whitehorn ticks = tbase; 204*1c02b4c9SNathan Whitehorn return (ticks); 205*1c02b4c9SNathan Whitehorn } 206*1c02b4c9SNathan Whitehorn default: 207*1c02b4c9SNathan Whitehorn break; 208*1c02b4c9SNathan Whitehorn } 209d26eb2c1SNathan Whitehorn 210e3d41006SMarcel Moolenaar freq = 0; 211d1d3233eSRafal Jaworowski if (OF_getprop(child, "bus-frequency", (void *)&freq, 212d1d3233eSRafal Jaworowski sizeof(freq)) <= 0) 213d1d3233eSRafal Jaworowski goto out; 214e3d41006SMarcel Moolenaar 215b40ce02aSNathan Whitehorn /* 216b40ce02aSNathan Whitehorn * Time Base and Decrementer are updated every 8 CCB bus clocks. 217b40ce02aSNathan Whitehorn * HID0[SEL_TBCLK] = 0 218b40ce02aSNathan Whitehorn */ 219e3d41006SMarcel Moolenaar if (freq != 0) 220d1d3233eSRafal Jaworowski ticks = freq / 8; 221e3d41006SMarcel Moolenaar 222d1d3233eSRafal Jaworowski out: 223b40ce02aSNathan Whitehorn if (ticks <= 0) 224b40ce02aSNathan Whitehorn panic("Unable to determine timebase frequency!"); 225b40ce02aSNathan Whitehorn 226b40ce02aSNathan Whitehorn return (ticks); 227b40ce02aSNathan Whitehorn } 228b40ce02aSNathan Whitehorn 229b40ce02aSNathan Whitehorn static int 230b40ce02aSNathan Whitehorn bare_smp_first_cpu(platform_t plat, struct cpuref *cpuref) 231b40ce02aSNathan Whitehorn { 232b40ce02aSNathan Whitehorn 233b40ce02aSNathan Whitehorn cpu = 0; 234b40ce02aSNathan Whitehorn cpuref->cr_cpuid = cpu; 235b40ce02aSNathan Whitehorn cpuref->cr_hwref = cpuref->cr_cpuid; 236b40ce02aSNathan Whitehorn if (bootverbose) 237b40ce02aSNathan Whitehorn printf("powerpc_smp_first_cpu: cpuid %d\n", cpuref->cr_cpuid); 238b40ce02aSNathan Whitehorn cpu++; 239b40ce02aSNathan Whitehorn 240b40ce02aSNathan Whitehorn return (0); 241b40ce02aSNathan Whitehorn } 242b40ce02aSNathan Whitehorn 243b40ce02aSNathan Whitehorn static int 244b40ce02aSNathan Whitehorn bare_smp_next_cpu(platform_t plat, struct cpuref *cpuref) 245b40ce02aSNathan Whitehorn { 246b40ce02aSNathan Whitehorn 2472b7b2d79SRafal Jaworowski if (cpu >= maxcpu) 248b40ce02aSNathan Whitehorn return (ENOENT); 249b40ce02aSNathan Whitehorn 250b40ce02aSNathan Whitehorn cpuref->cr_cpuid = cpu++; 251b40ce02aSNathan Whitehorn cpuref->cr_hwref = cpuref->cr_cpuid; 252b40ce02aSNathan Whitehorn if (bootverbose) 253b40ce02aSNathan Whitehorn printf("powerpc_smp_next_cpu: cpuid %d\n", cpuref->cr_cpuid); 254b40ce02aSNathan Whitehorn 255b40ce02aSNathan Whitehorn return (0); 256b40ce02aSNathan Whitehorn } 257b40ce02aSNathan Whitehorn 258b40ce02aSNathan Whitehorn static int 259b40ce02aSNathan Whitehorn bare_smp_get_bsp(platform_t plat, struct cpuref *cpuref) 260b40ce02aSNathan Whitehorn { 261b40ce02aSNathan Whitehorn 262b40ce02aSNathan Whitehorn cpuref->cr_cpuid = mfspr(SPR_PIR); 263b40ce02aSNathan Whitehorn cpuref->cr_hwref = cpuref->cr_cpuid; 264b40ce02aSNathan Whitehorn 265b40ce02aSNathan Whitehorn return (0); 266b40ce02aSNathan Whitehorn } 267b40ce02aSNathan Whitehorn 268b40ce02aSNathan Whitehorn static int 269b40ce02aSNathan Whitehorn bare_smp_start_cpu(platform_t plat, struct pcpu *pc) 270b40ce02aSNathan Whitehorn { 27128bb01e5SRafal Jaworowski #ifdef SMP 2724a49da83SMarcel Moolenaar uint32_t *tlb1; 27328bb01e5SRafal Jaworowski uint32_t bptr, eebpcr; 2744a49da83SMarcel Moolenaar int i, timeout; 275b40ce02aSNathan Whitehorn 27628bb01e5SRafal Jaworowski eebpcr = ccsr_read4(OCP85XX_EEBPCR); 27720bf92c2SAttilio Rao if ((eebpcr & (1 << (pc->pc_cpuid + 24))) != 0) { 278a45d9127SMarcel Moolenaar printf("SMP: CPU %d already out of hold-off state!\n", 279a45d9127SMarcel Moolenaar pc->pc_cpuid); 28028bb01e5SRafal Jaworowski return (ENXIO); 28128bb01e5SRafal Jaworowski } 28228bb01e5SRafal Jaworowski 28328bb01e5SRafal Jaworowski ap_pcpu = pc; 2844a49da83SMarcel Moolenaar 2854a49da83SMarcel Moolenaar i = 0; 2864a49da83SMarcel Moolenaar tlb1 = bp_tlb1; 2874a49da83SMarcel Moolenaar while (i < bp_ntlb1s && tlb1 < bp_tlb1_end) { 2884a49da83SMarcel Moolenaar mtspr(SPR_MAS0, MAS0_TLBSEL(1) | MAS0_ESEL(i)); 2894a49da83SMarcel Moolenaar __asm __volatile("isync; tlbre"); 2904a49da83SMarcel Moolenaar tlb1[0] = mfspr(SPR_MAS1); 2914a49da83SMarcel Moolenaar tlb1[1] = mfspr(SPR_MAS2); 2924a49da83SMarcel Moolenaar tlb1[2] = mfspr(SPR_MAS3); 2934a49da83SMarcel Moolenaar i++; 2944a49da83SMarcel Moolenaar tlb1 += 3; 2954a49da83SMarcel Moolenaar } 2964a49da83SMarcel Moolenaar if (i < bp_ntlb1s) 2974a49da83SMarcel Moolenaar bp_ntlb1s = i; 29828bb01e5SRafal Jaworowski 29928bb01e5SRafal Jaworowski /* 30028bb01e5SRafal Jaworowski * Set BPTR to the physical address of the boot page 30128bb01e5SRafal Jaworowski */ 3024a49da83SMarcel Moolenaar bptr = ((uint32_t)__boot_page - KERNBASE) + kernload; 3034a49da83SMarcel Moolenaar KASSERT((bptr & 0xfff) == 0, 3044a49da83SMarcel Moolenaar ("%s: boot page is not aligned (%#x)", __func__, bptr)); 3054a49da83SMarcel Moolenaar bptr = (bptr >> 12) | 0x80000000u; 3064a49da83SMarcel Moolenaar ccsr_write4(OCP85XX_BPTR, bptr); 3074a49da83SMarcel Moolenaar __asm __volatile("isync; msync"); 3084a49da83SMarcel Moolenaar 3094a49da83SMarcel Moolenaar /* Flush caches to have our changes hit DRAM. */ 3104a49da83SMarcel Moolenaar cpu_flush_dcache(__boot_page, 4096); 31128bb01e5SRafal Jaworowski 31228bb01e5SRafal Jaworowski /* 31328bb01e5SRafal Jaworowski * Release AP from hold-off state 31428bb01e5SRafal Jaworowski */ 31520bf92c2SAttilio Rao eebpcr |= (1 << (pc->pc_cpuid + 24)); 31628bb01e5SRafal Jaworowski ccsr_write4(OCP85XX_EEBPCR, eebpcr); 31728bb01e5SRafal Jaworowski __asm __volatile("isync; msync"); 31828bb01e5SRafal Jaworowski 31928bb01e5SRafal Jaworowski timeout = 500; 32028bb01e5SRafal Jaworowski while (!pc->pc_awake && timeout--) 32128bb01e5SRafal Jaworowski DELAY(1000); /* wait 1ms */ 32228bb01e5SRafal Jaworowski 323a45d9127SMarcel Moolenaar /* 324a45d9127SMarcel Moolenaar * Disable boot page translation so that the 4K page at the default 325a45d9127SMarcel Moolenaar * address (= 0xfffff000) isn't permanently remapped and thus not 326a45d9127SMarcel Moolenaar * usable otherwise. 327a45d9127SMarcel Moolenaar */ 328a45d9127SMarcel Moolenaar ccsr_write4(OCP85XX_BPTR, 0); 3294a49da83SMarcel Moolenaar __asm __volatile("isync; msync"); 330a45d9127SMarcel Moolenaar 331a45d9127SMarcel Moolenaar if (!pc->pc_awake) 3324a49da83SMarcel Moolenaar printf("SMP: CPU %d didn't wake up.\n", pc->pc_cpuid); 33328bb01e5SRafal Jaworowski return ((pc->pc_awake) ? 0 : EBUSY); 33428bb01e5SRafal Jaworowski #else 335b40ce02aSNathan Whitehorn /* No SMP support */ 336b40ce02aSNathan Whitehorn return (ENXIO); 33728bb01e5SRafal Jaworowski #endif 338b40ce02aSNathan Whitehorn } 339b2a237beSNathan Whitehorn 340b2a237beSNathan Whitehorn static void 3412f6bd241SRafal Jaworowski booke_reset(platform_t plat) 342b2a237beSNathan Whitehorn { 343b2a237beSNathan Whitehorn 3447faf44baSMarcel Moolenaar /* 3457faf44baSMarcel Moolenaar * Try the dedicated reset register first. 3467faf44baSMarcel Moolenaar * If the SoC doesn't have one, we'll fall 3477faf44baSMarcel Moolenaar * back to using the debug control register. 3487faf44baSMarcel Moolenaar */ 349b2a237beSNathan Whitehorn ccsr_write4(OCP85XX_RSTCR, 2); 3507faf44baSMarcel Moolenaar 351b2a237beSNathan Whitehorn /* Clear DBCR0, disables debug interrupts and events. */ 352b2a237beSNathan Whitehorn mtspr(SPR_DBCR0, 0); 353b2a237beSNathan Whitehorn __asm __volatile("isync"); 354b2a237beSNathan Whitehorn 355b2a237beSNathan Whitehorn /* Enable Debug Interrupts in MSR. */ 356b2a237beSNathan Whitehorn mtmsr(mfmsr() | PSL_DE); 357b2a237beSNathan Whitehorn 358b2a237beSNathan Whitehorn /* Enable debug interrupts and issue reset. */ 3597faf44baSMarcel Moolenaar mtspr(SPR_DBCR0, mfspr(SPR_DBCR0) | DBCR0_IDM | DBCR0_RST_SYSTEM); 360b2a237beSNathan Whitehorn 361b2a237beSNathan Whitehorn printf("Reset failed...\n"); 3622f6bd241SRafal Jaworowski while (1) 3632f6bd241SRafal Jaworowski ; 364b2a237beSNathan Whitehorn } 365b2a237beSNathan Whitehorn 366