brcm47xx: deactivate mips wait instruction only for BCM4706
[openwrt.git] / target / linux / brcm47xx / patches-3.10 / 209-b44-register-adm-switch.patch
1 From b52546f8af54b78050f84ab031ad1aaf6507ed95 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 10/10] b44: register adm switch
5
6 ---
7  drivers/net/ethernet/broadcom/b44.c |   64 ++++++++++++++++++++++++++++++++++-
8  drivers/net/ethernet/broadcom/b44.h |    3 ++
9  2 files changed, 66 insertions(+), 1 deletion(-)
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 @@ -2216,6 +2218,58 @@ static void b44_adjust_link(struct net_d
23                 phy_print_status(phydev);
24  }
25  
26 +#ifdef CONFIG_BCM47XX
27 +static struct adm6996_gpio_platform_data b44_adm_data = {
28 +       .eecs   = 2,
29 +       .eesk   = 3,
30 +       .eedi   = 4,
31 +       .eerc   = 5,
32 +       .model  = ADM6996L,
33 +};
34 +
35 +static struct platform_device b44_adm_dev = {
36 +       .name           = "adm6996_gpio",
37 +       .id             = -1,
38 +       .dev            = {
39 +               .platform_data = &b44_adm_data,
40 +       },
41 +};
42 +
43 +static int b44_register_adm_switch(struct b44 *bp)
44 +{
45 +       int gpio;
46 +       int err;
47 +
48 +       gpio = bcm47xx_nvram_gpio_pin("adm_eecs");
49 +       if (gpio >= 0)
50 +               b44_adm_data.eecs = gpio;
51 +
52 +       gpio = bcm47xx_nvram_gpio_pin("adm_eesk");
53 +       if (gpio >= 0)
54 +               b44_adm_data.eesk = gpio;
55 +
56 +       gpio = bcm47xx_nvram_gpio_pin("adm_eedi");
57 +       if (gpio >= 0)
58 +               b44_adm_data.eedi = gpio;
59 +
60 +       gpio = bcm47xx_nvram_gpio_pin("adm_rc");
61 +       if (gpio >= 0)
62 +               b44_adm_data.eerc = gpio;
63 +
64 +       if (!bp->adm_switch) {
65 +               err = platform_device_register(&b44_adm_dev);
66 +               if (!err)
67 +                       bp->adm_switch = &b44_adm_dev;
68 +       }
69 +       return err;
70 +}
71 +#else
72 +static int b44_register_adm_switch(struct b44 *bp)
73 +{
74 +       return 0;
75 +}
76 +#endif /* CONFIG_BCM47XX */
77 +
78  static int b44_register_phy_one(struct b44 *bp)
79  {
80         struct mii_bus *mii_bus;
81 @@ -2223,6 +2277,7 @@ static int b44_register_phy_one(struct b
82         struct phy_device *phydev;
83         int err;
84         struct phy_c45_device_ids c45_ids = {0};
85 +       struct ssb_sprom *sprom = &sdev->bus->sprom;
86  
87         mii_bus = mdiobus_alloc();
88         if (!mii_bus) {
89 @@ -2256,7 +2311,11 @@ static int b44_register_phy_one(struct b
90         }
91  
92         phydev = bp->mii_bus->phy_map[bp->phy_addr];
93 -       if (!phydev) {
94 +       if (!phydev &&
95 +           (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) {
96 +               if (sprom->boardflags_lo & B44_BOARDFLAG_ADM)
97 +                       b44_register_adm_switch(bp);
98 +
99                 dev_info(sdev->dev, "could not find PHY at %i, create dummy one\n",
100                          bp->phy_addr);
101  
102 --- a/drivers/net/ethernet/broadcom/b44.h
103 +++ b/drivers/net/ethernet/broadcom/b44.h
104 @@ -345,6 +345,9 @@ B44_STAT_REG_DECLARE
105         struct u64_stats_sync   syncp;
106  };
107  
108 +#define        B44_BOARDFLAG_ROBO              0x0010  /* Board has robo switch or core */
109 +#define        B44_BOARDFLAG_ADM               0x0080  /* Board has ADMtek switch */
110 +
111  struct ssb_device;
112  
113  struct b44 {
114 @@ -402,6 +405,9 @@ struct b44 {
115         int                     old_link;
116         int                     old_duplex;
117         struct mii_if_info      mii_if;
118 +
119 +       /* platform device for associated switch */
120 +       struct platform_device *adm_switch;
121  };
122  
123  #endif /* _B44_H */