diff options
Diffstat (limited to 'firmware/target/arm/s5l8700/system-s5l8700.c')
-rw-r--r-- | firmware/target/arm/s5l8700/system-s5l8700.c | 67 |
1 files changed, 55 insertions, 12 deletions
diff --git a/firmware/target/arm/s5l8700/system-s5l8700.c b/firmware/target/arm/s5l8700/system-s5l8700.c index fe0fb9ff7c..68ec3826a8 100644 --- a/firmware/target/arm/s5l8700/system-s5l8700.c +++ b/firmware/target/arm/s5l8700/system-s5l8700.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "panic.h" | 24 | #include "panic.h" |
25 | #ifdef IPOD_NANO2G | 25 | #ifdef IPOD_NANO2G |
26 | #include "storage.h" | 26 | #include "storage.h" |
27 | #include "pmu-target.h" | ||
27 | #endif | 28 | #endif |
28 | 29 | ||
29 | #define default_interrupt(name) \ | 30 | #define default_interrupt(name) \ |
@@ -153,6 +154,7 @@ void fiq_dummy(void) | |||
153 | 154 | ||
154 | void system_init(void) | 155 | void system_init(void) |
155 | { | 156 | { |
157 | pmu_init(); | ||
156 | } | 158 | } |
157 | 159 | ||
158 | void system_reboot(void) | 160 | void system_reboot(void) |
@@ -180,7 +182,7 @@ void system_reboot(void) | |||
180 | 182 | ||
181 | void system_exception_wait(void) | 183 | void system_exception_wait(void) |
182 | { | 184 | { |
183 | while (1); | 185 | while(1); |
184 | } | 186 | } |
185 | 187 | ||
186 | int system_memory_guard(int newmode) | 188 | int system_memory_guard(int newmode) |
@@ -195,27 +197,68 @@ void set_cpu_frequency(long frequency) | |||
195 | { | 197 | { |
196 | if (cpu_frequency == frequency) | 198 | if (cpu_frequency == frequency) |
197 | return; | 199 | return; |
198 | 200 | ||
199 | /* CPU/COP frequencies can be scaled between Fbus (min) and Fsys (max). | 201 | int oldlevel = disable_irq_save(); |
200 | Fbus should not be set below ~32Mhz with LCD enabled or the display | 202 | |
201 | will be garbled. */ | 203 | #if 1 |
202 | if (frequency == CPUFREQ_MAX) | 204 | if (frequency == CPUFREQ_MAX) |
203 | { | 205 | { |
206 | /* FCLK_CPU = PLL0, HCLK = PLL0 / 2 */ | ||
207 | CLKCON = (CLKCON & ~0xFF00FF00) | 0x20003100; | ||
208 | /* PCLK = HCLK / 2 */ | ||
209 | CLKCON2 |= 0x200; | ||
210 | /* Switch to ASYNCHRONOUS mode */ | ||
211 | asm volatile( | ||
212 | "mrc p15, 0, r0,c1,c0 \n\t" | ||
213 | "orr r0, r0, #0xc0000000 \n\t" | ||
214 | "mcr p15, 0, r0,c1,c0 \n\t" | ||
215 | ::: "r0" | ||
216 | ); | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | /* Switch to FASTBUS mode */ | ||
221 | asm volatile( | ||
222 | "mrc p15, 0, r0,c1,c0 \n\t" | ||
223 | "bic r0, r0, #0xc0000000 \n\t" | ||
224 | "mcr p15, 0, r0,c1,c0 \n\t" | ||
225 | ::: "r0" | ||
226 | ); | ||
227 | /* PCLK = HCLK */ | ||
228 | CLKCON2 &= ~0x200; | ||
229 | /* FCLK_CPU = OFF, HCLK = PLL0 / 4 */ | ||
230 | CLKCON = (CLKCON & ~0xFF00FF00) | 0x80003300; | ||
204 | } | 231 | } |
205 | else if (frequency == CPUFREQ_NORMAL) | 232 | |
233 | #else /* Alternative: Also clock down the PLL. Doesn't seem to save much | ||
234 | current, but results in high switching latency. */ | ||
235 | |||
236 | if (frequency == CPUFREQ_MAX) | ||
206 | { | 237 | { |
238 | CLKCON &= ~0xFF00FF00; /* Everything back to the OSC */ | ||
239 | PLLCON &= ~1; /* Power down PLL0 */ | ||
240 | PLL0PMS = 0x021200; /* 192 MHz */ | ||
241 | PLL0LCNT = 8100; | ||
242 | PLLCON |= 1; /* Power up PLL0 */ | ||
243 | while (!(PLLLOCK & 1)); /* Wait for PLL to lock */ | ||
244 | CLKCON2 |= 0x200; /* PCLK = HCLK / 2 */ | ||
245 | CLKCON |= 0x20003100; /* FCLK_CPU = PLL0, PCLK = PLL0 / 2 */ | ||
207 | } | 246 | } |
208 | else | 247 | else |
209 | { | 248 | { |
249 | CLKCON &= ~0xFF00FF00; /* Everything back to the OSC */ | ||
250 | CLKCON2 &= ~0x200; /* PCLK = HCLK */ | ||
251 | PLLCON &= ~1; /* Power down PLL0 */ | ||
252 | PLL0PMS = 0x000500; /* 48 MHz */ | ||
253 | PLL0LCNT = 8100; | ||
254 | PLLCON |= 1; /* Power up PLL0 */ | ||
255 | while (!(PLLLOCK & 1)); /* Wait for PLL to lock */ | ||
256 | CLKCON |= 0x20002000; /* FCLK_CPU = PLL0, PCLK = PLL0 */ | ||
210 | } | 257 | } |
211 | 258 | #endif | |
212 | asm volatile ( | ||
213 | "nop \n\t" | ||
214 | "nop \n\t" | ||
215 | "nop \n\t" | ||
216 | ); | ||
217 | 259 | ||
218 | cpu_frequency = frequency; | 260 | cpu_frequency = frequency; |
261 | restore_irq(oldlevel); | ||
219 | } | 262 | } |
220 | 263 | ||
221 | #endif | 264 | #endif |