aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-s3c2443
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-11-05 21:21:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-11-05 21:21:21 -0400
commitc861cd3e92d92ae946e19099f198018fcb4fd887 (patch)
treefab678a30a85cf80038c560221d6ab01812a3891 /arch/arm/mach-s3c2443
parent7abec10c623d9e0416dab6919a0ea22e6283516b (diff)
parentb8bc83971cc20cae3c3b65c26a804f350d74960c (diff)
Merge branch 'next/devel2' of git://git.linaro.org/people/arnd/arm-soc
* 'next/devel2' of git://git.linaro.org/people/arnd/arm-soc: (30 commits) ARM: mmp: register internal sram bank ARM: mmp: register audio sram bank ARM: mmp: add sram allocator gpio/samsung: Complain loudly if we don't know the SoC ARM: S3C64XX: Fix SoC identification for S3C64xx devices ARM: S3C2443: Remove redundant s3c_register_clocks call for init_clocks ARM: S3C24XX: Add devname for hsmmc1 pclk ARM: S3C24XX: use clk_get_rate to init fclk in common_setup_clocks ARM: S3C2443: Accommodate cpufreq frequency scheme in armdiv ARM: S3C2443: handle unset armdiv values gracefully ARM: S3C2443: Add get_rate operation for clk_armdiv ARM: S3C2416: Add comment describing the armdiv/armclk ARM: S3C2443: Move clk_arm and clk_armdiv to common code ARM: S3C24XX: Add infrastructure to transmit armdiv to common code ARM: S3C2416: Add armdiv_mask constant ARM: EXYNOS4: Add support for M-5MOLS camera on Nuri board ARM: EXYNOS4: Enable MFC on ORIGEN ARM: SAMSUNG: Add support s3c2416-adc for S3C2416/S3C2450 ARM: SAMSUNG: Add support s3c2443-adc for S3C2443 ARM: SAMSUNG: Allow overriding of adc device name for S3C24XX ...
Diffstat (limited to 'arch/arm/mach-s3c2443')
-rw-r--r--arch/arm/mach-s3c2443/clock.c105
-rw-r--r--arch/arm/mach-s3c2443/s3c2443.c3
2 files changed, 9 insertions, 99 deletions
diff --git a/arch/arm/mach-s3c2443/clock.c b/arch/arm/mach-s3c2443/clock.c
index cd51d04e1de7..1c2c088aa2e8 100644
--- a/arch/arm/mach-s3c2443/clock.c
+++ b/arch/arm/mach-s3c2443/clock.c
@@ -61,10 +61,10 @@
61 * 61 *
62 * this clock is sourced from msysclk and can have a number of 62 * this clock is sourced from msysclk and can have a number of
63 * divider values applied to it to then be fed into armclk. 63 * divider values applied to it to then be fed into armclk.
64 * The real clock definition is done in s3c2443-clock.c,
65 * only the armdiv divisor table must be defined here.
64*/ 66*/
65 67
66/* armdiv divisor table */
67
68static unsigned int armdiv[16] = { 68static unsigned int armdiv[16] = {
69 [S3C2443_CLKDIV0_ARMDIV_1 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 1, 69 [S3C2443_CLKDIV0_ARMDIV_1 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 1,
70 [S3C2443_CLKDIV0_ARMDIV_2 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 2, 70 [S3C2443_CLKDIV0_ARMDIV_2 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 2,
@@ -76,92 +76,6 @@ static unsigned int armdiv[16] = {
76 [S3C2443_CLKDIV0_ARMDIV_16 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 16, 76 [S3C2443_CLKDIV0_ARMDIV_16 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 16,
77}; 77};
78 78
79static inline unsigned int s3c2443_fclk_div(unsigned long clkcon0)
80{
81 clkcon0 &= S3C2443_CLKDIV0_ARMDIV_MASK;
82
83 return armdiv[clkcon0 >> S3C2443_CLKDIV0_ARMDIV_SHIFT];
84}
85
86static unsigned long s3c2443_armclk_roundrate(struct clk *clk,
87 unsigned long rate)
88{
89 unsigned long parent = clk_get_rate(clk->parent);
90 unsigned long calc;
91 unsigned best = 256; /* bigger than any value */
92 unsigned div;
93 int ptr;
94
95 for (ptr = 0; ptr < ARRAY_SIZE(armdiv); ptr++) {
96 div = armdiv[ptr];
97 calc = parent / div;
98 if (calc <= rate && div < best)
99 best = div;
100 }
101
102 return parent / best;
103}
104
105static int s3c2443_armclk_setrate(struct clk *clk, unsigned long rate)
106{
107 unsigned long parent = clk_get_rate(clk->parent);
108 unsigned long calc;
109 unsigned div;
110 unsigned best = 256; /* bigger than any value */
111 int ptr;
112 int val = -1;
113
114 for (ptr = 0; ptr < ARRAY_SIZE(armdiv); ptr++) {
115 div = armdiv[ptr];
116 calc = parent / div;
117 if (calc <= rate && div < best) {
118 best = div;
119 val = ptr;
120 }
121 }
122
123 if (val >= 0) {
124 unsigned long clkcon0;
125
126 clkcon0 = __raw_readl(S3C2443_CLKDIV0);
127 clkcon0 &= ~S3C2443_CLKDIV0_ARMDIV_MASK;
128 clkcon0 |= val << S3C2443_CLKDIV0_ARMDIV_SHIFT;
129 __raw_writel(clkcon0, S3C2443_CLKDIV0);
130 }
131
132 return (val == -1) ? -EINVAL : 0;
133}
134
135static struct clk clk_armdiv = {
136 .name = "armdiv",
137 .parent = &clk_msysclk.clk,
138 .ops = &(struct clk_ops) {
139 .round_rate = s3c2443_armclk_roundrate,
140 .set_rate = s3c2443_armclk_setrate,
141 },
142};
143
144/* armclk
145 *
146 * this is the clock fed into the ARM core itself, from armdiv or from hclk.
147 */
148
149static struct clk *clk_arm_sources[] = {
150 [0] = &clk_armdiv,
151 [1] = &clk_h,
152};
153
154static struct clksrc_clk clk_arm = {
155 .clk = {
156 .name = "armclk",
157 },
158 .sources = &(struct clksrc_sources) {
159 .sources = clk_arm_sources,
160 .nr_sources = ARRAY_SIZE(clk_arm_sources),
161 },
162 .reg_src = { .reg = S3C2443_CLKDIV0, .size = 1, .shift = 13 },
163};
164
165/* hsspi 79/* hsspi
166 * 80 *
167 * high-speed spi clock, sourced from esysclk 81 * high-speed spi clock, sourced from esysclk
@@ -254,25 +168,20 @@ static struct clk init_clocks_off[] = {
254 } 168 }
255}; 169};
256 170
257static struct clk init_clocks[] = {
258};
259
260/* clocks to add straight away */ 171/* clocks to add straight away */
261 172
262static struct clksrc_clk *clksrcs[] __initdata = { 173static struct clksrc_clk *clksrcs[] __initdata = {
263 &clk_arm,
264 &clk_hsspi, 174 &clk_hsspi,
265 &clk_hsmmc_div, 175 &clk_hsmmc_div,
266}; 176};
267 177
268static struct clk *clks[] __initdata = { 178static struct clk *clks[] __initdata = {
269 &clk_hsmmc, 179 &clk_hsmmc,
270 &clk_armdiv,
271}; 180};
272 181
273void __init_or_cpufreq s3c2443_setup_clocks(void) 182void __init_or_cpufreq s3c2443_setup_clocks(void)
274{ 183{
275 s3c2443_common_setup_clocks(s3c2443_get_mpll, s3c2443_fclk_div); 184 s3c2443_common_setup_clocks(s3c2443_get_mpll);
276} 185}
277 186
278void __init s3c2443_init_clocks(int xtal) 187void __init s3c2443_init_clocks(int xtal)
@@ -283,7 +192,9 @@ void __init s3c2443_init_clocks(int xtal)
283 clk_epll.rate = s3c2443_get_epll(epllcon, xtal); 192 clk_epll.rate = s3c2443_get_epll(epllcon, xtal);
284 clk_epll.parent = &clk_epllref.clk; 193 clk_epll.parent = &clk_epllref.clk;
285 194
286 s3c2443_common_init_clocks(xtal, s3c2443_get_mpll, s3c2443_fclk_div); 195 s3c2443_common_init_clocks(xtal, s3c2443_get_mpll,
196 armdiv, ARRAY_SIZE(armdiv),
197 S3C2443_CLKDIV0_ARMDIV_MASK);
287 198
288 s3c2443_setup_clocks(); 199 s3c2443_setup_clocks();
289 200
@@ -292,10 +203,6 @@ void __init s3c2443_init_clocks(int xtal)
292 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++) 203 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
293 s3c_register_clksrc(clksrcs[ptr], 1); 204 s3c_register_clksrc(clksrcs[ptr], 1);
294 205
295 /* register clocks from clock array */
296
297 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
298
299 /* We must be careful disabling the clocks we are not intending to 206 /* We must be careful disabling the clocks we are not intending to
300 * be using at boot time, as subsystems such as the LCD which do 207 * be using at boot time, as subsystems such as the LCD which do
301 * their own DMA requests to the bus can cause the system to lockup 208 * their own DMA requests to the bus can cause the system to lockup
diff --git a/arch/arm/mach-s3c2443/s3c2443.c b/arch/arm/mach-s3c2443/s3c2443.c
index 5df6458ddd42..a22b771b0f36 100644
--- a/arch/arm/mach-s3c2443/s3c2443.c
+++ b/arch/arm/mach-s3c2443/s3c2443.c
@@ -41,6 +41,7 @@
41#include <plat/cpu.h> 41#include <plat/cpu.h>
42#include <plat/fb-core.h> 42#include <plat/fb-core.h>
43#include <plat/nand-core.h> 43#include <plat/nand-core.h>
44#include <plat/adc-core.h>
44 45
45static struct map_desc s3c2443_iodesc[] __initdata = { 46static struct map_desc s3c2443_iodesc[] __initdata = {
46 IODESC_ENT(WATCHDOG), 47 IODESC_ENT(WATCHDOG),
@@ -70,6 +71,8 @@ int __init s3c2443_init(void)
70 s3c_nand_setname("s3c2412-nand"); 71 s3c_nand_setname("s3c2412-nand");
71 s3c_fb_setname("s3c2443-fb"); 72 s3c_fb_setname("s3c2443-fb");
72 73
74 s3c_adc_setname("s3c2443-adc");
75
73 /* change WDT IRQ number */ 76 /* change WDT IRQ number */
74 s3c_device_wdt.resource[1].start = IRQ_S3C2443_WDT; 77 s3c_device_wdt.resource[1].start = IRQ_S3C2443_WDT;
75 s3c_device_wdt.resource[1].end = IRQ_S3C2443_WDT; 78 s3c_device_wdt.resource[1].end = IRQ_S3C2443_WDT;