* [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate
@ 2024-08-18 21:50 Jan Petrous (OSS)
2024-08-19 14:15 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jan Petrous (OSS) @ 2024-08-18 21:50 UTC (permalink / raw)
To: Jan Petrous (OSS), David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Alexandre Torgue, Jose Abreu, Maxime Coquelin, Vinod Koul,
Andrew Lunn, Heiner Kallweit, Russell King, Richard Cochran,
Giuseppe Cavallaro
Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, dl-S32
The helper rgmii_clock() implemented Russel's hint during stmmac
glue driver review:
---
We seem to have multiple cases of very similar logic in lots of stmmac
platform drivers, and I think it's about time we said no more to this.
So, what I think we should do is as follows:
add the following helper - either in stmmac, or more generically
(phylib? - in which case its name will need changing.)
static long stmmac_get_rgmii_clock(int speed)
{
switch (speed) {
case SPEED_10:
return 2500000;
case SPEED_100:
return 25000000;
case SPEED_1000:
return 125000000;
default:
return -ENVAL;
}
}
Then, this can become:
long tx_clk_rate;
...
tx_clk_rate = stmmac_get_rgmii_clock(speed);
if (tx_clk_rate < 0) {
dev_err(gmac->dev, "Unsupported/Invalid speed: %d\n", speed);
return;
}
ret = clk_set_rate(gmac->tx_clk, tx_clk_rate);
---
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
include/linux/phy.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 6b7d40d49129..bb797364d91c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -298,6 +298,27 @@ static inline const char *phy_modes(phy_interface_t interface)
}
}
+/**
+ * rgmi_clock - map link speed to the clock rate
+ * @speed: link speed value
+ *
+ * Description: maps RGMII supported link speeds
+ * into the clock rates.
+ */
+static inline long rgmii_clock(int speed)
+{
+ switch (speed) {
+ case SPEED_10:
+ return 2500000;
+ case SPEED_100:
+ return 25000000;
+ case SPEED_1000:
+ return 125000000;
+ default:
+ return -EINVAL;
+ }
+}
+
#define PHY_INIT_TIMEOUT 100000
#define PHY_FORCE_TIMEOUT 10
--
2.46.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate
2024-08-18 21:50 [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate Jan Petrous (OSS)
@ 2024-08-19 14:15 ` Simon Horman
2024-10-06 19:30 ` Jan Petrous
2024-08-19 15:49 ` Andrew Lunn
2024-08-19 15:57 ` Andrew Lunn
2 siblings, 1 reply; 7+ messages in thread
From: Simon Horman @ 2024-08-19 14:15 UTC (permalink / raw)
To: Jan Petrous (OSS)
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Alexandre Torgue,
Jose Abreu, Maxime Coquelin, Vinod Koul, Andrew Lunn,
Heiner Kallweit, Russell King, Richard Cochran,
Giuseppe Cavallaro, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, dl-S32
On Sun, Aug 18, 2024 at 09:50:46PM +0000, Jan Petrous (OSS) wrote:
> The helper rgmii_clock() implemented Russel's hint during stmmac
> glue driver review:
>
> ---
> We seem to have multiple cases of very similar logic in lots of stmmac
> platform drivers, and I think it's about time we said no more to this.
> So, what I think we should do is as follows:
>
> add the following helper - either in stmmac, or more generically
> (phylib? - in which case its name will need changing.)
>
> static long stmmac_get_rgmii_clock(int speed)
> {
> switch (speed) {
> case SPEED_10:
> return 2500000;
>
> case SPEED_100:
> return 25000000;
>
> case SPEED_1000:
> return 125000000;
>
> default:
> return -ENVAL;
> }
> }
>
> Then, this can become:
>
> long tx_clk_rate;
>
> ...
>
> tx_clk_rate = stmmac_get_rgmii_clock(speed);
> if (tx_clk_rate < 0) {
> dev_err(gmac->dev, "Unsupported/Invalid speed: %d\n", speed);
> return;
> }
>
> ret = clk_set_rate(gmac->tx_clk, tx_clk_rate);
> ---
>
> Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
> ---
> include/linux/phy.h | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 6b7d40d49129..bb797364d91c 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -298,6 +298,27 @@ static inline const char *phy_modes(phy_interface_t interface)
> }
> }
>
> +/**
> + * rgmi_clock - map link speed to the clock rate
nit: rgmii_clock
Flagged by ./scripts/kernel-doc -none
> + * @speed: link speed value
> + *
> + * Description: maps RGMII supported link speeds
> + * into the clock rates.
> + */
> +static inline long rgmii_clock(int speed)
> +{
> + switch (speed) {
> + case SPEED_10:
> + return 2500000;
> + case SPEED_100:
> + return 25000000;
> + case SPEED_1000:
> + return 125000000;
> + default:
> + return -EINVAL;
> + }
> +}
> +
> #define PHY_INIT_TIMEOUT 100000
> #define PHY_FORCE_TIMEOUT 10
>
> --
> 2.46.0
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate
2024-08-18 21:50 [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate Jan Petrous (OSS)
2024-08-19 14:15 ` Simon Horman
@ 2024-08-19 15:49 ` Andrew Lunn
2024-10-06 19:28 ` Jan Petrous
2024-08-19 15:57 ` Andrew Lunn
2 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2024-08-19 15:49 UTC (permalink / raw)
To: Jan Petrous (OSS)
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Alexandre Torgue,
Jose Abreu, Maxime Coquelin, Vinod Koul, Heiner Kallweit,
Russell King, Richard Cochran, Giuseppe Cavallaro,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, dl-S32
On Sun, Aug 18, 2024 at 09:50:46PM +0000, Jan Petrous (OSS) wrote:
> The helper rgmii_clock() implemented Russel's hint during stmmac
> glue driver review:
>
> ---
> We seem to have multiple cases of very similar logic in lots of stmmac
> platform drivers, and I think it's about time we said no more to this.
> So, what I think we should do is as follows:
>
> add the following helper - either in stmmac, or more generically
> (phylib? - in which case its name will need changing.)
>
> static long stmmac_get_rgmii_clock(int speed)
> {
> switch (speed) {
> case SPEED_10:
> return 2500000;
>
> case SPEED_100:
> return 25000000;
>
> case SPEED_1000:
> return 125000000;
>
> default:
> return -ENVAL;
> }
> }
>
> Then, this can become:
>
> long tx_clk_rate;
>
> ...
>
> tx_clk_rate = stmmac_get_rgmii_clock(speed);
> if (tx_clk_rate < 0) {
> dev_err(gmac->dev, "Unsupported/Invalid speed: %d\n", speed);
> return;
> }
>
> ret = clk_set_rate(gmac->tx_clk, tx_clk_rate);
> ---
>
> Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
This Signed-off-by: needs to be above the first ---, otherwise it gets
discard.
When you repost, please do try to get threading correct.
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate
2024-08-18 21:50 [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate Jan Petrous (OSS)
2024-08-19 14:15 ` Simon Horman
2024-08-19 15:49 ` Andrew Lunn
@ 2024-08-19 15:57 ` Andrew Lunn
2024-10-06 19:37 ` Jan Petrous
2 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2024-08-19 15:57 UTC (permalink / raw)
To: Jan Petrous (OSS)
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Alexandre Torgue,
Jose Abreu, Maxime Coquelin, Vinod Koul, Heiner Kallweit,
Russell King, Richard Cochran, Giuseppe Cavallaro,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, dl-S32
On Sun, Aug 18, 2024 at 09:50:46PM +0000, Jan Petrous (OSS) wrote:
> The helper rgmii_clock() implemented Russel's hint during stmmac
> glue driver review:
>
> ---
> We seem to have multiple cases of very similar logic in lots of stmmac
> platform drivers, and I think it's about time we said no more to this.
> So, what I think we should do is as follows:
>
> add the following helper - either in stmmac, or more generically
> (phylib? - in which case its name will need changing.)
As Russell pointed out, this code appears a few times in the stmmac
driver. Please include patches changing the other instances to use
this helper.
It also looks like macb, and maybe xgene_enet_hw.c could use it as
well.
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate
2024-08-19 15:49 ` Andrew Lunn
@ 2024-10-06 19:28 ` Jan Petrous
0 siblings, 0 replies; 7+ messages in thread
From: Jan Petrous @ 2024-10-06 19:28 UTC (permalink / raw)
To: Andrew Lunn
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Alexandre Torgue,
Jose Abreu, Maxime Coquelin, Vinod Koul, Heiner Kallweit,
Russell King, Richard Cochran, Giuseppe Cavallaro,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, dl-S32
On Mon, Aug 19, 2024 at 05:49:58PM +0200, Andrew Lunn wrote:
> On Sun, Aug 18, 2024 at 09:50:46PM +0000, Jan Petrous (OSS) wrote:
> > The helper rgmii_clock() implemented Russel's hint during stmmac
> > glue driver review:
> >
> > ---
> > We seem to have multiple cases of very similar logic in lots of stmmac
> > platform drivers, and I think it's about time we said no more to this.
> > So, what I think we should do is as follows:
> >
> > add the following helper - either in stmmac, or more generically
> > (phylib? - in which case its name will need changing.)
> >
> > static long stmmac_get_rgmii_clock(int speed)
> > {
> > switch (speed) {
> > case SPEED_10:
> > return 2500000;
> >
> > case SPEED_100:
> > return 25000000;
> >
> > case SPEED_1000:
> > return 125000000;
> >
> > default:
> > return -ENVAL;
> > }
> > }
> >
> > Then, this can become:
> >
> > long tx_clk_rate;
> >
> > ...
> >
> > tx_clk_rate = stmmac_get_rgmii_clock(speed);
> > if (tx_clk_rate < 0) {
> > dev_err(gmac->dev, "Unsupported/Invalid speed: %d\n", speed);
> > return;
> > }
> >
> > ret = clk_set_rate(gmac->tx_clk, tx_clk_rate);
> > ---
> >
> > Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
>
> This Signed-off-by: needs to be above the first ---, otherwise it gets
> discard.
>
I see, it is used as delimiter, my fault.
I will change formating for v3.
> When you repost, please do try to get threading correct.
>
Yeh, I already got the same feedback from Krzysztof.
I'm switching to b4/lei/mutt for v3 what I hope fixed
the threading issue.
BR.
/Jan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate
2024-08-19 14:15 ` Simon Horman
@ 2024-10-06 19:30 ` Jan Petrous
0 siblings, 0 replies; 7+ messages in thread
From: Jan Petrous @ 2024-10-06 19:30 UTC (permalink / raw)
To: Simon Horman
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Alexandre Torgue,
Jose Abreu, Maxime Coquelin, Vinod Koul, Andrew Lunn,
Heiner Kallweit, Russell King, Richard Cochran,
Giuseppe Cavallaro, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, dl-S32
On Mon, Aug 19, 2024 at 03:15:41PM +0100, Simon Horman wrote:
> On Sun, Aug 18, 2024 at 09:50:46PM +0000, Jan Petrous (OSS) wrote:
> > The helper rgmii_clock() implemented Russel's hint during stmmac
> > glue driver review:
> >
> > ---
> > We seem to have multiple cases of very similar logic in lots of stmmac
> > platform drivers, and I think it's about time we said no more to this.
> > So, what I think we should do is as follows:
> >
> > add the following helper - either in stmmac, or more generically
> > (phylib? - in which case its name will need changing.)
> >
> > static long stmmac_get_rgmii_clock(int speed)
> > {
> > switch (speed) {
> > case SPEED_10:
> > return 2500000;
> >
> > case SPEED_100:
> > return 25000000;
> >
> > case SPEED_1000:
> > return 125000000;
> >
> > default:
> > return -ENVAL;
> > }
> > }
> >
> > Then, this can become:
> >
> > long tx_clk_rate;
> >
> > ...
> >
> > tx_clk_rate = stmmac_get_rgmii_clock(speed);
> > if (tx_clk_rate < 0) {
> > dev_err(gmac->dev, "Unsupported/Invalid speed: %d\n", speed);
> > return;
> > }
> >
> > ret = clk_set_rate(gmac->tx_clk, tx_clk_rate);
> > ---
> >
> > Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
> > ---
> > include/linux/phy.h | 21 +++++++++++++++++++++
> > 1 file changed, 21 insertions(+)
> >
> > diff --git a/include/linux/phy.h b/include/linux/phy.h
> > index 6b7d40d49129..bb797364d91c 100644
> > --- a/include/linux/phy.h
> > +++ b/include/linux/phy.h
> > @@ -298,6 +298,27 @@ static inline const char *phy_modes(phy_interface_t interface)
> > }
> > }
> >
> > +/**
> > + * rgmi_clock - map link speed to the clock rate
>
> nit: rgmii_clock
>
> Flagged by ./scripts/kernel-doc -none
>
Thanks. Fixed in v3.
BR.
/Jan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate
2024-08-19 15:57 ` Andrew Lunn
@ 2024-10-06 19:37 ` Jan Petrous
0 siblings, 0 replies; 7+ messages in thread
From: Jan Petrous @ 2024-10-06 19:37 UTC (permalink / raw)
To: Andrew Lunn
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Alexandre Torgue,
Jose Abreu, Maxime Coquelin, Vinod Koul, Heiner Kallweit,
Russell King, Richard Cochran, Giuseppe Cavallaro,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, dl-S32
On Mon, Aug 19, 2024 at 05:57:11PM +0200, Andrew Lunn wrote:
> On Sun, Aug 18, 2024 at 09:50:46PM +0000, Jan Petrous (OSS) wrote:
> > The helper rgmii_clock() implemented Russel's hint during stmmac
> > glue driver review:
> >
> > ---
> > We seem to have multiple cases of very similar logic in lots of stmmac
> > platform drivers, and I think it's about time we said no more to this.
> > So, what I think we should do is as follows:
> >
> > add the following helper - either in stmmac, or more generically
> > (phylib? - in which case its name will need changing.)
>
> As Russell pointed out, this code appears a few times in the stmmac
> driver. Please include patches changing the other instances to use
> this helper.
>
> It also looks like macb, and maybe xgene_enet_hw.c could use it as
> well.
>
OK, for v3 added patches for the following possible users:
dwmac-sti, xgene_enet, macb, dwmac-starfive, dwmac-rk,
dwmac-intel-plat, dwmac-imx, dwmac-dwc-qos-eth.
BR.
/Jan
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-10-06 19:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-18 21:50 [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate Jan Petrous (OSS)
2024-08-19 14:15 ` Simon Horman
2024-10-06 19:30 ` Jan Petrous
2024-08-19 15:49 ` Andrew Lunn
2024-10-06 19:28 ` Jan Petrous
2024-08-19 15:57 ` Andrew Lunn
2024-10-06 19:37 ` Jan Petrous
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).