diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/arm/s3c2440/crt0.S | 230 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c | 18 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c | 84 |
3 files changed, 244 insertions, 88 deletions
diff --git a/firmware/target/arm/s3c2440/crt0.S b/firmware/target/arm/s3c2440/crt0.S index 6df8e4215d..e916cafe40 100644 --- a/firmware/target/arm/s3c2440/crt0.S +++ b/firmware/target/arm/s3c2440/crt0.S | |||
@@ -40,8 +40,19 @@ vectors: | |||
40 | b irq_handler | 40 | b irq_handler |
41 | b fiq_handler | 41 | b fiq_handler |
42 | 42 | ||
43 | /* This branch is used to make sure that we know where the shutdown routine | ||
44 | * is located in flash (0x04000020) | ||
45 | */ | ||
46 | b rom_shutdown | ||
47 | |||
48 | /* Add some strings to detect the bootloader in flash and give it a version | ||
49 | * number. (0x04000024, 0x04000028) | ||
50 | */ | ||
51 | .string "ROCKBOX" | ||
52 | .word 0x0001 | ||
53 | |||
43 | /* | 54 | /* |
44 | * Function: code_copy | 55 | * Function: word_copy |
45 | * Variables: | 56 | * Variables: |
46 | * r0 = from | 57 | * r0 = from |
47 | * r1 = to | 58 | * r1 = to |
@@ -53,8 +64,7 @@ vectors: | |||
53 | .global word_copy | 64 | .global word_copy |
54 | .type word_copy, %function | 65 | .type word_copy, %function |
55 | word_copy: | 66 | word_copy: |
56 | sub r2, r2, #0x04 | 67 | subs r2, r2, #0x04 |
57 | cmp r2, #0 | ||
58 | ldrge r3, [r0], #4 | 68 | ldrge r3, [r0], #4 |
59 | strge r3, [r1], #4 | 69 | strge r3, [r1], #4 |
60 | bgt word_copy | 70 | bgt word_copy |
@@ -83,14 +93,18 @@ start: | |||
83 | /* Mask all Interupts to be safe */ | 93 | /* Mask all Interupts to be safe */ |
84 | ldr r2, =0xFFFFFFFF | 94 | ldr r2, =0xFFFFFFFF |
85 | mov r1, #0x4A000000 | 95 | mov r1, #0x4A000000 |
86 | str r2, [r1] | 96 | str r2, [r1, #0x08] |
87 | 97 | ||
88 | /* Submask too */ | 98 | /* Submask too */ |
89 | ldr r2, =0x00003FFF | 99 | ldr r2, =0x00003FFF |
90 | str r2, [r1, #0x1C] | 100 | str r2, [r1, #0x1C] |
91 | 101 | ||
92 | /* Check if loaded by the old bootloader or by the OF | 102 | /* Check if loaded by the old bootloader or by the OF. This copy routine |
93 | * Be careful with code size above this as well. | 103 | * cannot run/copy properly until the memory has been initialized, so the copy |
104 | * routine later is still necessary. The old bootloader/OF will initialize the | ||
105 | * memory. | ||
106 | * Be careful with code size above this as well since this routine has to start | ||
107 | * before 0x100 for it to work right. | ||
94 | */ | 108 | */ |
95 | 109 | ||
96 | /* Get the execute address (cannot be past 0x100 for this to work */ | 110 | /* Get the execute address (cannot be past 0x100 for this to work */ |
@@ -125,6 +139,13 @@ start: | |||
125 | skipreset: | 139 | skipreset: |
126 | 140 | ||
127 | /* Initial Clock Setup */ | 141 | /* Initial Clock Setup */ |
142 | /* set Bus to Asynchronous mode (full speed) */ | ||
143 | mov r0, #0 | ||
144 | mrc p15, 0, r0, c1, c0, 0 | ||
145 | ldr r1, =0xC0000000 | ||
146 | orr r0, r0, r1 | ||
147 | mcr p15, 0, r0, c1, c0, 0 | ||
148 | |||
128 | mov r2, #0x7 | 149 | mov r2, #0x7 |
129 | mov r1, #0x4C000000 | 150 | mov r1, #0x4C000000 |
130 | str r2, [r1, #0x14] | 151 | str r2, [r1, #0x14] |
@@ -159,48 +180,11 @@ start: | |||
159 | nop | 180 | nop |
160 | nop | 181 | nop |
161 | 182 | ||
162 | /* If we want to disable extraneous clocks, uncomment, but it can | ||
163 | * freeze the device | ||
164 | */ | ||
165 | #if 0 | ||
166 | ldr r2, =0x6030 | ||
167 | mov r1, #0x4C000000 | ||
168 | str r2, [r1, #0x0C] | ||
169 | #endif | ||
170 | |||
171 | /* set Bus to Asynchronous mode (full speed) */ | ||
172 | mov r0, #0 | ||
173 | mrc p15, 0, r0, c1, c0, 0 | ||
174 | ldr r1, =0xC0000000 | ||
175 | orr r0, r0, r1 | ||
176 | mcr p15, 0, r0, c1, c0, 0 | ||
177 | |||
178 | /* Setup MISCCR */ | 183 | /* Setup MISCCR */ |
179 | ldr r2, =0x00613020 | 184 | ldr r2, =0x00613020 |
180 | mov r1, #0x56000000 | 185 | mov r1, #0x56000000 |
181 | str r2, [r1, #0x80] | 186 | str r2, [r1, #0x80] |
182 | 187 | ||
183 | /* Setup some unknown outputs in GPB and GPH */ | ||
184 | ldr r2, [r1, #0x10] | ||
185 | mov r3, #0x05 | ||
186 | orr r2, r3, r2 | ||
187 | str r2, [r1, #0x10] | ||
188 | |||
189 | ldr r2, [r1, #0x14] | ||
190 | mov r3, #0x03 | ||
191 | orr r2, r3, r2 | ||
192 | str r2, [r1, #0x14] | ||
193 | |||
194 | ldr r2, [r1, #0x70] | ||
195 | mov r3, #0x05 | ||
196 | orr r2, r3, r2 | ||
197 | str r2, [r1, #0x70] | ||
198 | |||
199 | ldr r2, [r1, #0x74] | ||
200 | mov r3, #0x03 | ||
201 | orr r2, r3, r2 | ||
202 | str r2, [r1, #0x74] | ||
203 | |||
204 | /* Memory setup (taken from 0x5070) */ | 188 | /* Memory setup (taken from 0x5070) */ |
205 | 189 | ||
206 | /* BWSCON | 190 | /* BWSCON |
@@ -323,6 +307,18 @@ start: | |||
323 | /* MRSRB7 */ | 307 | /* MRSRB7 */ |
324 | str r2, [r1, #0x30] | 308 | str r2, [r1, #0x30] |
325 | 309 | ||
310 | /* | ||
311 | 0x56000000 0x1FFFCFF | ||
312 | 4 0x1FFFEFF | ||
313 | 0X4800002C 0X0 | ||
314 | 0X560000 | ||
315 | */ | ||
316 | |||
317 | /* GPACON */ | ||
318 | mov r1, #0x56000000 | ||
319 | ldr r2, =0x00FFFFFF | ||
320 | str r2, [r1] | ||
321 | |||
326 | #if 0 | 322 | #if 0 |
327 | /* GPACON */ | 323 | /* GPACON */ |
328 | mov r1, #0x56000000 | 324 | mov r1, #0x56000000 |
@@ -448,8 +444,10 @@ stackmunge: | |||
448 | /* Start the main function */ | 444 | /* Start the main function */ |
449 | ldr pc, =main | 445 | ldr pc, =main |
450 | 446 | ||
451 | /* Should never get here, but let's restart in case */ | 447 | /* Should never get here, but let's restart in case (also needed when |
452 | // b vectors | 448 | * linking) |
449 | */ | ||
450 | b vectors | ||
453 | 451 | ||
454 | /* All illegal exceptions call into UIE with exception address as first | 452 | /* All illegal exceptions call into UIE with exception address as first |
455 | parameter. This is calculated differently depending on which exception | 453 | parameter. This is calculated differently depending on which exception |
@@ -486,6 +484,148 @@ fiq_handler: | |||
486 | UIE: | 484 | UIE: |
487 | b UIE | 485 | b UIE |
488 | 486 | ||
487 | /* | ||
488 | * Function: rom_shutdown | ||
489 | * Variables: | ||
490 | * none | ||
491 | */ | ||
492 | |||
493 | .section .init.text, "ax", %progbits | ||
494 | .align 0x04 | ||
495 | .global rom_shutdown | ||
496 | .type rom_shutdown, %function | ||
497 | rom_shutdown: | ||
498 | /* Turn off the MMU */ | ||
499 | mrc p15, 0, r1, c1, c0, 0 | ||
500 | bic r1, r1, #0x0001 | ||
501 | mcr p15, 0, r1, c1, c0, 0 | ||
502 | |||
503 | /* Taken from 0x10010 */ | ||
504 | ldr r2, =0x56000014 //GPBDAT | ||
505 | ldr r1, =0x56000010 //GPBCON | ||
506 | ldr r3, =0x00015450 | ||
507 | ldr r8, =0x56000024 //GPCDAT | ||
508 | ldr r10, =0x56000020 //GPCCON | ||
509 | ldr r5, =0xAAA054A8 | ||
510 | ldr r6, =0x56000024 //GPDDAT | ||
511 | ldr r7, =0x56000030 //GPDCON | ||
512 | ldr r12, =0x56000044 //GPEDAT | ||
513 | ldr lr, =0x56000040 //GPECON | ||
514 | ldr r0, =0x56000054 //GPFDAT | ||
515 | mov r4, #0 | ||
516 | str r4, [r2] | ||
517 | str r3, [r1] | ||
518 | ldr r1, =0xAAA0AAA5 | ||
519 | ldr r2, =0xAA8002AA | ||
520 | mov r3, #0x80 | ||
521 | str r3, [r8] | ||
522 | add r3, r3, #0x980 | ||
523 | str r5, [r10] | ||
524 | mov r5, #4 | ||
525 | str r4, [r6] | ||
526 | str r1, [r7] | ||
527 | str r4, [r12] | ||
528 | str r2, [lr] | ||
529 | str r4, [r0],#(0x56000064-0x56000054) //(GPGDAT - GPFDAT) | ||
530 | add r12, r12, #(0x56000060-0x56000044)//(GPGCON - GPEDAT) | ||
531 | ldr r1, =0x56000050 //GPFCON | ||
532 | ldr r2, =0x01401002 | ||
533 | mov lr, #0xFFFFFFFF | ||
534 | str r3, [r1],#(0x56000074-0x56000050)// (GPHDAT - GPFCON) | ||
535 | str r4, [r0],#(0x56000060-0x56000054)// (GPGCON - GPFDAT) | ||
536 | // str r2, [r12] | ||
537 | ldr r2, =0x140A5 | ||
538 | mov r3, #0x81 | ||
539 | str r3, [r1] | ||
540 | ldr r12, =0x4A000008 //INTMSK | ||
541 | |||
542 | // mov r3, #0x200000 // disable EINT13 | ||
543 | ldr r3, =0xFFFFFECF | ||
544 | |||
545 | str r2, [r0] // GPFDAT=0x140A5 | ||
546 | ldr r2, =0x56000088 //EXTINT0 | ||
547 | ldr r0, =0x4A000010 //INTPND | ||
548 | |||
549 | add r1, r1, #(0x56000068 - 0x56000050) // (GPGUP - GPFCON) (0x18) | ||
550 | str lr, [r12] /* INTMSK = 0xFFFFFFFF */ | ||
551 | str r3, [r2],#(0x560000A4 - 0x56000088) // (EINTMASK - EXTINT0) disable EINT13 (0x1C) | ||
552 | // mov r3, #0xFFFFFECF | ||
553 | mov r3, #0xFFFFFEFF | ||
554 | str r5, [r1],#(0x56000074-0x56000058) //(GPHDAT - GPFUP) (0x1C) DCLKCON | ||
555 | str r3, [r2] | ||
556 | |||
557 | ldr r11, =0x56000060 | ||
558 | ldr r6, =0x01401002 | ||
559 | str r6, [r11] | ||
560 | |||
561 | // add r3, r3, #0x00000100 | ||
562 | ldr r3, =0xFFFFFFDF; | ||
563 | str r3, [r12] // disable INT_TICK | ||
564 | |||
565 | mov r3, #0x4A000000 | ||
566 | add r2, r2, #(0x560000B0-0x56000088) //(GSTATUS1 - EXTINT0) //; 0x600 (0x28) | ||
567 | str lr, [r1] | ||
568 | str lr, [r3] | ||
569 | mov r3, #0x600 | ||
570 | str lr, [r0] | ||
571 | str r3, [r2] // GSTATUS1 = 0x600 /* what for ??? */ | ||
572 | |||
573 | ldr r12, =0x56000080 //MISCCr | ||
574 | mov r2, #0x58000000 //ADCCON | ||
575 | str r5, [r2] | ||
576 | add r2, r2, #(0x4D000000-0x58000000) //(LCDCON1 - ADCCON) // LCDCON1 (0xF5000000) | ||
577 | ldr r3, [r12] | ||
578 | ldr r0, =0x48000024 // REFRESH | ||
579 | bic r3, r3, #0x700000 | ||
580 | bic r3, r3, #0x3000 | ||
581 | orr r3, r3, #0x600000 | ||
582 | orr r3, r3, #0x3000 | ||
583 | str r3, [r12] // MISCCR = (MISCCR & ~0x100000) | 0x603000; | ||
584 | /* clear [20] BATTFLT_FUNC - BATT_FLT function On/Off. | ||
585 | * 0, Battery fault function will be turned on. | ||
586 | * set [21] BATTFLT_INTR - BATT_FLT Interrupt On/Off. | ||
587 | * 1, Battery fault interrupt will be masked by hardware. | ||
588 | * set [13] SEL_SUSPND1 - USB Port 1 Suspend mode | ||
589 | * 1= suspend mode | ||
590 | * set [12] SEL_SUSPND0 - USB Port 0 Suspend mode | ||
591 | * 1= suspend mode | ||
592 | */ | ||
593 | mov r3, #0x4C000000 // LOCKTIME | ||
594 | str r4, [r2] | ||
595 | |||
596 | str lr, [r3] | ||
597 | ldr r1, [r0] | ||
598 | ldr lr, =0x4C00000C // CLKCON | ||
599 | // str r1, [r11,#-0x28] | ||
600 | ldr r2, [lr] | ||
601 | // str r2, [r11,#-0x28] | ||
602 | ldr r3, [r0] | ||
603 | Orr r3, r3, #0x00400000 | ||
604 | /* REFRESH | ||
605 | * [22] TREFMD - SDRAM Refresh Mode | ||
606 | */ | ||
607 | str r3, [r0] | ||
608 | ldr r2, [r12] | ||
609 | |||
610 | ldr r3, =0x00004018 | ||
611 | /* [3] SLEEP - Control SLEEP mode of S3C2440X. | ||
612 | * [4] NAND - Control HCLK into NAND Flash Controller block. | ||
613 | * [14] RTC - Control PCLK into RTC control block. | ||
614 | */ | ||
615 | orr r2, r2, #0x000E0000 | ||
616 | /* [17] nEN_SCLK0 - SCLK0 output enable (1: SCLK 0 = 0) | ||
617 | * [18] nEN_SCLK1 - SCLK1 output enable (1: SCLK 1 = 0) | ||
618 | * [19] OFFREFRESH - Self refresh retain enable after wake-up from sleep | ||
619 | */ | ||
620 | |||
621 | str r2, [r12] | ||
622 | str r3, [lr] | ||
623 | |||
624 | 1: | ||
625 | b 1b | ||
626 | .ltorg | ||
627 | .size rom_shutdown, .-rom_shutdown | ||
628 | |||
489 | .section .text | 629 | .section .text |
490 | /* 256 words of IRQ stack */ | 630 | /* 256 words of IRQ stack */ |
491 | .space 256*4 | 631 | .space 256*4 |
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c index 9fb2a90c42..ac8dc380e2 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c | |||
@@ -244,6 +244,24 @@ static void LCD_SPI_init(void) | |||
244 | /* LCD init */ | 244 | /* LCD init */ |
245 | void lcd_init_device(void) | 245 | void lcd_init_device(void) |
246 | { | 246 | { |
247 | #ifdef BOOTLOADER | ||
248 | int i; | ||
249 | /* When the Rockbox bootloader starts, we are changing framebuffer address, | ||
250 | but we don't want what's shown on the LCD to change until we do an | ||
251 | lcd_update(), so copy the data from the old framebuffer to the new one */ | ||
252 | unsigned short *buf = (unsigned short*)FRAME; | ||
253 | |||
254 | memcpy(FRAME, (short *)((LCDSADDR1)<<1), 320*240*2); | ||
255 | |||
256 | /* The Rockbox bootloader is transitioning from RGB555I to RGB565 mode | ||
257 | so convert the frambuffer data accordingly */ | ||
258 | for(i=0; i< 320*240; i++){ | ||
259 | *buf = ((*buf>>1) & 0x1F) | (*buf & 0xffc0); | ||
260 | buf++; | ||
261 | } | ||
262 | #endif | ||
263 | |||
264 | |||
247 | /* Set pins up */ | 265 | /* Set pins up */ |
248 | 266 | ||
249 | GPHUP &= 0x600; | 267 | GPHUP &= 0x600; |
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c index 8b83a4f343..8065926e28 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c | |||
@@ -144,51 +144,49 @@ void s3c_regclr(volatile int *reg, unsigned int mask) | |||
144 | 144 | ||
145 | void system_init(void) | 145 | void system_init(void) |
146 | { | 146 | { |
147 | /* Disable interrupts and set all to IRQ mode */ | 147 | INTMSK = 0xFFFFFFFF; |
148 | INTMSK = -1; | 148 | INTMOD = 0; |
149 | INTMOD = 0; | 149 | SRCPND = 0xFFFFFFFF; |
150 | SRCPND = -1; | 150 | INTPND = 0xFFFFFFFF; |
151 | INTPND = -1; | 151 | INTSUBMSK = 0xFFFFFFFF; |
152 | INTSUBMSK = -1; | 152 | SUBSRCPND = 0xFFFFFFFF; |
153 | SUBSRCPND = -1; | 153 | |
154 | GPBCON |= 0x85; | ||
155 | GPBDAT |= 0x07; | ||
156 | GPBUP |= 0x20F; | ||
157 | |||
158 | /* Take care of flash related pins */ | ||
159 | GPCCON |= 0x1000; | ||
160 | GPCDAT &= ~0x40; | ||
161 | GPCUP |= 0x51; | ||
162 | |||
163 | GPDCON |= 0x05; | ||
164 | GPDUP |= 0x03; | ||
165 | GPDDAT &= ~0x03; | ||
166 | |||
167 | GPFCON |= 0x00000AAA; | ||
168 | GPFUP |= 0xFF; | ||
169 | |||
170 | GPGCON |= 0x01001000; | ||
171 | GPGUP |= 0x70; | ||
172 | |||
173 | GPHCON |= 0x4005; | ||
174 | GPHDAT |= 0x03; | ||
154 | 175 | ||
155 | /* TODO: do something with PRIORITY */ | 176 | /* TODO: do something with PRIORITY */ |
156 | 177 | ||
157 | 178 | /* Turn off currently-not or never-needed devices. | |
158 | /* Turn off currently-not or never-needed devices */ | 179 | * Be careful here, it is possible to freeze the device by disabling |
159 | 180 | * clocks at the wrong time. | |
160 | CLKCON &= ~( | 181 | * |
161 | /* Turn off AC97 and Camera */ | 182 | * Turn off AC97, Camera, SPI, IIS, I2C, UARTS, MMC/SD/SDIO Controller |
162 | (1<<19) | (1<<20) | 183 | * USB device, USB host, NAND flash controller. |
163 | 184 | * | |
164 | /* Turn off SPI */ | 185 | * IDLE, Sleep, LCDC, PWM timer, GPIO, RTC, and ADC are untouched (on) |
165 | | (1 << 18) | 186 | */ |
166 | 187 | CLKCON &= ~0xFF1ED0; | |
167 | /* Turn off IIS */ | 188 | |
168 | | (1 << 17) | 189 | CLKSLOW |= 0x80; |
169 | |||
170 | /* Turn off I2C */ | ||
171 | | (1 << 16) | ||
172 | |||
173 | /* Turn off all of the UARTS */ | ||
174 | | ( (1<<10) | (1<<11) |(1<<12) ) | ||
175 | |||
176 | /* Turn off MMC/SD/SDIO Controller (SDI) */ | ||
177 | | (1 << 9) | ||
178 | |||
179 | /* Turn off USB device */ | ||
180 | | (1 << 7) | ||
181 | |||
182 | /* Turn off USB host */ | ||
183 | | (1 << 6) | ||
184 | |||
185 | /* Turn off NAND flash controller */ | ||
186 | | (1 << 4) | ||
187 | |||
188 | ); | ||
189 | |||
190 | /* Turn off the USB PLL */ | ||
191 | CLKSLOW |= (1 << 7); | ||
192 | } | 190 | } |
193 | 191 | ||
194 | int system_memory_guard(int newmode) | 192 | int system_memory_guard(int newmode) |