Skip to content

Commit

Permalink
Merge tag 'linux-watchdog-4.19-rc1' of git://www.linux-watchdog.org/l…
Browse files Browse the repository at this point in the history
…inux-watchdog

Pull watchdog updates from Wim Van Sebroeck:

 - add MEN 16z069 IP-Core driver

 - renesas-wdt: add support for the R8A77990 wdt

 - stm32_iwdg: Add stm32mp1 support and pclk feature

 - sp805_wdt, orion_wdt, sprd_wdt: several improvements

 - imx2_wdt, stmp3xxx: switch to SPDX identifier

* tag 'linux-watchdog-4.19-rc1' of git://www.linux-watchdog.org/linux-watchdog:
  watchdog: fix dependencies of menz69_wdt.o
  watchdog: sp805: Add clock-frequency property
  watchdog: add driver for the MEN 16z069 IP-Core
  watchdog: sprd_wdt: Remove redundant dev_err call in sprd_wdt_probe()
  watchdog: stmp3xxx: Switch to SPDX identifier
  watchdog: imx2_wdt: Switch to SPDX identifier
  watchdog: sp805: set WDOG_HW_RUNNING when appropriate
  watchdog: sp805: add 'timeout-sec' DT property support
  dt-bindings: watchdog: Add optional 'timeout-sec' property for sp805
  dt-bindings: watchdog: Consolidate SP805 binding docs
  watchdog: orion_wdt: Mark watchdog as active when running at probe
  watchdog: stm32: add pclk feature for stm32mp1
  dt-bindings: watchdog: add stm32mp1 support
  dt-bindings: watchdog: renesas-wdt: Add support for the R8A77990 wdt
  • Loading branch information
torvalds committed Aug 18, 2018
2 parents 13bf2cf + 12aea51 commit 6eaac34
Show file tree
Hide file tree
Showing 14 changed files with 351 additions and 105 deletions.
29 changes: 22 additions & 7 deletions Documentation/devicetree/bindings/watchdog/arm,sp805.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
ARM AMBA Primecell SP805 Watchdog

SP805 WDT is a ARM Primecell Peripheral and has a standard-id register that
can be used to identify the peripheral type, vendor, and revision.
This value can be used for driver matching.

As SP805 WDT is a primecell IP, it follows the base bindings specified in
'arm/primecell.txt'

Required properties:
- compatible: Should be "arm,sp805" & "arm,primecell"
- reg: Should contain location and length for watchdog timer register.
- interrupts: Should contain the list of watchdog timer interrupts.
- clocks: clocks driving the watchdog timer hardware. This list should be 2
clocks. With 2 clocks, the order is wdogclk clock, apb_pclk.
- compatible: Should be "arm,sp805" & "arm,primecell"
- reg: Should contain location and length for watchdog timer register
- clocks: Clocks driving the watchdog timer hardware. This list should be
2 clocks. With 2 clocks, the order is wdog_clk, apb_pclk
wdog_clk can be equal to or be a sub-multiple of the apb_pclk
frequency
- clock-names: Shall be "wdog_clk" for first clock and "apb_pclk" for the
second one

Optional properties:
- interrupts: Should specify WDT interrupt number
- timeout-sec: Should specify default WDT timeout in seconds. If unset, the
default timeout is determined by the driver

Example:
watchdog@66090000 {
compatible = "arm,sp805", "arm,primecell";
reg = <0x66090000 0x1000>;
interrupts = <GIC_SPI 406 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&apb_pclk>,<&apb_pclk>;
clock-names = "wdogclk", "apb_pclk";
clocks = <&wdt_clk>, <&apb_pclk>;
clock-names = "wdog_clk", "apb_pclk";
};
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/watchdog/renesas-wdt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Required properties:
- "renesas,r8a7796-wdt" (R-Car M3-W)
- "renesas,r8a77965-wdt" (R-Car M3-N)
- "renesas,r8a77970-wdt" (R-Car V3M)
- "renesas,r8a77990-wdt" (R-Car E3)
- "renesas,r8a77995-wdt" (R-Car D3)
- "renesas,r7s72100-wdt" (RZ/A1)
The generic compatible string must be:
Expand Down
31 changes: 0 additions & 31 deletions Documentation/devicetree/bindings/watchdog/sp805-wdt.txt

This file was deleted.

