CPU boosting support for ipod nano and video. The rest of the targets

are either untested or do not work with the current code.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9070 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thom Johansen 2006-03-17 02:02:13 +00:00
parent 4ba14d9113
commit f6e856774c
5 changed files with 71 additions and 18 deletions

View file

@ -1049,7 +1049,9 @@ bool dbg_ports(void)
lcd_puts(0, line++, buf);
snprintf(buf, sizeof(buf), "GPIO_D: %02x", gpio_d);
lcd_puts(0, line++, buf);
unsigned hehe = 0x12345678;
snprintf(buf, sizeof(buf), "%x %x", hehe, swap32(hehe));
lcd_puts(0, line++, buf);
lcd_update();
button = button_get_w_tmo(HZ/10);
@ -1183,16 +1185,24 @@ bool dbg_cpufreq(void)
switch(button)
{
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD)
case BUTTON_MENU:
#else
case BUTTON_UP:
#endif
cpu_boost(true);
break;
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD)
case BUTTON_PLAY:
#else
case BUTTON_DOWN:
#endif
cpu_boost(false);
break;
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
(CONFIG_KEYPAD == IRIVER_H300_PAD)
(CONFIG_KEYPAD == IRIVER_H300_PAD) || \
(CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD)
case BUTTON_SELECT:
#else
case BUTTON_PLAY:
@ -1200,9 +1210,13 @@ bool dbg_cpufreq(void)
set_cpu_frequency(CPUFREQ_DEFAULT);
boost_counter = 0;
break;
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD)
case BUTTON_LEFT:
#else
case SETTINGS_CANCEL:
case SETTINGS_OK2:
#endif
return false;
}
}

View file

@ -73,7 +73,7 @@
#define ROM_START 0x00000000
/* Define this to the CPU frequency */
#define CPU_FREQ 11289600
#define CPU_FREQ 24000000
#define CONFIG_LCD LCD_IPODNANO
@ -95,7 +95,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 "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT

View file

@ -97,7 +97,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 "ipod"
#define BOOTFILE "rockbox." BOOTFILE_EXT

View file

@ -305,8 +305,11 @@ static inline void invalidate_icache(void)
/* TODO: Implement set_irq_level and check CPU frequencies */
#define CPUFREQ_DEFAULT CPU_FREQ
#define CPUFREQ_NORMAL 37500000
#define CPUFREQ_DEFAULT_MULT 8
#define CPUFREQ_DEFAULT 240000000
#define CPUFREQ_NORMAL_MULT 10
#define CPUFREQ_NORMAL 30000000
#define CPUFREQ_MAX_MULT 25
#define CPUFREQ_MAX 75000000
static inline unsigned short swap16(unsigned short value)

View file

@ -1200,21 +1200,55 @@ static void ipod_init_cache(void)
inb(i);
}
static void ipod_set_cpu_speed(void)
/* Only these two support CPU boosting at the moment */
#if defined(APPLE_IPODNANO) || defined(APPLE_IPODVIDEO)
void set_cpu_frequency(long frequency)
{
outl(inl(0x70000020) | (1<<30), 0x70000020);
unsigned long postmult;
/* Set run state to 24MHz */
if (frequency == CPUFREQ_NORMAL)
postmult = CPUFREQ_NORMAL_MULT;
else if (frequency == CPUFREQ_MAX)
postmult = CPUFREQ_MAX_MULT;
else
postmult = CPUFREQ_DEFAULT_MULT;
cpu_frequency = frequency;
/* Enable PLL? */
outl(inl(0x70000020) | (1<<30), 0x70000020);
/* Select 24MHz crystal as clock source? */
outl((inl(0x60006020) & 0x0fffff0f) | 0x20000020, 0x60006020);
/* 75 MHz (24/8)*25 */
outl(0xaa021908, 0x60006034);
udelay(2000);
/* Clock frequency = (24/8)*postmult */
outl(0xaa020000 | 8 | (postmult << 8), 0x60006034);
/* Wait for PLL relock? */
udelay(2000);
outl((inl(0x60006020) & 0x0fffff0f) | 0x20000070, 0x60006020);
/* Select PLL as clock source? */
outl((inl(0x60006020) & 0x0fffff0f) | 0x20000070, 0x60006020);
}
#else
void ipod_set_cpu_frequency(void)
{
/* Enable PLL? */
outl(inl(0x70000020) | (1<<30), 0x70000020);
/* Select 24MHz crystal as clock source? */
outl((inl(0x60006020) & 0x0fffff0f) | 0x20000020, 0x60006020);
/* Clock frequency = (24/8)*25 = 75MHz */
outl(0xaa020000 | 8 | (25 << 8), 0x60006034);
/* Wait for PLL relock? */
udelay(2000);
/* Select PLL as clock source? */
outl((inl(0x60006020) & 0x0fffff0f) | 0x20000070, 0x60006020);
}
#endif
#endif /* BOOTLOADER */
void system_init(void)
{
#ifndef BOOTLOADER
@ -1230,8 +1264,10 @@ void system_init(void)
outl(-1, 0x60001038);
outl(-1, 0x60001028);
outl(-1, 0x6000101c);
ipod_set_cpu_speed();
ipod_init_cache();
#if !defined(APPLE_IPODNANO) && !defined(APPLE_IPODVIDEO)
ipod_set_cpu_frequency();
#endif
ipod_init_cache();
#endif
}