From 97e907538ad8c51bf5467644ed12c695f7ce56f5 Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Wed, 26 Nov 2008 16:46:12 +0000 Subject: Sansa AMS: implement set_cpu_frequency() Use a 24MHz peripheral clock instead of 64MHz for battery life git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19234 a1c6a512-1295-4272-9138-f99709370657 --- .../target/arm/as3525/sansa-clip/system-target.h | 30 ---------------------- .../target/arm/as3525/sansa-e200v2/system-target.h | 30 ---------------------- .../target/arm/as3525/sansa-fuze/system-target.h | 30 ---------------------- .../target/arm/as3525/sansa-m200v4/system-target.h | 30 ---------------------- firmware/target/arm/as3525/system-as3525.c | 19 +++++++++++--- firmware/target/arm/as3525/system-target.h | 30 ++++++++++++++++++++++ 6 files changed, 45 insertions(+), 124 deletions(-) delete mode 100644 firmware/target/arm/as3525/sansa-clip/system-target.h delete mode 100644 firmware/target/arm/as3525/sansa-e200v2/system-target.h delete mode 100644 firmware/target/arm/as3525/sansa-fuze/system-target.h delete mode 100644 firmware/target/arm/as3525/sansa-m200v4/system-target.h create mode 100644 firmware/target/arm/as3525/system-target.h diff --git a/firmware/target/arm/as3525/sansa-clip/system-target.h b/firmware/target/arm/as3525/sansa-clip/system-target.h deleted file mode 100644 index dc9d77f3dc..0000000000 --- a/firmware/target/arm/as3525/sansa-clip/system-target.h +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2008 ?? - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef SYSTEM_TARGET_H -#define SYSTEM_TARGET_H - -#include "system-arm.h" - -#define CPUFREQ_MAX 250000000 -#define CPUFREQ_DEFAULT 250000000 -#define CPUFREQ_NORMAL 250000000 - -#endif /* SYSTEM_TARGET_H */ diff --git a/firmware/target/arm/as3525/sansa-e200v2/system-target.h b/firmware/target/arm/as3525/sansa-e200v2/system-target.h deleted file mode 100644 index 19ddd03b7c..0000000000 --- a/firmware/target/arm/as3525/sansa-e200v2/system-target.h +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2008 ?? - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef SYSTEM_TARGET_H -#define SYSTEM_TARGET_H - -#include "system-arm.h" - -#define CPUFREQ_MAX 250000000 -#define CPUFREQ_DEFAULT 250000000 -#define CPUFREQ_NORMAL 250000000 - -#endif /* SYSTEM_TARGET_H */ diff --git a/firmware/target/arm/as3525/sansa-fuze/system-target.h b/firmware/target/arm/as3525/sansa-fuze/system-target.h deleted file mode 100644 index 553ce90846..0000000000 --- a/firmware/target/arm/as3525/sansa-fuze/system-target.h +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2008 ?? - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef SYSTEM_TARGET_H -#define SYSTEM_TARGET_H - -#include "system-arm.h" - -#define CPUFREQ_MAX 250000000 -#define CPUFREQ_DEFAULT 250000000 -#define CPUFREQ_NORMAL 250000000 - -#endif /* SYSTEM_TARGET_H */ diff --git a/firmware/target/arm/as3525/sansa-m200v4/system-target.h b/firmware/target/arm/as3525/sansa-m200v4/system-target.h deleted file mode 100644 index dc9d77f3dc..0000000000 --- a/firmware/target/arm/as3525/sansa-m200v4/system-target.h +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2008 ?? - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef SYSTEM_TARGET_H -#define SYSTEM_TARGET_H - -#include "system-arm.h" - -#define CPUFREQ_MAX 250000000 -#define CPUFREQ_DEFAULT 250000000 -#define CPUFREQ_NORMAL 250000000 - -#endif /* SYSTEM_TARGET_H */ diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index 10338ee148..bc3911afdf 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c @@ -219,6 +219,11 @@ void system_init(void) while(!(CGU_INTCTRL & (1<<0))); /* wait until PLLA is locked */ CGU_PROC = (3<<2)|0x01; /* fclk = PLLA*5/8 = 240 MHz */ +#ifndef BOOTLOADER +#ifdef HAVE_ADJUSTABLE_CPU_FREQ + set_cpu_frequency(CPUFREQ_DEFAULT); +#endif +#endif asm volatile( "mov r0, #0 \n" @@ -231,8 +236,6 @@ void system_init(void) sdram_init(); - CGU_PERI |= (5<<2)|0x01; /* pclk = PLLA / 6 = 64 MHz */ - /* enable timer interface for TIMER1 & TIMER2 */ CGU_PERI |= CGU_TIMERIF_CLOCK_ENABLE; @@ -264,11 +267,19 @@ int system_memory_guard(int newmode) } #ifndef BOOTLOADER - #ifdef HAVE_ADJUSTABLE_CPU_FREQ void set_cpu_frequency(long frequency) { - /* TODO */ + int divider = CPUFREQ_MAX / frequency; + + if(divider > 16) + divider = 16; + else if(divider < 1) + divider = 1; + + cpu_frequency = CPUFREQ_MAX / divider; + + CGU_PROC &= ~(0xf << 4) /* clear divider bits */ ^ ((divider-1) << 4); } #endif /* HAVE_ADJUSTABLE_CPU_FREQ */ #endif /* BOOTLOADER */ diff --git a/firmware/target/arm/as3525/system-target.h b/firmware/target/arm/as3525/system-target.h new file mode 100644 index 0000000000..2309b9790f --- /dev/null +++ b/firmware/target/arm/as3525/system-target.h @@ -0,0 +1,30 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Rafaël Carré + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef SYSTEM_TARGET_H +#define SYSTEM_TARGET_H + +#include "system-arm.h" + +#define CPUFREQ_MAX 240000000 +#define CPUFREQ_DEFAULT 24000000 +#define CPUFREQ_NORMAL 30000000 + +#endif /* SYSTEM_TARGET_H */ -- cgit v1.2.3