Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 1 | /* |
| 2 | * DaVinci timer subsystem |
| 3 | * |
| 4 | * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com> |
| 5 | * |
| 6 | * 2007 (c) MontaVista Software, Inc. This file is licensed under |
| 7 | * the terms of the GNU General Public License version 2. This program |
| 8 | * is licensed "as is" without any warranty of any kind, whether express |
| 9 | * or implied. |
| 10 | */ |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/types.h> |
| 14 | #include <linux/interrupt.h> |
| 15 | #include <linux/clocksource.h> |
| 16 | #include <linux/clockchips.h> |
| 17 | #include <linux/spinlock.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 18 | #include <linux/io.h> |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 19 | #include <linux/clk.h> |
| 20 | #include <linux/err.h> |
| 21 | #include <linux/device.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 22 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 23 | #include <mach/hardware.h> |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 24 | #include <asm/system.h> |
| 25 | #include <asm/irq.h> |
| 26 | #include <asm/mach/irq.h> |
| 27 | #include <asm/mach/time.h> |
| 28 | #include <asm/errno.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 29 | #include <mach/io.h> |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 30 | #include <mach/cputype.h> |
| 31 | #include "clock.h" |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 32 | |
| 33 | static struct clock_event_device clockevent_davinci; |
| 34 | |
| 35 | #define DAVINCI_TIMER0_BASE (IO_PHYS + 0x21400) |
| 36 | #define DAVINCI_TIMER1_BASE (IO_PHYS + 0x21800) |
| 37 | #define DAVINCI_WDOG_BASE (IO_PHYS + 0x21C00) |
| 38 | |
| 39 | enum { |
| 40 | T0_BOT = 0, T0_TOP, T1_BOT, T1_TOP, NUM_TIMERS, |
| 41 | }; |
| 42 | |
| 43 | #define IS_TIMER1(id) (id & 0x2) |
| 44 | #define IS_TIMER0(id) (!IS_TIMER1(id)) |
| 45 | #define IS_TIMER_TOP(id) ((id & 0x1)) |
| 46 | #define IS_TIMER_BOT(id) (!IS_TIMER_TOP(id)) |
| 47 | |
| 48 | static int timer_irqs[NUM_TIMERS] = { |
| 49 | IRQ_TINT0_TINT12, |
| 50 | IRQ_TINT0_TINT34, |
| 51 | IRQ_TINT1_TINT12, |
| 52 | IRQ_TINT1_TINT34, |
| 53 | }; |
| 54 | |
| 55 | /* |
| 56 | * This driver configures the 2 64-bit count-up timers as 4 independent |
| 57 | * 32-bit count-up timers used as follows: |
| 58 | * |
| 59 | * T0_BOT: Timer 0, bottom: clockevent source for hrtimers |
| 60 | * T0_TOP: Timer 0, top : clocksource for generic timekeeping |
| 61 | * T1_BOT: Timer 1, bottom: (used by DSP in TI DSPLink code) |
| 62 | * T1_TOP: Timer 1, top : <unused> |
| 63 | */ |
| 64 | #define TID_CLOCKEVENT T0_BOT |
| 65 | #define TID_CLOCKSOURCE T0_TOP |
| 66 | |
| 67 | /* Timer register offsets */ |
| 68 | #define PID12 0x0 |
| 69 | #define TIM12 0x10 |
| 70 | #define TIM34 0x14 |
| 71 | #define PRD12 0x18 |
| 72 | #define PRD34 0x1c |
| 73 | #define TCR 0x20 |
| 74 | #define TGCR 0x24 |
| 75 | #define WDTCR 0x28 |
| 76 | |
| 77 | /* Timer register bitfields */ |
| 78 | #define TCR_ENAMODE_DISABLE 0x0 |
| 79 | #define TCR_ENAMODE_ONESHOT 0x1 |
| 80 | #define TCR_ENAMODE_PERIODIC 0x2 |
| 81 | #define TCR_ENAMODE_MASK 0x3 |
| 82 | |
| 83 | #define TGCR_TIMMODE_SHIFT 2 |
| 84 | #define TGCR_TIMMODE_64BIT_GP 0x0 |
| 85 | #define TGCR_TIMMODE_32BIT_UNCHAINED 0x1 |
| 86 | #define TGCR_TIMMODE_64BIT_WDOG 0x2 |
| 87 | #define TGCR_TIMMODE_32BIT_CHAINED 0x3 |
| 88 | |
| 89 | #define TGCR_TIM12RS_SHIFT 0 |
| 90 | #define TGCR_TIM34RS_SHIFT 1 |
| 91 | #define TGCR_RESET 0x0 |
| 92 | #define TGCR_UNRESET 0x1 |
| 93 | #define TGCR_RESET_MASK 0x3 |
| 94 | |
| 95 | #define WDTCR_WDEN_SHIFT 14 |
| 96 | #define WDTCR_WDEN_DISABLE 0x0 |
| 97 | #define WDTCR_WDEN_ENABLE 0x1 |
| 98 | #define WDTCR_WDKEY_SHIFT 16 |
| 99 | #define WDTCR_WDKEY_SEQ0 0xa5c6 |
| 100 | #define WDTCR_WDKEY_SEQ1 0xda7e |
| 101 | |
| 102 | struct timer_s { |
| 103 | char *name; |
| 104 | unsigned int id; |
| 105 | unsigned long period; |
| 106 | unsigned long opts; |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 107 | void __iomem *base; |
| 108 | unsigned long tim_off; |
| 109 | unsigned long prd_off; |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 110 | unsigned long enamode_shift; |
| 111 | struct irqaction irqaction; |
| 112 | }; |
| 113 | static struct timer_s timers[]; |
| 114 | |
| 115 | /* values for 'opts' field of struct timer_s */ |
| 116 | #define TIMER_OPTS_DISABLED 0x00 |
| 117 | #define TIMER_OPTS_ONESHOT 0x01 |
| 118 | #define TIMER_OPTS_PERIODIC 0x02 |
| 119 | |
| 120 | static int timer32_config(struct timer_s *t) |
| 121 | { |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 122 | u32 tcr = __raw_readl(t->base + TCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 123 | |
| 124 | /* disable timer */ |
| 125 | tcr &= ~(TCR_ENAMODE_MASK << t->enamode_shift); |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 126 | __raw_writel(tcr, t->base + TCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 127 | |
| 128 | /* reset counter to zero, set new period */ |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 129 | __raw_writel(0, t->base + t->tim_off); |
| 130 | __raw_writel(t->period, t->base + t->prd_off); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 131 | |
| 132 | /* Set enable mode */ |
| 133 | if (t->opts & TIMER_OPTS_ONESHOT) { |
| 134 | tcr |= TCR_ENAMODE_ONESHOT << t->enamode_shift; |
| 135 | } else if (t->opts & TIMER_OPTS_PERIODIC) { |
| 136 | tcr |= TCR_ENAMODE_PERIODIC << t->enamode_shift; |
| 137 | } |
| 138 | |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 139 | __raw_writel(tcr, t->base + TCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 140 | return 0; |
| 141 | } |
| 142 | |
| 143 | static inline u32 timer32_read(struct timer_s *t) |
| 144 | { |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 145 | return __raw_readl(t->base + t->tim_off); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | static irqreturn_t timer_interrupt(int irq, void *dev_id) |
| 149 | { |
| 150 | struct clock_event_device *evt = &clockevent_davinci; |
| 151 | |
| 152 | evt->event_handler(evt); |
| 153 | return IRQ_HANDLED; |
| 154 | } |
| 155 | |
| 156 | /* called when 32-bit counter wraps */ |
| 157 | static irqreturn_t freerun_interrupt(int irq, void *dev_id) |
| 158 | { |
| 159 | return IRQ_HANDLED; |
| 160 | } |
| 161 | |
| 162 | static struct timer_s timers[] = { |
| 163 | [TID_CLOCKEVENT] = { |
| 164 | .name = "clockevent", |
| 165 | .opts = TIMER_OPTS_DISABLED, |
| 166 | .irqaction = { |
| 167 | .flags = IRQF_DISABLED | IRQF_TIMER, |
| 168 | .handler = timer_interrupt, |
| 169 | } |
| 170 | }, |
| 171 | [TID_CLOCKSOURCE] = { |
| 172 | .name = "free-run counter", |
| 173 | .period = ~0, |
| 174 | .opts = TIMER_OPTS_PERIODIC, |
| 175 | .irqaction = { |
| 176 | .flags = IRQF_DISABLED | IRQF_TIMER, |
| 177 | .handler = freerun_interrupt, |
| 178 | } |
| 179 | }, |
| 180 | }; |
| 181 | |
| 182 | static void __init timer_init(void) |
| 183 | { |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 184 | u32 phys_bases[] = {DAVINCI_TIMER0_BASE, DAVINCI_TIMER1_BASE}; |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 185 | int i; |
| 186 | |
| 187 | /* Global init of each 64-bit timer as a whole */ |
| 188 | for(i=0; i<2; i++) { |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 189 | u32 tgcr; |
| 190 | void __iomem *base = IO_ADDRESS(phys_bases[i]); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 191 | |
| 192 | /* Disabled, Internal clock source */ |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 193 | __raw_writel(0, base + TCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 194 | |
| 195 | /* reset both timers, no pre-scaler for timer34 */ |
| 196 | tgcr = 0; |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 197 | __raw_writel(tgcr, base + TGCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 198 | |
| 199 | /* Set both timers to unchained 32-bit */ |
| 200 | tgcr = TGCR_TIMMODE_32BIT_UNCHAINED << TGCR_TIMMODE_SHIFT; |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 201 | __raw_writel(tgcr, base + TGCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 202 | |
| 203 | /* Unreset timers */ |
| 204 | tgcr |= (TGCR_UNRESET << TGCR_TIM12RS_SHIFT) | |
| 205 | (TGCR_UNRESET << TGCR_TIM34RS_SHIFT); |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 206 | __raw_writel(tgcr, base + TGCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 207 | |
| 208 | /* Init both counters to zero */ |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 209 | __raw_writel(0, base + TIM12); |
| 210 | __raw_writel(0, base + TIM34); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | /* Init of each timer as a 32-bit timer */ |
| 214 | for (i=0; i< ARRAY_SIZE(timers); i++) { |
| 215 | struct timer_s *t = &timers[i]; |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 216 | u32 phys_base; |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 217 | |
| 218 | if (t->name) { |
| 219 | t->id = i; |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 220 | phys_base = (IS_TIMER1(t->id) ? |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 221 | DAVINCI_TIMER1_BASE : DAVINCI_TIMER0_BASE); |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 222 | t->base = IO_ADDRESS(phys_base); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 223 | |
| 224 | if (IS_TIMER_BOT(t->id)) { |
| 225 | t->enamode_shift = 6; |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 226 | t->tim_off = TIM12; |
| 227 | t->prd_off = PRD12; |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 228 | } else { |
| 229 | t->enamode_shift = 22; |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 230 | t->tim_off = TIM34; |
| 231 | t->prd_off = PRD34; |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | /* Register interrupt */ |
| 235 | t->irqaction.name = t->name; |
| 236 | t->irqaction.dev_id = (void *)t; |
| 237 | if (t->irqaction.handler != NULL) { |
| 238 | setup_irq(timer_irqs[t->id], &t->irqaction); |
| 239 | } |
| 240 | |
| 241 | timer32_config(&timers[i]); |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /* |
| 247 | * clocksource |
| 248 | */ |
Magnus Damm | 8e19608 | 2009-04-21 12:24:00 -0700 | [diff] [blame] | 249 | static cycle_t read_cycles(struct clocksource *cs) |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 250 | { |
| 251 | struct timer_s *t = &timers[TID_CLOCKSOURCE]; |
| 252 | |
| 253 | return (cycles_t)timer32_read(t); |
| 254 | } |
| 255 | |
| 256 | static struct clocksource clocksource_davinci = { |
| 257 | .name = "timer0_1", |
| 258 | .rating = 300, |
| 259 | .read = read_cycles, |
| 260 | .mask = CLOCKSOURCE_MASK(32), |
| 261 | .shift = 24, |
| 262 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
| 263 | }; |
| 264 | |
| 265 | /* |
| 266 | * clockevent |
| 267 | */ |
| 268 | static int davinci_set_next_event(unsigned long cycles, |
| 269 | struct clock_event_device *evt) |
| 270 | { |
| 271 | struct timer_s *t = &timers[TID_CLOCKEVENT]; |
| 272 | |
| 273 | t->period = cycles; |
| 274 | timer32_config(t); |
| 275 | return 0; |
| 276 | } |
| 277 | |
| 278 | static void davinci_set_mode(enum clock_event_mode mode, |
| 279 | struct clock_event_device *evt) |
| 280 | { |
| 281 | struct timer_s *t = &timers[TID_CLOCKEVENT]; |
| 282 | |
| 283 | switch (mode) { |
| 284 | case CLOCK_EVT_MODE_PERIODIC: |
| 285 | t->period = CLOCK_TICK_RATE / (HZ); |
| 286 | t->opts = TIMER_OPTS_PERIODIC; |
| 287 | timer32_config(t); |
| 288 | break; |
| 289 | case CLOCK_EVT_MODE_ONESHOT: |
| 290 | t->opts = TIMER_OPTS_ONESHOT; |
| 291 | break; |
| 292 | case CLOCK_EVT_MODE_UNUSED: |
| 293 | case CLOCK_EVT_MODE_SHUTDOWN: |
| 294 | t->opts = TIMER_OPTS_DISABLED; |
| 295 | break; |
Thomas Gleixner | 18de5bc | 2007-07-21 04:37:34 -0700 | [diff] [blame] | 296 | case CLOCK_EVT_MODE_RESUME: |
| 297 | break; |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | |
| 301 | static struct clock_event_device clockevent_davinci = { |
| 302 | .name = "timer0_0", |
| 303 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, |
| 304 | .shift = 32, |
| 305 | .set_next_event = davinci_set_next_event, |
| 306 | .set_mode = davinci_set_mode, |
| 307 | }; |
| 308 | |
| 309 | |
| 310 | static void __init davinci_timer_init(void) |
| 311 | { |
| 312 | static char err[] __initdata = KERN_ERR |
| 313 | "%s: can't register clocksource!\n"; |
| 314 | |
| 315 | /* init timer hw */ |
| 316 | timer_init(); |
| 317 | |
| 318 | /* setup clocksource */ |
| 319 | clocksource_davinci.mult = |
| 320 | clocksource_khz2mult(CLOCK_TICK_RATE/1000, |
| 321 | clocksource_davinci.shift); |
| 322 | if (clocksource_register(&clocksource_davinci)) |
| 323 | printk(err, clocksource_davinci.name); |
| 324 | |
| 325 | /* setup clockevent */ |
| 326 | clockevent_davinci.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, |
| 327 | clockevent_davinci.shift); |
| 328 | clockevent_davinci.max_delta_ns = |
| 329 | clockevent_delta2ns(0xfffffffe, &clockevent_davinci); |
| 330 | clockevent_davinci.min_delta_ns = |
| 331 | clockevent_delta2ns(1, &clockevent_davinci); |
| 332 | |
Rusty Russell | 320ab2b | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 333 | clockevent_davinci.cpumask = cpumask_of(0); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 334 | clockevents_register_device(&clockevent_davinci); |
| 335 | } |
| 336 | |
| 337 | struct sys_timer davinci_timer = { |
| 338 | .init = davinci_timer_init, |
| 339 | }; |
| 340 | |
| 341 | |
| 342 | /* reset board using watchdog timer */ |
| 343 | void davinci_watchdog_reset(void) { |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 344 | u32 tgcr, wdtcr; |
| 345 | void __iomem *base = IO_ADDRESS(DAVINCI_WDOG_BASE); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 346 | |
| 347 | /* disable, internal clock source */ |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 348 | __raw_writel(0, base + TCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 349 | |
| 350 | /* reset timer, set mode to 64-bit watchdog, and unreset */ |
| 351 | tgcr = 0; |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 352 | __raw_writel(tgcr, base + TCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 353 | tgcr = TGCR_TIMMODE_64BIT_WDOG << TGCR_TIMMODE_SHIFT; |
| 354 | tgcr |= (TGCR_UNRESET << TGCR_TIM12RS_SHIFT) | |
| 355 | (TGCR_UNRESET << TGCR_TIM34RS_SHIFT); |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 356 | __raw_writel(tgcr, base + TCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 357 | |
| 358 | /* clear counter and period regs */ |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 359 | __raw_writel(0, base + TIM12); |
| 360 | __raw_writel(0, base + TIM34); |
| 361 | __raw_writel(0, base + PRD12); |
| 362 | __raw_writel(0, base + PRD34); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 363 | |
| 364 | /* enable */ |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 365 | wdtcr = __raw_readl(base + WDTCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 366 | wdtcr |= WDTCR_WDEN_ENABLE << WDTCR_WDEN_SHIFT; |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 367 | __raw_writel(wdtcr, base + WDTCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 368 | |
| 369 | /* put watchdog in pre-active state */ |
| 370 | wdtcr = (WDTCR_WDKEY_SEQ0 << WDTCR_WDKEY_SHIFT) | |
| 371 | (WDTCR_WDEN_ENABLE << WDTCR_WDEN_SHIFT); |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 372 | __raw_writel(wdtcr, base + WDTCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 373 | |
| 374 | /* put watchdog in active state */ |
| 375 | wdtcr = (WDTCR_WDKEY_SEQ1 << WDTCR_WDKEY_SHIFT) | |
| 376 | (WDTCR_WDEN_ENABLE << WDTCR_WDEN_SHIFT); |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 377 | __raw_writel(wdtcr, base + WDTCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 378 | |
| 379 | /* write an invalid value to the WDKEY field to trigger |
| 380 | * a watchdog reset */ |
| 381 | wdtcr = 0x00004000; |
Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame^] | 382 | __raw_writel(wdtcr, base + WDTCR); |
Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 383 | } |