]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/blob - arch/arm/mach-omap2/clkt2xxx_apll.c
Merge tag 'mxs-dt-3.8' of git://git.linaro.org/people/shawnguo/linux-2.6 into next/dt
[can-eth-gw-linux.git] / arch / arm / mach-omap2 / clkt2xxx_apll.c
1 /*
2  * OMAP2xxx APLL clock control functions
3  *
4  * Copyright (C) 2005-2008 Texas Instruments, Inc.
5  * Copyright (C) 2004-2010 Nokia Corporation
6  *
7  * Contacts:
8  * Richard Woodruff <r-woodruff2@ti.com>
9  * Paul Walmsley
10  *
11  * Based on earlier work by Tuukka Tikkanen, Tony Lindgren,
12  * Gordon McNutt and RidgeRun, Inc.
13  *
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.
17  */
18 #undef DEBUG
19
20 #include <linux/kernel.h>
21 #include <linux/clk.h>
22 #include <linux/io.h>
23
24
25 #include "clock.h"
26 #include "clock2xxx.h"
27 #include "cm2xxx.h"
28 #include "cm-regbits-24xx.h"
29
30 /* CM_CLKEN_PLL.EN_{54,96}M_PLL options (24XX) */
31 #define EN_APLL_STOPPED                 0
32 #define EN_APLL_LOCKED                  3
33
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
38
39 /* Private functions */
40
41 static int _apll96_enable(struct clk *clk)
42 {
43         return omap2xxx_cm_apll96_enable();
44 }
45
46 static int _apll54_enable(struct clk *clk)
47 {
48         return omap2xxx_cm_apll54_enable();
49 }
50
51 static void _apll96_allow_idle(struct clk *clk)
52 {
53         omap2xxx_cm_set_apll96_auto_low_power_stop();
54 }
55
56 static void _apll96_deny_idle(struct clk *clk)
57 {
58         omap2xxx_cm_set_apll96_disable_autoidle();
59 }
60
61 static void _apll54_allow_idle(struct clk *clk)
62 {
63         omap2xxx_cm_set_apll54_auto_low_power_stop();
64 }
65
66 static void _apll54_deny_idle(struct clk *clk)
67 {
68         omap2xxx_cm_set_apll54_disable_autoidle();
69 }
70
71 static void _apll96_disable(struct clk *clk)
72 {
73         omap2xxx_cm_apll96_disable();
74 }
75
76 static void _apll54_disable(struct clk *clk)
77 {
78         omap2xxx_cm_apll54_disable();
79 }
80
81 /* Public data */
82
83 const struct clkops clkops_apll96 = {
84         .enable         = _apll96_enable,
85         .disable        = _apll96_disable,
86         .allow_idle     = _apll96_allow_idle,
87         .deny_idle      = _apll96_deny_idle,
88 };
89
90 const struct clkops clkops_apll54 = {
91         .enable         = _apll54_enable,
92         .disable        = _apll54_disable,
93         .allow_idle     = _apll54_allow_idle,
94         .deny_idle      = _apll54_deny_idle,
95 };
96
97 /* Public functions */
98
99 u32 omap2xxx_get_apll_clkin(void)
100 {
101         u32 aplls, srate = 0;
102
103         aplls = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL1);
104         aplls &= OMAP24XX_APLLS_CLKIN_MASK;
105         aplls >>= OMAP24XX_APLLS_CLKIN_SHIFT;
106
107         if (aplls == APLLS_CLKIN_19_2MHZ)
108                 srate = 19200000;
109         else if (aplls == APLLS_CLKIN_13MHZ)
110                 srate = 13000000;
111         else if (aplls == APLLS_CLKIN_12MHZ)
112                 srate = 12000000;
113
114         return srate;
115 }
116