blob: 75561a6b04d3ea2d4bd6d93c61badd8074f4e60d [file] [log] [blame]
Paul Walmsley49214642010-01-26 20:13:06 -07001/*
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
Paul Walmsley49214642010-01-26 20:13:06 -070024#include <plat/prcm.h>
25
26#include "clock.h"
27#include "clock2xxx.h"
Paul Walmsleyff4ae5d2012-10-21 01:01:11 -060028#include "cm2xxx.h"
Paul Walmsley49214642010-01-26 20:13:06 -070029#include "cm-regbits-24xx.h"
30
31/* CM_CLKEN_PLL.EN_{54,96}M_PLL options (24XX) */
32#define EN_APLL_STOPPED 0
33#define EN_APLL_LOCKED 3
34
35/* CM_CLKSEL1_PLL.APLLS_CLKIN options (24XX) */
36#define APLLS_CLKIN_19_2MHZ 0
37#define APLLS_CLKIN_13MHZ 2
38#define APLLS_CLKIN_12MHZ 3
39
40/* Private functions */
41
Paul Walmsleyb6ffa052012-10-29 20:56:17 -060042static int _apll96_enable(struct clk *clk)
Paul Walmsley49214642010-01-26 20:13:06 -070043{
Paul Walmsleyb6ffa052012-10-29 20:56:17 -060044 return omap2xxx_cm_apll96_enable();
Paul Walmsley49214642010-01-26 20:13:06 -070045}
46
Paul Walmsleyb6ffa052012-10-29 20:56:17 -060047static int _apll54_enable(struct clk *clk)
Paul Walmsley49214642010-01-26 20:13:06 -070048{
Paul Walmsleyb6ffa052012-10-29 20:56:17 -060049 return omap2xxx_cm_apll54_enable();
Paul Walmsley49214642010-01-26 20:13:06 -070050}
51
Paul Walmsley92618ff2011-02-25 15:39:27 -070052static void _apll96_allow_idle(struct clk *clk)
53{
54 omap2xxx_cm_set_apll96_auto_low_power_stop();
55}
56
57static void _apll96_deny_idle(struct clk *clk)
58{
59 omap2xxx_cm_set_apll96_disable_autoidle();
60}
61
62static void _apll54_allow_idle(struct clk *clk)
63{
64 omap2xxx_cm_set_apll54_auto_low_power_stop();
65}
66
67static void _apll54_deny_idle(struct clk *clk)
68{
69 omap2xxx_cm_set_apll54_disable_autoidle();
70}
71
Paul Walmsleyb6ffa052012-10-29 20:56:17 -060072static void _apll96_disable(struct clk *clk)
Paul Walmsley49214642010-01-26 20:13:06 -070073{
Paul Walmsleyb6ffa052012-10-29 20:56:17 -060074 omap2xxx_cm_apll96_disable();
75}
Paul Walmsley49214642010-01-26 20:13:06 -070076
Paul Walmsleyb6ffa052012-10-29 20:56:17 -060077static void _apll54_disable(struct clk *clk)
78{
79 omap2xxx_cm_apll54_disable();
Paul Walmsley49214642010-01-26 20:13:06 -070080}
81
82/* Public data */
83
84const struct clkops clkops_apll96 = {
Paul Walmsleyb6ffa052012-10-29 20:56:17 -060085 .enable = _apll96_enable,
86 .disable = _apll96_disable,
Paul Walmsley92618ff2011-02-25 15:39:27 -070087 .allow_idle = _apll96_allow_idle,
88 .deny_idle = _apll96_deny_idle,
Paul Walmsley49214642010-01-26 20:13:06 -070089};
90
91const struct clkops clkops_apll54 = {
Paul Walmsleyb6ffa052012-10-29 20:56:17 -060092 .enable = _apll54_enable,
93 .disable = _apll54_disable,
Paul Walmsley92618ff2011-02-25 15:39:27 -070094 .allow_idle = _apll54_allow_idle,
95 .deny_idle = _apll54_deny_idle,
Paul Walmsley49214642010-01-26 20:13:06 -070096};
97
98/* Public functions */
99
100u32 omap2xxx_get_apll_clkin(void)
101{
102 u32 aplls, srate = 0;
103
Paul Walmsleyc4d7e582010-12-21 21:05:14 -0700104 aplls = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL1);
Paul Walmsley49214642010-01-26 20:13:06 -0700105 aplls &= OMAP24XX_APLLS_CLKIN_MASK;
106 aplls >>= OMAP24XX_APLLS_CLKIN_SHIFT;
107
108 if (aplls == APLLS_CLKIN_19_2MHZ)
109 srate = 19200000;
110 else if (aplls == APLLS_CLKIN_13MHZ)
111 srate = 13000000;
112 else if (aplls == APLLS_CLKIN_12MHZ)
113 srate = 12000000;
114
115 return srate;
116}
117