1 /*
2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #include <linux/module.h>
20 #include <linux/kernel.h>
21 #include <linux/printk.h>
22 #include <linux/version.h>
23 #include <linux/of_platform.h>
24 #include "hi_type.h"
25 #include "watchdog.h"
26
27 #define OSDRV_MODULE_VERSION_STRING "HISI_wtdg @HiMPP"
28
29 extern int default_margin;
30 extern int nodeamon;
31 extern volatile void *g_wtdg_reg_base;
32
33 module_param(default_margin, int, 0);
34 MODULE_PARM_DESC(default_margin,
35 "Watchdog default_margin in seconds. (0<default_margin<80, default=" __MODULE_STRING(HIDOG_TIMER_MARGIN) ")");
36
37 module_param(nodeamon, int, 0);
38 MODULE_PARM_DESC(nodeamon,
39 "By default, a kernel daemon feed watchdog when idle, set 'nodeamon=1' to disable this. (default=0)");
40
hi_wdg_probe(struct platform_device * pdev)41 static int hi_wdg_probe(struct platform_device *pdev)
42 {
43 struct resource *mem = NULL;
44
45 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
46 g_wtdg_reg_base = devm_ioremap_resource(&pdev->dev, mem);
47 if (IS_ERR((void*)g_wtdg_reg_base)) {
48 return PTR_ERR((void*)g_wtdg_reg_base);
49 }
50
51 return watchdog_init();
52 }
53
hi_wdg_remove(struct platform_device * pdev)54 static int hi_wdg_remove(struct platform_device *pdev)
55 {
56 hi_wtdg_unused(pdev);
57
58 watchdog_exit();
59 return 0;
60 }
61
62 static const struct of_device_id g_hi_wdg_match[] = {
63 { .compatible = "hisilicon,hi_wdg" },
64 { .compatible = "hisilicon,hi-wdg" },
65 {},
66 };
67
68 static struct platform_driver g_hi_wdg_driver = {
69 .probe = hi_wdg_probe,
70 .remove = hi_wdg_remove,
71 .driver = { .name = "hi_wdg",
72 .of_match_table = g_hi_wdg_match,
73 },
74 };
75
76 module_platform_driver(g_hi_wdg_driver);
77 MODULE_LICENSE("GPL");
78
79 /*
80 * Export symbol
81 */
82 MODULE_AUTHOR("Digital Media Team ,Hisilicon crop ");
83 MODULE_DESCRIPTION("hi_wdg Driver");
84 MODULE_VERSION("HI_VERSION=" OSDRV_MODULE_VERSION_STRING);
85
86