diff options
-rw-r--r-- | bootloader/ipodnano2g.c | 8 | ||||
-rw-r--r-- | firmware/target/arm/ipod/button-clickwheel.c | 74 |
2 files changed, 61 insertions, 21 deletions
diff --git a/bootloader/ipodnano2g.c b/bootloader/ipodnano2g.c index b2b2138f78..be714c6273 100644 --- a/bootloader/ipodnano2g.c +++ b/bootloader/ipodnano2g.c | |||
@@ -82,10 +82,6 @@ void fatal_error(void) | |||
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | /* aes_decrypt() and readfw() functions taken from iLoader. | ||
86 | (C) Michael Sparmann and licenced under GPL v2 or later. | ||
87 | */ | ||
88 | |||
89 | static void aes_decrypt(void* data, uint32_t size) | 85 | static void aes_decrypt(void* data, uint32_t size) |
90 | { | 86 | { |
91 | uint32_t ptr, i; | 87 | uint32_t ptr, i; |
@@ -196,9 +192,9 @@ void main(void) | |||
196 | lcd_set_background(LCD_BLACK); | 192 | lcd_set_background(LCD_BLACK); |
197 | lcd_clear_display(); | 193 | lcd_clear_display(); |
198 | 194 | ||
199 | // button_init(); | 195 | button_init(); |
200 | 196 | ||
201 | btn=0; /* TODO */ | 197 | btn = button_status(); |
202 | 198 | ||
203 | /* Enable bootloader messages */ | 199 | /* Enable bootloader messages */ |
204 | if (btn==BUTTON_RIGHT) | 200 | if (btn==BUTTON_RIGHT) |
diff --git a/firmware/target/arm/ipod/button-clickwheel.c b/firmware/target/arm/ipod/button-clickwheel.c index 512e133402..580f95a453 100644 --- a/firmware/target/arm/ipod/button-clickwheel.c +++ b/firmware/target/arm/ipod/button-clickwheel.c | |||
@@ -50,9 +50,16 @@ | |||
50 | #ifdef CPU_PP | 50 | #ifdef CPU_PP |
51 | #define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x7000c140)) | 51 | #define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x7000c140)) |
52 | #elif CONFIG_CPU==S5L8701 | 52 | #elif CONFIG_CPU==S5L8701 |
53 | #define CLICKWHEEL00 (*(volatile unsigned long*)(0x3c200000)) | 53 | #define PCON15 (*((volatile uint32_t*)(0x3CF000F0))) |
54 | #define CLICKWHEEL10 (*(volatile unsigned long*)(0x3c200010)) | 54 | #define PUNK15 (*((volatile uint32_t*)(0x3CF000FC))) |
55 | #define CLICKWHEELINT (*(volatile unsigned long*)(0x3c200014)) | 55 | #define WHEEL00 (*((volatile uint32_t*)(0x3C200000))) |
56 | #define WHEEL04 (*((volatile uint32_t*)(0x3C200004))) | ||
57 | #define WHEEL08 (*((volatile uint32_t*)(0x3C200008))) | ||
58 | #define WHEEL0C (*((volatile uint32_t*)(0x3C20000C))) | ||
59 | #define WHEEL10 (*((volatile uint32_t*)(0x3C200010))) | ||
60 | #define WHEELINT (*((volatile uint32_t*)(0x3C200014))) | ||
61 | #define WHEELRX (*((volatile uint32_t*)(0x3C200018))) | ||
62 | #define WHEELTX (*((volatile uint32_t*)(0x3C20001C))) | ||
56 | #define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x3c200018)) | 63 | #define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x3c200018)) |
57 | #else | 64 | #else |
58 | #error CPU architecture not supported! | 65 | #error CPU architecture not supported! |
@@ -86,6 +93,10 @@ int int_btn = BUTTON_NONE; | |||
86 | static bool send_events = true; | 93 | static bool send_events = true; |
87 | #endif | 94 | #endif |
88 | 95 | ||
96 | #if CONFIG_CPU==S5L8701 | ||
97 | static struct wakeup button_init_wakeup; | ||
98 | #endif | ||
99 | |||
89 | #ifdef CPU_PP | 100 | #ifdef CPU_PP |
90 | static void opto_i2c_init(void) | 101 | static void opto_i2c_init(void) |
91 | { | 102 | { |
@@ -254,6 +265,23 @@ static inline int ipod_4g_button_read(void) | |||
254 | } | 265 | } |
255 | 266 | ||
256 | } | 267 | } |
268 | #if CONFIG_CPU==S5L8701 | ||
269 | else if ((status & 0x8000FFFF) == 0x8000023A) | ||
270 | { | ||
271 | if (status & 0x00010000) | ||
272 | btn |= BUTTON_SELECT; | ||
273 | if (status & 0x00020000) | ||
274 | btn |= BUTTON_RIGHT; | ||
275 | if (status & 0x00040000) | ||
276 | btn |= BUTTON_LEFT; | ||
277 | if (status & 0x00080000) | ||
278 | btn |= BUTTON_PLAY; | ||
279 | if (status & 0x00100000) | ||
280 | btn |= BUTTON_MENU; | ||
281 | wakeup_signal(&button_init_wakeup); | ||
282 | } | ||
283 | #endif | ||
284 | |||
257 | #ifdef CPU_PP | 285 | #ifdef CPU_PP |
258 | } | 286 | } |
259 | #endif | 287 | #endif |
@@ -319,23 +347,37 @@ bool headphones_inserted(void) | |||
319 | #else | 347 | #else |
320 | void INT_SPI(void) | 348 | void INT_SPI(void) |
321 | { | 349 | { |
322 | int clickwheel_events = CLICKWHEELINT; | 350 | int clickwheel_events = WHEELINT; |
323 | 351 | ||
324 | /* Clear interrupts */ | 352 | /* Clear interrupts */ |
325 | if (clickwheel_events & 4) CLICKWHEELINT = 4; | 353 | if (clickwheel_events & 4) WHEELINT = 4; |
326 | if (clickwheel_events & 2) CLICKWHEELINT = 2; | 354 | if (clickwheel_events & 2) WHEELINT = 2; |
327 | if (clickwheel_events & 1) CLICKWHEELINT = 1; | 355 | if (clickwheel_events & 1) WHEELINT = 1; |
328 | 356 | ||
329 | int_btn = ipod_4g_button_read(); | 357 | int_btn = ipod_4g_button_read(); |
330 | } | 358 | } |
331 | 359 | ||
360 | void s5l_clickwheel_init(void) | ||
361 | { | ||
362 | PWRCONEXT &= ~1; | ||
363 | PCON15 = (PCON15 & ~0xFFFF0000) | 0x22220000; | ||
364 | PUNK15 = 0xF0; | ||
365 | WHEEL08 = 0x3A980; | ||
366 | WHEEL00 = 0x280000; | ||
367 | WHEEL10 = 3; | ||
368 | PCON10 = (PCON10 & ~0xFF0) | 0x10; | ||
369 | PDAT10 |= 2; | ||
370 | WHEELTX = 0x8000023A; | ||
371 | WHEEL04 |= 1; | ||
372 | PDAT10 &= ~2; | ||
373 | } | ||
374 | |||
332 | void button_init_device(void) | 375 | void button_init_device(void) |
333 | { | 376 | { |
334 | CLICKWHEEL00 = 0x280000; | 377 | wakeup_init(&button_init_wakeup); |
335 | CLICKWHEEL10 = 3; | ||
336 | INTMOD = 0; | ||
337 | INTMSK |= (1<<26); | 378 | INTMSK |= (1<<26); |
338 | PCON10 &= ~0xF00; | 379 | s5l_clickwheel_init(); |
380 | wakeup_wait(&button_init_wakeup, HZ / 10); | ||
339 | } | 381 | } |
340 | 382 | ||
341 | bool button_hold(void) | 383 | bool button_hold(void) |
@@ -363,7 +405,9 @@ int button_read_device(void) | |||
363 | 405 | ||
364 | if (hold_button != hold_button_old) | 406 | if (hold_button != hold_button_old) |
365 | { | 407 | { |
408 | #ifndef BOOTLOADER | ||
366 | backlight_hold_changed(hold_button); | 409 | backlight_hold_changed(hold_button); |
410 | #endif | ||
367 | 411 | ||
368 | if (hold_button) | 412 | if (hold_button) |
369 | { | 413 | { |
@@ -372,8 +416,9 @@ int button_read_device(void) | |||
372 | DEV_EN &= ~DEV_OPTO; | 416 | DEV_EN &= ~DEV_OPTO; |
373 | #elif CONFIG_CPU==S5L8701 | 417 | #elif CONFIG_CPU==S5L8701 |
374 | pmu_ldo_power_off(1); /* disable clickwheel power supply */ | 418 | pmu_ldo_power_off(1); /* disable clickwheel power supply */ |
375 | CLICKWHEEL00 = 0; | 419 | WHEEL00 = 0; |
376 | CLICKWHEEL10 = 0; | 420 | WHEEL10 = 0; |
421 | PWRCONEXT |= 1; | ||
377 | #endif | 422 | #endif |
378 | } | 423 | } |
379 | else | 424 | else |
@@ -384,8 +429,7 @@ int button_read_device(void) | |||
384 | opto_i2c_init(); | 429 | opto_i2c_init(); |
385 | #elif CONFIG_CPU==S5L8701 | 430 | #elif CONFIG_CPU==S5L8701 |
386 | pmu_ldo_power_on(1); /* enable clickwheel power supply */ | 431 | pmu_ldo_power_on(1); /* enable clickwheel power supply */ |
387 | CLICKWHEEL00 = 0x280000; | 432 | s5l_clickwheel_init(); |
388 | CLICKWHEEL10 = 3; | ||
389 | #endif | 433 | #endif |
390 | } | 434 | } |
391 | } | 435 | } |