static int rt288x_wdt_probe(struct platform_device *pdev) { struct resource *res; int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); rt288x_wdt_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(rt288x_wdt_base)) return PTR_ERR(rt288x_wdt_base); rt288x_wdt_clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(rt288x_wdt_clk)) return PTR_ERR(rt288x_wdt_clk); rt288x_wdt_reset = devm_reset_control_get(&pdev->dev, NULL); if (!IS_ERR(rt288x_wdt_reset)) reset_control_deassert(rt288x_wdt_reset); rt288x_wdt_freq = clk_get_rate(rt288x_wdt_clk) / RALINK_WDT_PRESCALE; rt288x_wdt_dev.bootstatus = rt288x_wdt_bootcause(); rt288x_wdt_dev.max_timeout = (0xfffful / rt288x_wdt_freq); rt288x_wdt_dev.parent = &pdev->dev; watchdog_init_timeout(&rt288x_wdt_dev, rt288x_wdt_dev.max_timeout, &pdev->dev); watchdog_set_nowayout(&rt288x_wdt_dev, nowayout); ret = watchdog_register_device(&rt288x_wdt_dev); if (!ret) dev_info(&pdev->dev, "Initialized\n"); return 0; }
static int __devinit max63xx_wdt_probe(struct platform_device *pdev) { struct resource *wdt_mem; struct max63xx_timeout *table; table = (struct max63xx_timeout *)pdev->id_entry->driver_data; if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) heartbeat = DEFAULT_HEARTBEAT; dev_info(&pdev->dev, "requesting %ds heartbeat\n", heartbeat); current_timeout = max63xx_select_timeout(table, heartbeat); if (!current_timeout) { dev_err(&pdev->dev, "unable to satisfy heartbeat request\n"); return -EINVAL; } dev_info(&pdev->dev, "using %ds heartbeat with %ds initial delay\n", current_timeout->twd, current_timeout->tdelay); heartbeat = current_timeout->twd; wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdt_base = devm_request_and_ioremap(&pdev->dev, wdt_mem); if (!wdt_base) return -ENOMEM; max63xx_wdt_dev.timeout = heartbeat; watchdog_set_nowayout(&max63xx_wdt_dev, nowayout); watchdog_set_drvdata(&max63xx_wdt_dev, current_timeout); return watchdog_register_device(&max63xx_wdt_dev); }
static int twl4030_wdt_probe(struct platform_device *pdev) { int ret = 0; struct watchdog_device *wdt; wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; wdt->info = &twl4030_wdt_info; wdt->ops = &twl4030_wdt_ops; wdt->status = 0; wdt->timeout = 30; wdt->min_timeout = 1; wdt->max_timeout = 30; watchdog_set_nowayout(wdt, nowayout); platform_set_drvdata(pdev, wdt); twl4030_wdt_stop(wdt); ret = watchdog_register_device(wdt); if (ret) { platform_set_drvdata(pdev, NULL); return ret; } return 0; }
static int rn5t618_wdt_probe(struct platform_device *pdev) { struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); struct rn5t618_wdt *wdt; int min_timeout, max_timeout; wdt = devm_kzalloc(&pdev->dev, sizeof(struct rn5t618_wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; min_timeout = rn5t618_wdt_map[0].time; max_timeout = rn5t618_wdt_map[ARRAY_SIZE(rn5t618_wdt_map) - 1].time; wdt->rn5t618 = rn5t618; wdt->wdt_dev.info = &rn5t618_wdt_info; wdt->wdt_dev.ops = &rn5t618_wdt_ops; wdt->wdt_dev.min_timeout = min_timeout; wdt->wdt_dev.max_timeout = max_timeout; wdt->wdt_dev.timeout = max_timeout; wdt->wdt_dev.parent = &pdev->dev; watchdog_set_drvdata(&wdt->wdt_dev, wdt); watchdog_init_timeout(&wdt->wdt_dev, timeout, &pdev->dev); watchdog_set_nowayout(&wdt->wdt_dev, nowayout); platform_set_drvdata(pdev, wdt); return watchdog_register_device(&wdt->wdt_dev); }
static int moxart_wdt_probe(struct platform_device *pdev) { struct moxart_wdt_dev *moxart_wdt; struct device *dev = &pdev->dev; struct device_node *node = dev->of_node; struct resource *res; struct clk *clk; int err; unsigned int max_timeout; bool nowayout = WATCHDOG_NOWAYOUT; moxart_wdt = devm_kzalloc(dev, sizeof(*moxart_wdt), GFP_KERNEL); if (!moxart_wdt) return -ENOMEM; platform_set_drvdata(pdev, moxart_wdt); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); moxart_wdt->base = devm_ioremap_resource(dev, res); if (IS_ERR(moxart_wdt->base)) return PTR_ERR(moxart_wdt->base); clk = of_clk_get(node, 0); if (IS_ERR(clk)) { pr_err("%s: of_clk_get failed\n", __func__); return PTR_ERR(clk); } moxart_wdt->clock_frequency = clk_get_rate(clk); if (moxart_wdt->clock_frequency == 0) { pr_err("%s: incorrect clock frequency\n", __func__); return -EINVAL; } max_timeout = UINT_MAX / moxart_wdt->clock_frequency; moxart_wdt->dev.info = &moxart_wdt_info; moxart_wdt->dev.ops = &moxart_wdt_ops; moxart_wdt->dev.timeout = max_timeout; moxart_wdt->dev.min_timeout = 1; moxart_wdt->dev.max_timeout = max_timeout; moxart_wdt->dev.parent = dev; watchdog_init_timeout(&moxart_wdt->dev, heartbeat, dev); watchdog_set_nowayout(&moxart_wdt->dev, nowayout); watchdog_set_drvdata(&moxart_wdt->dev, moxart_wdt); err = watchdog_register_device(&moxart_wdt->dev); if (err) return err; moxart_restart_ctx = moxart_wdt; arm_pm_restart = moxart_wdt_restart; dev_dbg(dev, "Watchdog enabled (heartbeat=%d sec, nowayout=%d)\n", moxart_wdt->dev.timeout, nowayout); return 0; }
static int ux500_wdt_probe(struct platform_device *pdev) { int ret; struct ux500_wdt_data *pdata = dev_get_platdata(&pdev->dev); if (pdata) { if (pdata->timeout > 0) timeout = pdata->timeout; if (pdata->has_28_bits_resolution) ux500_wdt.max_timeout = WATCHDOG_MAX28; } watchdog_set_nowayout(&ux500_wdt, nowayout); /* disable auto off on sleep */ prcmu_config_a9wdog(PRCMU_WDOG_CPU1, false); /* set HW initial value */ prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); ret = watchdog_register_device(&ux500_wdt); if (ret) return ret; dev_info(&pdev->dev, "initialized\n"); return 0; }
static int sirfsoc_wdt_probe(struct platform_device *pdev) { struct resource *res; int ret; void __iomem *base; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(base)) return PTR_ERR(base); watchdog_set_drvdata(&sirfsoc_wdd, base); watchdog_init_timeout(&sirfsoc_wdd, timeout, &pdev->dev); watchdog_set_nowayout(&sirfsoc_wdd, nowayout); sirfsoc_wdd.parent = &pdev->dev; ret = watchdog_register_device(&sirfsoc_wdd); if (ret) return ret; platform_set_drvdata(pdev, &sirfsoc_wdd); return 0; }
static int __init wdt_init(void) { int ret; int chip; static const char * const chip_name[] = { "W83627HF", "W83627S", "W83697HF", "W83697UG", "W83637HF", "W83627THF", "W83687THF", "W83627EHF", "W83627DHG", "W83627UHG", "W83667HG", "W83667DHG-P", "W83667HG-B", "NCT6775", "NCT6776", "NCT6779", "NCT6791", "NCT6792", "NCT6793", "NCT6795", "NCT6102", }; wdt_io = 0x2e; chip = wdt_find(0x2e); if (chip < 0) { wdt_io = 0x4e; chip = wdt_find(0x4e); if (chip < 0) return chip; } pr_info("WDT driver for %s Super I/O chip initialising\n", chip_name[chip]); watchdog_init_timeout(&wdt_dev, timeout, NULL); watchdog_set_nowayout(&wdt_dev, nowayout); watchdog_stop_on_reboot(&wdt_dev); ret = w83627hf_init(&wdt_dev, chip); if (ret) { pr_err("failed to initialize watchdog (err=%d)\n", ret); return ret; } ret = watchdog_register_device(&wdt_dev); if (ret) return ret; pr_info("initialized. timeout=%d sec (nowayout=%d)\n", wdt_dev.timeout, nowayout); return ret; }
static int kempld_wdt_probe(struct platform_device *pdev) { struct kempld_device_data *pld = dev_get_drvdata(pdev->dev.parent); struct kempld_wdt_data *wdt_data; struct device *dev = &pdev->dev; struct watchdog_device *wdd; u8 status; int ret = 0; wdt_data = devm_kzalloc(dev, sizeof(*wdt_data), GFP_KERNEL); if (!wdt_data) return -ENOMEM; wdt_data->pld = pld; wdd = &wdt_data->wdd; wdd->parent = dev; kempld_get_mutex(pld); status = kempld_read8(pld, KEMPLD_WDT_CFG); kempld_release_mutex(pld); /* Enable nowayout if watchdog is already locked */ if (status & (KEMPLD_WDT_CFG_ENABLE_LOCK | KEMPLD_WDT_CFG_GLOBAL_LOCK)) { if (!nowayout) dev_warn(dev, "Forcing nowayout - watchdog lock enabled!\n"); nowayout = true; } wdd->info = &kempld_wdt_info; wdd->ops = &kempld_wdt_ops; watchdog_set_drvdata(wdd, wdt_data); watchdog_set_nowayout(wdd, nowayout); ret = kempld_wdt_probe_stages(wdd); if (ret) return ret; kempld_wdt_set_timeout(wdd, timeout); kempld_wdt_set_pretimeout(wdd, pretimeout); /* Check if watchdog is already enabled */ if (status & KEMPLD_WDT_CFG_ENABLE) { /* Get current watchdog settings */ kempld_wdt_update_timeouts(wdt_data); dev_info(dev, "Watchdog was already enabled\n"); } platform_set_drvdata(pdev, wdt_data); ret = watchdog_register_device(wdd); if (ret) return ret; dev_info(dev, "Watchdog registered with %ds timeout\n", wdd->timeout); return 0; }
static int ltq_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct ltq_wdt_priv *priv; struct watchdog_device *wdt; struct clk *clk; const struct ltq_wdt_hw *ltq_wdt_hw; int ret; u32 status; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; priv->membase = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(priv->membase)) return PTR_ERR(priv->membase); /* we do not need to enable the clock as it is always running */ clk = clk_get_io(); priv->clk_rate = clk_get_rate(clk) / LTQ_WDT_DIVIDER; if (!priv->clk_rate) { dev_err(dev, "clock rate less than divider %i\n", LTQ_WDT_DIVIDER); return -EINVAL; } wdt = &priv->wdt; wdt->info = <q_wdt_info; wdt->ops = <q_wdt_ops; wdt->min_timeout = 1; wdt->max_timeout = LTQ_WDT_CR_MAX_TIMEOUT / priv->clk_rate; wdt->timeout = wdt->max_timeout; wdt->parent = dev; ltq_wdt_hw = of_device_get_match_data(dev); if (ltq_wdt_hw && ltq_wdt_hw->bootstatus_get) { ret = ltq_wdt_hw->bootstatus_get(dev); if (ret >= 0) wdt->bootstatus = ret; } watchdog_set_nowayout(wdt, nowayout); watchdog_init_timeout(wdt, 0, dev); status = ltq_wdt_r32(priv, LTQ_WDT_SR); if (status & LTQ_WDT_SR_EN) { /* * If the watchdog is already running overwrite it with our * new settings. Stop is not needed as the start call will * replace all settings anyway. */ ltq_wdt_start(wdt); set_bit(WDOG_HW_RUNNING, &wdt->status); } return devm_watchdog_register_device(dev, wdt); }
static int atlas7_wdt_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct atlas7_wdog *wdt; struct resource *res; struct clk *clk; int ret; wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdt->base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base); clk = of_clk_get(np, 0); if (IS_ERR(clk)) return PTR_ERR(clk); ret = clk_prepare_enable(clk); if (ret) { dev_err(&pdev->dev, "clk enable failed\n"); goto err; } /* disable watchdog hardware */ writel(0, wdt->base + ATLAS7_WDT_CNT_CTRL); wdt->tick_rate = clk_get_rate(clk); if (!wdt->tick_rate) { ret = -EINVAL; goto err1; } wdt->clk = clk; atlas7_wdd.min_timeout = 1; atlas7_wdd.max_timeout = UINT_MAX / wdt->tick_rate; watchdog_init_timeout(&atlas7_wdd, 0, &pdev->dev); watchdog_set_nowayout(&atlas7_wdd, nowayout); watchdog_set_drvdata(&atlas7_wdd, wdt); platform_set_drvdata(pdev, &atlas7_wdd); ret = watchdog_register_device(&atlas7_wdd); if (ret) goto err1; return 0; err1: clk_disable_unprepare(clk); err: clk_put(clk); return ret; }
static int __devinit jz4740_wdt_probe(struct platform_device *pdev) { struct jz4740_wdt_drvdata *drvdata; struct watchdog_device *jz4740_wdt; struct resource *res; int ret; drvdata = devm_kzalloc(&pdev->dev, sizeof(struct jz4740_wdt_drvdata), GFP_KERNEL); if (!drvdata) { dev_err(&pdev->dev, "Unable to alloacate watchdog device\n"); return -ENOMEM; } if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) heartbeat = DEFAULT_HEARTBEAT; jz4740_wdt = &drvdata->wdt; jz4740_wdt->info = &jz4740_wdt_info; jz4740_wdt->ops = &jz4740_wdt_ops; jz4740_wdt->timeout = heartbeat; jz4740_wdt->min_timeout = 1; jz4740_wdt->max_timeout = MAX_HEARTBEAT; watchdog_set_nowayout(jz4740_wdt, nowayout); watchdog_set_drvdata(jz4740_wdt, drvdata); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); drvdata->base = devm_request_and_ioremap(&pdev->dev, res); if (drvdata->base == NULL) { ret = -EBUSY; goto err_out; } drvdata->rtc_clk = clk_get(NULL, "rtc"); if (IS_ERR(drvdata->rtc_clk)) { dev_err(&pdev->dev, "cannot find RTC clock\n"); ret = PTR_ERR(drvdata->rtc_clk); goto err_out; } ret = watchdog_register_device(&drvdata->wdt); if (ret < 0) goto err_disable_clk; platform_set_drvdata(pdev, drvdata); return 0; err_disable_clk: clk_put(drvdata->rtc_clk); err_out: return ret; }
static int __init at91wdt_probe(struct platform_device *pdev) { struct at91wdt_drvdata *driver_data; struct resource *r; int ret; driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data), GFP_KERNEL); if (!driver_data) { dev_err(&pdev->dev, "Unable to alloacate watchdog device\n"); return -ENOMEM; } watchdog_set_drvdata(&at91wdt_wdd, driver_data); r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r) return -ENODEV; driver_data->phybase = ioremap(r->start, resource_size(r)); if (!driver_data->phybase) { dev_err(&pdev->dev, "failed to map registers, aborting.\n"); return -ENOMEM; } ret = watchdog_register_device(&at91wdt_wdd); if (ret) { dev_err(&pdev->dev, "cannot register watchdog (%d)\n", ret); return ret; } watchdog_set_nowayout(&at91wdt_wdd, nowayout); watchdog_init_timeout(&at91wdt_wdd, heartbeat, pdev->dev.of_node); ret = at91wdt_enable(&at91wdt_wdd, ms_to_ticks(WDT_HW_TIMEOUT * 1000)); if (ret) { pr_info("the watchdog has been disabled\n"); return 0; } driver_data->next_heartbeat = jiffies + at91wdt_wdd.timeout * HZ; setup_timer(&driver_data->timer, at91wdt_timer_tick, (unsigned long)&at91wdt_wdd); mod_timer(&driver_data->timer, jiffies + WDT_TIMEOUT); pr_info("enabled (heartbeat=%d sec, nowayout=%d)\n", at91wdt_wdd.timeout, nowayout); return 0; }
static int bcm2835_wdt_probe(struct platform_device *pdev) { struct resource *res; struct device *dev = &pdev->dev; struct bcm2835_wdt *wdt; int err; wdt = devm_kzalloc(dev, sizeof(struct bcm2835_wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; platform_set_drvdata(pdev, wdt); spin_lock_init(&wdt->lock); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdt->base = devm_ioremap_resource(dev, res); if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base); watchdog_set_drvdata(&bcm2835_wdt_wdd, wdt); watchdog_init_timeout(&bcm2835_wdt_wdd, heartbeat, dev); watchdog_set_nowayout(&bcm2835_wdt_wdd, nowayout); bcm2835_wdt_wdd.parent = dev; if (bcm2835_wdt_is_running(wdt)) { /* * The currently active timeout value (set by the * bootloader) may be different from the module * heartbeat parameter or the value in device * tree. But we just need to set WDOG_HW_RUNNING, * because then the framework will "immediately" ping * the device, updating the timeout. */ set_bit(WDOG_HW_RUNNING, &bcm2835_wdt_wdd.status); } watchdog_set_restart_priority(&bcm2835_wdt_wdd, 128); watchdog_stop_on_reboot(&bcm2835_wdt_wdd); err = devm_watchdog_register_device(dev, &bcm2835_wdt_wdd); if (err) { dev_err(dev, "Failed to register watchdog device"); return err; } if (pm_power_off == NULL) pm_power_off = bcm2835_power_off; dev_info(dev, "Broadcom BCM2835 watchdog timer"); return 0; }
static int menf21bmc_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; int ret, bmc_timeout; struct menf21bmc_wdt *drv_data; struct i2c_client *i2c_client = to_i2c_client(dev->parent); drv_data = devm_kzalloc(dev, sizeof(struct menf21bmc_wdt), GFP_KERNEL); if (!drv_data) return -ENOMEM; drv_data->wdt.ops = &menf21bmc_wdt_ops; drv_data->wdt.info = &menf21bmc_wdt_info; drv_data->wdt.min_timeout = BMC_WD_TIMEOUT_MIN; drv_data->wdt.max_timeout = BMC_WD_TIMEOUT_MAX; drv_data->wdt.parent = dev; drv_data->i2c_client = i2c_client; /* * Get the current wdt timeout value from the BMC because * the BMC will save the value set before if the system restarts. */ bmc_timeout = i2c_smbus_read_word_data(drv_data->i2c_client, BMC_CMD_WD_TIME); if (bmc_timeout < 0) { dev_err(dev, "failed to get current WDT timeout\n"); return bmc_timeout; } watchdog_init_timeout(&drv_data->wdt, bmc_timeout / 10, dev); watchdog_set_nowayout(&drv_data->wdt, nowayout); watchdog_set_drvdata(&drv_data->wdt, drv_data); platform_set_drvdata(pdev, drv_data); ret = menf21bmc_wdt_set_bootstatus(drv_data); if (ret < 0) { dev_err(dev, "failed to set Watchdog bootstatus\n"); return ret; } ret = devm_watchdog_register_device(dev, &drv_data->wdt); if (ret) { dev_err(dev, "failed to register Watchdog device\n"); return ret; } dev_info(dev, "MEN 14F021P00 BMC Watchdog device enabled\n"); return 0; }
static int uniphier_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct uniphier_wdt_dev *wdev; struct regmap *regmap; struct device_node *parent; int ret; wdev = devm_kzalloc(dev, sizeof(*wdev), GFP_KERNEL); if (!wdev) return -ENOMEM; platform_set_drvdata(pdev, wdev); parent = of_get_parent(dev->of_node); /* parent should be syscon node */ regmap = syscon_node_to_regmap(parent); of_node_put(parent); if (IS_ERR(regmap)) return PTR_ERR(regmap); wdev->regmap = regmap; wdev->wdt_dev.info = &uniphier_wdt_info; wdev->wdt_dev.ops = &uniphier_wdt_ops; wdev->wdt_dev.max_timeout = WDT_PERIOD_MAX; wdev->wdt_dev.min_timeout = WDT_PERIOD_MIN; wdev->wdt_dev.parent = dev; if (watchdog_init_timeout(&wdev->wdt_dev, timeout, dev) < 0) { wdev->wdt_dev.timeout = WDT_DEFAULT_TIMEOUT; } watchdog_set_nowayout(&wdev->wdt_dev, nowayout); watchdog_stop_on_reboot(&wdev->wdt_dev); watchdog_set_drvdata(&wdev->wdt_dev, wdev); uniphier_watchdog_stop(&wdev->wdt_dev); ret = regmap_write(wdev->regmap, WDTRSTSEL, WDTRSTSEL_RSTSEL_BOTH); if (ret) return ret; ret = devm_watchdog_register_device(dev, &wdev->wdt_dev); if (ret) return ret; dev_info(dev, "watchdog driver (timeout=%d sec, nowayout=%d)\n", wdev->wdt_dev.timeout, nowayout); return 0; }
static int __init txx9wdt_probe(struct platform_device *dev) { struct resource *res; int ret; txx9_imclk = clk_get(NULL, "imbus_clk"); if (IS_ERR(txx9_imclk)) { ret = PTR_ERR(txx9_imclk); txx9_imclk = NULL; goto exit; } ret = clk_enable(txx9_imclk); if (ret) { clk_put(txx9_imclk); txx9_imclk = NULL; goto exit; } res = platform_get_resource(dev, IORESOURCE_MEM, 0); txx9wdt_reg = devm_ioremap_resource(&dev->dev, res); if (IS_ERR(txx9wdt_reg)) { ret = PTR_ERR(txx9wdt_reg); goto exit; } if (timeout < 1 || timeout > WD_MAX_TIMEOUT) timeout = TIMER_MARGIN; txx9wdt.timeout = timeout; txx9wdt.min_timeout = 1; txx9wdt.max_timeout = WD_MAX_TIMEOUT; watchdog_set_nowayout(&txx9wdt, nowayout); ret = watchdog_register_device(&txx9wdt); if (ret) goto exit; pr_info("Hardware Watchdog Timer: timeout=%d sec (max %ld) (nowayout= %d)\n", timeout, WD_MAX_TIMEOUT, nowayout); return 0; exit: if (txx9_imclk) { clk_disable(txx9_imclk); clk_put(txx9_imclk); } return ret; }
static int wm8350_wdt_probe(struct platform_device *pdev) { struct wm8350 *wm8350 = platform_get_drvdata(pdev); if (!wm8350) { pr_err("No driver data supplied\n"); return -ENODEV; } watchdog_set_nowayout(&wm8350_wdt, nowayout); watchdog_set_drvdata(&wm8350_wdt, wm8350); /* Default to 4s timeout */ wm8350_wdt_set_timeout(&wm8350_wdt, 4); return watchdog_register_device(&wm8350_wdt); }
static int __init softdog_init(void) { int ret; watchdog_init_timeout(&softdog_dev, soft_margin, NULL); watchdog_set_nowayout(&softdog_dev, nowayout); watchdog_stop_on_reboot(&softdog_dev); ret = watchdog_register_device(&softdog_dev); if (ret) return ret; pr_info("initialized. soft_noboot=%d soft_margin=%d sec soft_panic=%d (nowayout=%d)\n", soft_noboot, softdog_dev.timeout, soft_panic, nowayout); return 0; }
static int __init booke_wdt_init(void) { int ret = 0; bool nowayout = WATCHDOG_NOWAYOUT; pr_info("powerpc book-e watchdog driver loaded\n"); booke_wdt_info.firmware_version = cur_cpu_spec->pvr_value; booke_wdt_set_timeout(&booke_wdt_dev, period_to_sec(CONFIG_BOOKE_WDT_DEFAULT_TIMEOUT)); watchdog_set_nowayout(&booke_wdt_dev, nowayout); if (booke_wdt_enabled) __booke_wdt_start(&booke_wdt_dev); ret = watchdog_register_device(&booke_wdt_dev); return ret; }
static int __devinit pnx4008_wdt_probe(struct platform_device *pdev) { struct resource *r; int ret = 0; if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) heartbeat = DEFAULT_HEARTBEAT; r = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdt_base = devm_request_and_ioremap(&pdev->dev, r); if (!wdt_base) return -EADDRINUSE; wdt_clk = clk_get(&pdev->dev, NULL); if (IS_ERR(wdt_clk)) return PTR_ERR(wdt_clk); ret = clk_enable(wdt_clk); if (ret) goto out; pnx4008_wdd.timeout = heartbeat; pnx4008_wdd.bootstatus = (readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ? WDIOF_CARDRESET : 0; watchdog_set_nowayout(&pnx4008_wdd, nowayout); pnx4008_wdt_stop(&pnx4008_wdd); /* disable for now */ ret = watchdog_register_device(&pnx4008_wdd); if (ret < 0) { dev_err(&pdev->dev, "cannot register watchdog device\n"); goto disable_clk; } dev_info(&pdev->dev, "PNX4008 Watchdog Timer: heartbeat %d sec\n", heartbeat); return 0; disable_clk: clk_disable(wdt_clk); out: clk_put(wdt_clk); return ret; }
static int ts72xx_wdt_probe(struct platform_device *pdev) { struct ts72xx_wdt_priv *priv; struct watchdog_device *wdd; struct resource *res; int ret; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->control_reg = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(priv->control_reg)) return PTR_ERR(priv->control_reg); res = platform_get_resource(pdev, IORESOURCE_MEM, 1); priv->feed_reg = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(priv->feed_reg)) return PTR_ERR(priv->feed_reg); wdd = &priv->wdd; wdd->info = &ts72xx_wdt_ident; wdd->ops = &ts72xx_wdt_ops; wdd->min_timeout = 1; wdd->max_hw_heartbeat_ms = 8000; wdd->parent = &pdev->dev; watchdog_set_nowayout(wdd, nowayout); wdd->timeout = TS72XX_WDT_DEFAULT_TIMEOUT; watchdog_init_timeout(wdd, timeout, &pdev->dev); watchdog_set_drvdata(wdd, priv); ret = devm_watchdog_register_device(&pdev->dev, wdd); if (ret) return ret; dev_info(&pdev->dev, "TS-72xx Watchdog driver\n"); return 0; }
static int ep93xx_wdt_probe(struct platform_device *pdev) { struct resource *res; unsigned long val; int err; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENXIO; if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res), pdev->name)) return -EBUSY; mmio_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!mmio_base) return -ENXIO; if (timeout < 1 || timeout > 3600) { timeout = WDT_TIMEOUT; dev_warn(&pdev->dev, "timeout value must be 1<=x<=3600, using %d\n", timeout); } val = readl(mmio_base + EP93XX_WATCHDOG); ep93xx_wdt_wdd.bootstatus = (val & 0x01) ? WDIOF_CARDRESET : 0; ep93xx_wdt_wdd.timeout = timeout; watchdog_set_nowayout(&ep93xx_wdt_wdd, nowayout); setup_timer(&timer, ep93xx_wdt_timer_ping, 1); err = watchdog_register_device(&ep93xx_wdt_wdd); if (err) return err; dev_info(&pdev->dev, "EP93XX watchdog, driver version " WDT_VERSION "%s\n", (val & 0x08) ? " (nCS1 disable detected)" : ""); return 0; }
static int retu_wdt_probe(struct platform_device *pdev) { struct retu_dev *rdev = dev_get_drvdata(pdev->dev.parent); bool nowayout = WATCHDOG_NOWAYOUT; struct watchdog_device *retu_wdt; struct retu_wdt_dev *wdev; int ret; retu_wdt = devm_kzalloc(&pdev->dev, sizeof(*retu_wdt), GFP_KERNEL); if (!retu_wdt) return -ENOMEM; wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL); if (!wdev) return -ENOMEM; retu_wdt->info = &retu_wdt_info; retu_wdt->ops = &retu_wdt_ops; retu_wdt->timeout = RETU_WDT_MAX_TIMER; retu_wdt->min_timeout = 0; retu_wdt->max_timeout = RETU_WDT_MAX_TIMER; watchdog_set_drvdata(retu_wdt, wdev); watchdog_set_nowayout(retu_wdt, nowayout); wdev->rdev = rdev; wdev->dev = &pdev->dev; INIT_DELAYED_WORK(&wdev->ping_work, retu_wdt_ping_work); ret = watchdog_register_device(retu_wdt); if (ret < 0) return ret; if (nowayout) retu_wdt_ping(retu_wdt); else retu_wdt_ping_enable(wdev); platform_set_drvdata(pdev, retu_wdt); return 0; }
static int da9055_wdt_probe(struct platform_device *pdev) { struct da9055 *da9055 = dev_get_drvdata(pdev->dev.parent); struct da9055_wdt_data *driver_data; struct watchdog_device *da9055_wdt; int ret; driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data), GFP_KERNEL); if (!driver_data) { dev_err(da9055->dev, "Failed to allocate watchdog device\n"); return -ENOMEM; } driver_data->da9055 = da9055; da9055_wdt = &driver_data->wdt; da9055_wdt->timeout = DA9055_DEF_TIMEOUT; da9055_wdt->info = &da9055_wdt_info; da9055_wdt->ops = &da9055_wdt_ops; watchdog_set_nowayout(da9055_wdt, nowayout); watchdog_set_drvdata(da9055_wdt, driver_data); kref_init(&driver_data->kref); ret = da9055_wdt_stop(da9055_wdt); if (ret < 0) { dev_err(&pdev->dev, "Failed to stop watchdog, %d\n", ret); goto err; } dev_set_drvdata(&pdev->dev, driver_data); ret = watchdog_register_device(&driver_data->wdt); if (ret != 0) dev_err(da9055->dev, "watchdog_register_device() failed: %d\n", ret); err: return ret; }
static int pnx4008_wdt_probe(struct platform_device *pdev) { struct resource *r; int ret = 0; watchdog_init_timeout(&pnx4008_wdd, heartbeat, &pdev->dev); r = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdt_base = devm_ioremap_resource(&pdev->dev, r); if (IS_ERR(wdt_base)) return PTR_ERR(wdt_base); wdt_clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(wdt_clk)) return PTR_ERR(wdt_clk); ret = clk_prepare_enable(wdt_clk); if (ret) return ret; pnx4008_wdd.bootstatus = (readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ? WDIOF_CARDRESET : 0; pnx4008_wdd.parent = &pdev->dev; watchdog_set_nowayout(&pnx4008_wdd, nowayout); watchdog_set_restart_priority(&pnx4008_wdd, 128); pnx4008_wdt_stop(&pnx4008_wdd); /* disable for now */ ret = watchdog_register_device(&pnx4008_wdd); if (ret < 0) { dev_err(&pdev->dev, "cannot register watchdog device\n"); goto disable_clk; } dev_info(&pdev->dev, "heartbeat %d sec\n", pnx4008_wdd.timeout); return 0; disable_clk: clk_disable_unprepare(wdt_clk); return ret; }
static int mtk_wdt_probe(struct platform_device *pdev) { struct mtk_wdt_dev *mtk_wdt; struct resource *res; int err; mtk_wdt = devm_kzalloc(&pdev->dev, sizeof(*mtk_wdt), GFP_KERNEL); if (!mtk_wdt) return -ENOMEM; platform_set_drvdata(pdev, mtk_wdt); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mtk_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(mtk_wdt->wdt_base)) return PTR_ERR(mtk_wdt->wdt_base); mtk_wdt->wdt_dev.info = &mtk_wdt_info; mtk_wdt->wdt_dev.ops = &mtk_wdt_ops; mtk_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT; mtk_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT; mtk_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT; mtk_wdt->wdt_dev.parent = &pdev->dev; watchdog_init_timeout(&mtk_wdt->wdt_dev, timeout, &pdev->dev); watchdog_set_nowayout(&mtk_wdt->wdt_dev, nowayout); watchdog_set_restart_priority(&mtk_wdt->wdt_dev, 128); watchdog_set_drvdata(&mtk_wdt->wdt_dev, mtk_wdt); mtk_wdt_stop(&mtk_wdt->wdt_dev); err = watchdog_register_device(&mtk_wdt->wdt_dev); if (unlikely(err)) return err; dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)\n", mtk_wdt->wdt_dev.timeout, nowayout); return 0; }
static int orion_wdt_probe(struct platform_device *pdev) { struct resource *res; int ret; clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(clk)) { dev_err(&pdev->dev, "Orion Watchdog missing clock\n"); return -ENODEV; } clk_prepare_enable(clk); wdt_tclk = clk_get_rate(clk); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; wdt_reg = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!wdt_reg) return -ENOMEM; wdt_max_duration = WDT_MAX_CYCLE_COUNT / wdt_tclk; if ((heartbeat < 1) || (heartbeat > wdt_max_duration)) heartbeat = wdt_max_duration; orion_wdt.timeout = heartbeat; orion_wdt.min_timeout = 1; orion_wdt.max_timeout = wdt_max_duration; watchdog_set_nowayout(&orion_wdt, nowayout); ret = watchdog_register_device(&orion_wdt); if (ret) { clk_disable_unprepare(clk); return ret; } pr_info("Initial timeout %d sec%s\n", heartbeat, nowayout ? ", nowayout" : ""); return 0; }
static int pmic_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; int ret; struct stpmic1 *pmic; struct stpmic1_wdt *wdt; if (!dev->parent) return -EINVAL; pmic = dev_get_drvdata(dev->parent); if (!pmic) return -EINVAL; wdt = devm_kzalloc(dev, sizeof(struct stpmic1_wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; wdt->pmic = pmic; wdt->wdtdev.info = &pmic_watchdog_info; wdt->wdtdev.ops = &pmic_watchdog_ops; wdt->wdtdev.min_timeout = PMIC_WDT_MIN_TIMEOUT; wdt->wdtdev.max_timeout = PMIC_WDT_MAX_TIMEOUT; wdt->wdtdev.parent = dev; wdt->wdtdev.timeout = PMIC_WDT_DEFAULT_TIMEOUT; watchdog_init_timeout(&wdt->wdtdev, 0, dev); watchdog_set_nowayout(&wdt->wdtdev, nowayout); watchdog_set_drvdata(&wdt->wdtdev, wdt); ret = devm_watchdog_register_device(dev, &wdt->wdtdev); if (ret) return ret; dev_dbg(wdt->pmic->dev, "PMIC Watchdog driver probed\n"); return 0; }
static int mt7621_wdt_probe(struct platform_device *pdev) { struct resource *res; int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mt7621_wdt_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(mt7621_wdt_base)) return PTR_ERR(mt7621_wdt_base); mt7621_wdt_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); if (!IS_ERR(mt7621_wdt_reset)) reset_control_deassert(mt7621_wdt_reset); mt7621_wdt_dev.bootstatus = mt7621_wdt_bootcause(); watchdog_init_timeout(&mt7621_wdt_dev, mt7621_wdt_dev.max_timeout, &pdev->dev); watchdog_set_nowayout(&mt7621_wdt_dev, nowayout); ret = watchdog_register_device(&mt7621_wdt_dev); return 0; }