layerscape: add patches-5.4
[openwrt/staging/stintel.git] / target / linux / layerscape / patches-5.4 / 701-net-0247-net-mscc-ocelot-move-port-initialization-into-separa.patch
1 From 66f4bb358787f4f52de0614a92f9e4130d1e0e01 Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Sat, 9 Nov 2019 15:02:56 +0200
4 Subject: [PATCH] net: mscc: ocelot: move port initialization into separate
5 function
6
7 We need a function for the DSA front-end that does none of the
8 net_device registration, but initializes the hardware ports.
9
10 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
12 ---
13 drivers/net/ethernet/mscc/ocelot.c | 45 ++++++++++++++++++++------------------
14 1 file changed, 24 insertions(+), 21 deletions(-)
15
16 --- a/drivers/net/ethernet/mscc/ocelot.c
17 +++ b/drivers/net/ethernet/mscc/ocelot.c
18 @@ -2137,6 +2137,28 @@ static int ocelot_init_timestamp(struct
19 return 0;
20 }
21
22 +static void ocelot_init_port(struct ocelot *ocelot, int port)
23 +{
24 + struct ocelot_port *ocelot_port = ocelot->ports[port];
25 +
26 + INIT_LIST_HEAD(&ocelot_port->skbs);
27 +
28 + /* Basic L2 initialization */
29 +
30 + /* Drop frames with multicast source address */
31 + ocelot_rmw_gix(ocelot, ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,
32 + ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA,
33 + ANA_PORT_DROP_CFG, port);
34 +
35 + /* Set default VLAN and tag type to 8021Q. */
36 + ocelot_rmw_gix(ocelot, REW_PORT_VLAN_CFG_PORT_TPID(ETH_P_8021Q),
37 + REW_PORT_VLAN_CFG_PORT_TPID_M,
38 + REW_PORT_VLAN_CFG, port);
39 +
40 + /* Enable vcap lookups */
41 + ocelot_vcap_enable(ocelot, port);
42 +}
43 +
44 int ocelot_probe_port(struct ocelot *ocelot, u8 port,
45 void __iomem *regs,
46 struct phy_device *phy)
47 @@ -2144,7 +2166,6 @@ int ocelot_probe_port(struct ocelot *oce
48 struct ocelot_port_private *priv;
49 struct ocelot_port *ocelot_port;
50 struct net_device *dev;
51 - u32 val;
52 int err;
53
54 dev = alloc_etherdev(sizeof(struct ocelot_port_private));
55 @@ -2172,32 +2193,14 @@ int ocelot_probe_port(struct ocelot *oce
56 ocelot_mact_learn(ocelot, PGID_CPU, dev->dev_addr, ocelot_port->pvid,
57 ENTRYTYPE_LOCKED);
58
59 - INIT_LIST_HEAD(&ocelot_port->skbs);
60 + ocelot_init_port(ocelot, port);
61
62 err = register_netdev(dev);
63 if (err) {
64 dev_err(ocelot->dev, "register_netdev failed\n");
65 - goto err_register_netdev;
66 + free_netdev(dev);
67 }
68
69 - /* Basic L2 initialization */
70 -
71 - /* Drop frames with multicast source address */
72 - val = ANA_PORT_DROP_CFG_DROP_MC_SMAC_ENA;
73 - ocelot_rmw_gix(ocelot, val, val, ANA_PORT_DROP_CFG, port);
74 -
75 - /* Set default VLAN and tag type to 8021Q. */
76 - ocelot_rmw_gix(ocelot, REW_PORT_VLAN_CFG_PORT_TPID(ETH_P_8021Q),
77 - REW_PORT_VLAN_CFG_PORT_TPID_M,
78 - REW_PORT_VLAN_CFG, port);
79 -
80 - /* Enable vcap lookups */
81 - ocelot_vcap_enable(ocelot, port);
82 -
83 - return 0;
84 -
85 -err_register_netdev:
86 - free_netdev(dev);
87 return err;
88 }
89 EXPORT_SYMBOL(ocelot_probe_port);