]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/arm/mach-mx6/clock.c
ENGR00176655:mx6:remove openvg_axi_clk from gpu2d_axi_clk's secondary
[karo-tx-linux.git] / arch / arm / mach-mx6 / clock.c
index a75011e5d23a354343ba05349024c2b9518d419e..813c55432d708aea873e1c65ee069aa23b9c2e8b 100644 (file)
@@ -60,8 +60,6 @@ static struct clk pll8_enet_main_clk;
 static struct clk apbh_dma_clk;
 static struct clk openvg_axi_clk;
 static struct clk enfc_clk;
-static struct clk ipu1_di_clk_root;
-static struct clk ipu2_di_clk_root;
 static struct clk usdhc3_clk;
 
 static struct cpu_op *cpu_op_tbl;
@@ -107,13 +105,13 @@ static unsigned long anaclk_1_reference, anaclk_2_reference;
  * parameters, in order to set the EPDC parent clock to the Video PLL.
  * This will have an impact on the behavior of HDMI and LVDS.
  */
-static int epdc_use_video_pll;
-static int __init epdc_clk_setup(char *__unused)
+int epdc_enabled;
+static int __init epdc_setup(char *__unused)
 {
-       epdc_use_video_pll = 1;
+       epdc_enabled = 1;
        return 1;
 }
