Skip to content

Commit f6f4015

Browse files
committed
imx6: init ENET RGMII tx clock source
Set GPR5[9] on imx6dp/qp to select clock from internal PLL_enet when ENET_REF_CLK pad has a different function than ENET_TX_CLK. Signed-off-by: Rustam Abdullaev <rustamabd@gmail.com>
1 parent df24f94 commit f6f4015

2 files changed

Lines changed: 50 additions & 2 deletions

File tree

arch/arm/mach-imx/mach-imx6q.c

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,45 @@ static void __init imx6q_enet_phy_init(void)
7676
}
7777
}
7878

79+
static bool imx6q_enet_ref_clk_is_tx_clk(void)
80+
{
81+
const u32 enet_ref_mux_reg = 0x1d4;
82+
struct device_node *fec_np, *pin_np;
83+
const __be32 *list;
84+
int size, j;
85+
bool result = false;
86+
87+
fec_np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-fec");
88+
if (!fec_np)
89+
return false;
90+
91+
for (j = 0; (pin_np = of_parse_phandle(fec_np, "pinctrl-0", j)); j++) {
92+
int n, k;
93+
94+
list = of_get_property(pin_np, "fsl,pins", &size);
95+
if (!list) {
96+
of_node_put(pin_np);
97+
continue;
98+
}
99+
100+
n = size / sizeof(*list);
101+
for (k = 0; k + 5 < n; k += 6) {
102+
u32 mux_reg = be32_to_cpu(list[k]);
103+
u32 mux_mode = be32_to_cpu(list[k + 3]);
104+
105+
if (mux_reg == enet_ref_mux_reg) {
106+
result = (mux_mode == 0x1);
107+
of_node_put(pin_np);
108+
goto out;
109+
}
110+
}
111+
of_node_put(pin_np);
112+
}
113+
out:
114+
of_node_put(fec_np);
115+
return result;
116+
}
117+
79118
static void __init imx6q_1588_init(void)
80119
{
81120
struct device_node *np;
@@ -119,11 +158,19 @@ static void __init imx6q_1588_init(void)
119158
IMX6Q_GPR1_ENET_CLK_SEL_ANATOP :
120159
IMX6Q_GPR1_ENET_CLK_SEL_PAD;
121160
gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
122-
if (!IS_ERR(gpr))
161+
if (!IS_ERR(gpr)) {
123162
regmap_update_bits(gpr, IOMUXC_GPR1,
124163
IMX6Q_GPR1_ENET_CLK_SEL_MASK,
125164
clksel);
126-
else
165+
if (clksel == IMX6Q_GPR1_ENET_CLK_SEL_ANATOP &&
166+
cpu_is_imx6q() &&
167+
imx_get_soc_revision() >= IMX_CHIP_REVISION_2_0 &&
168+
!imx6q_enet_ref_clk_is_tx_clk()) {
169+
regmap_update_bits(gpr, IOMUXC_GPR5,
170+
IMX6Q_GPR5_ENET_TX_CLK_SEL,
171+
IMX6Q_GPR5_ENET_TX_CLK_SEL);
172+
}
173+
} else
127174
pr_err("failed to find fsl,imx6q-iomuxc-gpr regmap\n");
128175

129176
clk_put(enet_ref);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@
240240
#define IMX6Q_GPR4_IPU_RD_CACHE_CTL BIT(0)
241241

242242
#define IMX6Q_GPR5_L2_CLK_STOP BIT(8)
243+
#define IMX6Q_GPR5_ENET_TX_CLK_SEL BIT(9)
243244
#define IMX6Q_GPR5_SATA_SW_PD BIT(10)
244245
#define IMX6Q_GPR5_SATA_SW_RST BIT(11)
245246
#define IMX6Q_GPR5_PRE_PRG_SEL0_MASK (0x3 << 12)

0 commit comments

Comments
 (0)