ARM: sunxi: New watchdog driver for Allwinner A10/A13
Subsystems (2)
PATCH v6 1/1 ARM: sunxi: New watchdog driver for Allwinner A10/A13
This patch adds the driver for the watchdog found in the Allwinner A10 and A13 SoCs. It has DT-support and uses the new watchdog framework.
Signed-off-by Carlo Caione <[email protected]>
Acked-by Maxime Ripard <[email protected]>
--- drivers/watchdog/Kconfig | 10 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sunxi_wdt.c | 241 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 252 insertions(+) create mode 100644 drivers/watchdog/sunxi_wdt.c
drivers/watchdog/Kconfig +10 -0
@@ -290,6 +290,16 @@ config ORION_WATCHDOG To compile this driver as a module, choose M here: the module will be called orion_wdt. +config SUNXI_WATCHDOG + tristate "Allwinner SoCs watchdog support" + depends on ARCH_SUNXI + select WATCHDOG_CORE + help + Say Y here to include support for the watchdog timer + in Allwinner SoCs. + To compile this driver as a module, choose M here: the + module will be called sunxi_wdt. + config COH901327_WATCHDOG bool "ST-Ericsson COH 901 327 watchdog" depends on ARCH_U300
drivers/watchdog/Makefile +1 -0
@@ -46,6 +46,7 @@ obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o obj-$(CONFIG_ORION_WATCHDOG) += orion_wdt.o +obj-$(CONFIG_SUNXI_WATCHDOG) += sunxi_wdt.o obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o obj-$(CONFIG_STMP3XXX_RTC_WATCHDOG) += stmp3xxx_rtc_wdt.o obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
drivers/watchdog/sunxi_wdt.c new file +241 -0
241 lines not on this page · raw message
Signature · 1 line
1.8.3.3
Guenter Roeck
maintainerPATCH v6 1/1 ARM: sunxi: New watchdog driver for Allwinner A10/A13
Quoted 65 lines · Carlo Caione
This patch adds the driver for the watchdog found in the Allwinner A10 and A13 SoCs. It has DT-support and uses the new watchdog framework.
Signed-off-by Carlo Caione <[email protected]>Acked-by Maxime Ripard <[email protected]>--- drivers/watchdog/Kconfig | 10 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/sunxi_wdt.c | 241 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 252 insertions(+) create mode 100644 drivers/watchdog/sunxi_wdt.cdrivers/watchdog/Kconfig +10
-0@@ -290,6 +290,16 @@ config ORION_WATCHDOG To compile this driver as a module, choose M here: the module will be called orion_wdt. +config SUNXI_WATCHDOG + tristate "Allwinner SoCs watchdog support" + depends on ARCH_SUNXI + select WATCHDOG_CORE + help + Say Y here to include support for the watchdog timer + in Allwinner SoCs. + To compile this driver as a module, choose M here: the + module will be called sunxi_wdt. + config COH901327_WATCHDOG bool "ST-Ericsson COH 901 327 watchdog" depends on ARCH_U300drivers/watchdog/Makefile +1
-0@@ -46,6 +46,7 @@ obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o obj-$(CONFIG_ORION_WATCHDOG) += orion_wdt.o +obj-$(CONFIG_SUNXI_WATCHDOG) += sunxi_wdt.o obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o obj-$(CONFIG_STMP3XXX_RTC_WATCHDOG) += stmp3xxx_rtc_wdt.o obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.odrivers/watchdog/sunxi_wdt.c new file +14
-0@@ -0,0 +1,241 @@ +/* +* sunxi Watchdog Driver +* +* Copyright (c) 2013 Carlo Caione +* 2012 Henrik Nordstrom +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +* +* Based on xen_wdt.c +* (c) Copyright 2010 Novell, Inc. +*/
drivers/watchdog/sunxi_wdt.c line 24
Quoted 10 lines
drivers/watchdog/sunxi_wdt.c new file +10
-0+ +#include <linux/clk.h> +#include <linux/err.h> +#include <linux/init.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/of.h> +#include <linux/of_address.h>
Is this include file really needed ?
Quoted 59 lines
drivers/watchdog/sunxi_wdt.c new file +59
-0+#include <linux/platform_device.h> +#include <linux/types.h> +#include <linux/watchdog.h> + +#define WDT_MAX_TIMEOUT 16 +#define WDT_MIN_TIMEOUT 1 +#define WDT_MODE_TIMEOUT (n) ((n) << 3) +#define WDT_TIMEOUT_MASK WDT_MODE_TIMEOUT(0x0F) + +#define WDT_CTRL 0x00 +#define WDT_CTRL_RELOAD ((1 << 0) | (0x0a57 << 1)) + +#define WDT_MODE 0x04 +#define WDT_MODE_EN (1 << 0) +#define WDT_MODE_RST_EN (1 << 1) + +#define DRV_NAME "sunxi-wdt" +#define DRV_VERSION "1.0" + +static bool nowayout =WATCHDOG_NOWAYOUT ; +static unsigned int timeout =WDT_MAX_TIMEOUT ; + +struct sunxi_wdt_dev { +struct watchdog_device wdt_dev; +void __iomem *wdt_base; +}; + +/* +* wdt_timeout_map maps the watchdog timer interval value in seconds to +* the value of the register WDT_MODE bit 3:6 +* +* [timeout seconds] = register value +* +*/ + +static const int wdt_timeout_map[] = { + [1 ] =0b0001 ,/* 1s */ + [2 ] =0b0010 ,/* 2s */ + [3 ] =0b0011 ,/* 3s */ + [4 ] =0b0100 ,/* 4s */ + [5 ] =0b0101 ,/* 5s */ + [6 ] =0b0110 ,/* 6s */ + [8 ] =0b0111 ,/* 8s */ + [10 ] =0b1000 ,/* 10s */ + [12 ] =0b1001 ,/* 12s */ + [14 ] =0b1010 ,/* 14s */ + [16 ] =0b1011 ,/* 16s */ +}; + +static int sunxi_wdt_ping (struct watchdog_device *wdt_dev) +{ +struct sunxi_wdt_dev *sunxi_wdt =watchdog_get_drvdata (wdt_dev); +void __iomem *wdt_base = sunxi_wdt->wdt_base; + +iowrite32 (WDT_CTRL_RELOAD , wdt_base +WDT_CTRL ); + +return 0 ; +} +
drivers/watchdog/sunxi_wdt.c line 93
Quoted 10 lines
drivers/watchdog/sunxi_wdt.c new file +10
-0+static int sunxi_wdt_set_timeout (struct watchdog_device *wdt_dev, +unsigned int timeout) +{ +struct sunxi_wdt_dev *sunxi_wdt =watchdog_get_drvdata (wdt_dev); +void __iomem *wdt_base = sunxi_wdt->wdt_base; +u32 reg; + +if (timeout >WDT_MAX_TIMEOUT ) +return -EINVAL ; +
This check is already done by the infrastructure and thus not needed here.
Guenter