blob: 2a1c013c618df3a872b4df066f5751899cf211c3 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#define pr_fmt(fmt) "%s: " fmt, __func__
15
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/err.h>
19#include <linux/ctype.h>
20#include <linux/bitops.h>
21#include <linux/io.h>
22#include <linux/spinlock.h>
23#include <linux/delay.h>
24#include <linux/clk.h>
25
26#include <mach/msm_iomap.h>
27#include <mach/clk.h>
28#include <mach/scm-io.h>
29
30#include "clock.h"
31#include "clock-local.h"
32
33#ifdef CONFIG_MSM_SECURE_IO
34#undef readl_relaxed
35#undef writel_relaxed
36#define readl_relaxed secure_readl
37#define writel_relaxed secure_writel
38#endif
39
40/*
41 * When enabling/disabling a clock, check the halt bit up to this number
42 * number of times (with a 1 us delay in between) before continuing.
43 */
Stephen Boyd138da0e2011-08-05 13:25:57 -070044#define HALT_CHECK_MAX_LOOPS 200
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070045/* For clock without halt checking, wait this long after enables/disables. */
46#define HALT_CHECK_DELAY_US 10
47
48DEFINE_SPINLOCK(local_clock_reg_lock);
Matt Wagantall84f43fd2011-08-16 23:28:38 -070049struct clk_freq_tbl rcg_dummy_freq = F_END;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051/*
52 * Common Set-Rate Functions
53 */
54
55/* For clocks with MND dividers. */
56void set_rate_mnd(struct rcg_clk *clk, struct clk_freq_tbl *nf)
57{
58 uint32_t ns_reg_val, ctl_reg_val;
59
60 /* Assert MND reset. */
61 ns_reg_val = readl_relaxed(clk->ns_reg);
62 ns_reg_val |= BIT(7);
63 writel_relaxed(ns_reg_val, clk->ns_reg);
64
65 /* Program M and D values. */
66 writel_relaxed(nf->md_val, clk->md_reg);
67
68 /* If the clock has a separate CC register, program it. */
69 if (clk->ns_reg != clk->b.ctl_reg) {
70 ctl_reg_val = readl_relaxed(clk->b.ctl_reg);
71 ctl_reg_val &= ~(clk->ctl_mask);
72 ctl_reg_val |= nf->ctl_val;
73 writel_relaxed(ctl_reg_val, clk->b.ctl_reg);
74 }
75
76 /* Deassert MND reset. */
77 ns_reg_val &= ~BIT(7);
78 writel_relaxed(ns_reg_val, clk->ns_reg);
79}
80
81void set_rate_nop(struct rcg_clk *clk, struct clk_freq_tbl *nf)
82{
83 /*
84 * Nothing to do for fixed-rate or integer-divider clocks. Any settings
85 * in NS registers are applied in the enable path, since power can be
86 * saved by leaving an un-clocked or slowly-clocked source selected
87 * until the clock is enabled.
88 */
89}
90
91void set_rate_mnd_8(struct rcg_clk *clk, struct clk_freq_tbl *nf)
92{
93 uint32_t ctl_reg_val;
94
95 /* Assert MND reset. */
96 ctl_reg_val = readl_relaxed(clk->b.ctl_reg);
97 ctl_reg_val |= BIT(8);
98 writel_relaxed(ctl_reg_val, clk->b.ctl_reg);
99
100 /* Program M and D values. */
101 writel_relaxed(nf->md_val, clk->md_reg);
102
103 /* Program MN counter Enable and Mode. */
104 ctl_reg_val &= ~(clk->ctl_mask);
105 ctl_reg_val |= nf->ctl_val;
106 writel_relaxed(ctl_reg_val, clk->b.ctl_reg);
107
108 /* Deassert MND reset. */
109 ctl_reg_val &= ~BIT(8);
110 writel_relaxed(ctl_reg_val, clk->b.ctl_reg);
111}
112
113void set_rate_mnd_banked(struct rcg_clk *clk, struct clk_freq_tbl *nf)
114{
Stephen Boydc78d9a72011-07-20 00:46:24 -0700115 struct bank_masks *banks = clk->bank_info;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700116 const struct bank_mask_info *new_bank_masks;
117 const struct bank_mask_info *old_bank_masks;
118 uint32_t ns_reg_val, ctl_reg_val;
119 uint32_t bank_sel;
120
121 /*
122 * Determine active bank and program the other one. If the clock is
123 * off, program the active bank since bank switching won't work if
124 * both banks aren't running.
125 */
126 ctl_reg_val = readl_relaxed(clk->b.ctl_reg);
127 bank_sel = !!(ctl_reg_val & banks->bank_sel_mask);
128 /* If clock isn't running, don't switch banks. */
129 bank_sel ^= (!clk->enabled || clk->current_freq->freq_hz == 0);
130 if (bank_sel == 0) {
131 new_bank_masks = &banks->bank1_mask;
132 old_bank_masks = &banks->bank0_mask;
133 } else {
134 new_bank_masks = &banks->bank0_mask;
135 old_bank_masks = &banks->bank1_mask;
136 }
137
138 ns_reg_val = readl_relaxed(clk->ns_reg);
139
140 /* Assert bank MND reset. */
141 ns_reg_val |= new_bank_masks->rst_mask;
142 writel_relaxed(ns_reg_val, clk->ns_reg);
143
144 /*
145 * Program NS only if the clock is enabled, since the NS will be set
146 * as part of the enable procedure and should remain with a low-power
147 * MUX input selected until then.
148 */
149 if (clk->enabled) {
150 ns_reg_val &= ~(new_bank_masks->ns_mask);
151 ns_reg_val |= (nf->ns_val & new_bank_masks->ns_mask);
152 writel_relaxed(ns_reg_val, clk->ns_reg);
153 }
154
155 writel_relaxed(nf->md_val, new_bank_masks->md_reg);
156
157 /* Enable counter only if clock is enabled. */
158 if (clk->enabled)
159 ctl_reg_val |= new_bank_masks->mnd_en_mask;
160 else
161 ctl_reg_val &= ~(new_bank_masks->mnd_en_mask);
162
163 ctl_reg_val &= ~(new_bank_masks->mode_mask);
164 ctl_reg_val |= (nf->ctl_val & new_bank_masks->mode_mask);
165 writel_relaxed(ctl_reg_val, clk->b.ctl_reg);
166
167 /* Deassert bank MND reset. */
168 ns_reg_val &= ~(new_bank_masks->rst_mask);
169 writel_relaxed(ns_reg_val, clk->ns_reg);
170
171 /*
172 * Switch to the new bank if clock is running. If it isn't, then
173 * no switch is necessary since we programmed the active bank.
174 */
175 if (clk->enabled && clk->current_freq->freq_hz) {
176 ctl_reg_val ^= banks->bank_sel_mask;
177 writel_relaxed(ctl_reg_val, clk->b.ctl_reg);
178 /*
179 * Wait at least 6 cycles of slowest bank's clock
180 * for the glitch-free MUX to fully switch sources.
181 */
182 mb();
183 udelay(1);
184
185 /* Disable old bank's MN counter. */
186 ctl_reg_val &= ~(old_bank_masks->mnd_en_mask);
187 writel_relaxed(ctl_reg_val, clk->b.ctl_reg);
188
189 /* Program old bank to a low-power source and divider. */
190 ns_reg_val &= ~(old_bank_masks->ns_mask);
191 ns_reg_val |= (clk->freq_tbl->ns_val & old_bank_masks->ns_mask);
192 writel_relaxed(ns_reg_val, clk->ns_reg);
193 }
194
195 /*
196 * If this freq requires the MN counter to be enabled,
197 * update the enable mask to match the current bank.
198 */
199 if (nf->mnd_en_mask)
200 nf->mnd_en_mask = new_bank_masks->mnd_en_mask;
201 /* Update the NS mask to match the current bank. */
202 clk->ns_mask = new_bank_masks->ns_mask;
203}
204
205void set_rate_div_banked(struct rcg_clk *clk, struct clk_freq_tbl *nf)
206{
Stephen Boydc78d9a72011-07-20 00:46:24 -0700207 struct bank_masks *banks = clk->bank_info;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700208 const struct bank_mask_info *new_bank_masks;
209 const struct bank_mask_info *old_bank_masks;
210 uint32_t ns_reg_val, bank_sel;
211
212 /*
213 * Determine active bank and program the other one. If the clock is
214 * off, program the active bank since bank switching won't work if
215 * both banks aren't running.
216 */
217 ns_reg_val = readl_relaxed(clk->ns_reg);
218 bank_sel = !!(ns_reg_val & banks->bank_sel_mask);
219 /* If clock isn't running, don't switch banks. */
220 bank_sel ^= (!clk->enabled || clk->current_freq->freq_hz == 0);
221 if (bank_sel == 0) {
222 new_bank_masks = &banks->bank1_mask;
223 old_bank_masks = &banks->bank0_mask;
224 } else {
225 new_bank_masks = &banks->bank0_mask;
226 old_bank_masks = &banks->bank1_mask;
227 }
228
229 /*
230 * Program NS only if the clock is enabled, since the NS will be set
231 * as part of the enable procedure and should remain with a low-power
232 * MUX input selected until then.
233 */
234 if (clk->enabled) {
235 ns_reg_val &= ~(new_bank_masks->ns_mask);
236 ns_reg_val |= (nf->ns_val & new_bank_masks->ns_mask);
237 writel_relaxed(ns_reg_val, clk->ns_reg);
238 }
239
240 /*
241 * Switch to the new bank if clock is running. If it isn't, then
242 * no switch is necessary since we programmed the active bank.
243 */
244 if (clk->enabled && clk->current_freq->freq_hz) {
245 ns_reg_val ^= banks->bank_sel_mask;
246 writel_relaxed(ns_reg_val, clk->ns_reg);
247 /*
248 * Wait at least 6 cycles of slowest bank's clock
249 * for the glitch-free MUX to fully switch sources.
250 */
251 mb();
252 udelay(1);
253
254 /* Program old bank to a low-power source and divider. */
255 ns_reg_val &= ~(old_bank_masks->ns_mask);
256 ns_reg_val |= (clk->freq_tbl->ns_val & old_bank_masks->ns_mask);
257 writel_relaxed(ns_reg_val, clk->ns_reg);
258 }
259
260 /* Update the NS mask to match the current bank. */
261 clk->ns_mask = new_bank_masks->ns_mask;
262}
263
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700264/*
265 * Clock enable/disable functions
266 */
267
268/* Return non-zero if a clock status registers shows the clock is halted. */
269static int branch_clk_is_halted(const struct branch *clk)
270{
271 int invert = (clk->halt_check == ENABLE);
272 int status_bit = readl_relaxed(clk->halt_reg) & BIT(clk->halt_bit);
273 return invert ? !status_bit : status_bit;
274}
275
Stephen Boyda52d7e32011-11-10 11:59:00 -0800276int branch_in_hwcg_mode(const struct branch *b)
277{
278 if (!b->hwcg_mask)
279 return 0;
280
281 return !!(readl_relaxed(b->hwcg_reg) & b->hwcg_mask);
282}
283
Stephen Boyd092fd182011-10-21 15:56:30 -0700284void __branch_clk_enable_reg(const struct branch *clk, const char *name)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700285{
286 u32 reg_val;
287
288 if (clk->en_mask) {
289 reg_val = readl_relaxed(clk->ctl_reg);
290 reg_val |= clk->en_mask;
291 writel_relaxed(reg_val, clk->ctl_reg);
292 }
293
294 /*
295 * Use a memory barrier since some halt status registers are
296 * not within the same 1K segment as the branch/root enable
297 * registers. It's also needed in the udelay() case to ensure
298 * the delay starts after the branch enable.
299 */
300 mb();
301
Stephen Boyda52d7e32011-11-10 11:59:00 -0800302 /* Skip checking halt bit if the clock is in hardware gated mode */
303 if (branch_in_hwcg_mode(clk))
304 return;
305
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700306 /* Wait for clock to enable before returning. */
307 if (clk->halt_check == DELAY)
308 udelay(HALT_CHECK_DELAY_US);
309 else if (clk->halt_check == ENABLE || clk->halt_check == HALT
310 || clk->halt_check == ENABLE_VOTED
311 || clk->halt_check == HALT_VOTED) {
312 int count;
313
314 /* Wait up to HALT_CHECK_MAX_LOOPS for clock to enable. */
315 for (count = HALT_CHECK_MAX_LOOPS; branch_clk_is_halted(clk)
316 && count > 0; count--)
317 udelay(1);
318 WARN(count == 0, "%s status stuck at 'off'", name);
319 }
320}
321
322/* Perform any register operations required to enable the clock. */
Matt Wagantall0625ea02011-07-13 18:51:56 -0700323static void __rcg_clk_enable_reg(struct rcg_clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700324{
325 u32 reg_val;
326 void __iomem *const reg = clk->b.ctl_reg;
327
Matt Wagantall84f43fd2011-08-16 23:28:38 -0700328 WARN(clk->current_freq == &rcg_dummy_freq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700329 "Attempting to enable %s before setting its rate. "
330 "Set the rate first!\n", clk->c.dbg_name);
331
332 /*
333 * Program the NS register, if applicable. NS registers are not
334 * set in the set_rate path because power can be saved by deferring
335 * the selection of a clocked source until the clock is enabled.
336 */
337 if (clk->ns_mask) {
338 reg_val = readl_relaxed(clk->ns_reg);
339 reg_val &= ~(clk->ns_mask);
340 reg_val |= (clk->current_freq->ns_val & clk->ns_mask);
341 writel_relaxed(reg_val, clk->ns_reg);
342 }
343
344 /* Enable MN counter, if applicable. */
345 reg_val = readl_relaxed(reg);
346 if (clk->current_freq->mnd_en_mask) {
347 reg_val |= clk->current_freq->mnd_en_mask;
348 writel_relaxed(reg_val, reg);
349 }
350 /* Enable root. */
351 if (clk->root_en_mask) {
352 reg_val |= clk->root_en_mask;
353 writel_relaxed(reg_val, reg);
354 }
355 __branch_clk_enable_reg(&clk->b, clk->c.dbg_name);
356}
357
358/* Perform any register operations required to disable the branch. */
Stephen Boyd092fd182011-10-21 15:56:30 -0700359u32 __branch_clk_disable_reg(const struct branch *clk, const char *name)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700360{
361 u32 reg_val;
362
363 reg_val = readl_relaxed(clk->ctl_reg);
364 if (clk->en_mask) {
365 reg_val &= ~(clk->en_mask);
366 writel_relaxed(reg_val, clk->ctl_reg);
367 }
368
369 /*
370 * Use a memory barrier since some halt status registers are
371 * not within the same K segment as the branch/root enable
372 * registers. It's also needed in the udelay() case to ensure
373 * the delay starts after the branch disable.
374 */
375 mb();
376
Stephen Boyda52d7e32011-11-10 11:59:00 -0800377 /* Skip checking halt bit if the clock is in hardware gated mode */
378 if (branch_in_hwcg_mode(clk))
379 return reg_val;
380
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700381 /* Wait for clock to disable before continuing. */
382 if (clk->halt_check == DELAY || clk->halt_check == ENABLE_VOTED
383 || clk->halt_check == HALT_VOTED)
384 udelay(HALT_CHECK_DELAY_US);
385 else if (clk->halt_check == ENABLE || clk->halt_check == HALT) {
386 int count;
387
388 /* Wait up to HALT_CHECK_MAX_LOOPS for clock to disable. */
389 for (count = HALT_CHECK_MAX_LOOPS; !branch_clk_is_halted(clk)
390 && count > 0; count--)
391 udelay(1);
392 WARN(count == 0, "%s status stuck at 'on'", name);
393 }
394
395 return reg_val;
396}
397
398/* Perform any register operations required to disable the generator. */
Matt Wagantall0625ea02011-07-13 18:51:56 -0700399static void __rcg_clk_disable_reg(struct rcg_clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700400{
401 void __iomem *const reg = clk->b.ctl_reg;
402 uint32_t reg_val;
403
404 reg_val = __branch_clk_disable_reg(&clk->b, clk->c.dbg_name);
405 /* Disable root. */
406 if (clk->root_en_mask) {
407 reg_val &= ~(clk->root_en_mask);
408 writel_relaxed(reg_val, reg);
409 }
410 /* Disable MN counter, if applicable. */
411 if (clk->current_freq->mnd_en_mask) {
412 reg_val &= ~(clk->current_freq->mnd_en_mask);
413 writel_relaxed(reg_val, reg);
414 }
415 /*
416 * Program NS register to low-power value with an un-clocked or
417 * slowly-clocked source selected.
418 */
419 if (clk->ns_mask) {
420 reg_val = readl_relaxed(clk->ns_reg);
421 reg_val &= ~(clk->ns_mask);
422 reg_val |= (clk->freq_tbl->ns_val & clk->ns_mask);
423 writel_relaxed(reg_val, clk->ns_reg);
424 }
425}
426
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700427/* Enable a rate-settable clock. */
428int rcg_clk_enable(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700429{
430 unsigned long flags;
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700431 struct rcg_clk *clk = to_rcg_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700432
433 spin_lock_irqsave(&local_clock_reg_lock, flags);
Matt Wagantall0625ea02011-07-13 18:51:56 -0700434 __rcg_clk_enable_reg(clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700435 clk->enabled = true;
436 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700437
438 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700439}
440
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700441/* Disable a rate-settable clock. */
442void rcg_clk_disable(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700443{
444 unsigned long flags;
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700445 struct rcg_clk *clk = to_rcg_clk(c);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700446
447 spin_lock_irqsave(&local_clock_reg_lock, flags);
Matt Wagantall0625ea02011-07-13 18:51:56 -0700448 __rcg_clk_disable_reg(clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700449 clk->enabled = false;
450 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
451}
452
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700453/*
454 * Frequency-related functions
455 */
456
457/* Set a clock's frequency. */
Matt Wagantall0625ea02011-07-13 18:51:56 -0700458static int _rcg_clk_set_rate(struct rcg_clk *clk, struct clk_freq_tbl *nf)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700459{
460 struct clk_freq_tbl *cf;
461 int rc = 0;
462 struct clk *chld;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700463
464 /* Check if frequency is actually changed. */
465 cf = clk->current_freq;
466 if (nf == cf)
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700467 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700468
469 if (clk->enabled) {
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700470 /* Enable source clock dependency for the new freq. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700471 rc = clk_enable(nf->src_clk);
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700472 if (rc)
473 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700474 }
475
476 spin_lock(&local_clock_reg_lock);
477
478 /* Disable branch if clock isn't dual-banked with a glitch-free MUX. */
Stephen Boydc78d9a72011-07-20 00:46:24 -0700479 if (!clk->bank_info) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700480 /* Disable all branches to prevent glitches. */
481 list_for_each_entry(chld, &clk->c.children, siblings) {
482 struct branch_clk *x = to_branch_clk(chld);
483 /*
484 * We don't need to grab the child's lock because
485 * we hold the local_clock_reg_lock and 'enabled' is
486 * only modified within lock.
487 */
488 if (x->enabled)
489 __branch_clk_disable_reg(&x->b, x->c.dbg_name);
490 }
491 if (clk->enabled)
Matt Wagantall0625ea02011-07-13 18:51:56 -0700492 __rcg_clk_disable_reg(clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700493 }
494
495 /* Perform clock-specific frequency switch operations. */
496 BUG_ON(!clk->set_rate);
497 clk->set_rate(clk, nf);
498
499 /*
Matt Wagantall0625ea02011-07-13 18:51:56 -0700500 * Current freq must be updated before __rcg_clk_enable_reg()
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700501 * is called to make sure the MNCNTR_EN bit is set correctly.
502 */
503 clk->current_freq = nf;
504
505 /* Enable any clocks that were disabled. */
Stephen Boydc78d9a72011-07-20 00:46:24 -0700506 if (!clk->bank_info) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700507 if (clk->enabled)
Matt Wagantall0625ea02011-07-13 18:51:56 -0700508 __rcg_clk_enable_reg(clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700509 /* Enable only branches that were ON before. */
510 list_for_each_entry(chld, &clk->c.children, siblings) {
511 struct branch_clk *x = to_branch_clk(chld);
512 if (x->enabled)
513 __branch_clk_enable_reg(&x->b, x->c.dbg_name);
514 }
515 }
516
517 spin_unlock(&local_clock_reg_lock);
518
Matt Wagantalle18bbc82011-10-06 10:07:28 -0700519 /* Release source requirements of the old freq. */
520 if (clk->enabled)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700521 clk_disable(cf->src_clk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700522
523 return rc;
524}
525
526/* Set a clock to an exact rate. */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -0700527int rcg_clk_set_rate(struct clk *c, unsigned long rate)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700528{
529 struct rcg_clk *clk = to_rcg_clk(c);
530 struct clk_freq_tbl *nf;
531
532 for (nf = clk->freq_tbl; nf->freq_hz != FREQ_END
533 && nf->freq_hz != rate; nf++)
534 ;
535
536 if (nf->freq_hz == FREQ_END)
537 return -EINVAL;
538
Matt Wagantall0625ea02011-07-13 18:51:56 -0700539 return _rcg_clk_set_rate(clk, nf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700540}
541
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700542/* Get the currently-set rate of a clock in Hz. */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -0700543unsigned long rcg_clk_get_rate(struct clk *c)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700544{
545 struct rcg_clk *clk = to_rcg_clk(c);
546 unsigned long flags;
547 unsigned ret = 0;
548
549 spin_lock_irqsave(&local_clock_reg_lock, flags);
550 ret = clk->current_freq->freq_hz;
551 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
552
553 /*
554 * Return 0 if the rate has never been set. Might not be correct,
555 * but it's good enough.
556 */
557 if (ret == FREQ_END)
558 ret = 0;
559
560 return ret;
561}
562
563/* Check if a clock is currently enabled. */
Matt Wagantall0625ea02011-07-13 18:51:56 -0700564int rcg_clk_is_enabled(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700565{
566 return to_rcg_clk(clk)->enabled;
567}
568
569/* Return a supported rate that's at least the specified rate. */
Matt Wagantall9de3bfb2011-11-03 20:13:12 -0700570long rcg_clk_round_rate(struct clk *c, unsigned long rate)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700571{
572 struct rcg_clk *clk = to_rcg_clk(c);
573 struct clk_freq_tbl *f;
574
575 for (f = clk->freq_tbl; f->freq_hz != FREQ_END; f++)
576 if (f->freq_hz >= rate)
577 return f->freq_hz;
578
579 return -EPERM;
580}
581
582bool local_clk_is_local(struct clk *clk)
583{
584 return true;
585}
586
587/* Return the nth supported frequency for a given clock. */
Matt Wagantall0625ea02011-07-13 18:51:56 -0700588int rcg_clk_list_rate(struct clk *c, unsigned n)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700589{
590 struct rcg_clk *clk = to_rcg_clk(c);
591
592 if (!clk->freq_tbl || clk->freq_tbl->freq_hz == FREQ_END)
593 return -ENXIO;
594
595 return (clk->freq_tbl + n)->freq_hz;
596}
597
Matt Wagantall0625ea02011-07-13 18:51:56 -0700598struct clk *rcg_clk_get_parent(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700599{
600 return to_rcg_clk(clk)->current_freq->src_clk;
601}
602
Stephen Boyda52d7e32011-11-10 11:59:00 -0800603/* Disable hw clock gating if not set at boot */
604static void branch_handoff(struct branch *clk, struct clk *c)
605{
606 if (!branch_in_hwcg_mode(clk)) {
607 clk->hwcg_mask = 0;
608 c->flags &= ~CLKFLAG_HWCG;
609 } else {
610 c->flags |= CLKFLAG_HWCG;
611 }
612}
613
614int branch_clk_handoff(struct clk *c)
615{
616 struct branch_clk *clk = to_branch_clk(c);
617 branch_handoff(&clk->b, &clk->c);
618 return 0;
619}
620
Matt Wagantall271a6cd2011-09-20 16:06:31 -0700621int rcg_clk_handoff(struct clk *c)
Matt Wagantall14dc2af2011-08-12 13:16:06 -0700622{
623 struct rcg_clk *clk = to_rcg_clk(c);
624 uint32_t ctl_val, ns_val, md_val, ns_mask;
625 struct clk_freq_tbl *freq;
626
Stephen Boyda52d7e32011-11-10 11:59:00 -0800627 branch_handoff(&clk->b, &clk->c);
628
Matt Wagantall14dc2af2011-08-12 13:16:06 -0700629 ctl_val = readl_relaxed(clk->b.ctl_reg);
630 if (!(ctl_val & clk->root_en_mask))
Matt Wagantall271a6cd2011-09-20 16:06:31 -0700631 return 0;
Matt Wagantall14dc2af2011-08-12 13:16:06 -0700632
Stephen Boydc78d9a72011-07-20 00:46:24 -0700633 if (clk->bank_info) {
634 const struct bank_masks *bank_masks = clk->bank_info;
Matt Wagantall14dc2af2011-08-12 13:16:06 -0700635 const struct bank_mask_info *bank_info;
Stephen Boydc78d9a72011-07-20 00:46:24 -0700636 if (!(ctl_val & bank_masks->bank_sel_mask))
637 bank_info = &bank_masks->bank0_mask;
Matt Wagantall14dc2af2011-08-12 13:16:06 -0700638 else
Stephen Boydc78d9a72011-07-20 00:46:24 -0700639 bank_info = &bank_masks->bank1_mask;
Matt Wagantall14dc2af2011-08-12 13:16:06 -0700640
641 ns_mask = bank_info->ns_mask;
642 md_val = readl_relaxed(bank_info->md_reg);
643 } else {
644 ns_mask = clk->ns_mask;
645 md_val = clk->md_reg ? readl_relaxed(clk->md_reg) : 0;
646 }
647
648 ns_val = readl_relaxed(clk->ns_reg) & ns_mask;
649 for (freq = clk->freq_tbl; freq->freq_hz != FREQ_END; freq++) {
650 if ((freq->ns_val & ns_mask) == ns_val &&
651 (freq->mnd_en_mask || freq->md_val == md_val)) {
652 pr_info("%s rate=%d\n", clk->c.dbg_name, freq->freq_hz);
653 break;
654 }
655 }
656 if (freq->freq_hz == FREQ_END)
Matt Wagantall271a6cd2011-09-20 16:06:31 -0700657 return 0;
Matt Wagantall14dc2af2011-08-12 13:16:06 -0700658
659 clk->current_freq = freq;
Matt Wagantall271a6cd2011-09-20 16:06:31 -0700660
661 return 1;
Matt Wagantall14dc2af2011-08-12 13:16:06 -0700662}
663
Vikram Mulukutla31680ae2011-11-04 14:23:55 -0700664int pll_vote_clk_enable(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700665{
666 u32 ena;
667 unsigned long flags;
668 struct pll_vote_clk *pll = to_pll_vote_clk(clk);
669
670 spin_lock_irqsave(&local_clock_reg_lock, flags);
671 ena = readl_relaxed(pll->en_reg);
672 ena |= pll->en_mask;
673 writel_relaxed(ena, pll->en_reg);
674 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
675
676 /* Wait until PLL is enabled */
677 while ((readl_relaxed(pll->status_reg) & BIT(16)) == 0)
678 cpu_relax();
679
680 return 0;
681}
682
Vikram Mulukutla31680ae2011-11-04 14:23:55 -0700683void pll_vote_clk_disable(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700684{
685 u32 ena;
686 unsigned long flags;
687 struct pll_vote_clk *pll = to_pll_vote_clk(clk);
688
689 spin_lock_irqsave(&local_clock_reg_lock, flags);
690 ena = readl_relaxed(pll->en_reg);
691 ena &= ~(pll->en_mask);
692 writel_relaxed(ena, pll->en_reg);
693 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
694}
695
Vikram Mulukutla31680ae2011-11-04 14:23:55 -0700696unsigned long pll_vote_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700697{
698 struct pll_vote_clk *pll = to_pll_vote_clk(clk);
699 return pll->rate;
700}
701
Vikram Mulukutla31680ae2011-11-04 14:23:55 -0700702struct clk *pll_vote_clk_get_parent(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700703{
704 struct pll_vote_clk *pll = to_pll_vote_clk(clk);
705 return pll->parent;
706}
707
Vikram Mulukutla31680ae2011-11-04 14:23:55 -0700708int pll_vote_clk_is_enabled(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700709{
710 struct pll_vote_clk *pll = to_pll_vote_clk(clk);
711 return !!(readl_relaxed(pll->status_reg) & BIT(16));
712}
713
714struct clk_ops clk_ops_pll_vote = {
715 .enable = pll_vote_clk_enable,
716 .disable = pll_vote_clk_disable,
Matt Wagantalle3d939d2011-11-06 11:21:37 -0800717 .auto_off = pll_vote_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700718 .is_enabled = pll_vote_clk_is_enabled,
719 .get_rate = pll_vote_clk_get_rate,
720 .get_parent = pll_vote_clk_get_parent,
721 .is_local = local_clk_is_local,
722};
723
724static int pll_clk_enable(struct clk *clk)
725{
726 u32 mode;
727 unsigned long flags;
728 struct pll_clk *pll = to_pll_clk(clk);
729
730 spin_lock_irqsave(&local_clock_reg_lock, flags);
731 mode = readl_relaxed(pll->mode_reg);
732 /* Disable PLL bypass mode. */
733 mode |= BIT(1);
734 writel_relaxed(mode, pll->mode_reg);
735
736 /*
737 * H/W requires a 5us delay between disabling the bypass and
738 * de-asserting the reset. Delay 10us just to be safe.
739 */
740 mb();
741 udelay(10);
742
743 /* De-assert active-low PLL reset. */
744 mode |= BIT(2);
745 writel_relaxed(mode, pll->mode_reg);
746
747 /* Wait until PLL is locked. */
748 mb();
749 udelay(50);
750
751 /* Enable PLL output. */
752 mode |= BIT(0);
753 writel_relaxed(mode, pll->mode_reg);
754
755 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
756 return 0;
757}
758
759static void pll_clk_disable(struct clk *clk)
760{
761 u32 mode;
762 unsigned long flags;
763 struct pll_clk *pll = to_pll_clk(clk);
764
765 /*
766 * Disable the PLL output, disable test mode, enable
767 * the bypass mode, and assert the reset.
768 */
769 spin_lock_irqsave(&local_clock_reg_lock, flags);
770 mode = readl_relaxed(pll->mode_reg);
771 mode &= ~BM(3, 0);
772 writel_relaxed(mode, pll->mode_reg);
773 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
774}
775
Matt Wagantall9de3bfb2011-11-03 20:13:12 -0700776static unsigned long pll_clk_get_rate(struct clk *clk)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700777{
778 struct pll_clk *pll = to_pll_clk(clk);
779 return pll->rate;
780}
781
782static struct clk *pll_clk_get_parent(struct clk *clk)
783{
784 struct pll_clk *pll = to_pll_clk(clk);
785 return pll->parent;
786}
787
Vikram Mulukutla489e39e2011-08-31 18:04:05 -0700788int sr_pll_clk_enable(struct clk *clk)
789{
790 u32 mode;
791 unsigned long flags;
792 struct pll_clk *pll = to_pll_clk(clk);
793
794 spin_lock_irqsave(&local_clock_reg_lock, flags);
795 mode = readl_relaxed(pll->mode_reg);
796 /* De-assert active-low PLL reset. */
797 mode |= BIT(2);
798 writel_relaxed(mode, pll->mode_reg);
799
800 /*
801 * H/W requires a 5us delay between disabling the bypass and
802 * de-asserting the reset. Delay 10us just to be safe.
803 */
804 mb();
805 udelay(10);
806
807 /* Disable PLL bypass mode. */
808 mode |= BIT(1);
809 writel_relaxed(mode, pll->mode_reg);
810
811 /* Wait until PLL is locked. */
812 mb();
813 udelay(60);
814
815 /* Enable PLL output. */
816 mode |= BIT(0);
817 writel_relaxed(mode, pll->mode_reg);
818
819 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
820 return 0;
821}
822
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700823struct clk_ops clk_ops_pll = {
824 .enable = pll_clk_enable,
825 .disable = pll_clk_disable,
Matt Wagantalle3d939d2011-11-06 11:21:37 -0800826 .auto_off = pll_clk_disable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700827 .get_rate = pll_clk_get_rate,
828 .get_parent = pll_clk_get_parent,
829 .is_local = local_clk_is_local,
830};
831
832struct clk_ops clk_ops_gnd = {
833 .get_rate = fixed_clk_get_rate,
834 .is_local = local_clk_is_local,
835};
836
837struct fixed_clk gnd_clk = {
838 .c = {
839 .dbg_name = "ground_clk",
840 .ops = &clk_ops_gnd,
841 CLK_INIT(gnd_clk.c),
842 },
843};
844
845struct clk_ops clk_ops_measure = {
846 .is_local = local_clk_is_local,
847};
848
849int branch_clk_enable(struct clk *clk)
850{
851 unsigned long flags;
852 struct branch_clk *branch = to_branch_clk(clk);
853
854 spin_lock_irqsave(&local_clock_reg_lock, flags);
855 __branch_clk_enable_reg(&branch->b, branch->c.dbg_name);
856 branch->enabled = true;
857 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
858
859 return 0;
860}
861
862void branch_clk_disable(struct clk *clk)
863{
864 unsigned long flags;
865 struct branch_clk *branch = to_branch_clk(clk);
866
867 spin_lock_irqsave(&local_clock_reg_lock, flags);
868 __branch_clk_disable_reg(&branch->b, branch->c.dbg_name);
869 branch->enabled = false;
870 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700871}
872
873struct clk *branch_clk_get_parent(struct clk *clk)
874{
875 struct branch_clk *branch = to_branch_clk(clk);
876 return branch->parent;
877}
878
879int branch_clk_set_parent(struct clk *clk, struct clk *parent)
880{
881 /*
882 * We setup the parent pointer at init time in msm_clock_init().
883 * This check is to make sure drivers can't change the parent.
884 */
885 if (parent && list_empty(&clk->siblings)) {
886 list_add(&clk->siblings, &parent->children);
887 return 0;
888 }
889 return -EINVAL;
890}
891
892int branch_clk_is_enabled(struct clk *clk)
893{
894 struct branch_clk *branch = to_branch_clk(clk);
895 return branch->enabled;
896}
897
Stephen Boyda52d7e32011-11-10 11:59:00 -0800898static void branch_enable_hwcg(struct branch *b)
899{
900 unsigned long flags;
901 u32 reg_val;
902
903 spin_lock_irqsave(&local_clock_reg_lock, flags);
904 reg_val = readl_relaxed(b->hwcg_reg);
905 reg_val |= b->hwcg_mask;
906 writel_relaxed(reg_val, b->hwcg_reg);
907 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
908}
909
910static void branch_disable_hwcg(struct branch *b)
911{
912 unsigned long flags;
913 u32 reg_val;
914
915 spin_lock_irqsave(&local_clock_reg_lock, flags);
916 reg_val = readl_relaxed(b->hwcg_reg);
917 reg_val &= ~b->hwcg_mask;
918 writel_relaxed(reg_val, b->hwcg_reg);
919 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
920}
921
922void branch_clk_enable_hwcg(struct clk *clk)
923{
924 struct branch_clk *branch = to_branch_clk(clk);
925 branch_enable_hwcg(&branch->b);
926}
927
928void branch_clk_disable_hwcg(struct clk *clk)
929{
930 struct branch_clk *branch = to_branch_clk(clk);
931 branch_disable_hwcg(&branch->b);
932}
933
934int branch_clk_in_hwcg_mode(struct clk *c)
935{
936 struct branch_clk *clk = to_branch_clk(c);
937 return branch_in_hwcg_mode(&clk->b);
938}
939
940void rcg_clk_enable_hwcg(struct clk *clk)
941{
942 struct rcg_clk *rcg = to_rcg_clk(clk);
943 branch_enable_hwcg(&rcg->b);
944}
945
946void rcg_clk_disable_hwcg(struct clk *clk)
947{
948 struct rcg_clk *rcg = to_rcg_clk(clk);
949 branch_disable_hwcg(&rcg->b);
950}
951
952int rcg_clk_in_hwcg_mode(struct clk *c)
953{
954 struct rcg_clk *clk = to_rcg_clk(c);
955 return branch_in_hwcg_mode(&clk->b);
956}
957
958int branch_reset(struct branch *b, enum clk_reset_action action)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700959{
960 int ret = 0;
961 u32 reg_val;
962 unsigned long flags;
963
Stephen Boyda52d7e32011-11-10 11:59:00 -0800964 if (!b->reset_reg)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700965 return -EPERM;
966
Stephen Boyda52d7e32011-11-10 11:59:00 -0800967 /* Disable hw gating when asserting a reset */
968 if (b->hwcg_mask && action == CLK_RESET_ASSERT)
969 branch_disable_hwcg(b);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700970
Stephen Boyda52d7e32011-11-10 11:59:00 -0800971 spin_lock_irqsave(&local_clock_reg_lock, flags);
972 /* Assert/Deassert reset */
973 reg_val = readl_relaxed(b->reset_reg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700974 switch (action) {
975 case CLK_RESET_ASSERT:
Stephen Boyda52d7e32011-11-10 11:59:00 -0800976 reg_val |= b->reset_mask;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700977 break;
978 case CLK_RESET_DEASSERT:
Stephen Boyda52d7e32011-11-10 11:59:00 -0800979 reg_val &= ~b->reset_mask;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700980 break;
981 default:
982 ret = -EINVAL;
983 }
Stephen Boyda52d7e32011-11-10 11:59:00 -0800984 writel_relaxed(reg_val, b->reset_reg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700985 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
986
Stephen Boyda52d7e32011-11-10 11:59:00 -0800987 /* Enable hw gating when deasserting a reset */
988 if (b->hwcg_mask && action == CLK_RESET_DEASSERT)
989 branch_enable_hwcg(b);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700990 /* Make sure write is issued before returning. */
991 mb();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700992 return ret;
993}
994
995int branch_clk_reset(struct clk *clk, enum clk_reset_action action)
996{
997 return branch_reset(&to_branch_clk(clk)->b, action);
998}
Stephen Boydb8ad8222011-11-28 12:17:58 -0800999
Stephen Boyd7bf28142011-12-07 00:30:52 -08001000int rcg_clk_reset(struct clk *clk, enum clk_reset_action action)
1001{
1002 return branch_reset(&to_rcg_clk(clk)->b, action);
1003}
1004
Stephen Boydb8ad8222011-11-28 12:17:58 -08001005static int cdiv_clk_enable(struct clk *c)
1006{
1007 unsigned long flags;
1008 struct cdiv_clk *clk = to_cdiv_clk(c);
1009
1010 spin_lock_irqsave(&local_clock_reg_lock, flags);
1011 __branch_clk_enable_reg(&clk->b, clk->c.dbg_name);
1012 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
1013
1014 return 0;
1015}
1016
1017static void cdiv_clk_disable(struct clk *c)
1018{
1019 unsigned long flags;
1020 struct cdiv_clk *clk = to_cdiv_clk(c);
1021
1022 spin_lock_irqsave(&local_clock_reg_lock, flags);
1023 __branch_clk_disable_reg(&clk->b, clk->c.dbg_name);
1024 spin_unlock_irqrestore(&local_clock_reg_lock, flags);
1025}
1026
1027static int cdiv_clk_set_rate(struct clk *c, unsigned long rate)
1028{
1029 struct cdiv_clk *clk = to_cdiv_clk(c);
1030 u32 reg_val;
1031
1032 if (rate > clk->max_div)
1033 return -EINVAL;
1034 /* Check if frequency is actually changed. */
1035 if (rate == clk->cur_div)
1036 return 0;
1037
1038 spin_lock(&local_clock_reg_lock);
1039 reg_val = readl_relaxed(clk->ns_reg);
1040 reg_val &= ~(clk->ext_mask | (clk->max_div - 1) << clk->div_offset);
1041 /* Non-zero rates mean set a divider, zero means use external input */
1042 if (rate)
1043 reg_val |= (rate - 1) << clk->div_offset;
1044 else
1045 reg_val |= clk->ext_mask;
1046 writel_relaxed(reg_val, clk->ns_reg);
1047 spin_unlock(&local_clock_reg_lock);
1048
1049 clk->cur_div = rate;
1050 return 0;
1051}
1052
1053static unsigned long cdiv_clk_get_rate(struct clk *c)
1054{
1055 struct cdiv_clk *clk = to_cdiv_clk(c);
1056 return clk->cur_div;
1057}
1058
1059static long cdiv_clk_round_rate(struct clk *c, unsigned long rate)
1060{
1061 struct cdiv_clk *clk = to_cdiv_clk(c);
1062 return rate > clk->max_div ? -EPERM : rate;
1063}
1064
1065static int cdiv_clk_list_rate(struct clk *c, unsigned n)
1066{
1067 struct cdiv_clk *clk = to_cdiv_clk(c);
1068 return n > clk->max_div ? -ENXIO : n;
1069}
1070
1071static int cdiv_clk_handoff(struct clk *c)
1072{
1073 struct cdiv_clk *clk = to_cdiv_clk(c);
1074 u32 reg_val;
1075
Stephen Boyda52d7e32011-11-10 11:59:00 -08001076 branch_handoff(&clk->b, &clk->c);
1077
Stephen Boydb8ad8222011-11-28 12:17:58 -08001078 reg_val = readl_relaxed(clk->ns_reg);
1079 if (reg_val & clk->ext_mask) {
1080 clk->cur_div = 0;
1081 } else {
1082 reg_val >>= clk->div_offset;
1083 clk->cur_div = (reg_val & (clk->max_div - 1)) + 1;
1084 }
1085
1086 return 0;
1087}
1088
Stephen Boyda52d7e32011-11-10 11:59:00 -08001089static void cdiv_clk_enable_hwcg(struct clk *c)
1090{
1091 struct cdiv_clk *clk = to_cdiv_clk(c);
1092 branch_enable_hwcg(&clk->b);
1093}
1094
1095static void cdiv_clk_disable_hwcg(struct clk *c)
1096{
1097 struct cdiv_clk *clk = to_cdiv_clk(c);
1098 branch_disable_hwcg(&clk->b);
1099}
1100
1101static int cdiv_clk_in_hwcg_mode(struct clk *c)
1102{
1103 struct cdiv_clk *clk = to_cdiv_clk(c);
1104 return branch_in_hwcg_mode(&clk->b);
1105}
1106
Stephen Boydb8ad8222011-11-28 12:17:58 -08001107struct clk_ops clk_ops_cdiv = {
1108 .enable = cdiv_clk_enable,
1109 .disable = cdiv_clk_disable,
Stephen Boyda52d7e32011-11-10 11:59:00 -08001110 .in_hwcg_mode = cdiv_clk_in_hwcg_mode,
1111 .enable_hwcg = cdiv_clk_enable_hwcg,
1112 .disable_hwcg = cdiv_clk_disable_hwcg,
Stephen Boydb8ad8222011-11-28 12:17:58 -08001113 .auto_off = cdiv_clk_disable,
1114 .handoff = cdiv_clk_handoff,
1115 .set_rate = cdiv_clk_set_rate,
1116 .get_rate = cdiv_clk_get_rate,
1117 .list_rate = cdiv_clk_list_rate,
1118 .round_rate = cdiv_clk_round_rate,
1119 .is_local = local_clk_is_local,
1120};