aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/clock.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/clock.c')
-rw-r--r--arch/arm/mach-pxa/clock.c66
1 files changed, 10 insertions, 56 deletions
diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
index ca8e2053815..a3e0e1989a6 100644
--- a/arch/arm/mach-pxa/clock.c
+++ b/arch/arm/mach-pxa/clock.c
@@ -12,6 +12,7 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14 14
15#include <asm/clkdev.h>
15#include <mach/pxa2xx-regs.h> 16#include <mach/pxa2xx-regs.h>
16#include <mach/pxa2xx-gpio.h> 17#include <mach/pxa2xx-gpio.h>
17#include <mach/hardware.h> 18#include <mach/hardware.h>
@@ -20,45 +21,8 @@
20#include "generic.h" 21#include "generic.h"
21#include "clock.h" 22#include "clock.h"
22 23
23static LIST_HEAD(clocks);
24static DEFINE_MUTEX(clocks_mutex);
25static DEFINE_SPINLOCK(clocks_lock); 24static DEFINE_SPINLOCK(clocks_lock);
26 25
27static struct clk *clk_lookup(struct device *dev, const char *id)
28{
29 struct clk *p;
30
31 list_for_each_entry(p, &clocks, node)
32 if (strcmp(id, p->name) == 0 && p->dev == dev)
33 return p;
34
35 return NULL;
36}
37
38struct clk *clk_get(struct device *dev, const char *id)
39{
40 struct clk *p, *clk = ERR_PTR(-ENOENT);
41
42 mutex_lock(&clocks_mutex);
43 p = clk_lookup(dev, id);
44 if (!p)
45 p = clk_lookup(NULL, id);
46 if (p)
47 clk = p;
48 mutex_unlock(&clocks_mutex);
49
50 if (!IS_ERR(clk) && clk->ops == NULL)
51 clk = clk->other;
52
53 return clk;
54}
55EXPORT_SYMBOL(clk_get);
56
57void clk_put(struct clk *clk)
58{
59}
60EXPORT_SYMBOL(clk_put);
61
62int clk_enable(struct clk *clk) 26int clk_enable(struct clk *clk)
63{ 27{
64 unsigned long flags; 28 unsigned long flags;
@@ -116,37 +80,27 @@ const struct clkops clk_cken_ops = {
116 .disable = clk_cken_disable, 80 .disable = clk_cken_disable,
117}; 81};
118 82
119void clks_register(struct clk *clks, size_t num) 83void clks_register(struct clk_lookup *clks, size_t num)
120{ 84{
121 int i; 85 int i;
122 86
123 mutex_lock(&clocks_mutex);
124 for (i = 0; i < num; i++) 87 for (i = 0; i < num; i++)
125 list_add(&clks[i].node, &clocks); 88 clkdev_add(&clks[i]);
126 mutex_unlock(&clocks_mutex);
127} 89}
128 90
129int clk_add_alias(char *alias, struct device *alias_dev, char *id, 91int clk_add_alias(char *alias, struct device *alias_dev, char *id,
130 struct device *dev) 92 struct device *dev)
131{ 93{
132 struct clk *r = clk_lookup(dev, id); 94 struct clk *r = clk_get(dev, id);
133 struct clk *new; 95 struct clk_lookup *l;
134 96
135 if (!r) 97 if (!r)
136 return -ENODEV; 98 return -ENODEV;
137 99
138 new = kzalloc(sizeof(struct clk), GFP_KERNEL); 100 l = clkdev_alloc(r, alias, alias_dev ? dev_name(alias_dev) : NULL);
139 101 clk_put(r);
140 if (!new) 102 if (!l)
141 return -ENOMEM; 103 return -ENODEV;
142 104 clkdev_add(l);
143 new->name = alias;
144 new->dev = alias_dev;
145 new->other = r;
146
147 mutex_lock(&clocks_mutex);
148 list_add(&new->node, &clocks);
149 mutex_unlock(&clocks_mutex);
150
151 return 0; 105 return 0;
152} 106}