69bf2d0d2f3c39571122cbb460493ac7dd5bf7e9
[openwrt/openwrt.git] /
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 @@ -380,8 +380,9 @@ 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 - int mode;
29 unsigned int port_num;
30
31 priv->moca_port = -1;
32 @@ -390,19 +391,26 @@ static void bcm_sf2_identify_ports(struc
33 if (of_property_read_u32(port, "reg", &port_num))
34 continue;
35
36 + if (port_num >= DSA_MAX_PORTS) {
37 + dev_err(dev, "Invalid port number %d\n", port_num);
38 + continue;
39 + }
40 +
41 + port_st = &priv->port_sts[port_num];
42 +
43 /* Internal PHYs get assigned a specific 'phy-mode' property
44 * value: "internal" to help flag them before MDIO probing
45 * has completed, since they might be turned off at that
46 * time
47 */
48 - mode = of_get_phy_mode(port);
49 - if (mode < 0)
50 + port_st->mode = of_get_phy_mode(port);
51 + if (port_st->mode < 0)
52 continue;
53
54 - if (mode == PHY_INTERFACE_MODE_INTERNAL)
55 + if (port_st->mode == PHY_INTERFACE_MODE_INTERNAL)
56 priv->int_phy_mask |= 1 << port_num;
57
58 - if (mode == PHY_INTERFACE_MODE_MOCA)
59 + if (port_st->mode == PHY_INTERFACE_MODE_MOCA)
60 priv->moca_port = port_num;
61
62 if (of_property_read_bool(port, "brcm,use-bcm-hdr"))
63 --- a/drivers/net/dsa/bcm_sf2.h
64 +++ b/drivers/net/dsa/bcm_sf2.h
65 @@ -43,6 +43,7 @@ struct bcm_sf2_hw_params {
66 #define BCM_SF2_REGS_NUM 6
67
68 struct bcm_sf2_port_status {
69 + int mode;
70 unsigned int link;
71 };
72