generic: fix Macronix SPI-NAND driver
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 703-06-v5.18-net-dsa-add-support-for-phylink-mac_select_pcs.patch
1 From bde018222c6b084ac32933a9f933581dd83da18e Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Thu, 17 Feb 2022 18:30:35 +0000
4 Subject: [PATCH] net: dsa: add support for phylink mac_select_pcs()
5
6 Add DSA support for the phylink mac_select_pcs() method so DSA drivers
7 can return provide phylink with the appropriate PCS for the PHY
8 interface mode.
9
10 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
12 ---
13 include/net/dsa.h | 3 +++
14 net/dsa/port.c | 15 +++++++++++++++
15 2 files changed, 18 insertions(+)
16
17 --- a/include/net/dsa.h
18 +++ b/include/net/dsa.h
19 @@ -631,6 +631,9 @@ struct dsa_switch_ops {
20 void (*phylink_validate)(struct dsa_switch *ds, int port,
21 unsigned long *supported,
22 struct phylink_link_state *state);
23 + struct phylink_pcs *(*phylink_mac_select_pcs)(struct dsa_switch *ds,
24 + int port,
25 + phy_interface_t iface);
26 int (*phylink_mac_link_state)(struct dsa_switch *ds, int port,
27 struct phylink_link_state *state);
28 void (*phylink_mac_config)(struct dsa_switch *ds, int port,
29 --- a/net/dsa/port.c
30 +++ b/net/dsa/port.c
31 @@ -1028,6 +1028,20 @@ static void dsa_port_phylink_mac_pcs_get
32 }
33 }
34
35 +static struct phylink_pcs *
36 +dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
37 + phy_interface_t interface)
38 +{
39 + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
40 + struct dsa_switch *ds = dp->ds;
41 + struct phylink_pcs *pcs = NULL;
42 +
43 + if (ds->ops->phylink_mac_select_pcs)
44 + pcs = ds->ops->phylink_mac_select_pcs(ds, dp->index, interface);
45 +
46 + return pcs;
47 +}
48 +
49 static void dsa_port_phylink_mac_config(struct phylink_config *config,
50 unsigned int mode,
51 const struct phylink_link_state *state)
52 @@ -1094,6 +1108,7 @@ static void dsa_port_phylink_mac_link_up
53
54 static const struct phylink_mac_ops dsa_port_phylink_mac_ops = {
55 .validate = dsa_port_phylink_validate,
56 + .mac_select_pcs = dsa_port_phylink_mac_select_pcs,
57 .mac_pcs_get_state = dsa_port_phylink_mac_pcs_get_state,
58 .mac_config = dsa_port_phylink_mac_config,
59 .mac_an_restart = dsa_port_phylink_mac_an_restart,