aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s3c24xx/s3c244x-clock.c
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-01-28 07:01:34 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-01-28 08:20:52 -0500
commit3a38e4be76e86c7b94c36dc8f3ce489987da24e4 (patch)
tree1b8ce87d0002c28fe9a8615151a28a3b666f5c17 /arch/arm/plat-s3c24xx/s3c244x-clock.c
parentc27cb681ac1598352569f75cb19850a12b7ef102 (diff)
[ARM] 4794/1: S3C24XX: Comonise S3C2440 and S3C2442 clock code
Merge together the bits of the S3C2440 and S3C2442 clock code that can be. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/plat-s3c24xx/s3c244x-clock.c')
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x-clock.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/arch/arm/plat-s3c24xx/s3c244x-clock.c b/arch/arm/plat-s3c24xx/s3c244x-clock.c
new file mode 100644
index 000000000000..0bf5e7fbb2bf
--- /dev/null
+++ b/arch/arm/plat-s3c24xx/s3c244x-clock.c
@@ -0,0 +1,100 @@
1/* linux/arch/arm/plat-s3c24xx/s3c24xx-clock.c
2 *
3 * Copyright (c) 2004-2005,2008 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * S3C2440/S3C2442 Common clock support
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22*/
23
24#include <linux/init.h>
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/list.h>
28#include <linux/errno.h>
29#include <linux/err.h>
30#include <linux/device.h>
31#include <linux/sysdev.h>
32#include <linux/interrupt.h>
33#include <linux/ioport.h>
34#include <linux/mutex.h>
35#include <linux/clk.h>
36
37#include <asm/hardware.h>
38#include <asm/atomic.h>
39#include <asm/irq.h>
40#include <asm/io.h>
41
42#include <asm/arch/regs-clock.h>
43
44#include <asm/plat-s3c24xx/clock.h>
45#include <asm/plat-s3c24xx/cpu.h>
46
47static int s3c244x_clk_add(struct sys_device *sysdev)
48{
49 unsigned long camdivn = __raw_readl(S3C2440_CAMDIVN);
50 unsigned long clkdivn;
51 struct clk *clock_upll;
52
53 printk("S3C244X: Clock Support, DVS %s\n",
54 (camdivn & S3C2440_CAMDIVN_DVSEN) ? "on" : "off");
55
56 clock_upll = clk_get(NULL, "upll");
57 if (IS_ERR(clock_upll)) {
58 printk(KERN_ERR "S3C244X: Failed to get upll clock\n");
59 return -ENOENT;
60 }
61
62 /* check rate of UPLL, and if it is near 96MHz, then change
63 * to using half the UPLL rate for the system */
64
65 if (clk_get_rate(clock_upll) > (94 * MHZ)) {
66 clk_usb_bus.rate = clk_get_rate(clock_upll) / 2;
67
68 mutex_lock(&clocks_mutex);
69
70 clkdivn = __raw_readl(S3C2410_CLKDIVN);
71 clkdivn |= S3C2440_CLKDIVN_UCLK;
72 __raw_writel(clkdivn, S3C2410_CLKDIVN);
73
74 mutex_unlock(&clocks_mutex);
75 }
76
77 return 0;
78}
79
80static struct sysdev_driver s3c2440_clk_driver = {
81 .add = s3c244x_clk_add,
82};
83
84static int s3c2440_clk_init(void)
85{
86 return sysdev_driver_register(&s3c2440_sysclass, &s3c2440_clk_driver);
87}
88
89arch_initcall(s3c2440_clk_init);
90
91static struct sysdev_driver s3c2442_clk_driver = {
92 .add = s3c244x_clk_add,
93};
94
95static int s3c2442_clk_init(void)
96{
97 return sysdev_driver_register(&s3c2442_sysclass, &s3c2442_clk_driver);
98}
99
100arch_initcall(s3c2442_clk_init);