Skip to content

Commit a22a311

Browse files
haukelinvjw
authored andcommitted
bcma: 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>
1 parent f6354c8 commit a22a311

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

‎drivers/bcma/driver_chipcommon.c‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include "bcma_private.h"
13+
#include <linux/bcm47xx_wdt.h>
1314
#include <linux/export.h>
1415
#include <linux/bcma/bcma.h>
1516

@@ -52,6 +53,39 @@ static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
5253
return (1 << nb) - 1;
5354
}
5455

56+
static u32 bcma_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
57+
u32 ticks)
58+
{
59+
struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
60+
61+
return bcma_chipco_watchdog_timer_set(cc, ticks);
62+
}
63+
64+
static u32 bcma_chipco_watchdog_timer_set_ms_wdt(struct bcm47xx_wdt *wdt,
65+
u32 ms)
66+
{
67+
struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
68+
u32 ticks;
69+
70+
ticks = bcma_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms);
71+
return ticks / cc->ticks_per_ms;
72+
}
73+
74+
static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
75+
{
76+
struct bcma_bus *bus = cc->core->bus;
77+
78+
if (cc->capabilities & BCMA_CC_CAP_PMU) {
79+
if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
80+
/* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */
81+
return bcma_chipco_alp_clock(cc) / 4000;
82+
else
83+
/* based on 32KHz ILP clock */
84+
return 32;
85+
} else {
86+
return bcma_chipco_alp_clock(cc) / 1000;
87+
}
88+
}
5589

5690
void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
5791
{
@@ -100,12 +134,13 @@ void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
100134
((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
101135
(leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
102136
}
137+
cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
103138

104139
cc->setup_done = true;
105140
}
106141

107142
/* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
108-
void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
143+
u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
109144
{
110145
u32 maxt;
111146
enum bcma_clkmode clkmode;
@@ -125,6 +160,7 @@ void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
125160
/* instant NMI */
126161
bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
127162
}
163+
return ticks;
128164
}
129165

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

‎include/linux/bcma/bcma_driver_chipcommon.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ struct bcma_drv_cc {
570570
int nr_serial_ports;
571571
struct bcma_serial_port serial_ports[4];
572572
#endif /* CONFIG_BCMA_DRIVER_MIPS */
573+
u32 ticks_per_ms;
573574
};
574575

575576
/* Register access */
@@ -593,8 +594,7 @@ extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
593594

594595
void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
595596

596-
extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
597-
u32 ticks);
597+
extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
598598

599599
void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
600600

0 commit comments

Comments
 (0)