|
@@ -17,22 +17,25 @@
|
|
#include <linux/init.h>
|
|
#include <linux/init.h>
|
|
#include <linux/io.h>
|
|
#include <linux/io.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/kernel.h>
|
|
|
|
+#include <linux/mfd/syscon.h>
|
|
|
|
+#include <linux/mfd/syscon/atmel-st.h>
|
|
#include <linux/miscdevice.h>
|
|
#include <linux/miscdevice.h>
|
|
#include <linux/module.h>
|
|
#include <linux/module.h>
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
+#include <linux/regmap.h>
|
|
#include <linux/types.h>
|
|
#include <linux/types.h>
|
|
#include <linux/watchdog.h>
|
|
#include <linux/watchdog.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/of_device.h>
|
|
-#include <mach/at91_st.h>
|
|
|
|
|
|
|
|
#define WDT_DEFAULT_TIME 5 /* seconds */
|
|
#define WDT_DEFAULT_TIME 5 /* seconds */
|
|
#define WDT_MAX_TIME 256 /* seconds */
|
|
#define WDT_MAX_TIME 256 /* seconds */
|
|
|
|
|
|
static int wdt_time = WDT_DEFAULT_TIME;
|
|
static int wdt_time = WDT_DEFAULT_TIME;
|
|
static bool nowayout = WATCHDOG_NOWAYOUT;
|
|
static bool nowayout = WATCHDOG_NOWAYOUT;
|
|
|
|
+static struct regmap *regmap_st;
|
|
|
|
|
|
module_param(wdt_time, int, 0);
|
|
module_param(wdt_time, int, 0);
|
|
MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="
|
|
MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="
|
|
@@ -55,7 +58,7 @@ static unsigned long at91wdt_busy;
|
|
*/
|
|
*/
|
|
static inline void at91_wdt_stop(void)
|
|
static inline void at91_wdt_stop(void)
|
|
{
|
|
{
|
|
- at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN);
|
|
|
|
|
|
+ regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -63,9 +66,9 @@ static inline void at91_wdt_stop(void)
|
|
*/
|
|
*/
|
|
static inline void at91_wdt_start(void)
|
|
static inline void at91_wdt_start(void)
|
|
{
|
|
{
|
|
- at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN |
|
|
|
|
|
|
+ regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN |
|
|
(((65536 * wdt_time) >> 8) & AT91_ST_WDV));
|
|
(((65536 * wdt_time) >> 8) & AT91_ST_WDV));
|
|
- at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
|
|
|
|
|
|
+ regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -73,7 +76,7 @@ static inline void at91_wdt_start(void)
|
|
*/
|
|
*/
|
|
static inline void at91_wdt_reload(void)
|
|
static inline void at91_wdt_reload(void)
|
|
{
|
|
{
|
|
- at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
|
|
|
|
|
|
+ regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
|
|
}
|
|
}
|
|
|
|
|
|
/* ......................................................................... */
|
|
/* ......................................................................... */
|
|
@@ -203,12 +206,24 @@ static struct miscdevice at91wdt_miscdev = {
|
|
|
|
|
|
static int at91wdt_probe(struct platform_device *pdev)
|
|
static int at91wdt_probe(struct platform_device *pdev)
|
|
{
|
|
{
|
|
|
|
+ struct device *dev = &pdev->dev;
|
|
|
|
+ struct device *parent;
|
|
int res;
|
|
int res;
|
|
|
|
|
|
if (at91wdt_miscdev.parent)
|
|
if (at91wdt_miscdev.parent)
|
|
return -EBUSY;
|
|
return -EBUSY;
|
|
at91wdt_miscdev.parent = &pdev->dev;
|
|
at91wdt_miscdev.parent = &pdev->dev;
|
|
|
|
|
|
|
|
+ parent = dev->parent;
|
|
|
|
+ if (!parent) {
|
|
|
|
+ dev_err(dev, "no parent\n");
|
|
|
|
+ return -ENODEV;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ regmap_st = syscon_node_to_regmap(parent->of_node);
|
|
|
|
+ if (!regmap_st)
|
|
|
|
+ return -ENODEV;
|
|
|
|
+
|
|
res = misc_register(&at91wdt_miscdev);
|
|
res = misc_register(&at91wdt_miscdev);
|
|
if (res)
|
|
if (res)
|
|
return res;
|
|
return res;
|
|
@@ -267,7 +282,7 @@ static struct platform_driver at91wdt_driver = {
|
|
.suspend = at91wdt_suspend,
|
|
.suspend = at91wdt_suspend,
|
|
.resume = at91wdt_resume,
|
|
.resume = at91wdt_resume,
|
|
.driver = {
|
|
.driver = {
|
|
- .name = "at91_wdt",
|
|
|
|
|
|
+ .name = "atmel_st_watchdog",
|
|
.of_match_table = at91_wdt_dt_ids,
|
|
.of_match_table = at91_wdt_dt_ids,
|
|
},
|
|
},
|
|
};
|
|
};
|
|
@@ -296,4 +311,4 @@ module_exit(at91_wdt_exit);
|
|
MODULE_AUTHOR("Andrew Victor");
|
|
MODULE_AUTHOR("Andrew Victor");
|
|
MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200");
|
|
MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_LICENSE("GPL");
|
|
-MODULE_ALIAS("platform:at91_wdt");
|
|
|
|
|
|
+MODULE_ALIAS("platform:atmel_st_watchdog");
|