* [PATCH net-next] net: dp83869: Add ability to advertise Fiber connection
@ 2020-09-02 13:25 Dan Murphy
2020-09-02 18:16 ` Dan Murphy
0 siblings, 1 reply; 2+ messages in thread
From: Dan Murphy @ 2020-09-02 13:25 UTC (permalink / raw)
To: davem, andrew, f.fainelli, hkallweit1; +Cc: netdev, linux-kernel, Dan Murphy
Add the ability to advertise the Fiber connection if the strap or the
op-mode is configured for 100Base-FX.
Auto negotiation is not supported on this PHY when in fiber mode.
Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
drivers/net/phy/dp83869.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c
index 58103152c601..1acf498832f1 100644
--- a/drivers/net/phy/dp83869.c
+++ b/drivers/net/phy/dp83869.c
@@ -52,6 +52,11 @@
BMCR_FULLDPLX | \
BMCR_SPEED1000)
+#define MII_DP83869_FIBER_ADVERTISE (ADVERTISED_TP | ADVERTISED_MII | \
+ ADVERTISED_FIBRE | ADVERTISED_BNC | \
+ ADVERTISED_Pause | ADVERTISED_Asym_Pause | \
+ ADVERTISED_100baseT_Full)
+
/* This is the same bit mask as the BMCR so re-use the BMCR default */
#define DP83869_FX_CTRL_DEFAULT MII_DP83869_BMCR_DEFAULT
@@ -300,6 +305,7 @@ static int dp83869_configure_mode(struct phy_device *phydev,
{
int phy_ctrl_val;
int ret;
+ int bmcr;
if (dp83869->mode < DP83869_RGMII_COPPER_ETHERNET ||
dp83869->mode > DP83869_SGMII_COPPER_ETHERNET)
@@ -383,7 +389,36 @@ static int dp83869_configure_mode(struct phy_device *phydev,
break;
case DP83869_RGMII_1000_BASE:
+ break;
case DP83869_RGMII_100_BASE:
+ /* Only allow advertising what this PHY supports */
+ linkmode_and(phydev->advertising, phydev->advertising,
+ phydev->supported);
+
+ linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT,
+ phydev->supported);
+ linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT,
+ phydev->advertising);
+
+ /* Auto neg is not supported in fiber mode */
+ bmcr = phy_read(phydev, MII_BMCR);
+ if (bmcr < 0)
+ return bmcr;
+
+ phydev->autoneg = AUTONEG_DISABLE;
+ linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
+ phydev->supported);
+ linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
+ phydev->advertising);
+
+ if (bmcr & BMCR_ANENABLE) {
+ ret = phy_modify(phydev, MII_BMCR, BMCR_ANENABLE, 0);
+ if (ret < 0)
+ return ret;
+ }
+ ret = phy_modify_changed(phydev, MII_ADVERTISE,
+ MII_DP83869_FIBER_ADVERTISE,
+ MII_DP83869_FIBER_ADVERTISE);
break;
default:
return -EINVAL;
--
2.28.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: dp83869: Add ability to advertise Fiber connection
2020-09-02 13:25 [PATCH net-next] net: dp83869: Add ability to advertise Fiber connection Dan Murphy
@ 2020-09-02 18:16 ` Dan Murphy
0 siblings, 0 replies; 2+ messages in thread
From: Dan Murphy @ 2020-09-02 18:16 UTC (permalink / raw)
To: davem, andrew, f.fainelli, hkallweit1; +Cc: netdev, linux-kernel
On 9/2/20 8:25 AM, Dan Murphy wrote:
> Add the ability to advertise the Fiber connection if the strap or the
> op-mode is configured for 100Base-FX.
>
> Auto negotiation is not supported on this PHY when in fiber mode.
>
> Signed-off-by: Dan Murphy <dmurphy@ti.com>
> ---
> drivers/net/phy/dp83869.c | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c
> index 58103152c601..1acf498832f1 100644
> --- a/drivers/net/phy/dp83869.c
> +++ b/drivers/net/phy/dp83869.c
> @@ -52,6 +52,11 @@
> BMCR_FULLDPLX | \
> BMCR_SPEED1000)
>
> +#define MII_DP83869_FIBER_ADVERTISE (ADVERTISED_TP | ADVERTISED_MII | \
> + ADVERTISED_FIBRE | ADVERTISED_BNC | \
> + ADVERTISED_Pause | ADVERTISED_Asym_Pause | \
> + ADVERTISED_100baseT_Full)
> +
> /* This is the same bit mask as the BMCR so re-use the BMCR default */
> #define DP83869_FX_CTRL_DEFAULT MII_DP83869_BMCR_DEFAULT
>
> @@ -300,6 +305,7 @@ static int dp83869_configure_mode(struct phy_device *phydev,
> {
> int phy_ctrl_val;
> int ret;
> + int bmcr;
>
> if (dp83869->mode < DP83869_RGMII_COPPER_ETHERNET ||
> dp83869->mode > DP83869_SGMII_COPPER_ETHERNET)
> @@ -383,7 +389,36 @@ static int dp83869_configure_mode(struct phy_device *phydev,
>
> break;
> case DP83869_RGMII_1000_BASE:
> + break;
> case DP83869_RGMII_100_BASE:
> + /* Only allow advertising what this PHY supports */
> + linkmode_and(phydev->advertising, phydev->advertising,
> + phydev->supported);
> +
> + linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT,
> + phydev->supported);
> + linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT,
> + phydev->advertising);
> +
> + /* Auto neg is not supported in fiber mode */
> + bmcr = phy_read(phydev, MII_BMCR);
> + if (bmcr < 0)
> + return bmcr;
> +
> + phydev->autoneg = AUTONEG_DISABLE;
> + linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
> + phydev->supported);
> + linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
> + phydev->advertising);
> +
> + if (bmcr & BMCR_ANENABLE) {
> + ret = phy_modify(phydev, MII_BMCR, BMCR_ANENABLE, 0);
> + if (ret < 0)
> + return ret;
> + }
> + ret = phy_modify_changed(phydev, MII_ADVERTISE,
> + MII_DP83869_FIBER_ADVERTISE,
> + MII_DP83869_FIBER_ADVERTISE);
This is not correct after some testing find that this fails to init
since ret will be non-zero on success
Dan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-02 18:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-02 13:25 [PATCH net-next] net: dp83869: Add ability to advertise Fiber connection Dan Murphy
2020-09-02 18:16 ` Dan Murphy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).