| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: a9wdt.c,v 1.3 2015/02/27 18:43:28 jmcneill Exp $ */ | | 1 | /* $NetBSD: a9wdt.c,v 1.4 2015/03/04 23:18:21 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2012 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Matt Thomas | | 8 | * by Matt Thomas |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: a9wdt.c,v 1.3 2015/02/27 18:43:28 jmcneill Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: a9wdt.c,v 1.4 2015/03/04 23:18:21 jmcneill Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/bus.h> | | 36 | #include <sys/bus.h> |
37 | #include <sys/cpu.h> | | 37 | #include <sys/cpu.h> |
38 | #include <sys/device.h> | | 38 | #include <sys/device.h> |
39 | #include <sys/wdog.h> | | 39 | #include <sys/wdog.h> |
40 | | | 40 | |
41 | #include <prop/proplib.h> | | 41 | #include <prop/proplib.h> |
42 | | | 42 | |
43 | #include <dev/sysmon/sysmonvar.h> | | 43 | #include <dev/sysmon/sysmonvar.h> |
44 | | | 44 | |
45 | #include <arm/cortex/a9tmr_reg.h> | | 45 | #include <arm/cortex/a9tmr_reg.h> |
46 | | | 46 | |
| @@ -176,26 +176,27 @@ a9wdt_setmode(struct sysmon_wdog *smw) | | | @@ -176,26 +176,27 @@ a9wdt_setmode(struct sysmon_wdog *smw) |
176 | a9wdt_wdog_write(sc, TMR_CTL, sc->sc_wdog_ctl); | | 176 | a9wdt_wdog_write(sc, TMR_CTL, sc->sc_wdog_ctl); |
177 | | | 177 | |
178 | aprint_debug_dev(sc->sc_dev, "setmode enable\n"); | | 178 | aprint_debug_dev(sc->sc_dev, "setmode enable\n"); |
179 | return 0; | | 179 | return 0; |
180 | } | | 180 | } |
181 | | | 181 | |
182 | | | 182 | |
183 | static void | | 183 | static void |
184 | a9wdt_attach(device_t parent, device_t self, void *aux) | | 184 | a9wdt_attach(device_t parent, device_t self, void *aux) |
185 | { | | 185 | { |
186 | struct a9wdt_softc * const sc = device_private(self); | | 186 | struct a9wdt_softc * const sc = device_private(self); |
187 | struct mpcore_attach_args * const mpcaa = aux; | | 187 | struct mpcore_attach_args * const mpcaa = aux; |
188 | prop_dictionary_t dict = device_properties(self); | | 188 | prop_dictionary_t dict = device_properties(self); |
| | | 189 | const char *cpu_type; |
189 | | | 190 | |
190 | sc->sc_dev = self; | | 191 | sc->sc_dev = self; |
191 | sc->sc_memt = mpcaa->mpcaa_memt; | | 192 | sc->sc_memt = mpcaa->mpcaa_memt; |
192 | | | 193 | |
193 | bus_space_subregion(sc->sc_memt, mpcaa->mpcaa_memh, | | 194 | bus_space_subregion(sc->sc_memt, mpcaa->mpcaa_memh, |
194 | TMR_WDOG_BASE, TMR_WDOG_SIZE, &sc->sc_wdog_memh); | | 195 | TMR_WDOG_BASE, TMR_WDOG_SIZE, &sc->sc_wdog_memh); |
195 | | | 196 | |
196 | /* | | 197 | /* |
197 | * This runs at the ARM PERIPHCLOCK which should be 1/2 of the | | 198 | * This runs at the ARM PERIPHCLOCK which should be 1/2 of the |
198 | * CPU clock. The MD code should have setup our frequency for us. | | 199 | * CPU clock. The MD code should have setup our frequency for us. |
199 | */ | | 200 | */ |
200 | prop_dictionary_get_uint32(dict, "frequency", &sc->sc_freq); | | 201 | prop_dictionary_get_uint32(dict, "frequency", &sc->sc_freq); |
201 | | | 202 | |
| @@ -220,28 +221,33 @@ a9wdt_attach(device_t parent, device_t s | | | @@ -220,28 +221,33 @@ a9wdt_attach(device_t parent, device_t s |
220 | } | | 221 | } |
221 | } | | 222 | } |
222 | sc->sc_freq /= sc->sc_wdog_prescaler; | | 223 | sc->sc_freq /= sc->sc_wdog_prescaler; |
223 | } | | 224 | } |
224 | sc->sc_wdog_max_period = UINT32_MAX / sc->sc_freq; | | 225 | sc->sc_wdog_max_period = UINT32_MAX / sc->sc_freq; |
225 | | | 226 | |
226 | /* | | 227 | /* |
227 | * Does the config file tell us to turn on the watchdog? | | 228 | * Does the config file tell us to turn on the watchdog? |
228 | */ | | 229 | */ |
229 | if (device_cfdata(self)->cf_flags & 1) | | 230 | if (device_cfdata(self)->cf_flags & 1) |
230 | sc->sc_wdog_armed = true; | | 231 | sc->sc_wdog_armed = true; |
231 | | | 232 | |
232 | aprint_naive("\n"); | | 233 | aprint_naive("\n"); |
233 | aprint_normal(": A9 Watchdog Timer, default period is %u seconds%s\n", | | 234 | if (CPU_ID_CORTEX_A5_P(curcpu()->ci_arm_cpuid)) { |
234 | sc->sc_wdog_period, | | 235 | cpu_type = "A5"; |
| | | 236 | } else { |
| | | 237 | cpu_type = "A9"; |
| | | 238 | } |
| | | 239 | aprint_normal(": %s Watchdog Timer, default period is %u seconds%s\n", |
| | | 240 | cpu_type, sc->sc_wdog_period, |
235 | sc->sc_wdog_armed ? " (armed)" : ""); | | 241 | sc->sc_wdog_armed ? " (armed)" : ""); |
236 | | | 242 | |
237 | sc->sc_smw.smw_name = device_xname(self); | | 243 | sc->sc_smw.smw_name = device_xname(self); |
238 | sc->sc_smw.smw_cookie = sc; | | 244 | sc->sc_smw.smw_cookie = sc; |
239 | sc->sc_smw.smw_setmode = a9wdt_setmode; | | 245 | sc->sc_smw.smw_setmode = a9wdt_setmode; |
240 | sc->sc_smw.smw_tickle = a9wdt_tickle; | | 246 | sc->sc_smw.smw_tickle = a9wdt_tickle; |
241 | sc->sc_smw.smw_period = sc->sc_wdog_period; | | 247 | sc->sc_smw.smw_period = sc->sc_wdog_period; |
242 | | | 248 | |
243 | if (sc->sc_wdog_armed) { | | 249 | if (sc->sc_wdog_armed) { |
244 | int error = sysmon_wdog_setmode(&sc->sc_smw, WDOG_MODE_KTICKLE, | | 250 | int error = sysmon_wdog_setmode(&sc->sc_smw, WDOG_MODE_KTICKLE, |
245 | sc->sc_wdog_period); | | 251 | sc->sc_wdog_period); |
246 | if (error) | | 252 | if (error) |
247 | aprint_error_dev(self, | | 253 | aprint_error_dev(self, |