Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: imx6ul: add ethernet refclock mux support

Add ethernet refclock mux support and set it to internal clock by
default. This configuration will not affect existing boards.

clock tree before this patch:
fec1 <- enet1_ref_125m (gate) <- enet1_ref (divider) <-,
|- pll6_enet
fec2 <- enet2_ref_125m (gate) <- enet2_ref (divider) <-´

after this patch:
fec1 <- enet1_ref_sel(mux) <- enet1_ref_125m (gate) <- ...
`--<> enet1_ref_pad |- pll6_enet
fec2 <- enet2_ref_sel(mux) <- enet2_ref_125m (gate) <- ...
`--<> enet2_ref_pad

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Lee Jones <lee@kernel.org>
Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Link: https://lore.kernel.org/r/20230131084642.709385-17-o.rempel@pengutronix.de

authored by

Oleksij Rempel and committed by
Abel Vesa
4e197ee8 5f82bfce

+35 -3
+26
drivers/clk/imx/clk-imx6ul.c
··· 10 10 #include <linux/err.h> 11 11 #include <linux/init.h> 12 12 #include <linux/io.h> 13 + #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h> 13 14 #include <linux/of.h> 14 15 #include <linux/of_address.h> 15 16 #include <linux/of_irq.h> ··· 94 93 { .val = 3, .div = 4, }, 95 94 { } 96 95 }; 96 + 97 + static const char * enet1_ref_sels[] = { "enet1_ref_125m", "enet1_ref_pad", }; 98 + static const u32 enet1_ref_sels_table[] = { IMX6UL_GPR1_ENET1_TX_CLK_DIR, 99 + IMX6UL_GPR1_ENET1_CLK_SEL }; 100 + static const u32 enet1_ref_sels_table_mask = IMX6UL_GPR1_ENET1_TX_CLK_DIR | 101 + IMX6UL_GPR1_ENET1_CLK_SEL; 102 + static const char * enet2_ref_sels[] = { "enet2_ref_125m", "enet2_ref_pad", }; 103 + static const u32 enet2_ref_sels_table[] = { IMX6UL_GPR1_ENET2_TX_CLK_DIR, 104 + IMX6UL_GPR1_ENET2_CLK_SEL }; 105 + static const u32 enet2_ref_sels_table_mask = IMX6UL_GPR1_ENET2_TX_CLK_DIR | 106 + IMX6UL_GPR1_ENET2_CLK_SEL; 97 107 98 108 static u32 share_count_asrc; 99 109 static u32 share_count_audio; ··· 484 472 /* mask handshake of mmdc */ 485 473 imx_mmdc_mask_handshake(base, 0); 486 474 475 + hws[IMX6UL_CLK_ENET1_REF_PAD] = imx_obtain_fixed_of_clock(ccm_node, "enet1_ref_pad", 0); 476 + 477 + hws[IMX6UL_CLK_ENET1_REF_SEL] = imx_clk_gpr_mux("enet1_ref_sel", "fsl,imx6ul-iomuxc-gpr", 478 + IOMUXC_GPR1, enet1_ref_sels, ARRAY_SIZE(enet1_ref_sels), 479 + enet1_ref_sels_table, enet1_ref_sels_table_mask); 480 + hws[IMX6UL_CLK_ENET2_REF_PAD] = imx_obtain_fixed_of_clock(ccm_node, "enet2_ref_pad", 0); 481 + 482 + hws[IMX6UL_CLK_ENET2_REF_SEL] = imx_clk_gpr_mux("enet2_ref_sel", "fsl,imx6ul-iomuxc-gpr", 483 + IOMUXC_GPR1, enet2_ref_sels, ARRAY_SIZE(enet2_ref_sels), 484 + enet2_ref_sels_table, enet2_ref_sels_table_mask); 485 + 487 486 imx_check_clk_hws(hws, IMX6UL_CLK_END); 488 487 489 488 of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_hw_data); ··· 539 516 clk_set_parent(hws[IMX6ULL_CLK_EPDC_PRE_SEL]->clk, hws[IMX6UL_CLK_PLL3_PFD2]->clk); 540 517 541 518 clk_set_parent(hws[IMX6UL_CLK_ENFC_SEL]->clk, hws[IMX6UL_CLK_PLL2_PFD2]->clk); 519 + 520 + clk_set_parent(hws[IMX6UL_CLK_ENET1_REF_SEL]->clk, hws[IMX6UL_CLK_ENET_REF]->clk); 521 + clk_set_parent(hws[IMX6UL_CLK_ENET2_REF_SEL]->clk, hws[IMX6UL_CLK_ENET2_REF]->clk); 542 522 } 543 523 544 524 CLK_OF_DECLARE(imx6ul, "fsl,imx6ul-ccm", imx6ul_clocks_init);
+5 -1
include/dt-bindings/clock/imx6ul-clock.h
··· 257 257 #define IMX6UL_CLK_GPIO5 248 258 258 #define IMX6UL_CLK_MMDC_P1_IPG 249 259 259 #define IMX6UL_CLK_ENET1_REF_125M 250 260 + #define IMX6UL_CLK_ENET1_REF_SEL 251 261 + #define IMX6UL_CLK_ENET1_REF_PAD 252 262 + #define IMX6UL_CLK_ENET2_REF_SEL 253 263 + #define IMX6UL_CLK_ENET2_REF_PAD 254 260 264 261 - #define IMX6UL_CLK_END 251 265 + #define IMX6UL_CLK_END 255 262 266 263 267 #endif /* __DT_BINDINGS_CLOCK_IMX6UL_H */
+4 -2
include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
··· 451 451 #define IMX6SX_GPR12_PCIE_RX_EQ_2 (0x2 << 0) 452 452 453 453 /* For imx6ul iomux gpr register field define */ 454 - #define IMX6UL_GPR1_ENET1_CLK_DIR (0x1 << 17) 455 - #define IMX6UL_GPR1_ENET2_CLK_DIR (0x1 << 18) 454 + #define IMX6UL_GPR1_ENET2_TX_CLK_DIR BIT(18) 455 + #define IMX6UL_GPR1_ENET1_TX_CLK_DIR BIT(17) 456 + #define IMX6UL_GPR1_ENET2_CLK_SEL BIT(14) 457 + #define IMX6UL_GPR1_ENET1_CLK_SEL BIT(13) 456 458 #define IMX6UL_GPR1_ENET1_CLK_OUTPUT (0x1 << 17) 457 459 #define IMX6UL_GPR1_ENET2_CLK_OUTPUT (0x1 << 18) 458 460 #define IMX6UL_GPR1_ENET_CLK_DIR (0x3 << 17)