summaryrefslogtreecommitdiff
path: root/firmware/target/arm/ipod/powermgmt-ipod-pcf.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/ipod/powermgmt-ipod-pcf.c')
-rw-r--r--firmware/target/arm/ipod/powermgmt-ipod-pcf.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/firmware/target/arm/ipod/powermgmt-ipod-pcf.c b/firmware/target/arm/ipod/powermgmt-ipod-pcf.c
new file mode 100644
index 0000000000..d2f88a20f2
--- /dev/null
+++ b/firmware/target/arm/ipod/powermgmt-ipod-pcf.c
@@ -0,0 +1,90 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
11 * Revisions copyright (C) 2005 by Gerald Van Baren
12 *
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include "config.h"
22#include "adc.h"
23#include "powermgmt.h"
24
25const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
26{
27#ifdef IPOD_NANO
28 3330
29#elif defined IPOD_VIDEO
30 3450
31#else
32 /* FIXME: calibrate value for other 3G+ ipods */
33 3380
34#endif
35};
36
37const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
38{
39#ifdef IPOD_NANO
40 3230
41#elif defined IPOD_VIDEO
42 3450
43#else
44 /* FIXME: calibrate value for other 3G+ ipods */
45 3020
46#endif
47};
48
49/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
50const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
51{
52#ifdef IPOD_NANO
53 /* measured values */
54 { 3230, 3620, 3700, 3730, 3750, 3780, 3830, 3890, 3950, 4030, 4160 },
55#elif defined IPOD_VIDEO
56 /* iPOD Video 30GB Li-Ion 400mAh, first approach based upon measurements */
57 { 3450, 3670, 3710, 3750, 3790, 3830, 3870, 3930, 4010, 4100, 4180 },
58#else
59 /* FIXME: calibrate value for other 3G+ ipods */
60 /* Table is "inherited" from iriver H100. */
61 { 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160 }
62#endif
63};
64
65#if CONFIG_CHARGING
66/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
67const unsigned short percent_to_volt_charge[11] =
68{
69#ifdef IPOD_NANO
70 /* measured values */
71 3230, 3620, 3700, 3730, 3750, 3780, 3830, 3890, 3950, 4030, 4160
72#elif defined IPOD_VIDEO
73 /* iPOD Video 30GB Li-Ion 400mAh, first approach based upon measurements */
74 3450, 3670, 3710, 3750, 3790, 3830, 3870, 3930, 4010, 4100, 4180
75#else
76 /* FIXME: calibrate value for other 3G+ ipods */
77 /* Table is "inherited" from iriver H100. */
78 3540, 3860, 3930, 3980, 4000, 4020, 4040, 4080, 4130, 4180, 4230
79#endif
80};
81#endif /* CONFIG_CHARGING */
82
83#define BATTERY_SCALE_FACTOR 6000
84/* full-scale ADC readout (2^10) in millivolt */
85
86/* Returns battery voltage from ADC [millivolts] */
87unsigned int battery_adc_voltage(void)
88{
89 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
90}