#include <linux/uaccess.h>\r
#include <linux/io.h>\r
#include <asm/mach/map.h>\r
+#ifdef CONFIG_OF\r
+#include <linux/of.h>\r
+#endif\r
\r
\r
/* RK29 registers define */\r
void rk29_wdt_stop(void)\r
{\r
__rk29_wdt_stop();\r
- clk_disable(wdt_clock);\r
+ clk_disable_unprepare(wdt_clock);\r
}\r
\r
/* timeout unit second */\r
void rk29_wdt_start(void)\r
{\r
unsigned long wtcon;\r
- clk_enable(wdt_clock);\r
+ clk_prepare_enable(wdt_clock);\r
rk29_wdt_set_heartbeat(tmr_margin);\r
wtcon = (RK29_WDT_EN << 0) | (RK29_RESPONSE_MODE << 1) | (RK29_RESET_PULSE << 2);\r
wdt_writel(wtcon, RK29_WDT_CR);\r
\r
/* device interface */\r
\r
-static int __devinit rk29_wdt_probe(struct platform_device *pdev)\r
+static int rk29_wdt_probe(struct platform_device *pdev)\r
{\r
struct resource *res;\r
struct device *dev;\r
int started = 0;\r
- int ret;\r
- int size;\r
+ int ret, val;\r
\r
dev = &pdev->dev;\r
wdt_dev = &pdev->dev;\r
\r
/* get the memory region for the watchdog timer */\r
-\r
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);\r
if (res == NULL) {\r
dev_err(dev, "no memory resource specified\n");\r
return -ENOENT;\r
}\r
\r
- size = (res->end - res->start) + 1;\r
- wdt_mem = request_mem_region(res->start, size, pdev->name);\r
- if (wdt_mem == NULL) {\r
- dev_err(dev, "failed to get memory region\n");\r
- ret = -ENOENT;\r
- goto err_req;\r
- }\r
-\r
- wdt_base = ioremap(res->start, size);\r
+ wdt_base = devm_request_and_ioremap(&pdev->dev, res);\r
if (wdt_base == NULL) {\r
dev_err(dev, "failed to ioremap() region\n");\r
- ret = -EINVAL;\r
- goto err_req;\r
+ return -EINVAL;\r
}\r
-\r
+ \r
+#ifdef CONFIG_OF\r
+ if(!of_property_read_u32(pdev->dev.of_node, "rockchip,atboot", &val))\r
+ tmr_atboot = val;\r
+ else\r
+ tmr_atboot = 0;\r
+\r
+ if(!of_property_read_u32(pdev->dev.of_node, "rockchip,timeout", &val))\r
+ tmr_margin = val;\r
+ else\r
+ tmr_margin = 0;\r
+\r
+ if(!of_property_read_u32(pdev->dev.of_node, "rockchip,debug", &val))\r
+ debug = val;\r
+ else\r
+ debug = 0;\r
DBG("probe: mapped wdt_base=%p\n", wdt_base);\r
\r
+ of_property_read_u32(pdev->dev.of_node, "rockchip,irq", &val);\r
+#endif\r
\r
-#ifdef CONFIG_RK29_FEED_DOG_BY_INTE\r
-\r
- wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);\r
- if (wdt_irq == NULL) {\r
- dev_err(dev, "no irq resource specified\n");\r
- ret = -ENOENT;\r
- goto err_map;\r
- }\r
-\r
- ret = request_irq(wdt_irq->start, rk29_wdt_irq_handler, 0, pdev->name, pdev);\r
-\r
- if (ret != 0) {\r
- dev_err(dev, "failed to install irq (%d)\n", ret);\r
- goto err_map;\r
- }\r
-\r
+#ifdef CONFIG_RK29_FEED_DOG_BY_INTE\r
+ val = 1;\r
#endif\r
+ //printk("atboot:%d, timeout:%ds, debug:%d, irq:%d\n", tmr_atboot, tmr_margin, debug, val);\r
+ \r
+ if(val == 1) {\r
+ wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);\r
+ if (wdt_irq == NULL) {\r
+ dev_err(dev, "no irq resource specified\n");\r
+ return -ENOENT;\r
+ }\r
\r
- wdt_clock = clk_get(&pdev->dev, "wdt");\r
- if (IS_ERR(wdt_clock)) {\r
- wdt_clock = clk_get(&pdev->dev, "pclk_wdt");\r
+ ret = request_irq(wdt_irq->start, rk29_wdt_irq_handler, 0, pdev->name, pdev);\r
+ if (ret != 0) {\r
+ dev_err(dev, "failed to install irq (%d)\n", ret);\r
+ return ret;\r
+ }\r
}\r
+\r
+ wdt_clock = devm_clk_get(&pdev->dev, "pclk_wdt");\r
if (IS_ERR(wdt_clock)) {\r
dev_err(dev, "failed to find watchdog clock source\n");\r
ret = PTR_ERR(wdt_clock);\r
if (ret) {\r
dev_err(dev, "cannot register miscdev on minor=%d (%d)\n",\r
WATCHDOG_MINOR, ret);\r
- goto err_clk;\r
+ goto err_irq;\r
}\r
if (tmr_atboot && started == 0) {\r
dev_info(dev, "starting watchdog timer\n");\r
\r
rk29_wdt_stop();\r
}\r
-\r
return 0;\r
\r
- err_clk:\r
- clk_disable(wdt_clock);\r
- clk_put(wdt_clock);\r
-\r
- err_irq:\r
+err_irq:\r
free_irq(wdt_irq->start, pdev);\r
-\r
- err_map:\r
- iounmap(wdt_base);\r
-\r
- err_req:\r
- release_resource(wdt_mem);\r
- kfree(wdt_mem);\r
-\r
return ret;\r
}\r
\r
-static int __devexit rk29_wdt_remove(struct platform_device *dev)\r
+static int rk29_wdt_remove(struct platform_device *dev)\r
{\r
- release_resource(wdt_mem);\r
- kfree(wdt_mem);\r
wdt_mem = NULL;\r
-\r
free_irq(wdt_irq->start, dev);\r
wdt_irq = NULL;\r
-\r
- clk_disable(wdt_clock);\r
- clk_put(wdt_clock);\r
+ clk_disable_unprepare(wdt_clock);\r
wdt_clock = NULL;\r
-\r
- iounmap(wdt_base);\r
misc_deregister(&rk29_wdt_miscdev);\r
-\r
return 0;\r
}\r
\r
#define rk29_wdt_resume NULL\r
#endif /* CONFIG_PM */\r
\r
-\r
+#ifdef CONFIG_OF\r
+static const struct of_device_id of_rk29_wdt_match[] = {\r
+ { .compatible = "rockchip,watch dog" },\r
+ { /* Sentinel */ }\r
+};\r
+#endif\r
static struct platform_driver rk29_wdt_driver = {\r
.probe = rk29_wdt_probe,\r
- .remove = __devexit_p(rk29_wdt_remove),\r
+ .remove = rk29_wdt_remove,\r
.shutdown = rk29_wdt_shutdown,\r
.suspend = rk29_wdt_suspend,\r
.resume = rk29_wdt_resume,\r
.driver = {\r
.owner = THIS_MODULE,\r
+#ifdef CONFIG_OF\r
+ .of_match_table = of_rk29_wdt_match,\r
+#endif\r
.name = "rk29-wdt",\r
},\r
};\r