From: Stefan Eichenberger <eichest@gmail.com>
To: trini@konsulko.com, ilias.apalodimas@linaro.org,
peng.fan@nxp.com, jh80.chung@samsung.com,
tanmay.kathpalia@altera.com, sbabic@nabladev.com,
festevam@gmail.com, uboot-imx@nxp.com,
francesco.dolcini@toradex.com, lukma@nabladev.com,
dlechner@baylibre.com, msp@baylibre.com,
stefan.eichenberger@toradex.com, Max.Merchel@ew.tq-group.com,
nora.schiffer@ew.tq-group.com, primoz.fiser@norik.com,
jbx6244@gmail.com, aford173@gmail.com,
cniedermaier@dh-electronics.com
Cc: u-boot@lists.u-boot-project.org
Subject: [PATCH v1 4/7] clk: imx: imx6ul: add the enet clock tree
Date: Fri, 20 Nov 2026 12:10:10 +0100 [thread overview]
Message-ID: <20261120111037.110741-5-eichest@gmail.com> (raw)
In-Reply-To: <20261120111037.110741-1-eichest@gmail.com>
From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
The FEC ipg/ahb/ptp/ref clocks and the regulator-fixed-clock PHY
supplies reference clock IDs the driver never registered, so none of
them can probe with the clock framework enabled. The CCM request
callback only checks the ID range, so clk_get_by_name() still succeeds,
but the following clk_set_rate() and clk_enable() fail to look up the
clock.
Model the ENET branch as the reference manual and Linux describe it:
- The PLL6 bypass muxes, as this driver already does for PLL3.
PLL_ENET comes out of reset with BYPASS set, and the PLLv3 enable
only powers the PLL up, so select pll6 at probe time. Otherwise the
reference dividers run from the 24 MHz oscillator.
- pll6_enet feeding the two ref dividers and their 125M gates.
pll6_enet was registered as a gate on PLL_ENET bit 13, which is the
ENET1 125M output enable, not a PLL gate.
- The ENET1/ENET2 reference clock selectors on the IOMUXC_GPR1
ENETn_CLK_SEL bits, choosing between the 125M gates and the
ENETn_TX_CLK pads. U-Boot has no GPR mux clock type, so use a plain
mux on the GPR1 register. The pad clocks are not modelled and map to
"dummy". Unlike the Linux GPR mux, this does not drive
ENETn_TX_CLK_DIR: the U-Boot mux can only update a contiguous bit
field, and CLK_SEL and TX_CLK_DIR are not adjacent.
- The PTP reference and the enet AHB gate.
The 125M gates and the selectors carry CLK_SET_RATE_PARENT, so the FEC
driver's clk_set_rate() on enet_clk_ref lands on the ref divider.
Default both ref dividers to 50 MHz as Linux does, so the clock is
already at the RMII rate when a consumer enables it before the FEC
sets the rate, such as a regulator-fixed-clock PHY supply that probes
before the FEC.
Co-developed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
---
drivers/clk/imx/clk-imx6ul.c | 76 +++++++++++++++++++++++++++++++++---
1 file changed, 71 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/imx/clk-imx6ul.c b/drivers/clk/imx/clk-imx6ul.c
index a73fb40b8ac..c65c029758b 100644
--- a/drivers/clk/imx/clk-imx6ul.c
+++ b/drivers/clk/imx/clk-imx6ul.c
@@ -34,8 +34,20 @@ static struct clk_ops imx6ul_clk_ops = {
.disable = ccf_clk_disable,
};
+static const struct clk_div_table clk_enet_ref_table[] = {
+ { .val = 0, .div = 20, },
+ { .val = 1, .div = 10, },
+ { .val = 2, .div = 5, },
+ { .val = 3, .div = 4, },
+ { }
+};
+
static const char *const pll_bypass_src_sels[] = { "osc", "dummy", };
static const char *const pll3_bypass_sels[] = { "pll3", "pll3_bypass_src", };
+static const char *const pll6_bypass_sels[] = { "pll6", "pll6_bypass_src", };
+/* The ENETn_TX_CLK pad clocks are not modelled, hence "dummy" */
+static const char *const enet1_ref_sels[] = { "enet1_ref_125m", "dummy", };
+static const char *const enet2_ref_sels[] = { "enet2_ref_125m", "dummy", };
static const char *const bch_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", };
static const char *const gpmi_sels[] = { "pll2_pfd2_396m", "pll2_pfd0_352m", };
@@ -103,8 +115,48 @@ static int imx6ul_clk_probe(struct udevice *dev)
clk_dm(IMX6UL_CLK_PLL6,
imx_clk_pllv3(dev, IMX_PLLV3_ENET, "pll6", "osc", base + 0xe0,
0x3));
+ clk_dm(IMX6UL_PLL6_BYPASS_SRC,
+ imx_clk_mux(dev, "pll6_bypass_src", base + 0xe0, 14, 1,
+ pll_bypass_src_sels,
+ ARRAY_SIZE(pll_bypass_src_sels)));
+ clk_dm(IMX6UL_PLL6_BYPASS,
+ imx_clk_mux_flags(dev, "pll6_bypass", base + 0xe0, 16, 1,
+ pll6_bypass_sels, ARRAY_SIZE(pll6_bypass_sels),
+ CLK_SET_RATE_PARENT));
clk_dm(IMX6UL_CLK_PLL6_ENET,
- imx_clk_gate(dev, "pll6_enet", "pll6", base + 0xe0, 13));
+ imx_clk_fixed_factor(dev, "pll6_enet", "pll6_bypass", 1, 1));
+ clk_dm(IMX6UL_CLK_ENET_REF,
+ clk_register_divider_table(dev, "enet1_ref", "pll6_enet", 0,
+ base + 0xe0, 0, 2, 0,
+ clk_enet_ref_table));
+ clk_dm(IMX6UL_CLK_ENET2_REF,
+ clk_register_divider_table(dev, "enet2_ref", "pll6_enet", 0,
+ base + 0xe0, 2, 2, 0,
+ clk_enet_ref_table));
+ clk_dm(IMX6UL_CLK_ENET1_REF_125M,
+ imx_clk_gate(dev, "enet1_ref_125m", "enet1_ref", base + 0xe0,
+ 13));
+ clk_dm(IMX6UL_CLK_ENET2_REF_125M,
+ imx_clk_gate(dev, "enet2_ref_125m", "enet2_ref", base + 0xe0,
+ 20));
+ /*
+ * IOMUXC_GPR1 ENETn_CLK_SEL: the ENET reference clock comes from
+ * the anatop ENET PLL (0) or from the ENETn_TX_CLK pad (1).
+ */
+ clk_dm(IMX6UL_CLK_ENET1_REF_SEL,
+ imx_clk_mux_flags(dev, "enet1_ref_sel",
+ (void *)IOMUXC_GPR_BASE_ADDR + 0x4, 13, 1,
+ enet1_ref_sels, ARRAY_SIZE(enet1_ref_sels),
+ CLK_SET_RATE_PARENT));
+ clk_dm(IMX6UL_CLK_ENET2_REF_SEL,
+ imx_clk_mux_flags(dev, "enet2_ref_sel",
+ (void *)IOMUXC_GPR_BASE_ADDR + 0x4, 14, 1,
+ enet2_ref_sels, ARRAY_SIZE(enet2_ref_sels),
+ CLK_SET_RATE_PARENT));
+ clk_dm(IMX6UL_CLK_ENET_PTP_REF,
+ imx_clk_fixed_factor(dev, "enet_ptp_ref", "pll6_enet", 1, 20));
+ clk_dm(IMX6UL_CLK_ENET_PTP,
+ imx_clk_gate(dev, "enet_ptp", "enet_ptp_ref", base + 0xe0, 21));
/* CCM clocks */
base = dev_read_addr_ptr(dev);
@@ -260,14 +312,17 @@ static int imx6ul_clk_probe(struct udevice *dev)
clk_dm(IMX6UL_CLK_PWM1,
imx_clk_gate2(dev, "pwm1", "perclk", base + 0x78, 16));
- if (is_mx6ull())
+ if (is_mx6ull()) {
clk_dm(IMX6UL_CLK_ENET,
imx_clk_gate2(dev, "enet", "ipg", base + 0x68, 12));
- else
+ clk_dm(IMX6UL_CLK_ENET_AHB,
+ imx_clk_gate2(dev, "enet_ahb", "ahb", base + 0x68, 12));
+ } else {
clk_dm(IMX6UL_CLK_ENET,
imx_clk_gate2(dev, "enet", "ipg", base + 0x74, 4));
- clk_dm(IMX6UL_CLK_ENET_REF,
- imx_clk_fixed_factor(dev, "enet_ref", "pll6_enet", 1, 1));
+ clk_dm(IMX6UL_CLK_ENET_AHB,
+ imx_clk_gate2(dev, "enet_ahb", "ahb", base + 0x74, 4));
+ }
struct clk *clk, *clk1;
@@ -276,6 +331,17 @@ static int imx6ul_clk_probe(struct udevice *dev)
clk_set_parent(clk, clk1);
+ /* Take PLL6 out of bypass, the ENET reference clocks need 500 MHz */
+ clk_get_by_id(IMX6UL_PLL6_BYPASS, &clk);
+ clk_get_by_id(IMX6UL_CLK_PLL6, &clk1);
+
+ clk_set_parent(clk, clk1);
+
+ clk_get_by_id(IMX6UL_CLK_ENET_REF, &clk);
+ clk_set_rate(clk, 50000000);
+ clk_get_by_id(IMX6UL_CLK_ENET2_REF, &clk);
+ clk_set_rate(clk, 50000000);
+
return 0;
}
--
2.56.1
next prev parent reply other threads:[~2026-11-20 13:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 11:10 [PATCH v1 0/7] colibri-imx6ull: fix the Ethernet PHY detection Stefan Eichenberger
2026-11-20 11:10 ` [PATCH v1 1/7] clk: imx: imx6ul: fix the enet clock gate register Stefan Eichenberger
2026-11-20 11:10 ` [PATCH v1 2/7] clk: imx: pllv3: wait for the ENET PLL to lock Stefan Eichenberger
2026-11-20 11:10 ` [PATCH v1 3/7] clk: imx: pllv3: do not touch the ENET output gate Stefan Eichenberger
2026-11-20 11:10 ` Stefan Eichenberger [this message]
2026-11-20 11:10 ` [PATCH v1 5/7] board: toradex: colibri-imx6ull: drop the static serial device Stefan Eichenberger
2026-11-20 11:10 ` [PATCH v1 6/7] arm: dts: imx6ull-colibri: migrate to OF_UPSTREAM Stefan Eichenberger
2026-11-20 11:10 ` [PATCH v1 7/7] board: toradex: colibri-imx6ull: enable the clock framework Stefan Eichenberger
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=20261120111037.110741-5-eichest@gmail.com \
--to=eichest@gmail.com \
--cc=Max.Merchel@ew.tq-group.com \
--cc=aford173@gmail.com \
--cc=cniedermaier@dh-electronics.com \
--cc=dlechner@baylibre.com \
--cc=festevam@gmail.com \
--cc=francesco.dolcini@toradex.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jbx6244@gmail.com \
--cc=jh80.chung@samsung.com \
--cc=lukma@nabladev.com \
--cc=msp@baylibre.com \
--cc=nora.schiffer@ew.tq-group.com \
--cc=peng.fan@nxp.com \
--cc=primoz.fiser@norik.com \
--cc=sbabic@nabladev.com \
--cc=stefan.eichenberger@toradex.com \
--cc=tanmay.kathpalia@altera.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
--cc=uboot-imx@nxp.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 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.