mx6: clock: Pass the frequency as argument of enable_fec_anatop_clock()
authorFabio Estevam <fabio.estevam@freescale.com>
Fri, 3 Jan 2014 17:55:57 +0000 (15:55 -0200)
committerStefano Babic <sbabic@denx.de>
Wed, 15 Jan 2014 09:33:25 +0000 (10:33 +0100)
Provide an argument to enable_fec_anatop_clock() to specify the clock frequency
that will be generated.

No changes are made to mx6slevk, which uses the default 50MHz fec clock.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Stefano Babic <sbabic@denx.de>
arch/arm/cpu/armv7/mx6/clock.c
arch/arm/include/asm/arch-mx6/clock.h
board/freescale/mx6slevk/mx6slevk.c

index f12bba2944a915558c24738760f80d0d72d2b3b3..5617a410da9f5c67f17cad0e4709904f86e75fcc 100644 (file)
@@ -323,7 +323,7 @@ static u32 get_mmdc_ch0_clk(void)
 #endif
 
 #ifdef CONFIG_FEC_MXC
-int enable_fec_anatop_clock(void)
+int enable_fec_anatop_clock(enum enet_freq freq)
 {
        u32 reg = 0;
        s32 timeout = 100000;
@@ -331,7 +331,13 @@ int enable_fec_anatop_clock(void)
        struct anatop_regs __iomem *anatop =
                (struct anatop_regs __iomem *)ANATOP_BASE_ADDR;
 
+       if (freq < ENET_25MHz || freq > ENET_125MHz)
+               return -EINVAL;
+
        reg = readl(&anatop->pll_enet);
+       reg &= ~BM_ANADIG_PLL_ENET_DIV_SELECT;
+       reg |= freq;
+
        if ((reg & BM_ANADIG_PLL_ENET_POWERDOWN) ||
            (!(reg & BM_ANADIG_PLL_ENET_LOCK))) {
                reg &= ~BM_ANADIG_PLL_ENET_POWERDOWN;
index 93f29a780f56dbe216265691875477714283cdb0..e31ba0a955efa519067b408927438dcbc3d79aac 100644 (file)
@@ -42,6 +42,13 @@ enum mxc_clock {
        MXC_I2C_CLK,
 };
 
+enum enet_freq {
+       ENET_25MHz,
+       ENET_50MHz,
+       ENET_100MHz,
+       ENET_125MHz,
+};
+
 u32 imx_get_uartclk(void);
 u32 imx_get_fecclk(void);
 unsigned int mxc_get_clock(enum mxc_clock clk);
@@ -50,5 +57,5 @@ void enable_usboh3_clk(unsigned char enable);
 int enable_sata_clock(void);
 int enable_i2c_clk(unsigned char enable, unsigned i2c_num);
 void enable_ipu_clock(void);
-int enable_fec_anatop_clock(void);
+int enable_fec_anatop_clock(enum enet_freq freq);
 #endif /* __ASM_ARCH_CLOCK_H */
index dfc5746c7f54f33dcd56345be5fb231e21414cd2..c4962549a71e2812f3610281da2b726de79e0224 100644 (file)
@@ -120,7 +120,7 @@ static int setup_fec(void)
        /* clear gpr1[14], gpr1[18:17] to select anatop clock */
        clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUX_GPR1_FEC_MASK, 0);
 
-       ret = enable_fec_anatop_clock();
+       ret = enable_fec_anatop_clock(ENET_50MHz);
        if (ret)
                return ret;