Source
x
/*
* 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.
*/
static bool nowayout = WATCHDOG_NOWAYOUT;
static unsigned int timeout;
/*
* This structure stores the register offsets for different variants
* of Allwinner's watchdog hardware.
*/
struct sunxi_wdt_reg {
u8 wdt_ctrl;
u8 wdt_cfg;
u8 wdt_mode;
u8 wdt_timeout_shift;
u8 wdt_reset_mask;
u8 wdt_reset_val;
};
struct sunxi_wdt_dev {
struct watchdog_device wdt_dev;
void __iomem *wdt_base;
const struct sunxi_wdt_reg *wdt_regs;
};
/*
* wdt_timeout_map maps the watchdog timer interval value in seconds to
* the value of the register WDT_MODE at bits .wdt_timeout_shift ~ +3
*
* [timeout seconds] = register value
*
*/
static const int wdt_timeout_map[] = {
[1] = 0x1, /* 1s */
[2] = 0x2, /* 2s */
[3] = 0x3, /* 3s */
[4] = 0x4, /* 4s */
[5] = 0x5, /* 5s */
[6] = 0x6, /* 6s */
[8] = 0x7, /* 8s */
[10] = 0x8, /* 10s */
[12] = 0x9, /* 12s */
[14] = 0xA, /* 14s */
[16] = 0xB, /* 16s */
};
static int sunxi_wdt_restart(struct watchdog_device *wdt_dev,
unsigned long action, void *data)
{
struct sunxi_wdt_dev *sunxi_wdt = watchdog_get_drvdata(wdt_dev);
void __iomem *wdt_base = sunxi_wdt->wdt_base;
const struct sunxi_wdt_reg *regs = sunxi_wdt->wdt_regs;
u32 val;