summaryrefslogtreecommitdiff
path: root/firmware/timer.c
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2009-06-12 21:11:45 +0000
committerBertrik Sikken <bertrik@sikken.nl>2009-06-12 21:11:45 +0000
commitd1faf8b39cf9492d1cd6f2e26b916dce0fe0354f (patch)
tree0759746bc14686cc506754ef17c8fd4bee41db5f /firmware/timer.c
parent9d2208e806a630b24c185ab9eb80c09a5ad8370f (diff)
downloadrockbox-d1faf8b39cf9492d1cd6f2e26b916dce0fe0354f.tar.gz
rockbox-d1faf8b39cf9492d1cd6f2e26b916dce0fe0354f.zip
FS#10317 - Sansa AMS 32-bit timers. Configure the timers for 32-bit mode instead of the default 16-bit mode.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21266 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/timer.c')
-rw-r--r--firmware/timer.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/firmware/timer.c b/firmware/timer.c
index e9f11b6ae7..85e50ae3ca 100644
--- a/firmware/timer.c
+++ b/firmware/timer.c
@@ -109,23 +109,17 @@ void TIMER1_ISR(void)
109 109
110static bool timer_set(long cycles, bool start) 110static bool timer_set(long cycles, bool start)
111{ 111{
112#if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || CONFIG_CPU == AS3525 112#if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
113 int phi = 0; /* bits for the prescaler */ 113 int phi = 0; /* bits for the prescaler */
114 int prescale = 1; 114 int prescale = 1;
115 115
116#if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
117#define PRESCALE_STEP 1
118#else /* CONFIG_CPU == AS3525 */
119#define PRESCALE_STEP 4
120#endif
121
122 while (cycles > 0x10000) 116 while (cycles > 0x10000)
123 { /* work out the smallest prescaler that makes it fit */ 117 { /* work out the smallest prescaler that makes it fit */
124#if CONFIG_CPU == SH7034 || CONFIG_CPU == AS3525 118#if CONFIG_CPU == SH7034
125 phi++; 119 phi++;
126#endif 120#endif
127 prescale <<= PRESCALE_STEP; 121 prescale <<= 1;
128 cycles >>= PRESCALE_STEP; 122 cycles >>= 1;
129 } 123 }
130#endif 124#endif
131 125
@@ -178,10 +172,6 @@ static bool timer_set(long cycles, bool start)
178 172
179 return true; 173 return true;
180#elif CONFIG_CPU == AS3525 174#elif CONFIG_CPU == AS3525
181 /* XXX: 32 bits cycles could be used */
182 if (prescale > 256 || cycles > 0x10000)
183 return false;
184
185 if (start) 175 if (start)
186 { 176 {
187 if (pfn_unregister != NULL) 177 if (pfn_unregister != NULL)
@@ -193,8 +183,12 @@ static bool timer_set(long cycles, bool start)
193 183
194 TIMER1_LOAD = TIMER1_BGLOAD = cycles; 184 TIMER1_LOAD = TIMER1_BGLOAD = cycles;
195 /* /!\ bit 4 (reserved) must not be modified 185 /* /!\ bit 4 (reserved) must not be modified
196 * periodic mode, interrupt enabled, 16 bits counter */ 186 * periodic mode, interrupt enabled, no prescale, 32 bits counter */
197 TIMER1_CONTROL = (TIMER1_CONTROL & (1<<4)) | 0xe0 | (phi<<2); 187 TIMER1_CONTROL = (TIMER2_CONTROL & (1<<4)) |
188 TIMER_ENABLE |
189 TIMER_PERIODIC |
190 TIMER_INT_ENABLE |
191 TIMER_32_BIT;
198 return true; 192 return true;
199#elif defined CPU_COLDFIRE 193#elif defined CPU_COLDFIRE
200 if (prescale > 4096/CPUFREQ_MAX_MULT) 194 if (prescale > 4096/CPUFREQ_MAX_MULT)