1 From bb13c3cfaaac3bb50a7f59d0cfa54ff463c2ca86 Mon Sep 17 00:00:00 2001
2 From: Calvin Johnson <calvin.johnson@nxp.com>
3 Date: Tue, 20 Nov 2018 21:50:51 +0530
4 Subject: [PATCH] staging: fsl_ppfe/eth: reorganize platform phy parameters
6 - Use "phy-handle" and of_* functions to get phy node and fixed-link
9 - Reorganize phy parameters and initialize them only if phy-handle
10 or fixed-link is defined in the dtb.
12 - correct typo pfe_get_gemac_if_proprties to pfe_get_gemac_if_properties
14 Signed-off-by: Calvin Johnson <calvin.johnson@nxp.com>
16 drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c | 91 ++++++++++++++-----------
17 1 file changed, 50 insertions(+), 41 deletions(-)
19 --- a/drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c
20 +++ b/drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c
23 struct ls1012a_pfe_platform_data pfe_platform_data;
25 -static int pfe_get_gemac_if_proprties(struct device_node *parent, int port, int
26 +static int pfe_get_gemac_if_properties(struct device_node *parent, int port, int
28 struct ls1012a_pfe_platform_data
31 - struct device_node *gem = NULL, *phy = NULL;
32 + struct device_node *gem = NULL, *phy = NULL, *phy_node = NULL;
34 int ii = 0, phy_id = 0;
36 @@ -49,12 +49,6 @@ static int pfe_get_gemac_if_proprties(st
38 of_get_mac_address(gem, pdata->ls1012a_eth_pdata[port].mac_addr);
40 - pdata->ls1012a_eth_pdata[port].mii_config = of_get_phy_mode(gem);
42 - if ((pdata->ls1012a_eth_pdata[port].mii_config) < 0)
43 - pr_err("%s:%d Incorrect Phy mode....\n", __func__,
46 addr = of_get_property(gem, "fsl,gemac-bus-id", &size);
48 pr_err("%s:%d Invalid gemac-bus-id....\n", __func__,
49 @@ -62,16 +56,55 @@ static int pfe_get_gemac_if_proprties(st
51 pdata->ls1012a_eth_pdata[port].bus_id = be32_to_cpup(addr);
53 - addr = of_get_property(gem, "fsl,gemac-phy-id", &size);
55 - pr_err("%s:%d Invalid gemac-phy-id....\n", __func__,
57 + phy_node = of_parse_phandle(gem, "phy-handle", 0);
58 + pdata->ls1012a_eth_pdata[port].phy_node = phy_node;
60 + goto process_phynode;
61 + } else if (of_phy_is_fixed_link(gem)) {
62 + if (of_phy_register_fixed_link(gem) < 0) {
63 + pr_err("broken fixed-link specification\n");
66 + phy_node = of_node_get(gem);
67 + pdata->ls1012a_eth_pdata[port].phy_node = phy_node;
68 + } else if (of_get_property(gem, "fsl,pfe-phy-if-flags", &size)) {
69 + /* Use old dts properties for phy handling */
70 + addr = of_get_property(gem, "fsl,pfe-phy-if-flags", &size);
71 + pdata->ls1012a_eth_pdata[port].phy_flags = be32_to_cpup(addr);
73 + addr = of_get_property(gem, "fsl,gemac-phy-id", &size);
75 + pr_err("%s:%d Invalid gemac-phy-id....\n", __func__,
78 + phy_id = be32_to_cpup(addr);
79 + pdata->ls1012a_eth_pdata[port].phy_id = phy_id;
80 + pdata->ls1012a_mdio_pdata[0].phy_mask &= ~(1 << phy_id);
83 + /* If PHY is enabled, read mdio properties */
84 + if (pdata->ls1012a_eth_pdata[port].phy_flags & GEMAC_NO_PHY)
87 + phy = of_get_next_child(gem, NULL);
88 + addr = of_get_property(phy, "reg", &size);
90 + pr_err("%s:%d Invalid phy enable flag....\n",
91 + __func__, __LINE__);
93 + pdata->ls1012a_mdio_pdata[port].enabled =
96 - phy_id = be32_to_cpup(addr);
97 - pdata->ls1012a_eth_pdata[port].phy_id = phy_id;
98 - pdata->ls1012a_mdio_pdata[0].phy_mask &= ~(1 << phy_id);
99 + pr_info("%s: No PHY or fixed-link\n", __func__);
104 + pdata->ls1012a_eth_pdata[port].mii_config = of_get_phy_mode(gem);
105 + if ((pdata->ls1012a_eth_pdata[port].mii_config) < 0)
106 + pr_err("%s:%d Incorrect Phy mode....\n", __func__,
109 addr = of_get_property(gem, "fsl,mdio-mux-val", &size);
111 pr_err("%s: Invalid mdio-mux-val....\n", __func__);
112 @@ -84,33 +117,10 @@ static int pfe_get_gemac_if_proprties(st
113 pfe->mdio_muxval[pdata->ls1012a_eth_pdata[port].phy_id] =
114 pdata->ls1012a_eth_pdata[port].mdio_muxval;
116 - addr = of_get_property(gem, "fsl,pfe-phy-if-flags", &size);
118 - pr_err("%s:%d Invalid pfe-phy-if-flags....\n",
119 - __func__, __LINE__);
121 - pdata->ls1012a_eth_pdata[port].phy_flags = be32_to_cpup(addr);
123 - /* If PHY is enabled, read mdio properties */
124 - if (pdata->ls1012a_eth_pdata[port].phy_flags & GEMAC_NO_PHY)
127 - phy = of_get_next_child(gem, NULL);
129 - addr = of_get_property(phy, "reg", &size);
132 - pr_err("%s:%d Invalid phy enable flag....\n",
133 - __func__, __LINE__);
135 - pdata->ls1012a_mdio_pdata[port].enabled = be32_to_cpup(addr);
137 pdata->ls1012a_mdio_pdata[port].irq[0] = PHY_POLL;
140 - if (of_phy_is_fixed_link(gem))
141 - pdata->ls1012a_eth_pdata[port].phy_node = of_node_get(gem);
146 @@ -212,8 +222,8 @@ static int pfe_platform_probe(struct pla
147 pfe_platform_data.ls1012a_mdio_pdata[0].phy_mask = 0xffffffff;
149 for (ii = 0; ii < interface_count; ii++) {
150 - pfe_get_gemac_if_proprties(np, ii, interface_count,
151 - &pfe_platform_data);
152 + pfe_get_gemac_if_properties(np, ii, interface_count,
153 + &pfe_platform_data);
156 pfe->dev = &pdev->dev;