From: Simon Horman <horms@kernel.org>
To: "Jan Petrous (OSS)" <jan.petrous@oss.nxp.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Vinod Koul <vkoul@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Richard Cochran <richardcochran@gmail.com>,
Giuseppe Cavallaro <peppe.cavallaro@st.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-stm32@st-md-mailman.stormreply.com"
<linux-stm32@st-md-mailman.stormreply.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
dl-S32 <S32@nxp.com>
Subject: Re: [PATCH v2 4/7] net: phy: add helper for mapping RGMII link speed to clock rate
Date: Mon, 19 Aug 2024 15:15:41 +0100 [thread overview]
Message-ID: <20240819141541.GE11472@kernel.org> (raw)
In-Reply-To: <AM9PR04MB85062E3A66BA92EF8D996513E2832@AM9PR04MB8506.eurprd04.prod.outlook.com>
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
>
>
next prev parent reply other threads:[~2024-08-19 14:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20240819141541.GE11472@kernel.org \
--to=horms@kernel.org \
--cc=S32@nxp.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=jan.petrous@oss.nxp.com \
--cc=joabreu@synopsys.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=peppe.cavallaro@st.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=vkoul@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.