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

Pull watchdog updates from Wim Van Sebroeck:

- add support for the watchdog on Meson8 and Meson8m2

- add support for MediaTek MT7623 and MT7622 SoC

- add support for the r8a77995 wdt

- explicitly request exclusive reset control for asm9260_wdt,
zx2967_wdt, rt2880_wdt and mt7621_wdt

- improvements to asm9260_wdt, aspeed_wdt, renesas_wdt and cadence_wdt

- add support for reading freq via CCF + suspend/resume support for
of_xilinx_wdt

- constify watchdog_ops and various device-id structures

- revert of commit 1fccb73011ea ("iTCO_wdt: all versions count down
twice") (Bug 196509)

* git://www.linux-watchdog.org/linux-watchdog: (40 commits)
watchdog: mei_wdt: constify mei_cl_device_id
watchdog: sp805: constify amba_id
watchdog: ziirave: constify i2c_device_id
watchdog: sc1200: constify pnp_device_id
dt-bindings: watchdog: renesas-wdt: Add support for the r8a77995 wdt
watchdog: renesas_wdt: update copyright dates
watchdog: renesas_wdt: make 'clk' a variable local to probe()
watchdog: renesas_wdt: consistently use RuntimePM for clock management
watchdog: aspeed: Support configuration of external signal properties
dt-bindings: watchdog: aspeed: External reset signal properties
drivers/watchdog: Add optional ASPEED device tree properties
drivers/watchdog: ASPEED reference dev tree properties for config
watchdog: da9063_wdt: Simplify by removing unneeded struct...
watchdog: bcm7038: Check the return value from clk_prepare_enable()
watchdog: qcom: Check for platform_get_resource() failure
watchdog: of_xilinx_wdt: Add suspend/resume support
watchdog: of_xilinx_wdt: Add support for reading freq via CCF
dt-bindings: watchdog: mediatek: add support for MediaTek MT7623 and MT7622 SoC
watchdog: max77620_wdt: constify platform_device_id
watchdog: pcwd_usb: constify usb_device_id
...

+363 -124
+40
Documentation/devicetree/bindings/watchdog/aspeed-wdt.txt
··· 8 8 - reg: physical base address of the controller and length of memory mapped 9 9 region 10 10 11 + Optional properties: 12 + 13 + - aspeed,reset-type = "cpu|soc|system|none" 14 + 15 + Reset behavior - Whenever a timeout occurs the watchdog can be programmed 16 + to generate one of three different, mutually exclusive, types of resets. 17 + 18 + Type "none" can be specified to indicate that no resets are to be done. 19 + This is useful in situations where another watchdog engine on chip is 20 + to perform the reset. 21 + 22 + If 'aspeed,reset-type=' is not specfied the default is to enable system 23 + reset. 24 + 25 + Reset types: 26 + 27 + - cpu: Reset CPU on watchdog timeout 28 + 29 + - soc: Reset 'System on Chip' on watchdog timeout 30 + 31 + - system: Reset system on watchdog timeout 32 + 33 + - none: No reset is performed on timeout. Assumes another watchdog 34 + engine is responsible for this. 35 + 36 + - aspeed,alt-boot: If property is present then boot from alternate block. 37 + - aspeed,external-signal: If property is present then signal is sent to 38 + external reset counter (only WDT1 and WDT2). If not 39 + specified no external signal is sent. 40 + - aspeed,ext-pulse-duration: External signal pulse duration in microseconds 41 + 42 + Optional properties for AST2500-compatible watchdogs: 43 + - aspeed,ext-push-pull: If aspeed,external-signal is present, set the pin's 44 + drive type to push-pull. The default is open-drain. 45 + - aspeed,ext-active-high: If aspeed,external-signal is present and and the pin 46 + is configured as push-pull, then set the pulse 47 + polarity to active-high. The default is active-low. 48 + 11 49 Example: 12 50 13 51 wdt1: watchdog@1e785000 { 14 52 compatible = "aspeed,ast2400-wdt"; 15 53 reg = <0x1e785000 0x1c>; 54 + aspeed,reset-type = "system"; 55 + aspeed,external-signal; 16 56 };
+5 -1
Documentation/devicetree/bindings/watchdog/meson-wdt.txt
··· 2 2 3 3 Required properties: 4 4 5 - - compatible : should be "amlogic,meson6-wdt" or "amlogic,meson8b-wdt" 5 + - compatible : depending on the SoC this should be one of: 6 + "amlogic,meson6-wdt" on Meson6 SoCs 7 + "amlogic,meson8-wdt" and "amlogic,meson6-wdt" on Meson8 SoCs 8 + "amlogic,meson8b-wdt" on Meson8b SoCs 9 + "amlogic,meson8m2-wdt" and "amlogic,meson8b-wdt" on Meson8m2 SoCs 6 10 - reg : Specifies base physical address and size of the registers. 7 11 8 12 Example:
+2
Documentation/devicetree/bindings/watchdog/mtk-wdt.txt
··· 6 6 "mediatek,mt2701-wdt", "mediatek,mt6589-wdt": for MT2701 7 7 "mediatek,mt6589-wdt": for MT6589 8 8 "mediatek,mt6797-wdt", "mediatek,mt6589-wdt": for MT6797 9 + "mediatek,mt7622-wdt", "mediatek,mt6589-wdt": for MT7622 10 + "mediatek,mt7623-wdt", "mediatek,mt6589-wdt": for MT7623 9 11 10 12 - reg : Specifies base physical address and size of the registers. 11 13
+1
Documentation/devicetree/bindings/watchdog/renesas-wdt.txt
··· 6 6 Examples with soctypes are: 7 7 - "renesas,r8a7795-wdt" (R-Car H3) 8 8 - "renesas,r8a7796-wdt" (R-Car M3-W) 9 + - "renesas,r8a77995-wdt" (R-Car D3) 9 10 - "renesas,r7s72100-wdt" (RZ/A1) 10 11 11 12 When compatible with the generic version, nodes must list the SoC-specific
+1 -1
Documentation/watchdog/watchdog-parameters.txt
··· 117 117 ------------------------------------------------- 118 118 iTCO_wdt: 119 119 heartbeat: Watchdog heartbeat in seconds. 120 - (5<=heartbeat<=74 (TCO v1) or 1226 (TCO v2), default=30) 120 + (2<heartbeat<39 (TCO v1) or 613 (TCO v2), default=30) 121 121 nowayout: Watchdog cannot be stopped once started 122 122 (default=kernel config parameter) 123 123 -------------------------------------------------
+2 -2
drivers/watchdog/asm9260_wdt.c
··· 82 82 83 83 counter = ioread32(priv->iobase + HW_WDTV); 84 84 85 - return DIV_ROUND_CLOSEST(counter, priv->wdt_freq); 85 + return counter / priv->wdt_freq; 86 86 } 87 87 88 88 static int asm9260_wdt_updatetimeout(struct watchdog_device *wdd) ··· 296 296 if (ret) 297 297 return ret; 298 298 299 - priv->rst = devm_reset_control_get(&pdev->dev, "wdt_rst"); 299 + priv->rst = devm_reset_control_get_exclusive(&pdev->dev, "wdt_rst"); 300 300 if (IS_ERR(priv->rst)) 301 301 return PTR_ERR(priv->rst); 302 302
+125 -7
drivers/watchdog/aspeed_wdt.c
··· 23 23 u32 ctrl; 24 24 }; 25 25 26 + struct aspeed_wdt_config { 27 + u32 ext_pulse_width_mask; 28 + }; 29 + 30 + static const struct aspeed_wdt_config ast2400_config = { 31 + .ext_pulse_width_mask = 0xff, 32 + }; 33 + 34 + static const struct aspeed_wdt_config ast2500_config = { 35 + .ext_pulse_width_mask = 0xfffff, 36 + }; 37 + 26 38 static const struct of_device_id aspeed_wdt_of_table[] = { 27 - { .compatible = "aspeed,ast2400-wdt" }, 28 - { .compatible = "aspeed,ast2500-wdt" }, 39 + { .compatible = "aspeed,ast2400-wdt", .data = &ast2400_config }, 40 + { .compatible = "aspeed,ast2500-wdt", .data = &ast2500_config }, 29 41 { }, 30 42 }; 31 43 MODULE_DEVICE_TABLE(of, aspeed_wdt_of_table); ··· 48 36 #define WDT_CTRL 0x0C 49 37 #define WDT_CTRL_RESET_MODE_SOC (0x00 << 5) 50 38 #define WDT_CTRL_RESET_MODE_FULL_CHIP (0x01 << 5) 39 + #define WDT_CTRL_RESET_MODE_ARM_CPU (0x10 << 5) 51 40 #define WDT_CTRL_1MHZ_CLK BIT(4) 52 41 #define WDT_CTRL_WDT_EXT BIT(3) 53 42 #define WDT_CTRL_WDT_INTR BIT(2) 54 43 #define WDT_CTRL_RESET_SYSTEM BIT(1) 55 44 #define WDT_CTRL_ENABLE BIT(0) 45 + 46 + /* 47 + * WDT_RESET_WIDTH controls the characteristics of the external pulse (if 48 + * enabled), specifically: 49 + * 50 + * * Pulse duration 51 + * * Drive mode: push-pull vs open-drain 52 + * * Polarity: Active high or active low 53 + * 54 + * Pulse duration configuration is available on both the AST2400 and AST2500, 55 + * though the field changes between SoCs: 56 + * 57 + * AST2400: Bits 7:0 58 + * AST2500: Bits 19:0 59 + * 60 + * This difference is captured in struct aspeed_wdt_config. 61 + * 62 + * The AST2500 exposes the drive mode and polarity options, but not in a 63 + * regular fashion. For read purposes, bit 31 represents active high or low, 64 + * and bit 30 represents push-pull or open-drain. With respect to write, magic 65 + * values need to be written to the top byte to change the state of the drive 66 + * mode and polarity bits. Any other value written to the top byte has no 67 + * effect on the state of the drive mode or polarity bits. However, the pulse 68 + * width value must be preserved (as desired) if written. 69 + */ 70 + #define WDT_RESET_WIDTH 0x18 71 + #define WDT_RESET_WIDTH_ACTIVE_HIGH BIT(31) 72 + #define WDT_ACTIVE_HIGH_MAGIC (0xA5 << 24) 73 + #define WDT_ACTIVE_LOW_MAGIC (0x5A << 24) 74 + #define WDT_RESET_WIDTH_PUSH_PULL BIT(30) 75 + #define WDT_PUSH_PULL_MAGIC (0xA8 << 24) 76 + #define WDT_OPEN_DRAIN_MAGIC (0x8A << 24) 56 77 57 78 #define WDT_RESTART_MAGIC 0x4755 58 79 ··· 183 138 184 139 static int aspeed_wdt_probe(struct platform_device *pdev) 185 140 { 141 + const struct aspeed_wdt_config *config; 142 + const struct of_device_id *ofdid; 186 143 struct aspeed_wdt *wdt; 187 144 struct resource *res; 145 + struct device_node *np; 146 + const char *reset_type; 147 + u32 duration; 188 148 int ret; 189 149 190 150 wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); ··· 214 164 wdt->wdd.timeout = WDT_DEFAULT_TIMEOUT; 215 165 watchdog_init_timeout(&wdt->wdd, 0, &pdev->dev); 216 166 167 + np = pdev->dev.of_node; 168 + 169 + ofdid = of_match_node(aspeed_wdt_of_table, np); 170 + if (!ofdid) 171 + return -EINVAL; 172 + config = ofdid->data; 173 + 174 + wdt->ctrl = WDT_CTRL_1MHZ_CLK; 175 + 217 176 /* 218 177 * Control reset on a per-device basis to ensure the 219 - * host is not affected by a BMC reboot, so only reset 220 - * the SOC and not the full chip 178 + * host is not affected by a BMC reboot 221 179 */ 222 - wdt->ctrl = WDT_CTRL_RESET_MODE_SOC | 223 - WDT_CTRL_1MHZ_CLK | 224 - WDT_CTRL_RESET_SYSTEM; 180 + ret = of_property_read_string(np, "aspeed,reset-type", &reset_type); 181 + if (ret) { 182 + wdt->ctrl |= WDT_CTRL_RESET_MODE_SOC | WDT_CTRL_RESET_SYSTEM; 183 + } else { 184 + if (!strcmp(reset_type, "cpu")) 185 + wdt->ctrl |= WDT_CTRL_RESET_MODE_ARM_CPU; 186 + else if (!strcmp(reset_type, "soc")) 187 + wdt->ctrl |= WDT_CTRL_RESET_MODE_SOC; 188 + else if (!strcmp(reset_type, "system")) 189 + wdt->ctrl |= WDT_CTRL_RESET_SYSTEM; 190 + else if (strcmp(reset_type, "none")) 191 + return -EINVAL; 192 + } 193 + if (of_property_read_bool(np, "aspeed,external-signal")) 194 + wdt->ctrl |= WDT_CTRL_WDT_EXT; 195 + 196 + writel(wdt->ctrl, wdt->base + WDT_CTRL); 225 197 226 198 if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE) { 227 199 aspeed_wdt_start(&wdt->wdd); 228 200 set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); 201 + } 202 + 203 + if (of_device_is_compatible(np, "aspeed,ast2500-wdt")) { 204 + u32 reg = readl(wdt->base + WDT_RESET_WIDTH); 205 + 206 + reg &= config->ext_pulse_width_mask; 207 + if (of_property_read_bool(np, "aspeed,ext-push-pull")) 208 + reg |= WDT_PUSH_PULL_MAGIC; 209 + else 210 + reg |= WDT_OPEN_DRAIN_MAGIC; 211 + 212 + writel(reg, wdt->base + WDT_RESET_WIDTH); 213 + 214 + reg &= config->ext_pulse_width_mask; 215 + if (of_property_read_bool(np, "aspeed,ext-active-high")) 216 + reg |= WDT_ACTIVE_HIGH_MAGIC; 217 + else 218 + reg |= WDT_ACTIVE_LOW_MAGIC; 219 + 220 + writel(reg, wdt->base + WDT_RESET_WIDTH); 221 + } 222 + 223 + if (!of_property_read_u32(np, "aspeed,ext-pulse-duration", &duration)) { 224 + u32 max_duration = config->ext_pulse_width_mask + 1; 225 + 226 + if (duration == 0 || duration > max_duration) { 227 + dev_err(&pdev->dev, "Invalid pulse duration: %uus\n", 228 + duration); 229 + duration = max(1U, min(max_duration, duration)); 230 + dev_info(&pdev->dev, "Pulse duration set to %uus\n", 231 + duration); 232 + } 233 + 234 + /* 235 + * The watchdog is always configured with a 1MHz source, so 236 + * there is no need to scale the microsecond value. However we 237 + * need to offset it - from the datasheet: 238 + * 239 + * "This register decides the asserting duration of wdt_ext and 240 + * wdt_rstarm signal. The default value is 0xFF. It means the 241 + * default asserting duration of wdt_ext and wdt_rstarm is 242 + * 256us." 243 + * 244 + * This implies a value of 0 gives a 1us pulse. 245 + */ 246 + writel(duration - 1, wdt->base + WDT_RESET_WIDTH); 229 247 } 230 248 231 249 ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdd);
+3 -1
drivers/watchdog/bcm7038_wdt.c
··· 136 136 wdt->clk = devm_clk_get(dev, NULL); 137 137 /* If unable to get clock, use default frequency */ 138 138 if (!IS_ERR(wdt->clk)) { 139 - clk_prepare_enable(wdt->clk); 139 + err = clk_prepare_enable(wdt->clk); 140 + if (err) 141 + return err; 140 142 wdt->rate = clk_get_rate(wdt->clk); 141 143 /* Prevent divide-by-zero exception */ 142 144 if (!wdt->rate)
+3 -3
drivers/watchdog/cadence_wdt.c
··· 52 52 static int wdt_timeout; 53 53 static int nowayout = WATCHDOG_NOWAYOUT; 54 54 55 - module_param(wdt_timeout, int, 0); 55 + module_param(wdt_timeout, int, 0644); 56 56 MODULE_PARM_DESC(wdt_timeout, 57 57 "Watchdog time in seconds. (default=" 58 58 __MODULE_STRING(CDNS_WDT_DEFAULT_TIMEOUT) ")"); 59 59 60 - module_param(nowayout, int, 0); 60 + module_param(nowayout, int, 0644); 61 61 MODULE_PARM_DESC(nowayout, 62 62 "Watchdog cannot be stopped once started (default=" 63 63 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); ··· 368 368 } 369 369 platform_set_drvdata(pdev, wdt); 370 370 371 - dev_dbg(&pdev->dev, "Xilinx Watchdog Timer at %p with timeout %ds%s\n", 371 + dev_info(&pdev->dev, "Xilinx Watchdog Timer at %p with timeout %ds%s\n", 372 372 wdt->regs, cdns_wdt_device->timeout, 373 373 nowayout ? ", nowayout" : ""); 374 374
+1 -1
drivers/watchdog/coh901327_wdt.c
··· 218 218 .identity = DRV_NAME, 219 219 }; 220 220 221 - static struct watchdog_ops coh901327_ops = { 221 + static const struct watchdog_ops coh901327_ops = { 222 222 .owner = THIS_MODULE, 223 223 .start = coh901327_start, 224 224 .stop = coh901327_stop,
+30 -37
drivers/watchdog/da9063_wdt.c
··· 36 36 #define DA9063_WDG_TIMEOUT wdt_timeout[3] 37 37 #define DA9063_RESET_PROTECTION_MS 256 38 38 39 - struct da9063_watchdog { 40 - struct da9063 *da9063; 41 - struct watchdog_device wdtdev; 42 - }; 43 - 44 39 static unsigned int da9063_wdt_timeout_to_sel(unsigned int secs) 45 40 { 46 41 unsigned int i; ··· 56 61 57 62 static int da9063_wdt_start(struct watchdog_device *wdd) 58 63 { 59 - struct da9063_watchdog *wdt = watchdog_get_drvdata(wdd); 64 + struct da9063 *da9063 = watchdog_get_drvdata(wdd); 60 65 unsigned int selector; 61 66 int ret; 62 67 63 - selector = da9063_wdt_timeout_to_sel(wdt->wdtdev.timeout); 64 - ret = _da9063_wdt_set_timeout(wdt->da9063, selector); 68 + selector = da9063_wdt_timeout_to_sel(wdd->timeout); 69 + ret = _da9063_wdt_set_timeout(da9063, selector); 65 70 if (ret) 66 - dev_err(wdt->da9063->dev, "Watchdog failed to start (err = %d)\n", 71 + dev_err(da9063->dev, "Watchdog failed to start (err = %d)\n", 67 72 ret); 68 73 69 74 return ret; ··· 71 76 72 77 static int da9063_wdt_stop(struct watchdog_device *wdd) 73 78 { 74 - struct da9063_watchdog *wdt = watchdog_get_drvdata(wdd); 79 + struct da9063 *da9063 = watchdog_get_drvdata(wdd); 75 80 int ret; 76 81 77 - ret = regmap_update_bits(wdt->da9063->regmap, DA9063_REG_CONTROL_D, 82 + ret = regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D, 78 83 DA9063_TWDSCALE_MASK, DA9063_TWDSCALE_DISABLE); 79 84 if (ret) 80 - dev_alert(wdt->da9063->dev, "Watchdog failed to stop (err = %d)\n", 85 + dev_alert(da9063->dev, "Watchdog failed to stop (err = %d)\n", 81 86 ret); 82 87 83 88 return ret; ··· 85 90 86 91 static int da9063_wdt_ping(struct watchdog_device *wdd) 87 92 { 88 - struct da9063_watchdog *wdt = watchdog_get_drvdata(wdd); 93 + struct da9063 *da9063 = watchdog_get_drvdata(wdd); 89 94 int ret; 90 95 91 - ret = regmap_write(wdt->da9063->regmap, DA9063_REG_CONTROL_F, 96 + ret = regmap_write(da9063->regmap, DA9063_REG_CONTROL_F, 92 97 DA9063_WATCHDOG); 93 98 if (ret) 94 - dev_alert(wdt->da9063->dev, "Failed to ping the watchdog (err = %d)\n", 99 + dev_alert(da9063->dev, "Failed to ping the watchdog (err = %d)\n", 95 100 ret); 96 101 97 102 return ret; ··· 100 105 static int da9063_wdt_set_timeout(struct watchdog_device *wdd, 101 106 unsigned int timeout) 102 107 { 103 - struct da9063_watchdog *wdt = watchdog_get_drvdata(wdd); 108 + struct da9063 *da9063 = watchdog_get_drvdata(wdd); 104 109 unsigned int selector; 105 110 int ret; 106 111 107 112 selector = da9063_wdt_timeout_to_sel(timeout); 108 - ret = _da9063_wdt_set_timeout(wdt->da9063, selector); 113 + ret = _da9063_wdt_set_timeout(da9063, selector); 109 114 if (ret) 110 - dev_err(wdt->da9063->dev, "Failed to set watchdog timeout (err = %d)\n", 115 + dev_err(da9063->dev, "Failed to set watchdog timeout (err = %d)\n", 111 116 ret); 112 117 else 113 118 wdd->timeout = wdt_timeout[selector]; ··· 118 123 static int da9063_wdt_restart(struct watchdog_device *wdd, unsigned long action, 119 124 void *data) 120 125 { 121 - struct da9063_watchdog *wdt = watchdog_get_drvdata(wdd); 126 + struct da9063 *da9063 = watchdog_get_drvdata(wdd); 122 127 int ret; 123 128 124 - ret = regmap_write(wdt->da9063->regmap, DA9063_REG_CONTROL_F, 129 + ret = regmap_write(da9063->regmap, DA9063_REG_CONTROL_F, 125 130 DA9063_SHUTDOWN); 126 131 if (ret) 127 - dev_alert(wdt->da9063->dev, "Failed to shutdown (err = %d)\n", 132 + dev_alert(da9063->dev, "Failed to shutdown (err = %d)\n", 128 133 ret); 129 134 130 135 return ret; ··· 147 152 static int da9063_wdt_probe(struct platform_device *pdev) 148 153 { 149 154 struct da9063 *da9063; 150 - struct da9063_watchdog *wdt; 155 + struct watchdog_device *wdd; 151 156 152 157 if (!pdev->dev.parent) 153 158 return -EINVAL; ··· 156 161 if (!da9063) 157 162 return -EINVAL; 158 163 159 - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); 160 - if (!wdt) 164 + wdd = devm_kzalloc(&pdev->dev, sizeof(*wdd), GFP_KERNEL); 165 + if (!wdd) 161 166 return -ENOMEM; 162 167 163 - wdt->da9063 = da9063; 168 + wdd->info = &da9063_watchdog_info; 169 + wdd->ops = &da9063_watchdog_ops; 170 + wdd->min_timeout = DA9063_WDT_MIN_TIMEOUT; 171 + wdd->max_timeout = DA9063_WDT_MAX_TIMEOUT; 172 + wdd->min_hw_heartbeat_ms = DA9063_RESET_PROTECTION_MS; 173 + wdd->timeout = DA9063_WDG_TIMEOUT; 174 + wdd->parent = &pdev->dev; 164 175 165 - wdt->wdtdev.info = &da9063_watchdog_info; 166 - wdt->wdtdev.ops = &da9063_watchdog_ops; 167 - wdt->wdtdev.min_timeout = DA9063_WDT_MIN_TIMEOUT; 168 - wdt->wdtdev.max_timeout = DA9063_WDT_MAX_TIMEOUT; 169 - wdt->wdtdev.min_hw_heartbeat_ms = DA9063_RESET_PROTECTION_MS; 170 - wdt->wdtdev.timeout = DA9063_WDG_TIMEOUT; 171 - wdt->wdtdev.parent = &pdev->dev; 176 + wdd->status = WATCHDOG_NOWAYOUT_INIT_STATUS; 172 177 173 - wdt->wdtdev.status = WATCHDOG_NOWAYOUT_INIT_STATUS; 178 + watchdog_set_restart_priority(wdd, 128); 174 179 175 - watchdog_set_restart_priority(&wdt->wdtdev, 128); 180 + watchdog_set_drvdata(wdd, da9063); 176 181 177 - watchdog_set_drvdata(&wdt->wdtdev, wdt); 178 - 179 - return devm_watchdog_register_device(&pdev->dev, &wdt->wdtdev); 182 + return devm_watchdog_register_device(&pdev->dev, wdd); 180 183 } 181 184 182 185 static struct platform_driver da9063_wdt_driver = {
+1 -1
drivers/watchdog/diag288_wdt.c
··· 213 213 .set_timeout = wdt_set_timeout, 214 214 }; 215 215 216 - static struct watchdog_info wdt_info = { 216 + static const struct watchdog_info wdt_info = { 217 217 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 218 218 .firmware_version = 0, 219 219 .identity = "z Watchdog",
+12 -10
drivers/watchdog/iTCO_wdt.c
··· 306 306 307 307 iTCO_vendor_pre_keepalive(p->smi_res, wd_dev->timeout); 308 308 309 - /* Reset the timeout status bit so that the timer 310 - * needs to count down twice again before rebooting */ 311 - outw(0x0008, TCO1_STS(p)); /* write 1 to clear bit */ 312 - 313 309 /* Reload the timer by writing to the TCO Timer Counter register */ 314 - if (p->iTCO_version >= 2) 310 + if (p->iTCO_version >= 2) { 315 311 outw(0x01, TCO_RLD(p)); 316 - else if (p->iTCO_version == 1) 312 + } else if (p->iTCO_version == 1) { 313 + /* Reset the timeout status bit so that the timer 314 + * needs to count down twice again before rebooting */ 315 + outw(0x0008, TCO1_STS(p)); /* write 1 to clear bit */ 316 + 317 317 outb(0x01, TCO_RLD(p)); 318 + } 318 319 319 320 spin_unlock(&p->io_lock); 320 321 return 0; ··· 328 327 unsigned char val8; 329 328 unsigned int tmrval; 330 329 331 - /* The timer counts down twice before rebooting */ 332 - tmrval = seconds_to_ticks(p, t) / 2; 330 + tmrval = seconds_to_ticks(p, t); 331 + 332 + /* For TCO v1 the timer counts down twice before rebooting */ 333 + if (p->iTCO_version == 1) 334 + tmrval /= 2; 333 335 334 336 /* from the specs: */ 335 337 /* "Values of 0h-3h are ignored and should not be attempted" */ ··· 385 381 spin_lock(&p->io_lock); 386 382 val16 = inw(TCO_RLD(p)); 387 383 val16 &= 0x3ff; 388 - if (!(inw(TCO1_STS(p)) & 0x0008)) 389 - val16 += (inw(TCOv2_TMR(p)) & 0x3ff); 390 384 spin_unlock(&p->io_lock); 391 385 392 386 time_left = ticks_to_seconds(p, val16);
+1 -1
drivers/watchdog/it87_wdt.c
··· 253 253 .identity = WATCHDOG_NAME, 254 254 }; 255 255 256 - static struct watchdog_ops wdt_ops = { 256 + static const struct watchdog_ops wdt_ops = { 257 257 .owner = THIS_MODULE, 258 258 .start = wdt_start, 259 259 .stop = wdt_stop,
+1 -1
drivers/watchdog/max77620_wdt.c
··· 201 201 return 0; 202 202 } 203 203 204 - static struct platform_device_id max77620_wdt_devtype[] = { 204 + static const struct platform_device_id max77620_wdt_devtype[] = { 205 205 { .name = "max77620-watchdog", }, 206 206 { }, 207 207 };
+1 -1
drivers/watchdog/mei_wdt.c
··· 670 670 #define MEI_UUID_WD UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, \ 671 671 0x89, 0x9D, 0xA9, 0x15, 0x14, 0xCB, 0x32, 0xAB) 672 672 673 - static struct mei_cl_device_id mei_wdt_tbl[] = { 673 + static const struct mei_cl_device_id mei_wdt_tbl[] = { 674 674 { .uuid = MEI_UUID_WD, .version = MEI_CL_VERSION_ANY }, 675 675 /* required last entry */ 676 676 { }
+2
drivers/watchdog/meson_wdt.c
··· 155 155 156 156 static const struct of_device_id meson_wdt_dt_ids[] = { 157 157 { .compatible = "amlogic,meson6-wdt", .data = &meson6_wdt_data }, 158 + { .compatible = "amlogic,meson8-wdt", .data = &meson6_wdt_data }, 158 159 { .compatible = "amlogic,meson8b-wdt", .data = &meson8b_wdt_data }, 160 + { .compatible = "amlogic,meson8m2-wdt", .data = &meson8b_wdt_data }, 159 161 { /* sentinel */ } 160 162 }; 161 163 MODULE_DEVICE_TABLE(of, meson_wdt_dt_ids);
+2 -2
drivers/watchdog/mt7621_wdt.c
··· 105 105 return 0; 106 106 } 107 107 108 - static struct watchdog_info mt7621_wdt_info = { 108 + static const struct watchdog_info mt7621_wdt_info = { 109 109 .identity = "Mediatek Watchdog", 110 110 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 111 111 }; ··· 135 135 if (IS_ERR(mt7621_wdt_base)) 136 136 return PTR_ERR(mt7621_wdt_base); 137 137 138 - mt7621_wdt_reset = devm_reset_control_get(&pdev->dev, NULL); 138 + mt7621_wdt_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); 139 139 if (!IS_ERR(mt7621_wdt_reset)) 140 140 reset_control_deassert(mt7621_wdt_reset); 141 141
+70 -13
drivers/watchdog/of_xilinx_wdt.c
··· 51 51 52 52 static int xilinx_wdt_start(struct watchdog_device *wdd) 53 53 { 54 + int ret; 54 55 u32 control_status_reg; 55 56 struct xwdt_device *xdev = watchdog_get_drvdata(wdd); 57 + 58 + ret = clk_enable(xdev->clk); 59 + if (ret) { 60 + dev_err(wdd->parent, "Failed to enable clock\n"); 61 + return ret; 62 + } 56 63 57 64 spin_lock(&xdev->spinlock); 58 65 ··· 92 85 iowrite32(0, xdev->base + XWT_TWCSR1_OFFSET); 93 86 94 87 spin_unlock(&xdev->spinlock); 88 + 89 + clk_disable(xdev->clk); 90 + 95 91 pr_info("Stopped!\n"); 96 92 97 93 return 0; ··· 177 167 if (IS_ERR(xdev->base)) 178 168 return PTR_ERR(xdev->base); 179 169 180 - rc = of_property_read_u32(pdev->dev.of_node, "clock-frequency", &pfreq); 181 - if (rc) 182 - dev_warn(&pdev->dev, 183 - "The watchdog clock frequency cannot be obtained\n"); 184 - 185 170 rc = of_property_read_u32(pdev->dev.of_node, "xlnx,wdt-interval", 186 171 &xdev->wdt_interval); 187 172 if (rc) ··· 191 186 192 187 watchdog_set_nowayout(xilinx_wdt_wdd, enable_once); 193 188 189 + xdev->clk = devm_clk_get(&pdev->dev, NULL); 190 + if (IS_ERR(xdev->clk)) { 191 + if (PTR_ERR(xdev->clk) != -ENOENT) 192 + return PTR_ERR(xdev->clk); 193 + 194 + /* 195 + * Clock framework support is optional, continue on 196 + * anyways if we don't find a matching clock. 197 + */ 198 + xdev->clk = NULL; 199 + 200 + rc = of_property_read_u32(pdev->dev.of_node, "clock-frequency", 201 + &pfreq); 202 + if (rc) 203 + dev_warn(&pdev->dev, 204 + "The watchdog clock freq cannot be obtained\n"); 205 + } else { 206 + pfreq = clk_get_rate(xdev->clk); 207 + } 208 + 194 209 /* 195 210 * Twice of the 2^wdt_interval / freq because the first wdt overflow is 196 211 * ignored (interrupt), reset is only generated at second wdt overflow ··· 221 196 222 197 spin_lock_init(&xdev->spinlock); 223 198 watchdog_set_drvdata(xilinx_wdt_wdd, xdev); 224 - 225 - xdev->clk = devm_clk_get(&pdev->dev, NULL); 226 - if (IS_ERR(xdev->clk)) { 227 - if (PTR_ERR(xdev->clk) == -ENOENT) 228 - xdev->clk = NULL; 229 - else 230 - return PTR_ERR(xdev->clk); 231 - } 232 199 233 200 rc = clk_prepare_enable(xdev->clk); 234 201 if (rc) { ··· 239 222 dev_err(&pdev->dev, "Cannot register watchdog (err=%d)\n", rc); 240 223 goto err_clk_disable; 241 224 } 225 + 226 + clk_disable(xdev->clk); 242 227 243 228 dev_info(&pdev->dev, "Xilinx Watchdog Timer at %p with timeout %ds\n", 244 229 xdev->base, xilinx_wdt_wdd->timeout); ··· 264 245 return 0; 265 246 } 266 247 248 + /** 249 + * xwdt_suspend - Suspend the device. 250 + * 251 + * @dev: handle to the device structure. 252 + * Return: 0 always. 253 + */ 254 + static int __maybe_unused xwdt_suspend(struct device *dev) 255 + { 256 + struct platform_device *pdev = to_platform_device(dev); 257 + struct xwdt_device *xdev = platform_get_drvdata(pdev); 258 + 259 + if (watchdog_active(&xdev->xilinx_wdt_wdd)) 260 + xilinx_wdt_stop(&xdev->xilinx_wdt_wdd); 261 + 262 + return 0; 263 + } 264 + 265 + /** 266 + * xwdt_resume - Resume the device. 267 + * 268 + * @dev: handle to the device structure. 269 + * Return: 0 on success, errno otherwise. 270 + */ 271 + static int __maybe_unused xwdt_resume(struct device *dev) 272 + { 273 + struct platform_device *pdev = to_platform_device(dev); 274 + struct xwdt_device *xdev = platform_get_drvdata(pdev); 275 + int ret = 0; 276 + 277 + if (watchdog_active(&xdev->xilinx_wdt_wdd)) 278 + ret = xilinx_wdt_start(&xdev->xilinx_wdt_wdd); 279 + 280 + return ret; 281 + } 282 + 283 + static SIMPLE_DEV_PM_OPS(xwdt_pm_ops, xwdt_suspend, xwdt_resume); 284 + 267 285 /* Match table for of_platform binding */ 268 286 static const struct of_device_id xwdt_of_match[] = { 269 287 { .compatible = "xlnx,xps-timebase-wdt-1.00.a", }, ··· 315 259 .driver = { 316 260 .name = WATCHDOG_NAME, 317 261 .of_match_table = xwdt_of_match, 262 + .pm = &xwdt_pm_ops, 318 263 }, 319 264 }; 320 265
+1 -1
drivers/watchdog/pcwd_usb.c
··· 74 74 #define USB_PCWD_PRODUCT_ID 0x1140 75 75 76 76 /* table of devices that work with this driver */ 77 - static struct usb_device_id usb_pcwd_table[] = { 77 + static const struct usb_device_id usb_pcwd_table[] = { 78 78 { USB_DEVICE(USB_PCWD_VENDOR_ID, USB_PCWD_PRODUCT_ID) }, 79 79 { } /* Terminating entry */ 80 80 };
+2
drivers/watchdog/qcom-wdt.c
··· 162 162 return -ENOMEM; 163 163 164 164 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 165 + if (!res) 166 + return -ENOMEM; 165 167 166 168 /* We use CPU0's DGT for the watchdog */ 167 169 if (of_property_read_u32(np, "cpu-offset", &percpu_offset))
+48 -32
drivers/watchdog/renesas_wdt.c
··· 1 1 /* 2 2 * Watchdog driver for Renesas WDT watchdog 3 3 * 4 - * Copyright (C) 2015-16 Wolfram Sang, Sang Engineering <wsa@sang-engineering.com> 5 - * Copyright (C) 2015-16 Renesas Electronics Corporation 4 + * Copyright (C) 2015-17 Wolfram Sang, Sang Engineering <wsa@sang-engineering.com> 5 + * Copyright (C) 2015-17 Renesas Electronics Corporation 6 6 * 7 7 * This program is free software; you can redistribute it and/or modify it 8 8 * under the terms of the GNU General Public License version 2 as published by ··· 23 23 #define RWTCSRA_WOVF BIT(4) 24 24 #define RWTCSRA_WRFLG BIT(5) 25 25 #define RWTCSRA_TME BIT(7) 26 + #define RWTCSRB 8 26 27 27 28 #define RWDT_DEFAULT_TIMEOUT 60U 28 29 29 - static const unsigned int clk_divs[] = { 1, 4, 16, 32, 64, 128, 1024 }; 30 + /* 31 + * In probe, clk_rate is checked to be not more than 16 bit * biggest clock 32 + * divider (12 bits). d is only a factor to fully utilize the WDT counter and 33 + * will not exceed its 16 bits. Thus, no overflow, we stay below 32 bits. 34 + */ 35 + #define MUL_BY_CLKS_PER_SEC(p, d) \ 36 + DIV_ROUND_UP((d) * (p)->clk_rate, clk_divs[(p)->cks]) 37 + 38 + /* d is 16 bit, clk_divs 12 bit -> no 32 bit overflow */ 39 + #define DIV_BY_CLKS_PER_SEC(p, d) ((d) * clk_divs[(p)->cks] / (p)->clk_rate) 40 + 41 + static const unsigned int clk_divs[] = { 1, 4, 16, 32, 64, 128, 1024, 4096 }; 30 42 31 43 static bool nowayout = WATCHDOG_NOWAYOUT; 32 44 module_param(nowayout, bool, 0); ··· 48 36 struct rwdt_priv { 49 37 void __iomem *base; 50 38 struct watchdog_device wdev; 51 - struct clk *clk; 52 - unsigned int clks_per_sec; 39 + unsigned long clk_rate; 53 40 u8 cks; 54 41 }; 55 42 ··· 66 55 { 67 56 struct rwdt_priv *priv = watchdog_get_drvdata(wdev); 68 57 69 - rwdt_write(priv, 65536 - wdev->timeout * priv->clks_per_sec, RWTCNT); 58 + rwdt_write(priv, 65536 - MUL_BY_CLKS_PER_SEC(priv, wdev->timeout), RWTCNT); 70 59 71 60 return 0; 72 61 } ··· 75 64 { 76 65 struct rwdt_priv *priv = watchdog_get_drvdata(wdev); 77 66 78 - clk_prepare_enable(priv->clk); 67 + pm_runtime_get_sync(wdev->parent); 79 68 69 + rwdt_write(priv, 0, RWTCSRB); 80 70 rwdt_write(priv, priv->cks, RWTCSRA); 81 71 rwdt_init_timeout(wdev); 82 72 ··· 94 82 struct rwdt_priv *priv = watchdog_get_drvdata(wdev); 95 83 96 84 rwdt_write(priv, priv->cks, RWTCSRA); 97 - clk_disable_unprepare(priv->clk); 85 + pm_runtime_put(wdev->parent); 98 86 99 87 return 0; 100 88 } ··· 104 92 struct rwdt_priv *priv = watchdog_get_drvdata(wdev); 105 93 u16 val = readw_relaxed(priv->base + RWTCNT); 106 94 107 - return DIV_ROUND_CLOSEST(65536 - val, priv->clks_per_sec); 95 + return DIV_BY_CLKS_PER_SEC(priv, 65536 - val); 108 96 } 109 97 110 98 static const struct watchdog_info rwdt_ident = { ··· 124 112 { 125 113 struct rwdt_priv *priv; 126 114 struct resource *res; 127 - unsigned long rate; 128 - unsigned int clks_per_sec; 115 + struct clk *clk; 116 + unsigned long clks_per_sec; 129 117 int ret, i; 130 118 131 119 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); ··· 137 125 if (IS_ERR(priv->base)) 138 126 return PTR_ERR(priv->base); 139 127 140 - priv->clk = devm_clk_get(&pdev->dev, NULL); 141 - if (IS_ERR(priv->clk)) 142 - return PTR_ERR(priv->clk); 128 + clk = devm_clk_get(&pdev->dev, NULL); 129 + if (IS_ERR(clk)) 130 + return PTR_ERR(clk); 143 131 144 - rate = clk_get_rate(priv->clk); 145 - if (!rate) 146 - return -ENOENT; 132 + pm_runtime_enable(&pdev->dev); 133 + 134 + pm_runtime_get_sync(&pdev->dev); 135 + priv->clk_rate = clk_get_rate(clk); 136 + pm_runtime_put(&pdev->dev); 137 + 138 + if (!priv->clk_rate) { 139 + ret = -ENOENT; 140 + goto out_pm_disable; 141 + } 147 142 148 143 for (i = ARRAY_SIZE(clk_divs) - 1; i >= 0; i--) { 149 - clks_per_sec = DIV_ROUND_UP(rate, clk_divs[i]); 150 - if (clks_per_sec) { 151 - priv->clks_per_sec = clks_per_sec; 144 + clks_per_sec = priv->clk_rate / clk_divs[i]; 145 + if (clks_per_sec && clks_per_sec < 65536) { 152 146 priv->cks = i; 153 147 break; 154 148 } 155 149 } 156 150 157 - if (!clks_per_sec) { 151 + if (i < 0) { 158 152 dev_err(&pdev->dev, "Can't find suitable clock divider\n"); 159 - return -ERANGE; 153 + ret = -ERANGE; 154 + goto out_pm_disable; 160 155 } 161 - 162 - pm_runtime_enable(&pdev->dev); 163 - pm_runtime_get_sync(&pdev->dev); 164 156 165 157 priv->wdev.info = &rwdt_ident, 166 158 priv->wdev.ops = &rwdt_ops, 167 159 priv->wdev.parent = &pdev->dev; 168 160 priv->wdev.min_timeout = 1; 169 - priv->wdev.max_timeout = 65536 / clks_per_sec; 161 + priv->wdev.max_timeout = DIV_BY_CLKS_PER_SEC(priv, 65536); 170 162 priv->wdev.timeout = min(priv->wdev.max_timeout, RWDT_DEFAULT_TIMEOUT); 171 163 172 164 platform_set_drvdata(pdev, priv); ··· 183 167 dev_warn(&pdev->dev, "Specified timeout value invalid, using default\n"); 184 168 185 169 ret = watchdog_register_device(&priv->wdev); 186 - if (ret < 0) { 187 - pm_runtime_put(&pdev->dev); 188 - pm_runtime_disable(&pdev->dev); 189 - return ret; 190 - } 170 + if (ret < 0) 171 + goto out_pm_disable; 191 172 192 173 return 0; 174 + 175 + out_pm_disable: 176 + pm_runtime_disable(&pdev->dev); 177 + return ret; 193 178 } 194 179 195 180 static int rwdt_remove(struct platform_device *pdev) ··· 198 181 struct rwdt_priv *priv = platform_get_drvdata(pdev); 199 182 200 183 watchdog_unregister_device(&priv->wdev); 201 - pm_runtime_put(&pdev->dev); 202 184 pm_runtime_disable(&pdev->dev); 203 185 204 186 return 0;
+2 -2
drivers/watchdog/rt2880_wdt.c
··· 119 119 return 0; 120 120 } 121 121 122 - static struct watchdog_info rt288x_wdt_info = { 122 + static const struct watchdog_info rt288x_wdt_info = { 123 123 .identity = "Ralink Watchdog", 124 124 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 125 125 }; ··· 152 152 if (IS_ERR(rt288x_wdt_clk)) 153 153 return PTR_ERR(rt288x_wdt_clk); 154 154 155 - rt288x_wdt_reset = devm_reset_control_get(&pdev->dev, NULL); 155 + rt288x_wdt_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); 156 156 if (!IS_ERR(rt288x_wdt_reset)) 157 157 reset_control_deassert(rt288x_wdt_reset); 158 158
+1 -1
drivers/watchdog/sc1200wdt.c
··· 342 342 343 343 #if defined CONFIG_PNP 344 344 345 - static struct pnp_device_id scl200wdt_pnp_devices[] = { 345 + static const struct pnp_device_id scl200wdt_pnp_devices[] = { 346 346 /* National Semiconductor PC87307/PC97307 watchdog component */ 347 347 {.id = "NSC0800", .driver_data = 0}, 348 348 {.id = ""},
+1 -1
drivers/watchdog/sp805_wdt.c
··· 281 281 static SIMPLE_DEV_PM_OPS(sp805_wdt_dev_pm_ops, sp805_wdt_suspend, 282 282 sp805_wdt_resume); 283 283 284 - static struct amba_id sp805_wdt_ids[] = { 284 + static const struct amba_id sp805_wdt_ids[] = { 285 285 { 286 286 .id = 0x00141805, 287 287 .mask = 0x00ffffff,
+1 -1
drivers/watchdog/stm32_iwdg.c
··· 140 140 .identity = "STM32 Independent Watchdog", 141 141 }; 142 142 143 - static struct watchdog_ops stm32_iwdg_ops = { 143 + static const struct watchdog_ops stm32_iwdg_ops = { 144 144 .owner = THIS_MODULE, 145 145 .start = stm32_iwdg_start, 146 146 .ping = stm32_iwdg_ping,
+1 -1
drivers/watchdog/ts72xx_wdt.c
··· 112 112 .identity = "TS-72XX WDT", 113 113 }; 114 114 115 - static struct watchdog_ops ts72xx_wdt_ops = { 115 + static const struct watchdog_ops ts72xx_wdt_ops = { 116 116 .owner = THIS_MODULE, 117 117 .start = ts72xx_wdt_start, 118 118 .stop = ts72xx_wdt_stop,
+1 -1
drivers/watchdog/w83627hf_wdt.c
··· 429 429 { 430 430 int ret; 431 431 int chip; 432 - const char * const chip_name[] = { 432 + static const char * const chip_name[] = { 433 433 "W83627HF", 434 434 "W83627S", 435 435 "W83697HF",
+1 -1
drivers/watchdog/ziirave_wdt.c
··· 737 737 return 0; 738 738 } 739 739 740 - static struct i2c_device_id ziirave_wdt_id[] = { 740 + static const struct i2c_device_id ziirave_wdt_id[] = { 741 741 { "rave-wdt", 0 }, 742 742 { } 743 743 };
+1 -1
drivers/watchdog/zx2967_wdt.c
··· 229 229 } 230 230 clk_set_rate(wdt->clock, ZX2967_WDT_CLK_FREQ); 231 231 232 - rstc = devm_reset_control_get(dev, NULL); 232 + rstc = devm_reset_control_get_exclusive(dev, NULL); 233 233 if (IS_ERR(rstc)) { 234 234 dev_err(dev, "failed to get rstc"); 235 235 ret = PTR_ERR(rstc);