2 * OMAP2xxx APLL clock control functions
4 * Copyright (C) 2005-2008 Texas Instruments, Inc.
5 * Copyright (C) 2004-2010 Nokia Corporation
8 * Richard Woodruff <r-woodruff2@ti.com>
11 * Based on earlier work by Tuukka Tikkanen, Tony Lindgren,
12 * Gordon McNutt and RidgeRun, Inc.
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
20 #include <linux/kernel.h>
21 #include <linux/clk.h>
26 #include "clock2xxx.h"
28 #include "cm-regbits-24xx.h"
30 /* CM_CLKEN_PLL.EN_{54,96}M_PLL options (24XX) */
31 #define EN_APLL_STOPPED 0
32 #define EN_APLL_LOCKED 3
34 /* CM_CLKSEL1_PLL.APLLS_CLKIN options (24XX) */
35 #define APLLS_CLKIN_19_2MHZ 0
36 #define APLLS_CLKIN_13MHZ 2
37 #define APLLS_CLKIN_12MHZ 3
39 /* Private functions */
42 * omap2xxx_clk_apll_locked - is the APLL locked?
43 * @hw: struct clk_hw * of the APLL to check
45 * If the APLL IP block referred to by @hw indicates that it's locked,
46 * return true; otherwise, return false.
48 static bool omap2xxx_clk_apll_locked(struct clk_hw
*hw
)
50 struct clk_hw_omap
*clk
= to_clk_hw_omap(hw
);
53 apll_mask
= EN_APLL_LOCKED
<< clk
->enable_bit
;
55 r
= omap2_cm_read_mod_reg(PLL_MOD
, CM_CLKEN
);
57 return ((r
& apll_mask
) == apll_mask
) ? true : false;
60 int omap2_clk_apll96_enable(struct clk_hw
*hw
)
62 return omap2xxx_cm_apll96_enable();
65 int omap2_clk_apll54_enable(struct clk_hw
*hw
)
67 return omap2xxx_cm_apll54_enable();
70 static void _apll96_allow_idle(struct clk_hw_omap
*clk
)
72 omap2xxx_cm_set_apll96_auto_low_power_stop();
75 static void _apll96_deny_idle(struct clk_hw_omap
*clk
)
77 omap2xxx_cm_set_apll96_disable_autoidle();
80 static void _apll54_allow_idle(struct clk_hw_omap
*clk
)
82 omap2xxx_cm_set_apll54_auto_low_power_stop();
85 static void _apll54_deny_idle(struct clk_hw_omap
*clk
)
87 omap2xxx_cm_set_apll54_disable_autoidle();
90 void omap2_clk_apll96_disable(struct clk_hw
*hw
)
92 omap2xxx_cm_apll96_disable();
95 void omap2_clk_apll54_disable(struct clk_hw
*hw
)
97 omap2xxx_cm_apll54_disable();
100 unsigned long omap2_clk_apll54_recalc(struct clk_hw
*hw
,
101 unsigned long parent_rate
)
103 return (omap2xxx_clk_apll_locked(hw
)) ? 54000000 : 0;
106 unsigned long omap2_clk_apll96_recalc(struct clk_hw
*hw
,
107 unsigned long parent_rate
)
109 return (omap2xxx_clk_apll_locked(hw
)) ? 96000000 : 0;
113 const struct clk_hw_omap_ops clkhwops_apll54
= {
114 .allow_idle
= _apll54_allow_idle
,
115 .deny_idle
= _apll54_deny_idle
,
118 const struct clk_hw_omap_ops clkhwops_apll96
= {
119 .allow_idle
= _apll96_allow_idle
,
120 .deny_idle
= _apll96_deny_idle
,
123 /* Public functions */
125 u32
omap2xxx_get_apll_clkin(void)
127 u32 aplls
, srate
= 0;
129 aplls
= omap2_cm_read_mod_reg(PLL_MOD
, CM_CLKSEL1
);
130 aplls
&= OMAP24XX_APLLS_CLKIN_MASK
;
131 aplls
>>= OMAP24XX_APLLS_CLKIN_SHIFT
;
133 if (aplls
== APLLS_CLKIN_19_2MHZ
)
135 else if (aplls
== APLLS_CLKIN_13MHZ
)
137 else if (aplls
== APLLS_CLKIN_12MHZ
)