diff mbox series

[net-next,v3,09/10] net: freescale: ucc_geth: Introduce a helper to check Reduced modes

Message ID 20241203124323.155866-10-maxime.chevallier@bootlin.com (mailing list archive)
State Accepted
Commit 02d4a6498b3028f64f93ac61c0ff346e8ab661e0
Delegated to: Netdev Maintainers
Headers show
Series net: freescale: ucc_geth: Phylink conversion | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: andrew+netdev@lunn.ch
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 304 this patch: 304
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-04--15-02 (tests: 760)

Commit Message

Maxime Chevallier Dec. 3, 2024, 12:43 p.m. UTC
A number of parallel MII interfaces also exist in a "Reduced" mode,
usually with higher clock rates and fewer data lines, to ease the
hardware design. This is what the 'R' stands for in RGMII, RMII, RTBI,
RXAUI, etc.

The UCC Geth controller has a special configuration bit that needs to be
set when the MII mode is one of the supported reduced modes.

Add a local helper for that.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
V3: No changes

 drivers/net/ethernet/freescale/ucc_geth.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Andrew Lunn Dec. 4, 2024, 2:15 a.m. UTC | #1
> +static bool phy_interface_mode_is_reduced(phy_interface_t interface)
> +{
> +	return phy_interface_mode_is_rgmii(interface) ||
> +	       interface == PHY_INTERFACE_MODE_RMII ||
> +	       interface == PHY_INTERFACE_MODE_RTBI;
> +}

I wounder if this is useful anywhere else? Did you take a look around
other MAC drivers? Maybe this should be in phy.h?

	Andrew
Maxime Chevallier Dec. 4, 2024, 8:22 a.m. UTC | #2
Hello Andrew,

On Wed, 4 Dec 2024 03:15:52 +0100
Andrew Lunn <andrew@lunn.ch> wrote:

> > +static bool phy_interface_mode_is_reduced(phy_interface_t interface)
> > +{
> > +	return phy_interface_mode_is_rgmii(interface) ||
> > +	       interface == PHY_INTERFACE_MODE_RMII ||
> > +	       interface == PHY_INTERFACE_MODE_RTBI;
> > +}  
> 
> I wounder if this is useful anywhere else? Did you take a look around
> other MAC drivers? Maybe this should be in phy.h?

Yes I did consider it but it looks like ucc_geth is the only driver
that has a configuration that applies to all R(MII/GMII/TBI) interfaces
:/ I didn't even know about RTBI mode before looking at that driver and
it does look like it's not supported by that many devices... I'd be
happy to put that in phy.h but I think ucc_geth is going to be the sole
user :)

Thanks,

Maxime
Andrew Lunn Dec. 4, 2024, 3:41 p.m. UTC | #3
On Wed, Dec 04, 2024 at 09:22:32AM +0100, Maxime Chevallier wrote:
> Hello Andrew,
> 
> On Wed, 4 Dec 2024 03:15:52 +0100
> Andrew Lunn <andrew@lunn.ch> wrote:
> 
> > > +static bool phy_interface_mode_is_reduced(phy_interface_t interface)
> > > +{
> > > +	return phy_interface_mode_is_rgmii(interface) ||
> > > +	       interface == PHY_INTERFACE_MODE_RMII ||
> > > +	       interface == PHY_INTERFACE_MODE_RTBI;
> > > +}  
> > 
> > I wounder if this is useful anywhere else? Did you take a look around
> > other MAC drivers? Maybe this should be in phy.h?
> 
> Yes I did consider it but it looks like ucc_geth is the only driver
> that has a configuration that applies to all R(MII/GMII/TBI) interfaces

O.K. What is important is you considered it. Thanks. Too many
developers are focus on just their driver and don't think about other
drivers and code reuse.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Maxime Chevallier Dec. 5, 2024, 7:32 a.m. UTC | #4
On Wed, 4 Dec 2024 16:41:33 +0100
Andrew Lunn <andrew@lunn.ch> wrote:

> On Wed, Dec 04, 2024 at 09:22:32AM +0100, Maxime Chevallier wrote:
> > Hello Andrew,
> > 
> > On Wed, 4 Dec 2024 03:15:52 +0100
> > Andrew Lunn <andrew@lunn.ch> wrote:
> >   
> > > > +static bool phy_interface_mode_is_reduced(phy_interface_t interface)
> > > > +{
> > > > +	return phy_interface_mode_is_rgmii(interface) ||
> > > > +	       interface == PHY_INTERFACE_MODE_RMII ||
> > > > +	       interface == PHY_INTERFACE_MODE_RTBI;
> > > > +}    
> > > 
> > > I wounder if this is useful anywhere else? Did you take a look around
> > > other MAC drivers? Maybe this should be in phy.h?  
> > 
> > Yes I did consider it but it looks like ucc_geth is the only driver
> > that has a configuration that applies to all R(MII/GMII/TBI) interfaces  
> 
> O.K. What is important is you considered it. Thanks. Too many
> developers are focus on just their driver and don't think about other
> drivers and code reuse.
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Thanks Andrew. I should have indicated that in the commit log or in the
cover in the first place though, I'll make sure to do it next time.

Maxime
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index f6dd36dc03fe..57debcba124c 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -1258,6 +1258,13 @@  static int init_min_frame_len(u16 min_frame_length,
 	return 0;
 }
 
+static bool phy_interface_mode_is_reduced(phy_interface_t interface)
+{
+	return phy_interface_mode_is_rgmii(interface) ||
+	       interface == PHY_INTERFACE_MODE_RMII ||
+	       interface == PHY_INTERFACE_MODE_RTBI;
+}
+
 static int adjust_enet_interface(struct ucc_geth_private *ugeth)
 {
 	struct ucc_geth_info *ug_info;
@@ -1290,12 +1297,7 @@  static int adjust_enet_interface(struct ucc_geth_private *ugeth)
 	upsmr = in_be32(&uf_regs->upsmr);
 	upsmr &= ~(UCC_GETH_UPSMR_RPM | UCC_GETH_UPSMR_R10M |
 		   UCC_GETH_UPSMR_TBIM | UCC_GETH_UPSMR_RMM);
-	if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) ||
-	    (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) ||
-	    (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
-	    (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
-	    (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) ||
-	    (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
+	if (phy_interface_mode_is_reduced(ugeth->phy_interface)) {
 		if (ugeth->phy_interface != PHY_INTERFACE_MODE_RMII)
 			upsmr |= UCC_GETH_UPSMR_RPM;
 		switch (ugeth->max_speed) {
@@ -1594,9 +1596,7 @@  static void ugeth_link_up(struct ucc_geth_private *ugeth,
 				    ~(MACCFG2_INTERFACE_MODE_MASK)) |
 				    MACCFG2_INTERFACE_MODE_NIBBLE);
 			/* if reduced mode, re-set UPSMR.R10M */
-			if (interface == PHY_INTERFACE_MODE_RMII ||
-			    phy_interface_mode_is_rgmii(interface) ||
-			    interface == PHY_INTERFACE_MODE_RTBI) {
+			if (phy_interface_mode_is_reduced(interface)) {
 				if (speed == SPEED_10)
 					upsmr |= UCC_GETH_UPSMR_R10M;
 				else