diff options
author | Dave Chapman <dave@dchapman.com> | 2005-12-21 23:32:19 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2005-12-21 23:32:19 +0000 |
commit | 4ba9eac8941fb5340ac5be09df37ee699bceaf64 (patch) | |
tree | d98a473e3a134debd740a6185a374b808689512e | |
parent | 085f2f428e1b2057a906e61ae016e47e41eb2719 (diff) | |
download | rockbox-4ba9eac8941fb5340ac5be09df37ee699bceaf64.tar.gz rockbox-4ba9eac8941fb5340ac5be09df37ee699bceaf64.zip |
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
-rw-r--r-- | firmware/drivers/pcf50605.c | 47 | ||||
-rw-r--r-- | firmware/drivers/power.c | 4 | ||||
-rw-r--r-- | firmware/export/pcf50605.h | 1 |
3 files changed, 48 insertions, 4 deletions
diff --git a/firmware/drivers/pcf50605.c b/firmware/drivers/pcf50605.c index c7a8db5941..d205f89882 100644 --- a/firmware/drivers/pcf50605.c +++ b/firmware/drivers/pcf50605.c | |||
@@ -27,6 +27,40 @@ | |||
27 | #include "i2c-pp5020.h" | 27 | #include "i2c-pp5020.h" |
28 | #include "rtc.h" | 28 | #include "rtc.h" |
29 | 29 | ||
30 | #define OOCS 0x01 | ||
31 | #define INT1 0x02 | ||
32 | #define INT2 0x03 | ||
33 | #define INT3 0x04 | ||
34 | #define INT1M 0x05 | ||
35 | #define INT2M 0x06 | ||
36 | #define INT3M 0x07 | ||
37 | #define OOCC1 0x08 | ||
38 | #define GOSTDBY 0x1 | ||
39 | #define TOTRST (0x1 << 1) | ||
40 | #define CLK32ON (0x1 << 2) | ||
41 | #define WDTRST (0x1 << 3) | ||
42 | #define RTCWAK (0x1 << 4) | ||
43 | #define CHGWAK (0x1 << 5) | ||
44 | #define EXTONWAK (0x01 << 6) | ||
45 | #define OOCC2 0x09 | ||
46 | #define RTCSC 0x0a | ||
47 | #define RTCMN 0x0b | ||
48 | #define RTCHR 0x0c | ||
49 | #define RTCWD 0x0d | ||
50 | #define RTCDT 0x0e | ||
51 | #define RTCMT 0x0f | ||
52 | #define RTCYR 0x10 | ||
53 | #define RTCSCA 0x11 | ||
54 | #define RTCMNA 0x12 | ||
55 | #define RTCHRA 0x13 | ||
56 | #define RTCWDA 0x14 | ||
57 | #define RTCDTA 0x15 | ||
58 | #define RTCMTA 0x16 | ||
59 | #define RTCYRA 0x17 | ||
60 | #define PSSC 0x18 | ||
61 | #define PWROKM 0x19 | ||
62 | #define PWROKS 0x1a | ||
63 | |||
30 | int pcf50605_read(int address) | 64 | int pcf50605_read(int address) |
31 | { | 65 | { |
32 | return i2c_readbyte(0x8,address); | 66 | return i2c_readbyte(0x8,address); |
@@ -47,9 +81,7 @@ int pcf50605_read_multiple(int address, unsigned char* buf, int count) | |||
47 | 81 | ||
48 | int pcf50605_write(int address, unsigned char val) | 82 | int pcf50605_write(int address, unsigned char val) |
49 | { | 83 | { |
50 | /* TODO */ | 84 | ipod_i2c_send(0x8, address, val); |
51 | (void)address; | ||
52 | (void)val; | ||
53 | return 0; | 85 | return 0; |
54 | } | 86 | } |
55 | 87 | ||
@@ -84,6 +116,15 @@ static int pcf50605_a2d_read(int adc_input) | |||
84 | return (hi << 2) | lo; | 116 | return (hi << 2) | lo; |
85 | } | 117 | } |
86 | 118 | ||
119 | /* The following command puts the iPod into a deep sleep. Warning | ||
120 | from the good people of ipodlinux - never issue this command | ||
121 | without setting CHGWAK or EXTONWAK if you ever want to be able to | ||
122 | power on your iPod again. */ | ||
123 | void pcf50605_standby_mode(void) | ||
124 | { | ||
125 | pcf50605_write(OOCC1, GOSTDBY | CHGWAK | EXTONWAK); | ||
126 | } | ||
127 | |||
87 | int pcf50605_battery_read(void) | 128 | int pcf50605_battery_read(void) |
88 | { | 129 | { |
89 | return pcf50605_a2d_read(0x3); /* ADCIN1, subtractor */ | 130 | return pcf50605_a2d_read(0x3); /* ADCIN1, subtractor */ |
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c index e339b901cb..04168f9895 100644 --- a/firmware/drivers/power.c +++ b/firmware/drivers/power.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "power.h" | 25 | #include "power.h" |
26 | #include "hwcompat.h" | 26 | #include "hwcompat.h" |
27 | #include "logf.h" | 27 | #include "logf.h" |
28 | #include "pcf50605.h" | ||
28 | #include "pcf50606.h" | 29 | #include "pcf50606.h" |
29 | 30 | ||
30 | #ifdef HAVE_CHARGE_CTRL | 31 | #ifdef HAVE_CHARGE_CTRL |
@@ -261,7 +262,8 @@ void power_off(void) | |||
261 | #if CONFIG_CPU == MCF5249 | 262 | #if CONFIG_CPU == MCF5249 |
262 | and_l(~0x00080000, &GPIO1_OUT); | 263 | and_l(~0x00080000, &GPIO1_OUT); |
263 | #elif CONFIG_CPU == PP5020 | 264 | #elif CONFIG_CPU == PP5020 |
264 | /* TODO: Implement power_off() */ | 265 | /* We don't turn off the ipod, we put it in a deep sleep */ |
266 | pcf50605_standby_mode(); | ||
265 | #elif defined(GMINI_ARCH) | 267 | #elif defined(GMINI_ARCH) |
266 | P1 &= ~1; | 268 | P1 &= ~1; |
267 | P1CON &= ~1; | 269 | P1CON &= ~1; |
diff --git a/firmware/export/pcf50605.h b/firmware/export/pcf50605.h index fc52b98e99..8da64f3325 100644 --- a/firmware/export/pcf50605.h +++ b/firmware/export/pcf50605.h | |||
@@ -26,6 +26,7 @@ void pcf50605_read_multiple(int address, unsigned char* buf, int count); | |||
26 | int pcf50605_write(int address, unsigned char val); | 26 | int pcf50605_write(int address, unsigned char val); |
27 | int pcf50605_write_multiple(int address, const unsigned char* buf, int count); | 27 | int pcf50605_write_multiple(int address, const unsigned char* buf, int count); |
28 | int pcf50605_battery_read(void); | 28 | int pcf50605_battery_read(void); |
29 | void pcf50605_standby_mode(void); | ||
29 | #endif | 30 | #endif |
30 | 31 | ||
31 | #endif | 32 | #endif |