108d79c0b8d16a95cf122017375ce0b0f68e02f9
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.14 / 209-b44-register-adm-switch.patch
1 From b36f694256f41bc71571f467646d015dda128d14 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sat, 9 Nov 2013 17:03:59 +0100
4 Subject: [PATCH 210/210] b44: register adm switch
5
6 ---
7 drivers/net/ethernet/broadcom/b44.c | 57 +++++++++++++++++++++++++++++++++++
8 drivers/net/ethernet/broadcom/b44.h | 3 ++
9 2 files changed, 60 insertions(+)
10
11 --- a/drivers/net/ethernet/broadcom/b44.c
12 +++ b/drivers/net/ethernet/broadcom/b44.c
13 @@ -31,6 +31,8 @@
14 #include <linux/ssb/ssb.h>
15 #include <linux/slab.h>
16 #include <linux/phy.h>
17 +#include <linux/platform_device.h>
18 +#include <linux/platform_data/adm6996-gpio.h>
19
20 #include <asm/uaccess.h>
21 #include <asm/io.h>
22 @@ -2239,6 +2241,70 @@ static void b44_adjust_link(struct net_d
23 }
24 }
25
26 +#ifdef CONFIG_BCM47XX
27 +static int b44_register_adm_switch(struct b44 *bp)
28 +{
29 + int gpio;
30 + struct platform_device *pdev;
31 + struct adm6996_gpio_platform_data adm_data = {0};
32 + struct platform_device_info info = {0};
33 +
34 + adm_data.model = ADM6996L;
35 + gpio = bcm47xx_nvram_gpio_pin("adm_eecs");
36 + if (gpio >= 0)
37 + adm_data.eecs = gpio;
38 + else
39 + adm_data.eecs = 2;
40 +
41 + gpio = bcm47xx_nvram_gpio_pin("adm_eesk");
42 + if (gpio >= 0)
43 + adm_data.eesk = gpio;
44 + else
45 + adm_data.eesk = 3;
46 +
47 + gpio = bcm47xx_nvram_gpio_pin("adm_eedi");
48 + if (gpio >= 0)
49 + adm_data.eedi = gpio;
50 + else
51 + adm_data.eedi = 4;
52 +
53 + gpio = bcm47xx_nvram_gpio_pin("adm_rc");
54 + if (gpio >= 0)
55 + adm_data.eerc = gpio;
56 + else
57 + adm_data.eerc = 5;
58 +
59 + info.parent = bp->sdev->dev;
60 + info.name = "adm6996_gpio";
61 + info.id = -1;
62 + info.data = &adm_data;
63 + info.size_data = sizeof(adm_data);
64 +
65 + if (!bp->adm_switch) {
66 + pdev = platform_device_register_full(&info);
67 + if (IS_ERR(pdev))
68 + return PTR_ERR(pdev);
69 +
70 + bp->adm_switch = pdev;
71 + }
72 + return 0;
73 +}
74 +static void b44_unregister_adm_switch(struct b44 *bp)
75 +{
76 + if (bp->adm_switch)
77 + platform_device_unregister(bp->adm_switch);
78 +}
79 +#else
80 +static int b44_register_adm_switch(struct b44 *bp)
81 +{
82 + return 0;
83 +}
84 +static void b44_unregister_adm_switch(struct b44 *bp)
85 +{
86 +
87 +}
88 +#endif /* CONFIG_BCM47XX */
89 +
90 static int b44_register_phy_one(struct b44 *bp)
91 {
92 struct mii_bus *mii_bus;
93 @@ -2282,6 +2348,9 @@ static int b44_register_phy_one(struct b
94 if (!bp->mii_bus->phy_map[bp->phy_addr] &&
95 (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) {
96
97 + if (sprom->boardflags_lo & B44_BOARDFLAG_ADM)
98 + b44_register_adm_switch(bp);
99 +
100 dev_info(sdev->dev,
101 "could not find PHY at %i, use fixed one\n",
102 bp->phy_addr);
103 @@ -2476,6 +2545,7 @@ static void b44_remove_one(struct ssb_de
104 unregister_netdev(dev);
105 if (bp->flags & B44_FLAG_EXTERNAL_PHY)
106 b44_unregister_phy_one(bp);
107 + b44_unregister_adm_switch(bp);
108 ssb_device_disable(sdev, 0);
109 ssb_bus_may_powerdown(sdev->bus);
110 free_netdev(dev);
111 --- a/drivers/net/ethernet/broadcom/b44.h
112 +++ b/drivers/net/ethernet/broadcom/b44.h
113 @@ -404,6 +404,9 @@ struct b44 {
114 struct mii_bus *mii_bus;
115 int old_link;
116 struct mii_if_info mii_if;
117 +
118 + /* platform device for associated switch */
119 + struct platform_device *adm_switch;
120 };
121
122 #endif /* _B44_H */