[WATCHDOG] Fix COH 901 327 watchdog enablement

Since the COH 901 327 found in U300 is clocked at 32 kHz we need
to wait for the interrupt clearing flag to propagate through
hardware in order not to accidentally fire off any interrupts
when we enable them.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by Linus Walleij and committed by Wim Van Sebroeck 5973bee4 ed680c4a

+11
+11
drivers/watchdog/coh901327_wdt.c
··· 18 18 #include <linux/bitops.h> 19 19 #include <linux/uaccess.h> 20 20 #include <linux/clk.h> 21 + #include <linux/delay.h> 21 22 22 23 #define DRV_NAME "WDOG COH 901 327" 23 24 ··· 93 92 static void coh901327_enable(u16 timeout) 94 93 { 95 94 u16 val; 95 + unsigned long freq; 96 + unsigned long delay_ns; 96 97 97 98 clk_enable(clk); 98 99 /* Restart timer if it is disabled */ ··· 105 102 /* Acknowledge any pending interrupt so it doesn't just fire off */ 106 103 writew(U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE, 107 104 virtbase + U300_WDOG_IER); 105 + /* 106 + * The interrupt is cleared in the 32 kHz clock domain. 107 + * Wait 3 32 kHz cycles for it to take effect 108 + */ 109 + freq = clk_get_rate(clk); 110 + delay_ns = (1000000000 + freq - 1) / freq; /* Freq to ns and round up */ 111 + delay_ns = 3 * delay_ns; /* Wait 3 cycles */ 112 + ndelay(delay_ns); 108 113 /* Enable the watchdog interrupt */ 109 114 writew(U300_WDOG_IMR_WILL_BARK_IRQ_ENABLE, virtbase + U300_WDOG_IMR); 110 115 /* Activate the watchdog timer */