Skip to content

Commit f6354c8

Browse files
haukelinvjw
authored andcommitted
bcma: set the pmu watchdog if available
Mostly all bcma based devices have a PMU and the PMU watchdog should be used and not the old one in chip common. This patch also calculates the maximal number the watchdog could be set to. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 56fd5f0 commit f6354c8

1 file changed

Lines changed: 40 additions & 2 deletions

File tree

‎drivers/bcma/driver_chipcommon.c‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ static u32 bcma_chipco_alp_clock(struct bcma_drv_cc *cc)
3131
return 20000000;
3232
}
3333

34+
static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
35+
{
36+
struct bcma_bus *bus = cc->core->bus;
37+
u32 nb;
38+
39+
if (cc->capabilities & BCMA_CC_CAP_PMU) {
40+
if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
41+
nb = 32;
42+
else if (cc->core->id.rev < 26)
43+
nb = 16;
44+
else
45+
nb = (cc->core->id.rev >= 37) ? 32 : 24;
46+
} else {
47+
nb = 28;
48+
}
49+
if (nb == 32)
50+
return 0xffffffff;
51+
else
52+
return (1 << nb) - 1;
53+
}
54+
55+
3456
void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
3557
{
3658
if (cc->early_setup_done)
@@ -85,8 +107,24 @@ void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
85107
/* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
86108
void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
87109
{
88-
/* instant NMI */
89-
bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
110+
u32 maxt;
111+
enum bcma_clkmode clkmode;
112+
113+
maxt = bcma_chipco_watchdog_get_max_timer(cc);
114+
if (cc->capabilities & BCMA_CC_CAP_PMU) {
115+
if (ticks == 1)
116+
ticks = 2;
117+
else if (ticks > maxt)
118+
ticks = maxt;
119+
bcma_cc_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
120+
} else {
121+
clkmode = ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC;
122+
bcma_core_set_clockmode(cc->core, clkmode);
123+
if (ticks > maxt)
124+
ticks = maxt;
125+
/* instant NMI */
126+
bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
127+
}
90128
}
91129

92130
void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value)

0 commit comments

Comments
 (0)