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
This commit is contained in:
Rafaël Carré 2008-11-26 16:46:12 +00:00
parent a39e4e9962
commit 97e907538a
5 changed files with 19 additions and 98 deletions

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 ??
* 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
@ -23,8 +23,8 @@
#include "system-arm.h"
#define CPUFREQ_MAX 250000000
#define CPUFREQ_DEFAULT 250000000
#define CPUFREQ_NORMAL 250000000
#define CPUFREQ_MAX 240000000
#define CPUFREQ_DEFAULT 24000000
#define CPUFREQ_NORMAL 30000000
#endif /* SYSTEM_TARGET_H */