diff --git a/firmware/export/config/sansaclipplus.h b/firmware/export/config/sansaclipplus.h index ab4408a..12151a7 100644 --- a/firmware/export/config/sansaclipplus.h +++ b/firmware/export/config/sansaclipplus.h @@ -188,7 +188,7 @@ #define CONFIG_LED LED_VIRTUAL /* Define this if you have adjustable CPU frequency */ -//#define HAVE_ADJUSTABLE_CPU_FREQ +#define HAVE_ADJUSTABLE_CPU_FREQ #define BOOTFILE_EXT "sansa" #define BOOTFILE "rockbox." BOOTFILE_EXT diff --git a/firmware/export/config/sansaclipv2.h b/firmware/export/config/sansaclipv2.h index 262ed36..4b83b32 100644 --- a/firmware/export/config/sansaclipv2.h +++ b/firmware/export/config/sansaclipv2.h @@ -181,7 +181,7 @@ #define CONFIG_LED LED_VIRTUAL /* Define this if you have adjustable CPU frequency */ -//#define HAVE_ADJUSTABLE_CPU_FREQ +#define HAVE_ADJUSTABLE_CPU_FREQ #define BOOTFILE_EXT "sansa" #define BOOTFILE "rockbox." BOOTFILE_EXT diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index 44e210a..8b09872 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c @@ -459,8 +459,6 @@ void set_cpu_frequency(long frequency) } } #else /* as3525v2 */ -/* FIXME : disabled for now, seems to cause buggy memory accesses - * Disabling MMU or putting the function in uncached memory seems to help? */ void set_cpu_frequency(long frequency) { int oldstatus = disable_irq_save(); @@ -470,21 +468,52 @@ void set_cpu_frequency(long frequency) if(frequency == CPUFREQ_MAX) { - /* Change PCLK while FCLK is low, so it doesn't go too high */ - CGU_PERI = (CGU_PERI & ~(0xF << 2)) | (AS3525_PCLK_DIV0 << 2); - - CGU_PROC = ((AS3525_FCLK_POSTDIV << 4) | - (AS3525_FCLK_PREDIV << 2) | - AS3525_FCLK_SEL); + /* Clip: fclk 24MHz -> 240MHz */ + static const uint8_t div[][2] = { + /* -> change fclk -> tmp pclk -> change pclk -> new pclk */ + /* fclk div pclk div fclk tmp pclk new pclk */ + { 10, 1 }, // 24 24 24 + { 5 , 2 }, // 48 48 24 + { 3 , 3 }, // 80 40 26.66 + { 2 , 5 }, // 120 40 24 + { 1, 10 }, // 240 48 24 + }; + + const size_t max = sizeof(div)/sizeof(div[0]); + unsigned i = 1; /* skip 1st entry */ + for(; i 24MHz */ + static const uint8_t div[][2] = { + /* -> change fclk -> tmp pclk -> change pclk -> new pclk */ + /* fclk div pclk div fclk tmp pclk new pclk */ + { 1, 10 }, // 240 24 24 + { 2 , 5 }, // 120 48 24 + { 3 , 2 }, // 80 20 40 + { 5 , 1 }, // 48 24 48 + { 10, 1 }, // 24 24 24 + }; + + const size_t max = sizeof(div)/sizeof(div[0]); + unsigned i = 1; /* skip 1st entry */ + for(; i