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

ssb: add methods for watchdog driver

The watchdog driver wants to set the watchdog timeout in ms and not in
ticks, which is depending on the SoC type and the clock.
Calculate the number of ticks per millisecond and provide two functions
for the watchdog driver. Also 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
7ffbffe3 26107309

+54 -3
+46 -1
drivers/ssb/driver_chipcommon.c
··· 4 4 * 5 5 * Copyright 2005, Broadcom Corporation 6 6 * Copyright 2006, 2007, Michael Buesch <m@bues.ch> 7 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de> 7 8 * 8 9 * Licensed under the GNU/GPL. See COPYING for details. 9 10 */ ··· 13 12 #include <linux/ssb/ssb_regs.h> 14 13 #include <linux/export.h> 15 14 #include <linux/pci.h> 15 + #include <linux/bcm47xx_wdt.h> 16 16 17 17 #include "ssb_private.h" 18 18 ··· 308 306 return (1 << nb) - 1; 309 307 } 310 308 309 + u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks) 310 + { 311 + struct ssb_chipcommon *cc = bcm47xx_wdt_get_drvdata(wdt); 312 + 313 + if (cc->dev->bus->bustype != SSB_BUSTYPE_SSB) 314 + return 0; 315 + 316 + return ssb_chipco_watchdog_timer_set(cc, ticks); 317 + } 318 + 319 + u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms) 320 + { 321 + struct ssb_chipcommon *cc = bcm47xx_wdt_get_drvdata(wdt); 322 + u32 ticks; 323 + 324 + if (cc->dev->bus->bustype != SSB_BUSTYPE_SSB) 325 + return 0; 326 + 327 + ticks = ssb_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms); 328 + return ticks / cc->ticks_per_ms; 329 + } 330 + 331 + static int ssb_chipco_watchdog_ticks_per_ms(struct ssb_chipcommon *cc) 332 + { 333 + struct ssb_bus *bus = cc->dev->bus; 334 + 335 + if (cc->capabilities & SSB_CHIPCO_CAP_PMU) { 336 + /* based on 32KHz ILP clock */ 337 + return 32; 338 + } else { 339 + if (cc->dev->id.revision < 18) 340 + return ssb_clockspeed(bus) / 1000; 341 + else 342 + return ssb_chipco_alp_clock(cc) / 1000; 343 + } 344 + } 345 + 311 346 void ssb_chipcommon_init(struct ssb_chipcommon *cc) 312 347 { 313 348 if (!cc->dev) ··· 362 323 chipco_powercontrol_init(cc); 363 324 ssb_chipco_set_clockmode(cc, SSB_CLKMODE_FAST); 364 325 calc_fast_powerup_delay(cc); 326 + 327 + if (cc->dev->bus->bustype == SSB_BUSTYPE_SSB) { 328 + cc->ticks_per_ms = ssb_chipco_watchdog_ticks_per_ms(cc); 329 + cc->max_timer_ms = ssb_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms; 330 + } 365 331 } 366 332 367 333 void ssb_chipco_suspend(struct ssb_chipcommon *cc) ··· 465 421 } 466 422 467 423 /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */ 468 - void ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc, u32 ticks) 424 + u32 ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc, u32 ticks) 469 425 { 470 426 u32 maxt; 471 427 enum ssb_clkmode clkmode; ··· 485 441 /* instant NMI */ 486 442 chipco_write32(cc, SSB_CHIPCO_WATCHDOG, ticks); 487 443 } 444 + return ticks; 488 445 } 489 446 490 447 void ssb_chipco_irq_mask(struct ssb_chipcommon *cc, u32 mask, u32 value)
+5
drivers/ssb/ssb_private.h
··· 3 3 4 4 #include <linux/ssb/ssb.h> 5 5 #include <linux/types.h> 6 + #include <linux/bcm47xx_wdt.h> 6 7 7 8 8 9 #define PFX "ssb: " ··· 212 211 extern u32 ssb_pmu_get_cpu_clock(struct ssb_chipcommon *cc); 213 212 extern u32 ssb_pmu_get_controlclock(struct ssb_chipcommon *cc); 214 213 extern u32 ssb_pmu_get_alp_clock(struct ssb_chipcommon *cc); 214 + 215 + extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, 216 + u32 ticks); 217 + extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms); 215 218 216 219 #endif /* LINUX_SSB_PRIVATE_H_ */
+3 -2
include/linux/ssb/ssb_driver_chipcommon.h
··· 591 591 /* Fast Powerup Delay constant */ 592 592 u16 fast_pwrup_delay; 593 593 struct ssb_chipcommon_pmu pmu; 594 + u32 ticks_per_ms; 595 + u32 max_timer_ms; 594 596 }; 595 597 596 598 static inline bool ssb_chipco_available(struct ssb_chipcommon *cc) ··· 632 630 extern void ssb_chipco_set_clockmode(struct ssb_chipcommon *cc, 633 631 enum ssb_clkmode mode); 634 632 635 - extern void ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc, 636 - u32 ticks); 633 + extern u32 ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc, u32 ticks); 637 634 638 635 void ssb_chipco_irq_mask(struct ssb_chipcommon *cc, u32 mask, u32 value); 639 636