blob: 6de713ad319a1c798c3444da58c2f545d933fb37 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* linux/arch/arm/mach-s3c2410/clock.c
2 *
3 * Copyright (c) 2004-2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 Clock control support
7 *
8 * Based on, and code from linux/arch/arm/mach-versatile/clock.c
9 **
10 ** Copyright (C) 2004 ARM Limited.
11 ** Written by Deep Blue Solutions Limited.
12 *
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27*/
28
29#include <linux/init.h>
30#include <linux/module.h>
31#include <linux/kernel.h>
32#include <linux/list.h>
33#include <linux/errno.h>
34#include <linux/err.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010035#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/sysdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <linux/interrupt.h>
38#include <linux/ioport.h>
Russell Kingf8ce2542006-01-07 16:15:52 +000039#include <linux/clk.h>
Arjan van de Ven00431702006-01-12 18:42:23 +000040#include <linux/mutex.h>
Ben Dooks8e40a2f2006-03-20 17:10:04 +000041#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43#include <asm/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <asm/irq.h>
45#include <asm/io.h>
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <asm/arch/regs-clock.h>
Ben Dooks3fc3e1c2006-03-20 17:10:07 +000048#include <asm/arch/regs-gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50#include "clock.h"
51#include "cpu.h"
52
53/* clock information */
54
55static LIST_HEAD(clocks);
Ben Dooks36c64af2006-03-20 21:00:48 +000056
57DEFINE_MUTEX(clocks_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59/* old functions */
60
61void inline s3c24xx_clk_enable(unsigned int clocks, unsigned int enable)
62{
63 unsigned long clkcon;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65 clkcon = __raw_readl(S3C2410_CLKCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67 if (enable)
68 clkcon |= clocks;
Ben Dooks2a513ce2006-02-08 21:09:05 +000069 else
70 clkcon &= ~clocks;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72 /* ensure none of the special function bits set */
73 clkcon &= ~(S3C2410_CLKCON_IDLE|S3C2410_CLKCON_POWER);
74
75 __raw_writel(clkcon, S3C2410_CLKCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076}
77
78/* enable and disable calls for use with the clk struct */
79
80static int clk_null_enable(struct clk *clk, int enable)
81{
82 return 0;
83}
84
85int s3c24xx_clkcon_enable(struct clk *clk, int enable)
86{
87 s3c24xx_clk_enable(clk->ctrlbit, enable);
88 return 0;
89}
90
91/* Clock API calls */
92
93struct clk *clk_get(struct device *dev, const char *id)
94{
95 struct clk *p;
96 struct clk *clk = ERR_PTR(-ENOENT);
97 int idno;
98
Ben Dooksc086f282005-10-18 07:51:34 +010099 if (dev == NULL || dev->bus != &platform_bus_type)
100 idno = -1;
101 else
102 idno = to_platform_device(dev)->id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Arjan van de Ven00431702006-01-12 18:42:23 +0000104 mutex_lock(&clocks_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
106 list_for_each_entry(p, &clocks, list) {
107 if (p->id == idno &&
108 strcmp(id, p->name) == 0 &&
109 try_module_get(p->owner)) {
110 clk = p;
111 break;
112 }
113 }
114
115 /* check for the case where a device was supplied, but the
116 * clock that was being searched for is not device specific */
117
118 if (IS_ERR(clk)) {
119 list_for_each_entry(p, &clocks, list) {
120 if (p->id == -1 && strcmp(id, p->name) == 0 &&
121 try_module_get(p->owner)) {
122 clk = p;
123 break;
124 }
125 }
126 }
127
Arjan van de Ven00431702006-01-12 18:42:23 +0000128 mutex_unlock(&clocks_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 return clk;
130}
131
132void clk_put(struct clk *clk)
133{
134 module_put(clk->owner);
135}
136
137int clk_enable(struct clk *clk)
138{
Ben Dooks2a513ce2006-02-08 21:09:05 +0000139 if (IS_ERR(clk) || clk == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 return -EINVAL;
141
Ben Dooks2a513ce2006-02-08 21:09:05 +0000142 clk_enable(clk->parent);
143
144 mutex_lock(&clocks_mutex);
145
146 if ((clk->usage++) == 0)
147 (clk->enable)(clk, 1);
148
149 mutex_unlock(&clocks_mutex);
150 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151}
152
153void clk_disable(struct clk *clk)
154{
Ben Dooks2a513ce2006-02-08 21:09:05 +0000155 if (IS_ERR(clk) || clk == NULL)
156 return;
157
158 mutex_lock(&clocks_mutex);
159
160 if ((--clk->usage) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 (clk->enable)(clk, 0);
Ben Dooks2a513ce2006-02-08 21:09:05 +0000162
163 mutex_unlock(&clocks_mutex);
164 clk_disable(clk->parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165}
166
167
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168unsigned long clk_get_rate(struct clk *clk)
169{
170 if (IS_ERR(clk))
171 return 0;
172
173 if (clk->rate != 0)
174 return clk->rate;
175
176 while (clk->parent != NULL && clk->rate == 0)
177 clk = clk->parent;
178
179 return clk->rate;
180}
181
182long clk_round_rate(struct clk *clk, unsigned long rate)
183{
Ben Dooks6e8908e2006-03-20 21:00:08 +0000184 if (!IS_ERR(clk) && clk->round_rate)
185 return (clk->round_rate)(clk, rate);
186
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 return rate;
188}
189
190int clk_set_rate(struct clk *clk, unsigned long rate)
191{
Ben Dooks6e8908e2006-03-20 21:00:08 +0000192 int ret;
193
194 if (IS_ERR(clk))
195 return -EINVAL;
196
197 mutex_lock(&clocks_mutex);
198 ret = (clk->set_rate)(clk, rate);
199 mutex_unlock(&clocks_mutex);
200
201 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202}
203
204struct clk *clk_get_parent(struct clk *clk)
205{
206 return clk->parent;
207}
208
Ben Dooksd3468da2006-03-20 17:10:04 +0000209int clk_set_parent(struct clk *clk, struct clk *parent)
210{
211 int ret = 0;
212
213 if (IS_ERR(clk))
214 return -EINVAL;
215
216 mutex_lock(&clocks_mutex);
217
218 if (clk->set_parent)
219 ret = (clk->set_parent)(clk, parent);
220
221 mutex_unlock(&clocks_mutex);
222
223 return ret;
224}
225
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226EXPORT_SYMBOL(clk_get);
227EXPORT_SYMBOL(clk_put);
228EXPORT_SYMBOL(clk_enable);
229EXPORT_SYMBOL(clk_disable);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230EXPORT_SYMBOL(clk_get_rate);
231EXPORT_SYMBOL(clk_round_rate);
232EXPORT_SYMBOL(clk_set_rate);
233EXPORT_SYMBOL(clk_get_parent);
Ben Dooksd3468da2006-03-20 17:10:04 +0000234EXPORT_SYMBOL(clk_set_parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Ben Dooks8e40a2f2006-03-20 17:10:04 +0000236/* base clock enable */
237
238static int s3c24xx_upll_enable(struct clk *clk, int enable)
239{
240 unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW);
241 unsigned long orig = clkslow;
242
243 if (enable)
244 clkslow &= ~S3C2410_CLKSLOW_UCLK_OFF;
245 else
246 clkslow |= S3C2410_CLKSLOW_UCLK_OFF;
247
248 __raw_writel(clkslow, S3C2410_CLKSLOW);
249
250 /* if we started the UPLL, then allow to settle */
251
Ben Dooks2b2ee152006-04-02 10:00:10 +0100252 if (enable && (orig & S3C2410_CLKSLOW_UCLK_OFF))
Ben Dooks8e40a2f2006-03-20 17:10:04 +0000253 udelay(200);
254
255 return 0;
256}
257
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258/* base clocks */
259
260static struct clk clk_xtal = {
261 .name = "xtal",
262 .id = -1,
263 .rate = 0,
264 .parent = NULL,
265 .ctrlbit = 0,
266};
267
Ben Dooks8e40a2f2006-03-20 17:10:04 +0000268static struct clk clk_upll = {
269 .name = "upll",
270 .id = -1,
271 .parent = NULL,
272 .enable = s3c24xx_upll_enable,
273 .ctrlbit = 0,
274};
275
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276static struct clk clk_f = {
277 .name = "fclk",
278 .id = -1,
279 .rate = 0,
280 .parent = NULL,
281 .ctrlbit = 0,
282};
283
284static struct clk clk_h = {
285 .name = "hclk",
286 .id = -1,
287 .rate = 0,
288 .parent = NULL,
289 .ctrlbit = 0,
290};
291
292static struct clk clk_p = {
293 .name = "pclk",
294 .id = -1,
295 .rate = 0,
296 .parent = NULL,
297 .ctrlbit = 0,
298};
299
Ben Dooks36c64af2006-03-20 21:00:48 +0000300struct clk clk_usb_bus = {
301 .name = "usb-bus",
302 .id = -1,
303 .rate = 0,
304 .parent = &clk_upll,
305};
306
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307/* clocks that could be registered by external code */
308
Ben Dooks3fc3e1c2006-03-20 17:10:07 +0000309static int s3c24xx_dclk_enable(struct clk *clk, int enable)
310{
311 unsigned long dclkcon = __raw_readl(S3C2410_DCLKCON);
312
313 if (enable)
314 dclkcon |= clk->ctrlbit;
315 else
316 dclkcon &= ~clk->ctrlbit;
317
318 __raw_writel(dclkcon, S3C2410_DCLKCON);
319
320 return 0;
321}
322
323static int s3c24xx_dclk_setparent(struct clk *clk, struct clk *parent)
324{
325 unsigned long dclkcon;
326 unsigned int uclk;
327
328 if (parent == &clk_upll)
329 uclk = 1;
330 else if (parent == &clk_p)
331 uclk = 0;
332 else
333 return -EINVAL;
334
335 clk->parent = parent;
336
337 dclkcon = __raw_readl(S3C2410_DCLKCON);
338
339 if (clk->ctrlbit == S3C2410_DCLKCON_DCLK0EN) {
340 if (uclk)
341 dclkcon |= S3C2410_DCLKCON_DCLK0_UCLK;
342 else
343 dclkcon &= ~S3C2410_DCLKCON_DCLK0_UCLK;
344 } else {
345 if (uclk)
346 dclkcon |= S3C2410_DCLKCON_DCLK1_UCLK;
347 else
348 dclkcon &= ~S3C2410_DCLKCON_DCLK1_UCLK;
349 }
350
351 __raw_writel(dclkcon, S3C2410_DCLKCON);
352
353 return 0;
354}
355
356
357static int s3c24xx_clkout_setparent(struct clk *clk, struct clk *parent)
358{
359 unsigned long mask;
360 unsigned long source;
361
362 /* calculate the MISCCR setting for the clock */
363
364 if (parent == &clk_xtal)
365 source = S3C2410_MISCCR_CLK0_MPLL;
366 else if (parent == &clk_upll)
367 source = S3C2410_MISCCR_CLK0_UPLL;
368 else if (parent == &clk_f)
369 source = S3C2410_MISCCR_CLK0_FCLK;
Ben Dooks73590362006-04-09 22:21:10 +0100370 else if (parent == &clk_h)
371 source = S3C2410_MISCCR_CLK0_HCLK;
Ben Dooks3fc3e1c2006-03-20 17:10:07 +0000372 else if (parent == &clk_p)
373 source = S3C2410_MISCCR_CLK0_PCLK;
374 else if (clk == &s3c24xx_clkout0 && parent == &s3c24xx_dclk0)
375 source = S3C2410_MISCCR_CLK0_DCLK0;
376 else if (clk == &s3c24xx_clkout1 && parent == &s3c24xx_dclk1)
377 source = S3C2410_MISCCR_CLK0_DCLK0;
378 else
379 return -EINVAL;
380
Ben Dooks73590362006-04-09 22:21:10 +0100381 clk->parent = parent;
382
Ben Dooks3fc3e1c2006-03-20 17:10:07 +0000383 if (clk == &s3c24xx_dclk0)
384 mask = S3C2410_MISCCR_CLK0_MASK;
385 else {
386 source <<= 4;
387 mask = S3C2410_MISCCR_CLK1_MASK;
388 }
389
390 s3c2410_modify_misccr(mask, source);
391 return 0;
392}
393
394/* external clock definitions */
395
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396struct clk s3c24xx_dclk0 = {
397 .name = "dclk0",
398 .id = -1,
Ben Dooks3fc3e1c2006-03-20 17:10:07 +0000399 .ctrlbit = S3C2410_DCLKCON_DCLK0EN,
400 .enable = s3c24xx_dclk_enable,
401 .set_parent = s3c24xx_dclk_setparent,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402};
403
404struct clk s3c24xx_dclk1 = {
405 .name = "dclk1",
406 .id = -1,
Ben Dooks3fc3e1c2006-03-20 17:10:07 +0000407 .ctrlbit = S3C2410_DCLKCON_DCLK0EN,
408 .enable = s3c24xx_dclk_enable,
409 .set_parent = s3c24xx_dclk_setparent,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410};
411
412struct clk s3c24xx_clkout0 = {
413 .name = "clkout0",
414 .id = -1,
Ben Dooks3fc3e1c2006-03-20 17:10:07 +0000415 .set_parent = s3c24xx_clkout_setparent,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416};
417
418struct clk s3c24xx_clkout1 = {
419 .name = "clkout1",
420 .id = -1,
Ben Dooks3fc3e1c2006-03-20 17:10:07 +0000421 .set_parent = s3c24xx_clkout_setparent,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422};
423
424struct clk s3c24xx_uclk = {
425 .name = "uclk",
426 .id = -1,
427};
428
429
Ben Dooks8e40a2f2006-03-20 17:10:04 +0000430/* standard clock definitions */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
432static struct clk init_clocks[] = {
Ben Dooksfe38ea52006-01-09 21:16:18 +0000433 {
434 .name = "nand",
435 .id = -1,
436 .parent = &clk_h,
437 .enable = s3c24xx_clkcon_enable,
438 .ctrlbit = S3C2410_CLKCON_NAND,
439 }, {
440 .name = "lcd",
441 .id = -1,
442 .parent = &clk_h,
443 .enable = s3c24xx_clkcon_enable,
444 .ctrlbit = S3C2410_CLKCON_LCDC,
445 }, {
446 .name = "usb-host",
447 .id = -1,
448 .parent = &clk_h,
449 .enable = s3c24xx_clkcon_enable,
450 .ctrlbit = S3C2410_CLKCON_USBH,
451 }, {
452 .name = "usb-device",
453 .id = -1,
454 .parent = &clk_h,
455 .enable = s3c24xx_clkcon_enable,
456 .ctrlbit = S3C2410_CLKCON_USBD,
457 }, {
458 .name = "timers",
459 .id = -1,
460 .parent = &clk_p,
461 .enable = s3c24xx_clkcon_enable,
462 .ctrlbit = S3C2410_CLKCON_PWMT,
463 }, {
464 .name = "sdi",
465 .id = -1,
466 .parent = &clk_p,
467 .enable = s3c24xx_clkcon_enable,
468 .ctrlbit = S3C2410_CLKCON_SDI,
469 }, {
470 .name = "uart",
471 .id = 0,
472 .parent = &clk_p,
473 .enable = s3c24xx_clkcon_enable,
474 .ctrlbit = S3C2410_CLKCON_UART0,
475 }, {
476 .name = "uart",
477 .id = 1,
478 .parent = &clk_p,
479 .enable = s3c24xx_clkcon_enable,
480 .ctrlbit = S3C2410_CLKCON_UART1,
481 }, {
482 .name = "uart",
483 .id = 2,
484 .parent = &clk_p,
485 .enable = s3c24xx_clkcon_enable,
486 .ctrlbit = S3C2410_CLKCON_UART2,
487 }, {
488 .name = "gpio",
489 .id = -1,
490 .parent = &clk_p,
491 .enable = s3c24xx_clkcon_enable,
492 .ctrlbit = S3C2410_CLKCON_GPIO,
493 }, {
494 .name = "rtc",
495 .id = -1,
496 .parent = &clk_p,
497 .enable = s3c24xx_clkcon_enable,
498 .ctrlbit = S3C2410_CLKCON_RTC,
499 }, {
500 .name = "adc",
501 .id = -1,
502 .parent = &clk_p,
503 .enable = s3c24xx_clkcon_enable,
504 .ctrlbit = S3C2410_CLKCON_ADC,
505 }, {
506 .name = "i2c",
507 .id = -1,
508 .parent = &clk_p,
509 .enable = s3c24xx_clkcon_enable,
510 .ctrlbit = S3C2410_CLKCON_IIC,
511 }, {
512 .name = "iis",
513 .id = -1,
514 .parent = &clk_p,
515 .enable = s3c24xx_clkcon_enable,
516 .ctrlbit = S3C2410_CLKCON_IIS,
517 }, {
518 .name = "spi",
519 .id = -1,
520 .parent = &clk_p,
521 .enable = s3c24xx_clkcon_enable,
522 .ctrlbit = S3C2410_CLKCON_SPI,
523 }, {
524 .name = "watchdog",
525 .id = -1,
526 .parent = &clk_p,
527 .ctrlbit = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 }
529};
530
531/* initialise the clock system */
532
533int s3c24xx_register_clock(struct clk *clk)
534{
535 clk->owner = THIS_MODULE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536
537 if (clk->enable == NULL)
538 clk->enable = clk_null_enable;
539
Ben Dooks2a513ce2006-02-08 21:09:05 +0000540 /* if this is a standard clock, set the usage state */
541
Ben Dooks3fc3e1c2006-03-20 17:10:07 +0000542 if (clk->ctrlbit && clk->enable == s3c24xx_clkcon_enable) {
Ben Dooks2a513ce2006-02-08 21:09:05 +0000543 unsigned long clkcon = __raw_readl(S3C2410_CLKCON);
544
545 clk->usage = (clkcon & clk->ctrlbit) ? 1 : 0;
546 }
547
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 /* add to the list of available clocks */
549
Arjan van de Ven00431702006-01-12 18:42:23 +0000550 mutex_lock(&clocks_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 list_add(&clk->list, &clocks);
Arjan van de Ven00431702006-01-12 18:42:23 +0000552 mutex_unlock(&clocks_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553
554 return 0;
555}
556
557/* initalise all the clocks */
558
559int __init s3c24xx_setup_clocks(unsigned long xtal,
560 unsigned long fclk,
561 unsigned long hclk,
562 unsigned long pclk)
563{
Ben Dooks8e40a2f2006-03-20 17:10:04 +0000564 unsigned long upllcon = __raw_readl(S3C2410_UPLLCON);
Ben Dooksd6b0bf22005-08-29 22:46:30 +0100565 unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 struct clk *clkp = init_clocks;
567 int ptr;
568 int ret;
569
570 printk(KERN_INFO "S3C2410 Clocks, (c) 2004 Simtec Electronics\n");
571
572 /* initialise the main system clocks */
573
574 clk_xtal.rate = xtal;
Ben Dooks8e40a2f2006-03-20 17:10:04 +0000575 clk_upll.rate = s3c2410_get_pll(upllcon, xtal);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576
577 clk_h.rate = hclk;
578 clk_p.rate = pclk;
579 clk_f.rate = fclk;
580
Ben Dooksfe38ea52006-01-09 21:16:18 +0000581 /* We must be careful disabling the clocks we are not intending to
582 * be using at boot time, as subsytems such as the LCD which do
583 * their own DMA requests to the bus can cause the system to lockup
584 * if they where in the middle of requesting bus access.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 *
Ben Dooksfe38ea52006-01-09 21:16:18 +0000586 * Disabling the LCD clock if the LCD is active is very dangerous,
587 * and therefore the bootloader should be careful to not enable
588 * the LCD clock if it is not needed.
589 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590
Ben Dooks2a513ce2006-02-08 21:09:05 +0000591 mutex_lock(&clocks_mutex);
592
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 s3c24xx_clk_enable(S3C2410_CLKCON_NAND, 0);
594 s3c24xx_clk_enable(S3C2410_CLKCON_USBH, 0);
595 s3c24xx_clk_enable(S3C2410_CLKCON_USBD, 0);
596 s3c24xx_clk_enable(S3C2410_CLKCON_ADC, 0);
597 s3c24xx_clk_enable(S3C2410_CLKCON_IIC, 0);
598 s3c24xx_clk_enable(S3C2410_CLKCON_SPI, 0);
599
Ben Dooks2a513ce2006-02-08 21:09:05 +0000600 mutex_unlock(&clocks_mutex);
601
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 /* assume uart clocks are correctly setup */
603
604 /* register our clocks */
605
606 if (s3c24xx_register_clock(&clk_xtal) < 0)
607 printk(KERN_ERR "failed to register master xtal\n");
608
Ben Dooks8e40a2f2006-03-20 17:10:04 +0000609 if (s3c24xx_register_clock(&clk_upll) < 0)
610 printk(KERN_ERR "failed to register upll clock\n");
611
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 if (s3c24xx_register_clock(&clk_f) < 0)
613 printk(KERN_ERR "failed to register cpu fclk\n");
614
615 if (s3c24xx_register_clock(&clk_h) < 0)
616 printk(KERN_ERR "failed to register cpu hclk\n");
617
618 if (s3c24xx_register_clock(&clk_p) < 0)
619 printk(KERN_ERR "failed to register cpu pclk\n");
620
Ben Dooks36c64af2006-03-20 21:00:48 +0000621
622 if (s3c24xx_register_clock(&clk_usb_bus) < 0)
623 printk(KERN_ERR "failed to register usb bus clock\n");
624
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 /* register clocks from clock array */
626
627 for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) {
628 ret = s3c24xx_register_clock(clkp);
629 if (ret < 0) {
630 printk(KERN_ERR "Failed to register clock %s (%d)\n",
631 clkp->name, ret);
632 }
633 }
634
Ben Dooksd6b0bf22005-08-29 22:46:30 +0100635 /* show the clock-slow value */
636
637 printk("CLOCK: Slow mode (%ld.%ld MHz), %s, MPLL %s, UPLL %s\n",
638 print_mhz(xtal / ( 2 * S3C2410_CLKSLOW_GET_SLOWVAL(clkslow))),
639 (clkslow & S3C2410_CLKSLOW_SLOW) ? "slow" : "fast",
640 (clkslow & S3C2410_CLKSLOW_MPLL_OFF) ? "off" : "on",
641 (clkslow & S3C2410_CLKSLOW_UCLK_OFF) ? "off" : "on");
642
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 return 0;
644}