diff options
Diffstat (limited to 'drivers/misc/nct1008.c')
-rw-r--r-- | drivers/misc/nct1008.c | 58 |
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", |