0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/kernel.h>
0009 #include <linux/io.h>
0010 #include <linux/err.h>
0011
0012 #include <linux/platform_data/omap-wd-timer.h>
0013
0014 #include "omap_hwmod.h"
0015 #include "omap_device.h"
0016 #include "wd_timer.h"
0017 #include "common.h"
0018 #include "prm.h"
0019 #include "soc.h"
0020
0021
0022
0023
0024
0025
0026
0027
0028 #define OMAP_WDT_WPS 0x34
0029 #define OMAP_WDT_SPR 0x48
0030
0031 int omap2_wd_timer_disable(struct omap_hwmod *oh)
0032 {
0033 void __iomem *base;
0034
0035 if (!oh) {
0036 pr_err("%s: Could not look up wdtimer_hwmod\n", __func__);
0037 return -EINVAL;
0038 }
0039
0040 base = omap_hwmod_get_mpu_rt_va(oh);
0041 if (!base) {
0042 pr_err("%s: Could not get the base address for %s\n",
0043 oh->name, __func__);
0044 return -EINVAL;
0045 }
0046
0047
0048 writel_relaxed(0xAAAA, base + OMAP_WDT_SPR);
0049 while (readl_relaxed(base + OMAP_WDT_WPS) & 0x10)
0050 cpu_relax();
0051
0052 writel_relaxed(0x5555, base + OMAP_WDT_SPR);
0053 while (readl_relaxed(base + OMAP_WDT_WPS) & 0x10)
0054 cpu_relax();
0055
0056 return 0;
0057 }
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 int omap2_wd_timer_reset(struct omap_hwmod *oh)
0076 {
0077 int c = 0;
0078
0079
0080 omap_hwmod_softreset(oh);
0081
0082
0083 omap_test_timeout((omap_hwmod_read(oh,
0084 oh->class->sysc->syss_offs)
0085 & SYSS_RESETDONE_MASK),
0086 MAX_MODULE_SOFTRESET_WAIT, c);
0087
0088 if (oh->class->sysc->srst_udelay)
0089 udelay(oh->class->sysc->srst_udelay);
0090
0091 if (c == MAX_MODULE_SOFTRESET_WAIT)
0092 pr_warn("%s: %s: softreset failed (waited %d usec)\n",
0093 __func__, oh->name, MAX_MODULE_SOFTRESET_WAIT);
0094 else
0095 pr_debug("%s: %s: softreset in %d usec\n", __func__,
0096 oh->name, c);
0097
0098 return (c == MAX_MODULE_SOFTRESET_WAIT) ? -ETIMEDOUT :
0099 omap2_wd_timer_disable(oh);
0100 }