1161370Simp/*- 2161370Simp * Copyright (c) 2006 M. Warner Losh. All rights reserved. 3161370Simp * 4161370Simp * Redistribution and use in source and binary forms, with or without 5161370Simp * modification, are permitted provided that the following conditions 6161370Simp * are met: 7161370Simp * 1. Redistributions of source code must retain the above copyright 8161370Simp * notice, this list of conditions and the following disclaimer. 9161370Simp * 2. Redistributions in binary form must reproduce the above copyright 10161370Simp * notice, this list of conditions and the following disclaimer in the 11161370Simp * documentation and/or other materials provided with the distribution. 12161370Simp * 13161370Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14161370Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15161370Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16161370Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17161370Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18161370Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19161370Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20161370Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21161370Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22161370Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23161370Simp * 24161370Simp * $FreeBSD: releng/11.0/sys/boot/arm/at91/libat91/reset.c 161370 2006-08-16 23:39:58Z imp $ 25161370Simp */ 26161370Simp 27161370Simp#include "at91rm9200.h" 28161370Simp#include "lib.h" 29161370Simp 30161370Simp/* 31161370Simp * void reset() 32161370Simp * 33161370Simp * Forces a reset of the system. Uses watchdog timer of '1', which 34161370Simp * corresponds to 128 / SLCK seconds (SLCK is 32,768 Hz, so 128/32768 is 35161370Simp * 1 / 256 ~= 5.4ms 36161370Simp */ 37161370Simpvoid 38161370Simpreset(void) 39161370Simp{ 40161370Simp // The following should effect a reset. 41161370Simp AT91C_BASE_ST->ST_WDMR = 1 | AT91C_ST_RSTEN; 42161370Simp AT91C_BASE_ST->ST_CR = AT91C_ST_WDRST; 43161370Simp} 44161370Simp 45161370Simp/* 46161370Simp * void start_wdog() 47161370Simp * 48161370Simp * Starts a watchdog timer. We force the boot process to get to the point 49161370Simp * it can kick the watch dog part of the ST part for the OS's driver. 50161370Simp */ 51161370Simpvoid 52161370Simpstart_wdog(int n) 53161370Simp{ 54161370Simp // The following should effect a reset after N seconds. 55161370Simp AT91C_BASE_ST->ST_WDMR = (n * (32768 / 128)) | AT91C_ST_RSTEN; 56161370Simp AT91C_BASE_ST->ST_CR = AT91C_ST_WDRST; 57161370Simp} 58