All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre TORGUE <alexandre.torgue@foss.st.com>
To: Marek Vasut <marex@denx.de>, <linux-arm-kernel@lists.infradead.org>
Cc: Christophe Roullier <christophe.roullier@foss.st.com>,
	Gabriel Fernandez <gabriel.fernandez@foss.st.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Stephen Boyd <swboyd@chromium.org>, <linux-clk@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH 0/7] ARM: dts: stm32: clk: Switch ETHRX clock parent from ETHCK_K to MCO2 on DHCOM SoM
Date: Mon, 12 Apr 2021 10:09:06 +0200	[thread overview]
Message-ID: <b81d6a69-713f-eda7-0837-d6e80d691c6a@foss.st.com> (raw)
In-Reply-To: <20210408185731.135511-1-marex@denx.de>

Hi Marek

On 4/8/21 8:57 PM, Marek Vasut wrote:
> The implementation of ETH_RX_CLK/ETH_REF_CLK handling on STM32MP1 currently
> does not permit selecting the RX clock input from SoC pad, the RX clock are
> hard-wired to eth_clk_fb. This cover letter describes multiple unsuccessful
> attempts at solving this problem and a proposed partial solution.
> 
> The problem is that in stm32mp151.dtsi, the "st,stm32mp1-dwmac" compatible
> ethernet requests mac-clk-rx = <&rcc ETHRX> as MAC RX clock, which per [1]
> page 576 maps to clk_rx_i signal. Upon closer inspection of clk-stm32mp1.c,
> the ETHRX clock 1) only models G_ETHRX gate, which represents ETHRXEN bit,
> and 2) sets ETHRX clock parent to ck_axi. Both are wrong for the following
> reasons:
> 1) ETHRX clock are composite clock of gate and two muxes, which ultimately
>     permit selecting ETHRX clock parent to be either eth_clk_fb or external
>     ETH_RX_CLK/ETH_REF_CLOCK clock from SoC pad. Because only the gate part
>     is modeled, the clock topology is wrong and it is not possible to select
>     the ETHRX clock parent using the clock framework at all.
> 2) ETHRX clock are supplied from a mux controlled by ETH_SEL[2] (from
>     SYSCFG), which is supplied from a mux controlled by ETH_REF_CLK_SEL
>     (from SYSCFG), which is supplied either by ETH_RX_CLK/ETH_REF_CLK
>     from pad OR internally from eth_clk_fb clock, which maps to ETHCK_K
>     clock. Hence, ETHRX can never be supplied by ck_axi.
> 
> Another unique feature of ETHRX clock muxes is that they are controlled
> via SYSCFG block instead of being part of the RCC block. This is a rather
> unfortunate design, as it creates dependency between RCC, SYSCFG and DWMAC.
> Currently, those clock muxes are configured in the dwmac4 driver through
> syscon interface to SYSCFG block, based on custom device tree properties --
> st,eth-clk-sel and st,eth-ref-clk-sel -- this is clearly not the correct
> approach.
> 
> First approach was to implement ETHRX clock including muxes in clk-stm32mp1.c.
> This means RCC clock driver, clk-stm32mp1.c, must obtain access to SYSCFG IP
> registers via some syscon_regmap_lookup_by_phandle() when registering ETHRX
> clock in RCC driver probe, so that it can read out SYSCFG register state to
> determine the current mux state, and later toggle the mux bits. The problem
> here is that the SYSCFG requires clock which are provided by RCC, so
> syscon_regmap_lookup_by_phandle() fails with EPROBE_DEFER because the clock
> are not available yet in RCC clock driver probe, so there is cyclic dependency
> between RCC and SYSCFG.
> 
> Similar approach would be to turn SYSCFG into simple-bus and implement
> separate SYSCFG clock sub-driver, which would register single clock mux with
> two parents -- ETHCK_K and ETH_RX_CLK -- and would only control the SYSCFG
> clock mux bits. The problem here is similar, for RCC driver to register the
> ETHRX clock, the ETHRX clock must have a parent clock, however the parent
> clock are not ready yet, because this new SYSCFG clock sub-driver requires
> SYSCFG register clock, which only become available once RCC finishes probing,
> so there again is a cyclic dependency between RCC and SYSCFG.
> 
> One possible solution could be to defer obtaining the SYSCFG regmap handle
> until later point, i.e. only once a register access to SYSCFG is required
> the first time. This could permit us to register the mux in the RCC driver
> including a mux which requires SYSCFG access via syscon, although this would
> likely still run into problems during probe, since the clock framework would
> call .get_parent() during mux registration and trigger the SYSCFG access.
> 
> All the above still only discusses the clock part of the problem. Even if
> the clock cyclic dependencies could be solved, it would be necessary to
> resolve legacy dwmac st,eth-clk-sel and st,eth-ref-clk-sel DT properties
> and avoid DT ABI break.

