diff options
author | viresh kumar <viresh.kumar@st.com> | 2011-02-16 01:40:39 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-03-09 04:49:45 -0500 |
commit | af89fd812b00a52c54a3b9b2290fae4d31c7be9a (patch) | |
tree | 3892de4165b23e98424f672c23b7a6d456ad235d /arch/arm/plat-spear/include | |
parent | cf285434ac0880f94bf4afdd90b06a4655f56570 (diff) |
ARM: 6703/1: SPEAr: update clk API support
- Add support for divisor per parent clock
- Add ENABLED_ON_INIT feature in clk
- Add clk_set_rate(), round_rate_index & clk_round_rate()
- Simplify clk_recalc functions
- Add/update clock definitions
Reviewed-by: Stanley Miao <stanley.miao@windriver.com>
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: shiraz hashim <shiraz.hashim@st.com>
Signed-off-by: Rajeev Kumar <rajeev-dlh.kumar@st.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/plat-spear/include')
-rw-r--r-- | arch/arm/plat-spear/include/plat/clock.h | 94 |
1 files changed, 82 insertions, 12 deletions
diff --git a/arch/arm/plat-spear/include/plat/clock.h b/arch/arm/plat-spear/include/plat/clock.h index 863d9e983927..5a601d830971 100644 --- a/arch/arm/plat-spear/include/plat/clock.h +++ b/arch/arm/plat-spear/include/plat/clock.h | |||
@@ -21,6 +21,7 @@ | |||
21 | /* clk structure flags */ | 21 | /* clk structure flags */ |
22 | #define ALWAYS_ENABLED (1 << 0) /* clock always enabled */ | 22 | #define ALWAYS_ENABLED (1 << 0) /* clock always enabled */ |
23 | #define RESET_TO_ENABLE (1 << 1) /* reset register bit to enable clk */ | 23 | #define RESET_TO_ENABLE (1 << 1) /* reset register bit to enable clk */ |
24 | #define ENABLED_ON_INIT (1 << 2) /* clocks enabled at init */ | ||
24 | 25 | ||
25 | /** | 26 | /** |
26 | * struct clkops - clock operations | 27 | * struct clkops - clock operations |
@@ -35,13 +36,11 @@ struct clkops { | |||
35 | /** | 36 | /** |
36 | * struct pclk_info - parents info | 37 | * struct pclk_info - parents info |
37 | * @pclk: pointer to parent clk | 38 | * @pclk: pointer to parent clk |
38 | * @pclk_mask: value to be written for selecting this parent | 39 | * @pclk_val: value to be written for selecting this parent |
39 | * @scalable: Is parent scalable (1 - YES, 0 - NO) | ||
40 | */ | 40 | */ |
41 | struct pclk_info { | 41 | struct pclk_info { |
42 | struct clk *pclk; | 42 | struct clk *pclk; |
43 | u8 pclk_mask; | 43 | u8 pclk_val; |
44 | u8 scalable; | ||
45 | }; | 44 | }; |
46 | 45 | ||
47 | /** | 46 | /** |
@@ -59,6 +58,18 @@ struct pclk_sel { | |||
59 | }; | 58 | }; |
60 | 59 | ||
61 | /** | 60 | /** |
61 | * struct rate_config - clk rate configurations | ||
62 | * @tbls: array of device specific clk rate tables, in ascending order of rates | ||
63 | * @count: size of tbls array | ||
64 | * @default_index: default setting when originally disabled | ||
65 | */ | ||
66 | struct rate_config { | ||
67 | void *tbls; | ||
68 | u8 count; | ||
69 | u8 default_index; | ||
70 | }; | ||
71 | |||
72 | /** | ||
62 | * struct clk - clock structure | 73 | * struct clk - clock structure |
63 | * @usage_count: num of users who enabled this clock | 74 | * @usage_count: num of users who enabled this clock |
64 | * @flags: flags for clock properties | 75 | * @flags: flags for clock properties |
@@ -67,7 +78,10 @@ struct pclk_sel { | |||
67 | * @en_reg_bit: clk enable/disable bit | 78 | * @en_reg_bit: clk enable/disable bit |
68 | * @ops: clk enable/disable ops - generic_clkops selected if NULL | 79 | * @ops: clk enable/disable ops - generic_clkops selected if NULL |
69 | * @recalc: pointer to clock rate recalculate function | 80 | * @recalc: pointer to clock rate recalculate function |
70 | * @div_factor: division factor to parent clock. Only for recalc = follow_parent | 81 | * @set_rate: pointer to clock set rate function |
82 | * @calc_rate: pointer to clock get rate function for index | ||
83 | * @rate_config: rate configuration information, used by set_rate | ||
84 | * @div_factor: division factor to parent clock. | ||
71 | * @pclk: current parent clk | 85 | * @pclk: current parent clk |
72 | * @pclk_sel: pointer to parent selection structure | 86 | * @pclk_sel: pointer to parent selection structure |
73 | * @pclk_sel_shift: register shift for selecting parent of this clock | 87 | * @pclk_sel_shift: register shift for selecting parent of this clock |
@@ -82,7 +96,10 @@ struct clk { | |||
82 | void __iomem *en_reg; | 96 | void __iomem *en_reg; |
83 | u8 en_reg_bit; | 97 | u8 en_reg_bit; |
84 | const struct clkops *ops; | 98 | const struct clkops *ops; |
85 | void (*recalc) (struct clk *); | 99 | int (*recalc) (struct clk *); |
100 | int (*set_rate) (struct clk *, unsigned long rate); | ||
101 | unsigned long (*calc_rate)(struct clk *, int index); | ||
102 | struct rate_config rate_config; | ||
86 | unsigned int div_factor; | 103 | unsigned int div_factor; |
87 | 104 | ||
88 | struct clk *pclk; | 105 | struct clk *pclk; |
@@ -115,6 +132,14 @@ struct pll_clk_config { | |||
115 | struct pll_clk_masks *masks; | 132 | struct pll_clk_masks *masks; |
116 | }; | 133 | }; |
117 | 134 | ||
135 | /* pll clk rate config structure */ | ||
136 | struct pll_rate_tbl { | ||
137 | u8 mode; | ||
138 | u16 m; | ||
139 | u8 n; | ||
140 | u8 p; | ||
141 | }; | ||
142 | |||
118 | /* ahb and apb bus configuration structure */ | 143 | /* ahb and apb bus configuration structure */ |
119 | struct bus_clk_masks { | 144 | struct bus_clk_masks { |
120 | u32 mask; | 145 | u32 mask; |
@@ -126,6 +151,11 @@ struct bus_clk_config { | |||
126 | struct bus_clk_masks *masks; | 151 | struct bus_clk_masks *masks; |
127 | }; | 152 | }; |
128 | 153 | ||
154 | /* ahb and apb clk bus rate config structure */ | ||
155 | struct bus_rate_tbl { | ||
156 | u8 div; | ||
157 | }; | ||
158 | |||
129 | /* Aux clk configuration structure: applicable to UART and FIRDA */ | 159 | /* Aux clk configuration structure: applicable to UART and FIRDA */ |
130 | struct aux_clk_masks { | 160 | struct aux_clk_masks { |
131 | u32 eq_sel_mask; | 161 | u32 eq_sel_mask; |
@@ -143,6 +173,13 @@ struct aux_clk_config { | |||
143 | struct aux_clk_masks *masks; | 173 | struct aux_clk_masks *masks; |
144 | }; | 174 | }; |
145 | 175 | ||
176 | /* aux clk rate config structure */ | ||
177 | struct aux_rate_tbl { | ||
178 | u16 xscale; | ||
179 | u16 yscale; | ||
180 | u8 eq; | ||
181 | }; | ||
182 | |||
146 | /* GPT clk configuration structure */ | 183 | /* GPT clk configuration structure */ |
147 | struct gpt_clk_masks { | 184 | struct gpt_clk_masks { |
148 | u32 mscale_sel_mask; | 185 | u32 mscale_sel_mask; |
@@ -156,15 +193,48 @@ struct gpt_clk_config { | |||
156 | struct gpt_clk_masks *masks; | 193 | struct gpt_clk_masks *masks; |
157 | }; | 194 | }; |
158 | 195 | ||
196 | /* gpt clk rate config structure */ | ||
197 | struct gpt_rate_tbl { | ||
198 | u16 mscale; | ||
199 | u16 nscale; | ||
200 | }; | ||
201 | |||
202 | /* clcd clk configuration structure */ | ||
203 | struct clcd_synth_masks { | ||
204 | u32 div_factor_mask; | ||
205 | u32 div_factor_shift; | ||
206 | }; | ||
207 | |||
208 | struct clcd_clk_config { | ||
209 | void __iomem *synth_reg; | ||
210 | struct clcd_synth_masks *masks; | ||
211 | }; | ||
212 | |||
213 | /* clcd clk rate config structure */ | ||
214 | struct clcd_rate_tbl { | ||
215 | u16 div; | ||
216 | }; | ||
217 | |||
159 | /* platform specific clock functions */ | 218 | /* platform specific clock functions */ |
160 | void clk_register(struct clk_lookup *cl); | 219 | void clk_register(struct clk_lookup *cl); |
161 | void recalc_root_clocks(void); | 220 | void recalc_root_clocks(void); |
162 | 221 | ||
163 | /* clock recalc functions */ | 222 | /* clock recalc & set rate functions */ |
164 | void follow_parent(struct clk *clk); | 223 | int follow_parent(struct clk *clk); |
165 | void pll_clk_recalc(struct clk *clk); | 224 | unsigned long pll_calc_rate(struct clk *clk, int index); |
166 | void bus_clk_recalc(struct clk *clk); | 225 | int pll_clk_recalc(struct clk *clk); |
167 | void gpt_clk_recalc(struct clk *clk); | 226 | int pll_clk_set_rate(struct clk *clk, unsigned long desired_rate); |
168 | void aux_clk_recalc(struct clk *clk); | 227 | unsigned long bus_calc_rate(struct clk *clk, int index); |
228 | int bus_clk_recalc(struct clk *clk); | ||
229 | int bus_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
230 | unsigned long gpt_calc_rate(struct clk *clk, int index); | ||
231 | int gpt_clk_recalc(struct clk *clk); | ||
232 | int gpt_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
233 | unsigned long aux_calc_rate(struct clk *clk, int index); | ||
234 | int aux_clk_recalc(struct clk *clk); | ||
235 | int aux_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
236 | unsigned long clcd_calc_rate(struct clk *clk, int index); | ||
237 | int clcd_clk_recalc(struct clk *clk); | ||
238 | int clcd_clk_set_rate(struct clk *clk, unsigned long desired_rate); | ||
169 | 239 | ||
170 | #endif /* __PLAT_CLOCK_H */ | 240 | #endif /* __PLAT_CLOCK_H */ |