[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aee610ab-2815-42f0-a4e4-5f695238beae@lunn.ch>
Date: Mon, 26 Feb 2024 16:34:34 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Jérémie Dautheribes <jeremie.dautheribes@...tlin.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>, Andrew Davis <afd@...com>,
netdev@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Miquèl Raynal <miquel.raynal@...tlin.com>,
Yen-Mei Goh <yen-mei.goh@...sight.com>,
Maxime Chevallier <maxime.chevallier@...tlin.com>
Subject: Re: [PATCH net-next 2/3] net: phy: dp83826: Add support for phy-mode
configuration
On Thu, Feb 22, 2024 at 11:31:16AM +0100, Jérémie Dautheribes wrote:
> The TI DP83826 PHY can operate in either MII mode or RMII mode.
> By default, it is configured by straps.
> It can also be configured by writing to the bit 5 of register 0x17 - RMII
> and Status Register (RCSR).
>
> When phydev->interface is rmii, rmii mode must be enabled, otherwise
> mii mode must be set.
> This prevents misconfiguration of hw straps.
>
> Signed-off-by: Jérémie Dautheribes <jeremie.dautheribes@...tlin.com>
> ---
> drivers/net/phy/dp83822.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
> index 30f2616ab1c2..2d8275e59dcc 100644
> --- a/drivers/net/phy/dp83822.c
> +++ b/drivers/net/phy/dp83822.c
> @@ -100,6 +100,7 @@
> #define DP83822_WOL_CLR_INDICATION BIT(11)
>
> /* RCSR bits */
> +#define DP83822_RMII_MODE_EN BIT(5)
> #define DP83822_RGMII_MODE_EN BIT(9)
> #define DP83822_RX_CLK_SHIFT BIT(12)
> #define DP83822_TX_CLK_SHIFT BIT(11)
> @@ -500,6 +501,16 @@ static int dp83826_config_init(struct phy_device *phydev)
> u16 val, mask;
> int ret;
>
> + if (phydev->interface == PHY_INTERFACE_MODE_RMII)
> + ret = phy_set_bits_mmd(phydev, DP83822_DEVADDR, MII_DP83822_RCSR,
> + DP83822_RMII_MODE_EN);
> + else
> + ret = phy_clear_bits_mmd(phydev, DP83822_DEVADDR, MII_DP83822_RCSR,
> + DP83822_RMII_MODE_EN);
I would probably add a test for MII and return -EINVAL if asked to do
something else altogether.
Andrew
Powered by blists - more mailing lists