aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap2/Makefile2
-rw-r--r--arch/arm/mach-omap2/devices.c55
-rw-r--r--arch/arm/mach-omap2/wd_timer.c68
-rw-r--r--arch/arm/mach-omap2/wd_timer.h17
4 files changed, 91 insertions, 51 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 1b699d3c6cb8..4a8ea79a2b0c 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -4,7 +4,7 @@
4 4
5# Common support 5# Common support
6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o pm.o \ 6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o pm.o \
7 common.o gpio.o dma.o 7 common.o gpio.o dma.o wd_timer.o
8 8
9omap-2-3-common = irq.o sdrc.o prm2xxx_3xxx.o 9omap-2-3-common = irq.o sdrc.o prm2xxx_3xxx.o
10hwmod-common = omap_hwmod.o \ 10hwmod-common = omap_hwmod.o \
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 1bca147ac91d..9221a486b51f 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -33,6 +33,7 @@
33 33
34#include "mux.h" 34#include "mux.h"
35#include "control.h" 35#include "control.h"
36#include "wd_timer.h"
36 37
37#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE) 38#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
38 39
@@ -955,69 +956,23 @@ static inline void omap_init_vout(void) {}
955 956
956/*-------------------------------------------------------------------------*/ 957/*-------------------------------------------------------------------------*/
957 958
958/*
959 * Inorder to avoid any assumptions from bootloader regarding WDT
960 * settings, WDT module is reset during init. This enables the watchdog
961 * timer. Hence it is required to disable the watchdog after the WDT reset
962 * during init. Otherwise the system would reboot as per the default
963 * watchdog timer registers settings.
964 */
965#define OMAP_WDT_WPS (0x34)
966#define OMAP_WDT_SPR (0x48)
967
968static int omap2_disable_wdt(struct omap_hwmod *oh, void *unused) 959static int omap2_disable_wdt(struct omap_hwmod *oh, void *unused)
969{ 960{
970 void __iomem *base; 961 return omap2_wd_timer_disable(oh);
971 int ret;
972
973 if (!oh) {
974 pr_err("%s: Could not look up wdtimer_hwmod\n", __func__);
975 return -EINVAL;
976 }
977
978 base = omap_hwmod_get_mpu_rt_va(oh);
979 if (!base) {
980 pr_err("%s: Could not get the base address for %s\n",
981 oh->name, __func__);
982 return -EINVAL;
983 }
984
985 /* Enable the clocks before accessing the WDT registers */
986 ret = omap_hwmod_enable(oh);
987 if (ret) {
988 pr_err("%s: Could not enable clocks for %s\n",
989 oh->name, __func__);
990 return ret;
991 }
992
993 /* sequence required to disable watchdog */
994 __raw_writel(0xAAAA, base + OMAP_WDT_SPR);
995 while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
996 cpu_relax();
997
998 __raw_writel(0x5555, base + OMAP_WDT_SPR);
999 while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
1000 cpu_relax();
1001
1002 ret = omap_hwmod_idle(oh);
1003 if (ret)
1004 pr_err("%s: Could not disable clocks for %s\n",
1005 oh->name, __func__);
1006
1007 return ret;
1008} 962}
1009 963
1010static void __init omap_disable_wdt(void) 964static void __init omap_disable_wdt(void)
1011{ 965{
1012 if (cpu_class_is_omap2()) 966 if (cpu_class_is_omap2())
1013 omap_hwmod_for_each_by_class("wd_timer", 967 omap_hwmod_for_each_by_class("wd_timer",
1014 omap2_disable_wdt, NULL); 968 omap2_disable_wdt, NULL);
1015 return; 969 return;
1016} 970}
1017 971
1018static int __init omap2_init_devices(void) 972static int __init omap2_init_devices(void)
1019{ 973{
1020 /* please keep these calls, and their implementations above, 974 /*
975 * please keep these calls, and their implementations above,
1021 * in alphabetical order so they're easier to sort through. 976 * in alphabetical order so they're easier to sort through.
1022 */ 977 */
1023 omap_disable_wdt(); 978 omap_disable_wdt();
diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
new file mode 100644
index 000000000000..06c256d38988
--- /dev/null
+++ b/arch/arm/mach-omap2/wd_timer.c
@@ -0,0 +1,68 @@
1/*
2 * OMAP2+ MPU WD_TIMER-specific code
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9
10#include <linux/kernel.h>
11#include <linux/io.h>
12#include <linux/err.h>
13
14#include <plat/omap_hwmod.h>
15
16/*
17 * In order to avoid any assumptions from bootloader regarding WDT
18 * settings, WDT module is reset during init. This enables the watchdog
19 * timer. Hence it is required to disable the watchdog after the WDT reset
20 * during init. Otherwise the system would reboot as per the default
21 * watchdog timer registers settings.
22 */
23#define OMAP_WDT_WPS 0x34
24#define OMAP_WDT_SPR 0x48
25
26
27int omap2_wd_timer_disable(struct omap_hwmod *oh)
28{
29 void __iomem *base;
30 int ret;
31
32 if (!oh) {
33 pr_err("%s: Could not look up wdtimer_hwmod\n", __func__);
34 return -EINVAL;
35 }
36
37 base = omap_hwmod_get_mpu_rt_va(oh);
38 if (!base) {
39 pr_err("%s: Could not get the base address for %s\n",
40 oh->name, __func__);
41 return -EINVAL;
42 }
43
44 /* Enable the clocks before accessing the WDT registers */
45 ret = omap_hwmod_enable(oh);
46 if (ret) {
47 pr_err("%s: Could not enable clocks for %s\n",
48 oh->name, __func__);
49 return ret;
50 }
51
52 /* sequence required to disable watchdog */
53 __raw_writel(0xAAAA, base + OMAP_WDT_SPR);
54 while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
55 cpu_relax();
56
57 __raw_writel(0x5555, base + OMAP_WDT_SPR);
58 while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
59 cpu_relax();
60
61 ret = omap_hwmod_idle(oh);
62 if (ret)
63 pr_err("%s: Could not disable clocks for %s\n",
64 oh->name, __func__);
65
66 return ret;
67}
68
diff --git a/arch/arm/mach-omap2/wd_timer.h b/arch/arm/mach-omap2/wd_timer.h
new file mode 100644
index 000000000000..e0054a2d5505
--- /dev/null
+++ b/arch/arm/mach-omap2/wd_timer.h
@@ -0,0 +1,17 @@
1/*
2 * OMAP2+ MPU WD_TIMER-specific function prototypes
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9
10#ifndef __ARCH_ARM_MACH_OMAP2_WD_TIMER_H
11#define __ARCH_ARM_MACH_OMAP2_WD_TIMER_H
12
13#include <plat/omap_hwmod.h>
14
15extern int omap2_wd_timer_disable(struct omap_hwmod *oh);
16
17#endif