8d0e122b1272d78b9ef5d4b1dca561e44dcef729
[openwrt/staging/ldir.git] /
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
5
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
10 function as needed.
11
12 Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
13 ---
14 drivers/staging/fsl-dpaa2/mac/mac.c | 39 ++++++++++++++++++++++++-------------
15 1 file changed, 25 insertions(+), 14 deletions(-)
16
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
20 }
21 #endif /* CONFIG_FSL_DPAA2_MAC_NETDEVS */
22
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;
26 -
27 - /* or if there's no phy-handle defined in the device tree */
28 - phy_node = of_parse_phandle(dpmac_node, "phy-handle", 0);
29 - if (!phy_node) {
30 - goto probe_fixed_link;
31 - }
32 -
33 + /* get the interface mode from the dpmac of node or from the MC attributes */
34 if_mode = of_get_phy_mode(dpmac_node);
35 if (if_mode >= 0) {
36 dev_dbg(dev, "\tusing if mode %s for eth_if %d\n",
37 phy_modes(if_mode), priv->attr.eth_if);
38 - goto phy_connect;
39 + goto link_type;
40 }
41
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);
46 } else {
47 - dev_warn(dev, "Unexpected interface mode %d, will probe as fixed link\n",
48 - priv->attr.eth_if);
49 + dev_err(dev, "Unexpected interface mode %d\n",
50 + priv->attr.eth_if);
51 + err = -EINVAL;
52 + goto err_no_if_mode;
53 + }
54 +
55 +link_type:
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;
59 +
60 + /* or if there's no phy-handle defined in the device tree */
61 + phy_node = of_parse_phandle(dpmac_node, "phy-handle", 0);
62 + if (!phy_node) {
63 goto probe_fixed_link;
64 }
65
66 -phy_connect:
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:
71 err = -EFAULT;
72 goto err_no_phy;
73 }
74 +
75 + err = phy_connect_direct(netdev, netdev->phydev,
76 + &dpaa2_mac_link_changed, if_mode);
77 + if (err) {
78 + dev_err(dev, "error trying to connect to PHY\n");
79 + goto err_no_phy;
80 + }
81 +
82 dev_info(dev, "Registered fixed PHY.\n");
83 }
84
85 @@ -709,6 +719,7 @@ probe_fixed_link:
86
87 return 0;
88
89 +err_no_if_mode:
90 err_defer:
91 err_no_phy:
92 #ifdef CONFIG_FSL_DPAA2_MAC_NETDEVS