summaryrefslogtreecommitdiff
path: root/bootloader/rk27xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader/rk27xx.c')
-rw-r--r--bootloader/rk27xx.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/bootloader/rk27xx.c b/bootloader/rk27xx.c
index 62280e2749..bcf1f8f764 100644
--- a/bootloader/rk27xx.c
+++ b/bootloader/rk27xx.c
@@ -37,42 +37,69 @@ extern void show_logo( void );
37static void enter_rkusb(void) 37static void enter_rkusb(void)
38{ 38{
39 asm volatile ( 39 asm volatile (
40 /* turn off cache */ 40 /* Turn off cache */
41 "ldr r0, =0xefff0000 \n" 41 "ldr r0, =0xefff0000 \n"
42 "ldrh r1, [r0] \n" 42 "ldrh r1, [r0] \n"
43 "strh r1, [r0] \n" 43 "strh r1, [r0] \n"
44 44
45 /* turn off interrupts */ 45 /* Turn off interrupts */
46 "mrs r0, cpsr \n" 46 "mrs r0, cpsr \n"
47 "bic r0, r0, #0x1f \n" 47 "bic r0, r0, #0x1f \n"
48 "orr r0, r0, #0xd3 \n" 48 "orr r0, r0, #0xd3 \n"
49 "msr cpsr, r0 \n" 49 "msr cpsr, r0 \n"
50 50
51 /* disable iram remap */ 51 /* Disable iram remap */
52 "mov r0, #0x18000000 \n" 52 "mov r0, #0x18000000 \n"
53 "add r0, r0, #0x1c000 \n" 53 "add r0, r0, #0x1c000 \n"
54 "mov r1, #0 \n" 54 "mov r1, #0 \n"
55 "str r1, [r0, #4] \n" 55 "str r1, [r0, #4] \n"
56 56
57 /* setup stacks in unmapped 57 /* Ungate all clocks */
58 * iram just as rom will do 58 "str r1, [r0, #0x18] \n"
59
60 /* Read SCU_ID to determine
61 * which version of bootrom we have
62 * 2706A has ID 0xa1000604
63 * 2706B and 2705 have ID 0xa10002b7
59 */ 64 */
60 "msr cpsr, #0xd2 \n" 65 "ldr r1, [r0] \n"
66 "ldr r2, =0xa1000604 \n"
67 "cmp r1, r2 \n"
68 "bne rk27xx_new \n"
69
70 /* Setup stacks in unmapped
71 * iram just as rom will do.
72 *
73 * We know about two versions
74 * of bootrom which are very similar
75 * but memory addresses are slightly
76 * different.
77 */
78 "rk27xx_old: \n"
79 "ldr r1, =0x18200258 \n"
80 "ldr r0, =0xaf0 \n"
81 "b jump_to_rom \n"
82
83 "rk27xx_new: \n"
61 "ldr r1, =0x18200274 \n" 84 "ldr r1, =0x18200274 \n"
85 "ldr r0, =0xec0 \n"
86
87 "jump_to_rom: \n"
88 "msr cpsr, #0xd2 \n"
62 "add r1, r1, #0x200 \n" 89 "add r1, r1, #0x200 \n"
63 "mov sp, r1 \n" 90 "mov sp, r1 \n"
64 "msr cpsr, #0xd3 \n" 91 "msr cpsr, #0xd3 \n"
65 "add r1, r1, #0x400 \n" 92 "add r1, r1, #0x400 \n"
66 "mov sp, r1 \n" 93 "mov sp, r1 \n"
67 94
68 /* jump to main() in rom 95 /* Finaly jump to rkusb handler
69 * just before dfu handler 96 * in bootrom.
70 */ 97 */
71 "ldr r0, =0xec0 \n"
72 "bx r0 \n" 98 "bx r0 \n"
73 ); 99 );
74} 100}
75 101
102
76void main(void) NORETURN_ATTR; 103void main(void) NORETURN_ATTR;
77void main(void) 104void main(void)
78{ 105{