summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2005-12-21 23:32:19 +0000
committerDave Chapman <dave@dchapman.com>2005-12-21 23:32:19 +0000
commit4ba9eac8941fb5340ac5be09df37ee699bceaf64 (patch)
treed98a473e3a134debd740a6185a374b808689512e /firmware/drivers
parent085f2f428e1b2057a906e61ae016e47e41eb2719 (diff)
downloadrockbox-4ba9eac8941fb5340ac5be09df37ee699bceaf64.zip
rockbox-4ba9eac8941fb5340ac5be09df37ee699bceaf64.tar.gz
rockbox-4ba9eac8941fb5340ac5be09df37ee699bceaf64.tar.bz2
rockbox-4ba9eac8941fb5340ac5be09df37ee699bceaf64.tar.xz
Put the ipod into standby mode on shutdown. This is untested on the 5g, but should work...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8275 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/pcf50605.c47
-rw-r--r--firmware/drivers/power.c4
2 files changed, 47 insertions, 4 deletions
diff --git a/firmware/drivers/pcf50605.c b/firmware/drivers/pcf50605.c
index c7a8db5..d205f89 100644
--- a/firmware/drivers/pcf50605.c
+++ b/firmware/drivers/pcf50605.c
@@ -27,6 +27,40 @@
#include "i2c-pp5020.h"
#include "rtc.h"
+#define OOCS 0x01
+#define INT1 0x02
+#define INT2 0x03
+#define INT3 0x04
+#define INT1M 0x05
+#define INT2M 0x06
+#define INT3M 0x07
+#define OOCC1 0x08
+ #define GOSTDBY 0x1
+ #define TOTRST (0x1 << 1)
+ #define CLK32ON (0x1 << 2)
+ #define WDTRST (0x1 << 3)
+ #define RTCWAK (0x1 << 4)
+ #define CHGWAK (0x1 << 5)
+ #define EXTONWAK (0x01 << 6)
+#define OOCC2 0x09
+#define RTCSC 0x0a
+#define RTCMN 0x0b
+#define RTCHR 0x0c
+#define RTCWD 0x0d
+#define RTCDT 0x0e
+#define RTCMT 0x0f
+#define RTCYR 0x10
+#define RTCSCA 0x11
+#define RTCMNA 0x12
+#define RTCHRA 0x13
+#define RTCWDA 0x14
+#define RTCDTA 0x15
+#define RTCMTA 0x16
+#define RTCYRA 0x17
+#define PSSC 0x18
+#define PWROKM 0x19
+#define PWROKS 0x1a
+
int pcf50605_read(int address)
{
return i2c_readbyte(0x8,address);
@@ -47,9 +81,7 @@ int pcf50605_read_multiple(int address, unsigned char* buf, int count)
int pcf50605_write(int address, unsigned char val)
{
- /* TODO */
- (void)address;
- (void)val;
+ ipod_i2c_send(0x8, address, val);
return 0;
}
@@ -84,6 +116,15 @@ static int pcf50605_a2d_read(int adc_input)
return (hi << 2) | lo;
}
+/* The following command puts the iPod into a deep sleep. Warning
+ from the good people of ipodlinux - never issue this command
+ without setting CHGWAK or EXTONWAK if you ever want to be able to
+ power on your iPod again. */
+void pcf50605_standby_mode(void)
+{
+ pcf50605_write(OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
+}
+
int pcf50605_battery_read(void)
{
return pcf50605_a2d_read(0x3); /* ADCIN1, subtractor */
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index e339b90..04168f9 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -25,6 +25,7 @@
#include "power.h"
#include "hwcompat.h"
#include "logf.h"
+#include "pcf50605.h"
#include "pcf50606.h"
#ifdef HAVE_CHARGE_CTRL
@@ -261,7 +262,8 @@ void power_off(void)
#if CONFIG_CPU == MCF5249
and_l(~0x00080000, &GPIO1_OUT);
#elif CONFIG_CPU == PP5020
- /* TODO: Implement power_off() */
+ /* We don't turn off the ipod, we put it in a deep sleep */
+ pcf50605_standby_mode();
#elif defined(GMINI_ARCH)
P1 &= ~1;
P1CON &= ~1;