Skip to content

Commit

Permalink
realtek: Use SerDes Information from .dts for phylink config
Browse files Browse the repository at this point in the history
When a port is brought up, read the SDS-id via the phy_device
for a given port and use this to configure the SDS when it
is brought up.

Signed-off-by: Birger Koblitz <git@birger-koblitz.de>
  • Loading branch information
Birger Koblitz authored and dangowrt committed Feb 17, 2022
1 parent 8079574 commit bf0ffe3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
30 changes: 26 additions & 4 deletions target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
Expand Up @@ -239,6 +239,26 @@ static int rtl930x_setup(struct dsa_switch *ds)
return 0;
}

static int rtl93xx_get_sds(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
struct device_node *dn;
u32 sds_num;

if (!dev)
return -1;
if (dev->of_node) {
dn = dev->of_node;
if (of_property_read_u32(dn, "sds", &sds_num))
sds_num = -1;
} else {
dev_err(dev, "No DT node.\n");
return -1;
}

return sds_num;
}

static void rtl83xx_phylink_validate(struct dsa_switch *ds, int port,
unsigned long *supported,
struct phylink_link_state *state)
Expand Down Expand Up @@ -594,7 +614,7 @@ static void rtl93xx_phylink_mac_config(struct dsa_switch *ds, int port,
int sds_num, sds_mode;
u32 reg;

pr_debug("%s port %d, mode %x, phy-mode: %s, speed %d, link %d\n", __func__,
pr_info("%s port %d, mode %x, phy-mode: %s, speed %d, link %d\n", __func__,
port, mode, phy_modes(state->interface), state->speed, state->link);

// Nothing to be done for the CPU-port
Expand All @@ -604,9 +624,9 @@ static void rtl93xx_phylink_mac_config(struct dsa_switch *ds, int port,
reg = sw_r32(priv->r->mac_force_mode_ctrl(port));
reg &= ~(0xf << 3);

// On the RTL930X, ports 24 to 27 are using an internal SerDes
if (port >=24 && port <= 27) {
sds_num = port - 18; // Port 24 mapped to SerDes 6, 25 to 7 ...
sds_num = priv->ports[port].sds_num;
pr_info("%s SDS is %d\n", __func__, sds_num);
if (sds_num >= 0) {
switch (state->interface) {
case PHY_INTERFACE_MODE_HSGMII:
sds_mode = 0x12;
Expand Down Expand Up @@ -781,6 +801,8 @@ static int rtl83xx_port_enable(struct dsa_switch *ds, int port,
sw_w32_mask(0, BIT(port), RTL930X_L2_PORT_DABLK_CTRL);
}

priv->ports[port].sds_num = rtl93xx_get_sds(phydev);

return 0;
}

Expand Down
Expand Up @@ -443,7 +443,7 @@ struct rtl838x_port {
enum phy_type phy;
bool is10G;
bool is2G5;
u8 sds_num;
int sds_num;
const struct dsa_port *dp;
};

Expand Down

0 comments on commit bf0ffe3

Please sign in to comment.