summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bootloader/iaudio_coldfire.c44
-rw-r--r--firmware/export/adc.h4
-rw-r--r--firmware/rolo.c1
-rw-r--r--firmware/target/coldfire/iaudio/m3/adc-target.h3
-rw-r--r--firmware/target/coldfire/iaudio/m3/power-m3.c4
-rw-r--r--firmware/target/coldfire/iaudio/m5/power-m5.c12
-rw-r--r--firmware/target/coldfire/iaudio/x5/power-x5.c12
-rw-r--r--firmware/target/coldfire/system-coldfire.c12
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)
void start_firmware(void)
{
+ adc_close();
asm(" move.w #0x2700,%sr");
__reset_cookie();
asm(" move.l %0,%%d0" :: "i"(DRAM_START));
@@ -126,16 +127,35 @@ void main(void)
int rc;
bool rc_on_button = false;
bool on_button = false;
- bool rec_button = false;
- bool hold_status = false;
+
+ /* We want to read the buttons as early as possible, before the user
+ releases the ON button */
+
+#ifdef IAUDIO_M3
+ or_l(0x80000000, &GPIO_FUNCTION); /* remote Play button */
+ and_l(~0x80000000, &GPIO_ENABLE);
+ or_l(0x00000202, &GPIO1_FUNCTION); /* main Hold & Play */
+
+ if ((GPIO1_READ & 0x000000002) == 0)
+ on_button = true;
+
+ if ((GPIO_READ & 0x80000000) == 0)
+ rc_on_button = true;
+#elif defined(IAUDIO_M5) || defined(IAUDIO_X5)
int data;
- (void)rc_on_button;
- (void)on_button;
- (void)rec_button;
- (void)hold_status;
- (void)data;
+ or_l(0x0e000000, &GPIO_FUNCTION); /* main Hold & Power, remote Play */
+ and_l(~0x0e000000, &GPIO_ENABLE);
+
+ data = GPIO_READ;
+ if ((data & 0x04000000) == 0)
+ on_button = true;
+
+ if ((data & 0x02000000) == 0)
+ rc_on_button = true;
+#endif
+
power_init();
system_init();
@@ -153,6 +173,16 @@ void main(void)
font_init();
adc_init();
button_init();
+
+ if ((!on_button || button_hold())
+ && (!rc_on_button || remote_button_hold())
+ && !charger_inserted())
+ {
+ /* No need to check for USB connection here, as USB is handled
+ * in the cowon loader. */
+ printf("Hold switch on");
+ shutdown();
+ }
printf("Rockbox boot loader");
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 @@
unsigned short adc_read(int channel);
void adc_init(void);
+#ifndef NEED_ADC_CLOSE
+#define adc_close()
+#endif
+
#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)
lcd_remote_puts(0, 1, "Executing");
lcd_remote_update();
#endif
+ adc_close();
set_irq_level(HIGHEST_IRQ_LEVEL);
#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 @@
#define ADC_BATTERY 1
#define ADC_REMOTE 2
+#define NEED_ADC_CLOSE
+void adc_close(void);
+
#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)
/* Charger detect */
and_l(~0x00000020, &GPIO1_ENABLE);
or_l(0x00000020, &GPIO1_FUNCTION);
-
+
/* FIXME: Just disable the multi-colour LED for now. */
and_l(~0x00000210, &GPIO1_OUT);
and_l(~0x00008000, &GPIO_OUT);
@@ -61,7 +61,7 @@ void ide_power_enable(bool on)
bool ide_powered(void)
{
- return false;
+ return (GPIO_OUT & 0x00800000) != 0;
}
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)
bool charger_inserted(void)
{
- return (GPIO1_READ & 0x01000000)?true:false;
+ return (GPIO1_READ & 0x01000000) != 0;
}
void ide_power_enable(bool on)
{
/* GPOOD3 */
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
- if(on)
- pcf50606_write(0x3c, 0x07);
- else
- pcf50606_write(0x3c, 0x00);
+ pcf50606_write(0x3c, on ? 0x07 : 0x00);
set_irq_level(level);
}
bool ide_powered(void)
{
- return false;
+ int level = set_irq_level(HIGHEST_IRQ_LEVEL);
+ int value = pcf50606_read(0x3c);
+ set_irq_level(level);
+ return (value & 0x07) != 0;
}
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)
bool charger_inserted(void)
{
- return (GPIO1_READ & 0x01000000)?true:false;
+ return (GPIO1_READ & 0x01000000) != 0;
}
void ide_power_enable(bool on)
{
/* GPOOD3 */
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
- if(on)
- pcf50606_write(0x3c, 0x07);
- else
- pcf50606_write(0x3c, 0x00);
+ pcf50606_write(0x3c, on ? 0x07 : 0x00);
set_irq_level(level);
}
bool ide_powered(void)
{
- return false;
+ int level = set_irq_level(HIGHEST_IRQ_LEVEL);
+ int value = pcf50606_read(0x3c);
+ set_irq_level(level);
+ return (value & 0x07) != 0;
}
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 @@
****************************************************************************/
#include <stdio.h>
#include "config.h"
+#include "adc.h"
#include "system.h"
#include "lcd.h"
#include "font.h"
@@ -254,6 +255,16 @@ void system_init(void)
what'll be the most useful for most things which the main thread
will do. */
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
+
+ IMR = 0x3ffff;
+ INTPRI1 = 0;
+ INTPRI2 = 0;
+ INTPRI3 = 0;
+ INTPRI4 = 0;
+ INTPRI5 = 0;
+ INTPRI6 = 0;
+ INTPRI7 = 0;
+ INTPRI8 = 0;
/* Set INTBASE and SPURVEC */
INTBASE = 64;
@@ -268,6 +279,7 @@ void system_init(void)
void system_reboot (void)
{
+ adc_close();
set_cpu_frequency(0);
asm(" move.w #0x2700,%sr");