1 From 69e35d8266713d36ad31b04d9b7cb32913d243c0 Mon Sep 17 00:00:00 2001
2 From: Ioana Ciornei <ioana.ciornei@nxp.com>
3 Date: Tue, 27 Nov 2018 15:23:47 +0200
4 Subject: [PATCH] staging: fsl-dpaa2/mac: connect to the fixed phy
6 This patch is formed from 2 parts:
7 - first it moves the code that determines the if_mode to the
8 beginning so that it's used for both fixed link and phy mode.
9 - secondly, when in fixed link mode, call the phy_connect_phy
12 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
14 drivers/staging/fsl-dpaa2/mac/mac.c | 39 ++++++++++++++++++++++++-------------
15 1 file changed, 25 insertions(+), 14 deletions(-)
17 --- a/drivers/staging/fsl-dpaa2/mac/mac.c
18 +++ b/drivers/staging/fsl-dpaa2/mac/mac.c
19 @@ -642,21 +642,12 @@ static int dpaa2_mac_probe(struct fsl_mc
21 #endif /* CONFIG_FSL_DPAA2_MAC_NETDEVS */
23 - /* probe the PHY as fixed-link if the DPMAC attribute indicates so */
24 - if (priv->attr.link_type == DPMAC_LINK_TYPE_FIXED)
25 - goto probe_fixed_link;
27 - /* or if there's no phy-handle defined in the device tree */
28 - phy_node = of_parse_phandle(dpmac_node, "phy-handle", 0);
30 - goto probe_fixed_link;
33 + /* get the interface mode from the dpmac of node or from the MC attributes */
34 if_mode = of_get_phy_mode(dpmac_node);
36 dev_dbg(dev, "\tusing if mode %s for eth_if %d\n",
37 phy_modes(if_mode), priv->attr.eth_if);
42 if (priv->attr.eth_if < ARRAY_SIZE(dpaa2_mac_iface_mode)) {
43 @@ -664,12 +655,23 @@ static int dpaa2_mac_probe(struct fsl_mc
44 dev_dbg(dev, "\tusing if mode %s for eth_if %d\n",
45 phy_modes(if_mode), priv->attr.eth_if);
47 - dev_warn(dev, "Unexpected interface mode %d, will probe as fixed link\n",
49 + dev_err(dev, "Unexpected interface mode %d\n",
52 + goto err_no_if_mode;
56 + /* probe the PHY as fixed-link if the DPMAC attribute indicates so */
57 + if (priv->attr.link_type == DPMAC_LINK_TYPE_FIXED)
58 + goto probe_fixed_link;
60 + /* or if there's no phy-handle defined in the device tree */
61 + phy_node = of_parse_phandle(dpmac_node, "phy-handle", 0);
63 goto probe_fixed_link;
67 /* try to connect to the PHY */
68 netdev->phydev = of_phy_connect(netdev, phy_node,
69 &dpaa2_mac_link_changed, 0, if_mode);
70 @@ -702,6 +704,14 @@ probe_fixed_link:
75 + err = phy_connect_direct(netdev, netdev->phydev,
76 + &dpaa2_mac_link_changed, if_mode);
78 + dev_err(dev, "error trying to connect to PHY\n");
82 dev_info(dev, "Registered fixed PHY.\n");
85 @@ -709,6 +719,7 @@ probe_fixed_link:
92 #ifdef CONFIG_FSL_DPAA2_MAC_NETDEVS