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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull watchdog updates from Wim Van Sebroeck:

- add support for BCM4908

- renesas_wdt: add R-Car Gen4 support

- improve watchdog_dev function documentation

- sp5100_tco: replace the cd6h/cd7h port I/O with MMIO accesses during
initialization

- several other small improvements and fixes

* tag 'linux-watchdog-5.18-rc1' of git://www.linux-watchdog.org/linux-watchdog:
Watchdog: sp5100_tco: Enable Family 17h+ CPUs
Watchdog: sp5100_tco: Add initialization using EFCH MMIO
Watchdog: sp5100_tco: Refactor MMIO base address initialization
Watchdog: sp5100_tco: Move timer initialization into function
watchdog: ixp4xx: Implement restart
watchdog: orion_wdt: support pretimeout on Armada-XP
watchdog: allow building BCM7038_WDT for BCM4908
watchdog: renesas_wdt: Add R-Car Gen4 support
dt-bindings: watchdog: renesas-wdt: Document r8a779f0 support
watchdog: Improve watchdog_dev function documentation
watchdog: aspeed: add nowayout support
watchdog: rti-wdt: Add missing pm_runtime_disable() in probe function
watchdog: imx2_wdg: Alow ping on suspend

+409 -246
+5
Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml
··· 55 55 - renesas,r8a779a0-wdt # R-Car V3U 56 56 - const: renesas,rcar-gen3-wdt # R-Car Gen3 and RZ/G2 57 57 58 + - items: 59 + - enum: 60 + - renesas,r8a779f0-wdt # R-Car S4-8 61 + - const: renesas,rcar-gen4-wdt # R-Car Gen4 62 + 58 63 reg: 59 64 maxItems: 1 60 65
+1 -1
drivers/watchdog/Kconfig
··· 1779 1779 tristate "BCM63xx/BCM7038 Watchdog" 1780 1780 select WATCHDOG_CORE 1781 1781 depends on HAS_IOMEM 1782 - depends on ARCH_BRCMSTB || BMIPS_GENERIC || BCM63XX || COMPILE_TEST 1782 + depends on ARCH_BCM4908 || ARCH_BRCMSTB || BMIPS_GENERIC || BCM63XX || COMPILE_TEST 1783 1783 help 1784 1784 Watchdog driver for the built-in hardware in Broadcom 7038 and 1785 1785 later SoCs used in set-top boxes. BCM7038 was made public
+7
drivers/watchdog/aspeed_wdt.c
··· 13 13 #include <linux/platform_device.h> 14 14 #include <linux/watchdog.h> 15 15 16 + static bool nowayout = WATCHDOG_NOWAYOUT; 17 + module_param(nowayout, bool, 0); 18 + MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 19 + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 20 + 16 21 struct aspeed_wdt { 17 22 struct watchdog_device wdd; 18 23 void __iomem *base; ··· 270 265 271 266 wdt->wdd.timeout = WDT_DEFAULT_TIMEOUT; 272 267 watchdog_init_timeout(&wdt->wdd, 0, dev); 268 + 269 + watchdog_set_nowayout(&wdt->wdd, nowayout); 273 270 274 271 np = dev->of_node; 275 272
+20 -7
drivers/watchdog/imx2_wdt.c
··· 66 66 struct watchdog_device wdog; 67 67 bool ext_reset; 68 68 bool clk_is_on; 69 + bool no_ping; 69 70 }; 70 71 71 72 static bool nowayout = WATCHDOG_NOWAYOUT; ··· 313 312 314 313 wdev->ext_reset = of_property_read_bool(dev->of_node, 315 314 "fsl,ext-reset-output"); 315 + /* 316 + * The i.MX7D doesn't support low power mode, so we need to ping the watchdog 317 + * during suspend. 318 + */ 319 + wdev->no_ping = !of_device_is_compatible(dev->of_node, "fsl,imx7d-wdt"); 316 320 platform_set_drvdata(pdev, wdog); 317 321 watchdog_set_drvdata(wdog, wdev); 318 322 watchdog_set_nowayout(wdog, nowayout); 319 323 watchdog_set_restart_priority(wdog, 128); 320 324 watchdog_init_timeout(wdog, timeout, dev); 321 - watchdog_stop_ping_on_suspend(wdog); 325 + if (wdev->no_ping) 326 + watchdog_stop_ping_on_suspend(wdog); 322 327 323 328 if (imx2_wdt_is_running(wdev)) { 324 329 imx2_wdt_set_timeout(wdog, wdog->timeout); ··· 373 366 imx2_wdt_ping(wdog); 374 367 } 375 368 376 - clk_disable_unprepare(wdev->clk); 369 + if (wdev->no_ping) { 370 + clk_disable_unprepare(wdev->clk); 377 371 378 - wdev->clk_is_on = false; 372 + wdev->clk_is_on = false; 373 + } 379 374 380 375 return 0; 381 376 } ··· 389 380 struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); 390 381 int ret; 391 382 392 - ret = clk_prepare_enable(wdev->clk); 393 - if (ret) 394 - return ret; 383 + if (wdev->no_ping) { 384 + ret = clk_prepare_enable(wdev->clk); 395 385 396 - wdev->clk_is_on = true; 386 + if (ret) 387 + return ret; 388 + 389 + wdev->clk_is_on = true; 390 + } 397 391 398 392 if (watchdog_active(wdog) && !imx2_wdt_is_running(wdev)) { 399 393 /* ··· 419 407 420 408 static const struct of_device_id imx2_wdt_dt_ids[] = { 421 409 { .compatible = "fsl,imx21-wdt", }, 410 + { .compatible = "fsl,imx7d-wdt", }, 422 411 { /* sentinel */ } 423 412 }; 424 413 MODULE_DEVICE_TABLE(of, imx2_wdt_dt_ids);
+14
drivers/watchdog/ixp4xx_wdt.c
··· 84 84 return 0; 85 85 } 86 86 87 + static int ixp4xx_wdt_restart(struct watchdog_device *wdd, 88 + unsigned long action, void *data) 89 + { 90 + struct ixp4xx_wdt *iwdt = to_ixp4xx_wdt(wdd); 91 + 92 + __raw_writel(IXP4XX_WDT_KEY, iwdt->base + IXP4XX_OSWK_OFFSET); 93 + __raw_writel(0, iwdt->base + IXP4XX_OSWT_OFFSET); 94 + __raw_writel(IXP4XX_WDT_COUNT_ENABLE | IXP4XX_WDT_RESET_ENABLE, 95 + iwdt->base + IXP4XX_OSWE_OFFSET); 96 + 97 + return 0; 98 + } 99 + 87 100 static const struct watchdog_ops ixp4xx_wdt_ops = { 88 101 .start = ixp4xx_wdt_start, 89 102 .stop = ixp4xx_wdt_stop, 90 103 .set_timeout = ixp4xx_wdt_set_timeout, 104 + .restart = ixp4xx_wdt_restart, 91 105 .owner = THIS_MODULE, 92 106 }; 93 107
+9 -4
drivers/watchdog/orion_wdt.c
··· 238 238 atomic_io_modify(dev->reg + TIMER_A370_STATUS, WDT_A370_EXPIRED, 0); 239 239 240 240 /* Enable watchdog timer */ 241 - atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, 242 - dev->data->wdt_enable_bit); 241 + reg = dev->data->wdt_enable_bit; 242 + if (dev->wdt.info->options & WDIOF_PRETIMEOUT) 243 + reg |= TIMER1_ENABLE_BIT; 244 + atomic_io_modify(dev->reg + TIMER_CTRL, reg, reg); 243 245 244 246 /* Enable reset on watchdog */ 245 247 reg = readl(dev->rstout); ··· 314 312 static int armada370_stop(struct watchdog_device *wdt_dev) 315 313 { 316 314 struct orion_watchdog *dev = watchdog_get_drvdata(wdt_dev); 317 - u32 reg; 315 + u32 reg, mask; 318 316 319 317 /* Disable reset on watchdog */ 320 318 reg = readl(dev->rstout); ··· 322 320 writel(reg, dev->rstout); 323 321 324 322 /* Disable watchdog timer */ 325 - atomic_io_modify(dev->reg + TIMER_CTRL, dev->data->wdt_enable_bit, 0); 323 + mask = dev->data->wdt_enable_bit; 324 + if (wdt_dev->info->options & WDIOF_PRETIMEOUT) 325 + mask |= TIMER1_ENABLE_BIT; 326 + atomic_io_modify(dev->reg + TIMER_CTRL, mask, 0); 326 327 327 328 return 0; 328 329 }
+1
drivers/watchdog/renesas_wdt.c
··· 327 327 static const struct of_device_id rwdt_ids[] = { 328 328 { .compatible = "renesas,rcar-gen2-wdt", }, 329 329 { .compatible = "renesas,rcar-gen3-wdt", }, 330 + { .compatible = "renesas,rcar-gen4-wdt", }, 330 331 { /* sentinel */ } 331 332 }; 332 333 MODULE_DEVICE_TABLE(of, rwdt_ids);
+1
drivers/watchdog/rti_wdt.c
··· 228 228 ret = pm_runtime_get_sync(dev); 229 229 if (ret) { 230 230 pm_runtime_put_noidle(dev); 231 + pm_runtime_disable(&pdev->dev); 231 232 return dev_err_probe(dev, ret, "runtime pm failed\n"); 232 233 } 233 234
+219 -115
drivers/watchdog/sp5100_tco.c
··· 49 49 /* internal variables */ 50 50 51 51 enum tco_reg_layout { 52 - sp5100, sb800, efch 52 + sp5100, sb800, efch, efch_mmio 53 53 }; 54 54 55 55 struct sp5100_tco { ··· 86 86 dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && 87 87 dev->revision < 0x40) { 88 88 return sp5100; 89 + } else if (dev->vendor == PCI_VENDOR_ID_AMD && 90 + sp5100_tco_pci->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS && 91 + sp5100_tco_pci->revision >= AMD_ZEN_SMBUS_PCI_REV) { 92 + return efch_mmio; 89 93 } else if (dev->vendor == PCI_VENDOR_ID_AMD && 90 94 ((dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS && 91 95 dev->revision >= 0x41) || ··· 213 209 ~EFCH_PM_WATCHDOG_DISABLE, 214 210 EFCH_PM_DECODEEN_SECOND_RES); 215 211 break; 212 + default: 213 + break; 216 214 } 217 215 } 218 216 ··· 229 223 return val; 230 224 } 231 225 226 + static u32 sp5100_tco_request_region(struct device *dev, 227 + u32 mmio_addr, 228 + const char *dev_name) 229 + { 230 + if (!devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE, 231 + dev_name)) { 232 + dev_dbg(dev, "MMIO address 0x%08x already in use\n", mmio_addr); 233 + return 0; 234 + } 235 + 236 + return mmio_addr; 237 + } 238 + 239 + static u32 sp5100_tco_prepare_base(struct sp5100_tco *tco, 240 + u32 mmio_addr, 241 + u32 alt_mmio_addr, 242 + const char *dev_name) 243 + { 244 + struct device *dev = tco->wdd.parent; 245 + 246 + dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", mmio_addr); 247 + 248 + if (!mmio_addr && !alt_mmio_addr) 249 + return -ENODEV; 250 + 251 + /* Check for MMIO address and alternate MMIO address conflicts */ 252 + if (mmio_addr) 253 + mmio_addr = sp5100_tco_request_region(dev, mmio_addr, dev_name); 254 + 255 + if (!mmio_addr && alt_mmio_addr) 256 + mmio_addr = sp5100_tco_request_region(dev, alt_mmio_addr, dev_name); 257 + 258 + if (!mmio_addr) { 259 + dev_err(dev, "Failed to reserve MMIO or alternate MMIO region\n"); 260 + return -EBUSY; 261 + } 262 + 263 + tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); 264 + if (!tco->tcobase) { 265 + dev_err(dev, "MMIO address 0x%08x failed mapping\n", mmio_addr); 266 + devm_release_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); 267 + return -ENOMEM; 268 + } 269 + 270 + dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", mmio_addr); 271 + 272 + return 0; 273 + } 274 + 275 + static int sp5100_tco_timer_init(struct sp5100_tco *tco) 276 + { 277 + struct watchdog_device *wdd = &tco->wdd; 278 + struct device *dev = wdd->parent; 279 + u32 val; 280 + 281 + val = readl(SP5100_WDT_CONTROL(tco->tcobase)); 282 + if (val & SP5100_WDT_DISABLED) { 283 + dev_err(dev, "Watchdog hardware is disabled\n"); 284 + return -ENODEV; 285 + } 286 + 287 + /* 288 + * Save WatchDogFired status, because WatchDogFired flag is 289 + * cleared here. 290 + */ 291 + if (val & SP5100_WDT_FIRED) 292 + wdd->bootstatus = WDIOF_CARDRESET; 293 + 294 + /* Set watchdog action to reset the system */ 295 + val &= ~SP5100_WDT_ACTION_RESET; 296 + writel(val, SP5100_WDT_CONTROL(tco->tcobase)); 297 + 298 + /* Set a reasonable heartbeat before we stop the timer */ 299 + tco_timer_set_timeout(wdd, wdd->timeout); 300 + 301 + /* 302 + * Stop the TCO before we change anything so we don't race with 303 + * a zeroed timer. 304 + */ 305 + tco_timer_stop(wdd); 306 + 307 + return 0; 308 + } 309 + 310 + static u8 efch_read_pm_reg8(void __iomem *addr, u8 index) 311 + { 312 + return readb(addr + index); 313 + } 314 + 315 + static void efch_update_pm_reg8(void __iomem *addr, u8 index, u8 reset, u8 set) 316 + { 317 + u8 val; 318 + 319 + val = readb(addr + index); 320 + val &= reset; 321 + val |= set; 322 + writeb(val, addr + index); 323 + } 324 + 325 + static void tco_timer_enable_mmio(void __iomem *addr) 326 + { 327 + efch_update_pm_reg8(addr, EFCH_PM_DECODEEN3, 328 + ~EFCH_PM_WATCHDOG_DISABLE, 329 + EFCH_PM_DECODEEN_SECOND_RES); 330 + } 331 + 332 + static int sp5100_tco_setupdevice_mmio(struct device *dev, 333 + struct watchdog_device *wdd) 334 + { 335 + struct sp5100_tco *tco = watchdog_get_drvdata(wdd); 336 + const char *dev_name = SB800_DEVNAME; 337 + u32 mmio_addr = 0, alt_mmio_addr = 0; 338 + struct resource *res; 339 + void __iomem *addr; 340 + int ret; 341 + u32 val; 342 + 343 + res = request_mem_region_muxed(EFCH_PM_ACPI_MMIO_PM_ADDR, 344 + EFCH_PM_ACPI_MMIO_PM_SIZE, 345 + "sp5100_tco"); 346 + 347 + if (!res) { 348 + dev_err(dev, 349 + "Memory region 0x%08x already in use\n", 350 + EFCH_PM_ACPI_MMIO_PM_ADDR); 351 + return -EBUSY; 352 + } 353 + 354 + addr = ioremap(EFCH_PM_ACPI_MMIO_PM_ADDR, EFCH_PM_ACPI_MMIO_PM_SIZE); 355 + if (!addr) { 356 + dev_err(dev, "Address mapping failed\n"); 357 + ret = -ENOMEM; 358 + goto out; 359 + } 360 + 361 + /* 362 + * EFCH_PM_DECODEEN_WDT_TMREN is dual purpose. This bitfield 363 + * enables sp5100_tco register MMIO space decoding. The bitfield 364 + * also starts the timer operation. Enable if not already enabled. 365 + */ 366 + val = efch_read_pm_reg8(addr, EFCH_PM_DECODEEN); 367 + if (!(val & EFCH_PM_DECODEEN_WDT_TMREN)) { 368 + efch_update_pm_reg8(addr, EFCH_PM_DECODEEN, 0xff, 369 + EFCH_PM_DECODEEN_WDT_TMREN); 370 + } 371 + 372 + /* Error if the timer could not be enabled */ 373 + val = efch_read_pm_reg8(addr, EFCH_PM_DECODEEN); 374 + if (!(val & EFCH_PM_DECODEEN_WDT_TMREN)) { 375 + dev_err(dev, "Failed to enable the timer\n"); 376 + ret = -EFAULT; 377 + goto out; 378 + } 379 + 380 + mmio_addr = EFCH_PM_WDT_ADDR; 381 + 382 + /* Determine alternate MMIO base address */ 383 + val = efch_read_pm_reg8(addr, EFCH_PM_ISACONTROL); 384 + if (val & EFCH_PM_ISACONTROL_MMIOEN) 385 + alt_mmio_addr = EFCH_PM_ACPI_MMIO_ADDR + 386 + EFCH_PM_ACPI_MMIO_WDT_OFFSET; 387 + 388 + ret = sp5100_tco_prepare_base(tco, mmio_addr, alt_mmio_addr, dev_name); 389 + if (!ret) { 390 + tco_timer_enable_mmio(addr); 391 + ret = sp5100_tco_timer_init(tco); 392 + } 393 + 394 + out: 395 + if (addr) 396 + iounmap(addr); 397 + 398 + release_resource(res); 399 + 400 + return ret; 401 + } 402 + 232 403 static int sp5100_tco_setupdevice(struct device *dev, 233 404 struct watchdog_device *wdd) 234 405 { 235 406 struct sp5100_tco *tco = watchdog_get_drvdata(wdd); 236 407 const char *dev_name; 237 408 u32 mmio_addr = 0, val; 409 + u32 alt_mmio_addr = 0; 238 410 int ret; 411 + 412 + if (tco->tco_reg_layout == efch_mmio) 413 + return sp5100_tco_setupdevice_mmio(dev, wdd); 239 414 240 415 /* Request the IO ports used by this driver */ 241 416 if (!request_muxed_region(SP5100_IO_PM_INDEX_REG, ··· 434 247 dev_name = SP5100_DEVNAME; 435 248 mmio_addr = sp5100_tco_read_pm_reg32(SP5100_PM_WATCHDOG_BASE) & 436 249 0xfffffff8; 250 + 251 + /* 252 + * Secondly, find the watchdog timer MMIO address 253 + * from SBResource_MMIO register. 254 + */ 255 + 256 + /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */ 257 + pci_read_config_dword(sp5100_tco_pci, 258 + SP5100_SB_RESOURCE_MMIO_BASE, 259 + &val); 260 + 261 + /* Verify MMIO is enabled and using bar0 */ 262 + if ((val & SB800_ACPI_MMIO_MASK) == SB800_ACPI_MMIO_DECODE_EN) 263 + alt_mmio_addr = (val & ~0xfff) + SB800_PM_WDT_MMIO_OFFSET; 437 264 break; 438 265 case sb800: 439 266 dev_name = SB800_DEVNAME; 440 267 mmio_addr = sp5100_tco_read_pm_reg32(SB800_PM_WATCHDOG_BASE) & 441 268 0xfffffff8; 269 + 270 + /* Read SBResource_MMIO from AcpiMmioEn(PM_Reg: 24h) */ 271 + val = sp5100_tco_read_pm_reg32(SB800_PM_ACPI_MMIO_EN); 272 + 273 + /* Verify MMIO is enabled and using bar0 */ 274 + if ((val & SB800_ACPI_MMIO_MASK) == SB800_ACPI_MMIO_DECODE_EN) 275 + alt_mmio_addr = (val & ~0xfff) + SB800_PM_WDT_MMIO_OFFSET; 442 276 break; 443 277 case efch: 444 278 dev_name = SB800_DEVNAME; 445 - /* 446 - * On Family 17h devices, the EFCH_PM_DECODEEN_WDT_TMREN bit of 447 - * EFCH_PM_DECODEEN not only enables the EFCH_PM_WDT_ADDR memory 448 - * region, it also enables the watchdog itself. 449 - */ 450 - if (boot_cpu_data.x86 == 0x17) { 451 - val = sp5100_tco_read_pm_reg8(EFCH_PM_DECODEEN); 452 - if (!(val & EFCH_PM_DECODEEN_WDT_TMREN)) { 453 - sp5100_tco_update_pm_reg8(EFCH_PM_DECODEEN, 0xff, 454 - EFCH_PM_DECODEEN_WDT_TMREN); 455 - } 456 - } 457 279 val = sp5100_tco_read_pm_reg8(EFCH_PM_DECODEEN); 458 280 if (val & EFCH_PM_DECODEEN_WDT_TMREN) 459 281 mmio_addr = EFCH_PM_WDT_ADDR; 282 + 283 + val = sp5100_tco_read_pm_reg8(EFCH_PM_ISACONTROL); 284 + if (val & EFCH_PM_ISACONTROL_MMIOEN) 285 + alt_mmio_addr = EFCH_PM_ACPI_MMIO_ADDR + 286 + EFCH_PM_ACPI_MMIO_WDT_OFFSET; 460 287 break; 461 288 default: 462 289 return -ENODEV; 463 290 } 464 291 465 - /* Check MMIO address conflict */ 466 - if (!mmio_addr || 467 - !devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE, 468 - dev_name)) { 469 - if (mmio_addr) 470 - dev_dbg(dev, "MMIO address 0x%08x already in use\n", 471 - mmio_addr); 472 - switch (tco->tco_reg_layout) { 473 - case sp5100: 474 - /* 475 - * Secondly, Find the watchdog timer MMIO address 476 - * from SBResource_MMIO register. 477 - */ 478 - /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */ 479 - pci_read_config_dword(sp5100_tco_pci, 480 - SP5100_SB_RESOURCE_MMIO_BASE, 481 - &mmio_addr); 482 - if ((mmio_addr & (SB800_ACPI_MMIO_DECODE_EN | 483 - SB800_ACPI_MMIO_SEL)) != 484 - SB800_ACPI_MMIO_DECODE_EN) { 485 - ret = -ENODEV; 486 - goto unreg_region; 487 - } 488 - mmio_addr &= ~0xFFF; 489 - mmio_addr += SB800_PM_WDT_MMIO_OFFSET; 490 - break; 491 - case sb800: 492 - /* Read SBResource_MMIO from AcpiMmioEn(PM_Reg: 24h) */ 493 - mmio_addr = 494 - sp5100_tco_read_pm_reg32(SB800_PM_ACPI_MMIO_EN); 495 - if ((mmio_addr & (SB800_ACPI_MMIO_DECODE_EN | 496 - SB800_ACPI_MMIO_SEL)) != 497 - SB800_ACPI_MMIO_DECODE_EN) { 498 - ret = -ENODEV; 499 - goto unreg_region; 500 - } 501 - mmio_addr &= ~0xFFF; 502 - mmio_addr += SB800_PM_WDT_MMIO_OFFSET; 503 - break; 504 - case efch: 505 - val = sp5100_tco_read_pm_reg8(EFCH_PM_ISACONTROL); 506 - if (!(val & EFCH_PM_ISACONTROL_MMIOEN)) { 507 - ret = -ENODEV; 508 - goto unreg_region; 509 - } 510 - mmio_addr = EFCH_PM_ACPI_MMIO_ADDR + 511 - EFCH_PM_ACPI_MMIO_WDT_OFFSET; 512 - break; 513 - } 514 - dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", 515 - mmio_addr); 516 - if (!devm_request_mem_region(dev, mmio_addr, 517 - SP5100_WDT_MEM_MAP_SIZE, 518 - dev_name)) { 519 - dev_dbg(dev, "MMIO address 0x%08x already in use\n", 520 - mmio_addr); 521 - ret = -EBUSY; 522 - goto unreg_region; 523 - } 292 + ret = sp5100_tco_prepare_base(tco, mmio_addr, alt_mmio_addr, dev_name); 293 + if (!ret) { 294 + /* Setup the watchdog timer */ 295 + tco_timer_enable(tco); 296 + ret = sp5100_tco_timer_init(tco); 524 297 } 525 298 526 - tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE); 527 - if (!tco->tcobase) { 528 - dev_err(dev, "failed to get tcobase address\n"); 529 - ret = -ENOMEM; 530 - goto unreg_region; 531 - } 532 - 533 - dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", mmio_addr); 534 - 535 - /* Setup the watchdog timer */ 536 - tco_timer_enable(tco); 537 - 538 - val = readl(SP5100_WDT_CONTROL(tco->tcobase)); 539 - if (val & SP5100_WDT_DISABLED) { 540 - dev_err(dev, "Watchdog hardware is disabled\n"); 541 - ret = -ENODEV; 542 - goto unreg_region; 543 - } 544 - 545 - /* 546 - * Save WatchDogFired status, because WatchDogFired flag is 547 - * cleared here. 548 - */ 549 - if (val & SP5100_WDT_FIRED) 550 - wdd->bootstatus = WDIOF_CARDRESET; 551 - /* Set watchdog action to reset the system */ 552 - val &= ~SP5100_WDT_ACTION_RESET; 553 - writel(val, SP5100_WDT_CONTROL(tco->tcobase)); 554 - 555 - /* Set a reasonable heartbeat before we stop the timer */ 556 - tco_timer_set_timeout(wdd, wdd->timeout); 557 - 558 - /* 559 - * Stop the TCO before we change anything so we don't race with 560 - * a zeroed timer. 561 - */ 562 - tco_timer_stop(wdd); 563 - 564 - release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE); 565 - 566 - return 0; 567 - 568 - unreg_region: 569 299 release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE); 570 300 return ret; 571 301 }
+7
drivers/watchdog/sp5100_tco.h
··· 58 58 #define SB800_PM_WATCHDOG_SECOND_RES GENMASK(1, 0) 59 59 #define SB800_ACPI_MMIO_DECODE_EN BIT(0) 60 60 #define SB800_ACPI_MMIO_SEL BIT(1) 61 + #define SB800_ACPI_MMIO_MASK GENMASK(1, 0) 61 62 62 63 #define SB800_PM_WDT_MMIO_OFFSET 0xB00 63 64 ··· 83 82 #define EFCH_PM_ISACONTROL_MMIOEN BIT(1) 84 83 85 84 #define EFCH_PM_ACPI_MMIO_ADDR 0xfed80000 85 + #define EFCH_PM_ACPI_MMIO_PM_OFFSET 0x00000300 86 86 #define EFCH_PM_ACPI_MMIO_WDT_OFFSET 0x00000b00 87 + 88 + #define EFCH_PM_ACPI_MMIO_PM_ADDR (EFCH_PM_ACPI_MMIO_ADDR + \ 89 + EFCH_PM_ACPI_MMIO_PM_OFFSET) 90 + #define EFCH_PM_ACPI_MMIO_PM_SIZE 8 91 + #define AMD_ZEN_SMBUS_PCI_REV 0x51
+125 -119
drivers/watchdog/watchdog_dev.c
··· 171 171 } 172 172 173 173 /* 174 - * watchdog_ping: ping the watchdog. 175 - * @wdd: the watchdog device to ping 174 + * watchdog_ping - ping the watchdog 175 + * @wdd: The watchdog device to ping 176 176 * 177 - * The caller must hold wd_data->lock. 177 + * If the watchdog has no own ping operation then it needs to be 178 + * restarted via the start operation. This wrapper function does 179 + * exactly that. 180 + * We only ping when the watchdog device is running. 181 + * The caller must hold wd_data->lock. 178 182 * 179 - * If the watchdog has no own ping operation then it needs to be 180 - * restarted via the start operation. This wrapper function does 181 - * exactly that. 182 - * We only ping when the watchdog device is running. 183 + * Return: 0 on success, error otherwise. 183 184 */ 184 - 185 185 static int watchdog_ping(struct watchdog_device *wdd) 186 186 { 187 187 struct watchdog_core_data *wd_data = wdd->wd_data; ··· 231 231 } 232 232 233 233 /* 234 - * watchdog_start: wrapper to start the watchdog. 235 - * @wdd: the watchdog device to start 234 + * watchdog_start - wrapper to start the watchdog 235 + * @wdd: The watchdog device to start 236 236 * 237 - * The caller must hold wd_data->lock. 237 + * Start the watchdog if it is not active and mark it active. 238 + * The caller must hold wd_data->lock. 238 239 * 239 - * Start the watchdog if it is not active and mark it active. 240 - * This function returns zero on success or a negative errno code for 241 - * failure. 240 + * Return: 0 on success or a negative errno code for failure. 242 241 */ 243 - 244 242 static int watchdog_start(struct watchdog_device *wdd) 245 243 { 246 244 struct watchdog_core_data *wd_data = wdd->wd_data; ··· 272 274 } 273 275 274 276 /* 275 - * watchdog_stop: wrapper to stop the watchdog. 276 - * @wdd: the watchdog device to stop 277 + * watchdog_stop - wrapper to stop the watchdog 278 + * @wdd: The watchdog device to stop 277 279 * 278 - * The caller must hold wd_data->lock. 280 + * Stop the watchdog if it is still active and unmark it active. 281 + * If the 'nowayout' feature was set, the watchdog cannot be stopped. 282 + * The caller must hold wd_data->lock. 279 283 * 280 - * Stop the watchdog if it is still active and unmark it active. 281 - * This function returns zero on success or a negative errno code for 282 - * failure. 283 - * If the 'nowayout' feature was set, the watchdog cannot be stopped. 284 + * Return: 0 on success or a negative errno code for failure. 284 285 */ 285 - 286 286 static int watchdog_stop(struct watchdog_device *wdd) 287 287 { 288 288 int err = 0; ··· 311 315 } 312 316 313 317 /* 314 - * watchdog_get_status: wrapper to get the watchdog status 315 - * @wdd: the watchdog device to get the status from 318 + * watchdog_get_status - wrapper to get the watchdog status 319 + * @wdd: The watchdog device to get the status from 316 320 * 317 - * The caller must hold wd_data->lock. 321 + * Get the watchdog's status flags. 322 + * The caller must hold wd_data->lock. 318 323 * 319 - * Get the watchdog's status flags. 324 + * Return: watchdog's status flags. 320 325 */ 321 - 322 326 static unsigned int watchdog_get_status(struct watchdog_device *wdd) 323 327 { 324 328 struct watchdog_core_data *wd_data = wdd->wd_data; ··· 348 352 } 349 353 350 354 /* 351 - * watchdog_set_timeout: set the watchdog timer timeout 352 - * @wdd: the watchdog device to set the timeout for 353 - * @timeout: timeout to set in seconds 355 + * watchdog_set_timeout - set the watchdog timer timeout 356 + * @wdd: The watchdog device to set the timeout for 357 + * @timeout: Timeout to set in seconds 354 358 * 355 - * The caller must hold wd_data->lock. 359 + * The caller must hold wd_data->lock. 360 + * 361 + * Return: 0 if successful, error otherwise. 356 362 */ 357 - 358 363 static int watchdog_set_timeout(struct watchdog_device *wdd, 359 364 unsigned int timeout) 360 365 { ··· 382 385 } 383 386 384 387 /* 385 - * watchdog_set_pretimeout: set the watchdog timer pretimeout 386 - * @wdd: the watchdog device to set the timeout for 387 - * @timeout: pretimeout to set in seconds 388 + * watchdog_set_pretimeout - set the watchdog timer pretimeout 389 + * @wdd: The watchdog device to set the timeout for 390 + * @timeout: pretimeout to set in seconds 391 + * 392 + * Return: 0 if successful, error otherwise. 388 393 */ 389 - 390 394 static int watchdog_set_pretimeout(struct watchdog_device *wdd, 391 395 unsigned int timeout) 392 396 { ··· 408 410 } 409 411 410 412 /* 411 - * watchdog_get_timeleft: wrapper to get the time left before a reboot 412 - * @wdd: the watchdog device to get the remaining time from 413 - * @timeleft: the time that's left 413 + * watchdog_get_timeleft - wrapper to get the time left before a reboot 414 + * @wdd: The watchdog device to get the remaining time from 415 + * @timeleft: The time that's left 414 416 * 415 - * The caller must hold wd_data->lock. 417 + * Get the time before a watchdog will reboot (if not pinged). 418 + * The caller must hold wd_data->lock. 416 419 * 417 - * Get the time before a watchdog will reboot (if not pinged). 420 + * Return: 0 if successful, error otherwise. 418 421 */ 419 - 420 422 static int watchdog_get_timeleft(struct watchdog_device *wdd, 421 423 unsigned int *timeleft) 422 424 { ··· 633 635 #endif 634 636 635 637 /* 636 - * watchdog_ioctl_op: call the watchdog drivers ioctl op if defined 637 - * @wdd: the watchdog device to do the ioctl on 638 - * @cmd: watchdog command 639 - * @arg: argument pointer 638 + * watchdog_ioctl_op - call the watchdog drivers ioctl op if defined 639 + * @wdd: The watchdog device to do the ioctl on 640 + * @cmd: Watchdog command 641 + * @arg: Argument pointer 640 642 * 641 - * The caller must hold wd_data->lock. 643 + * The caller must hold wd_data->lock. 644 + * 645 + * Return: 0 if successful, error otherwise. 642 646 */ 643 - 644 647 static int watchdog_ioctl_op(struct watchdog_device *wdd, unsigned int cmd, 645 648 unsigned long arg) 646 649 { ··· 652 653 } 653 654 654 655 /* 655 - * watchdog_write: writes to the watchdog. 656 - * @file: file from VFS 657 - * @data: user address of data 658 - * @len: length of data 659 - * @ppos: pointer to the file offset 656 + * watchdog_write - writes to the watchdog 657 + * @file: File from VFS 658 + * @data: User address of data 659 + * @len: Length of data 660 + * @ppos: Pointer to the file offset 660 661 * 661 - * A write to a watchdog device is defined as a keepalive ping. 662 - * Writing the magic 'V' sequence allows the next close to turn 663 - * off the watchdog (if 'nowayout' is not set). 662 + * A write to a watchdog device is defined as a keepalive ping. 663 + * Writing the magic 'V' sequence allows the next close to turn 664 + * off the watchdog (if 'nowayout' is not set). 665 + * 666 + * Return: @len if successful, error otherwise. 664 667 */ 665 - 666 668 static ssize_t watchdog_write(struct file *file, const char __user *data, 667 669 size_t len, loff_t *ppos) 668 670 { ··· 706 706 } 707 707 708 708 /* 709 - * watchdog_ioctl: handle the different ioctl's for the watchdog device. 710 - * @file: file handle to the device 711 - * @cmd: watchdog command 712 - * @arg: argument pointer 709 + * watchdog_ioctl - handle the different ioctl's for the watchdog device 710 + * @file: File handle to the device 711 + * @cmd: Watchdog command 712 + * @arg: Argument pointer 713 713 * 714 - * The watchdog API defines a common set of functions for all watchdogs 715 - * according to their available features. 714 + * The watchdog API defines a common set of functions for all watchdogs 715 + * according to their available features. 716 + * 717 + * Return: 0 if successful, error otherwise. 716 718 */ 717 719 718 720 static long watchdog_ioctl(struct file *file, unsigned int cmd, ··· 821 819 } 822 820 823 821 /* 824 - * watchdog_open: open the /dev/watchdog* devices. 825 - * @inode: inode of device 826 - * @file: file handle to device 822 + * watchdog_open - open the /dev/watchdog* devices 823 + * @inode: Inode of device 824 + * @file: File handle to device 827 825 * 828 - * When the /dev/watchdog* device gets opened, we start the watchdog. 829 - * Watch out: the /dev/watchdog device is single open, so we make sure 830 - * it can only be opened once. 826 + * When the /dev/watchdog* device gets opened, we start the watchdog. 827 + * Watch out: the /dev/watchdog device is single open, so we make sure 828 + * it can only be opened once. 829 + * 830 + * Return: 0 if successful, error otherwise. 831 831 */ 832 - 833 832 static int watchdog_open(struct inode *inode, struct file *file) 834 833 { 835 834 struct watchdog_core_data *wd_data; ··· 899 896 } 900 897 901 898 /* 902 - * watchdog_release: release the watchdog device. 903 - * @inode: inode of device 904 - * @file: file handle to device 899 + * watchdog_release - release the watchdog device 900 + * @inode: Inode of device 901 + * @file: File handle to device 905 902 * 906 - * This is the code for when /dev/watchdog gets closed. We will only 907 - * stop the watchdog when we have received the magic char (and nowayout 908 - * was not set), else the watchdog will keep running. 903 + * This is the code for when /dev/watchdog gets closed. We will only 904 + * stop the watchdog when we have received the magic char (and nowayout 905 + * was not set), else the watchdog will keep running. 906 + * 907 + * Always returns 0. 909 908 */ 910 - 911 909 static int watchdog_release(struct inode *inode, struct file *file) 912 910 { 913 911 struct watchdog_core_data *wd_data = file->private_data; ··· 981 977 }; 982 978 983 979 /* 984 - * watchdog_cdev_register: register watchdog character device 985 - * @wdd: watchdog device 980 + * watchdog_cdev_register - register watchdog character device 981 + * @wdd: Watchdog device 986 982 * 987 - * Register a watchdog character device including handling the legacy 988 - * /dev/watchdog node. /dev/watchdog is actually a miscdevice and 989 - * thus we set it up like that. 983 + * Register a watchdog character device including handling the legacy 984 + * /dev/watchdog node. /dev/watchdog is actually a miscdevice and 985 + * thus we set it up like that. 986 + * 987 + * Return: 0 if successful, error otherwise. 990 988 */ 991 - 992 989 static int watchdog_cdev_register(struct watchdog_device *wdd) 993 990 { 994 991 struct watchdog_core_data *wd_data; ··· 1079 1074 } 1080 1075 1081 1076 /* 1082 - * watchdog_cdev_unregister: unregister watchdog character device 1083 - * @watchdog: watchdog device 1077 + * watchdog_cdev_unregister - unregister watchdog character device 1078 + * @wdd: Watchdog device 1084 1079 * 1085 - * Unregister watchdog character device and if needed the legacy 1086 - * /dev/watchdog device. 1080 + * Unregister watchdog character device and if needed the legacy 1081 + * /dev/watchdog device. 1087 1082 */ 1088 - 1089 1083 static void watchdog_cdev_unregister(struct watchdog_device *wdd) 1090 1084 { 1091 1085 struct watchdog_core_data *wd_data = wdd->wd_data; ··· 1113 1109 put_device(&wd_data->dev); 1114 1110 } 1115 1111 1116 - /* 1117 - * watchdog_dev_register: register a watchdog device 1118 - * @wdd: watchdog device 1112 + /** 1113 + * watchdog_dev_register - register a watchdog device 1114 + * @wdd: Watchdog device 1119 1115 * 1120 - * Register a watchdog device including handling the legacy 1121 - * /dev/watchdog node. /dev/watchdog is actually a miscdevice and 1122 - * thus we set it up like that. 1116 + * Register a watchdog device including handling the legacy 1117 + * /dev/watchdog node. /dev/watchdog is actually a miscdevice and 1118 + * thus we set it up like that. 1119 + * 1120 + * Return: 0 if successful, error otherwise. 1123 1121 */ 1124 - 1125 1122 int watchdog_dev_register(struct watchdog_device *wdd) 1126 1123 { 1127 1124 int ret; ··· 1138 1133 return ret; 1139 1134 } 1140 1135 1141 - /* 1142 - * watchdog_dev_unregister: unregister a watchdog device 1143 - * @watchdog: watchdog device 1136 + /** 1137 + * watchdog_dev_unregister - unregister a watchdog device 1138 + * @wdd: watchdog device 1144 1139 * 1145 - * Unregister watchdog device and if needed the legacy 1146 - * /dev/watchdog device. 1140 + * Unregister watchdog device and if needed the legacy 1141 + * /dev/watchdog device. 1147 1142 */ 1148 - 1149 1143 void watchdog_dev_unregister(struct watchdog_device *wdd) 1150 1144 { 1151 1145 watchdog_unregister_pretimeout(wdd); 1152 1146 watchdog_cdev_unregister(wdd); 1153 1147 } 1154 1148 1155 - /* 1156 - * watchdog_set_last_hw_keepalive: set last HW keepalive time for watchdog 1157 - * @wdd: watchdog device 1158 - * @last_ping_ms: time since last HW heartbeat 1149 + /** 1150 + * watchdog_set_last_hw_keepalive - set last HW keepalive time for watchdog 1151 + * @wdd: Watchdog device 1152 + * @last_ping_ms: Time since last HW heartbeat 1159 1153 * 1160 - * Adjusts the last known HW keepalive time for a watchdog timer. 1161 - * This is needed if the watchdog is already running when the probe 1162 - * function is called, and it can't be pinged immediately. This 1163 - * function must be called immediately after watchdog registration, 1164 - * and min_hw_heartbeat_ms must be set for this to be useful. 1154 + * Adjusts the last known HW keepalive time for a watchdog timer. 1155 + * This is needed if the watchdog is already running when the probe 1156 + * function is called, and it can't be pinged immediately. This 1157 + * function must be called immediately after watchdog registration, 1158 + * and min_hw_heartbeat_ms must be set for this to be useful. 1159 + * 1160 + * Return: 0 if successful, error otherwise. 1165 1161 */ 1166 1162 int watchdog_set_last_hw_keepalive(struct watchdog_device *wdd, 1167 1163 unsigned int last_ping_ms) ··· 1186 1180 } 1187 1181 EXPORT_SYMBOL_GPL(watchdog_set_last_hw_keepalive); 1188 1182 1189 - /* 1190 - * watchdog_dev_init: init dev part of watchdog core 1183 + /** 1184 + * watchdog_dev_init - init dev part of watchdog core 1191 1185 * 1192 - * Allocate a range of chardev nodes to use for watchdog devices 1186 + * Allocate a range of chardev nodes to use for watchdog devices. 1187 + * 1188 + * Return: 0 if successful, error otherwise. 1193 1189 */ 1194 - 1195 1190 int __init watchdog_dev_init(void) 1196 1191 { 1197 1192 int err; ··· 1225 1218 return err; 1226 1219 } 1227 1220 1228 - /* 1229 - * watchdog_dev_exit: exit dev part of watchdog core 1221 + /** 1222 + * watchdog_dev_exit - exit dev part of watchdog core 1230 1223 * 1231 - * Release the range of chardev nodes used for watchdog devices 1224 + * Release the range of chardev nodes used for watchdog devices. 1232 1225 */ 1233 - 1234 1226 void __exit watchdog_dev_exit(void) 1235 1227 { 1236 1228 unregister_chrdev_region(watchdog_devt, MAX_DOGS);