Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://www.linux-watchdog.org/linux-watchdog

Pull watchdog updates from Wim Van Sebroeck:

- add support for Fintek F81865 Super-IO chip

- add support for watchdogs (RWDT and SWDT) found on RCar Gen3 based
SoCs from Renesas

- octeon: Handle the FROZEN hot plug notifier actions

- f71808e_wdt fixes and cleanups

- some small improvements in code and documentation

* git://www.linux-watchdog.org/linux-watchdog:
MAINTAINERS: Add file patterns for watchdog device tree bindings
Documentation: Add ebc-c384_wdt watchdog-parameters.txt entry
watchdog: shwdt: Use setup_timer()
watchdog: cpwd: Use setup_timer()
arm64: defconfig: enable Renesas Watchdog Timer
watchdog: renesas-wdt: add driver
watchdog: remove error message when unable to allocate watchdog device
watchdog: f71808e_wdt: Fix WDTMOUT_STS register read
watchdog: f71808e_wdt: Fix typo
watchdog: f71808e_wdt: Add F81865 support
watchdog: sp5100_tco: properly check for new register layouts
watchdog: core: Fix circular locking dependency
watchdog: core: fix trivial typo in a comment
watchdog: hpwdt: Adjust documentation to match latest kernel module parameters.
watchdog: imx2_wdt: add external reset support via dt prop
watchdog: octeon: Handle the FROZEN hot plug notifier actions.
watchdog: qcom: Report reboot reason

