Skip to content

Commit 4e197ee

Browse files
oleremabelvesa
authored andcommitted
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 <[email protected]> Acked-by: Lee Jones <[email protected]> Reviewed-by: Abel Vesa <[email protected]> Signed-off-by: Abel Vesa <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5f82bfc commit 4e197ee

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

drivers/clk/imx/clk-imx6ul.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/err.h>
1111
#include <linux/init.h>
1212
#include <linux/io.h>
13+
#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
1314
#include <linux/of.h>
1415
#include <linux/of_address.h>
1516
#include <linux/of_irq.h>
@@ -94,6 +95,17 @@ static const struct clk_div_table video_div_table[] = {
9495
{ }
9596
};
9697

98+
static const char * enet1_ref_sels[] = { "enet1_ref_125m", "enet1_ref_pad", };
99+
static const u32 enet1_ref_sels_table[] = { IMX6UL_GPR1_ENET1_TX_CLK_DIR,
100+
IMX6UL_GPR1_ENET1_CLK_SEL };
101+
static const u32 enet1_ref_sels_table_mask = IMX6UL_GPR1_ENET1_TX_CLK_DIR |
102+
IMX6UL_GPR1_ENET1_CLK_SEL;
103+
static const char * enet2_ref_sels[] = { "enet2_ref_125m", "enet2_ref_pad", };
104+
static const u32 enet2_ref_sels_table[] = { IMX6UL_GPR1_ENET2_TX_CLK_DIR,
105+
IMX6UL_GPR1_ENET2_CLK_SEL };
106+
static const u32 enet2_ref_sels_table_mask = IMX6UL_GPR1_ENET2_TX_CLK_DIR |
107+
IMX6UL_GPR1_ENET2_CLK_SEL;
108+
97109
static u32 share_count_asrc;
98110
static u32 share_count_audio;
99111
static u32 share_count_sai1;
@@ -472,6 +484,17 @@ static void __init imx6ul_clocks_init(struct device_node *ccm_node)
472484
/* mask handshake of mmdc */
473485
imx_mmdc_mask_handshake(base, 0);
474486

487+
hws[IMX6UL_CLK_ENET1_REF_PAD] = imx_obtain_fixed_of_clock(ccm_node, "enet1_ref_pad", 0);
488+
489+
hws[IMX6UL_CLK_ENET1_REF_SEL] = imx_clk_gpr_mux("enet1_ref_sel", "fsl,imx6ul-iomuxc-gpr",
490+
IOMUXC_GPR1, enet1_ref_sels, ARRAY_SIZE(enet1_ref_sels),
491+
enet1_ref_sels_table, enet1_ref_sels_table_mask);
492+
hws[IMX6UL_CLK_ENET2_REF_PAD] = imx_obtain_fixed_of_clock(ccm_node, "enet2_ref_pad", 0);
493+
494+
hws[IMX6UL_CLK_ENET2_REF_SEL] = imx_clk_gpr_mux("enet2_ref_sel", "fsl,imx6ul-iomuxc-gpr",
495+
IOMUXC_GPR1, enet2_ref_sels, ARRAY_SIZE(enet2_ref_sels),
496+
enet2_ref_sels_table, enet2_ref_sels_table_mask);
497+
475498
imx_check_clk_hws(hws, IMX6UL_CLK_END);
476499

477500
of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_hw_data);
@@ -516,6 +539,9 @@ static void __init imx6ul_clocks_init(struct device_node *ccm_node)
516539
clk_set_parent(hws[IMX6ULL_CLK_EPDC_PRE_SEL]->clk, hws[IMX6UL_CLK_PLL3_PFD2]->clk);
517540

518541
clk_set_parent(hws[IMX6UL_CLK_ENFC_SEL]->clk, hws[IMX6UL_CLK_PLL2_PFD2]->clk);
542+
543+
clk_set_parent(hws[IMX6UL_CLK_ENET1_REF_SEL]->clk, hws[IMX6UL_CLK_ENET_REF]->clk);
544+
clk_set_parent(hws[IMX6UL_CLK_ENET2_REF_SEL]->clk, hws[IMX6UL_CLK_ENET2_REF]->clk);
519545
}
520546

521547
CLK_OF_DECLARE(imx6ul, "fsl,imx6ul-ccm", imx6ul_clocks_init);

include/dt-bindings/clock/imx6ul-clock.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,11 @@
257257
#define IMX6UL_CLK_GPIO5 248
258258
#define IMX6UL_CLK_MMDC_P1_IPG 249
259259
#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
260264

261-
#define IMX6UL_CLK_END 251
265+
#define IMX6UL_CLK_END 255
262266

263267
#endif /* __DT_BINDINGS_CLOCK_IMX6UL_H */

include/linux/mfd/syscon/imx6q-iomuxc-gpr.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,10 @@
451451
#define IMX6SX_GPR12_PCIE_RX_EQ_2 (0x2 << 0)
452452

453453
/* 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)
456458
#define IMX6UL_GPR1_ENET1_CLK_OUTPUT (0x1 << 17)
457459
#define IMX6UL_GPR1_ENET2_CLK_OUTPUT (0x1 << 18)
458460
#define IMX6UL_GPR1_ENET_CLK_DIR (0x3 << 17)

0 commit comments

Comments
 (0)