1833319da6ae6824da4367f08781c8771a437199
[openwrt/staging/ynezz.git] /
1 From 781d22f6cf6aded86e80be995b5c875c61512567 Mon Sep 17 00:00:00 2001
2 From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
3 Date: Thu, 18 Oct 2018 20:12:38 +0300
4 Subject: [PATCH] staging: fsl-dpaa2/mac: read phy mode from device tree
5
6 If the a dpmac node defines its phy mode in the device tree using
7 the 'phy-mode' or the 'phy-connection-type' attributes this will take
8 precedence over the interface mode reported by the MC in the
9 dpmac attributes structure.
10
11 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
12 Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
13 ---
14 drivers/staging/fsl-dpaa2/mac/mac.c | 10 +++++++++-
15 1 file changed, 9 insertions(+), 1 deletion(-)
16
17 --- a/drivers/staging/fsl-dpaa2/mac/mac.c
18 +++ b/drivers/staging/fsl-dpaa2/mac/mac.c
19 @@ -466,7 +466,7 @@ static int dpaa2_mac_probe(struct fsl_mc
20 struct dpaa2_mac_priv *priv = NULL;
21 struct device_node *phy_node, *dpmac_node;
22 struct net_device *netdev;
23 - phy_interface_t if_mode;
24 + int if_mode;
25 int err = 0;
26
27 dev = &mc_dev->dev;
28 @@ -555,6 +555,13 @@ static int dpaa2_mac_probe(struct fsl_mc
29 goto probe_fixed_link;
30 }
31
32 + if_mode = of_get_phy_mode(dpmac_node);
33 + if (if_mode >= 0) {
34 + dev_dbg(dev, "\tusing if mode %s for eth_if %d\n",
35 + phy_modes(if_mode), priv->attr.eth_if);
36 + goto phy_connect;
37 + }
38 +
39 if (priv->attr.eth_if < ARRAY_SIZE(dpaa2_mac_iface_mode)) {
40 if_mode = dpaa2_mac_iface_mode[priv->attr.eth_if];
41 dev_dbg(dev, "\tusing if mode %s for eth_if %d\n",
42 @@ -565,6 +572,7 @@ static int dpaa2_mac_probe(struct fsl_mc
43 goto probe_fixed_link;
44 }
45
46 +phy_connect:
47 /* try to connect to the PHY */
48 netdev->phydev = of_phy_connect(netdev, phy_node,
49 &dpaa2_mac_link_changed, 0, if_mode);