7bf236c86f3817b5683ee18d2213fe103e29855f
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.10 / 208-b44-use-fixed-PHY-device-if-we-do-not-find-any.patch
1 From b04138b335203b79ffe1b14750fa245a4dab7191 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Fri, 20 Dec 2013 02:16:13 +0100
4 Subject: [PATCH 208/208] b44: use fixed PHY device if we do not find any
5
6 The ADM6996L switch and some Broadcom switches with two MII interfaces
7 like the BCM5325F connected to two MACs on the SoC, used on some
8 routers do not return a valid value when reading the PHY id register
9 and Linux thinks there is no PHY at all, but that is wrong.
10 This patch registers a fixed phy in the arch code and then searches it
11 when there is no other phy in the Ethernet driver code.
12
13 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
15 ---
16 arch/mips/bcm47xx/setup.c | 10 ++++++++++
17 drivers/net/ethernet/broadcom/b44.c | 16 +++++++++++++++-
18 drivers/net/ethernet/broadcom/b44.h | 3 +++
19 3 files changed, 28 insertions(+), 1 deletion(-)
20
21 --- a/arch/mips/bcm47xx/setup.c
22 +++ b/arch/mips/bcm47xx/setup.c
23 @@ -30,6 +30,9 @@
24
25 #include <linux/export.h>
26 #include <linux/types.h>
27 +#include <linux/ethtool.h>
28 +#include <linux/phy.h>
29 +#include <linux/phy_fixed.h>
30 #include <linux/ssb/ssb.h>
31 #include <linux/ssb/ssb_embedded.h>
32 #include <linux/bcma/bcma_soc.h>
33 @@ -260,6 +263,12 @@ static int __init bcm47xx_cpu_fixes(void
34 }
35 arch_initcall(bcm47xx_cpu_fixes);
36
37 +static struct fixed_phy_status bcm47xx_fixed_phy_status __initdata = {
38 + .link = 1,
39 + .speed = SPEED_100,
40 + .duplex = DUPLEX_FULL,
41 +};
42 +
43 static int __init bcm47xx_register_bus_complete(void)
44 {
45 switch (bcm47xx_bus_type) {
46 @@ -278,6 +287,7 @@ static int __init bcm47xx_register_bus_c
47 bcm47xx_buttons_register();
48 bcm47xx_leds_register();
49 bcm47xx_workarounds();
50 + fixed_phy_add(PHY_POLL, 0, &bcm47xx_fixed_phy_status);
51
52 return 0;
53 }
54 --- a/drivers/net/ethernet/broadcom/b44.c
55 +++ b/drivers/net/ethernet/broadcom/b44.c
56 @@ -2233,6 +2233,7 @@ static int b44_register_phy_one(struct b
57 struct ssb_device *sdev = bp->sdev;
58 struct phy_device *phydev;
59 char bus_id[MII_BUS_ID_SIZE + 3];
60 + struct ssb_sprom *sprom = &sdev->bus->sprom;
61 int err;
62
63 mii_bus = mdiobus_alloc();
64 @@ -2266,7 +2267,20 @@ static int b44_register_phy_one(struct b
65 goto err_out_mdiobus_irq;
66 }
67
68 - snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, mii_bus->id, bp->phy_addr);
69 + if (!bp->mii_bus->phy_map[bp->phy_addr] &&
70 + (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) {
71 +
72 + dev_info(sdev->dev,
73 + "could not find PHY at %i, use fixed one\n",
74 + bp->phy_addr);
75 +
76 + bp->phy_addr = 0;
77 + snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, "fixed-0",
78 + bp->phy_addr);
79 + } else {
80 + snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, mii_bus->id,
81 + bp->phy_addr);
82 + }
83
84 phydev = phy_connect(bp->dev, bus_id, &b44_adjust_link,
85 PHY_INTERFACE_MODE_MII);
86 --- a/drivers/net/ethernet/broadcom/b44.h
87 +++ b/drivers/net/ethernet/broadcom/b44.h
88 @@ -345,6 +345,9 @@ B44_STAT_REG_DECLARE
89 struct u64_stats_sync syncp;
90 };
91
92 +#define B44_BOARDFLAG_ROBO 0x0010 /* Board has robo switch */
93 +#define B44_BOARDFLAG_ADM 0x0080 /* Board has ADMtek switch */
94 +
95 struct ssb_device;
96
97 struct b44 {