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.c67
1 files changed, 10 insertions, 57 deletions
diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
index ca8e20538157..40b774084514 100644
--- a/arch/arm/mach-pxa/clock.c
+++ b/arch/arm/mach-pxa/clock.c
@@ -12,53 +12,16 @@
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/hardware.h> 17#include <mach/hardware.h>
18 18
19#include "devices.h" 19#include "devices.h"
20#include "generic.h" 20#include "generic.h"
21#include "clock.h" 21#include "clock.h"
22 22
23static LIST_HEAD(clocks);
24static DEFINE_MUTEX(clocks_mutex);
25static DEFINE_SPINLOCK(clocks_lock); 23static DEFINE_SPINLOCK(clocks_lock);
26 24
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) 25int clk_enable(struct clk *clk)
63{ 26{
64 unsigned long flags; 27 unsigned long flags;
@@ -116,37 +79,27 @@ const struct clkops clk_cken_ops = {
116 .disable = clk_cken_disable, 79 .disable = clk_cken_disable,
117}; 80};
118 81
119void clks_register(struct clk *clks, size_t num) 82void clks_register(struct clk_lookup *clks, size_t num)
120{ 83{
121 int i; 84 int i;
122 85
123 mutex_lock(&clocks_mutex);
124 for (i = 0; i < num; i++) 86 for (i = 0; i < num; i++)
125 list_add(&clks[i].node, &clocks); 87 clkdev_add(&clks[i]);
126 mutex_unlock(&clocks_mutex);
127} 88}
128 89
129int clk_add_alias(char *alias, struct device *alias_dev, char *id, 90int clk_add_alias(char *alias, struct device *alias_dev, char *id,
130 struct device *dev) 91 struct device *dev)
131{ 92{
132 struct clk *r = clk_lookup(dev, id); 93 struct clk *r = clk_get(dev, id);
133 struct clk *new; 94 struct clk_lookup *l;
134 95
135 if (!r) 96 if (!r)
136 return -ENODEV; 97 return -ENODEV;
137 98
138 new = kzalloc(sizeof(struct clk), GFP_KERNEL); 99 l = clkdev_alloc(r, alias, alias_dev ? dev_name(alias_dev) : NULL);
139 100 clk_put(r);
140 if (!new) 101 if (!l)
141 return -ENOMEM; 102 return -ENODEV;
142 103 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; 104 return 0;
152} 105}