From 015f6286a8db3fb79d155cf33698ededf219d32e Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sat, 3 Nov 2007 23:57:24 +0000 Subject: Finally: HDD power control for all PP502x iPods (4th gen Grayscale, Color, Minis, Video). * Wait a short time after powering on the HDD on all disk based targets, as that seems like a good idea. Shorten the excessive wait on initial power on. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15444 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata.c | 3 ++- firmware/export/config-ipod4g.h | 3 +++ firmware/export/config-ipodcolor.h | 3 +++ firmware/export/config-ipodmini.h | 3 +++ firmware/export/config-ipodmini2g.h | 3 +++ firmware/export/config-ipodvideo.h | 3 +++ firmware/target/arm/ipod/power-ipod.c | 26 ++++++++++++++++++++------ firmware/target/arm/iriver/h10/power-h10.c | 5 ++--- 8 files changed, 39 insertions(+), 10 deletions(-) diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index f63b795a19..67aab8a9ba 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -949,6 +949,7 @@ static int ata_power_on(void) int rc; ide_power_enable(true); + sleep(HZ/50); /* allow voltage to build up */ if( ata_hard_reset() ) return -1; @@ -1145,7 +1146,7 @@ int ata_init(void) if (!ide_powered()) /* somebody has switched it off */ { ide_power_enable(true); - sleep(HZ); /* allow voltage to build up */ + sleep(HZ/50); /* allow voltage to build up */ } /* first try, hard reset at cold start only */ diff --git a/firmware/export/config-ipod4g.h b/firmware/export/config-ipod4g.h index d75650ba4f..7d58992ee8 100644 --- a/firmware/export/config-ipod4g.h +++ b/firmware/export/config-ipod4g.h @@ -104,6 +104,9 @@ /* Define this if you want to use the PP5020 i2c interface */ #define CONFIG_I2C I2C_PP5020 +/* We're able to shut off power to the HDD */ +#define HAVE_ATA_POWER_OFF + /* define this if the hardware can be powered off while charging */ //#define HAVE_POWEROFF_WHILE_CHARGING diff --git a/firmware/export/config-ipodcolor.h b/firmware/export/config-ipodcolor.h index 8a4c19eda7..a5850904fa 100644 --- a/firmware/export/config-ipodcolor.h +++ b/firmware/export/config-ipodcolor.h @@ -93,6 +93,9 @@ /* Define this if you want to use the PP5020 i2c interface */ #define CONFIG_I2C I2C_PP5020 +/* We're able to shut off power to the HDD */ +#define HAVE_ATA_POWER_OFF + /* define this if the hardware can be powered off while charging */ //#define HAVE_POWEROFF_WHILE_CHARGING diff --git a/firmware/export/config-ipodmini.h b/firmware/export/config-ipodmini.h index 3b2473718d..5cab1767e3 100644 --- a/firmware/export/config-ipodmini.h +++ b/firmware/export/config-ipodmini.h @@ -101,6 +101,9 @@ /* Define this if you want to use the PP5020 i2c interface */ #define CONFIG_I2C I2C_PP5020 +/* We're able to shut off power to the HDD */ +#define HAVE_ATA_POWER_OFF + /* define this if the hardware can be powered off while charging */ //#define HAVE_POWEROFF_WHILE_CHARGING diff --git a/firmware/export/config-ipodmini2g.h b/firmware/export/config-ipodmini2g.h index 34e5f5a46b..77299dda01 100644 --- a/firmware/export/config-ipodmini2g.h +++ b/firmware/export/config-ipodmini2g.h @@ -101,6 +101,9 @@ /* Define this if you want to use the PP5020 i2c interface */ #define CONFIG_I2C I2C_PP5020 +/* We're able to shut off power to the HDD */ +#define HAVE_ATA_POWER_OFF + /* define this if the hardware can be powered off while charging */ //#define HAVE_POWEROFF_WHILE_CHARGING diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h index 71cb8abf39..9ba479246b 100644 --- a/firmware/export/config-ipodvideo.h +++ b/firmware/export/config-ipodvideo.h @@ -103,6 +103,9 @@ /* Define this if you want to use the PP5020 i2c interface */ #define CONFIG_I2C I2C_PP5020 +/* We're able to shut off power to the HDD */ +#define HAVE_ATA_POWER_OFF + /* define this if the hardware can be powered off while charging */ //#define HAVE_POWEROFF_WHILE_CHARGING diff --git a/firmware/target/arm/ipod/power-ipod.c b/firmware/target/arm/ipod/power-ipod.c index 37ef418026..ae663d16e5 100644 --- a/firmware/target/arm/ipod/power-ipod.c +++ b/firmware/target/arm/ipod/power-ipod.c @@ -63,9 +63,19 @@ void ide_power_enable(bool on) GPIOC_OUTPUT_VAL &= ~0x40; else GPIOC_OUTPUT_VAL |= 0x40; -#else - /* We do nothing on other iPods yet */ - (void)on; +#elif defined(IPOD_4G) || defined(IPOD_COLOR) \ + || defined(IPOD_MINI) || defined(IPOD_MINI2G) + if (on) + GPIO_CLEAR_BITWISE(GPIOJ_OUTPUT_VAL, 0x04); + else + GPIO_SET_BITWISE(GPIOJ_OUTPUT_VAL, 0x04); +#elif defined(IPOD_VIDEO) + if (on) + GPO32_VAL &= ~0x40000000; + else + GPO32_VAL |= 0x40000000; +#else /* Nano */ + (void)on; /* Do nothing. */ #endif } @@ -73,9 +83,13 @@ bool ide_powered(void) { #if defined(IPOD_1G2G) || defined(IPOD_3G) return !(GPIOC_OUTPUT_VAL & 0x40); -#else - /* pretend we are always powered - we don't turn it off on the ipod */ - return true; +#elif defined(IPOD_4G) || defined(IPOD_COLOR) \ + || defined(IPOD_MINI) || defined(IPOD_MINI2G) + return !(GPIOJ_OUTPUT_VAL & 0x04); +#elif defined(IPOD_VIDEO) + return !(GPO32_VAL & 0x40000000); +#else /* Nano */ + return true; /* Pretend we are always powered */ #endif } diff --git a/firmware/target/arm/iriver/h10/power-h10.c b/firmware/target/arm/iriver/h10/power-h10.c index 9cbdb50080..7f3fb40b36 100644 --- a/firmware/target/arm/iriver/h10/power-h10.c +++ b/firmware/target/arm/iriver/h10/power-h10.c @@ -60,10 +60,9 @@ bool charger_inserted(void) void ide_power_enable(bool on) { if(on){ - GPIOF_OUTPUT_VAL &=~ 0x1; - sleep(1); + GPIO_CLEAR_BITWISE(GPIOF_OUTPUT_VAL, 0x01); } else { - GPIOF_OUTPUT_VAL |= 0x1; + GPIO_SET_BITWISE(GPIOF_OUTPUT_VAL, 0x01); } } -- cgit v1.2.3