Blame view
drivers/watchdog/twl4030_wdt.c
2.91 KB
1a59d1b8e treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
80e45b1e9 [WATCHDOG] twl403... |
2 3 4 5 |
/* * Copyright (C) Nokia Corporation * * Written by Timo Kokkonen <timo.t.kokkonen at nokia.com> |
80e45b1e9 [WATCHDOG] twl403... |
6 7 8 9 |
*/ #include <linux/module.h> #include <linux/types.h> |
5a0e3ad6a include cleanup: ... |
10 |
#include <linux/slab.h> |
80e45b1e9 [WATCHDOG] twl403... |
11 |
#include <linux/kernel.h> |
80e45b1e9 [WATCHDOG] twl403... |
12 13 |
#include <linux/watchdog.h> #include <linux/platform_device.h> |
a20542565 mfd: twl: Move he... |
14 |
#include <linux/mfd/twl.h> |
80e45b1e9 [WATCHDOG] twl403... |
15 16 |
#define TWL4030_WATCHDOG_CFG_REG_OFFS 0x3 |
86a1e1896 watchdog: nowayou... |
17 18 |
static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, bool, 0); |
80e45b1e9 [WATCHDOG] twl403... |
19 20 21 22 23 |
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); static int twl4030_wdt_write(unsigned char val) { |
2bc3f62f9 watchdog: twl4030... |
24 |
return twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, val, |
80e45b1e9 [WATCHDOG] twl403... |
25 26 |
TWL4030_WATCHDOG_CFG_REG_OFFS); } |
b2c4e4b26 watchdog: Convert... |
27 |
static int twl4030_wdt_start(struct watchdog_device *wdt) |
80e45b1e9 [WATCHDOG] twl403... |
28 |
{ |
b2c4e4b26 watchdog: Convert... |
29 |
return twl4030_wdt_write(wdt->timeout + 1); |
80e45b1e9 [WATCHDOG] twl403... |
30 |
} |
b2c4e4b26 watchdog: Convert... |
31 |
static int twl4030_wdt_stop(struct watchdog_device *wdt) |
80e45b1e9 [WATCHDOG] twl403... |
32 33 34 |
{ return twl4030_wdt_write(0); } |
b2c4e4b26 watchdog: Convert... |
35 36 |
static int twl4030_wdt_set_timeout(struct watchdog_device *wdt, unsigned int timeout) |
80e45b1e9 [WATCHDOG] twl403... |
37 |
{ |
b2c4e4b26 watchdog: Convert... |
38 |
wdt->timeout = timeout; |
80e45b1e9 [WATCHDOG] twl403... |
39 40 |
return 0; } |
b2c4e4b26 watchdog: Convert... |
41 |
static const struct watchdog_info twl4030_wdt_info = { |
fb1cbeaee watchdog: Fix oma... |
42 |
.options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, |
b2c4e4b26 watchdog: Convert... |
43 44 |
.identity = "TWL4030 Watchdog", }; |
80e45b1e9 [WATCHDOG] twl403... |
45 |
|
b2c4e4b26 watchdog: Convert... |
46 |
static const struct watchdog_ops twl4030_wdt_ops = { |
80e45b1e9 [WATCHDOG] twl403... |
47 |
.owner = THIS_MODULE, |
b2c4e4b26 watchdog: Convert... |
48 49 50 |
.start = twl4030_wdt_start, .stop = twl4030_wdt_stop, .set_timeout = twl4030_wdt_set_timeout, |
80e45b1e9 [WATCHDOG] twl403... |
51 |
}; |
2d991a164 watchdog: remove ... |
52 |
static int twl4030_wdt_probe(struct platform_device *pdev) |
80e45b1e9 [WATCHDOG] twl403... |
53 |
{ |
b42488bcd watchdog: twl4030... |
54 |
struct device *dev = &pdev->dev; |
b2c4e4b26 watchdog: Convert... |
55 |
struct watchdog_device *wdt; |
80e45b1e9 [WATCHDOG] twl403... |
56 |
|
b42488bcd watchdog: twl4030... |
57 |
wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); |
80e45b1e9 [WATCHDOG] twl403... |
58 59 |
if (!wdt) return -ENOMEM; |
b2c4e4b26 watchdog: Convert... |
60 61 62 63 64 65 |
wdt->info = &twl4030_wdt_info; wdt->ops = &twl4030_wdt_ops; wdt->status = 0; wdt->timeout = 30; wdt->min_timeout = 1; wdt->max_timeout = 30; |
b42488bcd watchdog: twl4030... |
66 |
wdt->parent = dev; |
80e45b1e9 [WATCHDOG] twl403... |
67 |
|
b2c4e4b26 watchdog: Convert... |
68 |
watchdog_set_nowayout(wdt, nowayout); |
80e45b1e9 [WATCHDOG] twl403... |
69 |
platform_set_drvdata(pdev, wdt); |
b2c4e4b26 watchdog: Convert... |
70 |
twl4030_wdt_stop(wdt); |
80e45b1e9 [WATCHDOG] twl403... |
71 |
|
b42488bcd watchdog: twl4030... |
72 |
return devm_watchdog_register_device(dev, wdt); |
80e45b1e9 [WATCHDOG] twl403... |
73 74 75 76 77 |
} #ifdef CONFIG_PM static int twl4030_wdt_suspend(struct platform_device *pdev, pm_message_t state) { |
b2c4e4b26 watchdog: Convert... |
78 79 80 |
struct watchdog_device *wdt = platform_get_drvdata(pdev); if (watchdog_active(wdt)) return twl4030_wdt_stop(wdt); |
80e45b1e9 [WATCHDOG] twl403... |
81 82 83 84 85 86 |
return 0; } static int twl4030_wdt_resume(struct platform_device *pdev) { |
b2c4e4b26 watchdog: Convert... |
87 88 89 |
struct watchdog_device *wdt = platform_get_drvdata(pdev); if (watchdog_active(wdt)) return twl4030_wdt_start(wdt); |
80e45b1e9 [WATCHDOG] twl403... |
90 91 92 93 94 95 96 |
return 0; } #else #define twl4030_wdt_suspend NULL #define twl4030_wdt_resume NULL #endif |
8899b8d93 watchdog: twl4030... |
97 98 99 100 101 |
static const struct of_device_id twl_wdt_of_match[] = { { .compatible = "ti,twl4030-wdt", }, { }, }; MODULE_DEVICE_TABLE(of, twl_wdt_of_match); |
80e45b1e9 [WATCHDOG] twl403... |
102 103 |
static struct platform_driver twl4030_wdt_driver = { .probe = twl4030_wdt_probe, |
80e45b1e9 [WATCHDOG] twl403... |
104 105 106 |
.suspend = twl4030_wdt_suspend, .resume = twl4030_wdt_resume, .driver = { |
8899b8d93 watchdog: twl4030... |
107 108 |
.name = "twl4030_wdt", .of_match_table = twl_wdt_of_match, |
80e45b1e9 [WATCHDOG] twl403... |
109 110 |
}, }; |
b8ec61189 watchdog: convert... |
111 |
module_platform_driver(twl4030_wdt_driver); |
80e45b1e9 [WATCHDOG] twl403... |
112 113 114 |
MODULE_AUTHOR("Nokia Corporation"); MODULE_LICENSE("GPL"); |
80e45b1e9 [WATCHDOG] twl403... |
115 |
MODULE_ALIAS("platform:twl4030_wdt"); |