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

Merge tag 'linux-watchdog-5.14-rc1' of git://www.linux-watchdog.org/linux-watchdog

Pull watchdog updates from Wim Van Sebroeck:

- Add Mstar MSC313e WDT driver

- Add support for sama7g5-wdt

- Add compatible for SC7280 SoC

- Add compatible for Mediatek MT8195

- sbsa: Support architecture version 1

- Removal of the MV64x60 watchdog driver

- Extra PCI IDs for hpwdt

- Add hrtimer-based pretimeout feature

- Add {min,max}_timeout sysfs nodes

- keembay timeout and pre-timeout handling

- Several fixes, cleanups and improvements

* tag 'linux-watchdog-5.14-rc1' of git://www.linux-watchdog.org/linux-watchdog: (56 commits)
watchdog: iTCO_wdt: use dev_err() instead of pr_err()
watchdog: Add Mstar MSC313e WDT driver
dt-bindings: watchdog: Add Mstar MSC313e WDT devicetree bindings documentation
watchdog: iTCO_wdt: Account for rebooting on second timeout
dt-bindings: watchdog: Convert arm,sbsa-gwdt to DT schema
dt-bindings: watchdog: sama5d4-wdt: add compatible for sama7g5-wdt
watchdog: sama5d4_wdt: add support for sama7g5-wdt
dt-bindings: watchdog: sama5d4-wdt: convert to yaml
watchdog: ziirave_wdt: Remove VERSION_FMT defines and add sysfs newlines
dt-bindings: watchdog: Add compatible for Mediatek MT8195
dt-bindings: watchdog: dw-wdt: add description for rk3568
watchdog: imx_sc_wdt: fix pretimeout
watchdog: diag288_wdt: Remove redundant assignment
watchdog: Add hrtimer-based pretimeout feature
dt-bindings: watchdog: Add compatible for SC7280 SoC
watchdog: qcom: Move suspend/resume to suspend_late/resume_early
watchdog: Fix a typo in the file orion_wdt.c
watchdog: jz4740: Fix return value check in jz4740_wdt_probe()
watchdog: Remove MV64x60 watchdog driver
doc: mtk-wdt: support pre-timeout when the bark irq is available
...

