Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux/fpc-iii.git] / arch / arm / mach-pxa / clock.c
blob4d466102a0272edc5812ec7645d480541c92be37
1 /*
2 * linux/arch/arm/mach-sa1100/clock.c
3 */
4 #include <linux/module.h>
5 #include <linux/kernel.h>
6 #include <linux/clk.h>
7 #include <linux/spinlock.h>
8 #include <linux/delay.h>
9 #include <linux/clkdev.h>
11 #include "clock.h"
13 static DEFINE_SPINLOCK(clocks_lock);
15 int clk_enable(struct clk *clk)
17 unsigned long flags;
19 spin_lock_irqsave(&clocks_lock, flags);
20 if (clk->enabled++ == 0)
21 clk->ops->enable(clk);
22 spin_unlock_irqrestore(&clocks_lock, flags);
24 if (clk->delay)
25 udelay(clk->delay);
27 return 0;
29 EXPORT_SYMBOL(clk_enable);
31 void clk_disable(struct clk *clk)
33 unsigned long flags;
35 WARN_ON(clk->enabled == 0);
37 spin_lock_irqsave(&clocks_lock, flags);
38 if (--clk->enabled == 0)
39 clk->ops->disable(clk);
40 spin_unlock_irqrestore(&clocks_lock, flags);
42 EXPORT_SYMBOL(clk_disable);
44 unsigned long clk_get_rate(struct clk *clk)
46 unsigned long rate;
48 rate = clk->rate;
49 if (clk->ops->getrate)
50 rate = clk->ops->getrate(clk);
52 return rate;
54 EXPORT_SYMBOL(clk_get_rate);
56 int clk_set_rate(struct clk *clk, unsigned long rate)
58 unsigned long flags;
59 int ret = -EINVAL;
61 if (clk->ops->setrate) {
62 spin_lock_irqsave(&clocks_lock, flags);
63 ret = clk->ops->setrate(clk, rate);
64 spin_unlock_irqrestore(&clocks_lock, flags);
67 return ret;
69 EXPORT_SYMBOL(clk_set_rate);
71 void clk_dummy_enable(struct clk *clk)
75 void clk_dummy_disable(struct clk *clk)
79 const struct clkops clk_dummy_ops = {
80 .enable = clk_dummy_enable,
81 .disable = clk_dummy_disable,
84 struct clk clk_dummy = {
85 .ops = &clk_dummy_ops,