brcm47xx: add initial support for kernel 3.14
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.14 / 830-huawei_e970_support.patch
1 --- a/arch/mips/bcm47xx/setup.c
2 +++ b/arch/mips/bcm47xx/setup.c
3 @@ -36,6 +36,7 @@
4 #include <linux/ssb/ssb.h>
5 #include <linux/ssb/ssb_embedded.h>
6 #include <linux/bcma/bcma_soc.h>
7 +#include <linux/old_gpio_wdt.h>
8 #include <asm/bootinfo.h>
9 #include <asm/idle.h>
10 #include <asm/prom.h>
11 @@ -266,6 +267,33 @@ static struct fixed_phy_status bcm47xx_f
12 .duplex = DUPLEX_FULL,
13 };
14
15 +static struct gpio_wdt_platform_data gpio_wdt_data;
16 +
17 +static struct platform_device gpio_wdt_device = {
18 + .name = "gpio-wdt",
19 + .id = 0,
20 + .dev = {
21 + .platform_data = &gpio_wdt_data,
22 + },
23 +};
24 +
25 +static int __init bcm47xx_register_gpio_watchdog(void)
26 +{
27 + enum bcm47xx_board board = bcm47xx_board_get();
28 +
29 + switch (board) {
30 + case BCM47XX_BOARD_HUAWEI_E970:
31 + pr_info("bcm47xx: detected Huawei E970 or similar, starting early gpio_wdt timer\n");
32 + gpio_wdt_data.gpio = 7;
33 + gpio_wdt_data.interval = HZ;
34 + gpio_wdt_data.first_interval = HZ / 5;
35 + return platform_device_register(&gpio_wdt_device);
36 + default:
37 + /* Nothing to do */
38 + return 0;
39 + }
40 +}
41 +
42 static int __init bcm47xx_register_bus_complete(void)
43 {
44 switch (bcm47xx_bus_type) {
45 @@ -285,6 +313,7 @@ static int __init bcm47xx_register_bus_c
46 bcm47xx_workarounds();
47
48 fixed_phy_add(PHY_POLL, 0, &bcm47xx_fixed_phy_status);
49 + bcm47xx_register_gpio_watchdog();
50 return 0;
51 }
52 device_initcall(bcm47xx_register_bus_complete);
53 --- a/arch/mips/configs/bcm47xx_defconfig
54 +++ b/arch/mips/configs/bcm47xx_defconfig
55 @@ -67,6 +67,7 @@ CONFIG_HW_RANDOM=y
56 CONFIG_GPIO_SYSFS=y
57 CONFIG_WATCHDOG=y
58 CONFIG_BCM47XX_WDT=y
59 +CONFIG_GPIO_WDT=y
60 CONFIG_SSB_DEBUG=y
61 CONFIG_SSB_DRIVER_GIGE=y
62 CONFIG_BCMA_DRIVER_GMAC_CMN=y
63 --- a/drivers/ssb/embedded.c
64 +++ b/drivers/ssb/embedded.c
65 @@ -34,11 +34,36 @@ int ssb_watchdog_timer_set(struct ssb_bu
66 }
67 EXPORT_SYMBOL(ssb_watchdog_timer_set);
68
69 +#ifdef CONFIG_BCM47XX
70 +#include <bcm47xx_board.h>
71 +
72 +static bool ssb_watchdog_supported(void)
73 +{
74 + enum bcm47xx_board board = bcm47xx_board_get();
75 +
76 + /* The Huawei E970 has a hardware watchdog using a GPIO */
77 + switch (board) {
78 + case BCM47XX_BOARD_HUAWEI_E970:
79 + return false;
80 + default:
81 + return true;
82 + }
83 +}
84 +#else
85 +static bool ssb_watchdog_supported(void)
86 +{
87 + return true;
88 +}
89 +#endif
90 +
91 int ssb_watchdog_register(struct ssb_bus *bus)
92 {
93 struct bcm47xx_wdt wdt = {};
94 struct platform_device *pdev;
95
96 + if (!ssb_watchdog_supported())
97 + return 0;
98 +
99 if (ssb_chipco_available(&bus->chipco)) {
100 wdt.driver_data = &bus->chipco;
101 wdt.timer_set = ssb_chipco_watchdog_timer_set_wdt;