mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Arun.Ramadoss@microchip.com
Cc: andrew@lunn.ch, davem@davemloft.net, hkallweit1@gmail.com,
	Yuiko.Oshino@microchip.com, linux@armlinux.org.uk,
	Woojung.Huh@microchip.com, pabeni@redhat.com,
	edumazet@google.com, f.fainelli@gmail.com, kuba@kernel.org,
	michal.kubiak@intel.com, kernel@pengutronix.de,
	linux-kernel@vger.kernel.org, florian.fainelli@broadcom.com,
	UNGLinuxDriver@microchip.com, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/1] net: phy: microchip: lan937x: add support for 100BaseTX PHY
Date: Fri, 5 Jul 2024 17:52:39 +0200	[thread overview]
Message-ID: <ZogWx59tzuH7t4PG@pengutronix.de> (raw)
In-Reply-To: <457179162ca6fd067b22b3b7733c60c2a17129a5.camel@microchip.com>

On Fri, Jul 05, 2024 at 03:15:36PM +0000, Arun.Ramadoss@microchip.com wrote:
> Hi Oleksij,
> On Fri, 2024-07-05 at 10:55 +0200, Oleksij Rempel wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > know the content is safe
> > 
> > Add support of 100BaseTX PHY build in to LAN9371 and LAN9372
> > switches.
> > 
> > Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> > Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
> > Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
> > ---
> > changes v2:
> > - move LAN937X_TX code from microchip_t1.c to microchip.c
> > - add Reviewed-by tags
> > ---
> >  drivers/net/phy/microchip.c | 75
> > +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 75 insertions(+)
> > 
> > diff --git a/drivers/net/phy/microchip.c
> > b/drivers/net/phy/microchip.c
> > index 0b88635f4fbca..b46d5d43e2585 100644
> > --- a/drivers/net/phy/microchip.c
> > +++ b/drivers/net/phy/microchip.c
> > @@ -12,6 +12,12 @@
> >  #include <linux/of.h>
> >  #include <dt-bindings/net/microchip-lan78xx.h>
> > 
> > +#define PHY_ID_LAN937X_TX                      0x0007c190
> 
> 0x0007c190 -> 0x0007C190

Why? 

I wrote a python script to gather stats in the drivers/net/phy:

Uppercase hex digits count:
E: 83
F: 216
C: 130
A: 148
B: 65
D: 74

Lowercase hex digits count:
b: 218
a: 337
d: 190
e: 238
f: 2560
c: 368

Sum of uppercase A-F: 716
Sum of lowercase a-f: 3911

> > +#define LAN937X_MODE_CTRL_STATUS_REG           0x11
> > +#define LAN937X_AUTOMDIX_EN                    BIT(7)
> > +#define LAN937X_MDI_MODE                       BIT(6)
> > +
> >  #define DRIVER_AUTHOR  "WOOJUNG HUH <woojung.huh@microchip.com>"
> >  #define DRIVER_DESC    "Microchip LAN88XX PHY driver"
> 
> nitpick:
> It can be updated to include "Microchip LAN88XX/LAN937X TX PHY driver"

ack

> > @@ -373,6 +379,66 @@ static void lan88xx_link_change_notify(struct
> > phy_device *phydev)
> >         }
> >  }
> > 
> 
> Adding function description will be good.

ack

> > +static int lan937x_tx_config_mdix(struct phy_device *phydev, u8
> > ctrl)
> > +{
> > +       u16 val;
> > +
> > +       switch (ctrl) {
> > +       case ETH_TP_MDI:
> > +               val = 0;
> > +               break;
> > +       case ETH_TP_MDI_X:
> > +               val = LAN937X_MDI_MODE;
> > +               break;
> > +       case ETH_TP_MDI_AUTO:
> > +               val = LAN937X_AUTOMDIX_EN;
> > +               break;
> > +       default:
> > +               return 0;
> > +       }
> > +
> > +       return phy_modify(phydev, LAN937X_MODE_CTRL_STATUS_REG,
> > +                         LAN937X_AUTOMDIX_EN | LAN937X_MDI_MODE,
> > val);
> > +}
> > +
> > +static int lan937x_tx_config_aneg(struct phy_device *phydev)
> > +{
> > +       int ret;
> > +
> > +       ret = genphy_config_aneg(phydev);
> > +       if (ret)
> 
> Is this if( ret < 0) ?

ack

> > +               return ret;
> > +
> > +       return lan937x_tx_config_mdix(phydev, phydev->mdix_ctrl);
> 
> why we need to pass argument phydev->mdix_ctrl, since already phydev is
> passed.

good point.

> Also IMO, this two function can be combined together if
> lan937x_tx_config_mdix is not used by other functions. 

I disagree here.

> > +{
> > +       PHY_ID_MATCH_MODEL(PHY_ID_LAN937X_TX),
> > +       .name           = "Microchip LAN937x TX",
> > +       .suspend        = genphy_suspend,
> > +       .resume         = genphy_resume,
> > +       .config_aneg    = lan937x_tx_config_aneg,
> > +       .read_status    = lan937x_tx_read_status,
> 
> Do we need to add genphy_suspend/resume, .features?

From PHY driver perspective - yes, otherwise to suspend or resume will be
called.
From internal PHY perspective - i do not know. Will the MAC disable PHY
automatically?

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2024-07-05 15:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-05  8:55 Oleksij Rempel
2024-07-05 15:15 ` Arun.Ramadoss
2024-07-05 15:52   ` Oleksij Rempel [this message]
2024-07-29  8:14 ` Russell King (Oracle)
2024-08-02  8:02   ` Oleksij Rempel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZogWx59tzuH7t4PG@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=Arun.Ramadoss@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=Woojung.Huh@microchip.com \
    --cc=Yuiko.Oshino@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=michal.kubiak@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®