diff options
author | Michael Sparmann <theseven@rockbox.org> | 2009-10-08 20:56:51 +0000 |
---|---|---|
committer | Michael Sparmann <theseven@rockbox.org> | 2009-10-08 20:56:51 +0000 |
commit | 1fa5d49380a412aa909446d2afeb6c3894e392c6 (patch) | |
tree | 90e4eae3b09e33578e490ddb48a22e01a0832460 /firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c | |
parent | 32b367b042f7e12d06be42e026bc679d48796ede (diff) | |
download | rockbox-1fa5d49380a412aa909446d2afeb6c3894e392c6.tar.gz rockbox-1fa5d49380a412aa909446d2afeb6c3894e392c6.zip |
Implemented iPod Nano 2G power_off()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23014 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c')
-rw-r--r-- | firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c index 7a6407e809..4dd295c21a 100644 --- a/firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c +++ b/firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c | |||
@@ -24,30 +24,30 @@ | |||
24 | #include "i2c-s5l8700.h" | 24 | #include "i2c-s5l8700.h" |
25 | 25 | ||
26 | static struct mutex pmu_adc_mutex; | 26 | static struct mutex pmu_adc_mutex; |
27 | int pmu_initialized; | 27 | int pmu_initialized = 0; |
28 | 28 | ||
29 | unsigned char pmu_read(int address) | 29 | void pmu_read_multiple(int address, int count, unsigned char* buffer) |
30 | { | 30 | { |
31 | unsigned char tmp; | 31 | i2c_read(0xe6, address, count, buffer); |
32 | |||
33 | i2c_read(0xe6, address, 1, &tmp); | ||
34 | |||
35 | return tmp; | ||
36 | } | 32 | } |
37 | 33 | ||
38 | void pmu_write(int address, unsigned char val) | 34 | void pmu_write_multiple(int address, int count, unsigned char* buffer) |
39 | { | 35 | { |
40 | i2c_write(0xe6, address, 1, &val); | 36 | i2c_write(0xe6, address, count, buffer); |
41 | } | 37 | } |
42 | 38 | ||
43 | void pmu_read_multiple(int address, int count, unsigned char* buffer) | 39 | unsigned char pmu_read(int address) |
44 | { | 40 | { |
45 | i2c_read(0xe6, address, count, buffer); | 41 | unsigned char tmp; |
42 | |||
43 | pmu_read_multiple(address, 1, &tmp); | ||
44 | |||
45 | return tmp; | ||
46 | } | 46 | } |
47 | 47 | ||
48 | void pmu_write_multiple(int address, int count, unsigned char* buffer) | 48 | void pmu_write(int address, unsigned char val) |
49 | { | 49 | { |
50 | i2c_write(0xe6, address, count, buffer); | 50 | pmu_write_multiple(address, 1, &val); |
51 | } | 51 | } |
52 | 52 | ||
53 | void pmu_init(void) | 53 | void pmu_init(void) |
@@ -88,3 +88,19 @@ int pmu_read_battery_current(void) | |||
88 | mutex_unlock(&pmu_adc_mutex); | 88 | mutex_unlock(&pmu_adc_mutex); |
89 | return milliamps; | 89 | return milliamps; |
90 | } | 90 | } |
91 | |||
92 | void pmu_switch_power(int gate, int onoff) | ||
93 | { | ||
94 | if (gate < 4) | ||
95 | { | ||
96 | unsigned char newval = pmu_read(0x3B) & ~(1 << (2 * gate)); | ||
97 | if (onoff) newval |= 1 << (2 * gate); | ||
98 | pmu_write(0x3B, newval); | ||
99 | } | ||
100 | else if (gate < 7) | ||
101 | { | ||
102 | unsigned char newval = pmu_read(0x3C) & ~(1 << (2 * (gate - 4))); | ||
103 | if (onoff) newval |= 1 << (2 * (gate - 4)); | ||
104 | pmu_write(0x3C, newval); | ||
105 | } | ||
106 | } \ No newline at end of file | ||