1
0
Fork 0
forked from len0rd/rockbox

mkximxboot/fuze+: add power button delay to power on

Only boot to rockbox if the power button is hold sufficiently long.
For consistency, use the same mechanism as the OF:
- read PSWITCH 550000 times
- boot if PSWITCH=1 at least 400000 out of 550000 times
Only apply the delay if Volume Down is not hold,
so that the OF and RB delay don't cumulate.

Change-Id: I1e8a4cd108c56bf784fcf1c320f7a001ef161701
This commit is contained in:
Amaury Pouly 2012-02-28 00:00:58 +01:00
parent 9f48f5f207
commit 15c69b8baf
3 changed files with 34 additions and 7 deletions

View file

@ -2,8 +2,13 @@
#include "dualboot.h" #include "dualboot.h"
unsigned char dualboot_fuzeplus[36] = { unsigned char dualboot_fuzeplus[128] = {
0x18, 0x20, 0x9f, 0xe5, 0x00, 0x20, 0x92, 0xe5, 0x01, 0x01, 0x12, 0xe3, 0x00, 0x00, 0xa0, 0x03, 0x70, 0x40, 0x2d, 0xe9, 0x5c, 0x20, 0x9f, 0xe5, 0x00, 0x20, 0x92, 0xe5, 0x01, 0x01, 0x12, 0xe3,
0x1e, 0xff, 0x2f, 0x01, 0x00, 0x00, 0x81, 0xe5, 0x01, 0x00, 0xa0, 0xe3, 0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0xa0, 0x03, 0x1e, 0xff, 0x2f, 0x01, 0x4c, 0x20, 0x9f, 0xe5, 0x00, 0x40, 0xa0, 0xe3,
0x10, 0x86, 0x01, 0x80 0x48, 0x30, 0x9f, 0xe5, 0x00, 0x30, 0x93, 0xe5, 0x03, 0x35, 0xa0, 0xe1, 0x23, 0x3f, 0xa0, 0xe1,
0x01, 0x00, 0x53, 0xe3, 0x03, 0x40, 0x84, 0x00, 0x01, 0x20, 0x52, 0xe2, 0xf7, 0xff, 0xff, 0x1a,
0x2c, 0x20, 0x9f, 0xe5, 0x02, 0x00, 0x54, 0xe1, 0x02, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x81, 0xe5,
0x01, 0x00, 0xa0, 0xe3, 0x70, 0x80, 0xbd, 0xe8, 0x18, 0x00, 0x9f, 0xe5, 0x18, 0x10, 0x9f, 0xe5,
0x00, 0x10, 0x80, 0xe5, 0xfb, 0xff, 0xff, 0xea, 0x10, 0x86, 0x01, 0x80, 0x70, 0x64, 0x08, 0x00,
0xc0, 0x40, 0x04, 0x80, 0x80, 0x1a, 0x06, 0x00, 0x00, 0x41, 0x04, 0x80, 0x01, 0x00, 0x77, 0x3e
}; };

View file

@ -1,3 +1,3 @@
/* Generated by bin2c */ /* Generated by bin2c */
extern unsigned char dualboot_fuzeplus[36]; extern unsigned char dualboot_fuzeplus[128];

View file

@ -23,6 +23,7 @@
.global start .global start
@ int start(uint32_t arg, uint32_t *result_id) @ int start(uint32_t arg, uint32_t *result_id)
start: start:
stmfd sp!, {r4-r6,lr}
#if defined(SANSA_FUZEPLUS) #if defined(SANSA_FUZEPLUS)
/* If volume down key is hold, return so that the OF can boot */ /* If volume down key is hold, return so that the OF can boot */
ldr r2, =0x80018610 @ HW_PINCTRL_DIN1 ldr r2, =0x80018610 @ HW_PINCTRL_DIN1
@ -30,10 +31,31 @@ start:
tst r2, #0x40000000 @ bit 30, active low tst r2, #0x40000000 @ bit 30, active low
moveq r0, #0 @ return 0, continue boot moveq r0, #0 @ return 0, continue boot
bxeq lr bxeq lr
/* otherwise jump to section given as argument */ /* otherwise monitor the power button for a short time */
ldr r2, =550000 @ loop count
ldr r4, =0 @ number of times PSWITCH was 1
pswitch_monitor_loop:
ldr r3, =0x800440c0 @ HW_POWER_STS
ldr r3, [r3]
mov r3, r3, lsl#10
mov r3, r3, lsr#30 @ extract PSWITCH
cmp r3, #1
addeq r4, r3 @ add one if PSWITCH=1 (means power hold)
subs r2, #1
bne pswitch_monitor_loop
/* power down if power wasn't hold long enough */
ldr r2, =400000
cmp r4, r2
bcc power_down
/* jump to section given as argument */
str r0, [r1] str r0, [r1]
mov r0, #1 mov r0, #1
bx lr ldmfd sp!, {r4-r6,pc}
power_down:
ldr r0, =0x80044100 @ HW_POWER_RESET
ldr r1, =0x3E770001 @ unlock key + power down
str r1, [r0]
b power_down
#else #else
#error No target defined ! #error No target defined !
#endif #endif