clk_register_clkdev(clk[gpt_ipg], "ipg", "imx-gpt.0");
        clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0");
+       clk_register_clkdev(clk[enet_ref], "enet_ref", NULL);
 
        if ((imx_get_soc_revision() != IMX_CHIP_REVISION_1_0) ||
            cpu_is_imx6dl()) {
 
 
 static void __init imx6q_1588_init(void)
 {
+       struct device_node *np;
+       struct clk *ptp_clk;
+       struct clk *enet_ref;
        struct regmap *gpr;
+       u32 clksel;
+
+       np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-fec");
+       if (!np) {
+               pr_warn("%s: failed to find fec node\n", __func__);
+               return;
+       }
+
+       ptp_clk = of_clk_get(np, 2);
+       if (IS_ERR(ptp_clk)) {
+               pr_warn("%s: failed to get ptp clock\n", __func__);
+               goto put_node;
+       }
+
+       enet_ref = clk_get_sys(NULL, "enet_ref");
+       if (IS_ERR(enet_ref)) {
+               pr_warn("%s: failed to get enet clock\n", __func__);
+               goto put_ptp_clk;
+       }
 
+       /*
+        * If enet_ref from ANATOP/CCM is the PTP clock source, we need to
+        * set bit IOMUXC_GPR1[21].  Or the PTP clock must be from pad
+        * (external OSC), and we need to clear the bit.
+        */
+       clksel = ptp_clk == enet_ref ? IMX6Q_GPR1_ENET_CLK_SEL_ANATOP :
+                                      IMX6Q_GPR1_ENET_CLK_SEL_PAD;
        gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
        if (!IS_ERR(gpr))
                regmap_update_bits(gpr, IOMUXC_GPR1,
                                IMX6Q_GPR1_ENET_CLK_SEL_MASK,
-                               IMX6Q_GPR1_ENET_CLK_SEL_ANATOP);
+                               clksel);
        else
                pr_err("failed to find fsl,imx6q-iomux-gpr regmap\n");
 
+       clk_put(enet_ref);
+put_ptp_clk:
+       clk_put(ptp_clk);
+put_node:
+       of_node_put(np);
 }
 
 static void __init imx6q_init_machine(void)