Commit FS#11663 by me - Patch: iPod Nano 2G Bootloader: Boot OF if MENU button is held

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28237 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sparmann 2010-10-10 20:52:46 +00:00
parent e94eea9538
commit c599da333e
2 changed files with 61 additions and 21 deletions

View file

@ -82,10 +82,6 @@ void fatal_error(void)
} }
} }
/* aes_decrypt() and readfw() functions taken from iLoader.
(C) Michael Sparmann and licenced under GPL v2 or later.
*/
static void aes_decrypt(void* data, uint32_t size) static void aes_decrypt(void* data, uint32_t size)
{ {
uint32_t ptr, i; uint32_t ptr, i;
@ -196,9 +192,9 @@ void main(void)
lcd_set_background(LCD_BLACK); lcd_set_background(LCD_BLACK);
lcd_clear_display(); lcd_clear_display();
// button_init(); button_init();
btn=0; /* TODO */ btn = button_status();
/* Enable bootloader messages */ /* Enable bootloader messages */
if (btn==BUTTON_RIGHT) if (btn==BUTTON_RIGHT)

View file

@ -50,9 +50,16 @@
#ifdef CPU_PP #ifdef CPU_PP
#define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x7000c140)) #define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x7000c140))
#elif CONFIG_CPU==S5L8701 #elif CONFIG_CPU==S5L8701
#define CLICKWHEEL00 (*(volatile unsigned long*)(0x3c200000)) #define PCON15 (*((volatile uint32_t*)(0x3CF000F0)))
#define CLICKWHEEL10 (*(volatile unsigned long*)(0x3c200010)) #define PUNK15 (*((volatile uint32_t*)(0x3CF000FC)))
#define CLICKWHEELINT (*(volatile unsigned long*)(0x3c200014)) #define WHEEL00 (*((volatile uint32_t*)(0x3C200000)))
#define WHEEL04 (*((volatile uint32_t*)(0x3C200004)))
#define WHEEL08 (*((volatile uint32_t*)(0x3C200008)))
#define WHEEL0C (*((volatile uint32_t*)(0x3C20000C)))
#define WHEEL10 (*((volatile uint32_t*)(0x3C200010)))
#define WHEELINT (*((volatile uint32_t*)(0x3C200014)))
#define WHEELRX (*((volatile uint32_t*)(0x3C200018)))
#define WHEELTX (*((volatile uint32_t*)(0x3C20001C)))
#define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x3c200018)) #define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x3c200018))
#else #else
#error CPU architecture not supported! #error CPU architecture not supported!
@ -86,6 +93,10 @@ int int_btn = BUTTON_NONE;
static bool send_events = true; static bool send_events = true;
#endif #endif
#if CONFIG_CPU==S5L8701
static struct wakeup button_init_wakeup;
#endif
#ifdef CPU_PP #ifdef CPU_PP
static void opto_i2c_init(void) static void opto_i2c_init(void)
{ {
@ -254,6 +265,23 @@ static inline int ipod_4g_button_read(void)
} }
} }
#if CONFIG_CPU==S5L8701
else if ((status & 0x8000FFFF) == 0x8000023A)
{
if (status & 0x00010000)
btn |= BUTTON_SELECT;
if (status & 0x00020000)
btn |= BUTTON_RIGHT;
if (status & 0x00040000)
btn |= BUTTON_LEFT;
if (status & 0x00080000)
btn |= BUTTON_PLAY;
if (status & 0x00100000)
btn |= BUTTON_MENU;
wakeup_signal(&button_init_wakeup);
}
#endif
#ifdef CPU_PP #ifdef CPU_PP
} }
#endif #endif
@ -319,23 +347,37 @@ bool headphones_inserted(void)
#else #else
void INT_SPI(void) void INT_SPI(void)
{ {
int clickwheel_events = CLICKWHEELINT; int clickwheel_events = WHEELINT;
/* Clear interrupts */ /* Clear interrupts */
if (clickwheel_events & 4) CLICKWHEELINT = 4; if (clickwheel_events & 4) WHEELINT = 4;
if (clickwheel_events & 2) CLICKWHEELINT = 2; if (clickwheel_events & 2) WHEELINT = 2;
if (clickwheel_events & 1) CLICKWHEELINT = 1; if (clickwheel_events & 1) WHEELINT = 1;
int_btn = ipod_4g_button_read(); int_btn = ipod_4g_button_read();
} }
void s5l_clickwheel_init(void)
{
PWRCONEXT &= ~1;
PCON15 = (PCON15 & ~0xFFFF0000) | 0x22220000;
PUNK15 = 0xF0;
WHEEL08 = 0x3A980;
WHEEL00 = 0x280000;
WHEEL10 = 3;
PCON10 = (PCON10 & ~0xFF0) | 0x10;
PDAT10 |= 2;
WHEELTX = 0x8000023A;
WHEEL04 |= 1;
PDAT10 &= ~2;
}
void button_init_device(void) void button_init_device(void)
{ {
CLICKWHEEL00 = 0x280000; wakeup_init(&button_init_wakeup);
CLICKWHEEL10 = 3;
INTMOD = 0;
INTMSK |= (1<<26); INTMSK |= (1<<26);
PCON10 &= ~0xF00; s5l_clickwheel_init();
wakeup_wait(&button_init_wakeup, HZ / 10);
} }
bool button_hold(void) bool button_hold(void)
@ -363,7 +405,9 @@ int button_read_device(void)
if (hold_button != hold_button_old) if (hold_button != hold_button_old)
{ {
#ifndef BOOTLOADER
backlight_hold_changed(hold_button); backlight_hold_changed(hold_button);
#endif
if (hold_button) if (hold_button)
{ {
@ -372,8 +416,9 @@ int button_read_device(void)
DEV_EN &= ~DEV_OPTO; DEV_EN &= ~DEV_OPTO;
#elif CONFIG_CPU==S5L8701 #elif CONFIG_CPU==S5L8701
pmu_ldo_power_off(1); /* disable clickwheel power supply */ pmu_ldo_power_off(1); /* disable clickwheel power supply */
CLICKWHEEL00 = 0; WHEEL00 = 0;
CLICKWHEEL10 = 0; WHEEL10 = 0;
PWRCONEXT |= 1;
#endif #endif
} }
else else
@ -384,8 +429,7 @@ int button_read_device(void)
opto_i2c_init(); opto_i2c_init();
#elif CONFIG_CPU==S5L8701 #elif CONFIG_CPU==S5L8701
pmu_ldo_power_on(1); /* enable clickwheel power supply */ pmu_ldo_power_on(1); /* enable clickwheel power supply */
CLICKWHEEL00 = 0x280000; s5l_clickwheel_init();
CLICKWHEEL10 = 3;
#endif #endif
} }
} }