diff options
Diffstat (limited to 'firmware/target/arm/tms320dm320/system-dm320.c')
-rw-r--r-- | firmware/target/arm/tms320dm320/system-dm320.c | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/firmware/target/arm/tms320dm320/system-dm320.c b/firmware/target/arm/tms320dm320/system-dm320.c index da3b9913a2..c03e05522c 100644 --- a/firmware/target/arm/tms320dm320/system-dm320.c +++ b/firmware/target/arm/tms320dm320/system-dm320.c | |||
@@ -114,7 +114,12 @@ void irq_handler(void) | |||
114 | 114 | ||
115 | asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */ | 115 | asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */ |
116 | "sub sp, sp, #8 \n"); /* Reserve stack */ | 116 | "sub sp, sp, #8 \n"); /* Reserve stack */ |
117 | irqvector[(IO_INTC_IRQENTRY0>>2)-1](); | 117 | unsigned short addr = IO_INTC_IRQENTRY0>>2; |
118 | if(addr != 0) | ||
119 | { | ||
120 | addr--; | ||
121 | irqvector[addr](); | ||
122 | } | ||
118 | asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */ | 123 | asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */ |
119 | "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */ | 124 | "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */ |
120 | "subs pc, lr, #4 \n"); /* Return from FIQ */ | 125 | "subs pc, lr, #4 \n"); /* Return from FIQ */ |
@@ -130,18 +135,34 @@ void fiq_handler(void) | |||
130 | "sub lr, lr, #4 \r\n" | 135 | "sub lr, lr, #4 \r\n" |
131 | "stmfd sp!, {r0-r3, ip, lr} \r\n" | 136 | "stmfd sp!, {r0-r3, ip, lr} \r\n" |
132 | "mov r0, #0x00030000 \r\n" | 137 | "mov r0, #0x00030000 \r\n" |
133 | "ldr r0, [r0, #0x518] \r\n" | 138 | "ldr r0, [r0, #0x518] \r\n" |
139 | "sub r0, r0, #1 \r\n" | ||
134 | "ldr r1, =irqvector \r\n" | 140 | "ldr r1, =irqvector \r\n" |
135 | "ldr r1, [r1, r0, lsl #2] \r\n" | 141 | "ldr r1, [r1, r0, lsl #2] \r\n" |
136 | "mov lr, pc \r\n" | 142 | "blx r1 \r\n" |
137 | "bx r1 \r\n" | ||
138 | "ldmfd sp!, {r0-r3, ip, pc}^ \r\n" | 143 | "ldmfd sp!, {r0-r3, ip, pc}^ \r\n" |
139 | ); | 144 | ); |
140 | } | 145 | } |
141 | 146 | ||
142 | void system_reboot(void) | 147 | void system_reboot(void) |
143 | { | 148 | { |
144 | 149 | /* Code taken from linux/include/asm-arm/arch-itdm320-20/system.h at NeuroSVN */ | |
150 | __asm__ __volatile__( | ||
151 | "mov ip, #0 \n" | ||
152 | "mcr p15, 0, ip, c7, c7, 0 @ invalidate cache \n" | ||
153 | "mcr p15, 0, ip, c7, c10,4 @ drain WB \n" | ||
154 | "mcr p15, 0, ip, c8, c7, 0 @ flush TLB (v4) \n" | ||
155 | "mrc p15, 0, ip, c1, c0, 0 @ get ctrl register\n" | ||
156 | "bic ip, ip, #0x000f @ ............wcam \n" | ||
157 | "bic ip, ip, #0x2100 @ ..v....s........ \n" | ||
158 | "mcr p15, 0, ip, c1, c0, 0 @ ctrl register \n" | ||
159 | "mov ip, #0xFF000000 \n" | ||
160 | "orr ip, ip, #0xFF0000 @ ip = 0xFFFF0000 \n" | ||
161 | "mov pc, ip \n" | ||
162 | : | ||
163 | : | ||
164 | : "cc" | ||
165 | ); | ||
145 | } | 166 | } |
146 | 167 | ||
147 | void system_init(void) | 168 | void system_init(void) |
@@ -167,16 +188,28 @@ void system_init(void) | |||
167 | IO_INTC_FISEL1 = 0; | 188 | IO_INTC_FISEL1 = 0; |
168 | IO_INTC_FISEL2 = 0; | 189 | IO_INTC_FISEL2 = 0; |
169 | 190 | ||
191 | /* IRQENTRY only reflects enabled interrupts */ | ||
192 | IO_INTC_RAW = 0; | ||
193 | |||
170 | IO_INTC_ENTRY_TBA0 = 0; | 194 | IO_INTC_ENTRY_TBA0 = 0; |
171 | IO_INTC_ENTRY_TBA1 = 0; | 195 | IO_INTC_ENTRY_TBA1 = 0; |
172 | 196 | ||
173 | /* Turn off other timers */ | 197 | unsigned short i; |
198 | /* Reset interrupt priorities to default values */ | ||
199 | for(i = 0; i < 23; i++) | ||
200 | DM320_REG(0x0540+i*2) = ( (i*2+1) << 8 ) | i*2 ;//IO_INTC_PRIORITYx | ||
201 | |||
202 | /* Turn off all timers */ | ||
203 | IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP; | ||
204 | IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP; | ||
174 | IO_TIMER2_TMMD = CONFIG_TIMER2_TMMD_STOP; | 205 | IO_TIMER2_TMMD = CONFIG_TIMER2_TMMD_STOP; |
175 | IO_TIMER3_TMMD = CONFIG_TIMER3_TMMD_STOP; | 206 | IO_TIMER3_TMMD = CONFIG_TIMER3_TMMD_STOP; |
176 | 207 | ||
208 | #ifndef CREATIVE_ZVM | ||
177 | /* set GIO26 (reset pin) to output and low */ | 209 | /* set GIO26 (reset pin) to output and low */ |
178 | IO_GIO_BITCLR1=(1<<10); | 210 | IO_GIO_BITCLR1=(1<<10); |
179 | IO_GIO_DIR1&=~(1<<10); | 211 | IO_GIO_DIR1&=~(1<<10); |
212 | #endif | ||
180 | 213 | ||
181 | uart_init(); | 214 | uart_init(); |
182 | spi_init(); | 215 | spi_init(); |
@@ -186,9 +219,18 @@ void system_init(void) | |||
186 | /* Make sure everything is mapped on itself */ | 219 | /* Make sure everything is mapped on itself */ |
187 | map_section(0, 0, 0x1000, CACHE_NONE); | 220 | map_section(0, 0, 0x1000, CACHE_NONE); |
188 | /* Enable caching for RAM */ | 221 | /* Enable caching for RAM */ |
189 | map_section(0x00900000, 0x00900000, 64, CACHE_ALL); | 222 | map_section(CONFIG_SDRAM_START, CONFIG_SDRAM_START, MEM, CACHE_ALL); |
190 | /* enable buffered writing for the framebuffer */ | 223 | /* enable buffered writing for the framebuffer */ |
191 | map_section((int)FRAME, (int)FRAME, 1, BUFFERED); | 224 | map_section((int)FRAME, (int)FRAME, 1, BUFFERED); |
225 | #ifdef CREATIVE_ZVM | ||
226 | //mimic OF | ||
227 | map_section(0x00100000, 0x00100000, 4, CACHE_NONE); | ||
228 | map_section(0x04700000, 0x04700000, 2, BUFFERED); | ||
229 | map_section(0x40000000, 0x40000000, 16, CACHE_NONE); | ||
230 | map_section(0x50000000, 0x50000000, 16, CACHE_NONE); | ||
231 | map_section(0x60000000, 0x60000000, 16, CACHE_NONE); | ||
232 | map_section(0x80000000, 0x80000000, 1, CACHE_NONE); | ||
233 | #endif | ||
192 | enable_mmu(); | 234 | enable_mmu(); |
193 | } | 235 | } |
194 | 236 | ||