diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2005-03-01 14:35:10 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2005-03-01 14:35:10 +0000 |
commit | d94f32883854c070780c837068500e2ec5f408ff (patch) | |
tree | 22fd6af387358d4a062c2f972f10e757dd94a23f | |
parent | 76620fbe5bf44063e1e18c2913b3a5a805db3ccd (diff) | |
download | rockbox-d94f32883854c070780c837068500e2ec5f408ff.tar.gz rockbox-d94f32883854c070780c837068500e2ec5f408ff.zip |
Adjustable CPU frequency for iRiver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6093 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/export/config-gmini120.h | 3 | ||||
-rw-r--r-- | firmware/export/config-gminisp.h | 3 | ||||
-rw-r--r-- | firmware/export/config-h100.h | 3 | ||||
-rw-r--r-- | firmware/export/system.h | 14 | ||||
-rw-r--r-- | firmware/system.c | 80 |
5 files changed, 103 insertions, 0 deletions
diff --git a/firmware/export/config-gmini120.h b/firmware/export/config-gmini120.h index 7b6af81a6b..473f1cfa7f 100644 --- a/firmware/export/config-gmini120.h +++ b/firmware/export/config-gmini120.h | |||
@@ -56,4 +56,7 @@ | |||
56 | 56 | ||
57 | #define HAVE_LED | 57 | #define HAVE_LED |
58 | 58 | ||
59 | /* Define this if you have adjustable CPU frequency */ | ||
60 | #define HAVE_ADJUSTABLE_CPU_FREQ | ||
61 | |||
59 | #endif | 62 | #endif |
diff --git a/firmware/export/config-gminisp.h b/firmware/export/config-gminisp.h index d85240bdd1..431cf2f3ef 100644 --- a/firmware/export/config-gminisp.h +++ b/firmware/export/config-gminisp.h | |||
@@ -50,4 +50,7 @@ | |||
50 | 50 | ||
51 | #define HAVE_LED | 51 | #define HAVE_LED |
52 | 52 | ||
53 | /* Define this if you have adjustable CPU frequency */ | ||
54 | #define HAVE_ADJUSTABLE_CPU_FREQ | ||
55 | |||
53 | #endif | 56 | #endif |
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h index 0083842770..9c7ba6c1d3 100644 --- a/firmware/export/config-h100.h +++ b/firmware/export/config-h100.h | |||
@@ -53,4 +53,7 @@ | |||
53 | /* Define this if you have a software controlled poweroff */ | 53 | /* Define this if you have a software controlled poweroff */ |
54 | #define HAVE_SW_POWEROFF | 54 | #define HAVE_SW_POWEROFF |
55 | 55 | ||
56 | /* Define this if you have adjustable CPU frequency */ | ||
57 | #define HAVE_ADJUSTABLE_CPU_FREQ | ||
58 | |||
56 | #endif | 59 | #endif |
diff --git a/firmware/export/system.h b/firmware/export/system.h index f792a132e7..442072ba51 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h | |||
@@ -22,11 +22,18 @@ | |||
22 | 22 | ||
23 | #include "cpu.h" | 23 | #include "cpu.h" |
24 | #include "config.h" | 24 | #include "config.h" |
25 | #include "stdbool.h" | ||
25 | 26 | ||
26 | extern void system_reboot (void); | 27 | extern void system_reboot (void); |
27 | extern void system_init(void); | 28 | extern void system_init(void); |
28 | 29 | ||
30 | extern long cpu_frequency; | ||
31 | |||
32 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
33 | #define FREQ cpu_frequency | ||
34 | #else | ||
29 | #define FREQ CPU_FREQ | 35 | #define FREQ CPU_FREQ |
36 | #endif | ||
30 | #define BAUDRATE 9600 | 37 | #define BAUDRATE 9600 |
31 | 38 | ||
32 | #ifndef NULL | 39 | #ifndef NULL |
@@ -188,6 +195,13 @@ static inline void invalidate_icache(void) | |||
188 | "movec.l %d0,%cacr"); | 195 | "movec.l %d0,%cacr"); |
189 | } | 196 | } |
190 | 197 | ||
198 | #define CPUFREQ_DEFAULT CPU_FREQ | ||
199 | #define CPUFREQ_NORMAL 47980800 | ||
200 | #define CPUFREQ_MAX 95961600 | ||
201 | |||
202 | void set_cpu_frequency(long frequency); | ||
203 | void cpu_boost(bool on_off); | ||
204 | |||
191 | #elif CONFIG_CPU == TCC730 | 205 | #elif CONFIG_CPU == TCC730 |
192 | 206 | ||
193 | extern int smsc_version(void); | 207 | extern int smsc_version(void); |
diff --git a/firmware/system.c b/firmware/system.c index 258fcd8827..382a7568a0 100644 --- a/firmware/system.c +++ b/firmware/system.c | |||
@@ -22,6 +22,11 @@ | |||
22 | #include "lcd.h" | 22 | #include "lcd.h" |
23 | #include "font.h" | 23 | #include "font.h" |
24 | #include "system.h" | 24 | #include "system.h" |
25 | #include "kernel.h" | ||
26 | |||
27 | #ifndef SIMULATOR | ||
28 | long cpu_frequency = CPU_FREQ; | ||
29 | #endif | ||
25 | 30 | ||
26 | #if CONFIG_CPU == TCC730 | 31 | #if CONFIG_CPU == TCC730 |
27 | 32 | ||
@@ -416,6 +421,81 @@ void system_init(void) | |||
416 | { | 421 | { |
417 | } | 422 | } |
418 | 423 | ||
424 | void set_cpu_frequency (long) __attribute__ ((section (".icode"))); | ||
425 | void set_cpu_frequency(long frequency) | ||
426 | { | ||
427 | switch(frequency) | ||
428 | { | ||
429 | case CPUFREQ_MAX: | ||
430 | DCR = (DCR & ~0x000001ff) | 1; /* Refresh timer for bypass | ||
431 | frequency */ | ||
432 | PLLCR &= ~1; /* Bypass mode */ | ||
433 | PLLCR = 0x11c8600d; | ||
434 | CSCR0 = 0x00000580; /* Flash: 1 wait state */ | ||
435 | CSCR1 = 0x00001180; /* LCD: 4 wait states */ | ||
436 | while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. | ||
437 | This may take up to 10ms! */ | ||
438 | DCR = (DCR & ~0x000001ff) | 33; /* Refresh timer */ | ||
439 | cpu_frequency = CPUFREQ_MAX; | ||
440 | tick_start(1000/HZ); | ||
441 | IDECONFIG1 = (IDECONFIG1 & ~(7 << 10)) | (5 << 10); /* CS2Pre,Post */ | ||
442 | IDECONFIG2 = (IDECONFIG2 & ~0x0000ff00) | (0 << 8); /* CS2wait */ | ||
443 | break; | ||
444 | |||
445 | case CPUFREQ_NORMAL: | ||
446 | DCR = (DCR & ~0x000001ff) | 1; /* Refresh timer for bypass | ||
447 | frequency */ | ||
448 | PLLCR &= ~1; /* Bypass mode */ | ||
449 | PLLCR = 0x10c86801; | ||
450 | CSCR0 = 0x00000180; /* Flash: 0 wait states */ | ||
451 | CSCR1 = 0x00000980; /* LCD: 2 wait states */ | ||
452 | while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. | ||
453 | This may take up to 10ms! */ | ||
454 | DCR = (DCR & ~0x000001ff) | 10; /* Refresh timer */ | ||
455 | cpu_frequency = CPUFREQ_NORMAL; | ||
456 | tick_start(1000/HZ); | ||
457 | IDECONFIG1 = (IDECONFIG1 & ~(7 << 10)) | (5 << 10); /* CS2Pre,Post */ | ||
458 | IDECONFIG2 = (IDECONFIG2 & ~0x0000ff00) | (0 << 8); /* CS2wait */ | ||
459 | break; | ||
460 | default: | ||
461 | DCR = (DCR & ~0x000001ff) | 1; /* Refresh timer for bypass | ||
462 | frequency */ | ||
463 | PLLCR &= ~1; /* Bypass mode */ | ||
464 | CSCR0 = 0x00000180; /* Flash: 0 wait states */ | ||
465 | CSCR1 = 0x00000180; /* LCD: 0 wait states */ | ||
466 | cpu_frequency = CPU_FREQ; | ||
467 | tick_start(1000/HZ); | ||
468 | IDECONFIG1 = (IDECONFIG1 & ~(7 << 10)) | (1 << 10); /* CS2Pre,Post */ | ||
469 | IDECONFIG2 = (IDECONFIG2 & ~0x0000ff00) | (0 << 8); /* CS2wait */ | ||
470 | break; | ||
471 | } | ||
472 | } | ||
473 | |||
474 | void cpu_boost(bool on_off) | ||
475 | { | ||
476 | static int counter = 0; | ||
477 | if(on_off) | ||
478 | { | ||
479 | /* Boost the frequency if not already boosted */ | ||
480 | if(counter++ == 0) | ||
481 | { | ||
482 | set_cpu_frequency(CPUFREQ_MAX); | ||
483 | } | ||
484 | } | ||
485 | else | ||
486 | { | ||
487 | /* Lower the frequency if the counter reaches 0 */ | ||
488 | if(--counter == 0) | ||
489 | { | ||
490 | set_cpu_frequency(CPUFREQ_NORMAL); | ||
491 | } | ||
492 | |||
493 | /* Safety measure */ | ||
494 | if(counter < 0) | ||
495 | counter = 0; | ||
496 | } | ||
497 | } | ||
498 | |||
419 | #elif CONFIG_CPU == SH7034 | 499 | #elif CONFIG_CPU == SH7034 |
420 | #include "led.h" | 500 | #include "led.h" |
421 | #include "system.h" | 501 | #include "system.h" |