bcma: register watchdog driver
authorHauke Mehrtens <hauke@hauke-m.de>
Wed, 5 Dec 2012 17:46:02 +0000 (18:46 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 6 Dec 2012 19:58:57 +0000 (14:58 -0500)
Register the watchdog driver to the system if this is a SoC. Using the
watchdog on a non SoC device, like a PCIe card, will make the PCIe
card die when the timeout expired, but starting it again is not
supported by bcma.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/bcma/bcma_private.h
drivers/bcma/driver_chipcommon.c
drivers/bcma/main.c
include/linux/bcma/bcma_driver_chipcommon.h

index 169fc58427d3cefc343c2e1ac229a5c2c280655f..bcb830ec4bb4c03c8dd9a772f71f736adb6f76f8 100644 (file)
@@ -84,6 +84,8 @@ extern void __exit bcma_host_pci_exit(void);
 /* driver_pci.c */
 u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
 
+extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
+
 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
 bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
 void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
index 117222697e1f660887b457c8c51a3e3f2e702e41..d017f25122758bd24135513ce769ca94214f470a 100644 (file)
@@ -12,6 +12,7 @@
 #include "bcma_private.h"
 #include <linux/bcm47xx_wdt.h>
 #include <linux/export.h>
+#include <linux/platform_device.h>
 #include <linux/bcma/bcma.h>
 
 static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
@@ -87,6 +88,27 @@ static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
        }
 }
 
+int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc)
+{
+       struct bcm47xx_wdt wdt = {};
+       struct platform_device *pdev;
+
+       wdt.driver_data = cc;
+       wdt.timer_set = bcma_chipco_watchdog_timer_set_wdt;
+       wdt.timer_set_ms = bcma_chipco_watchdog_timer_set_ms_wdt;
+       wdt.max_timer_ms = bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
+
+       pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
+                                            cc->core->bus->num, &wdt,
+                                            sizeof(wdt));
+       if (IS_ERR(pdev))
+               return PTR_ERR(pdev);
+
+       cc->watchdog = pdev;
+
+       return 0;
+}
+
 void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
 {
        if (cc->early_setup_done)
index a9718893000b907b7b990a673d956f37f05ce17e..debd4f142f936b084ff7d92c517188d7728cf332 100644 (file)
@@ -165,6 +165,12 @@ static int bcma_register_cores(struct bcma_bus *bus)
        }
 #endif
 
+       if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
+               err = bcma_chipco_watchdog_register(&bus->drv_cc);
+               if (err)
+                       bcma_err(bus, "Error registering watchdog driver\n");
+       }
+
        return 0;
 }
 
@@ -177,6 +183,8 @@ static void bcma_unregister_cores(struct bcma_bus *bus)
                if (core->dev_registered)
                        device_unregister(&core->dev);
        }
+       if (bus->hosttype == BCMA_HOSTTYPE_SOC)
+               platform_device_unregister(bus->drv_cc.watchdog);
 }
 
 int __devinit bcma_bus_register(struct bcma_bus *bus)
index 2f9b01493a902f2f2bd243e03859b2e638ea0a45..e51359180b6f7c6bdd85bdd33c86eb6792301ca7 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef LINUX_BCMA_DRIVER_CC_H_
 #define LINUX_BCMA_DRIVER_CC_H_
 
+#include <linux/platform_device.h>
+
 /** ChipCommon core registers. **/
 #define BCMA_CC_ID                     0x0000
 #define  BCMA_CC_ID_ID                 0x0000FFFF
@@ -571,6 +573,7 @@ struct bcma_drv_cc {
        struct bcma_serial_port serial_ports[4];
 #endif /* CONFIG_BCMA_DRIVER_MIPS */
        u32 ticks_per_ms;
+       struct platform_device *watchdog;
 };
 
 /* Register access */