mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-29 10:08:59 +00:00
8a9273d51e
Copy backport, hack, pending patch and config from 6.1 to 6.6. Signed-off-by: Weijie Gao <hackpascal@gmail.com>
98 lines
3.0 KiB
Diff
98 lines
3.0 KiB
Diff
From 38eb804e8458ba181a03a0498ce4bf84eebd1931 Mon Sep 17 00:00:00 2001
|
|
From: Christian Marangi <ansuelsmth@gmail.com>
|
|
Date: Thu, 14 Dec 2023 01:44:32 +0100
|
|
Subject: [PATCH 2/2] net: phy: at803x: make read specific status function more
|
|
generic
|
|
|
|
Rework read specific status function to be more generic. The function
|
|
apply different speed mask based on the PHY ID. Make it more generic by
|
|
adding an additional arg to pass the specific speed (ss) mask and use
|
|
the provided mask to parse the speed value.
|
|
|
|
This is needed to permit an easier deatch of qca808x code from the
|
|
at803x driver.
|
|
|
|
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
---
|
|
drivers/net/phy/at803x.c | 26 ++++++++++++++++++--------
|
|
1 file changed, 18 insertions(+), 8 deletions(-)
|
|
|
|
--- a/drivers/net/phy/at803x.c
|
|
+++ b/drivers/net/phy/at803x.c
|
|
@@ -301,6 +301,11 @@ static struct at803x_hw_stat qca83xx_hw_
|
|
{ "eee_wake_errors", 0x16, GENMASK(15, 0), MMD},
|
|
};
|
|
|
|
+struct at803x_ss_mask {
|
|
+ u16 speed_mask;
|
|
+ u8 speed_shift;
|
|
+};
|
|
+
|
|
struct at803x_priv {
|
|
int flags;
|
|
u16 clk_25m_reg;
|
|
@@ -921,7 +926,8 @@ static void at803x_link_change_notify(st
|
|
}
|
|
}
|
|
|
|
-static int at803x_read_specific_status(struct phy_device *phydev)
|
|
+static int at803x_read_specific_status(struct phy_device *phydev,
|
|
+ struct at803x_ss_mask ss_mask)
|
|
{
|
|
int ss;
|
|
|
|
@@ -940,11 +946,8 @@ static int at803x_read_specific_status(s
|
|
if (sfc < 0)
|
|
return sfc;
|
|
|
|
- /* qca8081 takes the different bits for speed value from at803x */
|
|
- if (phydev->drv->phy_id == QCA8081_PHY_ID)
|
|
- speed = FIELD_GET(QCA808X_SS_SPEED_MASK, ss);
|
|
- else
|
|
- speed = FIELD_GET(AT803X_SS_SPEED_MASK, ss);
|
|
+ speed = ss & ss_mask.speed_mask;
|
|
+ speed >>= ss_mask.speed_shift;
|
|
|
|
switch (speed) {
|
|
case AT803X_SS_SPEED_10:
|
|
@@ -989,6 +992,7 @@ static int at803x_read_specific_status(s
|
|
static int at803x_read_status(struct phy_device *phydev)
|
|
{
|
|
struct at803x_priv *priv = phydev->priv;
|
|
+ struct at803x_ss_mask ss_mask = { 0 };
|
|
int err, old_link = phydev->link;
|
|
|
|
if (priv->is_1000basex)
|
|
@@ -1012,7 +1016,9 @@ static int at803x_read_status(struct phy
|
|
if (err < 0)
|
|
return err;
|
|
|
|
- err = at803x_read_specific_status(phydev);
|
|
+ ss_mask.speed_mask = AT803X_SS_SPEED_MASK;
|
|
+ ss_mask.speed_shift = __bf_shf(AT803X_SS_SPEED_MASK);
|
|
+ err = at803x_read_specific_status(phydev, ss_mask);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
@@ -1869,6 +1875,7 @@ static int qca808x_config_init(struct ph
|
|
|
|
static int qca808x_read_status(struct phy_device *phydev)
|
|
{
|
|
+ struct at803x_ss_mask ss_mask = { 0 };
|
|
int ret;
|
|
|
|
ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_STAT);
|
|
@@ -1882,7 +1889,10 @@ static int qca808x_read_status(struct ph
|
|
if (ret)
|
|
return ret;
|
|
|
|
- ret = at803x_read_specific_status(phydev);
|
|
+ /* qca8081 takes the different bits for speed value from at803x */
|
|
+ ss_mask.speed_mask = QCA808X_SS_SPEED_MASK;
|
|
+ ss_mask.speed_shift = __bf_shf(QCA808X_SS_SPEED_MASK);
|
|
+ ret = at803x_read_specific_status(phydev, ss_mask);
|
|
if (ret < 0)
|
|
return ret;
|
|
|