Thanks for those clear explanations and for this series. As discussed, 
this approach looks good to me as it doesn't break our current strategy 
for dwmac clock integration. I don't know if those cyclic redundancies 
will be fixed one day but we can have a look on dwmac DT properties (the 
gain to change them, the effort to keep the backward compatibility, code 
readability, ...).

Your DT patches looks good. I'll merge them soon.

regards
alex


> So in the end, this series takes a different approach and only partly solves
> the problem. This series splits ETHCK_K, so the ETHCK_K gate could be turned
> off and adds support for selecting ETHRX clock parent clock via DT. This then
> permits e.g. DHCOM to select MCO2 as ETHRX clock source and the clock tree is
> then correctly set up.
> 
> [1] STM32MP1 Reference Manual RM0436 Rev 3, Page 574,
>      Figure 83. Peripheral clock distribution for Ethernet
>      https://www.st.com/resource/en/reference_manual/dm00327659-stm32mp157-advanced-armbased-32bit-mpus-stmicroelectronics.pdf
> 
> Marek Vasut (7):
>    clk: stm32mp1: Split ETHCK_K into separate MUX and GATE clock
>    clk: stm32mp1: The dev is always NULL, replace it with np
>    clk: stm32mp1: Register clock with device_node pointer
>    clk: stm32mp1: Add parent_data to ETHRX clock
>    ARM: dts: stm32: Add alternate pinmux for ethernet0 pins
>    ARM: dts: stm32: Add alternate pinmux for mco2 pins
>    ARM: dts: stm32: Switch DWMAC RMII clock to MCO2 on DHCOM
> 
>   arch/arm/boot/dts/stm32mp15-pinctrl.dtsi     |  49 +++++++
>   arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi |  20 ++-
>   drivers/clk/clk-stm32mp1.c                   | 134 +++++++++++--------
>   3 files changed, 146 insertions(+), 57 deletions(-)
> 
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
> Cc: Christophe Roullier <christophe.roullier@foss.st.com>
> Cc: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Stephen Boyd <swboyd@chromium.org>
> Cc: linux-clk@vger.kernel.org
> Cc: linux-stm32@st-md-mailman.stormreply.com
> To: linux-arm-kernel@lists.infradead.org
> 



WARNING: multiple messages have this Message-ID (diff)
From: Alexandre TORGUE <alexandre.torgue@foss.st.com>
To: Marek Vasut <marex@denx.de>, <linux-arm-kernel@lists.infradead.org>
Cc: Christophe Roullier <christophe.roullier@foss.st.com>,
	Gabriel Fernandez <gabriel.fernandez@foss.st.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Stephen Boyd <swboyd@chromium.org>, <linux-clk@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH 0/7] ARM: dts: stm32: clk: Switch ETHRX clock parent from ETHCK_K to MCO2 on DHCOM SoM
Date: Mon, 12 Apr 2021 10:09:06 +0200	[thread overview]
Message-ID: <b81d6a69-713f-eda7-0837-d6e80d691c6a@foss.st.com> (raw)
In-Reply-To: <20210408185731.135511-1-marex@denx.de>

Hi Marek

