FS#8961 - Anti-Aliased Fonts.
[kugel-rb.git] / firmware / target / arm / ipod / powermgmt-ipod-pcf.c
blob703d1da833e896eed0f6870a70c779c469f0be94
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
11 * Revisions copyright (C) 2005 by Gerald Van Baren
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
23 #include "config.h"
24 #include "adc.h"
25 #include "powermgmt.h"
26 #include "pcf5060x.h"
27 #include "pcf50605.h"
29 const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
31 #ifdef IPOD_NANO
32 3330
33 #elif defined IPOD_VIDEO
34 3300
35 #else
36 /* FIXME: calibrate value for other 3G+ ipods */
37 3380
38 #endif
41 const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
43 #ifdef IPOD_NANO
44 3230
45 #elif defined IPOD_VIDEO
46 3300
47 #else
48 /* FIXME: calibrate value for other 3G+ ipods */
49 3020
50 #endif
53 /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
54 const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
56 #ifdef IPOD_NANO
57 /* measured values */
58 { 3230, 3620, 3700, 3730, 3750, 3780, 3830, 3890, 3950, 4030, 4160 },
59 #elif defined IPOD_VIDEO
60 /* iPOD Video 30GB Li-Ion 400mAh, first approach based upon measurements */
61 { 3450, 3670, 3710, 3750, 3790, 3830, 3870, 3930, 4010, 4100, 4180 },
62 #elif defined IPOD_COLOR
63 /* iPOD Color 60GB Li-Ion, first approach based upon measurements */
64 { 3500, 3676, 3729, 3755, 3778, 3805, 3847, 3919, 3961, 4071, 4109 },
65 #else
66 /* FIXME: calibrate value for other 3G+ ipods */
67 /* Table is "inherited" from iriver H100. */
68 { 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160 }
69 #endif
72 #if CONFIG_CHARGING
73 /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
74 const unsigned short percent_to_volt_charge[11] =
76 #ifdef IPOD_NANO
77 /* measured values */
78 3230, 3620, 3700, 3730, 3750, 3780, 3830, 3890, 3950, 4030, 4160
79 #elif defined IPOD_VIDEO
80 /* iPOD Video 30GB Li-Ion 400mAh, first approach based upon measurements */
81 3450, 3670, 3710, 3750, 3790, 3830, 3870, 3930, 4010, 4100, 4180
82 #else
83 /* FIXME: calibrate value for other 3G+ ipods */
84 /* Table is "inherited" from iriver H100. */
85 3540, 3860, 3930, 3980, 4000, 4020, 4040, 4080, 4130, 4180, 4230
86 #endif
88 #endif /* CONFIG_CHARGING */
90 #define BATTERY_SCALE_FACTOR 6000
91 /* full-scale ADC readout (2^10) in millivolt */
93 /* Returns battery voltage from ADC [millivolts] */
94 unsigned int battery_adc_voltage(void)
96 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
99 #ifdef HAVE_ACCESSORY_SUPPLY
100 void accessory_supply_set(bool enable)
102 if (enable)
104 /* Accessory voltage supply */
105 pcf50605_write(PCF5060X_D2REGC1, 0xf8); /* 3.3V ON */
107 else
109 /* Accessory voltage supply */
110 pcf50605_write(PCF5060X_D2REGC1, 0x18); /* OFF */
114 #endif