Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ssb: extif: add methods for watchdog driver

The watchdog driver wants to set the watchdog timeout in ms and not in
ticks, add a method converting ms to ticks before setting the watchdog
register. Return the ticks or millisecond the timer was set to in case
the provided value was bigger than the max allowed value.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Hauke Mehrtens and committed by
John W. Linville
9f640a63 7280b51a

+40 -5
+20 -1
drivers/ssb/driver_extif.c
··· 112 112 *m = extif_read32(extif, SSB_EXTIF_CLOCK_SB); 113 113 } 114 114 115 - void ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks) 115 + u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks) 116 + { 117 + struct ssb_extif *extif = bcm47xx_wdt_get_drvdata(wdt); 118 + 119 + return ssb_extif_watchdog_timer_set(extif, ticks); 120 + } 121 + 122 + u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms) 123 + { 124 + struct ssb_extif *extif = bcm47xx_wdt_get_drvdata(wdt); 125 + u32 ticks = (SSB_EXTIF_WATCHDOG_CLK / 1000) * ms; 126 + 127 + ticks = ssb_extif_watchdog_timer_set(extif, ticks); 128 + 129 + return (ticks * 1000) / SSB_EXTIF_WATCHDOG_CLK; 130 + } 131 + 132 + u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks) 116 133 { 117 134 if (ticks > SSB_EXTIF_WATCHDOG_MAX_TIMER) 118 135 ticks = SSB_EXTIF_WATCHDOG_MAX_TIMER; 119 136 extif_write32(extif, SSB_EXTIF_WATCHDOG, ticks); 137 + 138 + return ticks; 120 139 } 121 140 122 141 u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask)
+15
drivers/ssb/ssb_private.h
··· 217 217 u32 ticks); 218 218 extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms); 219 219 220 + #ifdef CONFIG_SSB_DRIVER_EXTIF 221 + extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks); 222 + extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms); 223 + #else 224 + static inline u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, 225 + u32 ticks) 226 + { 227 + return 0; 228 + } 229 + static inline u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, 230 + u32 ms) 231 + { 232 + return 0; 233 + } 234 + #endif 220 235 #endif /* LINUX_SSB_PRIVATE_H_ */
+5 -4
include/linux/ssb/ssb_driver_extif.h
··· 153 153 #define SSB_EXTIF_WATCHDOG_CLK 48000000 /* Hz */ 154 154 155 155 #define SSB_EXTIF_WATCHDOG_MAX_TIMER ((1 << 28) - 1) 156 + #define SSB_EXTIF_WATCHDOG_MAX_TIMER_MS (SSB_EXTIF_WATCHDOG_MAX_TIMER \ 157 + / (SSB_EXTIF_WATCHDOG_CLK / 1000)) 156 158 157 159 158 160 #ifdef CONFIG_SSB_DRIVER_EXTIF ··· 174 172 extern void ssb_extif_timing_init(struct ssb_extif *extif, 175 173 unsigned long ns); 176 174 177 - extern void ssb_extif_watchdog_timer_set(struct ssb_extif *extif, 178 - u32 ticks); 175 + extern u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks); 179 176 180 177 /* Extif GPIO pin access */ 181 178 u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask); ··· 212 211 } 213 212 214 213 static inline 215 - void ssb_extif_watchdog_timer_set(struct ssb_extif *extif, 216 - u32 ticks) 214 + u32 ssb_extif_watchdog_timer_set(struct ssb_extif *extif, u32 ticks) 217 215 { 216 + return 0; 218 217 } 219 218 220 219 static inline u32 ssb_extif_gpio_in(struct ssb_extif *extif, u32 mask)