On 4/8/21 8:57 PM, Marek Vasut wrote:
> The implementation of ETH_RX_CLK/ETH_REF_CLK handling on STM32MP1 currently
> does not permit selecting the RX clock input from SoC pad, the RX clock are
> hard-wired to eth_clk_fb. This cover letter describes multiple unsuccessful
> attempts at solving this problem and a proposed partial solution.
> 
> The problem is that in stm32mp151.dtsi, the "st,stm32mp1-dwmac" compatible
> ethernet requests mac-clk-rx = <&rcc ETHRX> as MAC RX clock, which per [1]
> page 576 maps to clk_rx_i signal. Upon closer inspection of clk-stm32mp1.c,
> the ETHRX clock 1) only models G_ETHRX gate, which represents ETHRXEN bit,
> and 2) sets ETHRX clock parent to ck_axi. Both are wrong for the following
> reasons:
> 1) ETHRX clock are composite clock of gate and two muxes, which ultimately
>     permit selecting ETHRX clock parent to be either eth_clk_fb or external
>     ETH_RX_CLK/ETH_REF_CLOCK clock from SoC pad. Because only the gate part
>     is modeled, the clock topology is wrong and it is not possible to select
>     the ETHRX clock parent using the clock framework at all.
> 2) ETHRX clock are supplied from a mux controlled by ETH_SEL[2] (from
>     SYSCFG), which is supplied from a mux controlled by ETH_REF_CLK_SEL
>     (from SYSCFG), which is supplied either by ETH_RX_CLK/ETH_REF_CLK
>     from pad OR internally from eth_clk_fb clock, which maps to ETHCK_K
>     clock. Hence, ETHRX can never be supplied by ck_axi.
> 
> Another unique feature of ETHRX clock muxes is that they are controlled
> via SYSCFG block instead of being part of the RCC block. This is a rather
> unfortunate design, as it creates dependency between RCC, SYSCFG and DWMAC.
> Currently, those clock muxes are configured in the dwmac4 driver through
> syscon interface to SYSCFG block, based on custom device tree properties --
> st,eth-clk-sel and st,eth-ref-clk-sel -- this is clearly not the correct
> approach.
> 
> First approach was to implement ETHRX clock including muxes in clk-stm32mp1.c.
> This means RCC clock driver, clk-stm32mp1.c, must obtain access to SYSCFG IP
> registers via some syscon_regmap_lookup_by_phandle() when registering ETHRX
> clock in RCC driver probe, so that it can read out SYSCFG register state to
> determine the current mux state, and later toggle the mux bits. The problem
> here is that the SYSCFG requires clock which are provided by RCC, so
> syscon_regmap_lookup_by_phandle() fails with EPROBE_DEFER because the clock
> are not available yet in RCC clock driver probe, so there is cyclic dependency
> between RCC and SYSCFG.
> 
> Similar approach would be to turn SYSCFG into simple-bus and implement
> separate SYSCFG clock sub-driver, which would register single clock mux with
> two parents -- ETHCK_K and ETH_RX_CLK -- and would only control the SYSCFG
> clock mux bits. The problem here is similar, for RCC driver to register the
> ETHRX clock, the ETHRX clock must have a parent clock, however the parent
> clock are not ready yet, because this new SYSCFG clock sub-driver requires
> SYSCFG register clock, which only become available once RCC finishes probing,
> so there again is a cyclic dependency between RCC and SYSCFG.
> 
> One possible solution could be to defer obtaining the SYSCFG regmap handle
> until later point, i.e. only once a register access to SYSCFG is required
> the first time. This could permit us to register the mux in the RCC driver
> including a mux which requires SYSCFG access via syscon, although this would
> likely still run into problems during probe, since the clock framework would
> call .get_parent() during mux registration and trigger the SYSCFG access.
> 
> All the above still only discusses the clock part of the problem. Even if
> the clock cyclic dependencies could be solved, it would be necessary to
> resolve legacy dwmac st,eth-clk-sel and st,eth-ref-clk-sel DT properties
> and avoid DT ABI break.

Thanks for those clear explanations and for this series. As discussed, 
this approach looks good to me as it doesn't break our current strategy 
for dwmac clock integration. I don't know if those cyclic redundancies 
will be fixed one day but we can have a look on dwmac DT properties (the 
gain to change them, the effort to keep the backward compatibility, code 
readability, ...).

Your DT patches looks good. I'll merge them soon.

regards
alex


