summaryrefslogtreecommitdiff
path: root/firmware/target/arm/iriver
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/iriver')
-rw-r--r--firmware/target/arm/iriver/h10/powermgmt-h10.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/firmware/target/arm/iriver/h10/powermgmt-h10.c b/firmware/target/arm/iriver/h10/powermgmt-h10.c
new file mode 100644
index 0000000000..18e3879c43
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/powermgmt-h10.c
@@ -0,0 +1,71 @@
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 IRIVER_H10
28 3760
29#elif defined IRIVER_H10_5GB
30 3720
31#endif
32};
33
34const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
35{
36#ifdef IRIVER_H10
37 3650
38#elif defined IRIVER_H10_5GB
39 3650
40#endif
41};
42
43/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
44const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
45{
46#ifdef IRIVER_H10
47 { 3760, 3800, 3850, 3870, 3900, 3950, 4020, 4070, 4110, 4180, 4240 }
48#elif defined IRIVER_H10_5GB
49 { 3720, 3740, 3800, 3820, 3840, 3880, 3940, 4020, 4060, 4150, 4240 }
50#endif
51};
52
53/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
54const unsigned short percent_to_volt_charge[11] =
55{
56#ifdef IRIVER_H10
57 3990, 4030, 4060, 4080, 4100, 4120, 4150, 4180, 4220, 4260, 4310
58#elif defined IRIVER_H10_5GB
59 /* TODO: Not yet calibrated */
60 3880, 3920, 3960, 4000, 4060, 4100, 4150, 4190, 4240, 4280, 4330
61#endif
62};
63
64#define BATTERY_SCALE_FACTOR 4800
65/* full-scale ADC readout (2^10) in millivolt */
66
67/* Returns battery voltage from ADC [millivolts] */
68unsigned int battery_adc_voltage(void)
69{
70 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
71}