kernel: bump 5.4 to 5.4.123
[openwrt/staging/ynezz.git] / target / linux / layerscape / patches-5.4 / 701-net-0307-staging-fsl_ppfe-eth-add-fixed-link-support.patch
1 From 04373c37df836557ae7ebb769383baa1b57c5ffa Mon Sep 17 00:00:00 2001
2 From: Calvin Johnson <calvin.johnson@nxp.com>
3 Date: Thu, 4 Oct 2018 09:38:17 +0530
4 Subject: [PATCH] staging: fsl_ppfe/eth: add fixed-link support
5
6 In cases where MAC is not connected to a normal MDIO-managed PHY
7 device, and instead to a switch, it is configured as a "fixed-link".
8 Code to handle this scenario is added here.
9
10 phy_node in the dtb is checked to identify a fixed-link.
11 On identification of a fixed-link, it is registered and connected.
12
13 Signed-off-by: Calvin Johnson <calvin.johnson@nxp.com>
14 ---
15 drivers/staging/fsl_ppfe/pfe_eth.c | 21 ++++++++++++++++++++-
16 drivers/staging/fsl_ppfe/pfe_eth.h | 2 ++
17 drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c | 4 ++++
18 3 files changed, 26 insertions(+), 1 deletion(-)
19
20 --- a/drivers/staging/fsl_ppfe/pfe_eth.c
21 +++ b/drivers/staging/fsl_ppfe/pfe_eth.c
22 @@ -39,6 +39,9 @@
23 #include <net/ip.h>
24 #include <net/sock.h>
25
26 +#include <linux/of.h>
27 +#include <linux/of_mdio.h>
28 +
29 #include <linux/io.h>
30 #include <asm/irq.h>
31 #include <linux/delay.h>
32 @@ -1263,6 +1266,8 @@ static int pfe_phy_init(struct net_devic
33 char phy_id[MII_BUS_ID_SIZE + 3];
34 char bus_id[MII_BUS_ID_SIZE];
35 phy_interface_t interface;
36 + struct device_node *phy_node;
37 + int rc;
38
39 priv->oldlink = 0;
40 priv->oldspeed = 0;
41 @@ -1293,7 +1298,20 @@ static int pfe_phy_init(struct net_devic
42 priv->oldspeed = 0;
43 priv->oldduplex = -1;
44 pr_info("%s interface %x\n", __func__, interface);
45 - phydev = phy_connect(ndev, phy_id, &pfe_eth_adjust_link, interface);
46 +
47 + if (of_phy_is_fixed_link(priv->phy_node)) {
48 + rc = of_phy_register_fixed_link(priv->phy_node);
49 + if (rc)
50 + return rc;
51 + phy_node = of_node_get(priv->phy_node);
52 + phydev = of_phy_connect(ndev, phy_node, pfe_eth_adjust_link, 0,
53 + priv->einfo->mii_config);
54 + of_node_put(phy_node);
55 +
56 + } else {
57 + phydev = phy_connect(ndev, phy_id,
58 + &pfe_eth_adjust_link, interface);
59 + }
60
61 if (IS_ERR(phydev)) {
62 netdev_err(ndev, "phy_connect() failed\n");
63 @@ -2371,6 +2389,7 @@ static int pfe_eth_init_one(struct pfe *
64 priv->ndev = ndev;
65 priv->id = einfo[id].gem_id;
66 priv->pfe = pfe;
67 + priv->phy_node = einfo[id].phy_node;
68
69 SET_NETDEV_DEV(priv->ndev, priv->pfe->dev);
70
71 --- a/drivers/staging/fsl_ppfe/pfe_eth.h
72 +++ b/drivers/staging/fsl_ppfe/pfe_eth.h
73 @@ -61,6 +61,7 @@ struct ls1012a_eth_platform_data {
74 u32 phy_id;
75 u32 mdio_muxval;
76 u8 mac_addr[ETH_ALEN];
77 + struct device_node *phy_node;
78 };
79
80 struct ls1012a_mdio_platform_data {
81 @@ -144,6 +145,7 @@ struct pfe_eth_priv_s {
82 int oldspeed;
83 int oldduplex;
84 int oldlink;
85 + struct device_node *phy_node;
86 /* mdio info */
87 int mdc_div;
88 struct mii_bus *mii_bus;
89 --- a/drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c
90 +++ b/drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c
91 @@ -18,8 +18,10 @@
92
93 #include <linux/module.h>
94 #include <linux/device.h>
95 +#include <linux/of.h>
96 #include <linux/of_net.h>
97 #include <linux/of_address.h>
98 +#include <linux/of_mdio.h>
99 #include <linux/platform_device.h>
100 #include <linux/slab.h>
101 #include <linux/clk.h>
102 @@ -124,6 +126,8 @@ static int pfe_get_gemac_if_proprties(st
103 pdata->ls1012a_mdio_pdata[port].irq[0] = PHY_POLL;
104
105 done:
106 + if (of_phy_is_fixed_link(gem))
107 + pdata->ls1012a_eth_pdata[port].phy_node = of_node_get(gem);
108
109 return 0;
110