aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorAndy Green <andy@openmoko.com>2008-11-19 17:09:57 +0000
committerAndy Green <agreen@pads.home.warmcat.com>2008-11-19 17:09:57 +0000
commit1a79e3eedd41508187b310ea71328af7522ce10f (patch)
treef2afed15f9aef3b75205b6ae8e5aa6fb6d40fd04 /arch
parent93a92d72b7b77c8238116316ef24dfb740beae91 (diff)
fix-bq27000-charger-state-tracking.patch
Charger trigger stuff goes and asks for POWER_SUPPLY_PROP_STATUS to figure out what the charger state is. But until now, we only reported there what we found out from HDQ, and the HDQ registers are not updated very often in the coulomb counter, it can be 4 or more second lag before it tells us about what it experiences. When we react to USB insertion and only after 500ms debounce tell power_supply stuff that something changed, it most times will see old pre-USB-insertion state from bq27000 over HDQ at that time and will report it ain't charging, buggering up the LED trigger tracking. This patch maintains distance between bq27000 and pcf50633 by having platform callbacks in bq27000 that it can use to ask about definitive charger "online" presence and "activity", whether the charger says it is charging. If these callbacks are implemented (and we implement them in this patch up in mach_gta02.c) then this information is used in preference to what is found from HDQ. Result is if you set the LED trigger like this: echo bat-charging > /sys/devices/platform/gta02-led.0/leds/gta02-aux:red/trigger then it lights up properly on USB insertion now, goes away on removal properly, as as far as I saw, when charging stops too. Signed-off-by: Andy Green <andy@openmoko.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-s3c2440/mach-gta02.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index f30abb6ebe7..1fcd3fd2844 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -96,6 +96,9 @@ struct resume_dependency resume_dep_jbt_glamo;
struct resume_dependency resume_dep_glamo_mci_pcf;
+static int gta02_charger_online_status;
+static int gta02_charger_active_status;
+
/* define FIQ IPC struct */
/*
* contains stuff FIQ ISR modifies and normal kernel code can see and use
@@ -457,12 +460,25 @@ static struct s3c2410_uartcfg gta02_uartcfgs[] = {
/* BQ27000 Battery */
+static int gta02_get_charger_online_status(void)
+{
+ return gta02_charger_online_status;
+}
+
+static int gta02_get_charger_active_status(void)
+{
+ return gta02_charger_active_status;
+}
+
+
struct bq27000_platform_data bq27000_pdata = {
.name = "bat",
.rsense_mohms = 20,
.hdq_read = gta02hdq_read,
.hdq_write = gta02hdq_write,
.hdq_initialized = gta02hdq_initialized,
+ .get_charger_online_status = gta02_get_charger_online_status,
+ .get_charger_active_status = gta02_get_charger_active_status
};
struct platform_device bq27000_battery_device = {
@@ -481,16 +497,20 @@ static int pmu_callback(struct device *dev, unsigned int feature,
switch (feature) {
case PCF50633_FEAT_MBC:
switch (event) {
- case PMU_EVT_INSERT:
+ case PMU_EVT_CHARGER_IDLE:
+ gta02_charger_active_status = 0;
+ break;
+ case PMU_EVT_CHARGER_ACTIVE:
+ gta02_charger_active_status = 1;
+ break;
case PMU_EVT_USB_INSERT:
- pcf50633_charge_enable(pcf50633_global, 1);
+ gta02_charger_online_status = 1;
break;
- case PMU_EVT_REMOVE:
case PMU_EVT_USB_REMOVE:
- pcf50633_charge_enable(pcf50633_global, 0);
+ gta02_charger_online_status = 0;
break;
- case PMU_EVT_CHARGER_IDLE:
- case PMU_EVT_CHARGER_ACTIVE:
+ case PMU_EVT_INSERT: /* adapter is unsused */
+ case PMU_EVT_REMOVE: /* adapter is unused */
break;
default:
break;