2006-09-29 16:59:18 +08:00
|
|
|
/*
|
2008-09-20 09:14:01 +08:00
|
|
|
* omap_wdt.c
|
2006-09-29 16:59:18 +08:00
|
|
|
*
|
2008-09-20 09:14:01 +08:00
|
|
|
* Watchdog driver for the TI OMAP 16xx & 24xx/34xx 32KHz (non-secure) watchdog
|
2006-09-29 16:59:18 +08:00
|
|
|
*
|
|
|
|
* Author: MontaVista Software, Inc.
|
|
|
|
* <gdavis@mvista.com> or <source@mvista.com>
|
|
|
|
*
|
|
|
|
* 2003 (c) MontaVista Software, Inc. This file is licensed under the
|
|
|
|
* terms of the GNU General Public License version 2. This program is
|
|
|
|
* licensed "as is" without any warranty of any kind, whether express
|
|
|
|
* or implied.
|
|
|
|
*
|
|
|
|
* History:
|
|
|
|
*
|
|
|
|
* 20030527: George G. Davis <gdavis@mvista.com>
|
|
|
|
* Initially based on linux-2.4.19-rmk7-pxa1/drivers/char/sa1100_wdt.c
|
|
|
|
* (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
|
2008-10-27 23:17:56 +08:00
|
|
|
* Based on SoftDog driver by Alan Cox <alan@lxorguk.ukuu.org.uk>
|
2006-09-29 16:59:18 +08:00
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Texas Instruments.
|
|
|
|
* 1. Modified to support OMAP1610 32-KHz watchdog timer
|
|
|
|
* 2. Ported to 2.6 kernel
|
|
|
|
*
|
|
|
|
* Copyright (c) 2005 David Brownell
|
|
|
|
* Use the driver model and standard identifiers; handle bigger timeouts.
|
|
|
|
*/
|
|
|
|
|
2012-02-16 07:06:19 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/watchdog.h>
|
|
|
|
#include <linux/reboot.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/moduleparam.h>
|
2008-07-15 19:46:11 +08:00
|
|
|
#include <linux/io.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2010-09-23 22:32:43 +08:00
|
|
|
#include <linux/pm_runtime.h>
|
2012-10-30 10:49:44 +08:00
|
|
|
#include <linux/platform_data/omap-wd-timer.h>
|
2006-09-29 16:59:18 +08:00
|
|
|
|
|
|
|
#include "omap_wdt.h"
|
|
|
|
|
2013-02-17 07:49:26 +08:00
|
|
|
static bool nowayout = WATCHDOG_NOWAYOUT;
|
|
|
|
module_param(nowayout, bool, 0);
|
|
|
|
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
|
|
|
|
"(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
|
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
static unsigned timer_margin;
|
|
|
|
module_param(timer_margin, uint, 0);
|
|
|
|
MODULE_PARM_DESC(timer_margin, "initial watchdog timeout (in seconds)");
|
|
|
|
|
2015-04-27 17:23:00 +08:00
|
|
|
#define to_omap_wdt_dev(_wdog) container_of(_wdog, struct omap_wdt_dev, wdog)
|
|
|
|
|
2015-06-25 18:21:51 +08:00
|
|
|
static bool early_enable;
|
|
|
|
module_param(early_enable, bool, 0);
|
|
|
|
MODULE_PARM_DESC(early_enable,
|
|
|
|
"Watchdog is started on module insertion (default=0)");
|
|
|
|
|
2008-09-20 09:14:01 +08:00
|
|
|
struct omap_wdt_dev {
|
2015-04-27 17:23:00 +08:00
|
|
|
struct watchdog_device wdog;
|
2008-09-20 09:14:01 +08:00
|
|
|
void __iomem *base; /* physical */
|
|
|
|
struct device *dev;
|
2012-10-11 04:23:32 +08:00
|
|
|
bool omap_wdt_users;
|
|
|
|
int wdt_trgr_pattern;
|
|
|
|
struct mutex lock; /* to avoid races with PM */
|
2008-09-20 09:14:01 +08:00
|
|
|
};
|
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
static void omap_wdt_reload(struct omap_wdt_dev *wdev)
|
2006-09-29 16:59:18 +08:00
|
|
|
{
|
2008-09-20 09:14:01 +08:00
|
|
|
void __iomem *base = wdev->base;
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
/* wait for posted write to complete */
|
2013-11-16 08:01:05 +08:00
|
|
|
while ((readl_relaxed(base + OMAP_WATCHDOG_WPS)) & 0x08)
|
2006-09-29 16:59:18 +08:00
|
|
|
cpu_relax();
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
wdev->wdt_trgr_pattern = ~wdev->wdt_trgr_pattern;
|
2013-11-16 08:01:05 +08:00
|
|
|
writel_relaxed(wdev->wdt_trgr_pattern, (base + OMAP_WATCHDOG_TGR));
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
/* wait for posted write to complete */
|
2013-11-16 08:01:05 +08:00
|
|
|
while ((readl_relaxed(base + OMAP_WATCHDOG_WPS)) & 0x08)
|
2006-09-29 16:59:18 +08:00
|
|
|
cpu_relax();
|
|
|
|
/* reloaded WCRR from WLDR */
|
|
|
|
}
|
|
|
|
|
2008-09-20 09:14:01 +08:00
|
|
|
static void omap_wdt_enable(struct omap_wdt_dev *wdev)
|
2006-09-29 16:59:18 +08:00
|
|
|
{
|
2008-09-20 09:14:03 +08:00
|
|
|
void __iomem *base = wdev->base;
|
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
/* Sequence to enable the watchdog */
|
2013-11-16 08:01:05 +08:00
|
|
|
writel_relaxed(0xBBBB, base + OMAP_WATCHDOG_SPR);
|
|
|
|
while ((readl_relaxed(base + OMAP_WATCHDOG_WPS)) & 0x10)
|
2006-09-29 16:59:18 +08:00
|
|
|
cpu_relax();
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2013-11-16 08:01:05 +08:00
|
|
|
writel_relaxed(0x4444, base + OMAP_WATCHDOG_SPR);
|
|
|
|
while ((readl_relaxed(base + OMAP_WATCHDOG_WPS)) & 0x10)
|
2006-09-29 16:59:18 +08:00
|
|
|
cpu_relax();
|
|
|
|
}
|
|
|
|
|
2008-09-20 09:14:01 +08:00
|
|
|
static void omap_wdt_disable(struct omap_wdt_dev *wdev)
|
2006-09-29 16:59:18 +08:00
|
|
|
{
|
2008-09-20 09:14:03 +08:00
|
|
|
void __iomem *base = wdev->base;
|
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
/* sequence required to disable watchdog */
|
2013-11-16 08:01:05 +08:00
|
|
|
writel_relaxed(0xAAAA, base + OMAP_WATCHDOG_SPR); /* TIMER_MODE */
|
|
|
|
while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x10)
|
2006-09-29 16:59:18 +08:00
|
|
|
cpu_relax();
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2013-11-16 08:01:05 +08:00
|
|
|
writel_relaxed(0x5555, base + OMAP_WATCHDOG_SPR); /* TIMER_MODE */
|
|
|
|
while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x10)
|
2006-09-29 16:59:18 +08:00
|
|
|
cpu_relax();
|
|
|
|
}
|
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
static void omap_wdt_set_timer(struct omap_wdt_dev *wdev,
|
|
|
|
unsigned int timeout)
|
2006-09-29 16:59:18 +08:00
|
|
|
{
|
2012-10-11 04:23:32 +08:00
|
|
|
u32 pre_margin = GET_WLDR_VAL(timeout);
|
2008-09-20 09:14:03 +08:00
|
|
|
void __iomem *base = wdev->base;
|
2006-09-29 16:59:18 +08:00
|
|
|
|
|
|
|
/* just count up at 32 KHz */
|
2013-11-16 08:01:05 +08:00
|
|
|
while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x04)
|
2006-09-29 16:59:18 +08:00
|
|
|
cpu_relax();
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2013-11-16 08:01:05 +08:00
|
|
|
writel_relaxed(pre_margin, base + OMAP_WATCHDOG_LDR);
|
|
|
|
while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x04)
|
2006-09-29 16:59:18 +08:00
|
|
|
cpu_relax();
|
|
|
|
}
|
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
static int omap_wdt_start(struct watchdog_device *wdog)
|
2006-09-29 16:59:18 +08:00
|
|
|
{
|
2015-04-27 17:23:00 +08:00
|
|
|
struct omap_wdt_dev *wdev = to_omap_wdt_dev(wdog);
|
2008-09-20 09:14:03 +08:00
|
|
|
void __iomem *base = wdev->base;
|
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_lock(&wdev->lock);
|
|
|
|
|
|
|
|
wdev->omap_wdt_users = true;
|
2006-09-29 16:59:18 +08:00
|
|
|
|
2010-09-23 22:32:43 +08:00
|
|
|
pm_runtime_get_sync(wdev->dev);
|
2006-09-29 16:59:18 +08:00
|
|
|
|
2015-04-30 02:38:46 +08:00
|
|
|
/*
|
|
|
|
* Make sure the watchdog is disabled. This is unfortunately required
|
|
|
|
* because writing to various registers with the watchdog running has no
|
|
|
|
* effect.
|
|
|
|
*/
|
|
|
|
omap_wdt_disable(wdev);
|
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
/* initialize prescaler */
|
2013-11-16 08:01:05 +08:00
|
|
|
while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x01)
|
2006-09-29 16:59:18 +08:00
|
|
|
cpu_relax();
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2013-11-16 08:01:05 +08:00
|
|
|
writel_relaxed((1 << 5) | (PTV << 2), base + OMAP_WATCHDOG_CNTRL);
|
|
|
|
while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x01)
|
2006-09-29 16:59:18 +08:00
|
|
|
cpu_relax();
|
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
omap_wdt_set_timer(wdev, wdog->timeout);
|
|
|
|
omap_wdt_reload(wdev); /* trigger loading of new timeout value */
|
2008-09-20 09:14:01 +08:00
|
|
|
omap_wdt_enable(wdev);
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_unlock(&wdev->lock);
|
|
|
|
|
|
|
|
return 0;
|
2006-09-29 16:59:18 +08:00
|
|
|
}
|
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
static int omap_wdt_stop(struct watchdog_device *wdog)
|
2006-09-29 16:59:18 +08:00
|
|
|
{
|
2015-04-27 17:23:00 +08:00
|
|
|
struct omap_wdt_dev *wdev = to_omap_wdt_dev(wdog);
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_lock(&wdev->lock);
|
2008-09-20 09:14:01 +08:00
|
|
|
omap_wdt_disable(wdev);
|
2010-09-23 22:32:43 +08:00
|
|
|
pm_runtime_put_sync(wdev->dev);
|
2012-10-11 04:23:32 +08:00
|
|
|
wdev->omap_wdt_users = false;
|
|
|
|
mutex_unlock(&wdev->lock);
|
2006-09-29 16:59:18 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
static int omap_wdt_ping(struct watchdog_device *wdog)
|
2006-09-29 16:59:18 +08:00
|
|
|
{
|
2015-04-27 17:23:00 +08:00
|
|
|
struct omap_wdt_dev *wdev = to_omap_wdt_dev(wdog);
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_lock(&wdev->lock);
|
|
|
|
omap_wdt_reload(wdev);
|
|
|
|
mutex_unlock(&wdev->lock);
|
|
|
|
|
|
|
|
return 0;
|
2006-09-29 16:59:18 +08:00
|
|
|
}
|
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
static int omap_wdt_set_timeout(struct watchdog_device *wdog,
|
|
|
|
unsigned int timeout)
|
2006-09-29 16:59:18 +08:00
|
|
|
{
|
2015-04-27 17:23:00 +08:00
|
|
|
struct omap_wdt_dev *wdev = to_omap_wdt_dev(wdog);
|
2006-09-29 16:59:18 +08:00
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_lock(&wdev->lock);
|
|
|
|
omap_wdt_disable(wdev);
|
|
|
|
omap_wdt_set_timer(wdev, timeout);
|
|
|
|
omap_wdt_enable(wdev);
|
|
|
|
omap_wdt_reload(wdev);
|
|
|
|
wdog->timeout = timeout;
|
|
|
|
mutex_unlock(&wdev->lock);
|
|
|
|
|
|
|
|
return 0;
|
2006-09-29 16:59:18 +08:00
|
|
|
}
|
|
|
|
|
2015-06-17 16:58:59 +08:00
|
|
|
static unsigned int omap_wdt_get_timeleft(struct watchdog_device *wdog)
|
|
|
|
{
|
2015-11-02 10:20:20 +08:00
|
|
|
struct omap_wdt_dev *wdev = to_omap_wdt_dev(wdog);
|
2015-06-17 16:58:59 +08:00
|
|
|
void __iomem *base = wdev->base;
|
|
|
|
u32 value;
|
|
|
|
|
|
|
|
value = readl_relaxed(base + OMAP_WATCHDOG_CRR);
|
|
|
|
return GET_WCCR_SECS(value);
|
|
|
|
}
|
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
static const struct watchdog_info omap_wdt_info = {
|
2014-10-15 03:25:19 +08:00
|
|
|
.options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
|
2012-10-11 04:23:32 +08:00
|
|
|
.identity = "OMAP Watchdog",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct watchdog_ops omap_wdt_ops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.start = omap_wdt_start,
|
|
|
|
.stop = omap_wdt_stop,
|
|
|
|
.ping = omap_wdt_ping,
|
|
|
|
.set_timeout = omap_wdt_set_timeout,
|
2015-06-17 16:58:59 +08:00
|
|
|
.get_timeleft = omap_wdt_get_timeleft,
|
2006-09-29 16:59:18 +08:00
|
|
|
};
|
|
|
|
|
2012-11-20 02:21:41 +08:00
|
|
|
static int omap_wdt_probe(struct platform_device *pdev)
|
2006-09-29 16:59:18 +08:00
|
|
|
{
|
2013-07-30 18:58:51 +08:00
|
|
|
struct omap_wd_timer_platform_data *pdata = dev_get_platdata(&pdev->dev);
|
2014-02-11 20:44:12 +08:00
|
|
|
struct resource *res;
|
2008-09-20 09:14:01 +08:00
|
|
|
struct omap_wdt_dev *wdev;
|
2008-09-20 09:14:03 +08:00
|
|
|
int ret;
|
2006-09-29 16:59:18 +08:00
|
|
|
|
2012-10-11 04:23:33 +08:00
|
|
|
wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
|
|
|
|
if (!wdev)
|
|
|
|
return -ENOMEM;
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
wdev->omap_wdt_users = false;
|
|
|
|
wdev->dev = &pdev->dev;
|
|
|
|
wdev->wdt_trgr_pattern = 0x1234;
|
|
|
|
mutex_init(&wdev->lock);
|
2008-09-20 09:14:01 +08:00
|
|
|
|
2014-02-11 20:44:12 +08:00
|
|
|
/* reserve static register mappings */
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
wdev->base = devm_ioremap_resource(&pdev->dev, res);
|
|
|
|
if (IS_ERR(wdev->base))
|
|
|
|
return PTR_ERR(wdev->base);
|
2008-09-20 09:14:02 +08:00
|
|
|
|
2015-04-27 17:23:00 +08:00
|
|
|
wdev->wdog.info = &omap_wdt_info;
|
|
|
|
wdev->wdog.ops = &omap_wdt_ops;
|
|
|
|
wdev->wdog.min_timeout = TIMER_MARGIN_MIN;
|
|
|
|
wdev->wdog.max_timeout = TIMER_MARGIN_MAX;
|
2015-08-20 16:35:01 +08:00
|
|
|
wdev->wdog.parent = &pdev->dev;
|
2012-10-11 04:23:32 +08:00
|
|
|
|
2015-04-27 17:23:00 +08:00
|
|
|
if (watchdog_init_timeout(&wdev->wdog, timer_margin, &pdev->dev) < 0)
|
|
|
|
wdev->wdog.timeout = TIMER_MARGIN_DEFAULT;
|
2012-10-11 04:23:32 +08:00
|
|
|
|
2015-04-27 17:23:00 +08:00
|
|
|
watchdog_set_nowayout(&wdev->wdog, nowayout);
|
2012-10-11 04:23:32 +08:00
|
|
|
|
2015-04-27 17:23:00 +08:00
|
|
|
platform_set_drvdata(pdev, wdev);
|
2006-09-29 16:59:18 +08:00
|
|
|
|
2010-09-23 22:32:43 +08:00
|
|
|
pm_runtime_enable(wdev->dev);
|
|
|
|
pm_runtime_get_sync(wdev->dev);
|
2009-06-13 05:18:32 +08:00
|
|
|
|
2015-04-27 17:23:01 +08:00
|
|
|
if (pdata && pdata->read_reset_sources) {
|
|
|
|
u32 rs = pdata->read_reset_sources();
|
|
|
|
if (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT))
|
|
|
|
wdev->wdog.bootstatus = WDIOF_CARDRESET;
|
|
|
|
}
|
2006-09-29 16:59:18 +08:00
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
omap_wdt_disable(wdev);
|
2008-09-20 09:14:01 +08:00
|
|
|
|
2015-04-27 17:23:00 +08:00
|
|
|
ret = watchdog_register_device(&wdev->wdog);
|
2012-10-11 04:23:37 +08:00
|
|
|
if (ret) {
|
|
|
|
pm_runtime_disable(wdev->dev);
|
|
|
|
return ret;
|
|
|
|
}
|
2006-09-29 16:59:18 +08:00
|
|
|
|
2008-09-20 09:14:01 +08:00
|
|
|
pr_info("OMAP Watchdog Timer Rev 0x%02x: initial timeout %d sec\n",
|
2013-11-16 08:01:05 +08:00
|
|
|
readl_relaxed(wdev->base + OMAP_WATCHDOG_REV) & 0xFF,
|
2015-04-27 17:23:00 +08:00
|
|
|
wdev->wdog.timeout);
|
2006-09-29 16:59:18 +08:00
|
|
|
|
2015-06-25 18:21:51 +08:00
|
|
|
if (early_enable)
|
|
|
|
omap_wdt_start(&wdev->wdog);
|
|
|
|
|
2015-12-15 18:37:40 +08:00
|
|
|
pm_runtime_put(wdev->dev);
|
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void omap_wdt_shutdown(struct platform_device *pdev)
|
|
|
|
{
|
2015-04-27 17:23:00 +08:00
|
|
|
struct omap_wdt_dev *wdev = platform_get_drvdata(pdev);
|
2008-09-20 09:14:01 +08:00
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_lock(&wdev->lock);
|
2011-03-11 13:40:05 +08:00
|
|
|
if (wdev->omap_wdt_users) {
|
2008-09-20 09:14:01 +08:00
|
|
|
omap_wdt_disable(wdev);
|
2011-03-11 13:40:05 +08:00
|
|
|
pm_runtime_put_sync(wdev->dev);
|
|
|
|
}
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_unlock(&wdev->lock);
|
2006-09-29 16:59:18 +08:00
|
|
|
}
|
|
|
|
|
2012-11-20 02:26:24 +08:00
|
|
|
static int omap_wdt_remove(struct platform_device *pdev)
|
2006-09-29 16:59:18 +08:00
|
|
|
{
|
2015-04-27 17:23:00 +08:00
|
|
|
struct omap_wdt_dev *wdev = platform_get_drvdata(pdev);
|
2008-09-20 09:14:01 +08:00
|
|
|
|
2012-01-11 22:20:18 +08:00
|
|
|
pm_runtime_disable(wdev->dev);
|
2015-04-27 17:23:00 +08:00
|
|
|
watchdog_unregister_device(&wdev->wdog);
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
|
|
|
/* REVISIT ... not clear this is the best way to handle system suspend; and
|
|
|
|
* it's very inappropriate for selective device suspend (e.g. suspending this
|
|
|
|
* through sysfs rather than by stopping the watchdog daemon). Also, this
|
|
|
|
* may not play well enough with NOWAYOUT...
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int omap_wdt_suspend(struct platform_device *pdev, pm_message_t state)
|
|
|
|
{
|
2015-04-27 17:23:00 +08:00
|
|
|
struct omap_wdt_dev *wdev = platform_get_drvdata(pdev);
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_lock(&wdev->lock);
|
2011-03-11 13:40:05 +08:00
|
|
|
if (wdev->omap_wdt_users) {
|
2008-09-20 09:14:01 +08:00
|
|
|
omap_wdt_disable(wdev);
|
2011-03-11 13:40:05 +08:00
|
|
|
pm_runtime_put_sync(wdev->dev);
|
|
|
|
}
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_unlock(&wdev->lock);
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int omap_wdt_resume(struct platform_device *pdev)
|
|
|
|
{
|
2015-04-27 17:23:00 +08:00
|
|
|
struct omap_wdt_dev *wdev = platform_get_drvdata(pdev);
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_lock(&wdev->lock);
|
2008-09-20 09:14:01 +08:00
|
|
|
if (wdev->omap_wdt_users) {
|
2011-03-11 13:40:05 +08:00
|
|
|
pm_runtime_get_sync(wdev->dev);
|
2008-09-20 09:14:01 +08:00
|
|
|
omap_wdt_enable(wdev);
|
2012-10-11 04:23:32 +08:00
|
|
|
omap_wdt_reload(wdev);
|
2006-09-29 16:59:18 +08:00
|
|
|
}
|
2012-10-11 04:23:32 +08:00
|
|
|
mutex_unlock(&wdev->lock);
|
2008-09-20 09:14:03 +08:00
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define omap_wdt_suspend NULL
|
|
|
|
#define omap_wdt_resume NULL
|
|
|
|
#endif
|
|
|
|
|
2012-06-01 12:44:16 +08:00
|
|
|
static const struct of_device_id omap_wdt_of_match[] = {
|
|
|
|
{ .compatible = "ti,omap3-wdt", },
|
|
|
|
{},
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, omap_wdt_of_match);
|
|
|
|
|
2006-09-29 16:59:18 +08:00
|
|
|
static struct platform_driver omap_wdt_driver = {
|
|
|
|
.probe = omap_wdt_probe,
|
2012-11-20 02:21:12 +08:00
|
|
|
.remove = omap_wdt_remove,
|
2006-09-29 16:59:18 +08:00
|
|
|
.shutdown = omap_wdt_shutdown,
|
|
|
|
.suspend = omap_wdt_suspend,
|
|
|
|
.resume = omap_wdt_resume,
|
|
|
|
.driver = {
|
|
|
|
.name = "omap_wdt",
|
2012-06-01 12:44:16 +08:00
|
|
|
.of_match_table = omap_wdt_of_match,
|
2006-09-29 16:59:18 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-11-29 13:56:27 +08:00
|
|
|
module_platform_driver(omap_wdt_driver);
|
2006-09-29 16:59:18 +08:00
|
|
|
|
|
|
|
MODULE_AUTHOR("George G. Davis");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-11 12:29:23 +08:00
|
|
|
MODULE_ALIAS("platform:omap_wdt");
|