25 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/list.h>
28 #include <linux/errno.h>
30 #include <linux/device.h>
36 #include <linux/serial_core.h>
38 #include <mach/hardware.h>
42 #include <mach/regs-clock.h>
44 #include <plat/clock.h>
50 static unsigned long s3c2440_camif_upll_round(
struct clk *
clk,
56 if (rate > parent_rate)
61 div = (parent_rate /
rate) / 2;
68 return parent_rate / (div * 2);
71 static int s3c2440_camif_upll_setrate(
struct clk *clk,
unsigned long rate)
74 unsigned long camdivn =
__raw_readl(S3C2440_CAMDIVN);
76 rate = s3c2440_camif_upll_round(clk, rate);
78 camdivn &= ~(S3C2440_CAMDIVN_CAMCLK_SEL | S3C2440_CAMDIVN_CAMCLK_MASK);
80 if (rate != parent_rate) {
81 camdivn |= S3C2440_CAMDIVN_CAMCLK_SEL;
82 camdivn |= (((parent_rate /
rate) / 2) - 1);
90 static unsigned long s3c2440_camif_upll_getrate(
struct clk *clk)
93 unsigned long camdivn =
__raw_readl(S3C2440_CAMDIVN);
95 if (!(camdivn & S3C2440_CAMDIVN_CAMCLK_SEL))
98 camdivn &= S3C2440_CAMDIVN_CAMCLK_MASK;
100 return parent_rate / (camdivn + 1) / 2;
105 static struct clk s3c2440_clk_cam = {
108 .ctrlbit = S3C2440_CLKCON_CAMERA,
111 static struct clk s3c2440_clk_cam_upll = {
112 .name =
"camif-upll",
114 .set_rate = s3c2440_camif_upll_setrate,
115 .get_rate = s3c2440_camif_upll_getrate,
116 .round_rate = s3c2440_camif_upll_round,
120 static struct clk s3c2440_clk_ac97 = {
123 .ctrlbit = S3C2440_CLKCON_AC97,
126 static unsigned long s3c2440_fclk_n_getrate(
struct clk *clk)
128 unsigned long ucon0, ucon1, ucon2,
divisor;
152 static struct clk s3c2440_clk_fclk_n = {
156 .get_rate = s3c2440_fclk_n_getrate,
160 static struct clk_lookup s3c2440_clk_lookup[] = {
168 struct clk *clock_upll;
176 if (IS_ERR(clock_p) || IS_ERR(clock_h) || IS_ERR(clock_upll)) {
181 s3c2440_clk_cam.
parent = clock_h;
182 s3c2440_clk_ac97.
parent = clock_p;
183 s3c2440_clk_cam_upll.
parent = clock_upll;
198 .name =
"s3c2440_clk",
200 .add_dev = s3c2440_clk_add,
203 static __init int s3c24xx_clk_init(
void)