summaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorBitan Biswas <bbiswas@nvidia.com>2011-10-12 18:11:06 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:49:27 -0800
commitc1298380d704600bf5515db42cc6bd9f8a0643e8 (patch)
tree2628416371e7e11cc6b36bd5ad99f6b6d1c5f039 /drivers/misc
parent4e9a06c56016dabc73dae2001db359d9e863c6e9 (diff)
misc: nct1008: extended range enable sequence change
Extended range mode enable sequence for nct1008 updated as per recommended steps bug 869823 Reviewed-on: http://git-master/r/57552 (cherry picked from commit 75c6f5173cd4cfa3b0cf114cbbbf6ac1e355a09b) Reviewed-on: http://git-master/r/58328 (cherry picked from commit 9f2c9004b4f30f9297ef3a7aa8def8a8000934b7) Change-Id: Ic339d322450187f0ad417030d5da717fa5020592 Reviewed-on: http://git-master/r/59150 Reviewed-by: Varun Colbert <vcolbert@nvidia.com> Tested-by: Varun Colbert <vcolbert@nvidia.com> Rebase-Id: Re46ba9dba83b3e12d6341f9afc913514a9a1031a
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/nct1008.c58
1 files changed, 39 insertions, 19 deletions
diff --git a/drivers/misc/nct1008.c b/drivers/misc/nct1008.c
index 3a830b775dc8..af8660915a9a 100644
--- a/drivers/misc/nct1008.c
+++ b/drivers/misc/nct1008.c
@@ -707,25 +707,9 @@ static int __devinit nct1008_configure_sensor(struct nct1008_data* data)
if (!pdata || !pdata->supported_hwrev)
return -ENODEV;
- /*
- * Initial Configuration - device is placed in standby and
- * ALERT/THERM2 pin is configured as THERM2
- */
- data->config = pdata->ext_range ?
- (STANDBY_BIT | EXTENDED_RANGE_BIT) : STANDBY_BIT;
-
- if (pdata->thermal_zones_sz)
- data->config &= ~(THERM2_BIT | ALERT_BIT);
- else
- data->config |= (ALERT_BIT | THERM2_BIT);
-
- value = data->config;
- err = i2c_smbus_write_byte_data(client, CONFIG_WR, value);
- if (err)
- goto error;
-
- /* Temperature conversion rate */
- err = i2c_smbus_write_byte_data(client, CONV_RATE_WR, pdata->conv_rate);
+ /* Place in Standby */
+ data->config = STANDBY_BIT;
+ err = i2c_smbus_write_byte_data(client, CONFIG_WR, data->config);
if (err)
goto error;
@@ -743,6 +727,23 @@ static int __devinit nct1008_configure_sensor(struct nct1008_data* data)
if (err)
goto error;
+ /* set extended range mode if needed */
+ if (pdata->ext_range)
+ data->config |= EXTENDED_RANGE_BIT;
+ if (pdata->thermal_zones_sz)
+ data->config &= ~(THERM2_BIT | ALERT_BIT);
+ else
+ data->config |= (ALERT_BIT | THERM2_BIT);
+
+ err = i2c_smbus_write_byte_data(client, CONFIG_WR, data->config);
+ if (err)
+ goto error;
+
+ /* Temperature conversion rate */
+ err = i2c_smbus_write_byte_data(client, CONV_RATE_WR, pdata->conv_rate);
+ if (err)
+ goto error;
+
if (pdata->thermal_zones_sz) {
data->limits = pdata->thermal_zones;
data->limits_sz = pdata->thermal_zones_sz;
@@ -878,6 +879,22 @@ static unsigned int get_ext_mode_delay_ms(unsigned int conv_rate)
}
}
+/*
+ * Manufacturer(OnSemi) recommended sequence for
+ * Extended Range mode is as follows
+ * 1. Place in Standby
+ * 2. Scale the THERM and ALERT limits
+ * appropriately(for Extended Range mode).
+ * 3. Enable Extended Range mode.
+ * ALERT mask/THERM2 mode may be done here
+ * as these are not critical
+ * 4. Set Conversion Rate as required
+ * 5. Take device out of Standby
+ */
+
+/*
+ * function nct1008_probe takes care of initial configuration
+ */
static int __devinit nct1008_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -898,6 +915,8 @@ static int __devinit nct1008_probe(struct i2c_client *client,
mutex_init(&data->mutex);
nct1008_power_control(data, true);
+ /* extended range recommended steps 1 through 4 taken care
+ * in nct1008_configure_sensor function */
err = nct1008_configure_sensor(data); /* sensor is in standby */
if (err < 0) {
dev_err(&client->dev, "\n error file: %s : %s(), line=%d ",
@@ -913,6 +932,7 @@ static int __devinit nct1008_probe(struct i2c_client *client,
}
dev_info(&client->dev, "%s: initialized\n", __func__);
+ /* extended range recommended step 5 is in nct1008_enable function */
err = nct1008_enable(client); /* sensor is running */
if (err < 0) {
dev_err(&client->dev, "Error: %s, line=%d, error=%d\n",