brcm47xx: update watchdog driver
[openwrt.git] / target / linux / brcm47xx / patches-3.6 / 548-bcma-register-watchdog-driver.patch
1 --- a/drivers/bcma/bcma_private.h
2 +++ b/drivers/bcma/bcma_private.h
3 @@ -85,6 +85,8 @@ extern void __exit bcma_host_pci_exit(vo
4  /* driver_pci.c */
5  u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
6  
7 +extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
8 +
9  #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
10  bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
11  void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
12 --- a/drivers/bcma/driver_chipcommon.c
13 +++ b/drivers/bcma/driver_chipcommon.c
14 @@ -12,6 +12,7 @@
15  #include "bcma_private.h"
16  #include <linux/bcm47xx_wdt.h>
17  #include <linux/export.h>
18 +#include <linux/platform_device.h>
19  #include <linux/bcma/bcma.h>
20  
21  static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
22 @@ -87,6 +88,27 @@ static int bcma_chipco_watchdog_ticks_pe
23         }
24  }
25  
26 +int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc)
27 +{
28 +       struct bcm47xx_wdt wdt = {};
29 +       struct platform_device *pdev;
30 +
31 +       wdt.driver_data = cc;
32 +       wdt.timer_set = bcma_chipco_watchdog_timer_set_wdt;
33 +       wdt.timer_set_ms = bcma_chipco_watchdog_timer_set_ms_wdt;
34 +       wdt.max_timer_ms = bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
35 +
36 +       pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
37 +                                            cc->core->bus->num, &wdt,
38 +                                            sizeof(wdt));
39 +       if (IS_ERR(pdev))
40 +               return PTR_ERR(pdev);
41 +
42 +       cc->watchdog = pdev;
43 +
44 +       return 0;
45 +}
46 +
47  void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
48  {
49         if (cc->early_setup_done)
50 --- a/drivers/bcma/main.c
51 +++ b/drivers/bcma/main.c
52 @@ -173,6 +173,12 @@ static int bcma_register_cores(struct bc
53         }
54  #endif
55  
56 +       if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
57 +               err = bcma_chipco_watchdog_register(&bus->drv_cc);
58 +               if (err)
59 +                       bcma_err(bus, "Error registering watchdog driver\n");
60 +       }
61 +
62         return 0;
63  }
64  
65 @@ -185,6 +191,8 @@ static void bcma_unregister_cores(struct
66                 if (core->dev_registered)
67                         device_unregister(&core->dev);
68         }
69 +       if (bus->hosttype == BCMA_HOSTTYPE_SOC)
70 +               platform_device_unregister(bus->drv_cc.watchdog);
71  }
72  
73  int __devinit bcma_bus_register(struct bcma_bus *bus)
74 --- a/include/linux/bcma/bcma_driver_chipcommon.h
75 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
76 @@ -4,6 +4,8 @@
77  #include <linux/mtd/bcm47xx_sflash.h>
78  #include <linux/mtd/bcm47xx_nand.h>
79  
80 +#include <linux/platform_device.h>
81 +
82  /** ChipCommon core registers. **/
83  #define BCMA_CC_ID                     0x0000
84  #define  BCMA_CC_ID_ID                 0x0000FFFF
85 @@ -555,6 +557,7 @@ struct bcma_drv_cc {
86         /* Lock for GPIO register access. */
87         spinlock_t gpio_lock;
88         u32 ticks_per_ms;
89 +       struct platform_device *watchdog;
90  };
91  
92  /* Register access */