-__setup("epdc", epdc_clk_setup);
+__setup("epdc", epdc_setup);
 
 static void __calc_pre_post_dividers(u32 max_podf, u32 div, u32 *pre, u32 *post)
 {
@@ -494,17 +492,23 @@ static unsigned long  _clk_pll1_main_get_rate(struct clk *clk)
 
 static int _clk_pll1_main_set_rate(struct clk *clk, unsigned long rate)
 {
-       unsigned int reg,  div;
+       unsigned int reg, div;
 
        if (rate < AUDIO_VIDEO_MIN_CLK_FREQ || rate > AUDIO_VIDEO_MAX_CLK_FREQ)
                return -EINVAL;
 
-       div = (rate * 2) / clk_get_rate(clk->parent) ;
+       div = (rate * 2) / clk_get_rate(clk->parent);
 
+       /* Update div */
        reg = __raw_readl(PLL1_SYS_BASE_ADDR) & ~ANADIG_PLL_SYS_DIV_SELECT_MASK;
        reg |= div;
        __raw_writel(reg, PLL1_SYS_BASE_ADDR);
 
+       /* Wait for PLL1 to lock */
+       if (!WAIT(__raw_readl(PLL1_SYS_BASE_ADDR) & ANADIG_PLL_LOCK,
+                               SPIN_DELAY))
+               panic("pll1 enable failed\n");
+
        return 0;
 }
 
@@ -1183,6 +1187,17 @@ static struct clk cpu_clk = {
        .get_rate = _clk_arm_get_rate,
 };
 
+static unsigned long _clk_twd_get_rate(struct clk *clk)
+{
+       return clk_get_rate(clk->parent) / 2;
+}
+
+static struct clk twd_clk = {
+       __INIT_CLK_DEBUG(twd_clk)
+       .parent = &cpu_clk,
+       .get_rate = _clk_twd_get_rate,
+};
+
 static int _clk_periph_set_parent(struct clk *clk, struct clk *parent)
 {
        u32 reg;
@@ -1750,7 +1765,6 @@ static int _clk_gpu2d_axi_set_parent(struct clk *clk, struct clk *parent)
 static struct clk gpu2d_axi_clk = {
        __INIT_CLK_DEBUG(gpu2d_axi_clk)
        .parent = &axi_clk,
-       .secondary = &openvg_axi_clk,
        .set_parent = _clk_gpu2d_axi_set_parent,
 };
 
@@ -2077,123 +2091,6 @@ static struct clk ipu1_clk = {
        .flags = AHB_HIGH_SET_POINT | CPU_FREQ_TRIG_UPDATE,
 };
 
-static int _clk_cko1_clk0_set_parent(struct clk *clk, struct clk *parent)
-{
-       u32 sel, reg;
-
-       if (parent == &pll3_sw_clk)
-               sel = 0;
-       else if (parent == &pll2_528_bus_main_clk)
-               sel = 1;
-       else if (parent == &pll1_sys_main_clk)
-               sel = 2;
-       else if (parent == &pll5_video_main_clk)
-               sel = 3;
-       else if (parent == &axi_clk)
-               sel = 5;
-       else if (parent == &enfc_clk)
-               sel = 6;
-       else if (parent == &ipu1_di_clk_root)
-               sel = 7;
-       else if (parent == &ipu1_di_clk_root)
-               sel = 8;
-       else if (parent == &ipu2_di_clk_root)
-               sel = 9;
-       else if (parent == &ipu2_di_clk_root)
-               sel = 10;
-       else if (parent == &ahb_clk)
-               sel = 11;
-       else if (parent == &ipg_clk)
-               sel = 12;
-       else if (parent == &ipg_perclk)
-               sel = 13;
-       else if (parent == &ckil_clk)
-               sel = 14;
-       else if (parent == &pll4_audio_main_clk)
-               sel = 15;
-       else
-               return -EINVAL;
-
-       reg = __raw_readl(MXC_CCM_CCOSR);
-       reg &= ~MXC_CCM_CCOSR_CKOL_SEL_MASK;
-       reg |= sel << MXC_CCM_CCOSR_CKOL_SEL_OFFSET;
-       __raw_writel(reg, MXC_CCM_CCOSR);
-       return 0;
-}
-
-static unsigned long _clk_cko1_round_rate(struct clk *clk,
-                                               unsigned long rate)
-{
-       u32 div;
-       u32 parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-
-       /* Make sure rate is not greater than the maximum value for the clock.
-        * Also prevent a div of 0.
-        */
-       if (div == 0)
-               div++;
-
-       if (div > 8)
-               div = 8;
-
-       return parent_rate / div;
-}
-
-static int _clk_cko1_set_rate(struct clk *clk, unsigned long rate)
-{
-       u32 reg, div;
-       u32 parent_rate = clk_get_rate(clk->parent);
-
-       div = parent_rate / rate;
-       if (div == 0)
-               div++;
-       if (((parent_rate / div) != rate) || (div > 8))
-               return -EINVAL;
-
-       reg = __raw_readl(MXC_CCM_CCOSR);
-       reg &= ~MXC_CCM_CCOSR_CKOL_DIV_MASK;
-       reg |= div << MXC_CCM_CCOSR_CKOL_DIV_OFFSET;
-       __raw_writel(reg, MXC_CCM_CCOSR);
-
-       return 0;
-}
-
-static unsigned long _clk_cko1_get_rate(struct clk *clk)
-{
-       u32 reg, div;
-
-       reg = __raw_readl(MXC_CCM_CCOSR);
-       div = ((reg & MXC_CCM_CCOSR_CKOL_DIV_MASK) >>
-                       MXC_CCM_CCOSR_CKOL_DIV_OFFSET) + 1;
-
-       return clk_get_rate(clk->parent) / div;
-}
-
-static int cko1_clk_enable(struct clk *clk)
-{
-       u32 reg;
-       reg = __raw_readl(clk->enable_reg);
-       reg |= clk->enable_shift;
-       __raw_writel(reg, clk->enable_reg);
-
-       return 0;
-}
-
-static struct clk cko1_clk0 = {
-       __INIT_CLK_DEBUG(cko1_clk0)
-       .parent = &ipg_clk,
-       .enable_reg = MXC_CCM_CCOSR,
-       .enable_shift = MXC_CCM_CCOSR_CKOL_EN,
-       .enable = cko1_clk_enable,
-       .disable = _clk_disable,
-       .set_parent = _clk_cko1_clk0_set_parent,
-       .round_rate = _clk_cko1_round_rate,
-       .set_rate = _clk_cko1_set_rate,
-       .get_rate = _clk_cko1_get_rate,
-};
-
 static int _clk_ipu2_set_parent(struct clk *clk, struct clk *parent)
 {
        int mux;
@@ -4473,12 +4370,8 @@ static struct clk gpu2d_core_clk[] = {
        .set_rate = _clk_gpu2d_core_set_rate,
        .get_rate = _clk_gpu2d_core_get_rate,
        .round_rate = _clk_gpu2d_core_round_rate,
-       .secondary = &gpu2d_core_clk[1],
-       .flags = AHB_HIGH_SET_POINT | CPU_FREQ_TRIG_UPDATE,
-       },
-       {
-       .parent = &gpu2d_axi_clk,
        .secondary = &mx6fast1_clk,
+       .flags = AHB_HIGH_SET_POINT | CPU_FREQ_TRIG_UPDATE,
        },
 };
 
@@ -5110,6 +5003,7 @@ static struct clk_lookup lookups[] = {
        _REGISTER_CLOCK(NULL, "pll3", pll7_usb_host_main_clk),
        _REGISTER_CLOCK(NULL, "pll4", pll8_enet_main_clk),
        _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk),
+       _REGISTER_CLOCK("smp_twd", NULL, twd_clk),
        _REGISTER_CLOCK(NULL, "periph_clk", periph_clk),
        _REGISTER_CLOCK(NULL, "axi_clk", axi_clk),
        _REGISTER_CLOCK(NULL, "mmdc_ch0_axi", mmdc_ch0_axi_clk[0]),
@@ -5130,7 +5024,6 @@ static struct clk_lookup lookups[] = {
        _REGISTER_CLOCK(NULL, "vpu_clk", vpu_clk[0]),
        _REGISTER_CLOCK(NULL, "ipu1_clk", ipu1_clk),
        _REGISTER_CLOCK(NULL, "ipu2_clk", ipu2_clk),
-       _REGISTER_CLOCK(NULL, "cko1_clk0", cko1_clk0),
        _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, usdhc1_clk),
        _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, usdhc2_clk),
        _REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, usdhc3_clk),
