ath25: switch default kernel to 5.15
[openwrt/openwrt.git] / target / linux / bcm4908 / patches-5.10 / 075-v5.13-0001-net-dsa-bcm_sf2-store-PHY-interface-mode-in-port-str.patch
1 From 01488a0ccd9abe15565bed50a45afcddbb0fe199 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Fri, 12 Mar 2021 11:41:07 +0100
4 Subject: [PATCH] net: dsa: bcm_sf2: store PHY interface/mode in port structure
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 It's needed later for proper switch / crossbar setup.
10
11 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
12 Acked-by: Florian Fainelli <f.fainelli@gmail.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 drivers/net/dsa/bcm_sf2.c | 16 ++++++++++++----
16 drivers/net/dsa/bcm_sf2.h | 1 +
17 2 files changed, 13 insertions(+), 4 deletions(-)
18
19 --- a/drivers/net/dsa/bcm_sf2.c
20 +++ b/drivers/net/dsa/bcm_sf2.c
21 @@ -446,10 +446,11 @@ static void bcm_sf2_intr_disable(struct
22 static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
23 struct device_node *dn)
24 {
25 + struct device *dev = priv->dev->ds->dev;
26 + struct bcm_sf2_port_status *port_st;
27 struct device_node *port;
28 unsigned int port_num;
29 struct property *prop;
30 - phy_interface_t mode;
31 int err;
32
33 priv->moca_port = -1;
34 @@ -458,19 +459,26 @@ static void bcm_sf2_identify_ports(struc
35 if (of_property_read_u32(port, "reg", &port_num))
36 continue;
37
38 + if (port_num >= DSA_MAX_PORTS) {
39 + dev_err(dev, "Invalid port number %d\n", port_num);
40 + continue;
41 + }
42 +
43 + port_st = &priv->port_sts[port_num];
44 +
45 /* Internal PHYs get assigned a specific 'phy-mode' property
46 * value: "internal" to help flag them before MDIO probing
47 * has completed, since they might be turned off at that
48 * time
49 */
50 - err = of_get_phy_mode(port, &mode);
51 + err = of_get_phy_mode(port, &port_st->mode);
52 if (err)
53 continue;
54
55 - if (mode == PHY_INTERFACE_MODE_INTERNAL)
56 + if (port_st->mode == PHY_INTERFACE_MODE_INTERNAL)
57 priv->int_phy_mask |= 1 << port_num;
58
59 - if (mode == PHY_INTERFACE_MODE_MOCA)
60 + if (port_st->mode == PHY_INTERFACE_MODE_MOCA)
61 priv->moca_port = port_num;
62
63 if (of_property_read_bool(port, "brcm,use-bcm-hdr"))
64 --- a/drivers/net/dsa/bcm_sf2.h
65 +++ b/drivers/net/dsa/bcm_sf2.h
66 @@ -44,6 +44,7 @@ struct bcm_sf2_hw_params {
67 #define BCM_SF2_REGS_NUM 6
68
69 struct bcm_sf2_port_status {
70 + phy_interface_t mode;
71 unsigned int link;
72 bool enabled;
73 };