summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/ab5500.c14
-rw-r--r--drivers/hwmon/abx500.h2
-rw-r--r--drivers/power/ab5500_btemp.c11
3 files changed, 25 insertions, 2 deletions
diff --git a/drivers/hwmon/ab5500.c b/drivers/hwmon/ab5500.c
index f229d103ec1..79540c9a79b 100644
--- a/drivers/hwmon/ab5500.c
+++ b/drivers/hwmon/ab5500.c
@@ -23,6 +23,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/platform_device.h>
#include <linux/mfd/abx500/ab5500-gpadc.h>
+#include <linux/mfd/abx500/ab5500-bm.h>
#include "abx500.h"
/* AB5500 driver monitors GPADC - XTAL_TEMP, PCB_TEMP,
@@ -47,12 +48,17 @@ static int ab5500_output_convert(int val, u8 sensor)
static int ab5500_read_sensor(struct abx500_temp *data, u8 sensor)
{
+ int val;
/*
- * TODO: Add support for BAT_CTRL node, since this
+ * Special treatment for BAT_CTRL node, since this
* temperature measurement is more complex than just
* an ADC readout
*/
- int val = ab5500_gpadc_convert(data->ab5500_gpadc, sensor);
+ if (sensor == BAT_CTRL)
+ val = ab5500_btemp_get_batctrl_temp(data->ab5500_btemp);
+ else
+ val = ab5500_gpadc_convert(data->ab5500_gpadc, sensor);
+
if (val < 0)
return val;
else
@@ -156,6 +162,10 @@ int __init abx500_hwmon_init(struct abx500_temp *data)
if (IS_ERR(data->ab5500_gpadc))
return PTR_ERR(data->ab5500_gpadc);
+ data->ab5500_btemp = ab5500_btemp_get();
+ if (IS_ERR(data->ab5500_btemp))
+ return PTR_ERR(data->ab5500_btemp);
+
err = ab5500_temp_shutdown_auto(data);
if (err < 0) {
dev_err(&data->pdev->dev, "Failed to register"
diff --git a/drivers/hwmon/abx500.h b/drivers/hwmon/abx500.h
index 1d41aa191fe..77ae7cbd5c1 100644
--- a/drivers/hwmon/abx500.h
+++ b/drivers/hwmon/abx500.h
@@ -12,6 +12,7 @@
struct ab8500_gpadc;
struct ab5500_gpadc;
struct ab8500_btemp;
+struct ab5500_btemp;
struct adc_auto_input;
struct abx500_temp;
@@ -63,6 +64,7 @@ struct abx500_temp {
struct ab8500_gpadc *ab8500_gpadc;
struct ab5500_gpadc *ab5500_gpadc;
struct ab8500_btemp *ab8500_btemp;
+ struct ab5500_btemp *ab5500_btemp;
struct adc_auto_input *gpadc_auto;
struct abx500_temp_ops ops;
u8 gpadc_addr[NUM_SENSORS];
diff --git a/drivers/power/ab5500_btemp.c b/drivers/power/ab5500_btemp.c
index 04ad6bbb7ac..2e2a5054a58 100644
--- a/drivers/power/ab5500_btemp.c
+++ b/drivers/power/ab5500_btemp.c
@@ -110,6 +110,17 @@ struct ab5500_btemp *ab5500_btemp_get(void)
}
/**
+ * ab5500_btemp_get_batctrl_temp() - get the temperature
+ * @di: pointer to the ab5500_btemp structure
+ *
+ * Returns the batctrl temperature in millidegrees
+ */
+int ab5500_btemp_get_batctrl_temp(struct ab5500_btemp *di)
+{
+ return di->bat_temp * 1000;
+}
+
+/**
* ab5500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance
* @di: pointer to the ab5500_btemp structure
* @v_batctrl: measured batctrl voltage