diff options
-rw-r--r-- | bootloader/iaudio_coldfire.c | 44 | ||||
-rw-r--r-- | firmware/export/adc.h | 4 | ||||
-rw-r--r-- | firmware/rolo.c | 1 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/adc-target.h | 3 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/power-m3.c | 4 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m5/power-m5.c | 12 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/x5/power-x5.c | 12 | ||||
-rw-r--r-- | firmware/target/coldfire/system-coldfire.c | 12 |
8 files changed, 71 insertions, 21 deletions
diff --git a/bootloader/iaudio_coldfire.c b/bootloader/iaudio_coldfire.c index a80a202d41..bb7fbebd3e 100644 --- a/bootloader/iaudio_coldfire.c +++ b/bootloader/iaudio_coldfire.c | |||
@@ -67,6 +67,7 @@ inline void __reset_cookie(void) | |||
67 | 67 | ||
68 | void start_firmware(void) | 68 | void start_firmware(void) |
69 | { | 69 | { |
70 | adc_close(); | ||
70 | asm(" move.w #0x2700,%sr"); | 71 | asm(" move.w #0x2700,%sr"); |
71 | __reset_cookie(); | 72 | __reset_cookie(); |
72 | asm(" move.l %0,%%d0" :: "i"(DRAM_START)); | 73 | asm(" move.l %0,%%d0" :: "i"(DRAM_START)); |
@@ -126,16 +127,35 @@ void main(void) | |||
126 | int rc; | 127 | int rc; |
127 | bool rc_on_button = false; | 128 | bool rc_on_button = false; |
128 | bool on_button = false; | 129 | bool on_button = false; |
129 | bool rec_button = false; | 130 | |
130 | bool hold_status = false; | 131 | /* We want to read the buttons as early as possible, before the user |
132 | releases the ON button */ | ||
133 | |||
134 | #ifdef IAUDIO_M3 | ||
135 | or_l(0x80000000, &GPIO_FUNCTION); /* remote Play button */ | ||
136 | and_l(~0x80000000, &GPIO_ENABLE); | ||
137 | or_l(0x00000202, &GPIO1_FUNCTION); /* main Hold & Play */ | ||
138 | |||
139 | if ((GPIO1_READ & 0x000000002) == 0) | ||
140 | on_button = true; | ||
141 | |||
142 | if ((GPIO_READ & 0x80000000) == 0) | ||
143 | rc_on_button = true; | ||
144 | #elif defined(IAUDIO_M5) || defined(IAUDIO_X5) | ||
131 | int data; | 145 | int data; |
132 | 146 | ||
133 | (void)rc_on_button; | 147 | or_l(0x0e000000, &GPIO_FUNCTION); /* main Hold & Power, remote Play */ |
134 | (void)on_button; | 148 | and_l(~0x0e000000, &GPIO_ENABLE); |
135 | (void)rec_button; | 149 | |
136 | (void)hold_status; | 150 | data = GPIO_READ; |
137 | (void)data; | ||
138 | 151 | ||
152 | if ((data & 0x04000000) == 0) | ||
153 | on_button = true; | ||
154 | |||
155 | if ((data & 0x02000000) == 0) | ||
156 | rc_on_button = true; | ||
157 | #endif | ||
158 | |||
139 | power_init(); | 159 | power_init(); |
140 | 160 | ||
141 | system_init(); | 161 | system_init(); |
@@ -153,6 +173,16 @@ void main(void) | |||
153 | font_init(); | 173 | font_init(); |
154 | adc_init(); | 174 | adc_init(); |
155 | button_init(); | 175 | button_init(); |
176 | |||
177 | if ((!on_button || button_hold()) | ||
178 | && (!rc_on_button || remote_button_hold()) | ||
179 | && !charger_inserted()) | ||
180 | { | ||
181 | /* No need to check for USB connection here, as USB is handled | ||
182 | * in the cowon loader. */ | ||
183 | printf("Hold switch on"); | ||
184 | shutdown(); | ||
185 | } | ||
156 | 186 | ||
157 | printf("Rockbox boot loader"); | 187 | printf("Rockbox boot loader"); |
158 | printf("Version %s", version); | 188 | printf("Version %s", version); |
diff --git a/firmware/export/adc.h b/firmware/export/adc.h index e10cce0d27..54d5d98212 100644 --- a/firmware/export/adc.h +++ b/firmware/export/adc.h | |||
@@ -25,4 +25,8 @@ | |||
25 | unsigned short adc_read(int channel); | 25 | unsigned short adc_read(int channel); |
26 | void adc_init(void); | 26 | void adc_init(void); |
27 | 27 | ||
28 | #ifndef NEED_ADC_CLOSE | ||
29 | #define adc_close() | ||
30 | #endif | ||
31 | |||
28 | #endif /* _ADC_H_ */ | 32 | #endif /* _ADC_H_ */ |
diff --git a/firmware/rolo.c b/firmware/rolo.c index 2a4b753948..eac45e10ce 100644 --- a/firmware/rolo.c +++ b/firmware/rolo.c | |||
@@ -269,6 +269,7 @@ int rolo_load(const char* filename) | |||
269 | lcd_remote_puts(0, 1, "Executing"); | 269 | lcd_remote_puts(0, 1, "Executing"); |
270 | lcd_remote_update(); | 270 | lcd_remote_update(); |
271 | #endif | 271 | #endif |
272 | adc_close(); | ||
272 | 273 | ||
273 | set_irq_level(HIGHEST_IRQ_LEVEL); | 274 | set_irq_level(HIGHEST_IRQ_LEVEL); |
274 | #elif CONFIG_CPU == SH7034 | 275 | #elif CONFIG_CPU == SH7034 |
diff --git a/firmware/target/coldfire/iaudio/m3/adc-target.h b/firmware/target/coldfire/iaudio/m3/adc-target.h index e5ff818647..40ed226bea 100644 --- a/firmware/target/coldfire/iaudio/m3/adc-target.h +++ b/firmware/target/coldfire/iaudio/m3/adc-target.h | |||
@@ -26,4 +26,7 @@ | |||
26 | #define ADC_BATTERY 1 | 26 | #define ADC_BATTERY 1 |
27 | #define ADC_REMOTE 2 | 27 | #define ADC_REMOTE 2 |
28 | 28 | ||
29 | #define NEED_ADC_CLOSE | ||
30 | void adc_close(void); | ||
31 | |||
29 | #endif /* _ADC_TARGET_H_ */ | 32 | #endif /* _ADC_TARGET_H_ */ |
diff --git a/firmware/target/coldfire/iaudio/m3/power-m3.c b/firmware/target/coldfire/iaudio/m3/power-m3.c index 52a5de3460..a7f3fc46be 100644 --- a/firmware/target/coldfire/iaudio/m3/power-m3.c +++ b/firmware/target/coldfire/iaudio/m3/power-m3.c | |||
@@ -36,7 +36,7 @@ void power_init(void) | |||
36 | /* Charger detect */ | 36 | /* Charger detect */ |
37 | and_l(~0x00000020, &GPIO1_ENABLE); | 37 | and_l(~0x00000020, &GPIO1_ENABLE); |
38 | or_l(0x00000020, &GPIO1_FUNCTION); | 38 | or_l(0x00000020, &GPIO1_FUNCTION); |
39 | 39 | ||
40 | /* FIXME: Just disable the multi-colour LED for now. */ | 40 | /* FIXME: Just disable the multi-colour LED for now. */ |
41 | and_l(~0x00000210, &GPIO1_OUT); | 41 | and_l(~0x00000210, &GPIO1_OUT); |
42 | and_l(~0x00008000, &GPIO_OUT); | 42 | and_l(~0x00008000, &GPIO_OUT); |
@@ -61,7 +61,7 @@ void ide_power_enable(bool on) | |||
61 | 61 | ||
62 | bool ide_powered(void) | 62 | bool ide_powered(void) |
63 | { | 63 | { |
64 | return false; | 64 | return (GPIO_OUT & 0x00800000) != 0; |
65 | } | 65 | } |
66 | 66 | ||
67 | void power_off(void) | 67 | void power_off(void) |
diff --git a/firmware/target/coldfire/iaudio/m5/power-m5.c b/firmware/target/coldfire/iaudio/m5/power-m5.c index d33cbec8be..939cae02f2 100644 --- a/firmware/target/coldfire/iaudio/m5/power-m5.c +++ b/firmware/target/coldfire/iaudio/m5/power-m5.c | |||
@@ -38,23 +38,23 @@ void power_init(void) | |||
38 | 38 | ||
39 | bool charger_inserted(void) | 39 | bool charger_inserted(void) |
40 | { | 40 | { |
41 | return (GPIO1_READ & 0x01000000)?true:false; | 41 | return (GPIO1_READ & 0x01000000) != 0; |
42 | } | 42 | } |
43 | 43 | ||
44 | void ide_power_enable(bool on) | 44 | void ide_power_enable(bool on) |
45 | { | 45 | { |
46 | /* GPOOD3 */ | 46 | /* GPOOD3 */ |
47 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); | 47 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); |
48 | if(on) | 48 | pcf50606_write(0x3c, on ? 0x07 : 0x00); |
49 | pcf50606_write(0x3c, 0x07); | ||
50 | else | ||
51 | pcf50606_write(0x3c, 0x00); | ||
52 | set_irq_level(level); | 49 | set_irq_level(level); |
53 | } | 50 | } |
54 | 51 | ||
55 | bool ide_powered(void) | 52 | bool ide_powered(void) |
56 | { | 53 | { |
57 | return false; | 54 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); |
55 | int value = pcf50606_read(0x3c); | ||
56 | set_irq_level(level); | ||
57 | return (value & 0x07) != 0; | ||
58 | } | 58 | } |
59 | 59 | ||
60 | void power_off(void) | 60 | void power_off(void) |
diff --git a/firmware/target/coldfire/iaudio/x5/power-x5.c b/firmware/target/coldfire/iaudio/x5/power-x5.c index cfcb384a24..068b25f577 100644 --- a/firmware/target/coldfire/iaudio/x5/power-x5.c +++ b/firmware/target/coldfire/iaudio/x5/power-x5.c | |||
@@ -38,23 +38,23 @@ void power_init(void) | |||
38 | 38 | ||
39 | bool charger_inserted(void) | 39 | bool charger_inserted(void) |
40 | { | 40 | { |
41 | return (GPIO1_READ & 0x01000000)?true:false; | 41 | return (GPIO1_READ & 0x01000000) != 0; |
42 | } | 42 | } |
43 | 43 | ||
44 | void ide_power_enable(bool on) | 44 | void ide_power_enable(bool on) |
45 | { | 45 | { |
46 | /* GPOOD3 */ | 46 | /* GPOOD3 */ |
47 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); | 47 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); |
48 | if(on) | 48 | pcf50606_write(0x3c, on ? 0x07 : 0x00); |
49 | pcf50606_write(0x3c, 0x07); | ||
50 | else | ||
51 | pcf50606_write(0x3c, 0x00); | ||
52 | set_irq_level(level); | 49 | set_irq_level(level); |
53 | } | 50 | } |
54 | 51 | ||
55 | bool ide_powered(void) | 52 | bool ide_powered(void) |
56 | { | 53 | { |
57 | return false; | 54 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); |
55 | int value = pcf50606_read(0x3c); | ||
56 | set_irq_level(level); | ||
57 | return (value & 0x07) != 0; | ||
58 | } | 58 | } |
59 | 59 | ||
60 | void power_off(void) | 60 | void power_off(void) |
diff --git a/firmware/target/coldfire/system-coldfire.c b/firmware/target/coldfire/system-coldfire.c index 97e9d35aaa..60f7ab12ad 100644 --- a/firmware/target/coldfire/system-coldfire.c +++ b/firmware/target/coldfire/system-coldfire.c | |||
@@ -18,6 +18,7 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include <stdio.h> | 19 | #include <stdio.h> |
20 | #include "config.h" | 20 | #include "config.h" |
21 | #include "adc.h" | ||
21 | #include "system.h" | 22 | #include "system.h" |
22 | #include "lcd.h" | 23 | #include "lcd.h" |
23 | #include "font.h" | 24 | #include "font.h" |
@@ -254,6 +255,16 @@ void system_init(void) | |||
254 | what'll be the most useful for most things which the main thread | 255 | what'll be the most useful for most things which the main thread |
255 | will do. */ | 256 | will do. */ |
256 | coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); | 257 | coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); |
258 | |||
259 | IMR = 0x3ffff; | ||
260 | INTPRI1 = 0; | ||
261 | INTPRI2 = 0; | ||
262 | INTPRI3 = 0; | ||
263 | INTPRI4 = 0; | ||
264 | INTPRI5 = 0; | ||
265 | INTPRI6 = 0; | ||
266 | INTPRI7 = 0; | ||
267 | INTPRI8 = 0; | ||
257 | 268 | ||
258 | /* Set INTBASE and SPURVEC */ | 269 | /* Set INTBASE and SPURVEC */ |
259 | INTBASE = 64; | 270 | INTBASE = 64; |
@@ -268,6 +279,7 @@ void system_init(void) | |||
268 | 279 | ||
269 | void system_reboot (void) | 280 | void system_reboot (void) |
270 | { | 281 | { |
282 | adc_close(); | ||
271 | set_cpu_frequency(0); | 283 | set_cpu_frequency(0); |
272 | 284 | ||
273 | asm(" move.w #0x2700,%sr"); | 285 | asm(" move.w #0x2700,%sr"); |