apm821xx: net: emac: fix fixed-link setup for the RTL8363SB switch
[openwrt/openwrt.git] / target / linux / apm821xx / patches-4.14 / 050-net-emac-fix-fixed-link-setup-for-the-RTL8363SB-swit.patch
1 From 08e39982ef64f800fd1f9b9b92968d14d5fafa82 Mon Sep 17 00:00:00 2001
2 From: Christian Lamparter <chunkeey@gmail.com>
3 Date: Mon, 17 Sep 2018 17:22:40 +0200
4 Subject: net: emac: fix fixed-link setup for the RTL8363SB switch
5
6 On the Netgear WNDAP620, the emac ethernet isn't receiving nor
7 xmitting any frames from/to the RTL8363SB (identifies itself
8 as a RTL8367RB).
9
10 This is caused by the emac hardware not knowing the forced link
11 parameters for speed, duplex, pause, etc.
12
13 This begs the question, how this was working on the original
14 driver code, when it was necessary to set the phy_address and
15 phy_map to 0xffffffff. But I guess without access to the old
16 PPC405/440/460 hardware, it's not possible to know.
17
18 Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
19 Signed-off-by: David S. Miller <davem@davemloft.net>
20 ---
21 drivers/net/ethernet/ibm/emac/core.c | 15 ++++++++++-----
22 1 file changed, 10 insertions(+), 5 deletions(-)
23
24 --- a/drivers/net/ethernet/ibm/emac/core.c
25 +++ b/drivers/net/ethernet/ibm/emac/core.c
26 @@ -2671,12 +2671,17 @@ static int emac_init_phy(struct emac_ins
27 if (of_phy_is_fixed_link(np)) {
28 int res = emac_dt_mdio_probe(dev);
29
30 - if (!res) {
31 - res = of_phy_register_fixed_link(np);
32 - if (res)
33 - mdiobus_unregister(dev->mii_bus);
34 + if (res)
35 + return res;
36 +
37 + res = of_phy_register_fixed_link(np);
38 + dev->phy_dev = of_phy_find_device(np);
39 + if (res || !dev->phy_dev) {
40 + mdiobus_unregister(dev->mii_bus);
41 + return res ? res : -EINVAL;
42 }
43 - return res;
44 + emac_adjust_link(dev->ndev);
45 + put_device(&dev->phy_dev->mdio.dev);
46 }
47 return 0;
48 }