diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2012-01-22 04:01:16 -0500 |
---|---|---|
committer | Ryan Mallon <rmallon@gmail.com> | 2012-03-13 20:41:11 -0400 |
commit | 73303d129201de7af7fa837597e9c470c5efa71f (patch) | |
tree | 0990de666d5c3cb4a95182b4f163cd0086e40e37 | |
parent | 0fd1958050e92c859152e775e548284582335d25 (diff) |
ep93xx: Convert the watchdog driver into a platform device.
Convert the ep93xx watchdog driver into a platform device and
remove it's dependency on <mach/hardware.h>.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Ryan Mallon <rmallon@gmail.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Reviewed-by: Mika Westerberg <mika.westerberg@iki.fi>
Acked-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r-- | arch/arm/mach-ep93xx/core.c | 15 | ||||
-rw-r--r-- | arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h | 1 | ||||
-rw-r--r-- | drivers/watchdog/ep93xx_wdt.c | 51 |
3 files changed, 53 insertions, 14 deletions
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c index c73e299b08a5..3134baf6c7a4 100644 --- a/arch/arm/mach-ep93xx/core.c +++ b/arch/arm/mach-ep93xx/core.c | |||
@@ -889,6 +889,20 @@ void __init ep93xx_register_ac97(void) | |||
889 | platform_device_register(&ep93xx_pcm_device); | 889 | platform_device_register(&ep93xx_pcm_device); |
890 | } | 890 | } |
891 | 891 | ||
892 | /************************************************************************* | ||
893 | * EP93xx Watchdog | ||
894 | *************************************************************************/ | ||
895 | static struct resource ep93xx_wdt_resources[] = { | ||
896 | DEFINE_RES_MEM(EP93XX_WATCHDOG_PHYS_BASE, 0x08), | ||
897 | }; | ||
898 | |||
899 | static struct platform_device ep93xx_wdt_device = { | ||
900 | .name = "ep93xx-wdt", | ||
901 | .id = -1, | ||
902 | .num_resources = ARRAY_SIZE(ep93xx_wdt_resources), | ||
903 | .resource = ep93xx_wdt_resources, | ||
904 | }; | ||
905 | |||
892 | void __init ep93xx_init_devices(void) | 906 | void __init ep93xx_init_devices(void) |
893 | { | 907 | { |
894 | /* Disallow access to MaverickCrunch initially */ | 908 | /* Disallow access to MaverickCrunch initially */ |
@@ -904,6 +918,7 @@ void __init ep93xx_init_devices(void) | |||
904 | platform_device_register(&ep93xx_rtc_device); | 918 | platform_device_register(&ep93xx_rtc_device); |
905 | platform_device_register(&ep93xx_ohci_device); | 919 | platform_device_register(&ep93xx_ohci_device); |
906 | platform_device_register(&ep93xx_leds); | 920 | platform_device_register(&ep93xx_leds); |
921 | platform_device_register(&ep93xx_wdt_device); | ||
907 | } | 922 | } |
908 | 923 | ||
909 | void ep93xx_restart(char mode, const char *cmd) | 924 | void ep93xx_restart(char mode, const char *cmd) |
diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h index 72b86878e196..f28afcf29fc1 100644 --- a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h +++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h | |||
@@ -182,6 +182,7 @@ | |||
182 | #define EP93XX_SYSCON_SYSCFG_LCSN1 (1<<0) | 182 | #define EP93XX_SYSCON_SYSCFG_LCSN1 (1<<0) |
183 | #define EP93XX_SYSCON_SWLOCK EP93XX_SYSCON_REG(0xc0) | 183 | #define EP93XX_SYSCON_SWLOCK EP93XX_SYSCON_REG(0xc0) |
184 | 184 | ||
185 | #define EP93XX_WATCHDOG_PHYS_BASE EP93XX_APB_PHYS(0x00140000) | ||
185 | #define EP93XX_WATCHDOG_BASE EP93XX_APB_IOMEM(0x00140000) | 186 | #define EP93XX_WATCHDOG_BASE EP93XX_APB_IOMEM(0x00140000) |
186 | 187 | ||
187 | 188 | ||
diff --git a/drivers/watchdog/ep93xx_wdt.c b/drivers/watchdog/ep93xx_wdt.c index 726b7df61fd0..09cd888db619 100644 --- a/drivers/watchdog/ep93xx_wdt.c +++ b/drivers/watchdog/ep93xx_wdt.c | |||
@@ -23,6 +23,7 @@ | |||
23 | * - Add a few missing ioctls | 23 | * - Add a few missing ioctls |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/platform_device.h> | ||
26 | #include <linux/module.h> | 27 | #include <linux/module.h> |
27 | #include <linux/fs.h> | 28 | #include <linux/fs.h> |
28 | #include <linux/miscdevice.h> | 29 | #include <linux/miscdevice.h> |
@@ -30,7 +31,6 @@ | |||
30 | #include <linux/timer.h> | 31 | #include <linux/timer.h> |
31 | #include <linux/uaccess.h> | 32 | #include <linux/uaccess.h> |
32 | #include <linux/io.h> | 33 | #include <linux/io.h> |
33 | #include <mach/hardware.h> | ||
34 | 34 | ||
35 | #define WDT_VERSION "0.3" | 35 | #define WDT_VERSION "0.3" |
36 | #define PFX "ep93xx_wdt: " | 36 | #define PFX "ep93xx_wdt: " |
@@ -41,6 +41,7 @@ | |||
41 | static int nowayout = WATCHDOG_NOWAYOUT; | 41 | static int nowayout = WATCHDOG_NOWAYOUT; |
42 | static int timeout = WDT_TIMEOUT; | 42 | static int timeout = WDT_TIMEOUT; |
43 | 43 | ||
44 | static void __iomem *mmio_base; | ||
44 | static struct timer_list timer; | 45 | static struct timer_list timer; |
45 | static unsigned long next_heartbeat; | 46 | static unsigned long next_heartbeat; |
46 | static unsigned long wdt_status; | 47 | static unsigned long wdt_status; |
@@ -49,26 +50,25 @@ static unsigned long boot_status; | |||
49 | #define WDT_IN_USE 0 | 50 | #define WDT_IN_USE 0 |
50 | #define WDT_OK_TO_CLOSE 1 | 51 | #define WDT_OK_TO_CLOSE 1 |
51 | 52 | ||
52 | #define EP93XX_WDT_REG(x) (EP93XX_WATCHDOG_BASE + (x)) | 53 | #define EP93XX_WATCHDOG 0x00 |
53 | #define EP93XX_WDT_WATCHDOG EP93XX_WDT_REG(0x00) | 54 | #define EP93XX_WDSTATUS 0x04 |
54 | #define EP93XX_WDT_WDSTATUS EP93XX_WDT_REG(0x04) | ||
55 | 55 | ||
56 | /* reset the wdt every ~200ms */ | 56 | /* reset the wdt every ~200ms */ |
57 | #define WDT_INTERVAL (HZ/5) | 57 | #define WDT_INTERVAL (HZ/5) |
58 | 58 | ||
59 | static void wdt_enable(void) | 59 | static void wdt_enable(void) |
60 | { | 60 | { |
61 | __raw_writew(0xaaaa, EP93XX_WDT_WATCHDOG); | 61 | writel(0xaaaa, mmio_base + EP93XX_WATCHDOG); |
62 | } | 62 | } |
63 | 63 | ||
64 | static void wdt_disable(void) | 64 | static void wdt_disable(void) |
65 | { | 65 | { |
66 | __raw_writew(0xaa55, EP93XX_WDT_WATCHDOG); | 66 | writel(0xaa55, mmio_base + EP93XX_WATCHDOG); |
67 | } | 67 | } |
68 | 68 | ||
69 | static inline void wdt_ping(void) | 69 | static inline void wdt_ping(void) |
70 | { | 70 | { |
71 | __raw_writew(0x5555, EP93XX_WDT_WATCHDOG); | 71 | writel(0x5555, mmio_base + EP93XX_WATCHDOG); |
72 | } | 72 | } |
73 | 73 | ||
74 | static void wdt_startup(void) | 74 | static void wdt_startup(void) |
@@ -206,18 +206,32 @@ static void ep93xx_timer_ping(unsigned long data) | |||
206 | mod_timer(&timer, jiffies + WDT_INTERVAL); | 206 | mod_timer(&timer, jiffies + WDT_INTERVAL); |
207 | } | 207 | } |
208 | 208 | ||
209 | static int __init ep93xx_wdt_init(void) | 209 | static int __devinit ep93xx_wdt_probe(struct platform_device *pdev) |
210 | { | 210 | { |
211 | struct resource *res; | ||
212 | unsigned long val; | ||
211 | int err; | 213 | int err; |
212 | 214 | ||
215 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
216 | if (!res) | ||
217 | return -ENXIO; | ||
218 | |||
219 | if (!devm_request_mem_region(&pdev->dev, res->start, | ||
220 | resource_size(res), pdev->name)) | ||
221 | return -EBUSY; | ||
222 | |||
223 | mmio_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); | ||
224 | if (!mmio_base) | ||
225 | return -ENXIO; | ||
226 | |||
213 | err = misc_register(&ep93xx_wdt_miscdev); | 227 | err = misc_register(&ep93xx_wdt_miscdev); |
214 | 228 | ||
215 | boot_status = __raw_readl(EP93XX_WDT_WATCHDOG) & 0x01 ? 1 : 0; | 229 | val = readl(mmio_base + EP93XX_WATCHDOG); |
230 | boot_status = val & 0x01 ? 1 : 0; | ||
216 | 231 | ||
217 | printk(KERN_INFO PFX "EP93XX watchdog, driver version " | 232 | printk(KERN_INFO PFX "EP93XX watchdog, driver version " |
218 | WDT_VERSION "%s\n", | 233 | WDT_VERSION "%s\n", |
219 | (__raw_readl(EP93XX_WDT_WATCHDOG) & 0x08) | 234 | (val & 0x08) ? " (nCS1 disable detected)" : ""); |
220 | ? " (nCS1 disable detected)" : ""); | ||
221 | 235 | ||
222 | if (timeout < 1 || timeout > 3600) { | 236 | if (timeout < 1 || timeout > 3600) { |
223 | timeout = WDT_TIMEOUT; | 237 | timeout = WDT_TIMEOUT; |
@@ -230,14 +244,23 @@ static int __init ep93xx_wdt_init(void) | |||
230 | return err; | 244 | return err; |
231 | } | 245 | } |
232 | 246 | ||
233 | static void __exit ep93xx_wdt_exit(void) | 247 | static int __devexit ep93xx_wdt_remove(struct platform_device *pdev) |
234 | { | 248 | { |
235 | wdt_shutdown(); | 249 | wdt_shutdown(); |
236 | misc_deregister(&ep93xx_wdt_miscdev); | 250 | misc_deregister(&ep93xx_wdt_miscdev); |
251 | return 0; | ||
237 | } | 252 | } |
238 | 253 | ||
239 | module_init(ep93xx_wdt_init); | 254 | static struct platform_driver ep93xx_wdt_driver = { |
240 | module_exit(ep93xx_wdt_exit); | 255 | .driver = { |
256 | .owner = THIS_MODULE, | ||
257 | .name = "ep93xx-wdt", | ||
258 | }, | ||
259 | .probe = ep93xx_wdt_probe, | ||
260 | .remove = __devexit_p(ep93xx_wdt_remove), | ||
261 | }; | ||
262 | |||
263 | module_platform_driver(ep93xx_wdt_driver); | ||
241 | 264 | ||
242 | module_param(nowayout, int, 0); | 265 | module_param(nowayout, int, 0); |
243 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"); | 266 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"); |