2 * Copyright (c) 2009 Simtec Electronics
3 * http://armlinux.simtec.co.uk/
4 * Ben Dooks <ben@simtec.co.uk>
6 * S3C24XX CPU Frequency scaling - utils for S3C2410/S3C2440/S3C2442
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/errno.h>
15 #include <linux/cpufreq.h>
19 #include <mach/regs-clock.h>
21 #include <plat/cpu-freq-core.h>
26 * s3c2410_cpufreq_setrefresh - set SDRAM refresh value
27 * @cfg: The frequency configuration
29 * Set the SDRAM refresh value appropriately for the configured
32 void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config
*cfg
)
34 struct s3c_cpufreq_board
*board
= cfg
->board
;
35 unsigned long refresh
;
38 /* Reduce both the refresh time (in ns) and the frequency (in MHz)
39 * down to ensure that we do not overflow 32 bit numbers.
41 * This should work for HCLK up to 133MHz and refresh period up
45 refresh
= (cfg
->freq
.hclk
/ 100) * (board
->refresh
/ 10);
46 refresh
= DIV_ROUND_UP(refresh
, (1000 * 1000)); /* apply scale */
47 refresh
= (1 << 11) + 1 - refresh
;
49 s3c_freq_dbg("%s: refresh value %lu\n", __func__
, refresh
);
51 refval
= __raw_readl(S3C2410_REFRESH
);
52 refval
&= ~((1 << 12) - 1);
54 __raw_writel(refval
, S3C2410_REFRESH
);
58 * s3c2410_set_fvco - set the PLL value
59 * @cfg: The frequency configuration
61 void s3c2410_set_fvco(struct s3c_cpufreq_config
*cfg
)
63 __raw_writel(cfg
->pll
.driver_data
, S3C2410_MPLLCON
);