diff mbox series

[RFC,3/3] net: renesas: rswitch: Pass host parameters to phydev

Message ID 20221019085052.933385-4-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: phy: marvell10g: Add host speed setting by an ethernet driver | expand

Checks

Context Check Description
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Yoshihiro Shimoda Oct. 19, 2022, 8:50 a.m. UTC
Use of_phy_connect_with_host_params() to pass host parameters to
phydev. Otherwise, connected PHY cannot work correctly.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/net/ethernet/renesas/rswitch.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Yoshihiro Shimoda Oct. 20, 2022, 12:40 a.m. UTC | #1
Hi Marek,

> From: Marek Behún, Sent: Wednesday, October 19, 2022 7:41 PM
> 
> On Wed, 19 Oct 2022 17:50:52 +0900
> Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> wrote:
> 
> > Use of_phy_connect_with_host_params() to pass host parameters to
> > phydev. Otherwise, connected PHY cannot work correctly.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/rswitch.c | 13 +++++++++++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
> > index c604331bfd88..bb2f1e667210 100644
> > --- a/drivers/net/ethernet/renesas/rswitch.c
> > +++ b/drivers/net/ethernet/renesas/rswitch.c
> > @@ -16,6 +16,7 @@
> >  #include <linux/of_irq.h>
> >  #include <linux/of_mdio.h>
> >  #include <linux/of_net.h>
> > +#include <linux/phy.h>
> >  #include <linux/phy/phy.h>
> >  #include <linux/pm_runtime.h>
> >  #include <linux/slab.h>
> > @@ -1234,11 +1235,19 @@ static void rswitch_phy_remove_link_mode(struct rswitch_device *rdev,
> >
> >  static int rswitch_phy_init(struct rswitch_device *rdev, struct device_node *phy)
> >  {
> > +	DECLARE_PHY_INTERFACE_MASK(host_interfaces);
> >  	struct phy_device *phydev;
> >  	int err = 0;
> >
> > -	phydev = of_phy_connect(rdev->ndev, phy, rswitch_adjust_link, 0,
> > -				rdev->etha->phy_interface);
> > +	phy_interface_zero(host_interfaces);
> > +	if (rdev->etha->phy_interface == PHY_INTERFACE_MODE_SGMII)
> > +		__set_bit(PHY_INTERFACE_MODE_SGMII, host_interfaces);
> > +
> > +	phydev = of_phy_connect_with_host_params(rdev->ndev, phy,
> > +						 rswitch_adjust_link, 0,
> > +						 rdev->etha->phy_interface,
> > +						 host_interfaces,
> > +						 rdev->etha->speed);
> >  	if (!phydev) {
> >  		err = -ENOENT;
> >  		goto out;
> 
> NAK. There already is API for doing this: phylink. Adding new, and so
> much specific function for this is a waste. Just convert the rswitch
> driver to phylink.
> 
> Please look at the documentation at
>   Documentation/networking/sfp-phylink.rst

Thank you for your comments! I'll try to convert the rswitch driver to phylink.

Best regards,
Yoshihiro Shimoda

> Marek
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index c604331bfd88..bb2f1e667210 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -16,6 +16,7 @@ 
 #include <linux/of_irq.h>
 #include <linux/of_mdio.h>
 #include <linux/of_net.h>
+#include <linux/phy.h>
 #include <linux/phy/phy.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
@@ -1234,11 +1235,19 @@  static void rswitch_phy_remove_link_mode(struct rswitch_device *rdev,
 
 static int rswitch_phy_init(struct rswitch_device *rdev, struct device_node *phy)
 {
+	DECLARE_PHY_INTERFACE_MASK(host_interfaces);
 	struct phy_device *phydev;
 	int err = 0;
 
-	phydev = of_phy_connect(rdev->ndev, phy, rswitch_adjust_link, 0,
-				rdev->etha->phy_interface);
+	phy_interface_zero(host_interfaces);
+	if (rdev->etha->phy_interface == PHY_INTERFACE_MODE_SGMII)
+		__set_bit(PHY_INTERFACE_MODE_SGMII, host_interfaces);
+
+	phydev = of_phy_connect_with_host_params(rdev->ndev, phy,
+						 rswitch_adjust_link, 0,
+						 rdev->etha->phy_interface,
+						 host_interfaces,
+						 rdev->etha->speed);
 	if (!phydev) {
 		err = -ENOENT;
 		goto out;