[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 #include <linux/bitops.h> 19 #include <linux/uaccess.h> 20 #include <linux/clk.h> 21 22 #define DRV_NAME "WDOG COH 901 327" 23 ··· 93 static void coh901327_enable(u16 timeout) 94 { 95 u16 val; 96 97 clk_enable(clk); 98 /* Restart timer if it is disabled */ ··· 105 /* Acknowledge any pending interrupt so it doesn't just fire off */ 106 writew(U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE, 107 virtbase + U300_WDOG_IER); 108 /* Enable the watchdog interrupt */ 109 writew(U300_WDOG_IMR_WILL_BARK_IRQ_ENABLE, virtbase + U300_WDOG_IMR); 110 /* Activate the watchdog timer */
··· 18 #include <linux/bitops.h> 19 #include <linux/uaccess.h> 20 #include <linux/clk.h> 21 + #include <linux/delay.h> 22 23 #define DRV_NAME "WDOG COH 901 327" 24 ··· 92 static void coh901327_enable(u16 timeout) 93 { 94 u16 val; 95 + unsigned long freq; 96 + unsigned long delay_ns; 97 98 clk_enable(clk); 99 /* Restart timer if it is disabled */ ··· 102 /* Acknowledge any pending interrupt so it doesn't just fire off */ 103 writew(U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE, 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); 113 /* Enable the watchdog interrupt */ 114 writew(U300_WDOG_IMR_WILL_BARK_IRQ_ENABLE, virtbase + U300_WDOG_IMR); 115 /* Activate the watchdog timer */