13 changes: 10 additions & 3 deletions Documentation/devicetree/bindings/watchdog/st,stm32-iwdg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ STM32 Independent WatchDoG (IWDG)
---------------------------------

Required properties:
- compatible: "st,stm32-iwdg"
- reg: physical base address and length of the registers set for the device
- clocks: must contain a single entry describing the clock input
- compatible: Should be either:
- "st,stm32-iwdg"
- "st,stm32mp1-iwdg"
- reg: Physical base address and length of the registers set for the device
- clocks: Reference to the clock entry lsi. Additional pclk clock entry
is required only for st,stm32mp1-iwdg.
- clock-names: Name of the clocks used.
"lsi" for st,stm32-iwdg
"lsi", "pclk" for st,stm32mp1-iwdg

Optional Properties:
- timeout-sec: Watchdog timeout value in seconds.
Expand All @@ -15,5 +21,6 @@ iwdg: watchdog@40003000 {
compatible = "st,stm32-iwdg";
reg = <0x40003000 0x400>;
clocks = <&clk_lsi>;
clock-names = "lsi";
timeout-sec = <32>;
};
6 changes: 6 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -9427,6 +9427,12 @@ F: drivers/leds/leds-menf21bmc.c
F: drivers/hwmon/menf21bmc_hwmon.c
F: Documentation/hwmon/menf21bmc

MEN Z069 WATCHDOG DRIVER
M: Johannes Thumshirn <[email protected]>
L: [email protected]
S: Maintained
F: drivers/watchdog/menz069_wdt.c

MESON AO CEC DRIVER FOR AMLOGIC SOCS
M: Neil Armstrong <[email protected]>
L: [email protected]
Expand Down
10 changes: 10 additions & 0 deletions drivers/watchdog/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ config MENF21BMC_WATCHDOG
This driver can also be built as a module. If so the module
will be called menf21bmc_wdt.

config MENZ069_WATCHDOG
tristate "MEN 16Z069 Watchdog"
depends on MCB
select WATCHDOG_CORE
help
Say Y here to include support for the MEN 16Z069 Watchdog.

This driver can also be built as a module. If so the module
will be called menz069_wdt.

config TANGOX_WATCHDOG
tristate "Sigma Designs SMP86xx/SMP87xx watchdog"
select WATCHDOG_CORE
Expand Down
1 change: 1 addition & 0 deletions drivers/watchdog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,5 @@ obj-$(CONFIG_MAX77620_WATCHDOG) += max77620_wdt.o
obj-$(CONFIG_ZIIRAVE_WATCHDOG) += ziirave_wdt.o
obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
obj-$(CONFIG_MENF21BMC_WATCHDOG) += menf21bmc_wdt.o
obj-$(CONFIG_MENZ069_WATCHDOG) += menz69_wdt.o
obj-$(CONFIG_RAVE_SP_WATCHDOG) += rave-sp-wdt.o
5 changes: 1 addition & 4 deletions drivers/watchdog/imx2_wdt.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Watchdog driver for IMX2 and later processors
*
Expand All @@ -7,10 +8,6 @@
* some parts adapted by similar drivers from Darius Augulis and Vladimir
* Zapolskiy, additional improvements by Wim Van Sebroeck.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* NOTE: MX1 has a slightly different Watchdog than MX2 and later:
*
* MX1: MX2+:
Expand Down
170 changes: 170 additions & 0 deletions drivers/watchdog/menz69_wdt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Watchdog driver for the MEN z069 IP-Core
*
* Copyright (C) 2018 Johannes Thumshirn <[email protected]>
*/
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/mcb.h>
#include <linux/module.h>
#include <linux/watchdog.h>

struct men_z069_drv {
struct watchdog_device wdt;
void __iomem *base;
struct resource *mem;
};

#define MEN_Z069_WTR 0x10
#define MEN_Z069_WTR_WDEN BIT(15)
#define MEN_Z069_WTR_WDET_MASK 0x7fff
#define MEN_Z069_WVR 0x14

#define MEN_Z069_TIMER_FREQ 500 /* 500 Hz */
#define MEN_Z069_WDT_COUNTER_MIN 1
#define MEN_Z069_WDT_COUNTER_MAX 0x7fff
#define MEN_Z069_DEFAULT_TIMEOUT 30

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) ")");

