From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
Chaoyi Chen <kernel@airkyi.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jonas Karlman <jonas@kwiboo.se>,
David Wu <david.wu@rock-chips.com>,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org
Subject: Re: [PATCH net-next v3] net: ethernet: stmmac: dwmac-rk: Make the clk_phy could be used for external phy
Date: Tue, 26 Aug 2025 17:41:30 +0800 [thread overview]
Message-ID: <52c7a4d7-3b78-4f85-a51b-e7bf950983ab@rock-chips.com> (raw)
In-Reply-To: <aK1_uaBpnix4n4eS@shell.armlinux.org.uk>
On 8/26/2025 5:34 PM, Russell King (Oracle) wrote:
> On Tue, Aug 26, 2025 at 05:29:04PM +0800, Chaoyi Chen wrote:
>> On 8/26/2025 5:25 PM, Russell King (Oracle) wrote:
>>
>>> On Tue, Aug 26, 2025 at 04:08:40PM +0800, Chaoyi Chen wrote:
>>>> Hi Russell,
>>>>
>>>> On 8/25/2025 9:37 PM, Russell King (Oracle) wrote:
>>>>> On Mon, Aug 25, 2025 at 12:53:37PM +0200, Marek Szyprowski wrote:
>>>>>> On 25.08.2025 11:57, Chaoyi Chen wrote:
>>>>>>> On 8/25/2025 3:23 PM, Marek Szyprowski wrote:
>>>>>>>> On 15.08.2025 04:35, Chaoyi Chen wrote:
>>>>>>>>> From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
>>>>>>>>>
>>>>>>>>> For external phy, clk_phy should be optional, and some external phy
>>>>>>>>> need the clock input from clk_phy. This patch adds support for setting
>>>>>>>>> clk_phy for external phy.
>>>>>>>>>
>>>>>>>>> Signed-off-by: David Wu <david.wu@rock-chips.com>
>>>>>>>>> Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>> Changes in v3:
>>>>>>>>> - Link to V2:
>>>>>>>>> https://lore.kernel.org/netdev/20250812012127.197-1-kernel@airkyi.com/
>>>>>>>>> - Rebase to net-next/main
>>>>>>>>>
>>>>>>>>> Changes in v2:
>>>>>>>>> - Link to V1:
>>>>>>>>> https://lore.kernel.org/netdev/20250806011405.115-1-kernel@airkyi.com/
>>>>>>>>> - Remove get clock frequency from DT prop
>>>>>>>>>
>>>>>>>>> drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 11 +++++++----
>>>>>>>>> 1 file changed, 7 insertions(+), 4 deletions(-)
>>>>>>>>>
>>>>>>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>>>>>>>>> b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>>>>>>>>> index ac8288301994..5d921e62c2f5 100644
>>>>>>>>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>>>>>>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>>>>>>>>> @@ -1412,12 +1412,15 @@ static int rk_gmac_clk_init(struct
>>>>>>>>> plat_stmmacenet_data *plat)
>>>>>>>>> clk_set_rate(plat->stmmac_clk, 50000000);
>>>>>>>>> }
>>>>>>>>> - if (plat->phy_node && bsp_priv->integrated_phy) {
>>>>>>>>> + if (plat->phy_node) {
>>>>>>>>> bsp_priv->clk_phy = of_clk_get(plat->phy_node, 0);
>>>>>>>>> ret = PTR_ERR_OR_ZERO(bsp_priv->clk_phy);
>>>>>>>>> - if (ret)
>>>>>>>>> - return dev_err_probe(dev, ret, "Cannot get PHY clock\n");
>>>>>>>>> - clk_set_rate(bsp_priv->clk_phy, 50000000);
>>>>>>>>> + /* If it is not integrated_phy, clk_phy is optional */
>>>>>>>>> + if (bsp_priv->integrated_phy) {
>>>>>>>>> + if (ret)
>>>>>>>>> + return dev_err_probe(dev, ret, "Cannot get PHY
>>>>>>>>> clock\n");
>>>>>>>>> + clk_set_rate(bsp_priv->clk_phy, 50000000);
>>>>>>>>> + }
>>>>>>> I think we should set bsp_priv->clk_phy to NULL here if we failed to
>>>>>>> get the clock.
>>>>>>>
>>>>>>> Could you try this on your board? Thank you.
>>>>>> Right, the following change also fixes this issue:
>>>>>>
>>>>>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>>>>>> b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>>>>>> index 9fc41207cc45..2d19d48be01f 100644
>>>>>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>>>>>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
>>>>>> @@ -1415,6 +1415,8 @@ static int rk_gmac_clk_init(struct
>>>>>> plat_stmmacenet_data *plat)
>>>>>> if (plat->phy_node) {
>>>>>> bsp_priv->clk_phy = of_clk_get(plat->phy_node, 0);
>>>>>> ret = PTR_ERR_OR_ZERO(bsp_priv->clk_phy);
>>>>>> + if (ret)
>>>>>> + bsp_priv->clk_phy = NULL;
>>>>> Or just:
>>>>>
>>>>> clk = of_clk_get(plat->phy_node, 0);
>>>>> if (clk == ERR_PTR(-EPROBE_DEFER))
>>>> Do we actually need this? Maybe other devm_clk_get() before it would fail in advance.
>>> Is it the same clock as devm_clk_get()? If it is, what's the point of
>>> getting it a second time. If it isn't, then it could be a different
>>> clock which may be yet to probe.
>> It's not the same clock, but it should be use the same clock controller driver, which is the CRU on the Rockchip platform.
> Will it always be the same clock controller, including into the future
> Rockchip devices?
Hmm, I'm not sure if it will be the same for the devices that come later. I'll try adding those checks.
prev parent reply other threads:[~2025-08-26 10:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 2:35 Chaoyi Chen
2025-08-19 14:10 ` patchwork-bot+netdevbpf
[not found] ` <CGME20250825072312eucas1p2d4751199c0ea069c7938218be60e5e93@eucas1p2.samsung.com>
2025-08-25 7:23 ` Marek Szyprowski
2025-08-25 9:57 ` Chaoyi Chen
2025-08-25 10:53 ` Marek Szyprowski
2025-08-25 13:37 ` Russell King (Oracle)
2025-08-26 8:08 ` Chaoyi Chen
2025-08-26 9:25 ` Russell King (Oracle)
2025-08-26 9:29 ` Chaoyi Chen
2025-08-26 9:34 ` Russell King (Oracle)
2025-08-26 9:41 ` Chaoyi Chen [this message]
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=52c7a4d7-3b78-4f85-a51b-e7bf950983ab@rock-chips.com \
--to=chaoyi.chen@rock-chips.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=david.wu@rock-chips.com \
--cc=edumazet@google.com \
--cc=jonas@kwiboo.se \
--cc=kernel@airkyi.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=m.szyprowski@samsung.com \
--cc=mcoquelin.stm32@gmail.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®