aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDinh Nguyen <Dinh.Nguyen@freescale.com>2010-05-10 14:45:58 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2010-05-11 02:49:54 -0400
commitc79504e73a0e84c4db7a2315dcdd6987b0c52566 (patch)
tree9b63659c2711af9cf8f866961e9b6ab5f20673d8 /arch
parent7176441b95b4a04ad7cbac71d0d3614a7634d727 (diff)
mx5: change usb clock source from pll3 to pll2
For power management reasons, pll2 should be used to source the USBOH3 clock for mx51. PLL3 can be completely gated off when USB is not used. This patch applies to 2.6.34-rc7. Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-mx5/clock-mx51.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index dcca330addc9..566cfda6185e 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -36,6 +36,7 @@ static struct clk lp_apm_clk;
36static struct clk periph_apm_clk; 36static struct clk periph_apm_clk;
37static struct clk ahb_clk; 37static struct clk ahb_clk;
38static struct clk ipg_clk; 38static struct clk ipg_clk;
39static struct clk usboh3_clk;
39 40
40#define MAX_DPLL_WAIT_TRIES 1000 /* 1000 * udelay(1) = 1ms */ 41#define MAX_DPLL_WAIT_TRIES 1000 /* 1000 * udelay(1) = 1ms */
41 42
@@ -569,6 +570,35 @@ static int _clk_uart_set_parent(struct clk *clk, struct clk *parent)
569 return 0; 570 return 0;
570} 571}
571 572
573static unsigned long clk_usboh3_get_rate(struct clk *clk)
574{
575 u32 reg, prediv, podf;
576 unsigned long parent_rate;
577
578 parent_rate = clk_get_rate(clk->parent);
579
580 reg = __raw_readl(MXC_CCM_CSCDR1);
581 prediv = ((reg & MXC_CCM_CSCDR1_USBOH3_CLK_PRED_MASK) >>
582 MXC_CCM_CSCDR1_USBOH3_CLK_PRED_OFFSET) + 1;
583 podf = ((reg & MXC_CCM_CSCDR1_USBOH3_CLK_PODF_MASK) >>
584 MXC_CCM_CSCDR1_USBOH3_CLK_PODF_OFFSET) + 1;
585
586 return parent_rate / (prediv * podf);
587}
588
589static int _clk_usboh3_set_parent(struct clk *clk, struct clk *parent)
590{
591 u32 reg, mux;
592
593 mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk,
594 &lp_apm_clk);
595 reg = __raw_readl(MXC_CCM_CSCMR1) & ~MXC_CCM_CSCMR1_USBOH3_CLK_SEL_MASK;
596 reg |= mux << MXC_CCM_CSCMR1_USBOH3_CLK_SEL_OFFSET;
597 __raw_writel(reg, MXC_CCM_CSCMR1);
598
599 return 0;
600}
601
572static unsigned long get_high_reference_clock_rate(struct clk *clk) 602static unsigned long get_high_reference_clock_rate(struct clk *clk)
573{ 603{
574 return external_high_reference; 604 return external_high_reference;
@@ -690,6 +720,12 @@ static struct clk uart_root_clk = {
690 .set_parent = _clk_uart_set_parent, 720 .set_parent = _clk_uart_set_parent,
691}; 721};
692 722
723static struct clk usboh3_clk = {
724 .parent = &pll2_sw_clk,
725 .get_rate = clk_usboh3_get_rate,
726 .set_parent = _clk_usboh3_set_parent,
727};
728
693static struct clk ahb_max_clk = { 729static struct clk ahb_max_clk = {
694 .parent = &ahb_clk, 730 .parent = &ahb_clk,
695 .enable_reg = MXC_CCM_CCGR0, 731 .enable_reg = MXC_CCM_CCGR0,
@@ -761,10 +797,6 @@ DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG9_OFFSET,
761DEFINE_CLOCK(gpt_ipg_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG10_OFFSET, 797DEFINE_CLOCK(gpt_ipg_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG10_OFFSET,
762 NULL, NULL, &ipg_clk, NULL); 798 NULL, NULL, &ipg_clk, NULL);
763 799
764/* USB */
765DEFINE_CLOCK(usboh3_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG14_OFFSET,
766 NULL, NULL, &pll3_sw_clk, NULL);
767
768/* FEC */ 800/* FEC */
769DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET, 801DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET,
770 NULL, NULL, &ipg_clk, NULL); 802 NULL, NULL, &ipg_clk, NULL);
@@ -826,6 +858,9 @@ int __init mx51_clocks_init(unsigned long ckil, unsigned long osc,
826 clk_enable(&cpu_clk); 858 clk_enable(&cpu_clk);
827 clk_enable(&main_bus_clk); 859 clk_enable(&main_bus_clk);
828 860
861 /* set the usboh3_clk parent to pll2_sw_clk */
862 clk_set_parent(&usboh3_clk, &pll2_sw_clk);
863
829 /* System timer */ 864 /* System timer */
830 mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR), 865 mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
831 MX51_MXC_INT_GPT); 866 MX51_MXC_INT_GPT);