diff options
Diffstat (limited to 'firmware/target/arm/philips/hdd1630')
-rw-r--r-- | firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c index 7d132523e6..a5ed80b9ab 100644 --- a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c | |||
@@ -31,42 +31,33 @@ | |||
31 | 31 | ||
32 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | 32 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = |
33 | { | 33 | { |
34 | 3550 | 34 | 3500 |
35 | }; | 35 | }; |
36 | 36 | ||
37 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | 37 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = |
38 | { | 38 | { |
39 | 3500 | 39 | 3400 |
40 | }; | 40 | }; |
41 | 41 | ||
42 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | 42 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ |
43 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | 43 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = |
44 | { | 44 | { |
45 | { 3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990 }, | 45 | { 3400, 3550, 3630, 3690 ,3730, 3770, 3810, 3850, 3890, 3930, 3980 }, |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #if CONFIG_CHARGING | 48 | #if CONFIG_CHARGING |
49 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | 49 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ |
50 | const unsigned short percent_to_volt_charge[11] = | 50 | const unsigned short percent_to_volt_charge[11] = |
51 | { | 51 | { |
52 | 3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990 | 52 | 3400, 3650, 3822, 3910 ,3950, 3990, 4030, 4070, 4110, 4150, 4200 |
53 | }; | 53 | }; |
54 | #endif /* CONFIG_CHARGING */ | 54 | #endif /* CONFIG_CHARGING */ |
55 | 55 | ||
56 | #define BATTERY_SCALE_FACTOR 4200 | 56 | #define BATTERY_SCALE_FACTOR 4536 |
57 | /* full-scale ADC readout (2^10) in millivolt */ | 57 | /* full-scale ADC readout (2^10) in millivolt */ |
58 | 58 | ||
59 | /* Returns battery voltage from ADC [millivolts] */ | 59 | /* Returns battery voltage from ADC [millivolts] */ |
60 | int _battery_voltage(void) | 60 | int _battery_voltage(void) |
61 | { | 61 | { |
62 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ | 62 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
63 | |||
64 | /* This may be overly complicated (pulled from the OF) */ | ||
65 | int lo = 0; | ||
66 | int val = adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR; | ||
67 | |||
68 | SMLAL(lo, val, 0x8a42f871, val); | ||
69 | val>>= 9; | ||
70 | val -= (val >> 31); | ||
71 | return val; | ||
72 | } | 63 | } |