summaryrefslogtreecommitdiff
path: root/firmware/target/arm/system-pp5002.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-07-31 10:56:50 +0000
committerJens Arnold <amiconn@rockbox.org>2007-07-31 10:56:50 +0000
commit1bc3b7feb2b0fc1014c41203ab82047ec94f69d4 (patch)
tree2148dcd33c48b8da7f6d2619453af4367a6509dc /firmware/target/arm/system-pp5002.c
parent1dc5435f8ebe067fcd88dea72ba65ea9c186a6a6 (diff)
downloadrockbox-1bc3b7feb2b0fc1014c41203ab82047ec94f69d4.tar.gz
rockbox-1bc3b7feb2b0fc1014c41203ab82047ec94f69d4.zip
PP5002: Clock setup cleanup. * Switch to 80MHz when boosted like on the other PP targets. * Prepare sleep mode by adding CPUFREQ_SLEEP. This is already confirmed working, but a lot of functions in rockbox will probably hang because the microsecond timer isn't running in this mode.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14096 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/system-pp5002.c')
-rw-r--r--firmware/target/arm/system-pp5002.c91
1 files changed, 40 insertions, 51 deletions
diff --git a/firmware/target/arm/system-pp5002.c b/firmware/target/arm/system-pp5002.c
index 38dfe5b49c..5bff4fb202 100644
--- a/firmware/target/arm/system-pp5002.c
+++ b/firmware/target/arm/system-pp5002.c
@@ -91,60 +91,51 @@ static void ipod_init_cache(void)
91 outl(0x3, 0xcf004024); 91 outl(0x3, 0xcf004024);
92} 92}
93 93
94#endif
95
96#ifdef HAVE_ADJUSTABLE_CPU_FREQ 94#ifdef HAVE_ADJUSTABLE_CPU_FREQ
97void set_cpu_frequency(long frequency) 95void set_cpu_frequency(long frequency)
96#else
97static void pp_set_cpu_frequency(long frequency)
98#endif
98{ 99{
99 unsigned long postmult; 100 cpu_frequency = frequency;
100
101 if (CURRENT_CORE == CPU)
102 {
103 if (frequency == CPUFREQ_NORMAL)
104 postmult = CPUFREQ_NORMAL_MULT;
105 else if (frequency == CPUFREQ_MAX)
106 postmult = CPUFREQ_MAX_MULT;
107 else
108 postmult = CPUFREQ_DEFAULT_MULT;
109 cpu_frequency = frequency;
110
111 outl(0xd19b, 0xcf005038);
112
113 outl(inl(0xcf005010) | 0x6000, 0xcf005010);
114 outl(0x01, 0xcf005008);
115 outl(0xa9, 0xcf00500c);
116 outl(0xe000, 0xcf005010);
117 101
118 /* Clock frequency = (24/4)*postmult */ 102 PLL_CONTROL |= 0x6000; /* make sure some enable bits are set */
119 outl(4, 0xcf005018); 103 CLOCK_ENABLE = 0x01; /* select source #1 */
120 outl(postmult, 0xcf00501c);
121 104
122 /* Wait for PLL relock? */ 105 switch (frequency)
123 udelay(200); 106 {
124 107 case CPUFREQ_MAX:
125 outl(0x02, 0xcf005008); 108 PLL_UNLOCK = 0xd19b; /* unlock frequencies > 66MHz */
109 CLOCK_SOURCE = 0xa9; /* source #1: 24 Mhz, source #2..#4: PLL */
110 PLL_CONTROL = 0xe000; /* PLL enabled */
111 PLL_DIV = 3; /* 10/3 * 24MHz */
112 PLL_MULT = 10;
113 udelay(200); /* wait for relock */
114 break;
115
116 case CPUFREQ_NORMAL:
117 CLOCK_SOURCE = 0xa9; /* source #1: 24 Mhz, source #2..#4: PLL */
118 PLL_CONTROL = 0xe000; /* PLL enabled */
119 PLL_DIV = 4; /* 5/4 * 24MHz */
120 PLL_MULT = 5;
121 udelay(200); /* wait for relock */
122 break;
123
124 case CPUFREQ_SLEEP:
125 CLOCK_SOURCE = 0x51; /* source #2: 32kHz, #1, #2, #4: 24MHz */
126 PLL_CONTROL = 0x6000; /* PLL disabled */
127 udelay(10000); /* let 32kHz source stabilize? */
128 break;
129
130 default:
131 CLOCK_SOURCE = 0x55; /* source #1..#4: 24 Mhz */
132 PLL_CONTROL = 0x6000; /* PLL disabled */
133 cpu_frequency = CPUFREQ_DEFAULT;
134 break;
126 } 135 }
136 CLOCK_ENABLE = 0x02; /* select source #2 */
127} 137}
128#elif !defined(BOOTLOADER) 138#endif /* !BOOTLOADER */
129static void ipod_set_cpu_speed(void)
130{
131 outl(0xd19b, 0xcf005038);
132
133 outl(0x02, 0xcf005008);
134 outl(0x55, 0xcf00500c);
135 outl(0x6000, 0xcf005010);
136
137 /* 78 MHz (24*13/4) */
138 outl(4, 0xcf005018);
139 outl(13, 0xcf00501c);
140
141 outl(0xe000, 0xcf005010);
142
143 udelay(2000);
144
145 outl(0xa8, 0xcf00500c);
146}
147#endif
148 139
149void system_init(void) 140void system_init(void)
150{ 141{
@@ -165,7 +156,7 @@ void system_init(void)
165 GPIOD_INT_EN = 0; 156 GPIOD_INT_EN = 0;
166 157
167#ifndef HAVE_ADJUSTABLE_CPU_FREQ 158#ifndef HAVE_ADJUSTABLE_CPU_FREQ
168 ipod_set_cpu_speed(); 159 pp_set_cpu_frequency(CPUFREQ_MAX);
169#endif 160#endif
170 } 161 }
171 ipod_init_cache(); 162 ipod_init_cache();
@@ -174,7 +165,7 @@ void system_init(void)
174 165
175void system_reboot(void) 166void system_reboot(void)
176{ 167{
177 outl(inl(0xcf005030) | 0x4, 0xcf005030); 168 DEV_RS |= 4;
178} 169}
179 170
180int system_memory_guard(int newmode) 171int system_memory_guard(int newmode)
@@ -182,5 +173,3 @@ int system_memory_guard(int newmode)
182 (void)newmode; 173 (void)newmode;
183 return 0; 174 return 0;
184} 175}
185
186