summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/debug_menu.c22
-rw-r--r--firmware/export/config-ipodnano.h4
-rw-r--r--firmware/export/config-ipodvideo.h2
-rw-r--r--firmware/export/system.h7
-rw-r--r--firmware/system.c54
5 files changed, 71 insertions, 18 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 267f548d87..619d38c6d2 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -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;
}
}
diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h
index 1843d1809c..6bcbffb3b2 100644
--- a/firmware/export/config-ipodnano.h
+++ b/firmware/export/config-ipodnano.h
@@ -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
diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h
index 6057afa9d7..6ea9fcebb8 100644
--- a/firmware/export/config-ipodvideo.h
+++ b/firmware/export/config-ipodvideo.h
@@ -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
diff --git a/firmware/export/system.h b/firmware/export/system.h
index e88c793fae..eb5bb52053 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -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)
diff --git a/firmware/system.c b/firmware/system.c
index 63cdf0a144..b432cde79a 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -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;
+
+ 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;
- /* Set run state to 24MHz */
+ /* 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
}