summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorFlorian Fainelli <florian.fainelli@broadcom.com>2024-04-23 21:33:34 +0300
committerJakub Kicinski <kuba@kernel.org>2024-04-25 21:46:37 +0300
commit0d18dea4cde6d924ce830ab11780cb8500538227 (patch)
tree45c62b42e163f94e468c9856115bc6310a88f657 /drivers
parentb3d06dc3707f6d0b90ebc9841c7df039adcac7fc (diff)
downloadlinux-0d18dea4cde6d924ce830ab11780cb8500538227.tar.xz
net: dsa: b53: Introduce b53_adjust_5325_mii()
Takes care of doing the 5325 switch series specific MII programming and is called from b53_adjust_link() to allow the future removal of b53_adjust_link(). Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Link: https://lore.kernel.org/r/20240423183339.1368511-4-florian.fainelli@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/dsa/b53/b53_common.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 744567c465f7..a127a17be11c 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1309,6 +1309,29 @@ static void b53_adjust_531x5_rgmii(struct dsa_switch *ds, int port,
phy_modes(interface));
}
+static void b53_adjust_5325_mii(struct dsa_switch *ds, int port)
+{
+ struct b53_device *dev = ds->priv;
+ u8 reg = 0;
+
+ b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
+ &reg);
+
+ /* reverse mii needs to be enabled */
+ if (!(reg & PORT_OVERRIDE_RV_MII_25)) {
+ b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
+ reg | PORT_OVERRIDE_RV_MII_25);
+ b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
+ &reg);
+
+ if (!(reg & PORT_OVERRIDE_RV_MII_25)) {
+ dev_err(ds->dev,
+ "Failed to enable reverse MII mode\n");
+ return;
+ }
+ }
+}
+
static void b53_adjust_link(struct dsa_switch *ds, int port,
struct phy_device *phydev)
{
@@ -1316,7 +1339,6 @@ static void b53_adjust_link(struct dsa_switch *ds, int port,
struct ethtool_keee *p = &dev->ports[port].eee;
bool tx_pause = false;
bool rx_pause = false;
- u8 reg = 0;
if (!phy_is_pseudo_fixed_link(phydev))
return;
@@ -1342,24 +1364,8 @@ static void b53_adjust_link(struct dsa_switch *ds, int port,
b53_adjust_531x5_rgmii(ds, port, phydev->interface);
/* configure MII port if necessary */
- if (is5325(dev)) {
- b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
- &reg);
-
- /* reverse mii needs to be enabled */
- if (!(reg & PORT_OVERRIDE_RV_MII_25)) {
- b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
- reg | PORT_OVERRIDE_RV_MII_25);
- b53_read8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
- &reg);
-
- if (!(reg & PORT_OVERRIDE_RV_MII_25)) {
- dev_err(ds->dev,
- "Failed to enable reverse MII mode\n");
- return;
- }
- }
- }
+ if (is5325(dev))
+ b53_adjust_5325_mii(ds, port);
/* Re-negotiate EEE if it was enabled already */
p->eee_enabled = b53_eee_init(ds, port, phydev);