472b22b0e79daf941f5d68579bf65a396b28d053
[openwrt/staging/chunkeey.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 diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
21 index 0469f72..efda7cf 100644
22 --- a/drivers/net/ethernet/broadcom/bgmac.c
23 +++ b/drivers/net/ethernet/broadcom/bgmac.c
24 @@ -14,6 +14,7 @@
25 #include <linux/etherdevice.h>
26 #include <linux/mii.h>
27 #include <linux/phy.h>
28 +#include <linux/phy_fixed.h>
29 #include <linux/interrupt.h>
30 #include <linux/dma-mapping.h>
31 #include <bcm47xx_nvram.h>
32 @@ -1330,13 +1331,46 @@ static void bgmac_adjust_link(struct net_device *net_dev)
33 }
34 }
35
36 +static int bgmac_fixed_phy_register(struct bgmac *bgmac)
37 +{
38 + struct fixed_phy_status fphy_status = {
39 + .link = 1,
40 + .speed = SPEED_1000,
41 + .duplex = DUPLEX_FULL,
42 + };
43 + struct phy_device *phy_dev;
44 + int err;
45 +
46 + phy_dev = fixed_phy_register(PHY_POLL, &fphy_status, NULL);
47 + if (!phy_dev || IS_ERR(phy_dev)) {
48 + bgmac_err(bgmac, "Failed to register fixed PHY device\n");
49 + return -ENODEV;
50 + }
51 +
52 + err = phy_connect_direct(bgmac->net_dev, phy_dev, bgmac_adjust_link,
53 + PHY_INTERFACE_MODE_MII);
54 + if (err) {
55 + bgmac_err(bgmac, "Connecting PHY failed\n");
56 + return err;
57 + }
58 +
59 + bgmac->phy_dev = phy_dev;
60 +
61 + return err;
62 +}
63 +
64 static int bgmac_mii_register(struct bgmac *bgmac)
65 {
66 + struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
67 struct mii_bus *mii_bus;
68 struct phy_device *phy_dev;
69 char bus_id[MII_BUS_ID_SIZE + 3];
70 int i, err = 0;
71
72 + if (ci->id == BCMA_CHIP_ID_BCM4707 ||
73 + ci->id == BCMA_CHIP_ID_BCM53018)
74 + return bgmac_fixed_phy_register(bgmac);
75 +
76 mii_bus = mdiobus_alloc();
77 if (!mii_bus)
78 return -ENOMEM;
79 --
80 1.8.4.5
81