aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/platform/coldfire/clk.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/m68k/platform/coldfire/clk.c')
-rw-r--r--arch/m68k/platform/coldfire/clk.c105
1 files changed, 104 insertions, 1 deletions
diff --git a/arch/m68k/platform/coldfire/clk.c b/arch/m68k/platform/coldfire/clk.c
index 44da406897e5..c06c0f4a0ffc 100644
--- a/arch/m68k/platform/coldfire/clk.c
+++ b/arch/m68k/platform/coldfire/clk.c
@@ -10,11 +10,17 @@
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h>
14#include <linux/mutex.h>
13#include <linux/clk.h> 15#include <linux/clk.h>
16#include <linux/io.h>
17#include <linux/err.h>
14#include <asm/coldfire.h> 18#include <asm/coldfire.h>
19#include <asm/mcfsim.h>
20#include <asm/mcfclk.h>
15 21
16/***************************************************************************/ 22/***************************************************************************/
17 23#ifndef MCFPM_PPMCR0
18struct clk *clk_get(struct device *dev, const char *id) 24struct clk *clk_get(struct device *dev, const char *id)
19{ 25{
20 return NULL; 26 return NULL;
@@ -49,4 +55,101 @@ struct clk *devm_clk_get(struct device *dev, const char *id)
49} 55}
50EXPORT_SYMBOL(devm_clk_get); 56EXPORT_SYMBOL(devm_clk_get);
51 57
58#else
59static DEFINE_SPINLOCK(clk_lock);
60
61struct clk *clk_get(struct device *dev, const char *id)
62{
63 const char *clk_name = dev ? dev_name(dev) : id ? id : NULL;
64 struct clk *clk;
65 unsigned i;
66
67 for (i = 0; (clk = mcf_clks[i]) != NULL; ++i)
68 if (!strcmp(clk->name, clk_name))
69 return clk;
70 pr_warn("clk_get: didn't find clock %s\n", clk_name);
71 return ERR_PTR(-ENOENT);
72}
73EXPORT_SYMBOL(clk_get);
74
75int clk_enable(struct clk *clk)
76{
77 unsigned long flags;
78 spin_lock_irqsave(&clk_lock, flags);
79 if ((clk->enabled++ == 0) && clk->clk_ops)
80 clk->clk_ops->enable(clk);
81 spin_unlock_irqrestore(&clk_lock, flags);
82
83 return 0;
84}
85EXPORT_SYMBOL(clk_enable);
86
87void clk_disable(struct clk *clk)
88{
89 unsigned long flags;
90 spin_lock_irqsave(&clk_lock, flags);
91 if ((--clk->enabled == 0) && clk->clk_ops)
92 clk->clk_ops->disable(clk);
93 spin_unlock_irqrestore(&clk_lock, flags);
94}
95EXPORT_SYMBOL(clk_disable);
96
97void clk_put(struct clk *clk)
98{
99 if (clk->enabled != 0)
100 pr_warn("clk_put %s still enabled\n", clk->name);
101}
102EXPORT_SYMBOL(clk_put);
103
104unsigned long clk_get_rate(struct clk *clk)
105{
106 return clk->rate;
107}
108EXPORT_SYMBOL(clk_get_rate);
109
52/***************************************************************************/ 110/***************************************************************************/
111
112void __clk_init_enabled(struct clk *clk)
113{
114 clk->enabled = 1;
115 clk->clk_ops->enable(clk);
116}
117
118void __clk_init_disabled(struct clk *clk)
119{
120 clk->enabled = 0;
121 clk->clk_ops->disable(clk);
122}
123
124static void __clk_enable0(struct clk *clk)
125{
126 __raw_writeb(clk->slot, MCFPM_PPMCR0);
127}
128
129static void __clk_disable0(struct clk *clk)
130{
131 __raw_writeb(clk->slot, MCFPM_PPMSR0);
132}
133
134struct clk_ops clk_ops0 = {
135 .enable = __clk_enable0,
136 .disable = __clk_disable0,
137};
138
139#ifdef MCFPM_PPMCR1
140static void __clk_enable1(struct clk *clk)
141{
142 __raw_writeb(clk->slot, MCFPM_PPMCR1);
143}
144
145static void __clk_disable1(struct clk *clk)
146{
147 __raw_writeb(clk->slot, MCFPM_PPMSR1);
148}
149
150struct clk_ops clk_ops1 = {
151 .enable = __clk_enable1,
152 .disable = __clk_disable1,
153};
154#endif /* MCFPM_PPMCR1 */
155#endif /* MCFPM_PPMCR0 */