iq31244_machdep.c revision 1.1 1 1.1 briggs /* $NetBSD: iq31244_machdep.c,v 1.1 2009/01/09 16:23:59 briggs Exp $ */
2 1.1 briggs
3 1.1 briggs /*
4 1.1 briggs * Copyright (c) 2009 The NetBSD Foundation, Inc.
5 1.1 briggs * All rights reserved.
6 1.1 briggs *
7 1.1 briggs * Redistribution and use in source and binary forms, with or without
8 1.1 briggs * modification, are permitted provided that the following conditions
9 1.1 briggs * are met:
10 1.1 briggs * 1. Redistributions of source code must retain the above copyright
11 1.1 briggs * notice, this list of conditions and the following disclaimer.
12 1.1 briggs * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 briggs * notice, this list of conditions and the following disclaimer in the
14 1.1 briggs * documentation and/or other materials provided with the distribution.
15 1.1 briggs *
16 1.1 briggs * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1 briggs * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1 briggs * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1 briggs * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1 briggs * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1 briggs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1 briggs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1 briggs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1 briggs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1 briggs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 briggs * POSSIBILITY OF SUCH DAMAGE.
27 1.1 briggs */
28 1.1 briggs
29 1.1 briggs #include <sys/cdefs.h>
30 1.1 briggs __KERNEL_RCSID(0, "$NetBSD: iq31244_machdep.c,v 1.1 2009/01/09 16:23:59 briggs Exp $");
31 1.1 briggs
32 1.1 briggs #include <sys/param.h>
33 1.1 briggs #include <sys/device.h>
34 1.1 briggs #include <sys/systm.h>
35 1.1 briggs #include <sys/kernel.h>
36 1.1 briggs #include <sys/reboot.h>
37 1.1 briggs
38 1.1 briggs #include <dev/i2c/m41st84var.h>
39 1.1 briggs
40 1.1 briggs void iq31244_reboot(int); /* I80321_REBOOT */
41 1.1 briggs
42 1.1 briggs /*
43 1.1 briggs * Resetting the peripherals like the IQ80321 does isn't
44 1.1 briggs * a sufficient reset for the IQ31244. With the stock
45 1.1 briggs * Redboot, that reset will leave it in the Redboot
46 1.1 briggs * debugger on reinit.
47 1.1 briggs * The IQ31244 has an M41ST84, however, that can reset
48 1.1 briggs * the board with the watchdog. So we just set it to
49 1.1 briggs * do so here.
50 1.1 briggs * The wdog on the 41ST84 should probably be a real
51 1.1 briggs * device, but for now, we just kick it here.
52 1.1 briggs */
53 1.1 briggs void
54 1.1 briggs iq31244_reboot(int howto)
55 1.1 briggs {
56 1.1 briggs
57 1.1 briggs /* We can't halt; just reset. */
58 1.1 briggs if ((howto & RB_HALT) == 0) {
59 1.1 briggs device_t dv;
60 1.1 briggs
61 1.1 briggs dv = device_find_by_xname("strtc0");
62 1.1 briggs if (dv == NULL)
63 1.1 briggs {
64 1.1 briggs printf("No strtc0! Reset will probably fail!\n");
65 1.1 briggs return;
66 1.1 briggs }
67 1.1 briggs
68 1.1 briggs /*
69 1.1 briggs * 0x80 == steer to reset
70 1.1 briggs * 0x04 == multiplier 1, resolution 1/16s
71 1.1 briggs */
72 1.1 briggs strtc_wdog_config(device_private(dv), 0x84);
73 1.1 briggs delay(10000);
74 1.1 briggs }
75 1.1 briggs }
76