Skip to content

Commit b22eef6

Browse files
Russell King (Oracle)davem330
authored andcommitted
net: dsa: realtek: add phylink_get_caps implementation
The user ports use RSGMII, but we don't have that, and DT doesn't specify a phy interface mode, so phylib defaults to GMII. These support 1G, 100M and 10M with flow control. It is unknown whether asymetric pause is supported at all speeds. The CPU port uses MII/GMII/RGMII/REVMII by hardware pin strapping, and support speeds specific to each, with full duplex only supported in some modes. Flow control may be supported again by hardware pin strapping, and theoretically is readable through a register but no information is given in the datasheet for that. So, we do a best efforts - and be lenient. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 85c7863 commit b22eef6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

drivers/net/dsa/realtek/rtl8366rb.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,32 @@ static enum dsa_tag_protocol rtl8366_get_tag_protocol(struct dsa_switch *ds,
10491049
return DSA_TAG_PROTO_RTL4_A;
10501050
}
10511051

1052+
static void rtl8366rb_phylink_get_caps(struct dsa_switch *ds, int port,
1053+
struct phylink_config *config)
1054+
{
1055+
unsigned long *interfaces = config->supported_interfaces;
1056+
struct realtek_priv *priv = ds->priv;
1057+
1058+
if (port == priv->cpu_port) {
1059+
__set_bit(PHY_INTERFACE_MODE_MII, interfaces);
1060+
__set_bit(PHY_INTERFACE_MODE_GMII, interfaces);
1061+
/* REVMII only supports 100M FD */
1062+
__set_bit(PHY_INTERFACE_MODE_REVMII, interfaces);
1063+
/* RGMII only supports 1G FD */
1064+
phy_interface_set_rgmii(interfaces);
1065+
1066+
config->mac_capabilities = MAC_1000 | MAC_100 |
1067+
MAC_SYM_PAUSE;
1068+
} else {
1069+
/* RSGMII port, but we don't have that, and we don't
1070+
* specify in DT, so phylib uses the default of GMII
1071+
*/
1072+
__set_bit(PHY_INTERFACE_MODE_GMII, interfaces);
1073+
config->mac_capabilities = MAC_1000 | MAC_100 | MAC_10 |
1074+
MAC_SYM_PAUSE | MAC_ASYM_PAUSE;
1075+
}
1076+
}
1077+
10521078
static void
10531079
rtl8366rb_mac_link_up(struct dsa_switch *ds, int port, unsigned int mode,
10541080
phy_interface_t interface, struct phy_device *phydev,
@@ -1796,6 +1822,7 @@ static int rtl8366rb_detect(struct realtek_priv *priv)
17961822
static const struct dsa_switch_ops rtl8366rb_switch_ops_smi = {
17971823
.get_tag_protocol = rtl8366_get_tag_protocol,
17981824
.setup = rtl8366rb_setup,
1825+
.phylink_get_caps = rtl8366rb_phylink_get_caps,
17991826
.phylink_mac_link_up = rtl8366rb_mac_link_up,
18001827
.phylink_mac_link_down = rtl8366rb_mac_link_down,
18011828
.get_strings = rtl8366_get_strings,
@@ -1821,6 +1848,7 @@ static const struct dsa_switch_ops rtl8366rb_switch_ops_mdio = {
18211848
.setup = rtl8366rb_setup,
18221849
.phy_read = rtl8366rb_dsa_phy_read,
18231850
.phy_write = rtl8366rb_dsa_phy_write,
1851+
.phylink_get_caps = rtl8366rb_phylink_get_caps,
18241852
.phylink_mac_link_up = rtl8366rb_mac_link_up,
18251853
.phylink_mac_link_down = rtl8366rb_mac_link_down,
18261854
.get_strings = rtl8366_get_strings,

0 commit comments

Comments
 (0)