Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/amlogic Add watchdog timer support.
details: https://anonhg.NetBSD.org/src/rev/32a9342a4c1a
branches: trunk
changeset: 341748:32a9342a4c1a
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Nov 21 00:54:57 2015 +0000
description:
Add watchdog timer support.
diffstat:
sys/arch/arm/amlogic/amlogic_board.c | 59 ++++++++++++++++++++++++++++++++++-
sys/arch/arm/amlogic/amlogic_io.c | 5 +-
sys/arch/arm/amlogic/amlogic_var.h | 3 +-
3 files changed, 62 insertions(+), 5 deletions(-)
diffs (138 lines):
diff -r f55fdc3129bf -r 32a9342a4c1a sys/arch/arm/amlogic/amlogic_board.c
--- a/sys/arch/arm/amlogic/amlogic_board.c Sat Nov 21 00:50:15 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_board.c Sat Nov 21 00:54:57 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_board.c,v 1.14 2015/08/08 10:51:40 jmcneill Exp $ */
+/* $NetBSD: amlogic_board.c,v 1.15 2015/11/21 00:54:57 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,13 +29,16 @@
#include "opt_amlogic.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amlogic_board.c,v 1.14 2015/08/08 10:51:40 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amlogic_board.c,v 1.15 2015/11/21 00:54:57 jmcneill Exp $");
#define _ARM32_BUS_DMA_PRIVATE
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/cpu.h>
#include <sys/device.h>
+#include <sys/wdog.h>
+
+#include <dev/sysmon/sysmonvar.h>
#include <uvm/uvm_extern.h>
@@ -46,8 +49,22 @@
#include <arm/amlogic/amlogic_crureg.h>
#include <arm/amlogic/amlogic_var.h>
+#define AMLOGIC_EE_WDOG_PERIOD_DEFAULT 8
+#define AMLOGIC_EE_WDOG_PERIOD_MAX 8
+#define AMLOGIC_EE_WDOG_TICKS_PER_SEC 7812
+
bus_space_handle_t amlogic_core_bsh;
+static int amlogic_ee_wdog_setmode(struct sysmon_wdog *);
+static int amlogic_ee_wdog_tickle(struct sysmon_wdog *);
+
+static struct sysmon_wdog amlogic_ee_wdog = {
+ .smw_name = "EE-watchdog",
+ .smw_setmode = amlogic_ee_wdog_setmode,
+ .smw_tickle = amlogic_ee_wdog_tickle,
+ .smw_period = AMLOGIC_EE_WDOG_PERIOD_DEFAULT
+};
+
struct arm32_bus_dma_tag amlogic_dma_tag = {
_BUS_DMAMAP_FUNCS,
_BUS_DMAMEM_FUNCS,
@@ -223,6 +240,44 @@
}
void
+amlogic_wdog_init(void)
+{
+ sysmon_wdog_register(&amlogic_ee_wdog);
+}
+
+static int
+amlogic_ee_wdog_setmode(struct sysmon_wdog *smw)
+{
+ if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) {
+ CBUS_WRITE(WATCHDOG_RESET_REG, 0);
+ CBUS_SET_CLEAR(WATCHDOG_TC_REG, 0, WATCHDOG_TC_ENABLE);
+ return 0;
+ }
+
+ if (smw->smw_period == WDOG_PERIOD_DEFAULT) {
+ amlogic_ee_wdog.smw_period = AMLOGIC_EE_WDOG_PERIOD_DEFAULT;
+ } else if (smw->smw_period == 0 ||
+ smw->smw_period > AMLOGIC_EE_WDOG_PERIOD_MAX) {
+ return EINVAL;
+ } else {
+ amlogic_ee_wdog.smw_period = smw->smw_period;
+ }
+ u_int tcnt = amlogic_ee_wdog.smw_period * AMLOGIC_EE_WDOG_TICKS_PER_SEC;
+ CBUS_WRITE(WATCHDOG_RESET_REG, 0);
+ CBUS_WRITE(WATCHDOG_TC_REG, WATCHDOG_TC_CPUS | WATCHDOG_TC_ENABLE |
+ __SHIFTIN(tcnt, WATCHDOG_TC_TCNT));
+
+ return 0;
+}
+
+static int
+amlogic_ee_wdog_tickle(struct sysmon_wdog *smw)
+{
+ CBUS_WRITE(WATCHDOG_RESET_REG, 0);
+ return 0;
+}
+
+void
amlogic_sdhc_init(void)
{
/* enable SDHC clk */
diff -r f55fdc3129bf -r 32a9342a4c1a sys/arch/arm/amlogic/amlogic_io.c
--- a/sys/arch/arm/amlogic/amlogic_io.c Sat Nov 21 00:50:15 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_io.c Sat Nov 21 00:54:57 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_io.c,v 1.12 2015/08/08 14:01:44 jmcneill Exp $ */
+/* $NetBSD: amlogic_io.c,v 1.13 2015/11/21 00:54:57 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_amlogic.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amlogic_io.c,v 1.12 2015/08/08 14:01:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amlogic_io.c,v 1.13 2015/11/21 00:54:57 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -99,6 +99,7 @@
aprint_naive("\n");
aprint_normal("\n");
+ amlogic_wdog_init();
amlogic_usbphy_init(0);
amlogic_usbphy_init(1);
diff -r f55fdc3129bf -r 32a9342a4c1a sys/arch/arm/amlogic/amlogic_var.h
--- a/sys/arch/arm/amlogic/amlogic_var.h Sat Nov 21 00:50:15 2015 +0000
+++ b/sys/arch/arm/amlogic/amlogic_var.h Sat Nov 21 00:54:57 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amlogic_var.h,v 1.11 2015/08/04 01:23:07 jmcneill Exp $ */
+/* $NetBSD: amlogic_var.h,v 1.12 2015/11/21 00:54:57 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -59,6 +59,7 @@
void amlogic_cpufreq_bootstrap(void);
void amlogic_cpufreq_init(void);
+void amlogic_wdog_init(void);
void amlogic_usbphy_init(int);
void amlogic_eth_init(void);
void amlogic_rng_init(void);
Home |
Main Index |
Thread Index |
Old Index