13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/list.h>
16 #include <linux/errno.h>
19 #include <linux/device.h>
22 #include <plat/clock.h>
31 static inline u32 bit_mask(
u32 shift,
u32 nr_bits)
33 u32 mask = 0xffffffff >> (32 - nr_bits);
38 static unsigned long s3c_getrate_clksrc(
struct clk *
clk)
53 static int s3c_setrate_clksrc(
struct clk *
clk,
unsigned long rate)
63 if (div > (1 << sclk->
reg_div.size))
68 val |= (div - 1) << sclk->
reg_div.shift;
74 static int s3c_setparent_clksrc(
struct clk *clk,
struct clk *parent)
84 if (srcs->
sources[ptr] == parent) {
93 clksrc |= src_nr << sclk->
reg_src.shift;
102 static unsigned long s3c_roundrate_clksrc(
struct clk *clk,
107 int max_div = 1 << sclk->
reg_div.size;
110 if (rate >= parent_rate)
113 div = parent_rate /
rate;
114 if (parent_rate % rate)
122 rate = parent_rate /
div;
137 if (!clk->
clk.parent)
149 clk->
clk.name, clksrc);
157 clk->
clk.name, clk->
clk.parent->name, clksrc,
161 static struct clk_ops clksrc_ops = {
162 .set_parent = s3c_setparent_clksrc,
163 .get_rate = s3c_getrate_clksrc,
164 .set_rate = s3c_setrate_clksrc,
165 .round_rate = s3c_roundrate_clksrc,
168 static struct clk_ops clksrc_ops_nodiv = {
169 .set_parent = s3c_setparent_clksrc,
172 static struct clk_ops clksrc_ops_nosrc = {
173 .get_rate = s3c_getrate_clksrc,
174 .set_rate = s3c_setrate_clksrc,
175 .round_rate = s3c_roundrate_clksrc,
182 for (; size > 0; size--, clksrc++) {
185 __func__, clksrc->
clk.name);
189 if (!clksrc->
clk.ops) {
191 clksrc->
clk.ops = &clksrc_ops_nodiv;
193 clksrc->
clk.ops = &clksrc_ops_nosrc;
195 clksrc->
clk.ops = &clksrc_ops;
209 __func__, clksrc->
clk.name, ret);