summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorJohan Palsson <johan.palsson@stericsson.com>2011-08-25 12:27:06 +0530
committerUlf Hansson <ulf.hansson@stericsson.com>2011-09-19 16:00:09 +0200
commit83177878674c623a2aefb37c1ceb10ea48116e41 (patch)
tree68659ba413c93d3f99dff2e3ec2b3d2e1aec0148 /drivers/power
parent9b336751fe35a39d1ad67654027c78839c75e21a (diff)
hwmon: ab8500: Add support to monitor battery temp
ST-Ericsson ID: CR339643 ST-Ericsson Linux next: ER282986 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: Ib6ad58e7a702fe976a1d66fef0ce9d1782a1f8d2 Signed-off-by: Huan DUAN <huan.duan@stericsson.com> Signed-off-by: Johan Palsson <johan.palsson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/25108 Reviewed-by: QATEST Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/ab8500_btemp.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c
index b8053d577ab..336384c882f 100644
--- a/drivers/power/ab8500_btemp.c
+++ b/drivers/power/ab8500_btemp.c
@@ -67,6 +67,7 @@ struct ab8500_btemp_ranges {
/**
* struct ab8500_btemp - ab8500 BTEMP device information
* @dev: Pointer to the structure device
+ * @node: List of AB8500 BTEMPs, hence prepared for reentrance
* @chip_id: Chip-Id of the AB8500
* @curr_source: What current source we use, in uA
* @bat_temp: Battery temperature in degree Celcius
@@ -83,6 +84,7 @@ struct ab8500_btemp_ranges {
*/
struct ab8500_btemp {
struct device *dev;
+ struct list_head node;
u8 chip_id;
int curr_source;
int bat_temp;
@@ -106,6 +108,20 @@ static enum power_supply_property ab8500_btemp_props[] = {
POWER_SUPPLY_PROP_TEMP,
};
+static LIST_HEAD(ab8500_btemp_list);
+
+/**
+ * ab8500_btemp_get() - returns a reference to the primary AB8500 BTEMP
+ * (i.e. the first BTEMP in the instance list)
+ */
+struct ab8500_btemp *ab8500_btemp_get(void)
+{
+ struct ab8500_btemp *btemp;
+ btemp = list_first_entry(&ab8500_btemp_list, struct ab8500_btemp, node);
+
+ return btemp;
+}
+
/**
* ab8500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance
* @di: pointer to the ab8500_btemp structure
@@ -723,6 +739,17 @@ static int ab8500_btemp_get_temp(struct ab8500_btemp *di)
}
/**
+ * ab8500_btemp_get_batctrl_temp() - get the temperature
+ * @btemp: pointer to the btemp structure
+ *
+ * Returns the batctrl temperature in millidegrees
+ */
+int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp)
+{
+ return btemp->bat_temp * 1000;
+}
+
+/**
* ab8500_btemp_get_property() - get the btemp properties
* @psy: pointer to the power_supply structure
* @psp: pointer to the power_supply_property structure
@@ -1032,6 +1059,7 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
/* Kick off periodic temperature measurements */
ab8500_btemp_periodic(di, true);
+ list_add_tail(&di->node, &ab8500_btemp_list);
return ret;