diff options
author | Jack Halpin <jack.halpin@gmail.com> | 2010-04-06 17:22:57 +0000 |
---|---|---|
committer | Jack Halpin <jack.halpin@gmail.com> | 2010-04-06 17:22:57 +0000 |
commit | 36c16ea05d67567ee75faaf4f3a5f29ca734ac6d (patch) | |
tree | c2109a0cb21befd7b609cdb52278fde77111b948 /firmware/target/arm/as3525/system-as3525.c | |
parent | 48477f06bf1de21f69d0ede35fc0667fc8d67f0a (diff) | |
download | rockbox-36c16ea05d67567ee75faaf4f3a5f29ca734ac6d.tar.gz rockbox-36c16ea05d67567ee75faaf4f3a5f29ca734ac6d.zip |
Sansa AMS: Split set_cpu_frequency() into 2 separate functions for as3525v1/v2 as the code is quite different for each model.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25498 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/system-as3525.c')
-rw-r--r-- | firmware/target/arm/as3525/system-as3525.c | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index fb51dded34..c51d84469f 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c | |||
@@ -347,6 +347,8 @@ int system_memory_guard(int newmode) | |||
347 | 347 | ||
348 | #ifndef BOOTLOADER | 348 | #ifndef BOOTLOADER |
349 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 349 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
350 | |||
351 | #if CONFIG_CPU == AS3525 | ||
350 | void set_cpu_frequency(long frequency) | 352 | void set_cpu_frequency(long frequency) |
351 | { | 353 | { |
352 | if(frequency == CPUFREQ_MAX) | 354 | if(frequency == CPUFREQ_MAX) |
@@ -360,7 +362,6 @@ void set_cpu_frequency(long frequency) | |||
360 | while(adc_read(ADC_CVDD) < 470); /* 470 * .0025 = 1.175V */ | 362 | while(adc_read(ADC_CVDD) < 470); /* 470 * .0025 = 1.175V */ |
361 | #endif /* HAVE_ADJUSTABLE_CPU_VOLTAGE */ | 363 | #endif /* HAVE_ADJUSTABLE_CPU_VOLTAGE */ |
362 | 364 | ||
363 | #if CONFIG_CPU == AS3525 /* only in arm922tdmi */ | ||
364 | asm volatile( | 365 | asm volatile( |
365 | "mrc p15, 0, r0, c1, c0 \n" | 366 | "mrc p15, 0, r0, c1, c0 \n" |
366 | 367 | ||
@@ -373,42 +374,17 @@ void set_cpu_frequency(long frequency) | |||
373 | 374 | ||
374 | "mcr p15, 0, r0, c1, c0 \n" | 375 | "mcr p15, 0, r0, c1, c0 \n" |
375 | : : : "r0" ); | 376 | : : : "r0" ); |
376 | #else | ||
377 | /* AS3525v2 */ | ||
378 | int oldstatus = disable_irq_save(); | ||
379 | |||
380 | /* Change PCLK while FCLK is low, so it doesn't go too high */ | ||
381 | CGU_PERI = (CGU_PERI & ~(0x1F << 2)) | (AS3525_PCLK_DIV0 << 2); | ||
382 | |||
383 | CGU_PROC = ((AS3525_FCLK_POSTDIV << 4) | | ||
384 | (AS3525_FCLK_PREDIV << 2) | | ||
385 | AS3525_FCLK_SEL); | ||
386 | restore_irq(oldstatus); | ||
387 | #endif /* CONFIG_CPU == AS3525 */ | ||
388 | 377 | ||
389 | cpu_frequency = CPUFREQ_MAX; | 378 | cpu_frequency = CPUFREQ_MAX; |
390 | } | 379 | } |
391 | else | 380 | else |
392 | { | 381 | { |
393 | #if CONFIG_CPU == AS3525 /* only in arm922tdmi */ | ||
394 | asm volatile( | 382 | asm volatile( |
395 | "mrc p15, 0, r0, c1, c0 \n" | 383 | "mrc p15, 0, r0, c1, c0 \n" |
396 | "bic r0, r0, #3<<30 \n" /* fastbus clocking */ | 384 | "bic r0, r0, #3<<30 \n" /* fastbus clocking */ |
397 | "mcr p15, 0, r0, c1, c0 \n" | 385 | "mcr p15, 0, r0, c1, c0 \n" |
398 | : : : "r0" ); | 386 | : : : "r0" ); |
399 | #else | ||
400 | /* AS3525v2 */ | ||
401 | int oldstatus = disable_irq_save(); | ||
402 | 387 | ||
403 | CGU_PROC = ((AS3525_FCLK_POSTDIV_UNBOOSTED << 4) | | ||
404 | (AS3525_FCLK_PREDIV << 2) | | ||
405 | AS3525_FCLK_SEL); | ||
406 | |||
407 | /* Change PCLK after FCLK is low, so it doesn't go too high */ | ||
408 | CGU_PERI = (CGU_PERI & ~(0x1F << 2)) | (AS3525_PCLK_DIV0_UNBOOSTED << 2); | ||
409 | |||
410 | restore_irq(oldstatus); | ||
411 | #endif /* CONFIG_CPU == AS3525 */ | ||
412 | 388 | ||
413 | #ifdef HAVE_ADJUSTABLE_CPU_VOLTAGE | 389 | #ifdef HAVE_ADJUSTABLE_CPU_VOLTAGE |
414 | /* Decreasing frequency so reduce voltage after change */ | 390 | /* Decreasing frequency so reduce voltage after change */ |
@@ -418,5 +394,40 @@ void set_cpu_frequency(long frequency) | |||
418 | cpu_frequency = CPUFREQ_NORMAL; | 394 | cpu_frequency = CPUFREQ_NORMAL; |
419 | } | 395 | } |
420 | } | 396 | } |
397 | #else /* as3525v2 */ | ||
398 | void set_cpu_frequency(long frequency) | ||
399 | { | ||
400 | if(frequency == CPUFREQ_MAX) | ||
401 | { | ||
402 | int oldstatus = disable_irq_save(); | ||
403 | /* Change PCLK while FCLK is low, so it doesn't go too high */ | ||
404 | CGU_PERI = (CGU_PERI & ~(0x1F << 2)) | (AS3525_PCLK_DIV0 << 2); | ||
405 | |||
406 | CGU_PROC = ((AS3525_FCLK_POSTDIV << 4) | | ||
407 | (AS3525_FCLK_PREDIV << 2) | | ||
408 | AS3525_FCLK_SEL); | ||
409 | |||
410 | restore_irq(oldstatus); | ||
411 | |||
412 | cpu_frequency = CPUFREQ_MAX; | ||
413 | } | ||
414 | else | ||
415 | { | ||
416 | int oldstatus = disable_irq_save(); | ||
417 | |||
418 | CGU_PROC = ((AS3525_FCLK_POSTDIV_UNBOOSTED << 4) | | ||
419 | (AS3525_FCLK_PREDIV << 2) | | ||
420 | AS3525_FCLK_SEL); | ||
421 | |||
422 | /* Change PCLK after FCLK is low, so it doesn't go too high */ | ||
423 | CGU_PERI = (CGU_PERI & ~(0x1F << 2)) | (AS3525_PCLK_DIV0_UNBOOSTED << 2); | ||
424 | |||
425 | restore_irq(oldstatus); | ||
426 | |||
427 | cpu_frequency = CPUFREQ_NORMAL; | ||
428 | } | ||
429 | } | ||
430 | #endif | ||
431 | |||
421 | #endif /* HAVE_ADJUSTABLE_CPU_FREQ */ | 432 | #endif /* HAVE_ADJUSTABLE_CPU_FREQ */ |
422 | #endif /* !BOOTLOADER */ | 433 | #endif /* !BOOTLOADER */ |