summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Palsson <johan.palsson@stericsson.com>2011-07-07 11:45:03 +0200
committerUlf Hansson <ulf.hansson@stericsson.com>2011-09-19 16:00:09 +0200
commit9b336751fe35a39d1ad67654027c78839c75e21a (patch)
tree703d666a9090bfdb61754fb5595a830340f2a9a5
parentca6d6877f22adfb7376ecc7bacd201fdfaf819b6 (diff)
power: ab8500_bm: Measure battery temperature when not charging
Battery temperature is now measured even when no charger is connected. ST-Ericsson ID: 342846 ST-Ericsson Linux next: Not tested ST-Ericsson FOSS-OUT ID: Trivial Change-Id: Ia861437635bcdcdc32b259aff05d889b449ee682 Signed-off-by: Johan Palsson <johan.palsson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/26608 Reviewed-by: QATEST Reviewed-by: Mattias WALLIN <mattias.wallin@stericsson.com>
-rw-r--r--arch/arm/mach-ux500/board-mop500-bm.c2
-rw-r--r--drivers/power/ab8500_btemp.c33
-rw-r--r--include/linux/mfd/ab8500/bm.h4
3 files changed, 23 insertions, 16 deletions
diff --git a/arch/arm/mach-ux500/board-mop500-bm.c b/arch/arm/mach-ux500/board-mop500-bm.c
index 66ced8e088e..86be12cad3b 100644
--- a/arch/arm/mach-ux500/board-mop500-bm.c
+++ b/arch/arm/mach-ux500/board-mop500-bm.c
@@ -393,6 +393,8 @@ struct ab8500_bm_data ab8500_bm_data = {
.temp_high = 55,
.temp_over = 60,
.main_safety_tmr_h = 4,
+ .temp_interval_chg = 20,
+ .temp_interval_nochg = 120,
.usb_safety_tmr_h = 4,
.bkup_bat_v = BUP_VCH_SEL_2P6V,
.bkup_bat_i = BUP_ICH_SEL_150UA,
diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c
index 7d204b19742..b8053d577ab 100644
--- a/drivers/power/ab8500_btemp.c
+++ b/drivers/power/ab8500_btemp.c
@@ -510,6 +510,7 @@ static int ab8500_btemp_id(struct ab8500_btemp *di)
*/
static void ab8500_btemp_periodic_work(struct work_struct *work)
{
+ int interval;
struct ab8500_btemp *di = container_of(work,
struct ab8500_btemp, btemp_periodic_work.work);
@@ -520,10 +521,15 @@ static void ab8500_btemp_periodic_work(struct work_struct *work)
power_supply_changed(&di->btemp_psy);
}
+ if (di->events.ac_conn || di->events.usb_conn)
+ interval = di->bat->temp_interval_chg;
+ else
+ interval = di->bat->temp_interval_nochg;
+
/* Schedule a new measurement */
queue_delayed_work(di->btemp_wq,
&di->btemp_periodic_work,
- round_jiffies(20 * HZ));
+ round_jiffies(interval * HZ));
}
/**
@@ -656,11 +662,14 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di,
{
dev_dbg(di->dev, "Enable periodic temperature measurements: %d\n",
enable);
+ /*
+ * Make sure a new measurement is done directly by cancelling
+ * any pending work
+ */
+ cancel_delayed_work_sync(&di->btemp_periodic_work);
if (enable)
queue_delayed_work(di->btemp_wq, &di->btemp_periodic_work, 0);
- else
- cancel_delayed_work_sync(&di->btemp_periodic_work);
}
/**
@@ -795,9 +804,6 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data)
/* AC disconnected */
if (!ret.intval && di->events.ac_conn) {
di->events.ac_conn = false;
- if (!di->events.usb_conn)
- ab8500_btemp_periodic(di,
- false);
}
/* AC connected */
else if (ret.intval && !di->events.ac_conn) {
@@ -810,9 +816,6 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data)
/* USB disconnected */
if (!ret.intval && di->events.usb_conn) {
di->events.usb_conn = false;
- if (!di->events.ac_conn)
- ab8500_btemp_periodic(di,
- false);
}
/* USB connected */
else if (ret.intval && !di->events.usb_conn) {
@@ -863,8 +866,7 @@ static int ab8500_btemp_resume(struct platform_device *pdev)
{
struct ab8500_btemp *di = platform_get_drvdata(pdev);
- if (di->events.ac_conn || di->events.usb_conn)
- ab8500_btemp_periodic(di, true);
+ ab8500_btemp_periodic(di, true);
return 0;
}
@@ -874,8 +876,7 @@ static int ab8500_btemp_suspend(struct platform_device *pdev,
{
struct ab8500_btemp *di = platform_get_drvdata(pdev);
- if (di->events.ac_conn || di->events.usb_conn)
- ab8500_btemp_periodic(di, false);
+ ab8500_btemp_periodic(di, false);
return 0;
}
@@ -1004,9 +1005,6 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
break;
}
- /* Measure temperature once initially */
- di->bat_temp = ab8500_btemp_measure_temp(di);
-
/* Register BTEMP power supply class */
ret = power_supply_register(di->dev, &di->btemp_psy);
if (ret) {
@@ -1032,6 +1030,9 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, di);
+ /* Kick off periodic temperature measurements */
+ ab8500_btemp_periodic(di, true);
+
return ret;
free_irq:
diff --git a/include/linux/mfd/ab8500/bm.h b/include/linux/mfd/ab8500/bm.h
index 2ca4d8779cb..acde23b2a19 100644
--- a/include/linux/mfd/ab8500/bm.h
+++ b/include/linux/mfd/ab8500/bm.h
@@ -394,6 +394,8 @@ struct ab8500_bm_charger_parameters {
* @temp_low between this temp and temp_under charging is reduced
* @temp_high between this temp and temp_over charging is reduced
* @temp_over over this temp, charging is stopped
+ * @temp_interval_chg temperature measurement interval in s when charging
+ * @temp_interval_nochg temperature measurement interval in s when not charging
* @main_safety_tmr_h safety timer for main charger
* @usb_safety_tmr_h safety timer for usb charger
* @bkup_bat_v voltage which we charge the backup battery with
@@ -419,6 +421,8 @@ struct ab8500_bm_data {
int temp_low;
int temp_high;
int temp_over;
+ int temp_interval_chg;
+ int temp_interval_nochg;
int main_safety_tmr_h;
int usb_safety_tmr_h;
int bkup_bat_v;