summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2003-12-03 01:03:54 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2003-12-03 01:03:54 +0000
commit44298163ba2afb0d5506b67e163a655c44506295 (patch)
treeae4192b5028f4c140a9e22ec2147eefac208a1c1
parent99c218a2724788d78d42217d9a685f2b2163a31b (diff)
downloadrockbox-44298163ba2afb0d5506b67e163a655c44506295.tar.gz
rockbox-44298163ba2afb0d5506b67e163a655c44506295.zip
No more spinning disk while charging flashed FM+V2 (you need the new bootloader to utilize it). ToDo: remove now false voltage reading from charging screen.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4095 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/main.c1
-rw-r--r--firmware/drivers/ata.c6
-rw-r--r--firmware/drivers/power.c42
-rw-r--r--firmware/export/config-fmrecorder.h3
-rw-r--r--firmware/export/config-recorder.h3
-rw-r--r--firmware/export/config-recorderv2.h3
-rw-r--r--firmware/export/power.h1
-rw-r--r--flash/bootloader/bootloader.c5
8 files changed, 53 insertions, 11 deletions
diff --git a/apps/main.c b/apps/main.c
index 1a1c6711b9..64c79b6e03 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -144,7 +144,6 @@ void init(void)
if (rc == 1 || rc == 2) /* charger removed or "Off/Stop" pressed */
power_off();
/* "On" pressed or USB connected: proceed */
- ide_power_enable(true);
}
rc = ata_init();
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 3c58d1f27c..3f266f2c0b 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -795,6 +795,12 @@ int ata_init(void)
ata_enable(true);
if ( !initialized ) {
+ if (!ide_powered()) /* somebody has switched it off */
+ {
+ ide_power_enable(true);
+ sleep(HZ); /* allow voltage to build up */
+ }
+
if (coldstart)
{
/* Reset both master and slave, we don't yet know what's in */
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index 549624fd92..a701d01658 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -36,11 +36,6 @@ void power_init(void)
or_b(0x20, &PBIORL); /* Set charging control bit to output */
charger_enable(false); /* Default to charger OFF */
#endif
-#ifdef HAVE_ATA_POWER_OFF
- or_b(0x20, &PADRL); /* leave the disk on */
- or_b(0x20, &PAIORL);
- PACR2 &= 0xFBFF;
-#endif
}
bool charger_inserted(void)
@@ -79,16 +74,47 @@ void charger_enable(bool on)
void ide_power_enable(bool on)
{
-#ifdef HAVE_ATA_POWER_OFF
+ (void)on;
+ bool touched = false;
+
+#ifdef NEEDS_ATA_POWER_ON
if(on)
+ {
or_b(0x20, &PADRL);
- else
+ touched = true;
+ }
+#endif
+#ifdef HAVE_ATA_POWER_OFF
+ if(!on)
+ {
and_b(~0x20, &PADRL);
+ touched = true;
+ }
+#endif
+
+/* late port preparation, else problems with read/modify/write
+ of other bits on same port, while input and floating high */
+ if (touched)
+ {
+ or_b(0x20, &PAIORL); /* PA5 is an output */
+ PACR2 &= 0xFBFF; /* GPIO for PA5 */
+ }
+}
+
+
+bool ide_powered(void)
+{
+#if defined(NEEDS_ATA_POWER_ON) || defined(HAVE_ATA_POWER_OFF)
+ if ((PACR2 & 0x0400) || !(PAIOR & 0x0020)) // not configured for output
+ return true; // would be floating high, disk on
+ else
+ return (PADR & 0x0020) != 0;
#else
- on = on;
+ return TRUE; /* pretend always powered if not controlable */
#endif
}
+
void power_off(void)
{
set_irq_level(15);
diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h
index 7c5d631875..264f9984aa 100644
--- a/firmware/export/config-fmrecorder.h
+++ b/firmware/export/config-fmrecorder.h
@@ -19,6 +19,9 @@
/* Define this if you have a LiIon battery */
#define HAVE_LIION
+/* Define this if you need to power on ATA */
+#define NEEDS_ATA_POWER_ON
+
/* Define this to the CPU frequency */
#define CPU_FREQ 11059200
diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h
index f8326a0ead..85b0c392df 100644
--- a/firmware/export/config-recorder.h
+++ b/firmware/export/config-recorder.h
@@ -19,6 +19,9 @@
/* Define this if you have ATA power-off control */
#define HAVE_ATA_POWER_OFF
+/* Define this if you need to power on ATA */
+#define NEEDS_ATA_POWER_ON
+
/* Define this to the CPU frequency */
#define CPU_FREQ 11059200
diff --git a/firmware/export/config-recorderv2.h b/firmware/export/config-recorderv2.h
index 7c5d631875..264f9984aa 100644
--- a/firmware/export/config-recorderv2.h
+++ b/firmware/export/config-recorderv2.h
@@ -19,6 +19,9 @@
/* Define this if you have a LiIon battery */
#define HAVE_LIION
+/* Define this if you need to power on ATA */
+#define NEEDS_ATA_POWER_ON
+
/* Define this to the CPU frequency */
#define CPU_FREQ 11059200
diff --git a/firmware/export/power.h b/firmware/export/power.h
index 678260ac58..54d8ca1419 100644
--- a/firmware/export/power.h
+++ b/firmware/export/power.h
@@ -27,6 +27,7 @@ void power_init(void);
bool charger_inserted(void);
void charger_enable(bool on);
void ide_power_enable(bool on);
+bool ide_powered(void);
void power_off(void);
#endif
diff --git a/flash/bootloader/bootloader.c b/flash/bootloader/bootloader.c
index 7179bbef95..543a950129 100644
--- a/flash/bootloader/bootloader.c
+++ b/flash/bootloader/bootloader.c
@@ -139,8 +139,9 @@ void PlatformInit(void)
PBDR |= 0x20; // set PB5 to keep power (fixes the ON-holding problem)
PBIOR |= 0x20; // make PB5 an output
if (ReadADC(0) < 0x1FF) // charger plugged?
- {
- // how do we switch this off?
+ { // switch off the HD, else a flat battery may not start
+ PACR2 &= 0xFBFF; // GPIO for PA5
+ PAIOR |= 0x20; // make PA5 an output (low by default)
}
#endif