+772 -585
+74
Documentation/devicetree/bindings/watchdog/atmel,sama5d4-wdt.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/watchdog/atmel,sama5d4-wdt.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Atmel SAMA5D4 Watchdog Timer (WDT) Controller 8 + 9 + maintainers: 10 + - Eugen Hristev <eugen.hristev@microchip.com> 11 + 12 + allOf: 13 + - $ref: "watchdog.yaml#" 14 + 15 + properties: 16 + compatible: 17 + enum: 18 + - atmel,sama5d4-wdt 19 + - microchip,sam9x60-wdt 20 + - microchip,sama7g5-wdt 21 + 22 + reg: 23 + maxItems: 1 24 + 25 + atmel,watchdog-type: 26 + $ref: /schemas/types.yaml#/definitions/string 27 + description: should be hardware or software. 28 + oneOf: 29 + - description: 30 + Enable watchdog fault reset. A watchdog fault triggers 31 + watchdog reset. 32 + const: hardware 33 + - description: 34 + Enable watchdog fault interrupt. A watchdog fault asserts 35 + watchdog interrupt. 36 + const: software 37 + default: hardware 38 + 39 + atmel,idle-halt: 40 + $ref: /schemas/types.yaml#/definitions/flag 41 + description: | 42 + present if you want to stop the watchdog when the CPU is in idle state. 43 + CAUTION: This property should be used with care, it actually makes the 44 + watchdog not counting when the CPU is in idle state, therefore the 45 + watchdog reset time depends on mean CPU usage and will not reset at all 46 + if the CPU stop working while it is in idle state, which is probably 47 + not what you want. 48 + 49 + atmel,dbg-halt: 50 + $ref: /schemas/types.yaml#/definitions/flag 51 + description: | 52 + present if you want to stop the watchdog when the CPU is in debug state. 53 + 54 + required: 55 + - compatible 56 + - reg 57 + 58 + unevaluatedProperties: false 59 + 60 + examples: 61 + - | 62 + #include <dt-bindings/interrupt-controller/irq.h> 63 + 64 + watchdog@fc068640 { 65 + compatible = "atmel,sama5d4-wdt"; 66 + reg = <0xfc068640 0x10>; 67 + interrupts = <4 IRQ_TYPE_LEVEL_HIGH 5>; 68 + timeout-sec = <10>; 69 + atmel,watchdog-type = "hardware"; 70 + atmel,dbg-halt; 71 + atmel,idle-halt; 72 + }; 73 + 74 + ...
-34
Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
··· 1 - * Atmel SAMA5D4 Watchdog Timer (WDT) Controller 2 - 3 - Required properties: 4 - - compatible: "atmel,sama5d4-wdt" or "microchip,sam9x60-wdt" 5 - - reg: base physical address and length of memory mapped region. 6 - 7 - Optional properties: 8 - - timeout-sec: watchdog timeout value (in seconds). 9 - - interrupts: interrupt number to the CPU. 10 - - atmel,watchdog-type: should be "hardware" or "software". 11 - "hardware": enable watchdog fault reset. A watchdog fault triggers 12 - watchdog reset. 13 - "software": enable watchdog fault interrupt. A watchdog fault asserts 14 - watchdog interrupt. 15 - - atmel,idle-halt: present if you want to stop the watchdog when the CPU is 16 - in idle state. 17 - CAUTION: This property should be used with care, it actually makes the 18 - watchdog not counting when the CPU is in idle state, therefore the 19 - watchdog reset time depends on mean CPU usage and will not reset at all 20 - if the CPU stop working while it is in idle state, which is probably 21 - not what you want. 22 - - atmel,dbg-halt: present if you want to stop the watchdog when the CPU is 23 - in debug state. 24 - 25 - Example: 26 - watchdog@fc068640 { 27 - compatible = "atmel,sama5d4-wdt"; 28 - reg = <0xfc068640 0x10>; 29 - interrupts = <4 IRQ_TYPE_LEVEL_HIGH 5>; 30 - timeout-sec = <10>; 31 - atmel,watchdog-type = "hardware"; 32 - atmel,dbg-halt; 33 - atmel,idle-halt; 34 - };
+40
Documentation/devicetree/bindings/watchdog/mstar,msc313e-wdt.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/watchdog/mstar,msc313e-wdt.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: MStar Watchdog Device Tree Bindings 8 + 9 + maintainers: 10 + - Daniel Palmer <daniel@0x0f.com> 11 + - Romain Perier <romain.perier@gmail.com> 12 + 13 + allOf: 14 + - $ref: watchdog.yaml# 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - mstar,msc313e-wdt 20 + 21 + reg: 22 + maxItems: 1 23 + 24 + clocks: 25 + maxItems: 1 26 + 27 + required: 28 + - compatible 29 + - clocks 30 + - reg 31 + 32 + unevaluatedProperties: false 33 + 34 + examples: 35 + - | 36 + watchdog@6000 { 37 + compatible = "mstar,msc313e-wdt"; 38 + reg = <0x6000 0x1f>; 39 + clocks = <&xtal_div2>; 40 + };
+6
Documentation/devicetree/bindings/watchdog/mtk-wdt.txt
··· 1 1 Mediatek SoCs Watchdog timer 2 2 3 + The watchdog supports a pre-timeout interrupt that fires timeout-sec/2 4 + before the expiry. 5 + 3 6 Required properties: 4 7 5 8 - compatible should contain: ··· 16 13 "mediatek,mt8183-wdt": for MT8183 17 14 "mediatek,mt8516-wdt", "mediatek,mt6589-wdt": for MT8516 18 15 "mediatek,mt8192-wdt": for MT8192 16 + "mediatek,mt8195-wdt", "mediatek,mt6589-wdt": for MT8195 19 17 20 18 - reg : Specifies base physical address and size of the registers. 21 19 22 20 Optional properties: 21 + - interrupts: Watchdog pre-timeout (bark) interrupt. 23 22 - timeout-sec: contains the watchdog timeout in seconds. 24 23 - #reset-cells: Should be 1. 25 24 ··· 31 26 compatible = "mediatek,mt8183-wdt", 32 27 "mediatek,mt6589-wdt"; 33 28 reg = <0 0x10007000 0 0x100>; 29 + interrupts = <GIC_SPI 139 IRQ_TYPE_NONE>; 34 30 timeout-sec = <10>; 35 31 #reset-cells = <1>; 36 32 };
+1
Documentation/devicetree/bindings/watchdog/qcom-wdt.yaml
··· 17 17 enum: 18 18 - qcom,apss-wdt-qcs404 19 19 - qcom,apss-wdt-sc7180 20 + - qcom,apss-wdt-sc7280 20 21 - qcom,apss-wdt-sdm845 21 22 - qcom,apss-wdt-sdx55 22 23 - qcom,apss-wdt-sm8150
+1
Documentation/devicetree/bindings/watchdog/snps,dw-wdt.yaml
··· 27 27 - rockchip,rk3328-wdt 28 28 - rockchip,rk3368-wdt 29 29 - rockchip,rk3399-wdt 30 + - rockchip,rk3568-wdt 30 31 - rockchip,rv1108-wdt 31 32 - const: snps,dw-wdt 32 33
+1
MAINTAINERS
··· 2217 2217 F: arch/arm/mach-mstar/ 2218 2218 F: drivers/clk/mstar/ 2219 2219 F: drivers/gpio/gpio-msc313.c 2220 + F: drivers/watchdog/msc313e_wdt.c 2220 2221 F: include/dt-bindings/clock/mstar-* 2221 2222 F: include/dt-bindings/gpio/msc313-gpio.h 2222 2223
+49 -28
drivers/watchdog/Kconfig
··· 22 22 23 23 The watchdog is usually used together with the watchdog daemon 24 24 which is available from 25 - <ftp://ibiblio.org/pub/Linux/system/daemons/watchdog/>. This daemon can 26 - also monitor NFS connections and can reboot the machine when the process 27 - table is full. 25 + <https://ibiblio.org/pub/Linux/system/daemons/watchdog/>. This daemon 26 + can also monitor NFS connections and can reboot the machine when the 27 + process table is full. 28 28 29 29 If unsure, say N. 30 30 ··· 72 72 help 73 73 Say Y here if you want to enable watchdog device status read through 74 74 sysfs attributes. 75 + 76 + config WATCHDOG_HRTIMER_PRETIMEOUT 77 + bool "Enable watchdog hrtimer-based pretimeouts" 78 + help 79 + Enable this if you want to use a hrtimer timer based pretimeout for 80 + watchdogs that do not natively support pretimeout support. Be aware 81 + that because this pretimeout functionality uses hrtimers, it may not 82 + be able to fire before the actual watchdog fires in some situations. 75 83 76 84 comment "Watchdog Pretimeout Governors" 77 85 ··· 310 302 depends on HAS_IOMEM 311 303 select WATCHDOG_CORE 312 304 help 313 - Watchdog driver for the xps_timebase_wdt ip core. 305 + Watchdog driver for the xps_timebase_wdt IP core. 314 306 315 307 To compile this driver as a module, choose M here: the 316 308 module will be called of_xilinx_wdt. ··· 412 404 select WATCHDOG_CORE 413 405 select RESET_CONTROLLER 414 406 help 415 - Watchdog timer embedded into Alphascale asm9260 chips. This will reboot your 416 - system when the timeout is reached. 407 + Watchdog timer embedded into Alphascale asm9260 chips. This will 408 + reboot your system when the timeout is reached. 417 409 418 410 config AT91RM9200_WATCHDOG 419 411 tristate "AT91RM9200 watchdog" ··· 556 548 depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS || COMPILE_TEST 557 549 select WATCHDOG_CORE 558 550 help 559 - Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog. Say 'Y' 560 - here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog timer. 551 + Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog. 552 + Say 'Y' here to enable the 553 + OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog timer. 561 554 562 555 config PNX4008_WATCHDOG 563 556 tristate "LPC32XX Watchdog" ··· 989 980 Say Y here to include support for the watchdog timer in Toshiba 990 981 Visconti SoCs. 991 982 983 + config MSC313E_WATCHDOG 984 + tristate "MStar MSC313e watchdog" 985 + depends on ARCH_MSTARV7 || COMPILE_TEST 986 + select WATCHDOG_CORE 987 + help 988 + Say Y here to include support for the Watchdog timer embedded 989 + into MStar MSC313e chips. This will reboot your system when the 990 + timeout is reached. 991 + 992 + To compile this driver as a module, choose M here: the 993 + module will be called msc313e_wdt. 994 + 992 995 # X86 (i386 + ia64 + x86_64) Architecture 993 996 994 997 config ACQUIRE_WDT ··· 1117 1096 This is the driver for the built-in watchdog timer on the fit-PC2, 1118 1097 fit-PC2i, CM-iAM single-board computers made by Compulab. 1119 1098 1120 - It`s possible to enable watchdog timer either from BIOS (F2) or from booted Linux. 1121 - When "Watchdog Timer Value" enabled one can set 31-255 s operational range. 1099 + It's possible to enable the watchdog timer either from BIOS (F2) or 1100 + from booted Linux. 1101 + When the "Watchdog Timer Value" is enabled one can set 31-255 seconds 1102 + operational range. 1122 1103 1123 - Entering BIOS setup temporary disables watchdog operation regardless to current state, 1124 - so system will not be restarted while user in BIOS setup. 1104 + Entering BIOS setup temporarily disables watchdog operation regardless 1105 + of current state, so system will not be restarted while user is in 1106 + BIOS setup. 1125 1107 1126 - Once watchdog was enabled the system will be restarted every 1108 + Once the watchdog is enabled the system will be restarted every 1127 1109 "Watchdog Timer Value" period, so to prevent it user can restart or 1128 1110 disable the watchdog. 1129 1111 ··· 1148 1124 depends on X86 1149 1125 help 1150 1126 This is the driver for the hardware watchdog on the IB700 Single 1151 - Board Computer produced by TMC Technology (www.tmc-uk.com). This watchdog 1152 - simply watches your kernel to make sure it doesn't freeze, and if 1153 - it does, it reboots your computer after a certain amount of time. 1127 + Board Computer produced by TMC Technology (www.tmc-uk.com). This 1128 + watchdog simply watches your kernel to make sure it doesn't freeze, 1129 + and if it does, it reboots your computer after a certain amount of time. 1154 1130 1155 - This driver is like the WDT501 driver but for slightly different hardware. 1131 + This driver is like the WDT501 driver but for slightly different 1132 + hardware. 1156 1133 1157 1134 To compile this driver as a module, choose M here: the 1158 1135 module will be called ib700wdt. ··· 1832 1807 select WATCHDOG_CORE 1833 1808 depends on MACH_PIC32 || (MIPS && COMPILE_TEST) 1834 1809 help 1835 - Watchdog driver for PIC32 instruction fetch counting timer. This specific 1836 - timer is typically be used in misson critical and safety critical 1837 - applications, where any single failure of the software functionality 1838 - and sequencing must be detected. 1810 + Watchdog driver for PIC32 instruction fetch counting timer. This 1811 + specific timer is typically be used in mission critical and safety 1812 + critical applications, where any single failure of the software 1813 + functionality and sequencing must be detected. 1839 1814 1840 1815 To compile this driver as a loadable module, choose M here. 1841 1816 The module will be called pic32-dmt. ··· 1868 1843 - MPC86xx watchdogs 1869 1844 1870 1845 For BookE processors (MPC85xx) use the BOOKE_WDT driver instead. 1871 - 1872 - config MV64X60_WDT 1873 - tristate "MV64X60 (Marvell Discovery) Watchdog Timer" 1874 - depends on MV64X60 || COMPILE_TEST 1875 1846 1876 1847 config PIKA_WDT 1877 1848 tristate "PIKA FPGA Watchdog" ··· 2034 2013 This card simply watches your kernel to make sure it doesn't freeze, 2035 2014 and if it does, it reboots your computer after a certain amount of 2036 2015 time. This driver is like the WDT501 driver but for different 2037 - hardware. Please read <file:Documentation/watchdog/pcwd-watchdog.rst>. The PC 2038 - watchdog cards can be ordered from <http://www.berkprod.com/>. 2016 + hardware. Please read <file:Documentation/watchdog/pcwd-watchdog.rst>. 2017 + The PC watchdog cards can be ordered from <http://www.berkprod.com/>. 2039 2018 2040 2019 To compile this driver as a module, choose M here: the 2041 2020 module will be called pcwd. ··· 2136 2115 This option enable support for an In-secure watchdog timer driver for 2137 2116 Intel Keem Bay SoC. This WDT has a 32 bit timer and decrements in every 2138 2117 count unit. An interrupt will be triggered, when the count crosses 2139 - the thershold configured in the register. 2118 + the threshold configured in the register. 2140 2119 2141 2120 To compile this driver as a module, choose M here: the 2142 2121 module will be called keembay_wdt.
+2 -1
drivers/watchdog/Makefile
··· 9 9 watchdog-objs += watchdog_core.o watchdog_dev.o 10 10 11 11 watchdog-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV) += watchdog_pretimeout.o 12 + watchdog-$(CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT) += watchdog_hrtimer_pretimeout.o 12 13 13 14 obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_NOOP) += pretimeout_noop.o 14 15 obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC) += pretimeout_panic.o ··· 93 92 obj-$(CONFIG_PM8916_WATCHDOG) += pm8916_wdt.o 94 93 obj-$(CONFIG_ARM_SMC_WATCHDOG) += arm_smc_wdt.o 95 94 obj-$(CONFIG_VISCONTI_WATCHDOG) += visconti_wdt.o 95 + obj-$(CONFIG_MSC313E_WATCHDOG) += msc313e_wdt.o 96 96 97 97 # X86 (i386 + ia64 + x86_64) Architecture 98 98 obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o ··· 177 175 # POWERPC Architecture 178 176 obj-$(CONFIG_GEF_WDT) += gef_wdt.o 179 177 obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o 180 - obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o 181 178 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o 182 179 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o 183 180 obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o
+3 -3
drivers/watchdog/aspeed_wdt.c
··· 147 147 148 148 wdd->timeout = timeout; 149 149 150 - actual = min(timeout, wdd->max_hw_heartbeat_ms * 1000); 150 + actual = min(timeout, wdd->max_hw_heartbeat_ms / 1000); 151 151 152 152 writel(actual * WDT_RATE_1MHZ, wdt->base + WDT_RELOAD_VALUE); 153 153 writel(WDT_RESTART_MAGIC, wdt->base + WDT_RESTART); ··· 175 175 struct aspeed_wdt *wdt = dev_get_drvdata(dev); 176 176 u32 status = readl(wdt->base + WDT_TIMEOUT_STATUS); 177 177 178 - return sprintf(buf, "%u\n", 179 - !(status & WDT_TIMEOUT_STATUS_BOOT_SECONDARY)); 178 + return sysfs_emit(buf, "%u\n", 179 + !(status & WDT_TIMEOUT_STATUS_BOOT_SECONDARY)); 180 180 } 181 181 182 182 static ssize_t access_cs0_store(struct device *dev,
+25 -6
drivers/watchdog/bcm7038_wdt.c
··· 34 34 35 35 static bool nowayout = WATCHDOG_NOWAYOUT; 36 36 37 + static inline void bcm7038_wdt_write(u32 value, void __iomem *addr) 38 + { 39 + /* MIPS chips strapped for BE will automagically configure the 40 + * peripheral registers for CPU-native byte order. 41 + */ 42 + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) 43 + __raw_writel(value, addr); 44 + else 45 + writel_relaxed(value, addr); 46 + } 47 + 48 + static inline u32 bcm7038_wdt_read(void __iomem *addr) 49 + { 50 + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) 51 + return __raw_readl(addr); 52 + else 53 + return readl_relaxed(addr); 54 + } 55 + 37 56 static void bcm7038_wdt_set_timeout_reg(struct watchdog_device *wdog) 38 57 { 39 58 struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); ··· 60 41 61 42 timeout = wdt->rate * wdog->timeout; 62 43 63 - writel(timeout, wdt->base + WDT_TIMEOUT_REG); 44 + bcm7038_wdt_write(timeout, wdt->base + WDT_TIMEOUT_REG); 64 45 } 65 46 66 47 static int bcm7038_wdt_ping(struct watchdog_device *wdog) 67 48 { 68 49 struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); 69 50 70 - writel(WDT_START_1, wdt->base + WDT_CMD_REG); 71 - writel(WDT_START_2, wdt->base + WDT_CMD_REG); 51 + bcm7038_wdt_write(WDT_START_1, wdt->base + WDT_CMD_REG); 52 + bcm7038_wdt_write(WDT_START_2, wdt->base + WDT_CMD_REG); 72 53 73 54 return 0; 74 55 } ··· 85 66 { 86 67 struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); 87 68 88 - writel(WDT_STOP_1, wdt->base + WDT_CMD_REG); 89 - writel(WDT_STOP_2, wdt->base + WDT_CMD_REG); 69 + bcm7038_wdt_write(WDT_STOP_1, wdt->base + WDT_CMD_REG); 70 + bcm7038_wdt_write(WDT_STOP_2, wdt->base + WDT_CMD_REG); 90 71 91 72 return 0; 92 73 } ··· 107 88 struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); 108 89 u32 time_left; 109 90 110 - time_left = readl(wdt->base + WDT_CMD_REG); 91 + time_left = bcm7038_wdt_read(wdt->base + WDT_CMD_REG); 111 92 112 93 return time_left / wdt->rate; 113 94 }
+1 -1
drivers/watchdog/booke_wdt.c
··· 148 148 } 149 149 150 150 /** 151 - * booke_wdt_disable - disable the watchdog on the given CPU 151 + * __booke_wdt_disable - disable the watchdog on the given CPU 152 152 * 153 153 * This function is called on each CPU. It disables the watchdog on that CPU. 154 154 *
-4
drivers/watchdog/diag288_wdt.c
··· 118 118 if (test_and_set_bit(DIAG_WDOG_BUSY, &wdt_status)) 119 119 return -EBUSY; 120 120 121 - ret = -ENODEV; 122 - 123 121 if (MACHINE_IS_VM) { 124 122 ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL); 125 123 if (!ebc_cmd) { ··· 164 166 size_t len; 165 167 int ret; 166 168 unsigned int func; 167 - 168 - ret = -ENODEV; 169 169 170 170 if (MACHINE_IS_VM) { 171 171 ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL);
+4 -5
drivers/watchdog/dw_wdt.c
··· 13 13 */ 14 14 15 15 #include <linux/bitops.h> 16 - #include <linux/limits.h> 17 - #include <linux/kernel.h> 18 16 #include <linux/clk.h> 17 + #include <linux/debugfs.h> 19 18 #include <linux/delay.h> 20 19 #include <linux/err.h> 20 + #include <linux/interrupt.h> 21 21 #include <linux/io.h> 22 22 #include <linux/kernel.h> 23 + #include <linux/limits.h> 23 24 #include <linux/module.h> 24 25 #include <linux/moduleparam.h> 25 - #include <linux/interrupt.h> 26 26 #include <linux/of.h> 27 - #include <linux/pm.h> 28 27 #include <linux/platform_device.h> 28 + #include <linux/pm.h> 29 29 #include <linux/reset.h> 30 30 #include <linux/watchdog.h> 31 - #include <linux/debugfs.h> 32 31 33 32 #define WDOG_CONTROL_REG_OFFSET 0x00 34 33 #define WDOG_CONTROL_REG_WDT_EN_MASK 0x01
+1 -1
drivers/watchdog/eurotechwdt.c
··· 392 392 }; 393 393 394 394 /** 395 - * cleanup_module: 395 + * eurwdt_exit: 396 396 * 397 397 * Unload the watchdog. You cannot do this with any file handles open. 398 398 * If your watchdog is set to continue ticking on close and you unload
+1
drivers/watchdog/hpwdt.c
··· 45 45 static const struct pci_device_id hpwdt_devices[] = { 46 46 { PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB203) }, /* iLO2 */ 47 47 { PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3306) }, /* iLO3 */ 48 + { PCI_DEVICE(PCI_VENDOR_ID_HP_3PAR, 0x0389) }, /* PCtrl */ 48 49 {0}, /* terminate list */ 49 50 }; 50 51 MODULE_DEVICE_TABLE(pci, hpwdt_devices);
+11 -5
drivers/watchdog/iTCO_wdt.c
··· 71 71 #define TCOBASE(p) ((p)->tco_res->start) 72 72 /* SMI Control and Enable Register */ 73 73 #define SMI_EN(p) ((p)->smi_res->start) 74 + #define TCO_EN (1 << 13) 75 + #define GBL_SMI_EN (1 << 0) 74 76 75 77 #define TCO_RLD(p) (TCOBASE(p) + 0x00) /* TCO Timer Reload/Curr. Value */ 76 78 #define TCOv1_TMR(p) (TCOBASE(p) + 0x01) /* TCOv1 Timer Initial Value*/ ··· 357 355 358 356 tmrval = seconds_to_ticks(p, t); 359 357 360 - /* For TCO v1 the timer counts down twice before rebooting */ 361 - if (p->iTCO_version == 1) 358 + /* 359 + * If TCO SMIs are off, the timer counts down twice before rebooting. 360 + * Otherwise, the BIOS generally reboots when the SMI triggers. 361 + */ 362 + if (p->smi_res && 363 + (SMI_EN(p) & (TCO_EN | GBL_SMI_EN)) != (TCO_EN | GBL_SMI_EN)) 362 364 tmrval /= 2; 363 365 364 366 /* from the specs: */ ··· 485 479 if (!devm_request_region(dev, p->smi_res->start, 486 480 resource_size(p->smi_res), 487 481 pdev->name)) { 488 - pr_err("I/O address 0x%04llx already in use, device disabled\n", 482 + dev_err(dev, "I/O address 0x%04llx already in use, device disabled\n", 489 483 (u64)SMI_EN(p)); 490 484 return -EBUSY; 491 485 } 492 486 } else if (iTCO_vendorsupport || 493 487 turn_SMI_watchdog_clear_off >= p->iTCO_version) { 494 - pr_err("SMI I/O resource is missing\n"); 488 + dev_err(dev, "SMI I/O resource is missing\n"); 495 489 return -ENODEV; 496 490 } 497 491 ··· 527 521 * Disables TCO logic generating an SMI# 528 522 */ 529 523 val32 = inl(SMI_EN(p)); 530 - val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */ 524 + val32 &= ~TCO_EN; /* Turn off SMI clearing watchdog */ 531 525 outl(val32, SMI_EN(p)); 532 526 } 533 527
+10
drivers/watchdog/imx2_wdt.c
··· 65 65 struct regmap *regmap; 66 66 struct watchdog_device wdog; 67 67 bool ext_reset; 68 + bool clk_is_on; 68 69 }; 69 70 70 71 static bool nowayout = WATCHDOG_NOWAYOUT; ··· 160 159 static int imx2_wdt_ping(struct watchdog_device *wdog) 161 160 { 162 161 struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); 162 + 163 + if (!wdev->clk_is_on) 164 + return 0; 163 165 164 166 regmap_write(wdev->regmap, IMX2_WDT_WSR, IMX2_WDT_SEQ1); 165 167 regmap_write(wdev->regmap, IMX2_WDT_WSR, IMX2_WDT_SEQ2); ··· 305 301 if (ret) 306 302 return ret; 307 303 304 + wdev->clk_is_on = true; 305 + 308 306 regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val); 309 307 wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0; 310 308 ··· 367 361 368 362 clk_disable_unprepare(wdev->clk); 369 363 364 + wdev->clk_is_on = false; 365 + 370 366 return 0; 371 367 } 372 368 ··· 382 374 ret = clk_prepare_enable(wdev->clk); 383 375 if (ret) 384 376 return ret; 377 + 378 + wdev->clk_is_on = true; 385 379 386 380 if (watchdog_active(wdog) && !imx2_wdt_is_running(wdev)) { 387 381 /*
+4 -7
drivers/watchdog/imx_sc_wdt.c
··· 183 183 watchdog_stop_on_reboot(wdog); 184 184 watchdog_stop_on_unregister(wdog); 185 185 186 - ret = devm_watchdog_register_device(dev, wdog); 187 - if (ret) 188 - return ret; 189 - 190 186 ret = imx_scu_irq_group_enable(SC_IRQ_GROUP_WDOG, 191 187 SC_IRQ_WDOG, 192 188 true); 193 189 if (ret) { 194 190 dev_warn(dev, "Enable irq failed, pretimeout NOT supported\n"); 195 - return 0; 191 + goto register_device; 196 192 } 197 193 198 194 imx_sc_wdd->wdt_notifier.notifier_call = imx_sc_wdt_notify; ··· 199 203 false); 200 204 dev_warn(dev, 201 205 "Register irq notifier failed, pretimeout NOT supported\n"); 202 - return 0; 206 + goto register_device; 203 207 } 204 208 205 209 ret = devm_add_action_or_reset(dev, imx_sc_wdt_action, ··· 209 213 else 210 214 dev_warn(dev, "Add action failed, pretimeout NOT supported\n"); 211 215 212 - return 0; 216 + register_device: 217 + return devm_watchdog_register_device(dev, wdog); 213 218 } 214 219 215 220 static int __maybe_unused imx_sc_wdt_suspend(struct device *dev)
-8
drivers/watchdog/it87_wdt.c
··· 152 152 return val; 153 153 } 154 154 155 - static inline void superio_outw(int val, int reg) 156 - { 157 - outb(reg++, REG); 158 - outb(val >> 8, VAL); 159 - outb(reg, REG); 160 - outb(val, VAL); 161 - } 162 - 163 155 /* Internal function, should be called after superio_select(GPIO) */ 164 156 static void _wdt_update_timeout(unsigned int t) 165 157 {
+2 -2
drivers/watchdog/jz4740_wdt.c
··· 176 176 watchdog_set_drvdata(jz4740_wdt, drvdata); 177 177 178 178 drvdata->map = device_node_to_regmap(dev->parent->of_node); 179 - if (!drvdata->map) { 179 + if (IS_ERR(drvdata->map)) { 180 180 dev_err(dev, "regmap not found\n"); 181 - return -EINVAL; 181 + return PTR_ERR(drvdata->map); 182 182 } 183 183 184 184 return devm_watchdog_register_device(dev, &drvdata->wdt);
+22 -12
drivers/watchdog/keembay_wdt.c
··· 23 23 #define TIM_WDOG_EN 0x8 24 24 #define TIM_SAFE 0xc 25 25 26 - #define WDT_ISR_MASK GENMASK(9, 8) 27 - #define WDT_ISR_CLEAR 0x8200ff18 26 + #define WDT_TH_INT_MASK BIT(8) 27 + #define WDT_TO_INT_MASK BIT(9) 28 + #define WDT_INT_CLEAR_SMC 0x8200ff18 29 + 28 30 #define WDT_UNLOCK 0xf1d0dead 31 + #define WDT_DISABLE 0x0 32 + #define WDT_ENABLE 0x1 33 + 29 34 #define WDT_LOAD_MAX U32_MAX 30 35 #define WDT_LOAD_MIN 1 36 + 31 37 #define WDT_TIMEOUT 5 38 + #define WDT_PRETIMEOUT 4 32 39 33 40 static unsigned int timeout = WDT_TIMEOUT; 34 41 module_param(timeout, int, 0); ··· 89 82 { 90 83 struct keembay_wdt *wdt = watchdog_get_drvdata(wdog); 91 84 92 - keembay_wdt_set_timeout_reg(wdog); 93 - keembay_wdt_writel(wdt, TIM_WDOG_EN, 1); 85 + keembay_wdt_writel(wdt, TIM_WDOG_EN, WDT_ENABLE); 94 86 95 87 return 0; 96 88 } ··· 98 92 { 99 93 struct keembay_wdt *wdt = watchdog_get_drvdata(wdog); 100 94 101 - keembay_wdt_writel(wdt, TIM_WDOG_EN, 0); 95 + keembay_wdt_writel(wdt, TIM_WDOG_EN, WDT_DISABLE); 102 96 103 97 return 0; 104 98 } ··· 114 108 { 115 109 wdog->timeout = t; 116 110 keembay_wdt_set_timeout_reg(wdog); 111 + keembay_wdt_set_pretimeout_reg(wdog); 117 112 118 113 return 0; 119 114 } ··· 146 139 struct keembay_wdt *wdt = dev_id; 147 140 struct arm_smccc_res res; 148 141 149 - keembay_wdt_writel(wdt, TIM_WATCHDOG, 1); 150 - arm_smccc_smc(WDT_ISR_CLEAR, WDT_ISR_MASK, 0, 0, 0, 0, 0, 0, &res); 151 - dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt timeout.\n"); 142 + arm_smccc_smc(WDT_INT_CLEAR_SMC, WDT_TO_INT_MASK, 0, 0, 0, 0, 0, 0, &res); 143 + dev_crit(wdt->wdd.parent, "Intel Keem Bay non-secure wdt timeout.\n"); 152 144 emergency_restart(); 153 145 154 146 return IRQ_HANDLED; ··· 158 152 struct keembay_wdt *wdt = dev_id; 159 153 struct arm_smccc_res res; 160 154 161 - arm_smccc_smc(WDT_ISR_CLEAR, WDT_ISR_MASK, 0, 0, 0, 0, 0, 0, &res); 162 - dev_crit(wdt->wdd.parent, "Intel Keem Bay non-sec wdt pre-timeout.\n"); 155 + keembay_wdt_set_pretimeout(&wdt->wdd, 0x0); 156 + 157 + arm_smccc_smc(WDT_INT_CLEAR_SMC, WDT_TH_INT_MASK, 0, 0, 0, 0, 0, 0, &res); 158 + dev_crit(wdt->wdd.parent, "Intel Keem Bay non-secure wdt pre-timeout.\n"); 163 159 watchdog_notify_pretimeout(&wdt->wdd); 164 160 165 161 return IRQ_HANDLED; ··· 232 224 wdt->wdd.min_timeout = WDT_LOAD_MIN; 233 225 wdt->wdd.max_timeout = WDT_LOAD_MAX / wdt->rate; 234 226 wdt->wdd.timeout = WDT_TIMEOUT; 227 + wdt->wdd.pretimeout = WDT_PRETIMEOUT; 235 228 236 229 watchdog_set_drvdata(&wdt->wdd, wdt); 237 230 watchdog_set_nowayout(&wdt->wdd, nowayout); 238 231 watchdog_init_timeout(&wdt->wdd, timeout, dev); 239 232 keembay_wdt_set_timeout(&wdt->wdd, wdt->wdd.timeout); 233 + keembay_wdt_set_pretimeout(&wdt->wdd, wdt->wdd.pretimeout); 240 234 241 235 ret = devm_watchdog_register_device(dev, &wdt->wdd); 242 236 if (ret) ··· 281 271 MODULE_DEVICE_TABLE(of, keembay_wdt_match); 282 272 283 273 static struct platform_driver keembay_wdt_driver = { 284 - .probe = keembay_wdt_probe, 285 - .driver = { 274 + .probe = keembay_wdt_probe, 275 + .driver = { 286 276 .name = "keembay_wdt", 287 277 .of_match_table = keembay_wdt_match, 288 278 .pm = &keembay_wdt_pm_ops,
+1 -1
drivers/watchdog/lpc18xx_wdt.c
··· 292 292 struct lpc18xx_wdt_dev *lpc18xx_wdt = platform_get_drvdata(pdev); 293 293 294 294 dev_warn(&pdev->dev, "I quit now, hardware will probably reboot!\n"); 295 - del_timer(&lpc18xx_wdt->timer); 295 + del_timer_sync(&lpc18xx_wdt->timer); 296 296 297 297 return 0; 298 298 }
+2 -2
drivers/watchdog/mei_wdt.c
··· 105 105 #endif /* CONFIG_DEBUG_FS */ 106 106 }; 107 107 108 - /* 108 + /** 109 109 * struct mei_mc_hdr - Management Control Command Header 110 110 * 111 111 * @command: Management Control (0x2) ··· 474 474 complete(&wdt->response); 475 475 } 476 476 477 - /* 477 + /** 478 478 * mei_wdt_notif - callback for event notification 479 479 * 480 480 * @cldev: bus device
+1 -7
drivers/watchdog/meson_wdt.c
··· 162 162 { 163 163 struct device *dev = &pdev->dev; 164 164 struct meson_wdt_dev *meson_wdt; 165 - const struct of_device_id *of_id; 166 165 int err; 167 166 168 167 meson_wdt = devm_kzalloc(dev, sizeof(*meson_wdt), GFP_KERNEL); ··· 172 173 if (IS_ERR(meson_wdt->wdt_base)) 173 174 return PTR_ERR(meson_wdt->wdt_base); 174 175 175 - of_id = of_match_device(meson_wdt_dt_ids, dev); 176 - if (!of_id) { 177 - dev_err(dev, "Unable to initialize WDT data\n"); 178 - return -ENODEV; 179 - } 180 - meson_wdt->data = of_id->data; 176 + meson_wdt->data = device_get_match_data(dev); 181 177 182 178 meson_wdt->wdt_dev.parent = dev; 183 179 meson_wdt->wdt_dev.info = &meson_wdt_info;
+166
drivers/watchdog/msc313e_wdt.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * MStar WDT driver 4 + * 5 + * Copyright (C) 2019 - 2021 Daniel Palmer 6 + * Copyright (C) 2021 Romain Perier 7 + * 8 + */ 9 + 10 + #include <linux/clk.h> 11 + #include <linux/io.h> 12 + #include <linux/mod_devicetable.h> 13 + #include <linux/module.h> 14 + #include <linux/platform_device.h> 15 + #include <linux/watchdog.h> 16 + 17 + #define REG_WDT_CLR 0x0 18 + #define REG_WDT_MAX_PRD_L 0x10 19 + #define REG_WDT_MAX_PRD_H 0x14 20 + 21 + #define MSC313E_WDT_MIN_TIMEOUT 1 22 + #define MSC313E_WDT_DEFAULT_TIMEOUT 30 23 + 24 + static unsigned int timeout; 25 + 26 + module_param(timeout, int, 0); 27 + MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds"); 28 + 29 + struct msc313e_wdt_priv { 30 + void __iomem *base; 31 + struct watchdog_device wdev; 32 + struct clk *clk; 33 + }; 34 + 35 + static int msc313e_wdt_start(struct watchdog_device *wdev) 36 + { 37 + struct msc313e_wdt_priv *priv = watchdog_get_drvdata(wdev); 38 + u32 timeout; 39 + int err; 40 + 41 + err = clk_prepare_enable(priv->clk); 42 + if (err) 43 + return err; 44 + 45 + timeout = wdev->timeout * clk_get_rate(priv->clk); 46 + writew(timeout & 0xffff, priv->base + REG_WDT_MAX_PRD_L); 47 + writew((timeout >> 16) & 0xffff, priv->base + REG_WDT_MAX_PRD_H); 48 + writew(1, priv->base + REG_WDT_CLR); 49 + return 0; 50 + } 51 + 52 + static int msc313e_wdt_ping(struct watchdog_device *wdev) 53 + { 54 + struct msc313e_wdt_priv *priv = watchdog_get_drvdata(wdev); 55 + 56 + writew(1, priv->base + REG_WDT_CLR); 57 + return 0; 58 + } 59 + 60 + static int msc313e_wdt_stop(struct watchdog_device *wdev) 61 + { 62 + struct msc313e_wdt_priv *priv = watchdog_get_drvdata(wdev); 63 + 64 + writew(0, priv->base + REG_WDT_MAX_PRD_L); 65 + writew(0, priv->base + REG_WDT_MAX_PRD_H); 66 + writew(0, priv->base + REG_WDT_CLR); 67 + clk_disable_unprepare(priv->clk); 68 + return 0; 69 + } 70 + 71 + static int msc313e_wdt_settimeout(struct watchdog_device *wdev, unsigned int new_time) 72 + { 73 + wdev->timeout = new_time; 74 + 75 + return msc313e_wdt_start(wdev); 76 + } 77 + 78 + static const struct watchdog_info msc313e_wdt_ident = { 79 + .identity = "MSC313e watchdog", 80 + .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, 81 + }; 82 + 83 + static const struct watchdog_ops msc313e_wdt_ops = { 84 + .owner = THIS_MODULE, 85 + .start = msc313e_wdt_start, 86 + .stop = msc313e_wdt_stop, 87 + .ping = msc313e_wdt_ping, 88 + .set_timeout = msc313e_wdt_settimeout, 89 + }; 90 + 91 + static const struct of_device_id msc313e_wdt_of_match[] = { 92 + { .compatible = "mstar,msc313e-wdt", }, 93 + { /* sentinel */ } 94 + }; 95 + MODULE_DEVICE_TABLE(of, msc313e_wdt_of_match); 96 + 97 + static int msc313e_wdt_probe(struct platform_device *pdev) 98 + { 99 + struct device *dev = &pdev->dev; 100 + struct msc313e_wdt_priv *priv; 101 + 102 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 103 + if (!priv) 104 + return -ENOMEM; 105 + 106 + priv->base = devm_platform_ioremap_resource(pdev, 0); 107 + if (IS_ERR(priv->base)) 108 + return PTR_ERR(priv->base); 109 + 110 + priv->clk = devm_clk_get(dev, NULL); 111 + if (IS_ERR(priv->clk)) { 112 + dev_err(dev, "No input clock\n"); 113 + return PTR_ERR(priv->clk); 114 + } 115 + 116 + priv->wdev.info = &msc313e_wdt_ident, 117 + priv->wdev.ops = &msc313e_wdt_ops, 118 + priv->wdev.parent = dev; 119 + priv->wdev.min_timeout = MSC313E_WDT_MIN_TIMEOUT; 120 + priv->wdev.max_timeout = U32_MAX / clk_get_rate(priv->clk); 121 + priv->wdev.timeout = MSC313E_WDT_DEFAULT_TIMEOUT; 122 + 123 + watchdog_set_drvdata(&priv->wdev, priv); 124 + 125 + watchdog_init_timeout(&priv->wdev, timeout, dev); 126 + watchdog_stop_on_reboot(&priv->wdev); 127 + watchdog_stop_on_unregister(&priv->wdev); 128 + 129 + return devm_watchdog_register_device(dev, &priv->wdev); 130 + } 131 + 132 + static int __maybe_unused msc313e_wdt_suspend(struct device *dev) 133 + { 134 + struct msc313e_wdt_priv *priv = dev_get_drvdata(dev); 135 + 136 + if (watchdog_active(&priv->wdev)) 137 + msc313e_wdt_stop(&priv->wdev); 138 + 139 + return 0; 140 + } 141 + 142 + static int __maybe_unused msc313e_wdt_resume(struct device *dev) 143 + { 144 + struct msc313e_wdt_priv *priv = dev_get_drvdata(dev); 145 + 146 + if (watchdog_active(&priv->wdev)) 147 + msc313e_wdt_start(&priv->wdev); 148 + 149 + return 0; 150 + } 151 + 152 + static SIMPLE_DEV_PM_OPS(msc313e_wdt_pm_ops, msc313e_wdt_suspend, msc313e_wdt_resume); 153 + 154 + static struct platform_driver msc313e_wdt_driver = { 155 + .driver = { 156 + .name = "msc313e-wdt", 157 + .of_match_table = msc313e_wdt_of_match, 158 + .pm = &msc313e_wdt_pm_ops, 159 + }, 160 + .probe = msc313e_wdt_probe, 161 + }; 162 + module_platform_driver(msc313e_wdt_driver); 163 + 164 + MODULE_AUTHOR("Daniel Palmer <daniel@thingy.jp>"); 165 + MODULE_DESCRIPTION("Watchdog driver for MStar MSC313e"); 166 + MODULE_LICENSE("GPL v2");
+72 -5
drivers/watchdog/mtk_wdt.c
··· 25 25 #include <linux/reset-controller.h> 26 26 #include <linux/types.h> 27 27 #include <linux/watchdog.h> 28 + #include <linux/interrupt.h> 28 29 29 30 #define WDT_MAX_TIMEOUT 31 30 - #define WDT_MIN_TIMEOUT 1 31 + #define WDT_MIN_TIMEOUT 2 31 32 #define WDT_LENGTH_TIMEOUT(n) ((n) << 5) 32 33 33 34 #define WDT_LENGTH 0x04 ··· 188 187 u32 reg; 189 188 190 189 wdt_dev->timeout = timeout; 190 + /* 191 + * In dual mode, irq will be triggered at timeout / 2 192 + * the real timeout occurs at timeout 193 + */ 194 + if (wdt_dev->pretimeout) 195 + wdt_dev->pretimeout = timeout / 2; 191 196 192 197 /* 193 198 * One bit is the value of 512 ticks 194 199 * The clock has 32 KHz 195 200 */ 196 - reg = WDT_LENGTH_TIMEOUT(timeout << 6) | WDT_LENGTH_KEY; 201 + reg = WDT_LENGTH_TIMEOUT((timeout - wdt_dev->pretimeout) << 6) 202 + | WDT_LENGTH_KEY; 197 203 iowrite32(reg, wdt_base + WDT_LENGTH); 198 204 199 205 mtk_wdt_ping(wdt_dev); ··· 247 239 return ret; 248 240 249 241 reg = ioread32(wdt_base + WDT_MODE); 250 - reg &= ~(WDT_MODE_IRQ_EN | WDT_MODE_DUAL_EN); 242 + if (wdt_dev->pretimeout) 243 + reg |= (WDT_MODE_IRQ_EN | WDT_MODE_DUAL_EN); 244 + else 245 + reg &= ~(WDT_MODE_IRQ_EN | WDT_MODE_DUAL_EN); 251 246 reg |= (WDT_MODE_EN | WDT_MODE_KEY); 252 247 iowrite32(reg, wdt_base + WDT_MODE); 253 248 254 249 return 0; 255 250 } 256 251 252 + static int mtk_wdt_set_pretimeout(struct watchdog_device *wdd, 253 + unsigned int timeout) 254 + { 255 + struct mtk_wdt_dev *mtk_wdt = watchdog_get_drvdata(wdd); 256 + void __iomem *wdt_base = mtk_wdt->wdt_base; 257 + u32 reg = ioread32(wdt_base + WDT_MODE); 258 + 259 + if (timeout && !wdd->pretimeout) { 260 + wdd->pretimeout = wdd->timeout / 2; 261 + reg |= (WDT_MODE_IRQ_EN | WDT_MODE_DUAL_EN); 262 + } else if (!timeout && wdd->pretimeout) { 263 + wdd->pretimeout = 0; 264 + reg &= ~(WDT_MODE_IRQ_EN | WDT_MODE_DUAL_EN); 265 + } else { 266 + return 0; 267 + } 268 + 269 + reg |= WDT_MODE_KEY; 270 + iowrite32(reg, wdt_base + WDT_MODE); 271 + 272 + return mtk_wdt_set_timeout(wdd, wdd->timeout); 273 + } 274 + 275 + static irqreturn_t mtk_wdt_isr(int irq, void *arg) 276 + { 277 + struct watchdog_device *wdd = arg; 278 + 279 + watchdog_notify_pretimeout(wdd); 280 + 281 + return IRQ_HANDLED; 282 + } 283 + 257 284 static const struct watchdog_info mtk_wdt_info = { 258 285 .identity = DRV_NAME, 259 286 .options = WDIOF_SETTIMEOUT | 287 + WDIOF_KEEPALIVEPING | 288 + WDIOF_MAGICCLOSE, 289 + }; 290 + 291 + static const struct watchdog_info mtk_wdt_pt_info = { 292 + .identity = DRV_NAME, 293 + .options = WDIOF_SETTIMEOUT | 294 + WDIOF_PRETIMEOUT | 260 295 WDIOF_KEEPALIVEPING | 261 296 WDIOF_MAGICCLOSE, 262 297 }; ··· 310 259 .stop = mtk_wdt_stop, 311 260 .ping = mtk_wdt_ping, 312 261 .set_timeout = mtk_wdt_set_timeout, 262 + .set_pretimeout = mtk_wdt_set_pretimeout, 313 263 .restart = mtk_wdt_restart, 314 264 }; 315 265 ··· 319 267 struct device *dev = &pdev->dev; 320 268 struct mtk_wdt_dev *mtk_wdt; 321 269 const struct mtk_wdt_data *wdt_data; 322 - int err; 270 + int err, irq; 323 271 324 272 mtk_wdt = devm_kzalloc(dev, sizeof(*mtk_wdt), GFP_KERNEL); 325 273 if (!mtk_wdt) ··· 331 279 if (IS_ERR(mtk_wdt->wdt_base)) 332 280 return PTR_ERR(mtk_wdt->wdt_base); 333 281 334 - mtk_wdt->wdt_dev.info = &mtk_wdt_info; 282 + irq = platform_get_irq(pdev, 0); 283 + if (irq > 0) { 284 + err = devm_request_irq(&pdev->dev, irq, mtk_wdt_isr, 0, "wdt_bark", 285 + &mtk_wdt->wdt_dev); 286 + if (err) 287 + return err; 288 + 289 + mtk_wdt->wdt_dev.info = &mtk_wdt_pt_info; 290 + mtk_wdt->wdt_dev.pretimeout = WDT_MAX_TIMEOUT / 2; 291 + } else { 292 + if (irq == -EPROBE_DEFER) 293 + return -EPROBE_DEFER; 294 + 295 + mtk_wdt->wdt_dev.info = &mtk_wdt_info; 296 + } 297 + 335 298 mtk_wdt->wdt_dev.ops = &mtk_wdt_ops; 336 299 mtk_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT; 337 300 mtk_wdt->wdt_dev.max_hw_heartbeat_ms = WDT_MAX_TIMEOUT * 1000;
-2
drivers/watchdog/mtx-1_wdt.c
··· 41 41 #include <linux/uaccess.h> 42 42 #include <linux/gpio/consumer.h> 43 43 44 - #include <asm/mach-au1x00/au1000.h> 45 - 46 44 #define MTX1_WDT_INTERVAL (5 * HZ) 47 45 48 46 static int ticks = 100 * HZ;
-324
drivers/watchdog/mv64x60_wdt.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * mv64x60_wdt.c - MV64X60 (Marvell Discovery) watchdog userspace interface 4 - * 5 - * Author: James Chapman <jchapman@katalix.com> 6 - * 7 - * Platform-specific setup code should configure the dog to generate 8 - * interrupt or reset as required. This code only enables/disables 9 - * and services the watchdog. 10 - * 11 - * Derived from mpc8xx_wdt.c, with the following copyright. 12 - * 13 - * 2002 (c) Florian Schirmer <jolt@tuxbox.org> 14 - */ 15 - 16 - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17 - 18 - #include <linux/fs.h> 19 - #include <linux/init.h> 20 - #include <linux/kernel.h> 21 - #include <linux/miscdevice.h> 22 - #include <linux/module.h> 23 - #include <linux/watchdog.h> 24 - #include <linux/platform_device.h> 25 - #include <linux/mv643xx.h> 26 - #include <linux/uaccess.h> 27 - #include <linux/io.h> 28 - 29 - #define MV64x60_WDT_WDC_OFFSET 0 30 - 31 - /* 32 - * The watchdog configuration register contains a pair of 2-bit fields, 33 - * 1. a reload field, bits 27-26, which triggers a reload of 34 - * the countdown register, and 35 - * 2. an enable field, bits 25-24, which toggles between 36 - * enabling and disabling the watchdog timer. 37 - * Bit 31 is a read-only field which indicates whether the 38 - * watchdog timer is currently enabled. 39 - * 40 - * The low 24 bits contain the timer reload value. 41 - */ 42 - #define MV64x60_WDC_ENABLE_SHIFT 24 43 - #define MV64x60_WDC_SERVICE_SHIFT 26 44 - #define MV64x60_WDC_ENABLED_SHIFT 31 45 - 46 - #define MV64x60_WDC_ENABLED_TRUE 1 47 - #define MV64x60_WDC_ENABLED_FALSE 0 48 - 49 - /* Flags bits */ 50 - #define MV64x60_WDOG_FLAG_OPENED 0 51 - 52 - static unsigned long wdt_flags; 53 - static int wdt_status; 54 - static void __iomem *mv64x60_wdt_regs; 55 - static int mv64x60_wdt_timeout; 56 - static int mv64x60_wdt_count; 57 - static unsigned int bus_clk; 58 - static char expect_close; 59 - static DEFINE_SPINLOCK(mv64x60_wdt_spinlock); 60 - 61 - static bool nowayout = WATCHDOG_NOWAYOUT; 62 - module_param(nowayout, bool, 0); 63 - MODULE_PARM_DESC(nowayout, 64 - "Watchdog cannot be stopped once started (default=" 65 - __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 66 - 67 - static int mv64x60_wdt_toggle_wdc(int enabled_predicate, int field_shift) 68 - { 69 - u32 data; 70 - u32 enabled; 71 - int ret = 0; 72 - 73 - spin_lock(&mv64x60_wdt_spinlock); 74 - data = readl(mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET); 75 - enabled = (data >> MV64x60_WDC_ENABLED_SHIFT) & 1; 76 - 77 - /* only toggle the requested field if enabled state matches predicate */ 78 - if ((enabled ^ enabled_predicate) == 0) { 79 - /* We write a 1, then a 2 -- to the appropriate field */ 80 - data = (1 << field_shift) | mv64x60_wdt_count; 81 - writel(data, mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET); 82 - 83 - data = (2 << field_shift) | mv64x60_wdt_count; 84 - writel(data, mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET); 85 - ret = 1; 86 - } 87 - spin_unlock(&mv64x60_wdt_spinlock); 88 - 89 - return ret; 90 - } 91 - 92 - static void mv64x60_wdt_service(void) 93 - { 94 - mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_TRUE, 95 - MV64x60_WDC_SERVICE_SHIFT); 96 - } 97 - 98 - static void mv64x60_wdt_handler_enable(void) 99 - { 100 - if (mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_FALSE, 101 - MV64x60_WDC_ENABLE_SHIFT)) { 102 - mv64x60_wdt_service(); 103 - pr_notice("watchdog activated\n"); 104 - } 105 - } 106 - 107 - static void mv64x60_wdt_handler_disable(void) 108 - { 109 - if (mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_TRUE, 110 - MV64x60_WDC_ENABLE_SHIFT)) 111 - pr_notice("watchdog deactivated\n"); 112 - } 113 - 114 - static void mv64x60_wdt_set_timeout(unsigned int timeout) 115 - { 116 - /* maximum bus cycle count is 0xFFFFFFFF */ 117 - if (timeout > 0xFFFFFFFF / bus_clk) 118 - timeout = 0xFFFFFFFF / bus_clk; 119 - 120 - mv64x60_wdt_count = timeout * bus_clk >> 8; 121 - mv64x60_wdt_timeout = timeout; 122 - } 123 - 124 - static int mv64x60_wdt_open(struct inode *inode, struct file *file) 125 - { 126 - if (test_and_set_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags)) 127 - return -EBUSY; 128 - 129 - if (nowayout) 130 - __module_get(THIS_MODULE); 131 - 132 - mv64x60_wdt_handler_enable(); 133 - 134 - return stream_open(inode, file); 135 - } 136 - 137 - static int mv64x60_wdt_release(struct inode *inode, struct file *file) 138 - { 139 - if (expect_close == 42) 140 - mv64x60_wdt_handler_disable(); 141 - else { 142 - pr_crit("unexpected close, not stopping timer!\n"); 143 - mv64x60_wdt_service(); 144 - } 145 - expect_close = 0; 146 - 147 - clear_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags); 148 - 149 - return 0; 150 - } 151 - 152 - static ssize_t mv64x60_wdt_write(struct file *file, const char __user *data, 153 - size_t len, loff_t *ppos) 154 - { 155 - if (len) { 156 - if (!nowayout) { 157 - size_t i; 158 - 159 - expect_close = 0; 160 - 161 - for (i = 0; i != len; i++) { 162 - char c; 163 - if (get_user(c, data + i)) 164 - return -EFAULT; 165 - if (c == 'V') 166 - expect_close = 42; 167 - } 168 - } 169 - mv64x60_wdt_service(); 170 - } 171 - 172 - return len; 173 - } 174 - 175 - static long mv64x60_wdt_ioctl(struct file *file, 176 - unsigned int cmd, unsigned long arg) 177 - { 178 - int timeout; 179 - int options; 180 - void __user *argp = (void __user *)arg; 181 - static const struct watchdog_info info = { 182 - .options = WDIOF_SETTIMEOUT | 183 - WDIOF_MAGICCLOSE | 184 - WDIOF_KEEPALIVEPING, 185 - .firmware_version = 0, 186 - .identity = "MV64x60 watchdog", 187 - }; 188 - 189 - switch (cmd) { 190 - case WDIOC_GETSUPPORT: 191 - if (copy_to_user(argp, &info, sizeof(info))) 192 - return -EFAULT; 193 - break; 194 - 195 - case WDIOC_GETSTATUS: 196 - case WDIOC_GETBOOTSTATUS: 197 - if (put_user(wdt_status, (int __user *)argp)) 198 - return -EFAULT; 199 - wdt_status &= ~WDIOF_KEEPALIVEPING; 200 - break; 201 - 202 - case WDIOC_GETTEMP: 203 - return -EOPNOTSUPP; 204 - 205 - case WDIOC_SETOPTIONS: 206 - if (get_user(options, (int __user *)argp)) 207 - return -EFAULT; 208 - 209 - if (options & WDIOS_DISABLECARD) 210 - mv64x60_wdt_handler_disable(); 211 - 212 - if (options & WDIOS_ENABLECARD) 213 - mv64x60_wdt_handler_enable(); 214 - break; 215 - 216 - case WDIOC_KEEPALIVE: 217 - mv64x60_wdt_service(); 218 - wdt_status |= WDIOF_KEEPALIVEPING; 219 - break; 220 - 221 - case WDIOC_SETTIMEOUT: 222 - if (get_user(timeout, (int __user *)argp)) 223 - return -EFAULT; 224 - mv64x60_wdt_set_timeout(timeout); 225 - fallthrough; 226 - 227 - case WDIOC_GETTIMEOUT: 228 - if (put_user(mv64x60_wdt_timeout, (int __user *)argp)) 229 - return -EFAULT; 230 - break; 231 - 232 - default: 233 - return -ENOTTY; 234 - } 235 - 236 - return 0; 237 - } 238 - 239 - static const struct file_operations mv64x60_wdt_fops = { 240 - .owner = THIS_MODULE, 241 - .llseek = no_llseek, 242 - .write = mv64x60_wdt_write, 243 - .unlocked_ioctl = mv64x60_wdt_ioctl, 244 - .compat_ioctl = compat_ptr_ioctl, 245 - .open = mv64x60_wdt_open, 246 - .release = mv64x60_wdt_release, 247 - }; 248 - 249 - static struct miscdevice mv64x60_wdt_miscdev = { 250 - .minor = WATCHDOG_MINOR, 251 - .name = "watchdog", 252 - .fops = &mv64x60_wdt_fops, 253 - }; 254 - 255 - static int mv64x60_wdt_probe(struct platform_device *dev) 256 - { 257 - struct mv64x60_wdt_pdata *pdata = dev_get_platdata(&dev->dev); 258 - struct resource *r; 259 - int timeout = 10; 260 - 261 - bus_clk = 133; /* in MHz */ 262 - if (pdata) { 263 - timeout = pdata->timeout; 264 - bus_clk = pdata->bus_clk; 265 - } 266 - 267 - /* Since bus_clk is truncated MHz, actual frequency could be 268 - * up to 1MHz higher. Round up, since it's better to time out 269 - * too late than too soon. 270 - */ 271 - bus_clk++; 272 - bus_clk *= 1000000; /* convert to Hz */ 273 - 274 - r = platform_get_resource(dev, IORESOURCE_MEM, 0); 275 - if (!r) 276 - return -ENODEV; 277 - 278 - mv64x60_wdt_regs = devm_ioremap(&dev->dev, r->start, resource_size(r)); 279 - if (mv64x60_wdt_regs == NULL) 280 - return -ENOMEM; 281 - 282 - mv64x60_wdt_set_timeout(timeout); 283 - 284 - mv64x60_wdt_handler_disable(); /* in case timer was already running */ 285 - 286 - return misc_register(&mv64x60_wdt_miscdev); 287 - } 288 - 289 - static int mv64x60_wdt_remove(struct platform_device *dev) 290 - { 291 - misc_deregister(&mv64x60_wdt_miscdev); 292 - 293 - mv64x60_wdt_handler_disable(); 294 - 295 - return 0; 296 - } 297 - 298 - static struct platform_driver mv64x60_wdt_driver = { 299 - .probe = mv64x60_wdt_probe, 300 - .remove = mv64x60_wdt_remove, 301 - .driver = { 302 - .name = MV64x60_WDT_NAME, 303 - }, 304 - }; 305 - 306 - static int __init mv64x60_wdt_init(void) 307 - { 308 - pr_info("MV64x60 watchdog driver\n"); 309 - 310 - return platform_driver_register(&mv64x60_wdt_driver); 311 - } 312 - 313 - static void __exit mv64x60_wdt_exit(void) 314 - { 315 - platform_driver_unregister(&mv64x60_wdt_driver); 316 - } 317 - 318 - module_init(mv64x60_wdt_init); 319 - module_exit(mv64x60_wdt_exit); 320 - 321 - MODULE_AUTHOR("James Chapman <jchapman@katalix.com>"); 322 - MODULE_DESCRIPTION("MV64x60 watchdog driver"); 323 - MODULE_LICENSE("GPL"); 324 - MODULE_ALIAS("platform:" MV64x60_WDT_NAME);
+7 -5
drivers/watchdog/octeon-wdt-main.c
··· 120 120 } 121 121 122 122 /** 123 - * Poke the watchdog when an interrupt is received 123 + * octeon_wdt_poke_irq - Poke the watchdog when an interrupt is received 124 124 * 125 125 * @cpl: 126 126 * @dev_id: ··· 154 154 extern int prom_putchar(char c); 155 155 156 156 /** 157 - * Write a string to the uart 157 + * octeon_wdt_write_string - Write a string to the uart 158 158 * 159 159 * @str: String to write 160 160 */ ··· 166 166 } 167 167 168 168 /** 169 - * Write a hex number out of the uart 169 + * octeon_wdt_write_hex() - Write a hex number out of the uart 170 170 * 171 171 * @value: Number to display 172 172 * @digits: Number of digits to print (1 to 16) ··· 193 193 }; 194 194 195 195 /** 196 + * octeon_wdt_nmi_stage3: 197 + * 196 198 * NMI stage 3 handler. NMIs are handled in the following manner: 197 199 * 1) The first NMI handler enables CVMSEG and transfers from 198 200 * the bootbus region into normal memory. It is careful to not ··· 516 514 517 515 static enum cpuhp_state octeon_wdt_online; 518 516 /** 519 - * Module/ driver initialization. 517 + * octeon_wdt_init - Module/ driver initialization. 520 518 * 521 519 * Returns Zero on success 522 520 */ ··· 588 586 } 589 587 590 588 /** 591 - * Module / driver shutdown 589 + * octeon_wdt_cleanup - Module / driver shutdown 592 590 */ 593 591 static void __exit octeon_wdt_cleanup(void) 594 592 {
+20 -18
drivers/watchdog/of_xilinx_wdt.c
··· 6 6 * (C) Copyright 2011 (Alejandro Cabrera <aldaya@gmail.com>) 7 7 */ 8 8 9 + #include <linux/bits.h> 9 10 #include <linux/clk.h> 10 11 #include <linux/err.h> 11 12 #include <linux/module.h> ··· 25 24 #define XWT_TBR_OFFSET 0x8 /* Timebase Register Offset */ 26 25 27 26 /* Control/Status Register Masks */ 28 - #define XWT_CSR0_WRS_MASK 0x00000008 /* Reset status */ 29 - #define XWT_CSR0_WDS_MASK 0x00000004 /* Timer state */ 30 - #define XWT_CSR0_EWDT1_MASK 0x00000002 /* Enable bit 1 */ 27 + #define XWT_CSR0_WRS_MASK BIT(3) /* Reset status */ 28 + #define XWT_CSR0_WDS_MASK BIT(2) /* Timer state */ 29 + #define XWT_CSR0_EWDT1_MASK BIT(1) /* Enable bit 1 */ 31 30 32 31 /* Control/Status Register 0/1 bits */ 33 - #define XWT_CSRX_EWDT2_MASK 0x00000001 /* Enable bit 2 */ 32 + #define XWT_CSRX_EWDT2_MASK BIT(0) /* Enable bit 2 */ 34 33 35 34 /* SelfTest constants */ 36 35 #define XWT_MAX_SELFTEST_LOOP_COUNT 0x00010000 ··· 41 40 struct xwdt_device { 42 41 void __iomem *base; 43 42 u32 wdt_interval; 44 - spinlock_t spinlock; 43 + spinlock_t spinlock; /* spinlock for register handling */ 45 44 struct watchdog_device xilinx_wdt_wdd; 46 45 struct clk *clk; 47 46 }; ··· 71 70 72 71 spin_unlock(&xdev->spinlock); 73 72 73 + dev_dbg(wdd->parent, "Watchdog Started!\n"); 74 + 74 75 return 0; 75 76 } 76 77 ··· 94 91 95 92 clk_disable(xdev->clk); 96 93 97 - pr_info("Stopped!\n"); 94 + dev_dbg(wdd->parent, "Watchdog Stopped!\n"); 98 95 99 96 return 0; 100 97 } ··· 211 208 "The watchdog clock freq cannot be obtained\n"); 212 209 } else { 213 210 pfreq = clk_get_rate(xdev->clk); 211 + rc = clk_prepare_enable(xdev->clk); 212 + if (rc) { 213 + dev_err(dev, "unable to enable clock\n"); 214 + return rc; 215 + } 216 + rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare, 217 + xdev->clk); 218 + if (rc) 219 + return rc; 214 220 } 215 221 216 222 /* ··· 233 221 spin_lock_init(&xdev->spinlock); 234 222 watchdog_set_drvdata(xilinx_wdt_wdd, xdev); 235 223 236 - rc = clk_prepare_enable(xdev->clk); 237 - if (rc) { 238 - dev_err(dev, "unable to enable clock\n"); 239 - return rc; 240 - } 241 - rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare, 242 - xdev->clk); 243 - if (rc) 244 - return rc; 245 - 246 224 rc = xwdt_selftest(xdev); 247 225 if (rc == XWT_TIMER_FAILED) { 248 226 dev_err(dev, "SelfTest routine error\n"); ··· 245 243 246 244 clk_disable(xdev->clk); 247 245 248 - dev_info(dev, "Xilinx Watchdog Timer at %p with timeout %ds\n", 249 - xdev->base, xilinx_wdt_wdd->timeout); 246 + dev_info(dev, "Xilinx Watchdog Timer with timeout %ds\n", 247 + xilinx_wdt_wdd->timeout); 250 248 251 249 platform_set_drvdata(pdev, xdev); 252 250
+1 -1
drivers/watchdog/orion_wdt.c
··· 174 174 return ret; 175 175 } 176 176 177 - /* Fix the wdt and timer1 clock freqency to 25MHz */ 177 + /* Fix the wdt and timer1 clock frequency to 25MHz */ 178 178 val = WDT_AXP_FIXED_ENABLE_BIT | TIMER1_FIXED_ENABLE_BIT; 179 179 atomic_io_modify(dev->reg + TIMER_CTRL, val, val); 180 180
+1 -1
drivers/watchdog/pc87413_wdt.c
··· 445 445 /* -- Notifier funtions -----------------------------------------*/ 446 446 447 447 /** 448 - * notify_sys: 448 + * pc87413_notify_sys: 449 449 * @this: our notifier block 450 450 * @code: the event being reported 451 451 * @unused: unused
+3 -1
drivers/watchdog/qcom-wdt.c
··· 329 329 return 0; 330 330 } 331 331 332 - static SIMPLE_DEV_PM_OPS(qcom_wdt_pm_ops, qcom_wdt_suspend, qcom_wdt_resume); 332 + static const struct dev_pm_ops qcom_wdt_pm_ops = { 333 + SET_LATE_SYSTEM_SLEEP_PM_OPS(qcom_wdt_suspend, qcom_wdt_resume) 334 + }; 333 335 334 336 static const struct of_device_id qcom_wdt_of_table[] = { 335 337 { .compatible = "qcom,kpss-timer", .data = &match_data_apcs_tmr },
+8 -2
drivers/watchdog/sama5d4_wdt.c
··· 268 268 wdd->min_timeout = MIN_WDT_TIMEOUT; 269 269 wdd->max_timeout = MAX_WDT_TIMEOUT; 270 270 wdt->last_ping = jiffies; 271 - wdt->sam9x60_support = of_device_is_compatible(dev->of_node, 272 - "microchip,sam9x60-wdt"); 271 + 272 + if (of_device_is_compatible(dev->of_node, "microchip,sam9x60-wdt") || 273 + of_device_is_compatible(dev->of_node, "microchip,sama7g5-wdt")) 274 + wdt->sam9x60_support = true; 273 275 274 276 watchdog_set_drvdata(wdd, wdt); 275 277 ··· 331 329 { 332 330 .compatible = "microchip,sam9x60-wdt", 333 331 }, 332 + { 333 + .compatible = "microchip,sama7g5-wdt", 334 + }, 335 + 334 336 { } 335 337 }; 336 338 MODULE_DEVICE_TABLE(of, sama5d4_wdt_of_match);
+1 -1
drivers/watchdog/sbc60xxwdt.c
··· 146 146 static void wdt_turnoff(void) 147 147 { 148 148 /* Stop the timer */ 149 - del_timer(&timer); 149 + del_timer_sync(&timer); 150 150 inb_p(wdt_stop); 151 151 pr_info("Watchdog timer is now disabled...\n"); 152 152 }
+48 -6
drivers/watchdog/sbsa_gwdt.c
··· 73 73 #define SBSA_GWDT_WCS_WS0 BIT(1) 74 74 #define SBSA_GWDT_WCS_WS1 BIT(2) 75 75 76 + #define SBSA_GWDT_VERSION_MASK 0xF 77 + #define SBSA_GWDT_VERSION_SHIFT 16 78 + 76 79 /** 77 80 * struct sbsa_gwdt - Internal representation of the SBSA GWDT 78 81 * @wdd: kernel watchdog_device structure 79 82 * @clk: store the System Counter clock frequency, in Hz. 83 + * @version: store the architecture version 80 84 * @refresh_base: Virtual address of the watchdog refresh frame 81 85 * @control_base: Virtual address of the watchdog control frame 82 86 */ 83 87 struct sbsa_gwdt { 84 88 struct watchdog_device wdd; 85 89 u32 clk; 90 + int version; 86 91 void __iomem *refresh_base; 87 92 void __iomem *control_base; 88 93 }; ··· 118 113 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 119 114 120 115 /* 116 + * Arm Base System Architecture 1.0 introduces watchdog v1 which 117 + * increases the length watchdog offset register to 48 bits. 118 + * - For version 0: WOR is 32 bits; 119 + * - For version 1: WOR is 48 bits which comprises the register 120 + * offset 0x8 and 0xC, and the bits [63:48] are reserved which are 121 + * Read-As-Zero and Writes-Ignored. 122 + */ 123 + static u64 sbsa_gwdt_reg_read(struct sbsa_gwdt *gwdt) 124 + { 125 + if (gwdt->version == 0) 126 + return readl(gwdt->control_base + SBSA_GWDT_WOR); 127 + else 128 + return readq(gwdt->control_base + SBSA_GWDT_WOR); 129 + } 130 + 131 + static void sbsa_gwdt_reg_write(u64 val, struct sbsa_gwdt *gwdt) 132 + { 133 + if (gwdt->version == 0) 134 + writel((u32)val, gwdt->control_base + SBSA_GWDT_WOR); 135 + else 136 + writeq(val, gwdt->control_base + SBSA_GWDT_WOR); 137 + } 138 + 139 + /* 121 140 * watchdog operation functions 122 141 */ 123 142 static int sbsa_gwdt_set_timeout(struct watchdog_device *wdd, ··· 152 123 wdd->timeout = timeout; 153 124 154 125 if (action) 155 - writel(gwdt->clk * timeout, 156 - gwdt->control_base + SBSA_GWDT_WOR); 126 + sbsa_gwdt_reg_write(gwdt->clk * timeout, gwdt); 157 127 else 158 128 /* 159 129 * In the single stage mode, The first signal (WS0) is ignored, 160 130 * the timeout is (WOR * 2), so the WOR should be configured 161 131 * to half value of timeout. 162 132 */ 163 - writel(gwdt->clk / 2 * timeout, 164 - gwdt->control_base + SBSA_GWDT_WOR); 133 + sbsa_gwdt_reg_write(gwdt->clk / 2 * timeout, gwdt); 165 134 166 135 return 0; 167 136 } ··· 176 149 */ 177 150 if (!action && 178 151 !(readl(gwdt->control_base + SBSA_GWDT_WCS) & SBSA_GWDT_WCS_WS0)) 179 - timeleft += readl(gwdt->control_base + SBSA_GWDT_WOR); 152 + timeleft += sbsa_gwdt_reg_read(gwdt); 180 153 181 154 timeleft += lo_hi_readq(gwdt->control_base + SBSA_GWDT_WCV) - 182 155 arch_timer_read_counter(); ··· 197 170 writel(0, gwdt->refresh_base + SBSA_GWDT_WRR); 198 171 199 172 return 0; 173 + } 174 + 175 + static void sbsa_gwdt_get_version(struct watchdog_device *wdd) 176 + { 177 + struct sbsa_gwdt *gwdt = watchdog_get_drvdata(wdd); 178 + int ver; 179 + 180 + ver = readl(gwdt->control_base + SBSA_GWDT_W_IIDR); 181 + ver = (ver >> SBSA_GWDT_VERSION_SHIFT) & SBSA_GWDT_VERSION_MASK; 182 + 183 + gwdt->version = ver; 200 184 } 201 185 202 186 static int sbsa_gwdt_start(struct watchdog_device *wdd) ··· 290 252 wdd->info = &sbsa_gwdt_info; 291 253 wdd->ops = &sbsa_gwdt_ops; 292 254 wdd->min_timeout = 1; 293 - wdd->max_hw_heartbeat_ms = U32_MAX / gwdt->clk * 1000; 294 255 wdd->timeout = DEFAULT_TIMEOUT; 295 256 watchdog_set_drvdata(wdd, gwdt); 296 257 watchdog_set_nowayout(wdd, nowayout); 258 + sbsa_gwdt_get_version(wdd); 259 + if (gwdt->version == 0) 260 + wdd->max_hw_heartbeat_ms = U32_MAX / gwdt->clk * 1000; 261 + else 262 + wdd->max_hw_heartbeat_ms = GENMASK_ULL(47, 0) / gwdt->clk * 1000; 297 263 298 264 status = readl(cf_base + SBSA_GWDT_WCS); 299 265 if (status & SBSA_GWDT_WCS_WS1) {
+1 -1
drivers/watchdog/sc520_wdt.c
··· 186 186 static int wdt_turnoff(void) 187 187 { 188 188 /* Stop the timer */ 189 - del_timer(&timer); 189 + del_timer_sync(&timer); 190 190 191 191 /* Stop the watchdog */ 192 192 wdt_config(0);
+1 -1
drivers/watchdog/sl28cpld_wdt.c
··· 164 164 165 165 /* 166 166 * Initial timeout value, may be overwritten by device tree or module 167 - * parmeter in watchdog_init_timeout(). 167 + * parameter in watchdog_init_timeout(). 168 168 * 169 169 * Reading a zero here means that either the hardware has a default 170 170 * value of zero (which is very unlikely and definitely a hardware
+21 -22
drivers/watchdog/sp805_wdt.c
··· 11 11 * warranty of any kind, whether express or implied. 12 12 */ 13 13 14 - #include <linux/acpi.h> 15 14 #include <linux/device.h> 16 15 #include <linux/resource.h> 17 16 #include <linux/amba/bus.h> ··· 22 23 #include <linux/math64.h> 23 24 #include <linux/module.h> 24 25 #include <linux/moduleparam.h> 25 - #include <linux/of.h> 26 26 #include <linux/pm.h> 27 + #include <linux/property.h> 27 28 #include <linux/slab.h> 28 29 #include <linux/spinlock.h> 29 30 #include <linux/types.h> ··· 57 58 * @wdd: instance of struct watchdog_device 58 59 * @lock: spin lock protecting dev structure and io access 59 60 * @base: base address of wdt 60 - * @clk: clock structure of wdt 61 + * @clk: (optional) clock structure of wdt 62 + * @rate: (optional) clock rate when provided via properties 61 63 * @adev: amba device structure of wdt 62 64 * @status: current status of wdt 63 65 * @load_val: load value to be set for current timeout ··· 231 231 sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) 232 232 { 233 233 struct sp805_wdt *wdt; 234 + u64 rate = 0; 234 235 int ret = 0; 235 236 236 237 wdt = devm_kzalloc(&adev->dev, sizeof(*wdt), GFP_KERNEL); ··· 244 243 if (IS_ERR(wdt->base)) 245 244 return PTR_ERR(wdt->base); 246 245 247 - if (adev->dev.of_node) { 248 - wdt->clk = devm_clk_get(&adev->dev, NULL); 249 - if (IS_ERR(wdt->clk)) { 250 - dev_err(&adev->dev, "Clock not found\n"); 251 - return PTR_ERR(wdt->clk); 252 - } 253 - wdt->rate = clk_get_rate(wdt->clk); 254 - } else if (has_acpi_companion(&adev->dev)) { 255 - /* 256 - * When Driver probe with ACPI device, clock devices 257 - * are not available, so watchdog rate get from 258 - * clock-frequency property given in _DSD object. 259 - */ 260 - device_property_read_u64(&adev->dev, "clock-frequency", 261 - &wdt->rate); 262 - if (!wdt->rate) { 263 - dev_err(&adev->dev, "no clock-frequency property\n"); 264 - return -ENODEV; 265 - } 246 + /* 247 + * When driver probe with ACPI device, clock devices 248 + * are not available, so watchdog rate get from 249 + * clock-frequency property given in _DSD object. 250 + */ 251 + device_property_read_u64(&adev->dev, "clock-frequency", &rate); 252 + 253 + wdt->clk = devm_clk_get_optional(&adev->dev, NULL); 254 + if (IS_ERR(wdt->clk)) 255 + return dev_err_probe(&adev->dev, PTR_ERR(wdt->clk), "Clock not found\n"); 256 + 257 + wdt->rate = clk_get_rate(wdt->clk); 258 + if (!wdt->rate) 259 + wdt->rate = rate; 260 + if (!wdt->rate) { 261 + dev_err(&adev->dev, "no clock-frequency property\n"); 262 + return -ENODEV; 266 263 } 267 264 268 265 wdt->adev = adev;
+1 -1
drivers/watchdog/w83877f_wdt.c
··· 166 166 static void wdt_turnoff(void) 167 167 { 168 168 /* Stop the timer */ 169 - del_timer(&timer); 169 + del_timer_sync(&timer); 170 170 171 171 wdt_change(WDT_DISABLE); 172 172
+48
drivers/watchdog/watchdog_core.h
··· 7 7 * 8 8 * (c) Copyright 2008-2011 Wim Van Sebroeck <wim@iguana.be>. 9 9 * 10 + * (c) Copyright 2021 Hewlett Packard Enterprise Development LP. 11 + * 10 12 * This source code is part of the generic code that can be used 11 13 * by all the watchdog timer drivers. 12 14 * ··· 24 22 * This material is provided "AS-IS" and at no charge. 25 23 */ 26 24 25 + #include <linux/hrtimer.h> 26 + #include <linux/kthread.h> 27 + 27 28 #define MAX_DOGS 32 /* Maximum number of watchdog devices */ 29 + 30 + /* 31 + * struct watchdog_core_data - watchdog core internal data 32 + * @dev: The watchdog's internal device 33 + * @cdev: The watchdog's Character device. 34 + * @wdd: Pointer to watchdog device. 35 + * @lock: Lock for watchdog core. 36 + * @status: Watchdog core internal status bits. 37 + */ 38 + struct watchdog_core_data { 39 + struct device dev; 40 + struct cdev cdev; 41 + struct watchdog_device *wdd; 42 + struct mutex lock; 43 + ktime_t last_keepalive; 44 + ktime_t last_hw_keepalive; 45 + ktime_t open_deadline; 46 + struct hrtimer timer; 47 + struct kthread_work work; 48 + #if IS_ENABLED(CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT) 49 + struct hrtimer pretimeout_timer; 50 + #endif 51 + unsigned long status; /* Internal status bits */ 52 + #define _WDOG_DEV_OPEN 0 /* Opened ? */ 53 + #define _WDOG_ALLOW_RELEASE 1 /* Did we receive the magic char ? */ 54 + #define _WDOG_KEEPALIVE 2 /* Did we receive a keepalive ? */ 55 + }; 28 56 29 57 /* 30 58 * Functions/procedures to be called by the core ··· 63 31 extern void watchdog_dev_unregister(struct watchdog_device *); 64 32 extern int __init watchdog_dev_init(void); 65 33 extern void __exit watchdog_dev_exit(void); 34 + 35 + static inline bool watchdog_have_pretimeout(struct watchdog_device *wdd) 36 + { 37 + return wdd->info->options & WDIOF_PRETIMEOUT || 38 + IS_ENABLED(CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT); 39 + } 40 + 41 + #if IS_ENABLED(CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT) 42 + void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd); 43 + void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd); 44 + void watchdog_hrtimer_pretimeout_stop(struct watchdog_device *wdd); 45 + #else 46 + static inline void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd) {} 47 + static inline void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd) {} 48 + static inline void watchdog_hrtimer_pretimeout_stop(struct watchdog_device *wdd) {} 49 + #endif
+47 -39
drivers/watchdog/watchdog_dev.c
··· 7 7 * 8 8 * (c) Copyright 2008-2011 Wim Van Sebroeck <wim@iguana.be>. 9 9 * 10 + * (c) Copyright 2021 Hewlett Packard Enterprise Development LP. 10 11 * 11 12 * This source code is part of the generic code that can be used 12 13 * by all the watchdog timer drivers. ··· 46 45 47 46 #include "watchdog_core.h" 48 47 #include "watchdog_pretimeout.h" 49 - 50 - /* 51 - * struct watchdog_core_data - watchdog core internal data 52 - * @dev: The watchdog's internal device 53 - * @cdev: The watchdog's Character device. 54 - * @wdd: Pointer to watchdog device. 55 - * @lock: Lock for watchdog core. 56 - * @status: Watchdog core internal status bits. 57 - */ 58 - struct watchdog_core_data { 59 - struct device dev; 60 - struct cdev cdev; 61 - struct watchdog_device *wdd; 62 - struct mutex lock; 63 - ktime_t last_keepalive; 64 - ktime_t last_hw_keepalive; 65 - ktime_t open_deadline; 66 - struct hrtimer timer; 67 - struct kthread_work work; 68 - unsigned long status; /* Internal status bits */ 69 - #define _WDOG_DEV_OPEN 0 /* Opened ? */ 70 - #define _WDOG_ALLOW_RELEASE 1 /* Did we receive the magic char ? */ 71 - #define _WDOG_KEEPALIVE 2 /* Did we receive a keepalive ? */ 72 - }; 73 48 74 49 /* the dev_t structure to store the dynamically allocated watchdog devices */ 75 50 static dev_t watchdog_devt; ··· 162 185 else 163 186 err = wdd->ops->start(wdd); /* restart watchdog */ 164 187 188 + if (err == 0) 189 + watchdog_hrtimer_pretimeout_start(wdd); 190 + 165 191 watchdog_update_worker(wdd); 166 192 167 193 return err; ··· 255 275 started_at = ktime_get(); 256 276 if (watchdog_hw_running(wdd) && wdd->ops->ping) { 257 277 err = __watchdog_ping(wdd); 258 - if (err == 0) 278 + if (err == 0) { 259 279 set_bit(WDOG_ACTIVE, &wdd->status); 280 + watchdog_hrtimer_pretimeout_start(wdd); 281 + } 260 282 } else { 261 283 err = wdd->ops->start(wdd); 262 284 if (err == 0) { ··· 266 284 wd_data->last_keepalive = started_at; 267 285 wd_data->last_hw_keepalive = started_at; 268 286 watchdog_update_worker(wdd); 287 + watchdog_hrtimer_pretimeout_start(wdd); 269 288 } 270 289 } 271 290 ··· 308 325 if (err == 0) { 309 326 clear_bit(WDOG_ACTIVE, &wdd->status); 310 327 watchdog_update_worker(wdd); 328 + watchdog_hrtimer_pretimeout_stop(wdd); 311 329 } 312 330 313 331 return err; ··· 344 360 345 361 if (test_and_clear_bit(_WDOG_KEEPALIVE, &wd_data->status)) 346 362 status |= WDIOF_KEEPALIVEPING; 363 + 364 + if (IS_ENABLED(CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT)) 365 + status |= WDIOF_PRETIMEOUT; 347 366 348 367 return status; 349 368 } ··· 395 408 { 396 409 int err = 0; 397 410 398 - if (!(wdd->info->options & WDIOF_PRETIMEOUT)) 411 + if (!watchdog_have_pretimeout(wdd)) 399 412 return -EOPNOTSUPP; 400 413 401 414 if (watchdog_pretimeout_invalid(wdd, timeout)) ··· 438 451 { 439 452 struct watchdog_device *wdd = dev_get_drvdata(dev); 440 453 441 - return sprintf(buf, "%d\n", !!test_bit(WDOG_NO_WAY_OUT, &wdd->status)); 454 + return sysfs_emit(buf, "%d\n", !!test_bit(WDOG_NO_WAY_OUT, 455 + &wdd->status)); 442 456 } 443 457 444 458 static ssize_t nowayout_store(struct device *dev, struct device_attribute *attr, ··· 473 485 status = watchdog_get_status(wdd); 474 486 mutex_unlock(&wd_data->lock); 475 487 476 - return sprintf(buf, "0x%x\n", status); 488 + return sysfs_emit(buf, "0x%x\n", status); 477 489 } 478 490 static DEVICE_ATTR_RO(status); 479 491 ··· 482 494 { 483 495 struct watchdog_device *wdd = dev_get_drvdata(dev); 484 496 485 - return sprintf(buf, "%u\n", wdd->bootstatus); 497 + return sysfs_emit(buf, "%u\n", wdd->bootstatus); 486 498 } 487 499 static DEVICE_ATTR_RO(bootstatus); 488 500 ··· 498 510 status = watchdog_get_timeleft(wdd, &val); 499 511 mutex_unlock(&wd_data->lock); 500 512 if (!status) 501 - status = sprintf(buf, "%u\n", val); 513 + status = sysfs_emit(buf, "%u\n", val); 502 514 503 515 return status; 504 516 } ··· 509 521 { 510 522 struct watchdog_device *wdd = dev_get_drvdata(dev); 511 523 512 - return sprintf(buf, "%u\n", wdd->timeout); 524 + return sysfs_emit(buf, "%u\n", wdd->timeout); 513 525 } 514 526 static DEVICE_ATTR_RO(timeout); 527 + 528 + static ssize_t min_timeout_show(struct device *dev, 529 + struct device_attribute *attr, char *buf) 530 + { 531 + struct watchdog_device *wdd = dev_get_drvdata(dev); 532 + 533 + return sysfs_emit(buf, "%u\n", wdd->min_timeout); 534 + } 535 + static DEVICE_ATTR_RO(min_timeout); 536 + 537 + static ssize_t max_timeout_show(struct device *dev, 538 + struct device_attribute *attr, char *buf) 539 + { 540 + struct watchdog_device *wdd = dev_get_drvdata(dev); 541 + 542 + return sysfs_emit(buf, "%u\n", wdd->max_timeout); 543 + } 544 + static DEVICE_ATTR_RO(max_timeout); 515 545 516 546 static ssize_t pretimeout_show(struct device *dev, 517 547 struct device_attribute *attr, char *buf) 518 548 { 519 549 struct watchdog_device *wdd = dev_get_drvdata(dev); 520 550 521 - return sprintf(buf, "%u\n", wdd->pretimeout); 551 + return sysfs_emit(buf, "%u\n", wdd->pretimeout); 522 552 } 523 553 static DEVICE_ATTR_RO(pretimeout); 524 554 ··· 545 539 { 546 540 struct watchdog_device *wdd = dev_get_drvdata(dev); 547 541 548 - return sprintf(buf, "%s\n", wdd->info->identity); 542 + return sysfs_emit(buf, "%s\n", wdd->info->identity); 549 543 } 550 544 static DEVICE_ATTR_RO(identity); 551 545 ··· 555 549 struct watchdog_device *wdd = dev_get_drvdata(dev); 556 550 557 551 if (watchdog_active(wdd)) 558 - return sprintf(buf, "active\n"); 552 + return sysfs_emit(buf, "active\n"); 559 553 560 - return sprintf(buf, "inactive\n"); 554 + return sysfs_emit(buf, "inactive\n"); 561 555 } 562 556 static DEVICE_ATTR_RO(state); 563 557 ··· 600 594 601 595 if (attr == &dev_attr_timeleft.attr && !wdd->ops->get_timeleft) 602 596 mode = 0; 603 - else if (attr == &dev_attr_pretimeout.attr && 604 - !(wdd->info->options & WDIOF_PRETIMEOUT)) 597 + else if (attr == &dev_attr_pretimeout.attr && !watchdog_have_pretimeout(wdd)) 605 598 mode = 0; 606 599 else if ((attr == &dev_attr_pretimeout_governor.attr || 607 600 attr == &dev_attr_pretimeout_available_governors.attr) && 608 - (!(wdd->info->options & WDIOF_PRETIMEOUT) || 609 - !IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_GOV))) 601 + (!watchdog_have_pretimeout(wdd) || !IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_GOV))) 610 602 mode = 0; 611 603 612 604 return mode; ··· 613 609 &dev_attr_state.attr, 614 610 &dev_attr_identity.attr, 615 611 &dev_attr_timeout.attr, 612 + &dev_attr_min_timeout.attr, 613 + &dev_attr_max_timeout.attr, 616 614 &dev_attr_pretimeout.attr, 617 615 &dev_attr_timeleft.attr, 618 616 &dev_attr_bootstatus.attr, ··· 1015 1009 kthread_init_work(&wd_data->work, watchdog_ping_work); 1016 1010 hrtimer_init(&wd_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); 1017 1011 wd_data->timer.function = watchdog_timer_expired; 1012 + watchdog_hrtimer_pretimeout_init(wdd); 1018 1013 1019 1014 if (wdd->id == 0) { 1020 1015 old_wd_data = wd_data; ··· 1103 1096 1104 1097 hrtimer_cancel(&wd_data->timer); 1105 1098 kthread_cancel_work_sync(&wd_data->work); 1099 + watchdog_hrtimer_pretimeout_stop(wdd); 1106 1100 1107 1101 put_device(&wd_data->dev); 1108 1102 }
+44
drivers/watchdog/watchdog_hrtimer_pretimeout.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * (c) Copyright 2021 Hewlett Packard Enterprise Development LP. 4 + */ 5 + 6 + #include <linux/hrtimer.h> 7 + #include <linux/watchdog.h> 8 + 9 + #include "watchdog_core.h" 10 + #include "watchdog_pretimeout.h" 11 + 12 + static enum hrtimer_restart watchdog_hrtimer_pretimeout(struct hrtimer *timer) 13 + { 14 + struct watchdog_core_data *wd_data; 15 + 16 + wd_data = container_of(timer, struct watchdog_core_data, pretimeout_timer); 17 + 18 + watchdog_notify_pretimeout(wd_data->wdd); 19 + return HRTIMER_NORESTART; 20 + } 21 + 22 + void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd) 23 + { 24 + struct watchdog_core_data *wd_data = wdd->wd_data; 25 + 26 + hrtimer_init(&wd_data->pretimeout_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 27 + wd_data->pretimeout_timer.function = watchdog_hrtimer_pretimeout; 28 + } 29 + 30 + void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd) 31 + { 32 + if (!(wdd->info->options & WDIOF_PRETIMEOUT) && 33 + !watchdog_pretimeout_invalid(wdd, wdd->pretimeout)) 34 + hrtimer_start(&wdd->wd_data->pretimeout_timer, 35 + ktime_set(wdd->timeout - wdd->pretimeout, 0), 36 + HRTIMER_MODE_REL); 37 + else 38 + hrtimer_cancel(&wdd->wd_data->pretimeout_timer); 39 + } 40 + 41 + void watchdog_hrtimer_pretimeout_stop(struct watchdog_device *wdd) 42 + { 43 + hrtimer_cancel(&wdd->wd_data->pretimeout_timer); 44 + }
+5 -4
drivers/watchdog/watchdog_pretimeout.c
··· 9 9 #include <linux/string.h> 10 10 #include <linux/watchdog.h> 11 11 12 + #include "watchdog_core.h" 12 13 #include "watchdog_pretimeout.h" 13 14 14 15 /* Default watchdog pretimeout governor */ ··· 56 55 mutex_lock(&governor_lock); 57 56 58 57 list_for_each_entry(priv, &governor_list, entry) 59 - count += sprintf(buf + count, "%s\n", priv->gov->name); 58 + count += sysfs_emit_at(buf, count, "%s\n", priv->gov->name); 60 59 61 60 mutex_unlock(&governor_lock); 62 61 ··· 69 68 70 69 spin_lock_irq(&pretimeout_lock); 71 70 if (wdd->gov) 72 - count = sprintf(buf, "%s\n", wdd->gov->name); 71 + count = sysfs_emit(buf, "%s\n", wdd->gov->name); 73 72 spin_unlock_irq(&pretimeout_lock); 74 73 75 74 return count; ··· 178 177 { 179 178 struct watchdog_pretimeout *p; 180 179 181 - if (!(wdd->info->options & WDIOF_PRETIMEOUT)) 180 + if (!watchdog_have_pretimeout(wdd)) 182 181 return 0; 183 182 184 183 p = kzalloc(sizeof(*p), GFP_KERNEL); ··· 198 197 { 199 198 struct watchdog_pretimeout *p, *t; 200 199 201 - if (!(wdd->info->options & WDIOF_PRETIMEOUT)) 200 + if (!watchdog_have_pretimeout(wdd)) 202 201 return; 203 202 204 203 spin_lock_irq(&pretimeout_lock);
+2 -2
drivers/watchdog/wdat_wdt.c
··· 208 208 /* 209 209 * WDAT specification says that the watchdog is required to reboot 210 210 * the system when it fires. However, it also states that it is 211 - * recommeded to make it configurable through hardware register. We 211 + * recommended to make it configurable through hardware register. We 212 212 * enable reboot now if it is configurable, just in case. 213 213 */ 214 214 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_SET_REBOOT, 0, NULL); ··· 475 475 return 0; 476 476 477 477 /* 478 - * We need to stop the watchdog if firmare is not doing it or if we 478 + * We need to stop the watchdog if firmware is not doing it or if we 479 479 * are going suspend to idle (where firmware is not involved). If 480 480 * firmware is stopping the watchdog we kick it here one more time 481 481 * to give it some time.
+2 -2
drivers/watchdog/wdt.c
··· 494 494 } 495 495 496 496 /** 497 - * notify_sys: 497 + * wdt_notify_sys: 498 498 * @this: our notifier block 499 499 * @code: the event being reported 500 500 * @unused: unused ··· 558 558 }; 559 559 560 560 /** 561 - * cleanup_module: 561 + * wdt_exit: 562 562 * 563 563 * Unload the watchdog. You cannot do this with any file handles open. 564 564 * If your watchdog is set to continue ticking on close and you unload
+1 -1
drivers/watchdog/wdt_pci.c
··· 537 537 } 538 538 539 539 /** 540 - * notify_sys: 540 + * wdtpci_notify_sys: 541 541 * @this: our notifier block 542 542 * @code: the event being reported 543 543 * @unused: unused
+10 -11
drivers/watchdog/ziirave_wdt.c
··· 69 69 #define ZIIRAVE_CMD_JUMP_TO_BOOTLOADER_MAGIC 1 70 70 #define ZIIRAVE_CMD_RESET_PROCESSOR_MAGIC 1 71 71 72 - #define ZIIRAVE_FW_VERSION_FMT "02.%02u.%02u" 73 - #define ZIIRAVE_BL_VERSION_FMT "01.%02u.%02u" 74 - 75 72 struct ziirave_wdt_rev { 76 73 unsigned char major; 77 74 unsigned char minor; ··· 442 445 if (ret) 443 446 return ret; 444 447 445 - ret = sprintf(buf, ZIIRAVE_FW_VERSION_FMT, w_priv->firmware_rev.major, 446 - w_priv->firmware_rev.minor); 448 + ret = sysfs_emit(buf, "02.%02u.%02u\n", 449 + w_priv->firmware_rev.major, 450 + w_priv->firmware_rev.minor); 447 451 448 452 mutex_unlock(&w_priv->sysfs_mutex); 449 453 ··· 466 468 if (ret) 467 469 return ret; 468 470 469 - ret = sprintf(buf, ZIIRAVE_BL_VERSION_FMT, w_priv->bootloader_rev.major, 470 - w_priv->bootloader_rev.minor); 471 + ret = sysfs_emit(buf, "01.%02u.%02u\n", 472 + w_priv->bootloader_rev.major, 473 + w_priv->bootloader_rev.minor); 471 474 472 475 mutex_unlock(&w_priv->sysfs_mutex); 473 476 ··· 490 491 if (ret) 491 492 return ret; 492 493 493 - ret = sprintf(buf, "%s", ziirave_reasons[w_priv->reset_reason]); 494 + ret = sysfs_emit(buf, "%s\n", ziirave_reasons[w_priv->reset_reason]); 494 495 495 496 mutex_unlock(&w_priv->sysfs_mutex); 496 497 ··· 535 536 } 536 537 537 538 dev_info(&client->dev, 538 - "Firmware updated to version " ZIIRAVE_FW_VERSION_FMT "\n", 539 + "Firmware updated to version 02.%02u.%02u\n", 539 540 w_priv->firmware_rev.major, w_priv->firmware_rev.minor); 540 541 541 542 /* Restore the watchdog timeout */ ··· 676 677 } 677 678 678 679 dev_info(&client->dev, 679 - "Firmware version: " ZIIRAVE_FW_VERSION_FMT "\n", 680 + "Firmware version: 02.%02u.%02u\n", 680 681 w_priv->firmware_rev.major, w_priv->firmware_rev.minor); 681 682 682 683 ret = ziirave_wdt_revision(client, &w_priv->bootloader_rev, ··· 687 688 } 688 689 689 690 dev_info(&client->dev, 690 - "Bootloader version: " ZIIRAVE_BL_VERSION_FMT "\n", 691 + "Bootloader version: 01.%02u.%02u\n", 691 692 w_priv->bootloader_rev.major, w_priv->bootloader_rev.minor); 692 693 693 694 w_priv->reset_reason = i2c_smbus_read_byte_data(client,
-8
include/linux/mv643xx.h
··· 918 918 919 919 extern void mv64340_irq_init(unsigned int base); 920 920 921 - /* Watchdog Platform Device, Driver Data */ 922 - #define MV64x60_WDT_NAME "mv64x60_wdt" 923 - 924 - struct mv64x60_wdt_pdata { 925 - int timeout; /* watchdog expiry in seconds, default 10 */ 926 - int bus_clk; /* bus clock in MHz, default 133 */ 927 - }; 928 - 929 921 #endif /* __ASM_MV643XX_H */