blob: 4ee738a04a99bedf0f9ad50ff392f566d586439f [file] [log] [blame]
Pankaj Kumar3912c982011-12-07 16:59:03 +05301/*
2 * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
Vikram Mulukutla681d8682012-03-09 23:56:20 -080015#ifndef __ARCH_ARM_MACH_MSM_CLOCK_PLL_H
16#define __ARCH_ARM_MACH_MSM_CLOCK_PLL_H
17
Pankaj Kumar3912c982011-12-07 16:59:03 +053018/**
19 * enum - For PLL IDs
20 */
21enum {
22 PLL_TCXO = -1,
23 PLL_0 = 0,
24 PLL_1,
25 PLL_2,
26 PLL_3,
27 PLL_4,
28 PLL_END,
29};
30
31/**
32 * struct pll_shared_clk - PLL shared with other processors without
33 * any HW voting
34 * @id: PLL ID
35 * @mode_reg: enable register
36 * @parent: clock source
37 * @c: clk
38 */
39struct pll_shared_clk {
40 unsigned int id;
41 void __iomem *const mode_reg;
42 struct clk c;
Vikram Mulukutla4d6caa82012-04-10 18:04:55 -070043 void *const __iomem *base;
Pankaj Kumar3912c982011-12-07 16:59:03 +053044};
45
46extern struct clk_ops clk_pll_ops;
47
48static inline struct pll_shared_clk *to_pll_shared_clk(struct clk *clk)
49{
50 return container_of(clk, struct pll_shared_clk, c);
51}
52
53/**
54 * msm_shared_pll_control_init() - Initialize shared pll control structure
55 */
56void msm_shared_pll_control_init(void);
Vikram Mulukutla681d8682012-03-09 23:56:20 -080057
58/**
59 * struct pll_vote_clk - phase locked loop (HW voteable)
60 * @soft_vote: soft voting variable for multiple PLL software instances
61 * @soft_vote_mask: soft voting mask for multiple PLL software instances
62 * @en_reg: enable register
63 * @en_mask: ORed with @en_reg to enable the clock
64 * @status_mask: ANDed with @status_reg to determine if PLL is active.
65 * @status_reg: status register
66 * @parent: clock source
67 * @c: clk
68 */
69struct pll_vote_clk {
70 u32 *soft_vote;
71 const u32 soft_vote_mask;
72 void __iomem *const en_reg;
73 const u32 en_mask;
74 void __iomem *const status_reg;
75 const u32 status_mask;
76
77 struct clk *parent;
78 struct clk c;
Vikram Mulukutla4d6caa82012-04-10 18:04:55 -070079 void *const __iomem *base;
Vikram Mulukutla681d8682012-03-09 23:56:20 -080080};
81
82extern struct clk_ops clk_ops_pll_vote;
83
84static inline struct pll_vote_clk *to_pll_vote_clk(struct clk *clk)
85{
86 return container_of(clk, struct pll_vote_clk, c);
87}
88
89/**
90 * struct pll_clk - phase locked loop
91 * @mode_reg: enable register
92 * @parent: clock source
93 * @c: clk
94 */
95struct pll_clk {
96 void __iomem *const mode_reg;
97
98 struct clk *parent;
99 struct clk c;
Vikram Mulukutla4d6caa82012-04-10 18:04:55 -0700100 void *const __iomem *base;
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800101};
102
103extern struct clk_ops clk_ops_local_pll;
104
105static inline struct pll_clk *to_pll_clk(struct clk *clk)
106{
107 return container_of(clk, struct pll_clk, c);
108}
109
110int sr_pll_clk_enable(struct clk *clk);
111
112/*
113 * PLL vote clock APIs
114 */
115int pll_vote_clk_enable(struct clk *clk);
116void pll_vote_clk_disable(struct clk *clk);
117struct clk *pll_vote_clk_get_parent(struct clk *clk);
118int pll_vote_clk_is_enabled(struct clk *clk);
119
Vikram Mulukutla5b146722012-04-23 18:17:50 -0700120struct pll_config {
121 u32 l;
122 u32 m;
123 u32 n;
124 u32 vco_val;
125 u32 vco_mask;
126 u32 pre_div_val;
127 u32 pre_div_mask;
128 u32 post_div_val;
129 u32 post_div_mask;
130 u32 mn_ena_val;
131 u32 mn_ena_mask;
132 u32 main_output_val;
133 u32 main_output_mask;
134};
135
136struct pll_config_regs {
137 void __iomem *l_reg;
138 void __iomem *m_reg;
139 void __iomem *n_reg;
140 void __iomem *config_reg;
141 void __iomem *mode_reg;
142 void *const __iomem *base;
143};
144
145void __init configure_pll(struct pll_config *, struct pll_config_regs *, u32);
146
Vikram Mulukutla681d8682012-03-09 23:56:20 -0800147#endif