ramips: fix cd-poll sd card remove randomly
[openwrt/openwrt.git] / target / linux / generic / patches-3.18 / 074-bgmac-register-fixed-PHY-for-ARM-BCM470X-BCM5301X-ch.patch
1 From c25b23b8a387e7d31f7a74af8e37b61e9e6ebb21 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Fri, 20 Mar 2015 23:14:31 +0100
4 Subject: [PATCH] bgmac: register fixed PHY for ARM BCM470X / BCM5301X chipsets
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 On ARM SoCs with bgmac Ethernet hardware we don't have any normal PHY.
10 There is always a switch attached but it's not even controlled over MDIO
11 like in case of MIPS devices.
12 We need a fixed PHY to be able to send/receive packets from the switch.
13
14 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
15 Signed-off-by: David S. Miller <davem@davemloft.net>
16 ---
17 drivers/net/ethernet/broadcom/bgmac.c | 34 ++++++++++++++++++++++++++++++++++
18 1 file changed, 34 insertions(+)
19
20 --- a/drivers/net/ethernet/broadcom/bgmac.c
21 +++ b/drivers/net/ethernet/broadcom/bgmac.c
22 @@ -14,6 +14,7 @@
23 #include <linux/etherdevice.h>
24 #include <linux/mii.h>
25 #include <linux/phy.h>
26 +#include <linux/phy_fixed.h>
27 #include <linux/interrupt.h>
28 #include <linux/dma-mapping.h>
29 #include <bcm47xx_nvram.h>
30 @@ -1330,13 +1331,46 @@ static void bgmac_adjust_link(struct net
31 }
32 }
33
34 +static int bgmac_fixed_phy_register(struct bgmac *bgmac)
35 +{
36 + struct fixed_phy_status fphy_status = {
37 + .link = 1,
38 + .speed = SPEED_1000,
39 + .duplex = DUPLEX_FULL,
40 + };
41 + struct phy_device *phy_dev;
42 + int err;
43 +
44 + phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, NULL);
45 + if (!phy_dev || IS_ERR(phy_dev)) {
46 + bgmac_err(bgmac, "Failed to register fixed PHY device\n");
47 + return -ENODEV;
48 + }
49 +
50 + err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link,
51 + PHY_INTERFACE_MODE_MII);
52 + if (err) {
53 + bgmac_err(bgmac, "Connecting PHY failed\n");
54 + return err;
55 + }
56 +
57 + bgmac->phy_dev = phy_dev;
58 +
59 + return err;
60 +}
61 +
62 static int bgmac_mii_register(struct bgmac *bgmac)
63 {
64 + struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
65 struct mii_bus *mii_bus;
66 struct phy_device *phy_dev;
67 char bus_id[MII_BUS_ID_SIZE + 3];
68 int i, err = 0;
69
70 + if (ci->id == BCMA_CHIP_ID_BCM4707 ||
71 + ci->id == BCMA_CHIP_ID_BCM53018)
72 + return bgmac_fixed_phy_register(bgmac);
73 +
74 mii_bus = mdiobus_alloc();
75 if (!mii_bus)
76 return -ENOMEM;