@@ -5280,10 +5173,6 @@ int __init mx6_clocks_init(unsigned long ckil, unsigned long osc,
        clk_set_parent(&ipu2_di_clk[0], &pll5_video_main_clk);
        clk_set_parent(&ipu2_di_clk[1], &pll5_video_main_clk);
 
-       clk_set_parent(&cko1_clk0, &ipg_clk);
-       clk_set_rate(&cko1_clk0, 22000000);
-       clk_enable(&cko1_clk0);
-
        clk_set_parent(&emi_clk, &pll2_pfd_400M);
        clk_set_rate(&emi_clk, 200000000);
 
@@ -5298,7 +5187,6 @@ int __init mx6_clocks_init(unsigned long ckil, unsigned long osc,
                clk_set_parent(&gpu3d_axi_clk, &mmdc_ch0_axi_clk[0]);
                /* on mx6dl gpu2d_axi_clk source from mmdc0 directly */
                clk_set_parent(&gpu2d_axi_clk, &mmdc_ch0_axi_clk[0]);
-               gpu2d_axi_clk.secondary = NULL;
 
                /* set axi_clk parent to pll3_pfd_540M */
                clk_set_parent(&axi_clk, &pll3_pfd_540M);
@@ -5315,6 +5203,7 @@ int __init mx6_clocks_init(unsigned long ckil, unsigned long osc,
        clk_set_parent(&clko2_clk, &osc_clk);
        clk_set_rate(&clko2_clk, 2400000);
 
+       clk_set_parent(&clko_clk, &ipg_clk);
        /*
         * FIXME: asrc needs to use asrc_serial(spdif1) clock to do sample
         * rate convertion and this clock frequency can not be too high, set
@@ -5379,7 +5268,7 @@ int __init mx6_clocks_init(unsigned long ckil, unsigned long osc,
        }
 
        if (cpu_is_mx6dl()) {
-               if (epdc_use_video_pll)
+               if (epdc_enabled)
                        clk_set_parent(&ipu2_di_clk[1], &pll5_video_main_clk);
                else
                        clk_set_parent(&ipu2_di_clk[1], &pll3_pfd_540M);