ar71xx: add profile and build initramfs image for the WNDR4300
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.6 / 547-bcma-add-methods-for-watchdog-driver.patch
1 --- a/drivers/bcma/driver_chipcommon.c
2 +++ b/drivers/bcma/driver_chipcommon.c
3 @@ -10,6 +10,7 @@
4 */
5
6 #include "bcma_private.h"
7 +#include <linux/bcm47xx_wdt.h>
8 #include <linux/export.h>
9 #include <linux/bcma/bcma.h>
10
11 @@ -52,6 +53,39 @@ static u32 bcma_chipco_watchdog_get_max_
12 return (1 << nb) - 1;
13 }
14
15 +static u32 bcma_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
16 + u32 ticks)
17 +{
18 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
19 +
20 + return bcma_chipco_watchdog_timer_set(cc, ticks);
21 +}
22 +
23 +static u32 bcma_chipco_watchdog_timer_set_ms_wdt(struct bcm47xx_wdt *wdt,
24 + u32 ms)
25 +{
26 + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
27 + u32 ticks;
28 +
29 + ticks = bcma_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms);
30 + return ticks / cc->ticks_per_ms;
31 +}
32 +
33 +static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
34 +{
35 + struct bcma_bus *bus = cc->core->bus;
36 +
37 + if (cc->capabilities & BCMA_CC_CAP_PMU) {
38 + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
39 + /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */
40 + return bcma_chipco_alp_clock(cc) / 4000;
41 + else
42 + /* based on 32KHz ILP clock */
43 + return 32;
44 + } else {
45 + return bcma_chipco_alp_clock(cc) / 1000;
46 + }
47 +}
48
49 void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
50 {
51 @@ -102,12 +136,13 @@ void bcma_core_chipcommon_init(struct bc
52 }
53
54 spin_lock_init(&cc->gpio_lock);
55 + cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
56
57 cc->setup_done = true;
58 }
59
60 /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
61 -void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
62 +u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
63 {
64 u32 maxt;
65 enum bcma_clkmode clkmode;
66 @@ -126,6 +161,7 @@ void bcma_chipco_watchdog_timer_set(stru
67 ticks = maxt;
68 bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
69 }
70 + return ticks;
71 }
72
73 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value)
74 --- a/include/linux/bcma/bcma_driver_chipcommon.h
75 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
76 @@ -554,6 +554,7 @@ struct bcma_drv_cc {
77
78 /* Lock for GPIO register access. */
79 spinlock_t gpio_lock;
80 + u32 ticks_per_ms;
81 };
82
83 /* Register access */
84 @@ -577,8 +578,7 @@ extern void bcma_chipco_resume(struct bc
85
86 void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
87
88 -extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
89 - u32 ticks);
90 +extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
91
92 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
93