Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
clock.c
Go to the documentation of this file.
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>
10 
11 #include "clock.h"
12 
13 static DEFINE_SPINLOCK(clocks_lock);
14 
15 int clk_enable(struct clk *clk)
16 {
17  unsigned long flags;
18 
20  if (clk->enabled++ == 0)
21  clk->ops->enable(clk);
22  spin_unlock_irqrestore(&clocks_lock, flags);
23 
24  if (clk->delay)
25  udelay(clk->delay);
26 
27  return 0;
28 }
30 
31 void clk_disable(struct clk *clk)
32 {
33  unsigned long flags;
34 
35  WARN_ON(clk->enabled == 0);
36 
38  if (--clk->enabled == 0)
39  clk->ops->disable(clk);
40  spin_unlock_irqrestore(&clocks_lock, flags);
41 }
43 
44 unsigned long clk_get_rate(struct clk *clk)
45 {
46  unsigned long rate;
47 
48  rate = clk->rate;
49  if (clk->ops->getrate)
50  rate = clk->ops->getrate(clk);
51 
52  return rate;
53 }
55 
56 int clk_set_rate(struct clk *clk, unsigned long rate)
57 {
58  unsigned long flags;
59  int ret = -EINVAL;
60 
61  if (clk->ops->setrate) {
63  ret = clk->ops->setrate(clk, rate);
64  spin_unlock_irqrestore(&clocks_lock, flags);
65  }
66 
67  return ret;
68 }
70 
71 void clk_dummy_enable(struct clk *clk)
72 {
73 }
74 
75 void clk_dummy_disable(struct clk *clk)
76 {
77 }
78 
79 const struct clkops clk_dummy_ops = {
80  .enable = clk_dummy_enable,
81  .disable = clk_dummy_disable,
82 };
83 
84 struct clk clk_dummy = {
85  .ops = &clk_dummy_ops,
86 };