msm: generalize clock support.
[safe/jmp/linux-2.6] / arch / arm / mach-msm / clock.h
1 /* arch/arm/mach-msm/clock.h
2  *
3  * Copyright (C) 2007 Google, Inc.
4  * Copyright (c) 2007-2010, Code Aurora Forum. All rights reserved.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16
17 #ifndef __ARCH_ARM_MACH_MSM_CLOCK_H
18 #define __ARCH_ARM_MACH_MSM_CLOCK_H
19
20 #include <linux/list.h>
21 #include <mach/clk.h>
22
23 #include "clock-pcom.h"
24
25 #define CLKFLAG_INVERT                  0x00000001
26 #define CLKFLAG_NOINVERT                0x00000002
27 #define CLKFLAG_NONEST                  0x00000004
28 #define CLKFLAG_NORESET                 0x00000008
29
30 #define CLK_FIRST_AVAILABLE_FLAG        0x00000100
31 #define CLKFLAG_AUTO_OFF                0x00000200
32 #define CLKFLAG_MIN                     0x00000400
33 #define CLKFLAG_MAX                     0x00000800
34
35 struct clk_ops {
36         int (*enable)(unsigned id);
37         void (*disable)(unsigned id);
38         void (*auto_off)(unsigned id);
39         int (*reset)(unsigned id, enum clk_reset_action action);
40         int (*set_rate)(unsigned id, unsigned rate);
41         int (*set_min_rate)(unsigned id, unsigned rate);
42         int (*set_max_rate)(unsigned id, unsigned rate);
43         int (*set_flags)(unsigned id, unsigned flags);
44         unsigned (*get_rate)(unsigned id);
45         unsigned (*is_enabled)(unsigned id);
46         long (*round_rate)(unsigned id, unsigned rate);
47 };
48
49 struct clk {
50         uint32_t id;
51         uint32_t remote_id;
52         uint32_t count;
53         uint32_t flags;
54         const char *name;
55         struct clk_ops *ops;
56         const char *dbg_name;
57         struct list_head list;
58         struct device *dev;
59 };
60
61 #define A11S_CLK_CNTL_ADDR              (MSM_CSR_BASE + 0x100)
62 #define A11S_CLK_SEL_ADDR               (MSM_CSR_BASE + 0x104)
63 #define A11S_VDD_SVS_PLEVEL_ADDR        (MSM_CSR_BASE + 0x124)
64
65 #ifdef CONFIG_DEBUG_FS
66 #define CLOCK_DBG_NAME(x) .dbg_name = x,
67 #else
68 #define CLOCK_DBG_NAME(x)
69 #endif
70
71 #define CLOCK(clk_name, clk_id, clk_dev, clk_flags) {   \
72         .name = clk_name, \
73         .id = clk_id, \
74         .flags = clk_flags, \
75         .dev = clk_dev, \
76          CLOCK_DBG_NAME(#clk_id) \
77         }
78
79 #define OFF CLKFLAG_AUTO_OFF
80 #define CLK_MIN CLKFLAG_MIN
81 #define CLK_MAX CLKFLAG_MAX
82 #define CLK_MINMAX (CLK_MIN | CLK_MAX)
83 #define NR_CLKS P_NR_CLKS
84
85 enum {
86         PLL_0 = 0,
87         PLL_1,
88         PLL_2,
89         PLL_3,
90         PLL_4,
91         PLL_5,
92         PLL_6,
93         NUM_PLL
94 };
95
96 enum clkvote_client {
97         CLKVOTE_ACPUCLK = 0,
98         CLKVOTE_PMQOS,
99         CLKVOTE_MAX,
100 };
101
102 int msm_clock_require_tcxo(unsigned long *reason, int nbits);
103 int msm_clock_get_name(uint32_t id, char *name, uint32_t size);
104 int ebi1_clk_set_min_rate(enum clkvote_client client, unsigned long rate);
105 unsigned long clk_get_max_axi_khz(void);
106
107 #endif
108