diff options
Diffstat (limited to 'target/linux/layerscape/patches-5.4/701-net-0313-staging-fsl_ppfe-eth-reorganize-platform-phy-paramet.patch')
-rw-r--r-- | target/linux/layerscape/patches-5.4/701-net-0313-staging-fsl_ppfe-eth-reorganize-platform-phy-paramet.patch | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/target/linux/layerscape/patches-5.4/701-net-0313-staging-fsl_ppfe-eth-reorganize-platform-phy-paramet.patch b/target/linux/layerscape/patches-5.4/701-net-0313-staging-fsl_ppfe-eth-reorganize-platform-phy-paramet.patch new file mode 100644 index 0000000000..7e4c6ae6aa --- /dev/null +++ b/target/linux/layerscape/patches-5.4/701-net-0313-staging-fsl_ppfe-eth-reorganize-platform-phy-paramet.patch @@ -0,0 +1,162 @@ +From bb13c3cfaaac3bb50a7f59d0cfa54ff463c2ca86 Mon Sep 17 00:00:00 2001 +From: Calvin Johnson <calvin.johnson@nxp.com> +Date: Tue, 20 Nov 2018 21:50:51 +0530 +Subject: [PATCH] staging: fsl_ppfe/eth: reorganize platform phy parameters + +- Use "phy-handle" and of_* functions to get phy node and fixed-link +parameters + +- Reorganize phy parameters and initialize them only if phy-handle +or fixed-link is defined in the dtb. + +- correct typo pfe_get_gemac_if_proprties to pfe_get_gemac_if_properties + +Signed-off-by: Calvin Johnson <calvin.johnson@nxp.com> +--- + drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c | 91 ++++++++++++++----------- + 1 file changed, 50 insertions(+), 41 deletions(-) + +--- a/drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c ++++ b/drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c +@@ -20,12 +20,12 @@ + + struct ls1012a_pfe_platform_data pfe_platform_data; + +-static int pfe_get_gemac_if_proprties(struct device_node *parent, int port, int ++static int pfe_get_gemac_if_properties(struct device_node *parent, int port, int + if_cnt, + struct ls1012a_pfe_platform_data + *pdata) + { +- struct device_node *gem = NULL, *phy = NULL; ++ struct device_node *gem = NULL, *phy = NULL, *phy_node = NULL; + int size; + int ii = 0, phy_id = 0; + const u32 *addr; +@@ -49,18 +49,11 @@ static int pfe_get_gemac_if_proprties(st + pdata->ls1012a_eth_pdata[port].gem_id = port; + + mac_addr = of_get_mac_address(gem); +- + if (mac_addr) { + memcpy(pdata->ls1012a_eth_pdata[port].mac_addr, mac_addr, + ETH_ALEN); + } + +- pdata->ls1012a_eth_pdata[port].mii_config = of_get_phy_mode(gem); +- +- if ((pdata->ls1012a_eth_pdata[port].mii_config) < 0) +- pr_err("%s:%d Incorrect Phy mode....\n", __func__, +- __LINE__); +- + addr = of_get_property(gem, "fsl,gemac-bus-id", &size); + if (!addr) + pr_err("%s:%d Invalid gemac-bus-id....\n", __func__, +@@ -68,16 +61,55 @@ static int pfe_get_gemac_if_proprties(st + else + pdata->ls1012a_eth_pdata[port].bus_id = be32_to_cpup(addr); + +- addr = of_get_property(gem, "fsl,gemac-phy-id", &size); +- if (!addr) { +- pr_err("%s:%d Invalid gemac-phy-id....\n", __func__, +- __LINE__); ++ phy_node = of_parse_phandle(gem, "phy-handle", 0); ++ pdata->ls1012a_eth_pdata[port].phy_node = phy_node; ++ if (phy_node) { ++ goto process_phynode; ++ } else if (of_phy_is_fixed_link(gem)) { ++ if (of_phy_register_fixed_link(gem) < 0) { ++ pr_err("broken fixed-link specification\n"); ++ goto err; ++ } ++ phy_node = of_node_get(gem); ++ pdata->ls1012a_eth_pdata[port].phy_node = phy_node; ++ } else if (of_get_property(gem, "fsl,pfe-phy-if-flags", &size)) { ++ /* Use old dts properties for phy handling */ ++ addr = of_get_property(gem, "fsl,pfe-phy-if-flags", &size); ++ pdata->ls1012a_eth_pdata[port].phy_flags = be32_to_cpup(addr); ++ ++ addr = of_get_property(gem, "fsl,gemac-phy-id", &size); ++ if (!addr) { ++ pr_err("%s:%d Invalid gemac-phy-id....\n", __func__, ++ __LINE__); ++ } else { ++ phy_id = be32_to_cpup(addr); ++ pdata->ls1012a_eth_pdata[port].phy_id = phy_id; ++ pdata->ls1012a_mdio_pdata[0].phy_mask &= ~(1 << phy_id); ++ } ++ ++ /* If PHY is enabled, read mdio properties */ ++ if (pdata->ls1012a_eth_pdata[port].phy_flags & GEMAC_NO_PHY) ++ goto done; ++ ++ phy = of_get_next_child(gem, NULL); ++ addr = of_get_property(phy, "reg", &size); ++ if (!addr) ++ pr_err("%s:%d Invalid phy enable flag....\n", ++ __func__, __LINE__); ++ else ++ pdata->ls1012a_mdio_pdata[port].enabled = ++ be32_to_cpup(addr); + } else { +- phy_id = be32_to_cpup(addr); +- pdata->ls1012a_eth_pdata[port].phy_id = phy_id; +- pdata->ls1012a_mdio_pdata[0].phy_mask &= ~(1 << phy_id); ++ pr_info("%s: No PHY or fixed-link\n", __func__); ++ return 0; + } + ++process_phynode: ++ pdata->ls1012a_eth_pdata[port].mii_config = of_get_phy_mode(gem); ++ if ((pdata->ls1012a_eth_pdata[port].mii_config) < 0) ++ pr_err("%s:%d Incorrect Phy mode....\n", __func__, ++ __LINE__); ++ + addr = of_get_property(gem, "fsl,mdio-mux-val", &size); + if (!addr) { + pr_err("%s: Invalid mdio-mux-val....\n", __func__); +@@ -90,33 +122,10 @@ static int pfe_get_gemac_if_proprties(st + pfe->mdio_muxval[pdata->ls1012a_eth_pdata[port].phy_id] = + pdata->ls1012a_eth_pdata[port].mdio_muxval; + +- addr = of_get_property(gem, "fsl,pfe-phy-if-flags", &size); +- if (!addr) +- pr_err("%s:%d Invalid pfe-phy-if-flags....\n", +- __func__, __LINE__); +- else +- pdata->ls1012a_eth_pdata[port].phy_flags = be32_to_cpup(addr); +- +- /* If PHY is enabled, read mdio properties */ +- if (pdata->ls1012a_eth_pdata[port].phy_flags & GEMAC_NO_PHY) +- goto done; +- +- phy = of_get_next_child(gem, NULL); +- +- addr = of_get_property(phy, "reg", &size); +- +- if (!addr) +- pr_err("%s:%d Invalid phy enable flag....\n", +- __func__, __LINE__); +- else +- pdata->ls1012a_mdio_pdata[port].enabled = be32_to_cpup(addr); + + pdata->ls1012a_mdio_pdata[port].irq[0] = PHY_POLL; + + done: +- if (of_phy_is_fixed_link(gem)) +- pdata->ls1012a_eth_pdata[port].phy_node = of_node_get(gem); +- + return 0; + + err: +@@ -218,8 +227,8 @@ static int pfe_platform_probe(struct pla + pfe_platform_data.ls1012a_mdio_pdata[0].phy_mask = 0xffffffff; + + for (ii = 0; ii < interface_count; ii++) { +- pfe_get_gemac_if_proprties(np, ii, interface_count, +- &pfe_platform_data); ++ pfe_get_gemac_if_properties(np, ii, interface_count, ++ &pfe_platform_data); + } + + pfe->dev = &pdev->dev; |