summaryrefslogtreecommitdiff
path: root/firmware/target/arm/olympus/mrobe-500/system-mr500.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/olympus/mrobe-500/system-mr500.c')
-rw-r--r--firmware/target/arm/olympus/mrobe-500/system-mr500.c181
1 files changed, 181 insertions, 0 deletions
diff --git a/firmware/target/arm/olympus/mrobe-500/system-mr500.c b/firmware/target/arm/olympus/mrobe-500/system-mr500.c
new file mode 100644
index 0000000000..c93c9f6260
--- /dev/null
+++ b/firmware/target/arm/olympus/mrobe-500/system-mr500.c
@@ -0,0 +1,181 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "kernel.h"
21#include "system.h"
22#include "panic.h"
23
24#define default_interrupt(name) \
25 extern __attribute__((weak,alias("UIRQ"))) void name (void)
26
27default_interrupt(TIMER0);
28default_interrupt(TIMER1);
29default_interrupt(TIMER2);
30default_interrupt(TIMER3);
31default_interrupt(CCD_VD0);
32default_interrupt(CCD_VD1);
33default_interrupt(CCD_WEN);
34default_interrupt(VENC);
35default_interrupt(SERIAL0);
36default_interrupt(SERIAL1);
37default_interrupt(EXT_HOST);
38default_interrupt(DSPHINT);
39default_interrupt(UART0);
40default_interrupt(UART1);
41default_interrupt(USB_DMA);
42default_interrupt(USB_CORE);
43default_interrupt(VLYNQ);
44default_interrupt(MTC0);
45default_interrupt(MTC1);
46default_interrupt(SD_MMC);
47default_interrupt(SDIO_MS);
48default_interrupt(GIO0);
49default_interrupt(GIO1);
50default_interrupt(GIO2);
51default_interrupt(GIO3);
52default_interrupt(GIO4);
53default_interrupt(GIO5);
54default_interrupt(GIO6);
55default_interrupt(GIO7);
56default_interrupt(GIO8);
57default_interrupt(GIO9);
58default_interrupt(GIO10);
59default_interrupt(GIO11);
60default_interrupt(GIO12);
61default_interrupt(GIO13);
62default_interrupt(GIO14);
63default_interrupt(GIO15);
64default_interrupt(PREVIEW0);
65default_interrupt(PREVIEW1);
66default_interrupt(WATCHDOG);
67default_interrupt(I2C);
68default_interrupt(CLKC);
69default_interrupt(ICE);
70default_interrupt(ARMCOM_RX);
71default_interrupt(ARMCOM_TX);
72default_interrupt(RESERVED);
73
74static void (* const irqvector[])(void) =
75{
76 TIMER0,TIMER1,TIMER2,TIMER3,CCD_VD0,CCD_VD1,
77 CCD_WEN,VENC,SERIAL0,SERIAL1,EXT_HOST,DSPHINT,
78 UART0,UART1,USB_DMA,USB_CORE,VLYNQ,MTC0,MTC1,
79 SD_MMC,SDIO_MS,GIO0,GIO1,GIO2,GIO3,GIO4,GIO5,
80 GIO6,GIO7,GIO8,GIO9,GIO10,GIO11,GIO12,GIO13,
81 GIO14,GIO15,PREVIEW0,PREVIEW1,WATCHDOG,I2C,CLKC,
82 ICE,ARMCOM_RX,ARMCOM_TX,RESERVED
83};
84
85static const char * const irqname[] =
86{
87 "TIMER0","TIMER1","TIMER2","TIMER3","CCD_VD0","CCD_VD1",
88 "CCD_WEN","VENC","SERIAL0","SERIAL1","EXT_HOST","DSPHINT",
89 "UART0","UART1","USB_DMA","USB_CORE","VLYNQ","MTC0","MTC1",
90 "SD_MMC","SDIO_MS","GIO0","GIO1","GIO2","GIO3","GIO4","GIO5",
91 "GIO6","GIO7","GIO8","GIO9","GIO10","GIO11","GIO12","GIO13",
92 "GIO14","GIO15","PREVIEW0","PREVIEW1","WATCHDOG","I2C","CLKC",
93 "ICE","ARMCOM_RX","ARMCOM_TX","RESERVED"
94};
95
96static void UIRQ(void)
97{
98 unsigned int offset = inw(IO_INTC_IRQENTRY0);
99 panicf("Unhandled IRQ %02X: %s", offset, irqname[offset]);
100}
101
102void irq_handler(void) __attribute__((interrupt ("IRQ"), naked));
103void irq_handler(void)
104{
105 /*
106 * Based on: linux/arch/arm/kernel/entry-armv.S and system-meg-fx.c
107 */
108
109 asm volatile (
110 "sub lr, lr, #4 \r\n"
111 "stmfd sp!, {r0-r3, ip, lr} \r\n"
112 "mov r0, #0x00030000 \r\n"
113 "ldr r0, [r0, #0x518] \r\n"
114 "ldr r1, =irqvector \r\n"
115 "ldr r1, [r1, r0, lsl #2] \r\n"
116 "mov lr, pc \r\n"
117 "bx r1 \r\n"
118 "ldmfd sp!, {r0-r3, ip, pc}^ \r\n"
119 );
120}
121
122void system_reboot(void)
123{
124
125}
126
127void system_init(void)
128{
129 /* taken from linux/arch/arm/mach-itdm320-20/irq.c */
130
131 /* Clearing all FIQs and IRQs. */
132 outw(0xFFFF, IO_INTC_IRQ0);
133 outw(0xFFFF, IO_INTC_IRQ1);
134 outw(0xFFFF, IO_INTC_IRQ2);
135
136 outw(0xFFFF, IO_INTC_FIQ0);
137 outw(0xFFFF, IO_INTC_FIQ1);
138 outw(0xFFFF, IO_INTC_FIQ2);
139
140 /* Masking all Interrupts. */
141 outw(0, IO_INTC_EINT0);
142 outw(0, IO_INTC_EINT1);
143 outw(0, IO_INTC_EINT2);
144
145 /* Setting INTC to all IRQs. */
146 outw(0, IO_INTC_FISEL0);
147 outw(0, IO_INTC_FISEL1);
148 outw(0, IO_INTC_FISEL2);
149}
150
151int system_memory_guard(int newmode)
152{
153 (void)newmode;
154 return 0;
155}
156
157#ifdef HAVE_ADJUSTABLE_CPU_FREQ
158
159void set_cpu_frequency(long frequency)
160{
161 if (frequency == CPUFREQ_MAX)
162 {
163 asm volatile("mov r0, #0\n"
164 "mrc p15, 0, r0, c1, c0, 0\n"
165 "orr r0, r0, #3<<30\n" /* set to Asynchronous mode*/
166 "mcr p15, 0, r0, c1, c0, 0" : : : "r0");
167
168 FREQ = CPUFREQ_MAX;
169 }
170 else
171 {
172 asm volatile("mov r0, #0\n"
173 "mrc p15, 0, r0, c1, c0, 0\n"
174 "bic r0, r0, #3<<30\n" /* set to FastBus mode*/
175 "mcr p15, 0, r0, c1, c0, 0" : : : "r0");
176
177 FREQ = CPUFREQ_NORMAL;
178 }
179}
180
181#endif