aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bcma/driver_chipcommon.c
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2012-12-05 12:46:01 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-12-06 14:58:56 -0500
commita22a3114a820ca3eadee6af53d90736e5ca68fa1 (patch)
tree7ef75f05f651badbe8f7ef4ad7fd985f0dd214b0 /drivers/bcma/driver_chipcommon.c
parentf6354c8cf9a3be15de441fad593ce53e63e9bf2a (diff)
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>
Diffstat (limited to 'drivers/bcma/driver_chipcommon.c')
-rw-r--r--drivers/bcma/driver_chipcommon.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/drivers/bcma/driver_chipcommon.c b/drivers/bcma/driver_chipcommon.c
index 7c132e5eceb0..117222697e1f 100644
--- a/drivers/bcma/driver_chipcommon.c
+++ b/drivers/bcma/driver_chipcommon.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include "bcma_private.h" 12#include "bcma_private.h"
13#include <linux/bcm47xx_wdt.h>
13#include <linux/export.h> 14#include <linux/export.h>
14#include <linux/bcma/bcma.h> 15#include <linux/bcma/bcma.h>
15 16
@@ -52,6 +53,39 @@ static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
52 return (1 << nb) - 1; 53 return (1 << nb) - 1;
53} 54}
54 55
56static 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
64static 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
74static 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}
55 89
56void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc) 90void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
57{ 91{
@@ -100,12 +134,13 @@ void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
100 ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) | 134 ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
101 (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT))); 135 (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
102 } 136 }
137 cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
103 138
104 cc->setup_done = true; 139 cc->setup_done = true;
105} 140}
106 141
107/* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */ 142/* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
108void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks) 143u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
109{ 144{
110 u32 maxt; 145 u32 maxt;
111 enum bcma_clkmode clkmode; 146 enum bcma_clkmode clkmode;
@@ -125,6 +160,7 @@ void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
125 /* instant NMI */ 160 /* instant NMI */
126 bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks); 161 bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
127 } 162 }
163 return ticks;
128} 164}
129 165
130void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value) 166void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value)