summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/backlight.c20
-rw-r--r--firmware/drivers/button.c4
-rw-r--r--firmware/drivers/power.c28
-rw-r--r--firmware/export/config-fmrecorder.h4
-rw-r--r--firmware/export/config-gigabeat.h4
-rw-r--r--firmware/export/config-gmini120.h4
-rw-r--r--firmware/export/config-gminisp.h4
-rw-r--r--firmware/export/config-h100.h8
-rw-r--r--firmware/export/config-h120.h8
-rw-r--r--firmware/export/config-h300.h10
-rw-r--r--firmware/export/config-iaudiox5.h4
-rw-r--r--firmware/export/config-ifp7xx.h4
-rw-r--r--firmware/export/config-ipod3g.h4
-rw-r--r--firmware/export/config-ipod4g.h4
-rw-r--r--firmware/export/config-ipodcolor.h4
-rw-r--r--firmware/export/config-ipodmini.h4
-rwxr-xr-xfirmware/export/config-ipodmini2g.h4
-rw-r--r--firmware/export/config-ipodnano.h4
-rw-r--r--firmware/export/config-ipodvideo.h6
-rw-r--r--firmware/export/config-player.h4
-rw-r--r--firmware/export/config-recorder.h7
-rw-r--r--firmware/export/config-recorderv2.h4
-rw-r--r--firmware/export/config.h5
-rw-r--r--firmware/export/power.h6
-rw-r--r--firmware/export/powermgmt.h22
-rw-r--r--firmware/powermgmt.c68
26 files changed, 112 insertions, 136 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index aac438c673..76ffc6f0e4 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -156,14 +156,14 @@ static struct event_queue backlight_queue;
156 156
157static int backlight_timer; 157static int backlight_timer;
158static int backlight_timeout = 5*HZ; 158static int backlight_timeout = 5*HZ;
159#ifdef HAVE_CHARGING 159#ifdef CONFIG_CHARGING
160static int backlight_timeout_plugged = 5*HZ; 160static int backlight_timeout_plugged = 5*HZ;
161#endif 161#endif
162 162
163#ifdef HAVE_REMOTE_LCD 163#ifdef HAVE_REMOTE_LCD
164static int remote_backlight_timer; 164static int remote_backlight_timer;
165static int remote_backlight_timeout = 5*HZ; 165static int remote_backlight_timeout = 5*HZ;
166#ifdef HAVE_CHARGING 166#ifdef CONFIG_CHARGING
167static int remote_backlight_timeout_plugged = 5*HZ; 167static int remote_backlight_timeout_plugged = 5*HZ;
168#endif 168#endif
169#endif 169#endif
@@ -370,7 +370,7 @@ void backlight_thread(void)
370 { 370 {
371#ifdef HAVE_REMOTE_LCD 371#ifdef HAVE_REMOTE_LCD
372 case REMOTE_BACKLIGHT_ON: 372 case REMOTE_BACKLIGHT_ON:
373#ifdef HAVE_CHARGING 373#ifdef CONFIG_CHARGING
374 if (charger_inserted() 374 if (charger_inserted()
375#ifdef HAVE_USB_POWER 375#ifdef HAVE_USB_POWER
376 || usb_powered() 376 || usb_powered()
@@ -399,7 +399,7 @@ void backlight_thread(void)
399 399
400#endif /* HAVE_REMOTE_LCD */ 400#endif /* HAVE_REMOTE_LCD */
401 case BACKLIGHT_ON: 401 case BACKLIGHT_ON:
402#ifdef HAVE_CHARGING 402#ifdef CONFIG_CHARGING
403 if (charger_inserted() 403 if (charger_inserted()
404#ifdef HAVE_USB_POWER 404#ifdef HAVE_USB_POWER
405 || usb_powered() 405 || usb_powered()
@@ -447,7 +447,7 @@ void backlight_thread(void)
447 447
448static void backlight_tick(void) 448static void backlight_tick(void)
449{ 449{
450#ifdef HAVE_CHARGING 450#ifdef CONFIG_CHARGING
451 static bool charger_was_inserted = false; 451 static bool charger_was_inserted = false;
452 bool charger_is_inserted = charger_inserted() 452 bool charger_is_inserted = charger_inserted()
453#ifdef HAVE_USB_POWER 453#ifdef HAVE_USB_POWER
@@ -463,7 +463,7 @@ static void backlight_tick(void)
463#endif 463#endif
464 } 464 }
465 charger_was_inserted = charger_is_inserted; 465 charger_was_inserted = charger_is_inserted;
466#endif /* HAVE_CHARGING */ 466#endif /* CONFIG_CHARGING */
467 467
468 if(backlight_timer) 468 if(backlight_timer)
469 { 469 {
@@ -535,7 +535,7 @@ bool is_backlight_on(void)
535/* return value in ticks; 0 means always on, <0 means always off */ 535/* return value in ticks; 0 means always on, <0 means always off */
536int backlight_get_current_timeout(void) 536int backlight_get_current_timeout(void)
537{ 537{
538#ifdef HAVE_CHARGING 538#ifdef CONFIG_CHARGING
539 if (charger_inserted() 539 if (charger_inserted()
540#ifdef HAVE_USB_POWER 540#ifdef HAVE_USB_POWER
541 || usb_powered() 541 || usb_powered()
@@ -558,7 +558,7 @@ void backlight_set_timeout(int index)
558 backlight_on(); 558 backlight_on();
559} 559}
560 560
561#ifdef HAVE_CHARGING 561#ifdef CONFIG_CHARGING
562void backlight_set_timeout_plugged(int index) 562void backlight_set_timeout_plugged(int index)
563{ 563{
564 if((unsigned)index >= sizeof(backlight_timeout_value)) 564 if((unsigned)index >= sizeof(backlight_timeout_value))
@@ -589,7 +589,7 @@ void remote_backlight_set_timeout(int index)
589 remote_backlight_on(); 589 remote_backlight_on();
590} 590}
591 591
592#ifdef HAVE_CHARGING 592#ifdef CONFIG_CHARGING
593void remote_backlight_set_timeout_plugged(int index) 593void remote_backlight_set_timeout_plugged(int index)
594{ 594{
595 if((unsigned)index >= sizeof(backlight_timeout_value)) 595 if((unsigned)index >= sizeof(backlight_timeout_value))
@@ -603,7 +603,7 @@ void remote_backlight_set_timeout_plugged(int index)
603/* return value in ticks; 0 means always on, <0 means always off */ 603/* return value in ticks; 0 means always on, <0 means always off */
604int remote_backlight_get_current_timeout(void) 604int remote_backlight_get_current_timeout(void)
605{ 605{
606#ifdef HAVE_CHARGING 606#ifdef CONFIG_CHARGING
607 if (charger_inserted() 607 if (charger_inserted()
608#ifdef HAVE_USB_POWER 608#ifdef HAVE_USB_POWER
609 || usb_powered() 609 || usb_powered()
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 6513fb4a3a..216c51ea15 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -490,7 +490,7 @@ static void button_tick(void)
490 || btn == BUTTON_RC_STOP 490 || btn == BUTTON_RC_STOP
491#endif 491#endif
492 ) && 492 ) &&
493#if defined(HAVE_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING) 493#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
494 !charger_inserted() && 494 !charger_inserted() &&
495#endif 495#endif
496 repeat_count > POWEROFF_COUNT) 496 repeat_count > POWEROFF_COUNT)
@@ -1248,7 +1248,7 @@ static int button_read(void)
1248 backlight_on(); 1248 backlight_on();
1249 } 1249 }
1250 /* TODO: add light handling for the remote */ 1250 /* TODO: add light handling for the remote */
1251 1251
1252 hold_button = button_hold(); 1252 hold_button = button_hold();
1253 remote_hold_button = remote_button_hold(); 1253 remote_hold_button = remote_button_hold();
1254 1254
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index c4b9fb5b7d..bda03b0f8b 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -29,7 +29,7 @@
29#include "pcf50606.h" 29#include "pcf50606.h"
30#include "usb.h" 30#include "usb.h"
31 31
32#ifdef HAVE_CHARGE_CTRL 32#if CONFIG_CHARGING == CHARGING_CONTROL
33bool charger_enabled; 33bool charger_enabled;
34#endif 34#endif
35 35
@@ -92,7 +92,7 @@ void power_init(void)
92 or_b(0x20, &PBIORL); 92 or_b(0x20, &PBIORL);
93 or_b(0x20, &PBDRL); /* hold power */ 93 or_b(0x20, &PBDRL); /* hold power */
94#endif 94#endif
95#ifdef HAVE_CHARGE_CTRL 95#if CONFIG_CHARGING == CHARGING_CONTROL
96 PBCR2 &= ~0x0c00; /* GPIO for PB5 */ 96 PBCR2 &= ~0x0c00; /* GPIO for PB5 */
97 or_b(0x20, &PBIORL); /* Set charging control bit to output */ 97 or_b(0x20, &PBIORL); /* Set charging control bit to output */
98 charger_enable(false); /* Default to charger OFF */ 98 charger_enable(false); /* Default to charger OFF */
@@ -106,7 +106,7 @@ void power_init(void)
106} 106}
107 107
108 108
109#ifdef HAVE_CHARGING 109#ifdef CONFIG_CHARGING
110bool charger_inserted(void) 110bool charger_inserted(void)
111{ 111{
112#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) 112#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
@@ -115,7 +115,7 @@ bool charger_inserted(void)
115 return (P7 & 0x80) == 0; 115 return (P7 & 0x80) == 0;
116#elif defined(IAUDIO_X5) 116#elif defined(IAUDIO_X5)
117 return (GPIO1_READ & 0x01000000)?true:false; 117 return (GPIO1_READ & 0x01000000)?true:false;
118#elif defined(HAVE_CHARGE_CTRL) 118#elif CONFIG_CHARGING == CHARGING_CONTROL
119 /* Recorder */ 119 /* Recorder */
120 return adc_read(ADC_EXT_POWER) > 0x100; 120 return adc_read(ADC_EXT_POWER) > 0x100;
121#elif defined (HAVE_FMADC) 121#elif defined (HAVE_FMADC)
@@ -133,9 +133,9 @@ bool charger_inserted(void)
133 return (PADR & 1) == 0; 133 return (PADR & 1) == 0;
134#endif 134#endif
135} 135}
136#endif /* HAVE_CHARGING */ 136#endif /* CONFIG_CHARGING */
137 137
138#ifdef HAVE_CHARGE_CTRL 138#if CONFIG_CHARGING == CHARGING_CONTROL
139void charger_enable(bool on) 139void charger_enable(bool on)
140{ 140{
141 if(on) 141 if(on)
@@ -151,14 +151,22 @@ void charger_enable(bool on)
151} 151}
152#endif 152#endif
153 153
154#ifdef HAVE_CHARGE_STATE 154#if CONFIG_CHARGING == CHARGING_MONITOR
155/* Returns true if the unit is charging the batteries. */ 155/* Returns true if the unit is charging the batteries. */
156bool charging_state(void) { 156bool charging_state(void) {
157#if defined(IRIVER_H100_SERIES) 157#if CONFIG_BATTERY == BATT_LIION2200
158 /* We use the information from the ADC_EXT_POWER ADC channel, which
159 tells us the charging current from the LTC1734. When DC is
160 connected (either via the external adapter, or via USB), we try
161 to determine if it is actively charging or only maintaining the
162 charge. My tests show that ADC readings below about 0x80 means
163 that the LTC1734 is only maintaining the charge. */
164 return adc_read(ADC_EXT_POWER) >= 0x80;
165#elif defined(IRIVER_H100_SERIES) /* FIXME */
158 return charger_inserted(); 166 return charger_inserted();
159#elif defined(IRIVER_H300_SERIES) 167#elif defined IRIVER_H300_SERIES
160 return (GPIO_READ & 0x00800000)?true:false; 168 return (GPIO_READ & 0x00800000)?true:false;
161#elif defined(IPOD_VIDEO) 169#elif defined IPOD_VIDEO
162 return (GPIOB_INPUT_VAL & 0x01)?false:true; 170 return (GPIOB_INPUT_VAL & 0x01)?false:true;
163#endif 171#endif
164} 172}
diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h
index 8711640e93..7a78d48822 100644
--- a/firmware/export/config-fmrecorder.h
+++ b/firmware/export/config-fmrecorder.h
@@ -90,8 +90,8 @@
90/* How to detect USB */ 90/* How to detect USB */
91#define USB_FMRECORDERSTYLE 1 91#define USB_FMRECORDERSTYLE 1
92 92
93/* Define this if the platform can charge batteries */ 93/* Hardware controlled charging with monitoring */
94#define HAVE_CHARGING 1 94#define CONFIG_CHARGING CHARGING_MONITOR
95 95
96/* The start address index for ROM builds */ 96/* The start address index for ROM builds */
97/* #define ROM_START 0x14010 for behind original Archos */ 97/* #define ROM_START 0x14010 for behind original Archos */
diff --git a/firmware/export/config-gigabeat.h b/firmware/export/config-gigabeat.h
index 83a92ce140..1ebbdbf908 100644
--- a/firmware/export/config-gigabeat.h
+++ b/firmware/export/config-gigabeat.h
@@ -61,8 +61,8 @@
61 61
62#define BATTERY_SCALE_FACTOR 23437 /* FIX: this value is picked at random */ 62#define BATTERY_SCALE_FACTOR 23437 /* FIX: this value is picked at random */
63 63
64/* Define this if the platform can charge batteries */ 64/* Hardware controlled charging? FIXME */
65#define HAVE_CHARGING 1 65#define CONFIG_CHARGING CHARGING_SIMPLE
66 66
67/* define this if the hardware can be powered off while charging */ 67/* define this if the hardware can be powered off while charging */
68#define HAVE_POWEROFF_WHILE_CHARGING 68#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-gmini120.h b/firmware/export/config-gmini120.h
index 42424bb7b1..66ba7af09e 100644
--- a/firmware/export/config-gmini120.h
+++ b/firmware/export/config-gmini120.h
@@ -54,8 +54,8 @@
54#define BATTERY_SCALE_FACTOR 6465 54#define BATTERY_SCALE_FACTOR 6465
55/* chosen values at random -- jyp */ 55/* chosen values at random -- jyp */
56 56
57/* Define this if the platform can charge batteries */ 57/* Hardware controlled charging? FIXME */
58#define HAVE_CHARGING 1 58#define CONFIG_CHARGING CHARGING_SIMPLE
59 59
60#define CPU_FREQ 30000000 60#define CPU_FREQ 30000000
61/* approximate value (and false in general since freq is variable) */ 61/* approximate value (and false in general since freq is variable) */
diff --git a/firmware/export/config-gminisp.h b/firmware/export/config-gminisp.h
index e066661061..8df7b0f5a1 100644
--- a/firmware/export/config-gminisp.h
+++ b/firmware/export/config-gminisp.h
@@ -45,8 +45,8 @@
45#define BATTERY_SCALE_FACTOR 6465 45#define BATTERY_SCALE_FACTOR 6465
46/* chosen values at random -- jyp */ 46/* chosen values at random -- jyp */
47 47
48/* Define this if the platform can charge batteries */ 48/* Hardware controlled charging? FIXME */
49#define HAVE_CHARGING 1 49#define CONFIG_CHARGING CHARGING_SIMPLE
50 50
51#define CPU_FREQ 30000000 51#define CPU_FREQ 30000000
52/* approximate value (and false in general since freq is variable) */ 52/* approximate value (and false in general since freq is variable) */
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h
index d53adcec14..4461cc2d44 100644
--- a/firmware/export/config-h100.h
+++ b/firmware/export/config-h100.h
@@ -89,11 +89,9 @@
89#define BATTERY_TYPES_COUNT 1 /* only one type */ 89#define BATTERY_TYPES_COUNT 1 /* only one type */
90#define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */ 90#define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */
91 91
92/* Define this if the platform can charge batteries */ 92/* Hardware controlled charging */
93#define HAVE_CHARGING 1 93//#define CONFIG_CHARGING CHARGING_SIMPLE
94 94#define CONFIG_CHARGING CHARGING_MONITOR /* FIXME: remove that once monitoring is fixed properly */
95/* For units with a hardware charger that reports charge state */
96#define HAVE_CHARGE_STATE 1
97 95
98/* define this if the hardware can be powered off while charging */ 96/* define this if the hardware can be powered off while charging */
99#define HAVE_POWEROFF_WHILE_CHARGING 97#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h
index 34f5059b69..f2cd8c2665 100644
--- a/firmware/export/config-h120.h
+++ b/firmware/export/config-h120.h
@@ -84,11 +84,9 @@
84/* Define if we have a hardware defect that causes ticking on the audio line */ 84/* Define if we have a hardware defect that causes ticking on the audio line */
85#define HAVE_REMOTE_LCD_TICKING 85#define HAVE_REMOTE_LCD_TICKING
86 86
87/* Define this if the platform can charge batteries */ 87/* Hardware controlled charging */
88#define HAVE_CHARGING 1 88//#define CONFIG_CHARGING CHARGING_SIMPLE
89 89#define CONFIG_CHARGING CHARGING_MONITOR /* FIXME: remove that once monitoring is fixed properly */
90/* For units with a hardware charger that reports charge state */
91#define HAVE_CHARGE_STATE 1
92 90
93/* define this if the hardware can be powered off while charging */ 91/* define this if the hardware can be powered off while charging */
94#define HAVE_POWEROFF_WHILE_CHARGING 92#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h
index ae1940c987..7ed54958ca 100644
--- a/firmware/export/config-h300.h
+++ b/firmware/export/config-h300.h
@@ -85,14 +85,8 @@
85/* Define if we have a hardware defect that causes ticking on the audio line */ 85/* Define if we have a hardware defect that causes ticking on the audio line */
86#define HAVE_REMOTE_LCD_TICKING 86#define HAVE_REMOTE_LCD_TICKING
87 87
88/* Define this if the platform can charge batteries */ 88/* Hardware controlled charging with monitoring */
89#define HAVE_CHARGING 1 89#define CONFIG_CHARGING CHARGING_MONITOR
90
91/* For units with a hardware charger that reports charge state */
92#define HAVE_CHARGE_STATE 1
93
94/* define this if the hardware can be powered off while charging */
95#define HAVE_POWEROFF_WHILE_CHARGING
96 90
97/* The size of the flash ROM */ 91/* The size of the flash ROM */
98#define FLASH_SIZE 0x400000 92#define FLASH_SIZE 0x400000
diff --git a/firmware/export/config-iaudiox5.h b/firmware/export/config-iaudiox5.h
index 4690feb8fe..b16a142a28 100644
--- a/firmware/export/config-iaudiox5.h
+++ b/firmware/export/config-iaudiox5.h
@@ -65,8 +65,8 @@
65 65
66#define HAVE_TLV320 66#define HAVE_TLV320
67 67
68/* Define this if the platform can charge batteries */ 68/* Hardware controlled charging? FIXME */
69#define HAVE_CHARGING 1 69#define CONFIG_CHARGING CHARGING_SIMPLE
70 70
71/* define this if the hardware can be powered off while charging */ 71/* define this if the hardware can be powered off while charging */
72#define HAVE_POWEROFF_WHILE_CHARGING 72#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-ifp7xx.h b/firmware/export/config-ifp7xx.h
index 9e5a432260..6247625618 100644
--- a/firmware/export/config-ifp7xx.h
+++ b/firmware/export/config-ifp7xx.h
@@ -56,8 +56,8 @@
56 56
57#define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */ 57#define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */
58 58
59/* Define this if the platform can charge batteries */ 59/* Hardware controlled charging? FIXME */
60//#define HAVE_CHARGING 1 60//#define CONFIG_CHARGING CHARGING_SIMPLE
61 61
62/* define this if the hardware can be powered off while charging */ 62/* define this if the hardware can be powered off while charging */
63//#define HAVE_POWEROFF_WHILE_CHARGING 63//#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-ipod3g.h b/firmware/export/config-ipod3g.h
index a611dfdcaa..b3b5d14e85 100644
--- a/firmware/export/config-ipod3g.h
+++ b/firmware/export/config-ipod3g.h
@@ -68,8 +68,8 @@
68#define BATTERY_TYPES_COUNT 1 /* only one type */ 68#define BATTERY_TYPES_COUNT 1 /* only one type */
69#define BATTERY_SCALE_FACTOR 5865 69#define BATTERY_SCALE_FACTOR 5865
70 70
71/* Define this if the platform can charge batteries */ 71/* Hardware controlled charging? FIXME */
72//#define HAVE_CHARGING 1 72//#define CONFIG_CHARGING CHARGING_SIMPLE
73 73
74/* define this if the hardware can be powered off while charging */ 74/* define this if the hardware can be powered off while charging */
75//#define HAVE_POWEROFF_WHILE_CHARGING 75//#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-ipod4g.h b/firmware/export/config-ipod4g.h
index fa664acdb6..46abbdf72b 100644
--- a/firmware/export/config-ipod4g.h
+++ b/firmware/export/config-ipod4g.h
@@ -70,8 +70,8 @@
70#define BATTERY_TYPES_COUNT 1 /* only one type */ 70#define BATTERY_TYPES_COUNT 1 /* only one type */
71#define BATTERY_SCALE_FACTOR 5865 71#define BATTERY_SCALE_FACTOR 5865
72 72
73/* Define this if the platform can charge batteries */ 73/* Hardware controlled charging? FIXME */
74//#define HAVE_CHARGING 1 74//#define CONFIG_CHARGING CHARGING_SIMPLE
75 75
76/* define this if the hardware can be powered off while charging */ 76/* define this if the hardware can be powered off while charging */
77//#define HAVE_POWEROFF_WHILE_CHARGING 77//#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-ipodcolor.h b/firmware/export/config-ipodcolor.h
index b8f3d89346..e063e93737 100644
--- a/firmware/export/config-ipodcolor.h
+++ b/firmware/export/config-ipodcolor.h
@@ -69,8 +69,8 @@
69#define BATTERY_TYPES_COUNT 1 /* only one type */ 69#define BATTERY_TYPES_COUNT 1 /* only one type */
70#define BATTERY_SCALE_FACTOR 5865 70#define BATTERY_SCALE_FACTOR 5865
71 71
72/* Define this if the platform can charge batteries */ 72/* Hardware controlled charging? FIXME */
73//#define HAVE_CHARGING 1 73//#define CONFIG_CHARGING CHARGING_SIMPLE
74 74
75/* define this if the hardware can be powered off while charging */ 75/* define this if the hardware can be powered off while charging */
76//#define HAVE_POWEROFF_WHILE_CHARGING 76//#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-ipodmini.h b/firmware/export/config-ipodmini.h
index 64be801577..4871ea0acc 100644
--- a/firmware/export/config-ipodmini.h
+++ b/firmware/export/config-ipodmini.h
@@ -70,8 +70,8 @@
70#define BATTERY_TYPES_COUNT 1 /* only one type */ 70#define BATTERY_TYPES_COUNT 1 /* only one type */
71#define BATTERY_SCALE_FACTOR 5865 71#define BATTERY_SCALE_FACTOR 5865
72 72
73/* Define this if the platform can charge batteries */ 73/* Hardware controlled charging? FIXME */
74//#define HAVE_CHARGING 1 74//#define CONFIG_CHARGING CHARGING_SIMPLE
75 75
76/* define this if the hardware can be powered off while charging */ 76/* define this if the hardware can be powered off while charging */
77//#define HAVE_POWEROFF_WHILE_CHARGING 77//#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-ipodmini2g.h b/firmware/export/config-ipodmini2g.h
index 454309a786..adbb0973ac 100755
--- a/firmware/export/config-ipodmini2g.h
+++ b/firmware/export/config-ipodmini2g.h
@@ -73,8 +73,8 @@
73#define BATTERY_TYPES_COUNT 1 /* only one type */ 73#define BATTERY_TYPES_COUNT 1 /* only one type */
74#define BATTERY_SCALE_FACTOR 5865 74#define BATTERY_SCALE_FACTOR 5865
75 75
76/* Define this if the platform can charge batteries */ 76/* Hardware controlled charging? FIXME */
77//#define HAVE_CHARGING 1 77//#define CONFIG_CHARGING CHARGING_SIMPLE
78 78
79/* define this if the hardware can be powered off while charging */ 79/* define this if the hardware can be powered off while charging */
80//#define HAVE_POWEROFF_WHILE_CHARGING 80//#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h
index b7116bf249..3d4deb3abd 100644
--- a/firmware/export/config-ipodnano.h
+++ b/firmware/export/config-ipodnano.h
@@ -74,8 +74,8 @@
74#define BATTERY_TYPES_COUNT 1 /* only one type */ 74#define BATTERY_TYPES_COUNT 1 /* only one type */
75#define BATTERY_SCALE_FACTOR 5865 75#define BATTERY_SCALE_FACTOR 5865
76 76
77/* Define this if the platform can charge batteries */ 77/* Hardware controlled charging? FIXME */
78//#define HAVE_CHARGING 1 78//#define CONFIG_CHARGING CHARGING_SIMPLE
79 79
80/* define this if the hardware can be powered off while charging */ 80/* define this if the hardware can be powered off while charging */
81//#define HAVE_POWEROFF_WHILE_CHARGING 81//#define HAVE_POWEROFF_WHILE_CHARGING
diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h
index 1bbcfec157..79ef1a85ac 100644
--- a/firmware/export/config-ipodvideo.h
+++ b/firmware/export/config-ipodvideo.h
@@ -74,14 +74,12 @@
74#define BATTERY_TYPES_COUNT 1 /* only one type */ 74#define BATTERY_TYPES_COUNT 1 /* only one type */
75#define BATTERY_SCALE_FACTOR 5865 75#define BATTERY_SCALE_FACTOR 5865
76 76
77/* Define this if the platform can charge batteries */ 77/* Hardware controlled charging with monitoring */
78#define HAVE_CHARGING 1 78#define CONFIG_CHARGING CHARGING_MONITOR
79 79
80/* define this if the hardware can be powered off while charging */ 80/* define this if the hardware can be powered off while charging */
81//#define HAVE_POWEROFF_WHILE_CHARGING 81//#define HAVE_POWEROFF_WHILE_CHARGING
82 82
83#define HAVE_CHARGE_STATE 1
84
85/* The start address index for ROM builds */ 83/* The start address index for ROM builds */
86#define ROM_START 0x00000000 84#define ROM_START 0x00000000
87 85
diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h
index 324a0a2300..3dfdb0e727 100644
--- a/firmware/export/config-player.h
+++ b/firmware/export/config-player.h
@@ -67,8 +67,8 @@
67/* How to detect USB */ 67/* How to detect USB */
68#define USB_PLAYERSTYLE 1 68#define USB_PLAYERSTYLE 1
69 69
70/* Define this if the platform can charge batteries */ 70/* Hardware controlled charging */
71#define HAVE_CHARGING 1 71#define CONFIG_CHARGING CHARGING_SIMPLE
72 72
73/* The start address index for ROM builds */ 73/* The start address index for ROM builds */
74/* #define ROM_START 0xD010 for behind original Archos */ 74/* #define ROM_START 0xD010 for behind original Archos */
diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h
index 92dd07695d..854b1c1ade 100644
--- a/firmware/export/config-recorder.h
+++ b/firmware/export/config-recorder.h
@@ -45,9 +45,6 @@
45/* Define this if you have a SH7034 */ 45/* Define this if you have a SH7034 */
46#define CONFIG_CPU SH7034 46#define CONFIG_CPU SH7034
47 47
48/* Define this if you have charging control */
49#define HAVE_CHARGE_CTRL
50
51/* Define this if you have ATA power-off control */ 48/* Define this if you have ATA power-off control */
52#define HAVE_ATA_POWER_OFF 49#define HAVE_ATA_POWER_OFF
53 50
@@ -80,8 +77,8 @@
80/* How to detect USB */ 77/* How to detect USB */
81#define USB_RECORDERSTYLE 1 78#define USB_RECORDERSTYLE 1
82 79
83/* Define this if the platform can charge batteries */ 80/* Software controlled charging */
84#define HAVE_CHARGING 1 81#define CONFIG_CHARGING CHARGING_CONTROL
85 82
86/* The start address index for ROM builds */ 83/* The start address index for ROM builds */
87/* #define ROM_START 0x11010 for behind original Archos */ 84/* #define ROM_START 0x11010 for behind original Archos */
diff --git a/firmware/export/config-recorderv2.h b/firmware/export/config-recorderv2.h
index b508836080..09823cffb2 100644
--- a/firmware/export/config-recorderv2.h
+++ b/firmware/export/config-recorderv2.h
@@ -90,8 +90,8 @@
90/* How to detect USB */ 90/* How to detect USB */
91#define USB_FMRECORDERSTYLE 1 91#define USB_FMRECORDERSTYLE 1
92 92
93/* Define this if the platform can charge batteries */ 93/* Hardware controlled charging with monitoring */
94#define HAVE_CHARGING 1 94#define CONFIG_CHARGING CHARGING_MONITOR
95 95
96/* The start address index for ROM builds */ 96/* The start address index for ROM builds */
97/* #define ROM_START 0x12010 for behind original Archos */ 97/* #define ROM_START 0x12010 for behind original Archos */
diff --git a/firmware/export/config.h b/firmware/export/config.h
index d919b8b4f6..910aeca4eb 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -68,6 +68,11 @@
68#define BATT_3AAA 1000 /* Ondio */ 68#define BATT_3AAA 1000 /* Ondio */
69#define BATT_LIPOL1300 1300 /* the type used in iRiver h1x0 models */ 69#define BATT_LIPOL1300 1300 /* the type used in iRiver h1x0 models */
70 70
71/* CONFIG_CHARGING */
72#define CHARGING_SIMPLE 1 /* Simple, hardware controlled charging */
73#define CHARGING_MONITOR 2 /* Hardware controlled charging with monitoring */
74#define CHARGING_CONTROL 3 /* Software controlled charging */
75
71/* CONFIG_LCD */ 76/* CONFIG_LCD */
72#define LCD_GMINI100 0 77#define LCD_GMINI100 0
73#define LCD_SSD1815 1 /* as used by Archos Recorders and Ondios */ 78#define LCD_SSD1815 1 /* as used by Archos Recorders and Ondios */
diff --git a/firmware/export/power.h b/firmware/export/power.h
index be8ebda5b0..dc6c09d9f9 100644
--- a/firmware/export/power.h
+++ b/firmware/export/power.h
@@ -19,12 +19,12 @@
19#ifndef _POWER_H_ 19#ifndef _POWER_H_
20#define _POWER_H_ 20#define _POWER_H_
21 21
22#ifdef HAVE_CHARGE_CTRL 22#if CONFIG_CHARGING == CHARGING_CONTROL
23extern bool charger_enabled; 23extern bool charger_enabled;
24void charger_enable(bool on); 24void charger_enable(bool on);
25#endif 25#endif
26 26
27#ifdef HAVE_CHARGING 27#ifdef CONFIG_CHARGING
28bool charger_inserted(void); 28bool charger_inserted(void);
29#endif 29#endif
30 30
@@ -35,7 +35,7 @@ void ide_power_enable(bool on);
35 35
36void power_init(void); 36void power_init(void);
37 37
38# ifdef HAVE_CHARGE_STATE 38# if CONFIG_CHARGING == CHARGING_MONITOR
39bool charging_state(void); 39bool charging_state(void);
40# endif 40# endif
41 41
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index 6c31aeec52..30fe60c293 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -28,7 +28,7 @@
28 28
29#ifndef SIMULATOR 29#ifndef SIMULATOR
30 30
31#ifdef HAVE_CHARGE_CTRL 31#if CONFIG_CHARGING == CHARGING_CONTROL
32#define START_TOPOFF_CHG 85 /* Battery % to start at top-off */ 32#define START_TOPOFF_CHG 85 /* Battery % to start at top-off */
33#define START_TRICKLE_CHG 95 /* Battery % to start at trickle */ 33#define START_TRICKLE_CHG 95 /* Battery % to start at trickle */
34 34
@@ -59,23 +59,21 @@ extern int pid_p; /* PID proportional term */
59extern int pid_i; /* PID integral term */ 59extern int pid_i; /* PID integral term */
60extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */ 60extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */
61 61
62#endif /* HAVE_CHARGE_CTRL */ 62#endif /* CONFIG_CHARGING == CHARGING_CONTROL */
63 63
64#if defined(HAVE_CHARGE_CTRL) || \ 64#if CONFIG_CHARGING >= CHARGING_MONITOR
65 (CONFIG_BATTERY == BATT_LIION2200) || \ 65typedef enum { /* sorted by increasing charging current */
66 defined(HAVE_CHARGE_STATE) 66 DISCHARGING = 0,
67typedef enum { 67 TRICKLE, /* Can occur for CONFIG_CHARGING >= CHARGING_MONITOR */
68 DISCHARGING, 68 TOPOFF, /* Can occur for CONFIG_CHARGING == CHARGING_CONTROL */
69 CHARGING, 69 CHARGING /* Can occur for all CONFIG_CHARGING options */
70 TOPOFF,
71 TRICKLE
72} charge_state_type; 70} charge_state_type;
73 71
74/* tells what the charger is doing */ 72/* tells what the charger is doing */
75extern charge_state_type charge_state; 73extern charge_state_type charge_state;
76#endif /* defined(HAVE_CHARGE_CTRL) || (CONFIG_BATTERY == BATT_LIION2200) */ 74#endif /* CONFIG_CHARGING >= CHARGING_MONITOR */
77 75
78#ifdef HAVE_CHARGING 76#ifdef CONFIG_CHARGING
79/* 77/*
80 * Flag that the charger has been plugged in/removed: this is set for exactly 78 * Flag that the charger has been plugged in/removed: this is set for exactly
81 * one time through the power loop when the charger has been plugged in. 79 * one time through the power loop when the charger has been plugged in.
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 15977caed6..ee01fd862d 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -64,7 +64,7 @@
64 * in it (one sample per minute). This is only for very low level debug. 64 * in it (one sample per minute). This is only for very low level debug.
65 */ 65 */
66#undef DEBUG_FILE 66#undef DEBUG_FILE
67#if defined(DEBUG_FILE) && defined(HAVE_CHARGE_CTRL) 67#if defined(DEBUG_FILE) && (CONFIG_CHARGING == CHARGING_CONTROL)
68#include "file.h" 68#include "file.h"
69#define DEBUG_FILE_NAME "/powermgmt.csv" 69#define DEBUG_FILE_NAME "/powermgmt.csv"
70#define DEBUG_MESSAGE_LEN 133 70#define DEBUG_MESSAGE_LEN 133
@@ -190,7 +190,7 @@ static const short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
190#endif 190#endif
191}; 191};
192 192
193#ifdef HAVE_CHARGING 193#ifdef CONFIG_CHARGING
194charger_input_state_type charger_input_state IDATA_ATTR; 194charger_input_state_type charger_input_state IDATA_ATTR;
195 195
196/* voltages (centivolt) of 0%, 10%, ... 100% when charging enabled */ 196/* voltages (centivolt) of 0%, 10%, ... 100% when charging enabled */
@@ -207,15 +207,13 @@ static const short percent_to_volt_charge[11] =
207 476, 544, 551, 556, 561, 564, 566, 576, 582, 584, 585 /* NiMH */ 207 476, 544, 551, 556, 561, 564, 566, 576, 582, 584, 585 /* NiMH */
208#endif 208#endif
209}; 209};
210#endif /* HAVE_CHARGING */ 210#endif /* CONFIG_CHARGING */
211 211
212#if defined(HAVE_CHARGE_CTRL) || \ 212#if CONFIG_CHARGING >= CHARGING_MONITOR
213 CONFIG_BATTERY == BATT_LIION2200 || \
214 defined(HAVE_CHARGE_STATE)
215charge_state_type charge_state; /* charging mode */ 213charge_state_type charge_state; /* charging mode */
216#endif 214#endif
217 215
218#ifdef HAVE_CHARGE_CTRL 216#if CONFIG_CHARGING == CHARGING_CONTROL
219int long_delta; /* long term delta battery voltage */ 217int long_delta; /* long term delta battery voltage */
220int short_delta; /* short term delta battery voltage */ 218int short_delta; /* short term delta battery voltage */
221bool disk_activity_last_cycle = false; /* flag set to aid charger time 219bool disk_activity_last_cycle = false; /* flag set to aid charger time
@@ -235,7 +233,7 @@ int trickle_sec = 0; /* how many seconds should the
235 charging? */ 233 charging? */
236int pid_p = 0; /* PID proportional term */ 234int pid_p = 0; /* PID proportional term */
237int pid_i = 0; /* PID integral term */ 235int pid_i = 0; /* PID integral term */
238#endif /* HAVE_CHARGE_CTRL */ 236#endif /* CONFIG_CHARGING == CHARGING_CONTROL */
239 237
240/* 238/*
241 * Average battery voltage and charger voltage, filtered via a digital 239 * Average battery voltage and charger voltage, filtered via a digital
@@ -366,7 +364,7 @@ static void battery_status_update(void)
366{ 364{
367 int level; 365 int level;
368 366
369#if defined(HAVE_CHARGE_CTRL) || defined(HAVE_CHARGE_STATE) 367#if CONFIG_CHARGING >= CHARGING_MONITOR
370 if (charge_state == DISCHARGING) { 368 if (charge_state == DISCHARGING) {
371 level = voltage_to_percent(battery_centivolts, 369 level = voltage_to_percent(battery_centivolts,
372 percent_to_volt_discharge[battery_type]); 370 percent_to_volt_discharge[battery_type]);
@@ -397,7 +395,7 @@ static void battery_status_update(void)
397 /* calculate estimated remaining running time */ 395 /* calculate estimated remaining running time */
398 /* discharging: remaining running time */ 396 /* discharging: remaining running time */
399 /* charging: remaining charging time */ 397 /* charging: remaining charging time */
400#if defined(HAVE_CHARGE_CTRL) || defined(HAVE_CHARGE_STATE) 398#if CONFIG_CHARGING >= CHARGING_MONITOR
401 if (charge_state == CHARGING) { 399 if (charge_state == CHARGING) {
402 powermgmt_est_runningtime_min = (100 - level) * battery_capacity / 100 400 powermgmt_est_runningtime_min = (100 - level) * battery_capacity / 100
403 * 60 / (CURRENT_MAX_CHG - runcurrent()); 401 * 60 / (CURRENT_MAX_CHG - runcurrent());
@@ -425,7 +423,7 @@ static void handle_auto_poweroff(void)
425 long timeout = poweroff_idle_timeout_value[poweroff_timeout]*60*HZ; 423 long timeout = poweroff_idle_timeout_value[poweroff_timeout]*60*HZ;
426 int audio_stat = audio_status(); 424 int audio_stat = audio_status();
427 425
428#ifdef HAVE_CHARGING 426#ifdef CONFIG_CHARGING
429 /* 427 /*
430 * Inhibit shutdown as long as the charger is plugged in. If it is 428 * Inhibit shutdown as long as the charger is plugged in. If it is
431 * unplugged, wait for a timeout period and then shut down. 429 * unplugged, wait for a timeout period and then shut down.
@@ -458,7 +456,7 @@ static void handle_auto_poweroff(void)
458 if(TIME_AFTER(current_tick, sleeptimer_endtick)) 456 if(TIME_AFTER(current_tick, sleeptimer_endtick))
459 { 457 {
460 audio_stop(); 458 audio_stop();
461#if defined(HAVE_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING) 459#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
462 if((charger_input_state == CHARGER) || 460 if((charger_input_state == CHARGER) ||
463 (charger_input_state == CHARGER_PLUGGED)) 461 (charger_input_state == CHARGER_PLUGGED))
464 { 462 {
@@ -538,7 +536,7 @@ static void power_thread_sleep(int ticks)
538 536
539 while (ticks > 0) { 537 while (ticks > 0) {
540 538
541#ifdef HAVE_CHARGING 539#ifdef CONFIG_CHARGING
542 /* 540 /*
543 * Detect charger plugged/unplugged transitions. On a plugged or 541 * Detect charger plugged/unplugged transitions. On a plugged or
544 * unplugged event, we return immediately, run once through the main 542 * unplugged event, we return immediately, run once through the main
@@ -577,7 +575,7 @@ static void power_thread_sleep(int ticks)
577 } 575 }
578 } 576 }
579#endif 577#endif
580#ifdef HAVE_CHARGE_STATE 578#if CONFIG_CHARGING == CHARGING_MONITOR
581 switch (charger_input_state) { 579 switch (charger_input_state) {
582 case CHARGER_UNPLUGGED: 580 case CHARGER_UNPLUGGED:
583 case NO_CHARGER: 581 case NO_CHARGER:
@@ -593,7 +591,7 @@ static void power_thread_sleep(int ticks)
593 break; 591 break;
594 } 592 }
595 593
596#endif /* HAVE_CHARGE_STATE */ 594#endif /* CONFIG_CHARGING == CHARGING_MONITOR */
597 595
598 small_ticks = MIN(HZ/2, ticks); 596 small_ticks = MIN(HZ/2, ticks);
599 sleep(small_ticks); 597 sleep(small_ticks);
@@ -628,13 +626,13 @@ static void power_thread_sleep(int ticks)
628 battery_status_update(); 626 battery_status_update();
629 627
630 } 628 }
631#ifdef HAVE_CHARGE_CTRL 629#if CONFIG_CHARGING == CHARGING_CONTROL
632 if (ata_disk_is_active()) { 630 if (ata_disk_is_active()) {
633 /* flag hdd use for charging calculation */ 631 /* flag hdd use for charging calculation */
634 disk_activity_last_cycle = true; 632 disk_activity_last_cycle = true;
635 } 633 }
636#endif 634#endif
637#if defined(DEBUG_FILE) && defined(HAVE_CHARGE_CTRL) 635#if defined(DEBUG_FILE) && (CONFIG_CHARGING == CHARGING_CONTROL)
638 /* 636 /*
639 * If we have a lot of pending writes or if the disk is spining, 637 * If we have a lot of pending writes or if the disk is spining,
640 * fsync the debug log file. 638 * fsync the debug log file.
@@ -660,7 +658,7 @@ static void power_thread(void)
660{ 658{
661 int i; 659 int i;
662 short *phps, *phpd; /* power history rotation pointers */ 660 short *phps, *phpd; /* power history rotation pointers */
663#ifdef HAVE_CHARGE_CTRL 661#if CONFIG_CHARGING == CHARGING_CONTROL
664 unsigned int target_voltage = TRICKLE_VOLTAGE; /* desired topoff/trickle 662 unsigned int target_voltage = TRICKLE_VOLTAGE; /* desired topoff/trickle
665 * voltage level */ 663 * voltage level */
666 int charge_max_time_idle = 0; /* max. charging duration, calculated at 664 int charge_max_time_idle = 0; /* max. charging duration, calculated at
@@ -678,7 +676,7 @@ static void power_thread(void)
678 BATT_AVE_SAMPLES; 676 BATT_AVE_SAMPLES;
679 battery_centivolts = avgbat / BATT_AVE_SAMPLES / 10000; 677 battery_centivolts = avgbat / BATT_AVE_SAMPLES / 10000;
680 678
681#if defined(DEBUG_FILE) && defined(HAVE_CHARGE_CTRL) 679#if defined(DEBUG_FILE) && (CONFIG_CHARGING == CHARGING_CONTROL)
682 fd = -1; 680 fd = -1;
683 wrcount = 0; 681 wrcount = 0;
684#endif 682#endif
@@ -694,25 +692,7 @@ static void power_thread(void)
694 /* insert new value at the start, in centivolts 8-) */ 692 /* insert new value at the start, in centivolts 8-) */
695 power_history[0] = battery_centivolts; 693 power_history[0] = battery_centivolts;
696 694
697#if CONFIG_BATTERY == BATT_LIION2200 695#if CONFIG_CHARGING == CHARGING_CONTROL
698 /* We use the information from the ADC_EXT_POWER ADC channel, which
699 tells us the charging current from the LTC1734. When DC is
700 connected (either via the external adapter, or via USB), we try
701 to determine if it is actively charging or only maintaining the
702 charge. My tests show that ADC readings below about 0x80 means
703 that the LTC1734 is only maintaining the charge. */
704 if(charger_inserted()) {
705 if(adc_read(ADC_EXT_POWER) < 0x80) {
706 charge_state = TRICKLE;
707 } else {
708 charge_state = CHARGING;
709 }
710 } else {
711 charge_state = DISCHARGING;
712 }
713#endif /* # if CONFIG_BATTERY == BATT_LIION2200 */
714
715#ifdef HAVE_CHARGE_CTRL
716 if (charger_input_state == CHARGER_PLUGGED) { 696 if (charger_input_state == CHARGER_PLUGGED) {
717 pid_p = 0; 697 pid_p = 0;
718 pid_i = 0; 698 pid_i = 0;
@@ -876,7 +856,7 @@ static void power_thread(void)
876 } 856 }
877 } 857 }
878 } 858 }
879 else if (charge_state > CHARGING) /* top off or trickle */ 859 else if (charge_state != DISCHARGING) /* top off or trickle */
880 { 860 {
881 /* 861 /*
882 *Time to switch from topoff to trickle? 862 *Time to switch from topoff to trickle?
@@ -946,11 +926,11 @@ static void power_thread(void)
946 snprintf(power_message, POWER_MESSAGE_LEN, "Charger: discharge"); 926 snprintf(power_message, POWER_MESSAGE_LEN, "Charger: discharge");
947 } 927 }
948 928
949#endif /* end HAVE_CHARGE_CTRL */ 929#endif /* CONFIG_CHARGING == CHARGING_CONTROL */
950 930
951 /* sleep for a minute */ 931 /* sleep for a minute */
952 932
953#ifdef HAVE_CHARGE_CTRL 933#if CONFIG_CHARGING == CHARGING_CONTROL
954 if(trickle_sec > 0) { 934 if(trickle_sec > 0) {
955 charger_enable(true); 935 charger_enable(true);
956 power_thread_sleep(HZ * trickle_sec); 936 power_thread_sleep(HZ * trickle_sec);
@@ -962,7 +942,7 @@ static void power_thread(void)
962 power_thread_sleep(HZ * 60); 942 power_thread_sleep(HZ * 60);
963#endif 943#endif
964 944
965#if defined(DEBUG_FILE) && defined(HAVE_CHARGE_CTRL) 945#if defined(DEBUG_FILE) && (CONFIG_CHARGING == CHARGING_CONTROL)
966 if(usb_inserted()) { 946 if(usb_inserted()) {
967 if(fd >= 0) { 947 if(fd >= 0) {
968 /* It is probably too late to close the file but we can try...*/ 948 /* It is probably too late to close the file but we can try...*/
@@ -992,7 +972,7 @@ static void power_thread(void)
992#endif 972#endif
993 handle_auto_poweroff(); 973 handle_auto_poweroff();
994 974
995#ifdef HAVE_CHARGE_CTRL 975#if CONFIG_CHARGING == CHARGING_CONTROL
996 powermgmt_last_cycle_startstop_min++; 976 powermgmt_last_cycle_startstop_min++;
997#endif 977#endif
998 } 978 }
@@ -1029,7 +1009,7 @@ void cancel_shutdown(void)
1029void shutdown_hw(void) 1009void shutdown_hw(void)
1030{ 1010{
1031#ifndef SIMULATOR 1011#ifndef SIMULATOR
1032#if defined(DEBUG_FILE) && defined(HAVE_CHARGE_CTRL) 1012#if defined(DEBUG_FILE) && (CONFIG_CHARGING == CHARGING_CONTROL)
1033 if(fd >= 0) { 1013 if(fd >= 0) {
1034 close(fd); 1014 close(fd);
1035 fd = -1; 1015 fd = -1;