static int men_z069_wdt_start(struct watchdog_device *wdt)
{
struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
u16 val;

val = readw(drv->base + MEN_Z069_WTR);
val |= MEN_Z069_WTR_WDEN;
writew(val, drv->base + MEN_Z069_WTR);

return 0;
}

static int men_z069_wdt_stop(struct watchdog_device *wdt)
{
struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
u16 val;

val = readw(drv->base + MEN_Z069_WTR);
val &= ~MEN_Z069_WTR_WDEN;
writew(val, drv->base + MEN_Z069_WTR);

return 0;
}

static int men_z069_wdt_ping(struct watchdog_device *wdt)
{
struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
u16 val;

/* The watchdog trigger value toggles between 0x5555 and 0xaaaa */
val = readw(drv->base + MEN_Z069_WVR);
val ^= 0xffff;
writew(val, drv->base + MEN_Z069_WVR);

return 0;
}

static int men_z069_wdt_set_timeout(struct watchdog_device *wdt,
unsigned int timeout)
{
struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
u16 reg, val, ena;

wdt->timeout = timeout;
val = timeout * MEN_Z069_TIMER_FREQ;

reg = readw(drv->base + MEN_Z069_WVR);
ena = reg & MEN_Z069_WTR_WDEN;
reg = ena | val;
writew(reg, drv->base + MEN_Z069_WTR);

return 0;
}

static const struct watchdog_info men_z069_info = {
.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
.identity = "MEN z069 Watchdog",
};

static const struct watchdog_ops men_z069_ops = {
.owner = THIS_MODULE,
.start = men_z069_wdt_start,
.stop = men_z069_wdt_stop,
.ping = men_z069_wdt_ping,
.set_timeout = men_z069_wdt_set_timeout,
};

static struct watchdog_device men_z069_wdt = {
.info = &men_z069_info,
.ops = &men_z069_ops,
.timeout = MEN_Z069_DEFAULT_TIMEOUT,
.min_timeout = 1,
.max_timeout = MEN_Z069_WDT_COUNTER_MAX / MEN_Z069_TIMER_FREQ,
};

static int men_z069_probe(struct mcb_device *dev,
const struct mcb_device_id *id)
{
struct men_z069_drv *drv;
struct resource *mem;

drv = devm_kzalloc(&dev->dev, sizeof(struct men_z069_drv), GFP_KERNEL);
if (!drv)
return -ENOMEM;

mem = mcb_request_mem(dev, "z069-wdt");
if (IS_ERR(mem))
return PTR_ERR(mem);

drv->base = devm_ioremap(&dev->dev, mem->start, resource_size(mem));
if (drv->base == NULL)
goto release_mem;

drv->mem = mem;

drv->wdt = men_z069_wdt;
watchdog_init_timeout(&drv->wdt, 0, &dev->dev);
watchdog_set_nowayout(&drv->wdt, nowayout);
watchdog_set_drvdata(&drv->wdt, drv);
drv->wdt.parent = &dev->dev;
mcb_set_drvdata(dev, drv);

return watchdog_register_device(&men_z069_wdt);

release_mem:
mcb_release_mem(mem);
return -ENOMEM;
}

static void men_z069_remove(struct mcb_device *dev)
{
struct men_z069_drv *drv = mcb_get_drvdata(dev);

watchdog_unregister_device(&drv->wdt);
mcb_release_mem(drv->mem);
}

static const struct mcb_device_id men_z069_ids[] = {
{ .device = 0x45 },
{ }
};
MODULE_DEVICE_TABLE(mcb, men_z069_ids);

static struct mcb_driver men_z069_driver = {
.driver = {
.name = "z069-wdt",
.owner = THIS_MODULE,
},
.probe = men_z069_probe,
.remove = men_z069_remove,
.id_table = men_z069_ids,
};
module_mcb_driver(men_z069_driver);

MODULE_AUTHOR("Johannes Thumshirn <[email protected]>");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("mcb:16z069");
2 changes: 2 additions & 0 deletions drivers/watchdog/orion_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,8 @@ static int orion_wdt_probe(struct platform_device *pdev)
*/
if (!orion_wdt_enabled(&dev->wdt))
orion_wdt_stop(&dev->wdt);
else
set_bit(WDOG_HW_RUNNING, &dev->wdt.status);

/* Request the IRQ only after the watchdog is disabled */
irq = platform_get_irq(pdev, 0);
Expand Down
Loading

0 comments on commit 6eaac34

Please sign in to comment.