+349 -54
+3 -1
Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt
··· 5 5 - reg : Should contain WDT registers location and length 6 6 - interrupts : Should contain WDT interrupt 7 7 8 - Optional property: 8 + Optional properties: 9 9 - big-endian: If present the watchdog device's registers are implemented 10 10 in big endian mode, otherwise in native mode(same with CPU), for more 11 11 detail please see: Documentation/devicetree/bindings/regmap/regmap.txt. 12 + - fsl,ext-reset-output: If present the watchdog device is configured to 13 + assert its external reset (WDOG_B) instead of issuing a software reset. 12 14 13 15 Examples: 14 16
+25
Documentation/devicetree/bindings/watchdog/renesas-wdt.txt
··· 1 + Renesas Watchdog Timer (WDT) Controller 2 + 3 + Required properties: 4 + - compatible : Should be "renesas,r8a7795-wdt", or "renesas,rcar-gen3-wdt" 5 + 6 + When compatible with the generic version, nodes must list the SoC-specific 7 + version corresponding to the platform first, followed by the generic 8 + version. 9 + 10 + - reg : Should contain WDT registers location and length 11 + - clocks : the clock feeding the watchdog timer. 12 + 13 + Optional properties: 14 + - timeout-sec : Contains the watchdog timeout in seconds 15 + - power-domains : the power domain the WDT belongs to 16 + 17 + Examples: 18 + 19 + wdt0: watchdog@e6020000 { 20 + compatible = "renesas,r8a7795-wdt", "renesas,rcar-gen3-wdt"; 21 + reg = <0 0xe6020000 0 0x0c>; 22 + clocks = <&cpg CPG_MOD 402>; 23 + power-domains = <&cpg>; 24 + timeout-sec = <60>; 25 + };
+30 -27
Documentation/watchdog/hpwdt.txt
··· 1 - Last reviewed: 06/02/2009 1 + Last reviewed: 04/04/2016 2 2 3 - HP iLO2 NMI Watchdog Driver 4 - NMI sourcing for iLO2 based ProLiant Servers 3 + HPE iLO NMI Watchdog Driver 4 + NMI sourcing for iLO based ProLiant Servers 5 5 Documentation and Driver by 6 - Thomas Mingarelli <thomas.mingarelli@hp.com> 6 + Thomas Mingarelli <thomas.mingarelli@hpe.com> 7 7 8 - The HP iLO2 NMI Watchdog driver is a kernel module that provides basic 8 + The HPE iLO NMI Watchdog driver is a kernel module that provides basic 9 9 watchdog functionality and the added benefit of NMI sourcing. Both the 10 10 watchdog functionality and the NMI sourcing capability need to be enabled 11 11 by the user. Remember that the two modes are not dependent on one another. 12 12 A user can have the NMI sourcing without the watchdog timer and vice-versa. 13 + All references to iLO in this document imply it also works on iLO2 and all 14 + subsequent generations. 13 15 14 16 Watchdog functionality is enabled like any other common watchdog driver. That 15 17 is, an application needs to be started that kicks off the watchdog timer. A 16 18 basic application exists in the Documentation/watchdog/src directory called 17 19 watchdog-test.c. Simply compile the C file and kick it off. If the system 18 - gets into a bad state and hangs, the HP ProLiant iLO 2 timer register will 20 + gets into a bad state and hangs, the HPE ProLiant iLO timer register will 19 21 not be updated in a timely fashion and a hardware system reset (also known as 20 22 an Automatic Server Recovery (ASR)) event will occur. 21 23 22 - The hpwdt driver also has four (4) module parameters. They are the following: 24 + The hpwdt driver also has three (3) module parameters. They are the following: 23 25 24 - soft_margin - allows the user to set the watchdog timer value 25 - allow_kdump - allows the user to save off a kernel dump image after an NMI 26 + soft_margin - allows the user to set the watchdog timer value. 27 + Default value is 30 seconds. 28 + allow_kdump - allows the user to save off a kernel dump image after an NMI. 29 + Default value is 1/ON 26 30 nowayout - basic watchdog parameter that does not allow the timer to 27 31 be restarted or an impending ASR to be escaped. 28 - priority - determines whether or not the hpwdt driver is first on the 29 - die_notify list to handle NMIs or last. The default value 30 - for this module parameter is 0 or LAST. If the user wants to 31 - enable NMI sourcing then reload the hpwdt driver with 32 - priority=1 (and boot with nmi_watchdog=0). 32 + Default value is set when compiling the kernel. If it is set 33 + to "Y", then there is no way of disabling the watchdog once 34 + it has been started. 33 35 34 36 NOTE: More information about watchdog drivers in general, including the ioctl 35 37 interface to /dev/watchdog can be found in 36 38 Documentation/watchdog/watchdog-api.txt and Documentation/IPMI.txt. 37 - 38 - The priority parameter was introduced due to other kernel software that relied 39 - on handling NMIs (like oprofile). Keeping hpwdt's priority at 0 (or LAST) 40 - enables the users of NMIs for non critical events to be work as expected. 41 39 42 40 The NMI sourcing capability is disabled by default due to the inability to 43 41 distinguish between "NMI Watchdog Ticks" and "HW generated NMI events" in the ··· 43 45 each time the NMI signal fires off. This could amount to several thousands of 44 46 NMIs in a matter of seconds. If a user sees the Linux kernel's "dazed and 45 47 confused" message in the logs or if the system gets into a hung state, then 46 - the hpwdt driver can be reloaded with the "priority" module parameter set 47 - (priority=1). 48 + the hpwdt driver can be reloaded. 48 49 49 50 1. If the kernel has not been booted with nmi_watchdog turned off then 50 - edit /boot/grub/menu.lst and place the nmi_watchdog=0 at the end of the 51 - currently booting kernel line. 51 + edit and place the nmi_watchdog=0 at the end of the currently booting 52 + kernel line. Depending on your Linux distribution and platform setup: 53 + For non-UEFI systems 54 + /boot/grub/grub.conf or 55 + /boot/grub/menu.lst 56 + For UEFI systems 57 + /boot/efi/EFI/distroname/grub.conf or 58 + /boot/efi/efi/distroname/elilo.conf 52 59 2. reboot the sever 53 - 3. Once the system comes up perform a rmmod hpwdt 54 - 4. insmod /lib/modules/`uname -r`/kernel/drivers/char/watchdog/hpwdt.ko priority=1 60 + 3. Once the system comes up perform a modprobe -r hpwdt 61 + 4. modprobe /lib/modules/`uname -r`/kernel/drivers/watchdog/hpwdt.ko 55 62 56 63 Now, the hpwdt can successfully receive and source the NMI and provide a log 57 - message that details the reason for the NMI (as determined by the HP BIOS). 64 + message that details the reason for the NMI (as determined by the HPE BIOS). 58 65 59 - Below is a list of NMIs the HP BIOS understands along with the associated 66 + Below is a list of NMIs the HPE BIOS understands along with the associated 60 67 code (reason): 61 68 62 69 No source found 00h ··· 95 92 96 93 97 94 -- Tom Mingarelli 98 - (thomas.mingarelli@hp.com) 95 + (thomas.mingarelli@hpe.com)
+4
Documentation/watchdog/watchdog-parameters.txt
··· 86 86 davinci_wdt: 87 87 heartbeat: Watchdog heartbeat period in seconds from 1 to 600, default 60 88 88 ------------------------------------------------- 89 + ebc-c384_wdt: 90 + timeout: Watchdog timeout in seconds. (1<=timeout<=15300, default=60) 91 + nowayout: Watchdog cannot be stopped once started 92 + ------------------------------------------------- 89 93 ep93xx_wdt: 90 94 nowayout: Watchdog cannot be stopped once started 91 95 timeout: Watchdog timeout in seconds. (1<=timeout<=3600, default=TBD)
+1
MAINTAINERS
··· 12345 12345 W: http://www.linux-watchdog.org/ 12346 12346 T: git git://www.linux-watchdog.org/linux-watchdog.git 12347 12347 S: Maintained 12348 + F: Documentation/devicetree/bindings/watchdog/ 12348 12349 F: Documentation/watchdog/ 12349 12350 F: drivers/watchdog/ 12350 12351 F: include/linux/watchdog.h
+2
arch/arm64/configs/defconfig
··· 200 200 CONFIG_THERMAL=y 201 201 CONFIG_THERMAL_EMULATION=y 202 202 CONFIG_EXYNOS_THERMAL=y 203 + CONFIG_WATCHDOG=y 204 + CONFIG_RENESAS_WDT=y 203 205 CONFIG_MFD_SPMI_PMIC=y 204 206 CONFIG_MFD_SEC_CORE=y 205 207 CONFIG_MFD_HI655X_PMIC=y
+8
drivers/watchdog/Kconfig
··· 661 661 To compile this driver as a module, choose M here: the 662 662 module will be called atlas7_wdt. 663 663 664 + config RENESAS_WDT 665 + tristate "Renesas WDT Watchdog" 666 + depends on ARCH_RENESAS || COMPILE_TEST 667 + select WATCHDOG_CORE 668 + help 669 + This driver adds watchdog support for the integrated watchdogs in the 670 + Renesas R-Car and other SH-Mobile SoCs (usually named RWDT or SWDT). 671 + 664 672 # AVR32 Architecture 665 673 666 674 config AT32AP700X_WDT
+1
drivers/watchdog/Makefile
··· 73 73 obj-$(CONFIG_LPC18XX_WATCHDOG) += lpc18xx_wdt.o 74 74 obj-$(CONFIG_BCM7038_WDT) += bcm7038_wdt.o 75 75 obj-$(CONFIG_ATLAS7_WATCHDOG) += atlas7_wdt.o 76 + obj-$(CONFIG_RENESAS_WDT) += renesas_wdt.o 76 77 77 78 # AVR32 Architecture 78 79 obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
+1 -3
drivers/watchdog/cpwd.c
··· 611 611 } 612 612 613 613 if (p->broken) { 614 - init_timer(&cpwd_timer); 615 - cpwd_timer.function = cpwd_brokentimer; 616 - cpwd_timer.data = (unsigned long) p; 614 + setup_timer(&cpwd_timer, cpwd_brokentimer, (unsigned long)p); 617 615 cpwd_timer.expires = WD_BTIMEOUT; 618 616 619 617 pr_info("PLD defect workaround enabled for model %s\n",
+24 -6
drivers/watchdog/f71808e_wdt.c
··· 38 38 39 39 #define SIO_F71808FG_LD_WDT 0x07 /* Watchdog timer logical device */ 40 40 #define SIO_UNLOCK_KEY 0x87 /* Key to enable Super-I/O */ 41 - #define SIO_LOCK_KEY 0xAA /* Key to diasble Super-I/O */ 41 + #define SIO_LOCK_KEY 0xAA /* Key to disable Super-I/O */ 42 42 43 43 #define SIO_REG_LDSEL 0x07 /* Logical device select */ 44 44 #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ ··· 59 59 #define SIO_F71869A_ID 0x1007 /* Chipset ID */ 60 60 #define SIO_F71882_ID 0x0541 /* Chipset ID */ 61 61 #define SIO_F71889_ID 0x0723 /* Chipset ID */ 62 + #define SIO_F81865_ID 0x0704 /* Chipset ID */ 62 63 63 64 #define F71808FG_REG_WDO_CONF 0xf0 64 65 #define F71808FG_REG_WDT_CONF 0xf5 ··· 67 66 68 67 #define F71808FG_FLAG_WDOUT_EN 7 69 68 70 - #define F71808FG_FLAG_WDTMOUT_STS 5 69 + #define F71808FG_FLAG_WDTMOUT_STS 6 71 70 #define F71808FG_FLAG_WD_EN 5 72 71 #define F71808FG_FLAG_WD_PULSE 4 73 72 #define F71808FG_FLAG_WD_UNIT 3 73 + 74 + #define F81865_REG_WDO_CONF 0xfa 75 + #define F81865_FLAG_WDOUT_EN 0 74 76 75 77 /* Default values */ 76 78 #define WATCHDOG_TIMEOUT 60 /* 1 minute default timeout */ ··· 116 112 MODULE_PARM_DESC(start_withtimeout, "Start watchdog timer on module load with" 117 113 " given initial timeout. Zero (default) disables this feature."); 118 114 119 - enum chips { f71808fg, f71858fg, f71862fg, f71869, f71882fg, f71889fg }; 115 + enum chips { f71808fg, f71858fg, f71862fg, f71869, f71882fg, f71889fg, f81865 }; 120 116 121 117 static const char *f71808e_names[] = { 122 118 "f71808fg", ··· 125 121 "f71869", 126 122 "f71882fg", 127 123 "f71889fg", 124 + "f81865", 128 125 }; 129 126 130 127 /* Super-I/O Function prototypes */ ··· 365 360 superio_inb(watchdog.sioaddr, SIO_REG_MFUNCT3) & 0xcf); 366 361 break; 367 362 363 + case f81865: 364 + /* Set pin 70 to WDTRST# */ 365 + superio_clear_bit(watchdog.sioaddr, SIO_REG_MFUNCT3, 5); 366 + break; 367 + 368 368 default: 369 369 /* 370 370 * 'default' label to shut up the compiler and catch ··· 381 371 382 372 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); 383 373 superio_set_bit(watchdog.sioaddr, SIO_REG_ENABLE, 0); 384 - superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDO_CONF, 385 - F71808FG_FLAG_WDOUT_EN); 374 + 375 + if (watchdog.type == f81865) 376 + superio_set_bit(watchdog.sioaddr, F81865_REG_WDO_CONF, 377 + F81865_FLAG_WDOUT_EN); 378 + else 379 + superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDO_CONF, 380 + F71808FG_FLAG_WDOUT_EN); 386 381 387 382 superio_set_bit(watchdog.sioaddr, F71808FG_REG_WDT_CONF, 388 383 F71808FG_FLAG_WD_EN); ··· 670 655 superio_select(watchdog.sioaddr, SIO_F71808FG_LD_WDT); 671 656 672 657 wdt_conf = superio_inb(sioaddr, F71808FG_REG_WDT_CONF); 673 - watchdog.caused_reboot = wdt_conf & F71808FG_FLAG_WDTMOUT_STS; 658 + watchdog.caused_reboot = wdt_conf & BIT(F71808FG_FLAG_WDTMOUT_STS); 674 659 675 660 superio_exit(sioaddr); 676 661 ··· 785 770 /* Confirmed (by datasheet) not to have a watchdog. */ 786 771 err = -ENODEV; 787 772 goto exit; 773 + case SIO_F81865_ID: 774 + watchdog.type = f81865; 775 + break; 788 776 default: 789 777 pr_info("Unrecognized Fintek device: %04x\n", 790 778 (unsigned int)devid);
+17 -2
drivers/watchdog/imx2_wdt.c
··· 37 37 38 38 #define IMX2_WDT_WCR 0x00 /* Control Register */ 39 39 #define IMX2_WDT_WCR_WT (0xFF << 8) /* -> Watchdog Timeout Field */ 40 + #define IMX2_WDT_WCR_WDA (1 << 5) /* -> External Reset WDOG_B */ 41 + #define IMX2_WDT_WCR_SRS (1 << 4) /* -> Software Reset Signal */ 40 42 #define IMX2_WDT_WCR_WRE (1 << 3) /* -> WDOG Reset Enable */ 41 43 #define IMX2_WDT_WCR_WDE (1 << 2) /* -> Watchdog Enable */ 42 44 #define IMX2_WDT_WCR_WDZST (1 << 0) /* -> Watchdog timer Suspend */ ··· 61 59 struct clk *clk; 62 60 struct regmap *regmap; 63 61 struct watchdog_device wdog; 62 + bool ext_reset; 64 63 }; 65 64 66 65 static bool nowayout = WATCHDOG_NOWAYOUT; ··· 85 82 { 86 83 struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); 87 84 unsigned int wcr_enable = IMX2_WDT_WCR_WDE; 85 + 86 + /* Use internal reset or external - not both */ 87 + if (wdev->ext_reset) 88 + wcr_enable |= IMX2_WDT_WCR_SRS; /* do not assert int reset */ 89 + else 90 + wcr_enable |= IMX2_WDT_WCR_WDA; /* do not assert ext-reset */ 88 91 89 92 /* Assert SRS signal */ 90 93 regmap_write(wdev->regmap, IMX2_WDT_WCR, wcr_enable); ··· 121 112 val |= IMX2_WDT_WCR_WDZST; 122 113 /* Strip the old watchdog Time-Out value */ 123 114 val &= ~IMX2_WDT_WCR_WT; 124 - /* Generate reset if WDOG times out */ 125 - val &= ~IMX2_WDT_WCR_WRE; 115 + /* Generate internal chip-level reset if WDOG times out */ 116 + if (!wdev->ext_reset) 117 + val &= ~IMX2_WDT_WCR_WRE; 118 + /* Or if external-reset assert WDOG_B reset only on time-out */ 119 + else 120 + val |= IMX2_WDT_WCR_WRE; 126 121 /* Keep Watchdog Disabled */ 127 122 val &= ~IMX2_WDT_WCR_WDE; 128 123 /* Set the watchdog's Time-Out value */ ··· 243 230 regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val); 244 231 wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0; 245 232 233 + wdev->ext_reset = of_property_read_bool(pdev->dev.of_node, 234 + "fsl,ext-reset-output"); 246 235 wdog->timeout = clamp_t(unsigned, timeout, 1, IMX2_WDT_MAX_TIME); 247 236 if (wdog->timeout != timeout) 248 237 dev_warn(&pdev->dev, "Initial timeout out of range! Clamped from %u to %u\n",
+1 -3
drivers/watchdog/jz4740_wdt.c
··· 160 160 161 161 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct jz4740_wdt_drvdata), 162 162 GFP_KERNEL); 163 - if (!drvdata) { 164 - dev_err(&pdev->dev, "Unable to alloacate watchdog device\n"); 163 + if (!drvdata) 165 164 return -ENOMEM; 166 - } 167 165 168 166 if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) 169 167 heartbeat = DEFAULT_HEARTBEAT;
+1 -1
drivers/watchdog/octeon-wdt-main.c
··· 431 431 { 432 432 unsigned int cpu = (unsigned long)hcpu; 433 433 434 - switch (action) { 434 + switch (action & ~CPU_TASKS_FROZEN) { 435 435 case CPU_DOWN_PREPARE: 436 436 octeon_wdt_disable_interrupt(cpu); 437 437 break;
+6 -1
drivers/watchdog/qcom-wdt.c
··· 21 21 22 22 #define WDT_RST 0x38 23 23 #define WDT_EN 0x40 24 + #define WDT_STS 0x44 24 25 #define WDT_BITE_TIME 0x5C 25 26 26 27 struct qcom_wdt { ··· 109 108 static const struct watchdog_info qcom_wdt_info = { 110 109 .options = WDIOF_KEEPALIVEPING 111 110 | WDIOF_MAGICCLOSE 112 - | WDIOF_SETTIMEOUT, 111 + | WDIOF_SETTIMEOUT 112 + | WDIOF_CARDRESET, 113 113 .identity = KBUILD_MODNAME, 114 114 }; 115 115 ··· 172 170 wdt->wdd.min_timeout = 1; 173 171 wdt->wdd.max_timeout = 0x10000000U / wdt->rate; 174 172 wdt->wdd.parent = &pdev->dev; 173 + 174 + if (readl(wdt->base + WDT_STS) & 1) 175 + wdt->wdd.bootstatus = WDIOF_CARDRESET; 175 176 176 177 /* 177 178 * If 'timeout-sec' unspecified in devicetree, assume a 30 second
+213
drivers/watchdog/renesas_wdt.c
··· 1 + /* 2 + * Watchdog driver for Renesas WDT watchdog 3 + * 4 + * Copyright (C) 2015-16 Wolfram Sang, Sang Engineering <wsa@sang-engineering.com> 5 + * Copyright (C) 2015-16 Renesas Electronics Corporation 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License version 2 as published by 9 + * the Free Software Foundation. 10 + */ 11 + #include <linux/bitops.h> 12 + #include <linux/clk.h> 13 + #include <linux/io.h> 14 + #include <linux/kernel.h> 15 + #include <linux/module.h> 16 + #include <linux/of.h> 17 + #include <linux/platform_device.h> 18 + #include <linux/pm_runtime.h> 19 + #include <linux/watchdog.h> 20 + 21 + #define RWTCNT 0 22 + #define RWTCSRA 4 23 + #define RWTCSRA_WOVF BIT(4) 24 + #define RWTCSRA_WRFLG BIT(5) 25 + #define RWTCSRA_TME BIT(7) 26 + 27 + #define RWDT_DEFAULT_TIMEOUT 60U 28 + 29 + static const unsigned int clk_divs[] = { 1, 4, 16, 32, 64, 128, 1024 }; 30 + 31 + static bool nowayout = WATCHDOG_NOWAYOUT; 32 + module_param(nowayout, bool, 0); 33 + MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 34 + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 35 + 36 + struct rwdt_priv { 37 + void __iomem *base; 38 + struct watchdog_device wdev; 39 + struct clk *clk; 40 + unsigned int clks_per_sec; 41 + u8 cks; 42 + }; 43 + 44 + static void rwdt_write(struct rwdt_priv *priv, u32 val, unsigned int reg) 45 + { 46 + if (reg == RWTCNT) 47 + val |= 0x5a5a0000; 48 + else 49 + val |= 0xa5a5a500; 50 + 51 + writel_relaxed(val, priv->base + reg); 52 + } 53 + 54 + static int rwdt_init_timeout(struct watchdog_device *wdev) 55 + { 56 + struct rwdt_priv *priv = watchdog_get_drvdata(wdev); 57 + 58 + rwdt_write(priv, 65536 - wdev->timeout * priv->clks_per_sec, RWTCNT); 59 + 60 + return 0; 61 + } 62 + 63 + static int rwdt_start(struct watchdog_device *wdev) 64 + { 65 + struct rwdt_priv *priv = watchdog_get_drvdata(wdev); 66 + 67 + clk_prepare_enable(priv->clk); 68 + 69 + rwdt_write(priv, priv->cks, RWTCSRA); 70 + rwdt_init_timeout(wdev); 71 + 72 + while (readb_relaxed(priv->base + RWTCSRA) & RWTCSRA_WRFLG) 73 + cpu_relax(); 74 + 75 + rwdt_write(priv, priv->cks | RWTCSRA_TME, RWTCSRA); 76 + 77 + return 0; 78 + } 79 + 80 + static int rwdt_stop(struct watchdog_device *wdev) 81 + { 82 + struct rwdt_priv *priv = watchdog_get_drvdata(wdev); 83 + 84 + rwdt_write(priv, priv->cks, RWTCSRA); 85 + clk_disable_unprepare(priv->clk); 86 + 87 + return 0; 88 + } 89 + 90 + static unsigned int rwdt_get_timeleft(struct watchdog_device *wdev) 91 + { 92 + struct rwdt_priv *priv = watchdog_get_drvdata(wdev); 93 + u16 val = readw_relaxed(priv->base + RWTCNT); 94 + 95 + return DIV_ROUND_CLOSEST(65536 - val, priv->clks_per_sec); 96 + } 97 + 98 + static const struct watchdog_info rwdt_ident = { 99 + .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, 100 + .identity = "Renesas WDT Watchdog", 101 + }; 102 + 103 + static const struct watchdog_ops rwdt_ops = { 104 + .owner = THIS_MODULE, 105 + .start = rwdt_start, 106 + .stop = rwdt_stop, 107 + .ping = rwdt_init_timeout, 108 + .get_timeleft = rwdt_get_timeleft, 109 + }; 110 + 111 + static int rwdt_probe(struct platform_device *pdev) 112 + { 113 + struct rwdt_priv *priv; 114 + struct resource *res; 115 + unsigned long rate; 116 + unsigned int clks_per_sec; 117 + int ret, i; 118 + 119 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 120 + if (!priv) 121 + return -ENOMEM; 122 + 123 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 124 + priv->base = devm_ioremap_resource(&pdev->dev, res); 125 + if (IS_ERR(priv->base)) 126 + return PTR_ERR(priv->base); 127 + 128 + priv->clk = devm_clk_get(&pdev->dev, NULL); 129 + if (IS_ERR(priv->clk)) 130 + return PTR_ERR(priv->clk); 131 + 132 + rate = clk_get_rate(priv->clk); 133 + if (!rate) 134 + return -ENOENT; 135 + 136 + for (i = ARRAY_SIZE(clk_divs) - 1; i >= 0; i--) { 137 + clks_per_sec = DIV_ROUND_UP(rate, clk_divs[i]); 138 + if (clks_per_sec) { 139 + priv->clks_per_sec = clks_per_sec; 140 + priv->cks = i; 141 + break; 142 + } 143 + } 144 + 145 + if (!clks_per_sec) { 146 + dev_err(&pdev->dev, "Can't find suitable clock divider\n"); 147 + return -ERANGE; 148 + } 149 + 150 + pm_runtime_enable(&pdev->dev); 151 + pm_runtime_get_sync(&pdev->dev); 152 + 153 + priv->wdev.info = &rwdt_ident, 154 + priv->wdev.ops = &rwdt_ops, 155 + priv->wdev.parent = &pdev->dev; 156 + priv->wdev.min_timeout = 1; 157 + priv->wdev.max_timeout = 65536 / clks_per_sec; 158 + priv->wdev.timeout = min(priv->wdev.max_timeout, RWDT_DEFAULT_TIMEOUT); 159 + 160 + platform_set_drvdata(pdev, priv); 161 + watchdog_set_drvdata(&priv->wdev, priv); 162 + watchdog_set_nowayout(&priv->wdev, nowayout); 163 + 164 + /* This overrides the default timeout only if DT configuration was found */ 165 + ret = watchdog_init_timeout(&priv->wdev, 0, &pdev->dev); 166 + if (ret) 167 + dev_warn(&pdev->dev, "Specified timeout value invalid, using default\n"); 168 + 169 + ret = watchdog_register_device(&priv->wdev); 170 + if (ret < 0) { 171 + pm_runtime_put(&pdev->dev); 172 + pm_runtime_disable(&pdev->dev); 173 + return ret; 174 + } 175 + 176 + return 0; 177 + } 178 + 179 + static int rwdt_remove(struct platform_device *pdev) 180 + { 181 + struct rwdt_priv *priv = platform_get_drvdata(pdev); 182 + 183 + watchdog_unregister_device(&priv->wdev); 184 + pm_runtime_put(&pdev->dev); 185 + pm_runtime_disable(&pdev->dev); 186 + 187 + return 0; 188 + } 189 + 190 + /* 191 + * This driver does also fit for R-Car Gen2 (r8a779[0-4]) WDT. However, for SMP 192 + * to work there, one also needs a RESET (RST) driver which does not exist yet 193 + * due to HW issues. This needs to be solved before adding compatibles here. 194 + */ 195 + static const struct of_device_id rwdt_ids[] = { 196 + { .compatible = "renesas,rcar-gen3-wdt", }, 197 + { /* sentinel */ } 198 + }; 199 + MODULE_DEVICE_TABLE(of, rwdt_ids); 200 + 201 + static struct platform_driver rwdt_driver = { 202 + .driver = { 203 + .name = "renesas_wdt", 204 + .of_match_table = rwdt_ids, 205 + }, 206 + .probe = rwdt_probe, 207 + .remove = rwdt_remove, 208 + }; 209 + module_platform_driver(rwdt_driver); 210 + 211 + MODULE_DESCRIPTION("Renesas WDT Watchdog Driver"); 212 + MODULE_LICENSE("GPL v2"); 213 + MODULE_AUTHOR("Wolfram Sang <wsa@sang-engineering.com>");
+1 -3
drivers/watchdog/shwdt.c
··· 275 275 return rc; 276 276 } 277 277 278 - init_timer(&wdt->timer); 279 - wdt->timer.function = sh_wdt_ping; 280 - wdt->timer.data = (unsigned long)wdt; 278 + setup_timer(&wdt->timer, sh_wdt_ping, (unsigned long)wdt); 281 279 wdt->timer.expires = next_ping_period(clock_division_ratio); 282 280 283 281 dev_info(&pdev->dev, "initialized.\n");
+10 -5
drivers/watchdog/sp5100_tco.c
··· 73 73 /* 74 74 * Some TCO specific functions 75 75 */ 76 + 77 + static bool tco_has_sp5100_reg_layout(struct pci_dev *dev) 78 + { 79 + return dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && 80 + dev->revision < 0x40; 81 + } 82 + 76 83 static void tco_timer_start(void) 77 84 { 78 85 u32 val; ··· 136 129 { 137 130 int val; 138 131 139 - if (sp5100_tco_pci->revision >= 0x40) { 132 + if (!tco_has_sp5100_reg_layout(sp5100_tco_pci)) { 140 133 /* For SB800 or later */ 141 134 /* Set the Watchdog timer resolution to 1 sec */ 142 135 outb(SB800_PM_WATCHDOG_CONFIG, SB800_IO_PM_INDEX_REG); ··· 349 342 /* 350 343 * Determine type of southbridge chipset. 351 344 */ 352 - if (sp5100_tco_pci->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && 353 - sp5100_tco_pci->revision < 0x40) { 345 + if (tco_has_sp5100_reg_layout(sp5100_tco_pci)) { 354 346 dev_name = SP5100_DEVNAME; 355 347 index_reg = SP5100_IO_PM_INDEX_REG; 356 348 data_reg = SP5100_IO_PM_DATA_REG; ··· 394 388 * Secondly, Find the watchdog timer MMIO address 395 389 * from SBResource_MMIO register. 396 390 */ 397 - if (sp5100_tco_pci->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && 398 - sp5100_tco_pci->revision < 0x40) { 391 + if (tco_has_sp5100_reg_layout(sp5100_tco_pci)) { 399 392 /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */ 400 393 pci_read_config_dword(sp5100_tco_pci, 401 394 SP5100_SB_RESOURCE_MMIO_BASE, &val);
+1 -1
drivers/watchdog/watchdog_core.c
··· 104 104 * timeout module parameter (if it is valid value) or the timeout-sec property 105 105 * (only if it is a valid value and the timeout_parm is out of bounds). 106 106 * If none of them are valid then we keep the old value (which should normally 107 - * be the default timeout value. 107 + * be the default timeout value). 108 108 * 109 109 * A zero is returned on success and -EINVAL for failure. 110 110 */
-1
drivers/watchdog/watchdog_dev.c
··· 736 736 watchdog_ping(wdd); 737 737 } 738 738 739 - cancel_delayed_work_sync(&wd_data->work); 740 739 watchdog_update_worker(wdd); 741 740 742 741 /* make sure that /dev/watchdog can be re-opened */