summaryrefslogtreecommitdiff
path: root/firmware/target/arm/olympus
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2007-09-22 23:17:52 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2007-09-22 23:17:52 +0000
commit67ef4500e36fae01157519ae473177674a0d037a (patch)
tree69cd4180ff467bdecbf084a6930b0e02a55f9121 /firmware/target/arm/olympus
parent7d1eeddf93bc1ba23c348b6f64742b3fce85420f (diff)
More interupt/timer work
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14823 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/olympus')
-rw-r--r--firmware/target/arm/olympus/mrobe-500/kernel-mr500.c15
-rw-r--r--firmware/target/arm/olympus/mrobe-500/system-mr500.c28
-rwxr-xr-xfirmware/target/arm/olympus/mrobe-500/system-target.h32
-rw-r--r--firmware/target/arm/olympus/mrobe-500/timer-mr500.c58
4 files changed, 88 insertions, 45 deletions
diff --git a/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c b/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c
index 450f0e6b03..3ac0730691 100644
--- a/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c
+++ b/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c
@@ -27,7 +27,19 @@ extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
void tick_start(unsigned int interval_in_ms)
{
- (void)interval_in_ms;
+ IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP;
+
+ /* Setup the Prescalar */
+ IO_TIMER1_TMPRSCL = CONFIG_TIMER1_TMPRSCL;
+
+ /* Setup the Divisor */
+ IO_TIMER1_TMDIV = CONFIG_TIMER1_TMDIV;
+
+ /* Turn Timer1 to Free Run mode */
+ IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_FREE_RUN;
+
+ /* Enable the interrupt */
+ IO_INTC_EINT0 |= 1<<IRQ_TIMER1;
}
void TIMER4(void)
@@ -45,4 +57,5 @@ void TIMER4(void)
current_tick++;
+ IO_INTC_IRQ0 |= 1<<IRQ_TIMER1;
}
diff --git a/firmware/target/arm/olympus/mrobe-500/system-mr500.c b/firmware/target/arm/olympus/mrobe-500/system-mr500.c
index 1163104ad2..5b52dc3208 100644
--- a/firmware/target/arm/olympus/mrobe-500/system-mr500.c
+++ b/firmware/target/arm/olympus/mrobe-500/system-mr500.c
@@ -95,7 +95,7 @@ static const char * const irqname[] =
static void UIRQ(void)
{
- unsigned int offset = inw(IO_INTC_IRQENTRY0);
+ unsigned int offset = IO_INTC_IRQENTRY0;
panicf("Unhandled IRQ %02X: %s", offset, irqname[offset]);
}
@@ -105,7 +105,7 @@ void irq_handler(void)
/*
* Based on: linux/arch/arm/kernel/entry-armv.S and system-meg-fx.c
*/
-
+ printf("INTERUPT!");
asm volatile (
"sub lr, lr, #4 \r\n"
"stmfd sp!, {r0-r3, ip, lr} \r\n"
@@ -149,23 +149,23 @@ void system_init(void)
/* taken from linux/arch/arm/mach-itdm320-20/irq.c */
/* Clearing all FIQs and IRQs. */
- outw(0xFFFF, IO_INTC_IRQ0);
- outw(0xFFFF, IO_INTC_IRQ1);
- outw(0xFFFF, IO_INTC_IRQ2);
+ IO_INTC_IRQ0 = 0xFFFF;
+ IO_INTC_IRQ1 = 0xFFFF;
+ IO_INTC_IRQ2 = 0xFFFF;
- outw(0xFFFF, IO_INTC_FIQ0);
- outw(0xFFFF, IO_INTC_FIQ1);
- outw(0xFFFF, IO_INTC_FIQ2);
+ IO_INTC_FIQ0 = 0xFFFF;
+ IO_INTC_FIQ1 = 0xFFFF;
+ IO_INTC_FIQ2 = 0xFFFF;
/* Masking all Interrupts. */
- outw(0, IO_INTC_EINT0);
- outw(0, IO_INTC_EINT1);
- outw(0, IO_INTC_EINT2);
+ IO_INTC_EINT0 = 0;
+ IO_INTC_EINT1 = 0;
+ IO_INTC_EINT2 = 0;
/* Setting INTC to all IRQs. */
- outw(0, IO_INTC_FISEL0);
- outw(0, IO_INTC_FISEL1);
- outw(0, IO_INTC_FISEL2);
+ IO_INTC_FISEL0 = 0;
+ IO_INTC_FISEL1 = 0;
+ IO_INTC_FISEL2 = 0;
}
int system_memory_guard(int newmode)
diff --git a/firmware/target/arm/olympus/mrobe-500/system-target.h b/firmware/target/arm/olympus/mrobe-500/system-target.h
new file mode 100755
index 0000000000..7adfda6f7d
--- /dev/null
+++ b/firmware/target/arm/olympus/mrobe-500/system-target.h
@@ -0,0 +1,32 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Karl Kurbjun
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * 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_SLEEP 32768
+#define CPUFREQ_DEFAULT 24000000
+#define CPUFREQ_NORMAL 30000000
+#define CPUFREQ_MAX 80000000
+
+#define inw(p) (*((volatile unsigned short*)((p) + PHY_IO_BASE)))
+#define outw(v,p) (*((volatile unsigned short*)((p) + PHY_IO_BASE)) = (v))
+
+#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/olympus/mrobe-500/timer-mr500.c b/firmware/target/arm/olympus/mrobe-500/timer-mr500.c
index 846d83b3de..21449ed19f 100644
--- a/firmware/target/arm/olympus/mrobe-500/timer-mr500.c
+++ b/firmware/target/arm/olympus/mrobe-500/timer-mr500.c
@@ -29,59 +29,55 @@ void TIMER0(void)
{
if (pfn_timer != NULL)
pfn_timer();
+ IO_INTC_IRQ0 |= 1<<IRQ_TIMER0;
}
static void stop_timer(void)
{
+ IO_INTC_EINT0 &= ~(1<<IRQ_TIMER0);
+
+ IO_INTC_IRQ0 |= 1<<IRQ_TIMER0;
+
+ IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
}
bool __timer_set(long cycles, bool start)
{
+ int oldlevel;
+ unsigned int divider;
/* taken from linux/arch/arm/mach-itdm320-20/time.c and timer-meg-fx.c */
/* Turn off all timers */
-/* outw(CONFIG_TIMER0_TMMD_STOP, IO_TIMER0_TMMD);
- outw(CONFIG_TIMER1_TMMD_STOP, IO_TIMER1_TMMD);
- outw(CONFIG_TIMER2_TMMD_STOP, IO_TIMER2_TMMD);
- outw(CONFIG_TIMER3_TMMD_STOP, IO_TIMER3_TMMD);
- */
- /* Turn Timer0 to Free Run mode */
-// outw(CONFIG_TIMER0_TMMD_FREE_RUN, IO_TIMER0_TMMD);
-
- bool retval = false;
+ IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
+ IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP;
+ IO_TIMER2_TMMD = CONFIG_TIMER2_TMMD_STOP;
+ IO_TIMER3_TMMD = CONFIG_TIMER3_TMMD_STOP;
/* Find the minimum factor that puts the counter in range 1-65535 */
unsigned int prescaler = (cycles + 65534) / 65535;
/* Test this by writing 1's to registers to see how many bits we have */
/* Maximum divider setting is x / 1024 / 65536 = x / 67108864 */
+ if (start && pfn_unregister != NULL)
{
- int oldlevel;
- unsigned int divider;
-
- if (start && pfn_unregister != NULL)
- {
- pfn_unregister();
- pfn_unregister = NULL;
- }
-
- oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
+ pfn_unregister();
+ pfn_unregister = NULL;
+ }
- /* Max prescale is 1023+1 */
- for (divider = 0; prescaler > 1024; prescaler >>= 1, divider++);
+ oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
- /* Setup the Prescalar */
- outw(prescaler, IO_TIMER0_TMPRSCL);
+ /* Max prescale is 1023+1 */
+ for (divider = 0; prescaler > 1024; prescaler >>= 1, divider++);
- /* Setup the Divisor */
- outw(divider, IO_TIMER0_TMDIV);
+ /* Setup the Prescalar */
+ IO_TIMER0_TMPRSCL = prescaler;
- set_irq_level(oldlevel);
+ /* Setup the Divisor */
+ IO_TIMER0_TMDIV = divider;
- retval = true;
- }
+ set_irq_level(oldlevel);
- return retval;
+ return true;
}
bool __timer_register(void)
@@ -93,7 +89,9 @@ bool __timer_register(void)
stop_timer();
/* Turn Timer0 to Free Run mode */
- outw(0x0002, IO_TIMER0_TMMD);
+ IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_FREE_RUN;
+
+ IO_INTC_EINT0 |= 1<<IRQ_TIMER0;
set_interrupt_status(oldstatus, IRQ_FIQ_STATUS);