summaryrefslogtreecommitdiff
path: root/bootloader
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader')
-rw-r--r--bootloader/SOURCES2
-rw-r--r--bootloader/ipod.c52
2 files changed, 25 insertions, 29 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index 6b72d083ab..0c9aa8ba2f 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -1,4 +1,4 @@
1#if (CONFIG_CPU == PP5020) 1#if (CONFIG_CPU == PP5002) || (CONFIG_CPU == PP5020)
2ipod.c 2ipod.c
3#else 3#else
4main.c 4main.c
diff --git a/bootloader/ipod.c b/bootloader/ipod.c
index 97a4cebd69..63b7b2207b 100644
--- a/bootloader/ipod.c
+++ b/bootloader/ipod.c
@@ -39,9 +39,12 @@
39#include "power.h" 39#include "power.h"
40#include "file.h" 40#include "file.h"
41 41
42#define DRAM_START 0x10000000 42#if (CONFIG_CPU == PP5020)
43#define IPOD_PP5020_RTC 0x60005010 43#define DRAM_START 0x10000000
44 44#else
45#define IPOD_LCD_BASE 0xc0001000
46#define DRAM_START 0x28000000
47#endif
45#define IPOD_HW_REVISION (*((volatile unsigned long*)(0x00002084))) 48#define IPOD_HW_REVISION (*((volatile unsigned long*)(0x00002084)))
46 49
47/* We copy the hardware revision to the last four bytes of SDRAM and then 50/* We copy the hardware revision to the last four bytes of SDRAM and then
@@ -52,6 +55,7 @@
52#define BUTTON_MENU 2 55#define BUTTON_MENU 2
53#define BUTTON_RIGHT 3 56#define BUTTON_RIGHT 3
54#define BUTTON_PLAY 4 57#define BUTTON_PLAY 4
58#define BUTTON_HOLD 5
55 59
56/* Size of the buffer to store the loaded Rockbox/Linux image */ 60/* Size of the buffer to store the loaded Rockbox/Linux image */
57#define MAX_LOADSIZE (4*1024*1024) 61#define MAX_LOADSIZE (4*1024*1024)
@@ -96,35 +100,17 @@ static void memmove16(void *dest, const void *src, unsigned count)
96 } 100 }
97} 101}
98 102
99/* get current usec counter */ 103#if CONFIG_KEYPAD == IPOD_4G_PAD
100int timer_get_current(void)
101{
102 return inl(IPOD_PP5020_RTC);
103}
104
105/* check if number of seconds has past */ 104/* check if number of seconds has past */
106int timer_check(int clock_start, unsigned int usecs) 105int timer_check(int clock_start, unsigned int usecs)
107{ 106{
108 if ((inl(IPOD_PP5020_RTC) - clock_start) >= usecs) { 107 if ((USEC_TIMER - clock_start) >= usecs) {
109 return 1; 108 return 1;
110 } else { 109 } else {
111 return 0; 110 return 0;
112 } 111 }
113} 112}
114 113
115/* This isn't a sleep, but let's call it that. */
116int usleep(unsigned int usecs)
117{
118 unsigned int start = inl(IPOD_PP5020_RTC);
119
120 while ((inl(IPOD_PP5020_RTC) - start) < usecs) {
121 // empty
122 }
123
124 return 0;
125}
126
127
128static void ser_opto_keypad_cfg(int val) 114static void ser_opto_keypad_cfg(int val)
129{ 115{
130 int start_time; 116 int start_time;
@@ -138,7 +124,7 @@ static void ser_opto_keypad_cfg(int val)
138 outl(inl(0x6000d024) & ~0x10, 0x6000d024); 124 outl(inl(0x6000d024) & ~0x10, 0x6000d024);
139 outl(inl(0x6000d014) | 0x10, 0x6000d014); 125 outl(inl(0x6000d014) | 0x10, 0x6000d014);
140 126
141 start_time = timer_get_current(); 127 start_time = USEC_TIMER;
142 do { 128 do {
143 if ((inl(0x7000c104) & 0x80000000) == 0) { 129 if ((inl(0x7000c104) & 0x80000000) == 0) {
144 break; 130 break;
@@ -167,7 +153,7 @@ int opto_keypad_read(void)
167 153
168 ser_opto_keypad_cfg(0x8000023a); 154 ser_opto_keypad_cfg(0x8000023a);
169 155
170 start_time = timer_get_current(); 156 start_time = USEC_TIMER;
171 do { 157 do {
172 if (inl(0x7000c104) & 0x4000000) { 158 if (inl(0x7000c104) & 0x4000000) {
173 had_io = 1; 159 had_io = 1;
@@ -197,16 +183,26 @@ int opto_keypad_read(void)
197 183
198 return 0; 184 return 0;
199} 185}
186#endif
200 187
201static int key_pressed(void) 188static int key_pressed(void)
202{ 189{
203 unsigned char state; 190 unsigned char state;
204 191
192#if CONFIG_KEYPAD == IPOD_4G_PAD
205 state = opto_keypad_read(); 193 state = opto_keypad_read();
206 if ((state & 0x4) == 0) return BUTTON_LEFT; 194 if ((state & 0x4) == 0) return BUTTON_LEFT;
207 if ((state & 0x10) == 0) return BUTTON_MENU; 195 if ((state & 0x10) == 0) return BUTTON_MENU;
208 if ((state & 0x8) == 0) return BUTTON_PLAY; 196 if ((state & 0x8) == 0) return BUTTON_PLAY;
209 if ((state & 0x2) == 0) return BUTTON_RIGHT; 197 if ((state & 0x2) == 0) return BUTTON_RIGHT;
198#elif CONFIG_KEYPAD == IPOD_3G_PAD
199 state = inb(0xcf000030);
200 if (((state & 0x20) == 0)) return BUTTON_HOLD; /* hold on */
201 if ((state & 0x08) == 0) return BUTTON_LEFT;
202 if ((state & 0x10) == 0) return BUTTON_MENU;
203 if ((state & 0x04) == 0) return BUTTON_PLAY;
204 if ((state & 0x01) == 0) return BUTTON_RIGHT;
205#endif
210 return 0; 206 return 0;
211} 207}
212 208
@@ -336,7 +332,8 @@ void* main(void)
336 332
337 /* set port L07 on */ 333 /* set port L07 on */
338 outl(((0x100 | 1) << 7), 0x6000d12c); 334 outl(((0x100 | 1) << 7), 0x6000d12c);
339 335#elif CONFIG_BACKLIGHT==BL_IPOD3G
336 outl(inl(IPOD_LCD_BASE) | 0x2, IPOD_LCD_BASE);
340#endif 337#endif
341 338
342 TMP_IPOD_HW_REVISION = IPOD_HW_REVISION; 339 TMP_IPOD_HW_REVISION = IPOD_HW_REVISION;
@@ -441,12 +438,11 @@ void* main(void)
441 } 438 }
442 439
443 /* If everything else failed, try the original firmware */ 440 /* If everything else failed, try the original firmware */
444
445 lcd_puts(0, line, "Loading original firmware..."); 441 lcd_puts(0, line, "Loading original firmware...");
446 lcd_update(); 442 lcd_update();
447 443
448 /* Pause for 5 seconds so we can see what's happened */ 444 /* Pause for 5 seconds so we can see what's happened */
449// usleep(5000000); 445// udelay(5000000);
450 446
451 entry = tblp->addr + tblp->entryOffset; 447 entry = tblp->addr + tblp->entryOffset;
452 if (imageno || ((int)tblp->addr & 0xffffff) != 0) { 448 if (imageno || ((int)tblp->addr & 0xffffff) != 0) {