diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2012-07-10 09:10:30 +0200 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2012-07-10 09:14:09 +0200 |
commit | b43171dcdf71c5e33723da9e3394adcca91b43fd (patch) | |
tree | d56f430d80ca706eb57db21b94e5381338f1d510 | |
parent | fa5d22584aed2740e6ceac8ba9f0c9fe45be0b86 (diff) | |
download | rockbox-b43171dcdf71c5e33723da9e3394adcca91b43fd.tar.gz rockbox-b43171dcdf71c5e33723da9e3394adcca91b43fd.zip |
rk27xx: support entering rkusb mode on rk2706A
We know about two different bootroms. First can be found in rk2706A,
the second in rk2706B and rk2705. This two versions are very
similar but memory addresses are different. It seems it is possible
to distinguish bootrom version by reading SCU_ID register.
Change-Id: I01681b5e3a82930ae74a5cce6ab0244d7cd333d2
-rw-r--r-- | bootloader/rk27xx.c | 45 |
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 ); | |||
37 | static void enter_rkusb(void) | 37 | static 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 | |||
76 | void main(void) NORETURN_ATTR; | 103 | void main(void) NORETURN_ATTR; |
77 | void main(void) | 104 | void main(void) |
78 | { | 105 | { |