1a1cd472aSRafal Jaworowski /*- 2a1cd472aSRafal Jaworowski * Copyright (C) 2008 Semihalf, Rafal Jaworowski 3a1cd472aSRafal Jaworowski * All rights reserved. 4a1cd472aSRafal Jaworowski * 5a1cd472aSRafal Jaworowski * Redistribution and use in source and binary forms, with or without 6a1cd472aSRafal Jaworowski * modification, are permitted provided that the following conditions 7a1cd472aSRafal Jaworowski * are met: 8a1cd472aSRafal Jaworowski * 1. Redistributions of source code must retain the above copyright 9a1cd472aSRafal Jaworowski * notice, this list of conditions and the following disclaimer. 10a1cd472aSRafal Jaworowski * 2. Redistributions in binary form must reproduce the above copyright 11a1cd472aSRafal Jaworowski * notice, this list of conditions and the following disclaimer in the 12a1cd472aSRafal Jaworowski * documentation and/or other materials provided with the distribution. 13a1cd472aSRafal Jaworowski * 3. Neither the name of the author nor the names of contributors 14a1cd472aSRafal Jaworowski * may be used to endorse or promote products derived from this software 15a1cd472aSRafal Jaworowski * without specific prior written permission. 16a1cd472aSRafal Jaworowski * 17a1cd472aSRafal Jaworowski * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18a1cd472aSRafal Jaworowski * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19a1cd472aSRafal Jaworowski * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20a1cd472aSRafal Jaworowski * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 21a1cd472aSRafal Jaworowski * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22a1cd472aSRafal Jaworowski * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23a1cd472aSRafal Jaworowski * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24a1cd472aSRafal Jaworowski * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25a1cd472aSRafal Jaworowski * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26a1cd472aSRafal Jaworowski * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27a1cd472aSRafal Jaworowski * SUCH DAMAGE. 28a1cd472aSRafal Jaworowski */ 29a1cd472aSRafal Jaworowski 30a1cd472aSRafal Jaworowski #include <sys/cdefs.h> 31a1cd472aSRafal Jaworowski __FBSDID("$FreeBSD$"); 32a1cd472aSRafal Jaworowski 33a1cd472aSRafal Jaworowski #include <sys/param.h> 34a1cd472aSRafal Jaworowski #include <sys/systm.h> 35a1cd472aSRafal Jaworowski 368b79898eSRafal Jaworowski #include <vm/vm.h> 378b79898eSRafal Jaworowski #include <vm/vm_param.h> 388b79898eSRafal Jaworowski 39a1cd472aSRafal Jaworowski #include <machine/cpu.h> 40a1cd472aSRafal Jaworowski #include <machine/cpufunc.h> 418b79898eSRafal Jaworowski #include <machine/pio.h> 42a1cd472aSRafal Jaworowski #include <machine/spr.h> 43a1cd472aSRafal Jaworowski 448b79898eSRafal Jaworowski #include <powerpc/mpc85xx/ocpbus.h> 458b79898eSRafal Jaworowski 46a1cd472aSRafal Jaworowski /* 47a1cd472aSRafal Jaworowski * MPC85xx system specific routines 48a1cd472aSRafal Jaworowski */ 49a1cd472aSRafal Jaworowski 50a1cd472aSRafal Jaworowski void 51a1cd472aSRafal Jaworowski cpu_reset() 52a1cd472aSRafal Jaworowski { 538b79898eSRafal Jaworowski uint32_t svr = mfsvr(); 54a1cd472aSRafal Jaworowski 558b79898eSRafal Jaworowski if (svr == SVR_MPC8572E || svr == SVR_MPC8572) 568b79898eSRafal Jaworowski /* Systems with dedicated reset register */ 578b79898eSRafal Jaworowski out32(OCP85XX_RSTCR, 2); 588b79898eSRafal Jaworowski else { 59a1cd472aSRafal Jaworowski /* Clear DBCR0, disables debug interrupts and events. */ 60a1cd472aSRafal Jaworowski mtspr(SPR_DBCR0, 0); 61a1cd472aSRafal Jaworowski __asm volatile("isync"); 62a1cd472aSRafal Jaworowski 63a1cd472aSRafal Jaworowski /* Enable Debug Interrupts in MSR. */ 64a1cd472aSRafal Jaworowski mtmsr(mfmsr() | PSL_DE); 65a1cd472aSRafal Jaworowski 66a1cd472aSRafal Jaworowski /* Enable debug interrupts and issue reset. */ 67a1cd472aSRafal Jaworowski mtspr(SPR_DBCR0, mfspr(SPR_DBCR0) | DBCR0_IDM | DBCR0_RST_SYSTEM); 688b79898eSRafal Jaworowski } 698b79898eSRafal Jaworowski 70a1cd472aSRafal Jaworowski printf("Reset failed...\n"); 71a1cd472aSRafal Jaworowski while (1); 72a1cd472aSRafal Jaworowski } 73