devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"krzysztof.kozlowski+dt@linaro.org" 
	<krzysztof.kozlowski+dt@linaro.org>,
	"geert+renesas@glider.be" <geert+renesas@glider.be>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH 3/5] net: ethernet: renesas: Add Ethernet Switch driver
Date: Wed, 14 Sep 2022 14:03:06 +0200	[thread overview]
Message-ID: <YyHC+r3uP7s15kny@lunn.ch> (raw)
In-Reply-To: <TYBPR01MB5341F0C51EB2EBEF5A7107E7D8469@TYBPR01MB5341.jpnprd01.prod.outlook.com>

> > > +static void rswitch_adjust_link(struct net_device *ndev)
> > > +{
> > > +	struct rswitch_device *rdev = netdev_priv(ndev);
> > > +	struct phy_device *phydev = ndev->phydev;
> > > +
> > > +	if (phydev->link != rdev->etha->link) {
> > > +		phy_print_status(phydev);
> > > +		rdev->etha->link = phydev->link;
> > > +	}
> > 
> > Given that the SERDES supports 100 and 1G, it seems odd you don't need
> > to do anything here.
> 
> Indeed. However, unfortunately, the current hardware cannot change the speed at runtime...
> So, I'll add such comments here.

Then you need to tell phylib about this. MAC drivers with limitations
often call phy_set_max_speed() to remove higher speeds which the PHY
can support, but the MAC cannot. You need to go further and remove
lower speeds as well. The autoneg in the PHY should then only work for
the speeds you actually support.

> > > +static int rswitch_serdes_common_setting(void __iomem *addr0,
> > > +					 enum rswitch_serdes_mode mode)
> > > +{
> > > +	switch (mode) {
> > > +	case SGMII:
> > > +		rswitch_serdes_write32(addr0, 0x0244, 0x180, 0x97);
> > > +		rswitch_serdes_write32(addr0, 0x01d0, 0x180, 0x60);
> > > +		rswitch_serdes_write32(addr0, 0x01d8, 0x180, 0x2200);
> > > +		rswitch_serdes_write32(addr0, 0x01d4, 0x180, 0);
> > > +		rswitch_serdes_write32(addr0, 0x01e0, 0x180, 0x3d);
> > 
> > Please add #defines for all these magic numbers.
> 
> I should have added comments before though, the datasheet also describes
> such magic numbers like below...
> Step S.4.1	bank 0x180	address = 0x0244		data = 0x00000097
> Step S.4.2	bank 0x180	address = 0x01d0		data = 0x00000060
> ...
> 
> So, perhaps we can define like the followings:
> #define	SERDES_BANK_180		0x180
> 
> #define	SERDES_STEP_S_4_1_ADDR	0x0244
> #define	SERDES_STEP_S_4_1_DATA	0x00000097

Not really any better. Better to comment that you have no idea what
any of this does, it is all black magic.

    Andrew

  reply	other threads:[~2022-09-14 12:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09 13:26 [PATCH 0/5] treewide: Add R-Car S4-8 Ethernet Switch support Yoshihiro Shimoda
2022-09-09 13:26 ` [PATCH 1/5] clk: renesas: r8a779f0: Add Ethernet Switch clocks Yoshihiro Shimoda
2022-09-09 13:26 ` [PATCH 2/5] dt-bindings: net: renesas: Document Renesas Ethernet Switch Yoshihiro Shimoda
2022-09-12 22:32   ` Andrew Lunn
2022-09-13  5:56     ` Yoshihiro Shimoda
2022-09-13 13:02   ` Rob Herring
2022-09-14  5:01     ` Yoshihiro Shimoda
2022-09-09 13:26 ` [PATCH 3/5] net: ethernet: renesas: Add Ethernet Switch driver Yoshihiro Shimoda
2022-09-09 17:26   ` kernel test robot
2022-09-12 12:41     ` Yoshihiro Shimoda
2022-09-12 22:33   ` Andrew Lunn
2022-09-14  4:48     ` Yoshihiro Shimoda
2022-09-12 23:14   ` Andrew Lunn
2022-09-14  4:38     ` Yoshihiro Shimoda
2022-09-14 12:03       ` Andrew Lunn [this message]
2022-09-09 13:26 ` [PATCH 4/5] arm64: dts: renesas: r8a779f0: Add Ethernet Switch node Yoshihiro Shimoda
2022-09-09 13:26 ` [PATCH 5/5] arm64: dts: renesas: r8a779f0: spider: Enable Ethernet Switch Yoshihiro Shimoda
2022-09-13  0:16   ` Andrew Lunn
2022-09-14  4:47     ` Yoshihiro Shimoda
2022-09-14 12:14       ` Andrew Lunn
2022-09-21  7:54         ` Yoshihiro Shimoda

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=YyHC+r3uP7s15kny@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=geert+renesas@glider.be \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh+dt@kernel.org \
    --cc=yoshihiro.shimoda.uh@renesas.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;
as well as URLs for NNTP newsgroup(s).