> So in the end, this series takes a different approach and only partly solves
> the problem. This series splits ETHCK_K, so the ETHCK_K gate could be turned
> off and adds support for selecting ETHRX clock parent clock via DT. This then
> permits e.g. DHCOM to select MCO2 as ETHRX clock source and the clock tree is
> then correctly set up.
> 
> [1] STM32MP1 Reference Manual RM0436 Rev 3, Page 574,
>      Figure 83. Peripheral clock distribution for Ethernet
>      https://www.st.com/resource/en/reference_manual/dm00327659-stm32mp157-advanced-armbased-32bit-mpus-stmicroelectronics.pdf
> 
> Marek Vasut (7):
>    clk: stm32mp1: Split ETHCK_K into separate MUX and GATE clock
>    clk: stm32mp1: The dev is always NULL, replace it with np
>    clk: stm32mp1: Register clock with device_node pointer
>    clk: stm32mp1: Add parent_data to ETHRX clock
>    ARM: dts: stm32: Add alternate pinmux for ethernet0 pins
>    ARM: dts: stm32: Add alternate pinmux for mco2 pins
>    ARM: dts: stm32: Switch DWMAC RMII clock to MCO2 on DHCOM
> 
>   arch/arm/boot/dts/stm32mp15-pinctrl.dtsi     |  49 +++++++
>   arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi |  20 ++-
>   drivers/clk/clk-stm32mp1.c                   | 134 +++++++++++--------
>   3 files changed, 146 insertions(+), 57 deletions(-)
> 
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
> Cc: Christophe Roullier <christophe.roullier@foss.st.com>
> Cc: Gabriel Fernandez <gabriel.fernandez@foss.st.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Stephen Boyd <swboyd@chromium.org>
> Cc: linux-clk@vger.kernel.org
> Cc: linux-stm32@st-md-mailman.stormreply.com
> To: linux-arm-kernel@lists.infradead.org
> 



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2021-04-12  8:09 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 18:57 [PATCH 0/7] ARM: dts: stm32: clk: Switch ETHRX clock parent from ETHCK_K to MCO2 on DHCOM SoM Marek Vasut
2021-04-08 18:57 ` Marek Vasut
2021-04-08 18:57 ` [PATCH 1/7] clk: stm32mp1: Split ETHCK_K into separate MUX and GATE clock Marek Vasut
2021-04-08 18:57   ` Marek Vasut
2021-04-14 13:03   ` gabriel.fernandez
2021-04-14 13:03     ` gabriel.fernandez
2021-04-14 14:04     ` Marek Vasut
2021-04-14 14:04       ` Marek Vasut
2021-04-16  6:44       ` gabriel.fernandez
2021-04-16  6:44         ` gabriel.fernandez
2021-04-16 13:47         ` Marek Vasut
2021-04-16 13:47           ` Marek Vasut
2021-04-16 15:23           ` Alexandre TORGUE
2021-04-16 15:23             ` Alexandre TORGUE
2021-04-16 15:31             ` Marek Vasut
2021-04-16 15:31               ` Marek Vasut
2021-04-19  7:46               ` gabriel.fernandez
2021-04-19  7:46                 ` gabriel.fernandez
2022-01-18 22:11                 ` Marek Vasut
2022-01-18 22:11                   ` Marek Vasut
2021-04-08 18:57 ` [PATCH 2/7] clk: stm32mp1: The dev is always NULL, replace it with np Marek Vasut
2021-04-08 18:57   ` Marek Vasut
2021-04-16  6:44   ` gabriel.fernandez
2021-04-16  6:44     ` gabriel.fernandez
2021-04-16 13:39     ` Marek Vasut
2021-04-16 13:39       ` Marek Vasut
2021-04-16 14:39       ` Alexandre TORGUE
2021-04-16 14:39         ` Alexandre TORGUE
2021-04-16 14:54         ` Marek Vasut
2021-04-16 14:54           ` Marek Vasut
2021-04-16 15:01           ` Alexandre TORGUE
2021-04-16 15:01             ` Alexandre TORGUE
2021-04-08 18:57 ` [PATCH 3/7] clk: stm32mp1: Register clock with device_node pointer Marek Vasut
2021-04-08 18:57   ` Marek Vasut
2021-04-08 18:57 ` [PATCH 4/7] clk: stm32mp1: Add parent_data to ETHRX clock Marek Vasut
2021-04-08 18:57   ` Marek Vasut
2021-04-08 18:57 ` [PATCH 5/7] ARM: dts: stm32: Add alternate pinmux for ethernet0 pins Marek Vasut
2021-04-08 18:57   ` Marek Vasut
2021-04-08 18:57 ` [PATCH 6/7] ARM: dts: stm32: Add alternate pinmux for mco2 pins Marek Vasut
2021-04-08 18:57   ` Marek Vasut
2021-04-08 18:57 ` [PATCH 7/7] ARM: dts: stm32: Switch DWMAC RMII clock to MCO2 on DHCOM Marek Vasut
2021-04-08 18:57   ` Marek Vasut
2021-04-08 20:32 ` [PATCH 0/7] ARM: dts: stm32: clk: Switch ETHRX clock parent from ETHCK_K to MCO2 on DHCOM SoM Stephen Boyd
2021-04-08 20:32   ` Stephen Boyd
2021-04-12  8:09 ` Alexandre TORGUE [this message]
2021-04-12  8:09   ` Alexandre TORGUE
2021-04-12 18:44   ` Marek Vasut
2021-04-12 18:44     ` Marek Vasut
2021-04-13  7:48     ` Alexandre TORGUE
2021-04-13  7:48       ` Alexandre TORGUE
2021-04-13 12:05       ` Marek Vasut
2021-04-13 12:05         ` Marek Vasut

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=b81d6a69-713f-eda7-0837-d6e80d691c6a@foss.st.com \
    --to=alexandre.torgue@foss.st.com \
    --cc=christophe.roullier@foss.st.com \
    --cc=gabriel.fernandez@foss.st.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=marex@denx.de \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=swboyd@chromium.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.