All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] ARM: dts: stm32: clk: Switch ETHRX clock parent from ETHCK_K to MCO2 on DHCOM SoM
@ 2021-04-08 18:57 ` Marek Vasut
  0 siblings, 0 replies; 52+ messages in thread
From: Marek Vasut @ 2021-04-08 18:57 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Marek Vasut, Alexandre Torgue, Christophe Roullier,
	Gabriel Fernandez, Patrice Chotard, Patrick Delaunay,
	Stephen Boyd, linux-clk, linux-stm32

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.

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

-- 
2.30.2


^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2022-01-18 22:12 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.