Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pull watchdog updates from Wim Van Sebroeck:
 - remove unnecessary checks after platform_get_resource()
 - fix watchdog api documentation typo's
 - imx2_wdt: adds big endianness support
 - move restart code to the sunxi watchdog driver

* git://www.linux-watchdog.org/linux-watchdog:
  wdt: sunxi: Move restart code to the watchdog driver
  Documentation: fix two typos in watchdog-api.txt
  watchdog: imx2_wdt: adds big endianness support.
  watchdog: shwdt: Remove the unnecessary check of resource after platform_get_resource()
  watchdog: lantiq_wdt: Remove the un-necessary check of resource after platform_get_resource()
  watchdog: dw_wdt: Remove the un-necessary check after platform_get_resource()
  • Loading branch information
Linus Torvalds committed Aug 7, 2014
2 parents 7725131 + 440e96b commit a1b0a00
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
5 changes: 5 additions & 0 deletions Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ Required properties:
- reg : Should contain WDT registers location and length
- interrupts : Should contain WDT interrupt

Optional property:
- big-endian: If present the watchdog device's registers are implemented
in big endian mode, otherwise in little mode.

Examples:

wdt@73f98000 {
compatible = "fsl,imx51-wdt", "fsl,imx21-wdt";
reg = <0x73f98000 0x4000>;
interrupts = <58>;
big-endian;
};
2 changes: 1 addition & 1 deletion Documentation/watchdog/watchdog-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ resets.
Note that the pretimeout is the number of seconds before the time
when the timeout will go off. It is not the number of seconds until
the pretimeout. So, for instance, if you set the timeout to 60 seconds
and the pretimeout to 10 seconds, the pretimout will go of in 50
and the pretimeout to 10 seconds, the pretimeout will go off in 50
seconds. Setting a pretimeout to zero disables it.

There is also a get function for getting the pretimeout:
Expand Down
3 changes: 0 additions & 3 deletions drivers/watchdog/dw_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
int ret;
struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);

if (!mem)
return -EINVAL;

dw_wdt.regs = devm_ioremap_resource(&pdev->dev, mem);
if (IS_ERR(dw_wdt.regs))
return PTR_ERR(dw_wdt.regs);
Expand Down
7 changes: 7 additions & 0 deletions drivers/watchdog/imx2_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/timer.h>
Expand Down Expand Up @@ -190,17 +191,23 @@ static struct regmap_config imx2_wdt_regmap_config = {

static int __init imx2_wdt_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct imx2_wdt_device *wdev;
struct watchdog_device *wdog;
struct resource *res;
void __iomem *base;
bool big_endian;
int ret;
u32 val;

wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
if (!wdev)
return -ENOMEM;

big_endian = of_property_read_bool(np, "big-endian");
if (big_endian)
imx2_wdt_regmap_config.val_format_endian = REGMAP_ENDIAN_BIG;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(base))
Expand Down
5 changes: 0 additions & 5 deletions drivers/watchdog/lantiq_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,6 @@ ltq_wdt_probe(struct platform_device *pdev)
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
struct clk *clk;

if (!res) {
dev_err(&pdev->dev, "cannot obtain I/O memory region");
return -ENOENT;
}

ltq_wdt_membase = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(ltq_wdt_membase))
return PTR_ERR(ltq_wdt_membase);
Expand Down
5 changes: 1 addition & 4 deletions drivers/watchdog/shwdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,6 @@ static int sh_wdt_probe(struct platform_device *pdev)
if (pdev->id != -1)
return -EINVAL;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (unlikely(!res))
return -EINVAL;

wdt = devm_kzalloc(&pdev->dev, sizeof(struct sh_wdt), GFP_KERNEL);
if (unlikely(!wdt))
return -ENOMEM;
Expand All @@ -249,6 +245,7 @@ static int sh_wdt_probe(struct platform_device *pdev)
wdt->clk = NULL;
}

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
wdt->base = devm_ioremap_resource(wdt->dev, res);
if (IS_ERR(wdt->base))
return PTR_ERR(wdt->base);
Expand Down
29 changes: 29 additions & 0 deletions drivers/watchdog/sunxi_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/io.h>
Expand All @@ -22,9 +23,12 @@
#include <linux/moduleparam.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/reboot.h>
#include <linux/types.h>
#include <linux/watchdog.h>

#include <asm/system_misc.h>

#define WDT_MAX_TIMEOUT 16
#define WDT_MIN_TIMEOUT 1
#define WDT_MODE_TIMEOUT(n) ((n) << 3)
Expand Down Expand Up @@ -70,6 +74,26 @@ static const int wdt_timeout_map[] = {
[16] = 0xB, /* 16s */
};

static void __iomem *reboot_wdt_base;

static void sun4i_wdt_restart(enum reboot_mode mode, const char *cmd)
{
/* Enable timer and set reset bit in the watchdog */
writel(WDT_MODE_EN | WDT_MODE_RST_EN, reboot_wdt_base + WDT_MODE);

/*
* Restart the watchdog. The default (and lowest) interval
* value for the watchdog is 0.5s.
*/
writel(WDT_CTRL_RELOAD, reboot_wdt_base + WDT_CTRL);

while (1) {
mdelay(5);
writel(WDT_MODE_EN | WDT_MODE_RST_EN,
reboot_wdt_base + WDT_MODE);
}
}

static int sunxi_wdt_ping(struct watchdog_device *wdt_dev)
{
struct sunxi_wdt_dev *sunxi_wdt = watchdog_get_drvdata(wdt_dev);
Expand Down Expand Up @@ -181,6 +205,9 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
if (unlikely(err))
return err;

reboot_wdt_base = sunxi_wdt->wdt_base;
arm_pm_restart = sun4i_wdt_restart;

dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)",
sunxi_wdt->wdt_dev.timeout, nowayout);

Expand All @@ -191,6 +218,8 @@ static int sunxi_wdt_remove(struct platform_device *pdev)
{
struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev);

arm_pm_restart = NULL;

watchdog_unregister_device(&sunxi_wdt->wdt_dev);
watchdog_set_drvdata(&sunxi_wdt->wdt_dev, NULL);

Expand Down

0 comments on commit a1b0a00

Please sign in to comment.