summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVarun Wadekar <vwadekar@nvidia.com>2010-12-24 13:05:39 +0530
committerBharat Nihalani <bnihalani@nvidia.com>2010-12-24 06:11:42 -0800
commit9476a4955b1e4a9d39d5eec9492091f929fc0247 (patch)
treeff5e702ae880eb5a3eb9e82d5307cb78795c892b
parent4fc3137c38291a36b40ca136db85fedd45c5e7b7 (diff)
hwmon: nct1008: set offset and config registers
the bootloader may keep the offset and config registers in a bad state before the driver gets loaded. set offset and config registers forceibly, depending on the platform data to avoid any temperature measurement surprises later. Bug 769337 Change-Id: Ia13d547c1dcade9eb95df28015fa04ce40b338b3 Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-on: http://git-master/r/14226 Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com> Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
-rw-r--r--drivers/hwmon/nct1008.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/hwmon/nct1008.c b/drivers/hwmon/nct1008.c
index 72fa9b11642f..bc82da400035 100644
--- a/drivers/hwmon/nct1008.c
+++ b/drivers/hwmon/nct1008.c
@@ -36,12 +36,8 @@
#define NCT1008_MFR_ID_RD 0xFE
#define NCT1008_CONFIG_WR 0x09
- #define NCT1008_CONFIG_ALERT_DISABLE 0x80
- #define NCT1008_CONFIG_RUN_STANDBY 0x40
- #define NCT1008_CONFIG_ALERT_THERM2 0x20
- #define NCT1008_CONFIG_ENABLE_EXTENDED 0x04
-
#define NCT1008_CONV_RATE_WR 0x0A
+#define NCT1008_OFFSET_WR 0x11
#define NCT1008_LOCAL_THERM_LIMIT_WR 0x20
#define DRIVER_NAME "nct1008"
@@ -70,7 +66,7 @@ static ssize_t nct1008_show_temp(struct device *dev,
}
temp_value = (signed int)data;
- return sprintf(buf, "%d", temp_value);
+ return sprintf(buf, "%d\n", temp_value);
}
static DEVICE_ATTR(temperature, S_IRUGO, nct1008_show_temp, NULL);
@@ -127,21 +123,23 @@ static int __devinit nct1008_probe(struct i2c_client *client,
goto fail_alloc;
}
- data = i2c_smbus_read_byte_data(client, NCT1008_CONFIG_RD);
- if (data < 0) {
- dev_err(&client->dev, "%s: failed to read config\n", __func__);
- err = data;
- goto fail_alloc;
- }
-
/* set config params */
- data |= pdata->plat_data.config;
+ data = pdata->plat_data.config;
err = i2c_smbus_write_byte_data(client, NCT1008_CONFIG_WR, data);
if (err < 0) {
dev_err(&client->dev, "%s: failed to set config\n", __func__);
goto fail_alloc;
}
+ /* set offset value */
+ data = pdata->plat_data.offset;
+ err = i2c_smbus_write_byte_data(client, NCT1008_OFFSET_WR, data);
+ if (err < 0) {
+ dev_err(&client->dev,
+ "%s: failed to set offset\n", __func__);
+ goto fail_alloc;
+ }
+
/* set cpu shutdown threshold */
data = pdata->plat_data.thermal_threshold;
err = i2c_smbus_write_byte_data(client, NCT1008_LOCAL_THERM_LIMIT_WR, data);