summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c66
-rw-r--r--firmware/target/arm/ipod/powermgmt-ipod-pcf.c90
-rw-r--r--firmware/target/arm/iriver/h10/powermgmt-h10.c71
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c53
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c58
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/powermgmt-e200.c58
-rw-r--r--firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c60
-rw-r--r--firmware/target/coldfire/iaudio/powermgmt-iaudio.c58
-rw-r--r--firmware/target/coldfire/iriver/h100/powermgmt-h100.c58
-rw-r--r--firmware/target/coldfire/iriver/h300/powermgmt-h300.c58
-rw-r--r--firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c58
-rw-r--r--firmware/target/sh/archos/ondio/powermgmt-ondio.c51
-rw-r--r--firmware/target/sh/archos/player/powermgmt-player.c62
-rw-r--r--firmware/target/sh/archos/recorder/powermgmt-recorder.c60
14 files changed, 861 insertions, 0 deletions
diff --git a/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c b/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c
new file mode 100644
index 0000000000..fed67f56ef
--- /dev/null
+++ b/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c
@@ -0,0 +1,66 @@
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#include "hwcompat.h"
25
26/* FIXME: Properly calibrate values. Current values "inherited" from
27 * iriver H100 */
28
29const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
30{
31 3380
32};
33
34const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
35{
36 3020
37};
38
39/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
40const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
41{
42 { 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160 }
43};
44
45#if CONFIG_CHARGING
46/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
47const unsigned short percent_to_volt_charge[11] =
48{
49 3540, 3860, 3930, 3980, 4000, 4020, 4040, 4080, 4130, 4180, 4230
50};
51#endif /* CONFIG_CHARGING */
52
53#define BATTERY_SCALE_FACTOR_1G 4200
54#define BATTERY_SCALE_FACTOR_2G 6630
55/* full-scale ADC readout (2^8) in millivolt */
56
57/* Returns battery voltage from ADC [millivolts] */
58unsigned int battery_adc_voltage(void)
59{
60 unsigned adcval = adc_read(ADC_UNREG_POWER);
61
62 if ((IPOD_HW_REVISION >> 16) == 1)
63 return (adcval * BATTERY_SCALE_FACTOR_1G) >> 8;
64 else
65 return (adcval * BATTERY_SCALE_FACTOR_2G) >> 8;
66}
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}
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}
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
new file mode 100644
index 0000000000..9fcc150f86
--- /dev/null
+++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
@@ -0,0 +1,53 @@
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 1050, 1150
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 1050, 1150 /* FIXME: just copied from above, was missing in powermgmt.c */
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* These values are the same as for Ondio divided by 3. */
39 /* May need recalibration. */
40 { 930, 1080, 1140, 1180, 1210, 1250, 1280, 1320, 1360, 1420, 1580 }, /* alkaline */
41 { 1030, 1180, 1210, 1230, 1240, 1250, 1260, 1270, 1280, 1290, 1350 } /* NiMH */
42};
43
44/* TODO: only roughly correct */
45#define BATTERY_SCALE_FACTOR 3072
46/* full-scale ADC readout (2^10) in millivolt */
47
48/* Returns battery voltage from ADC [millivolts] */
49unsigned int battery_adc_voltage(void)
50{
51 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
52}
53
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c
new file mode 100644
index 0000000000..d38f41dd7b
--- /dev/null
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c
@@ -0,0 +1,58 @@
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 3450
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 3400
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* Toshiba Gigabeat Li Ion 830mAH figured from discharge curve */
39 { 3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990 },
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
43const unsigned short percent_to_volt_charge[11] =
44{
45 /* Toshiba Gigabeat Li Ion 830mAH */
46 3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990
47};
48
49/* ADC[0] is (530) at discharge and 625 at full charge */
50#define BATTERY_SCALE_FACTOR 6605
51/* full-scale ADC readout (2^10) in millivolt */
52
53/* Returns battery voltage from ADC [millivolts] */
54unsigned int battery_adc_voltage(void)
55{
56 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
57}
58
diff --git a/firmware/target/arm/sandisk/sansa-e200/powermgmt-e200.c b/firmware/target/arm/sandisk/sansa-e200/powermgmt-e200.c
new file mode 100644
index 0000000000..388ebaed43
--- /dev/null
+++ b/firmware/target/arm/sandisk/sansa-e200/powermgmt-e200.c
@@ -0,0 +1,58 @@
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 3400
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 3300
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* Sansa Li Ion 750mAH FIXME this is a first linear approach */
39 { 3300, 3390, 3480, 3570, 3660, 3750, 3840, 3930, 4020, 4110, 4200 },
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
43const unsigned short percent_to_volt_charge[11] =
44{
45 /* Sansa Li Ion 750mAH FIXME*/
46 3300, 3390, 3480, 3570, 3660, 3750, 3840, 3930, 4020, 4110, 4200
47};
48
49/* ADC should read 0x3ff=5.12V */
50#define BATTERY_SCALE_FACTOR 5125
51/* full-scale ADC readout (2^10) in millivolt */
52
53/* Returns battery voltage from ADC [millivolts] */
54unsigned int battery_adc_voltage(void)
55{
56 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
57}
58
diff --git a/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c b/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c
new file mode 100644
index 0000000000..a50932dd92
--- /dev/null
+++ b/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c
@@ -0,0 +1,60 @@
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
25/* FIXME: All voltages copied from H10 according to the battery type given
26 * in config-tpj1022.h at the time of splitting. This probably needs changing
27 * if that port ever gets up to speed. */
28
29const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
30{
31 3760
32};
33
34const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
35{
36 3650
37};
38
39/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
40const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
41{
42 { 3760, 3800, 3850, 3870, 3900, 3950, 4020, 4070, 4110, 4180, 4240 }
43};
44
45#if CONFIG_CHARGING
46/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
47const unsigned short percent_to_volt_charge[11] =
48{
49 3990, 4030, 4060, 4080, 4100, 4120, 4150, 4180, 4220, 4260, 4310
50};
51#endif /* CONFIG_CHARGING */
52
53#define BATTERY_SCALE_FACTOR 6000
54/* full-scale ADC readout (2^10) in millivolt */
55
56/* Returns battery voltage from ADC [millivolts] */
57unsigned int battery_adc_voltage(void)
58{
59 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
60}
diff --git a/firmware/target/coldfire/iaudio/powermgmt-iaudio.c b/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
new file mode 100644
index 0000000000..6e2b19d9b6
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
@@ -0,0 +1,58 @@
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 3540
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 3500
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* average measured values from X5 and M5L */
39 { 3500, 3650, 3720, 3740, 3760, 3790, 3840, 3900, 3950, 4040, 4120 }
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
43const unsigned short percent_to_volt_charge[11] =
44{
45 /* TODO: This is identical to the discharge curve.
46 * Calibrate charging curve using a battery_bench log. */
47 3500, 3650, 3720, 3740, 3760, 3790, 3840, 3900, 3950, 4040, 4120
48};
49
50#define BATTERY_SCALE_FACTOR 6000
51/* full-scale ADC readout (2^10) in millivolt */
52
53/* Returns battery voltage from ADC [millivolts] */
54unsigned int battery_adc_voltage(void)
55{
56 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
57}
58
diff --git a/firmware/target/coldfire/iriver/h100/powermgmt-h100.c b/firmware/target/coldfire/iriver/h100/powermgmt-h100.c
new file mode 100644
index 0000000000..5b3c297715
--- /dev/null
+++ b/firmware/target/coldfire/iriver/h100/powermgmt-h100.c
@@ -0,0 +1,58 @@
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 3380
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 3020
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* Below 3370 the backlight starts flickering during HD access */
39 { 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160 }
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
43const unsigned short percent_to_volt_charge[11] =
44{
45 /* values measured over one full charging cycle */
46 3540, 3860, 3930, 3980, 4000, 4020, 4040, 4080, 4130, 4180, 4230 /* LiPo */
47};
48
49/* FIX: this value is picked at random */
50#define BATTERY_SCALE_FACTOR 4266
51/* full-scale ADC readout (2^8) in millivolt */
52
53/* Returns battery voltage from ADC [millivolts] */
54unsigned int battery_adc_voltage(void)
55{
56 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 8;
57}
58
diff --git a/firmware/target/coldfire/iriver/h300/powermgmt-h300.c b/firmware/target/coldfire/iriver/h300/powermgmt-h300.c
new file mode 100644
index 0000000000..b2d844075e
--- /dev/null
+++ b/firmware/target/coldfire/iriver/h300/powermgmt-h300.c
@@ -0,0 +1,58 @@
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 3380
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 3020
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* Below 3370 the backlight starts flickering during HD access */
39 { 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160 }
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
43const unsigned short percent_to_volt_charge[11] =
44{
45 /* values measured over one full charging cycle */
46 3540, 3860, 3930, 3980, 4000, 4020, 4040, 4080, 4130, 4180, 4230 /* LiPo */
47};
48
49/* FIX: this value is picked at random */
50#define BATTERY_SCALE_FACTOR 6000
51/* full-scale ADC readout (2^8) in millivolt */
52
53/* Returns battery voltage from ADC [millivolts] */
54unsigned int battery_adc_voltage(void)
55{
56 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 8;
57}
58
diff --git a/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c b/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c
new file mode 100644
index 0000000000..3b0e7115ed
--- /dev/null
+++ b/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c
@@ -0,0 +1,58 @@
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 2800
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 2580
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* measured values */
39 { 2600, 2850, 2950, 3030, 3110, 3200, 3300, 3450, 3600, 3800, 4000 }
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
43const unsigned short percent_to_volt_charge[11] =
44{
45 /* TODO: This is identical to the discharge curve.
46 * Calibrate charging curve using a battery_bench log. */
47 2600, 2850, 2950, 3030, 3110, 3200, 3300, 3450, 3600, 3800, 4000
48};
49
50/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */
51#define BATTERY_SCALE_FACTOR 8275
52/* full-scale ADC readout (2^10) in millivolt */
53
54/* Returns battery voltage from ADC [millivolts] */
55unsigned int battery_adc_voltage(void)
56{
57 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
58}
diff --git a/firmware/target/sh/archos/ondio/powermgmt-ondio.c b/firmware/target/sh/archos/ondio/powermgmt-ondio.c
new file mode 100644
index 0000000000..8779857db1
--- /dev/null
+++ b/firmware/target/sh/archos/ondio/powermgmt-ondio.c
@@ -0,0 +1,51 @@
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 3100, 3450
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 2700, 2800
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* measured values */
39 { 2800, 3250, 3410, 3530, 3640, 3740, 3850, 3950, 4090, 4270, 4750 }, /* Alkaline */
40 { 3100, 3550, 3630, 3690, 3720, 3740, 3760, 3780, 3800, 3860, 4050 } /* NiMH */
41};
42
43#define BATTERY_SCALE_FACTOR 4849 /* average from 3 Ondios */
44/* full-scale ADC readout (2^10) in millivolt */
45
46/* Returns battery voltage from ADC [millivolts] */
47unsigned int battery_adc_voltage(void)
48{
49 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
50}
51
diff --git a/firmware/target/sh/archos/player/powermgmt-player.c b/firmware/target/sh/archos/player/powermgmt-player.c
new file mode 100644
index 0000000000..1a34160d44
--- /dev/null
+++ b/firmware/target/sh/archos/player/powermgmt-player.c
@@ -0,0 +1,62 @@
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 4750
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 4400
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* original values were taken directly after charging, but it should show
39 100% after turning off the device for some hours, too */
40 { 4500, 4810, 4910, 4970, 5030, 5070, 5120, 5140, 5170, 5250, 5400 }
41 /* orig. values: ...,5280,5600 */
42};
43
44/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
45const unsigned short percent_to_volt_charge[11] =
46{
47 /* values guessed, see
48 http://www.seattlerobotics.org/encoder/200210/LiIon2.pdf until someone
49 measures voltages over a charging cycle */
50 4760, 5440, 5510, 5560, 5610, 5640, 5660, 5760, 5820, 5840, 5850 /* NiMH */
51};
52
53#define BATTERY_SCALE_FACTOR 6703
54/* full-scale ADC readout (2^10) in millivolt */
55
56/* Returns battery voltage from ADC [millivolts] */
57unsigned int battery_adc_voltage(void)
58{
59 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
60}
61
62
diff --git a/firmware/target/sh/archos/recorder/powermgmt-recorder.c b/firmware/target/sh/archos/recorder/powermgmt-recorder.c
new file mode 100644
index 0000000000..c44076f589
--- /dev/null
+++ b/firmware/target/sh/archos/recorder/powermgmt-recorder.c
@@ -0,0 +1,60 @@
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 4750
28};
29
30const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
31{
32 4400
33};
34
35/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
36const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
37{
38 /* original values were taken directly after charging, but it should show
39 100% after turning off the device for some hours, too */
40 { 4500, 4810, 4910, 4970, 5030, 5070, 5120, 5140, 5170, 5250, 5400 }
41 /* orig. values: ...,5280,5600 */
42};
43
44/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
45const unsigned short percent_to_volt_charge[11] =
46{
47 /* values guessed, see
48 http://www.seattlerobotics.org/encoder/200210/LiIon2.pdf until someone
49 measures voltages over a charging cycle */
50 4760, 5440, 5510, 5560, 5610, 5640, 5660, 5760, 5820, 5840, 5850 /* NiMH */
51};
52
53#define BATTERY_SCALE_FACTOR 6620
54/* full-scale ADC readout (2^10) in millivolt */
55
56/* Returns battery voltage from ADC [millivolts] */
57unsigned int battery_adc_voltage(void)
58{
59 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
60}