diff options
Diffstat (limited to 'firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c')
-rw-r--r-- | firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c new file mode 100644 index 0000000000..3bd3791eeb --- /dev/null +++ b/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: powermgmt-nano2g.c 28159 2010-09-24 22:42:06Z Buschel $ | ||
9 | * | ||
10 | * Copyright © 2008 Rafaël Carré | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "powermgmt.h" | ||
24 | #include "pmu-target.h" | ||
25 | #include "power.h" | ||
26 | #include "audiohw.h" | ||
27 | |||
28 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
29 | { | ||
30 | 3600 | ||
31 | }; | ||
32 | |||
33 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
34 | { | ||
35 | 3350 | ||
36 | }; | ||
37 | |||
38 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
39 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
40 | { | ||
41 | { 3550, 3783, 3830, 3882, 3911, 3949, 3996, 4067, 4148, 4228, 4310 } | ||
42 | }; | ||
43 | |||
44 | #if CONFIG_CHARGING | ||
45 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
46 | const unsigned short percent_to_volt_charge[11] = | ||
47 | { | ||
48 | 3550, 3783, 3830, 3882, 3911, 3949, 3996, 4067, 4148, 4228, 4310 | ||
49 | }; | ||
50 | #endif /* CONFIG_CHARGING */ | ||
51 | |||
52 | /* ADC should read 0x3ff=6.00V */ | ||
53 | #define BATTERY_SCALE_FACTOR 6000 | ||
54 | /* full-scale ADC readout (2^10) in millivolt */ | ||
55 | |||
56 | |||
57 | /* Returns battery voltage from ADC [millivolts] */ | ||
58 | unsigned int battery_adc_voltage(void) | ||
59 | { | ||
60 | int compensation = (10 * (pmu_read_battery_current() - 7)) / 12; | ||
61 | if (charging_state()) return pmu_read_battery_voltage() - compensation; | ||
62 | return pmu_read_battery_voltage() + compensation; | ||
63 | } | ||
64 | |||
65 | |||
66 | #ifdef HAVE_ACCESSORY_SUPPLY | ||
67 | void accessory_supply_set(bool enable) | ||
68 | { | ||
69 | if (enable) | ||
70 | { | ||
71 | /* Accessory voltage supply on */ | ||
72 | //TODO: pmu_ldo_power_on(6); | ||
73 | } | ||
74 | else | ||
75 | { | ||
76 | /* Accessory voltage supply off */ | ||
77 | //TODO: pmu_ldo_power_off(6); | ||
78 | } | ||
79 | } | ||
80 | #endif | ||
81 | |||
82 | #ifdef HAVE_LINEOUT_POWEROFF | ||
83 | void lineout_set(bool enable) | ||
84 | { | ||
85 | /* Call audio hardware driver implementation */ | ||
86 | audiohw_enable_lineout(enable); | ||
87 | } | ||
88 | #endif | ||