ar71xx: add profile and build initramfs image for the WNDR4300
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.6 / 554-ssb-register-watchdog-driver.patch
1 --- a/drivers/ssb/embedded.c
2 +++ b/drivers/ssb/embedded.c
3 @@ -4,11 +4,13 @@
4 *
5 * Copyright 2005-2008, Broadcom Corporation
6 * Copyright 2006-2008, Michael Buesch <m@bues.ch>
7 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
8 *
9 * Licensed under the GNU/GPL. See COPYING for details.
10 */
11
12 #include <linux/export.h>
13 +#include <linux/platform_device.h>
14 #include <linux/ssb/ssb.h>
15 #include <linux/ssb/ssb_embedded.h>
16 #include <linux/ssb/ssb_driver_pci.h>
17 @@ -32,6 +34,39 @@ int ssb_watchdog_timer_set(struct ssb_bu
18 }
19 EXPORT_SYMBOL(ssb_watchdog_timer_set);
20
21 +int ssb_watchdog_register(struct ssb_bus *bus)
22 +{
23 + struct bcm47xx_wdt wdt = {};
24 + struct platform_device *pdev;
25 +
26 + if (ssb_chipco_available(&bus->chipco)) {
27 + wdt.driver_data = &bus->chipco;
28 + wdt.timer_set = ssb_chipco_watchdog_timer_set_wdt;
29 + wdt.timer_set_ms = ssb_chipco_watchdog_timer_set_ms;
30 + wdt.max_timer_ms = bus->chipco.max_timer_ms;
31 + } else if (ssb_extif_available(&bus->extif)) {
32 + wdt.driver_data = &bus->extif;
33 + wdt.timer_set = ssb_extif_watchdog_timer_set_wdt;
34 + wdt.timer_set_ms = ssb_extif_watchdog_timer_set_ms;
35 + wdt.max_timer_ms = SSB_EXTIF_WATCHDOG_MAX_TIMER_MS;
36 + } else {
37 + return -ENODEV;
38 + }
39 +
40 + pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
41 + bus->busnumber, &wdt,
42 + sizeof(wdt));
43 + if (IS_ERR(pdev)) {
44 + ssb_dprintk(KERN_INFO PFX
45 + "can not register watchdog device, err: %li\n",
46 + PTR_ERR(pdev));
47 + return PTR_ERR(pdev);
48 + }
49 +
50 + bus->watchdog = pdev;
51 + return 0;
52 +}
53 +
54 u32 ssb_gpio_in(struct ssb_bus *bus, u32 mask)
55 {
56 unsigned long flags;
57 --- a/drivers/ssb/main.c
58 +++ b/drivers/ssb/main.c
59 @@ -13,6 +13,7 @@
60 #include <linux/delay.h>
61 #include <linux/io.h>
62 #include <linux/module.h>
63 +#include <linux/platform_device.h>
64 #include <linux/ssb/ssb.h>
65 #include <linux/ssb/ssb_regs.h>
66 #include <linux/ssb/ssb_driver_gige.h>
67 @@ -434,6 +435,11 @@ static void ssb_devices_unregister(struc
68 if (sdev->dev)
69 device_unregister(sdev->dev);
70 }
71 +
72 +#ifdef CONFIG_SSB_EMBEDDED
73 + if (bus->bustype == SSB_BUSTYPE_SSB)
74 + platform_device_unregister(bus->watchdog);
75 +#endif
76 }
77
78 void ssb_bus_unregister(struct ssb_bus *bus)
79 @@ -579,6 +585,8 @@ static int __devinit ssb_attach_queued_b
80 if (err)
81 goto error;
82 ssb_pcicore_init(&bus->pcicore);
83 + if (bus->bustype == SSB_BUSTYPE_SSB)
84 + ssb_watchdog_register(bus);
85 ssb_bus_may_powerdown(bus);
86
87 err = ssb_devices_register(bus);
88 --- a/drivers/ssb/ssb_private.h
89 +++ b/drivers/ssb/ssb_private.h
90 @@ -246,4 +246,14 @@ static inline u32 ssb_extif_watchdog_tim
91 return 0;
92 }
93 #endif
94 +
95 +#ifdef CONFIG_SSB_EMBEDDED
96 +extern int ssb_watchdog_register(struct ssb_bus *bus);
97 +#else /* CONFIG_SSB_EMBEDDED */
98 +static inline int ssb_watchdog_register(struct ssb_bus *bus)
99 +{
100 + return 0;
101 +}
102 +#endif /* CONFIG_SSB_EMBEDDED */
103 +
104 #endif /* LINUX_SSB_PRIVATE_H_ */
105 --- a/include/linux/ssb/ssb.h
106 +++ b/include/linux/ssb/ssb.h
107 @@ -8,6 +8,7 @@
108 #include <linux/pci.h>
109 #include <linux/mod_devicetable.h>
110 #include <linux/dma-mapping.h>
111 +#include <linux/platform_device.h>
112
113 #include <linux/ssb/ssb_regs.h>
114
115 @@ -432,6 +433,7 @@ struct ssb_bus {
116 #ifdef CONFIG_SSB_EMBEDDED
117 /* Lock for GPIO register access. */
118 spinlock_t gpio_lock;
119 + struct platform_device *watchdog;
120 #endif /* EMBEDDED */
121
122 /* Internal-only stuff follows. Do not touch. */