summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajagopala V <rajagopala.v@stericsson.com>2011-10-18 16:57:25 +0530
committerPhilippe Langlais <philippe.langlais@stericsson.com>2012-05-22 11:01:07 +0200
commit2b6a91fa2618d226d8e8c5a97ad7cb57a75be3cd (patch)
tree40bd7e1cbcde0145eb0cc79fc3674af2dd200a87
parent672afbe5adffd7adcbd73456412c97cf32503023 (diff)
u5500: Battery temp monitoring in manual mode
Add support and enable manual mode battery temperature monitoring. As gpadc bdata auto trigger is not working as expected, switch to manual mode. ST-Ericsson Linux next: NA ST-Ericsson ID: 367324 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I0f4b619bb5527730ee779838507b09f6b37efb3a Signed-off-by: Rajagopala V <rajagopala.v@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/34364 Reviewed-by: Vijaya Kumar K-1 <vijay.kilari@stericsson.com> Reviewed-by: QATOOLS Reviewed-by: Arun MURTHY <arun.murthy@stericsson.com> Reviewed-by: Rabin VINCENT <rabin.vincent@stericsson.com>
-rw-r--r--drivers/power/ab5500_btemp.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/drivers/power/ab5500_btemp.c b/drivers/power/ab5500_btemp.c
index 7867455f493..111f0a8b107 100644
--- a/drivers/power/ab5500_btemp.c
+++ b/drivers/power/ab5500_btemp.c
@@ -38,6 +38,9 @@
#define RESET 0x00
#define ADOUT_10K_PULL_UP 0x07
+/* Enable battery temp monitoring manual mode */
+#define BTEMP_MANUAL_MONITORING
+
#define to_ab5500_btemp_device_info(x) container_of((x), \
struct ab5500_btemp, btemp_psy);
@@ -102,6 +105,8 @@ static enum power_supply_property ab5500_btemp_props[] = {
static LIST_HEAD(ab5500_btemp_list);
+static int ab5500_btemp_bat_temp_trig(int mux);
+
struct ab5500_btemp *ab5500_btemp_get(void)
{
struct ab5500_btemp *di;
@@ -451,11 +456,25 @@ static void ab5500_btemp_periodic_work(struct work_struct *work)
power_supply_changed(&di->btemp_psy);
}
di->bat->temp_now = di->bat_temp;
+#if defined(BTEMP_MANUAL_MONITORING)
+ /* Check for temperature limits */
+ ab5500_btemp_bat_temp_trig(0);
/* Schedule a new measurement */
+ if (di->events.usb_conn)
+ queue_delayed_work(di->btemp_wq,
+ &di->btemp_periodic_work,
+ round_jiffies(di->bat->interval_charging * HZ));
+ else
+ queue_delayed_work(di->btemp_wq,
+ &di->btemp_periodic_work,
+ round_jiffies(di->bat->interval_not_charging * HZ));
+#else
+ /* Schedule a new measurement */
queue_delayed_work(di->btemp_wq,
&di->btemp_periodic_work,
- round_jiffies(20 * HZ));
+ round_jiffies(di->bat->interval_charging * HZ));
+#endif
}
/**
@@ -604,13 +623,18 @@ static int ab5500_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 !defined(BTEMP_MANUAL_MONITORING)
ab5500_btemp_periodic(di,
false);
+#endif
}
/* USB connected */
else if (ret.intval && !di->events.usb_conn) {
di->events.usb_conn = true;
+
+#if !defined(BTEMP_MANUAL_MONITORING)
ab5500_btemp_periodic(di, true);
+#endif
}
break;
default:
@@ -646,6 +670,7 @@ static struct ab5500_btemp_interrupts ab5500_btemp_irq[] = {
{"BATT_REMOVAL", ab5500_btemp_batt_removal_handler},
{"BATT_ATTACH", ab5500_btemp_batt_attach_handler},
};
+
static int ab5500_btemp_bat_temp_trig(int mux)
{
struct ab5500_btemp *di = ab5500_btemp_get();
@@ -661,6 +686,7 @@ static int ab5500_btemp_bat_temp_trig(int mux)
return 0;;
}
+#if !defined(BTEMP_MANUAL_MONITORING)
static int ab5500_btemp_auto_temp(struct ab5500_btemp *di)
{
struct adc_auto_input *auto_ip;
@@ -684,6 +710,7 @@ static int ab5500_btemp_auto_temp(struct ab5500_btemp *di)
"failed to set auto trigger for battery temp\n");
return ret;
}
+#endif
#if defined(CONFIG_PM)
static int ab5500_btemp_resume(struct platform_device *pdev)
@@ -831,14 +858,21 @@ static int __devinit ab5500_btemp_probe(struct platform_device *pdev)
dev_dbg(di->dev, "Requested %s IRQ %d: %d\n",
ab5500_btemp_irq[i].name, irq, ret);
}
+#if defined(BTEMP_MANUAL_MONITORING)
+ /* Schedule monitoring work only if battery type is known */
+ if (di->bat->batt_id != BATTERY_UNKNOWN)
+ queue_delayed_work(di->btemp_wq, &di->btemp_periodic_work, 0);
+#else
ret = ab5500_btemp_auto_temp(di);
if (ret) {
dev_err(di->dev,
"failed to register auto trigger for battery temp\n");
goto free_irq;
}
+#endif
platform_set_drvdata(pdev, di);
+ list_add_tail(&di->node, &ab5500_btemp_list);
dev_info(di->dev, "probe success\n");
return ret;