diff options
Diffstat (limited to 'firmware/target/arm/olympus/mrobe-500/system-mr500.c')
-rw-r--r-- | firmware/target/arm/olympus/mrobe-500/system-mr500.c | 181 |
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 | |||
27 | default_interrupt(TIMER0); | ||
28 | default_interrupt(TIMER1); | ||
29 | default_interrupt(TIMER2); | ||
30 | default_interrupt(TIMER3); | ||
31 | default_interrupt(CCD_VD0); | ||
32 | default_interrupt(CCD_VD1); | ||
33 | default_interrupt(CCD_WEN); | ||
34 | default_interrupt(VENC); | ||
35 | default_interrupt(SERIAL0); | ||
36 | default_interrupt(SERIAL1); | ||
37 | default_interrupt(EXT_HOST); | ||
38 | default_interrupt(DSPHINT); | ||
39 | default_interrupt(UART0); | ||
40 | default_interrupt(UART1); | ||
41 | default_interrupt(USB_DMA); | ||
42 | default_interrupt(USB_CORE); | ||
43 | default_interrupt(VLYNQ); | ||
44 | default_interrupt(MTC0); | ||
45 | default_interrupt(MTC1); | ||
46 | default_interrupt(SD_MMC); | ||
47 | default_interrupt(SDIO_MS); | ||
48 | default_interrupt(GIO0); | ||
49 | default_interrupt(GIO1); | ||
50 | default_interrupt(GIO2); | ||
51 | default_interrupt(GIO3); | ||
52 | default_interrupt(GIO4); | ||
53 | default_interrupt(GIO5); | ||
54 | default_interrupt(GIO6); | ||
55 | default_interrupt(GIO7); | ||
56 | default_interrupt(GIO8); | ||
57 | default_interrupt(GIO9); | ||
58 | default_interrupt(GIO10); | ||
59 | default_interrupt(GIO11); | ||
60 | default_interrupt(GIO12); | ||
61 | default_interrupt(GIO13); | ||
62 | default_interrupt(GIO14); | ||
63 | default_interrupt(GIO15); | ||
64 | default_interrupt(PREVIEW0); | ||
65 | default_interrupt(PREVIEW1); | ||
66 | default_interrupt(WATCHDOG); | ||
67 | default_interrupt(I2C); | ||
68 | default_interrupt(CLKC); | ||
69 | default_interrupt(ICE); | ||
70 | default_interrupt(ARMCOM_RX); | ||
71 | default_interrupt(ARMCOM_TX); | ||
72 | default_interrupt(RESERVED); | ||
73 | |||
74 | static 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 | |||
85 | static 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 | |||
96 | static void UIRQ(void) | ||
97 | { | ||
98 | unsigned int offset = inw(IO_INTC_IRQENTRY0); | ||
99 | panicf("Unhandled IRQ %02X: %s", offset, irqname[offset]); | ||
100 | } | ||
101 | |||
102 | void irq_handler(void) __attribute__((interrupt ("IRQ"), naked)); | ||
103 | void 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 | |||
122 | void system_reboot(void) | ||
123 | { | ||
124 | |||
125 | } | ||
126 | |||
127 | void 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 | |||
151 | int system_memory_guard(int newmode) | ||
152 | { | ||
153 | (void)newmode; | ||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
158 | |||
159 | void 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 | ||