diff options
author | Joshua Primero <jprimero@nvidia.com> | 2012-08-28 14:38:51 -0700 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-10-25 15:48:06 -0700 |
commit | 190cfeae9d2d6f398046b9e00870ac149116e817 (patch) | |
tree | 8b35930407f004afe3af9399e9731c287d9e3629 /drivers/misc/nct1008.c | |
parent | cbf6adffaff040ca826dee1712d6963b6b9ad8a5 (diff) |
drivers: nct: shutdown and thermal register
Shutdown temperature in platform data now used. Also,
cleaned up some unused platform data parameters.
Also, have nct driver register with thermal framework
itself.
Change-Id: Ic97aa3968b945033c83d2809b63c571b05bb89eb
Signed-off-by: Joshua Primero <jprimero@nvidia.com>
Reviewed-on: http://git-master/r/132879
(cherry picked from commit e361239aab1a9c393a4a6ccfb8ac78f066adbffb)
Signed-off-by: Gaurav Batra <gbatra@nvidia.com>
Reviewed-on: http://git-master/r/130285
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
Tested-by: Diwakar Tundlam <dtundlam@nvidia.com>
Diffstat (limited to 'drivers/misc/nct1008.c')
-rw-r--r-- | drivers/misc/nct1008.c | 70 |
1 files changed, 47 insertions, 23 deletions
diff --git a/drivers/misc/nct1008.c b/drivers/misc/nct1008.c index 5e354132c211..56b437d087cf 100644 --- a/drivers/misc/nct1008.c +++ b/drivers/misc/nct1008.c @@ -30,6 +30,7 @@ #include <linux/device.h> #include <linux/nct1008.h> #include <linux/delay.h> +#include <linux/thermal.h> #include <linux/regulator/consumer.h> /* Register Addresses */ @@ -598,13 +599,15 @@ static int __devinit nct1008_configure_sensor(struct nct1008_data* data) goto error; /* External temperature h/w shutdown limit */ - value = temperature_to_value(pdata->ext_range, NCT1008_MAX_TEMP); + value = temperature_to_value(pdata->ext_range, + pdata->shutdown_ext_limit); err = i2c_smbus_write_byte_data(client, EXT_THERM_LIMIT_WR, value); if (err) goto error; /* Local temperature h/w shutdown limit */ - value = temperature_to_value(pdata->ext_range, NCT1008_MAX_TEMP); + value = temperature_to_value(pdata->ext_range, + pdata->shutdown_local_limit); err = i2c_smbus_write_byte_data(client, LOCAL_THERM_LIMIT_WR, value); if (err) goto error; @@ -724,12 +727,6 @@ int nct1008_thermal_get_temps(struct nct1008_data *data, long *etemp, long *item return nct1008_get_temp(&data->client->dev, etemp, itemp); } -int nct1008_thermal_get_temp_low(struct nct1008_data *data, long *temp) -{ - *temp = 0; - return 0; -} - int nct1008_thermal_set_limits(struct nct1008_data *data, long lo_limit_milli, long hi_limit_milli) @@ -778,32 +775,48 @@ int nct1008_thermal_set_alert(struct nct1008_data *data, return 0; } -int nct1008_thermal_set_shutdown_temp(struct nct1008_data *data, - long shutdown_temp_milli) +#ifdef CONFIG_THERMAL +static int nct1008_zone_get_temp(struct thermal_zone_device *thz, + unsigned long *temp) { + struct nct1008_data *data = thz->devdata; struct i2c_client *client = data->client; struct nct1008_platform_data *pdata = client->dev.platform_data; - int err; + s8 temp_local; + long temp_local_milli; u8 value; - long shutdown_temp; - shutdown_temp = MILLICELSIUS_TO_CELSIUS(shutdown_temp_milli); + /* Read Local Temp */ + value = i2c_smbus_read_byte_data(client, LOCAL_TEMP_RD); + if (value < 0) + return -1; + temp_local = value_to_temperature(pdata->ext_range, value); + temp_local_milli = CELSIUS_TO_MILLICELSIUS(temp_local); - /* External temperature h/w shutdown limit */ - value = temperature_to_value(pdata->ext_range, shutdown_temp); - err = i2c_smbus_write_byte_data(client, EXT_THERM_LIMIT_WR, value); - if (err) - return err; + *temp = temp_local_milli; - /* Local temperature h/w shutdown limit */ - value = temperature_to_value(pdata->ext_range, shutdown_temp); - err = i2c_smbus_write_byte_data(client, LOCAL_THERM_LIMIT_WR, value); - if (err) - return err; + return 0; +} +static int nct1008_bind(struct thermal_zone_device *thz, + struct thermal_cooling_device *cdev) +{ return 0; } +static int nct1008_unbind(struct thermal_zone_device *thz, + struct thermal_cooling_device *cdev) +{ + return 0; +} + +static struct thermal_zone_device_ops nct_ops = { + .get_temp = nct1008_zone_get_temp, + .bind = nct1008_bind, + .unbind = nct1008_unbind, +}; +#endif + /* * Manufacturer(OnSemi) recommended sequence for * Extended Range mode is as follows @@ -866,6 +879,17 @@ static int __devinit nct1008_probe(struct i2c_client *client, if (err < 0) err = 0; /* without debugfs we may continue */ +#ifdef CONFIG_THERMAL + thermal_zone_device_register("nct_int", + 0, + data, + &nct_ops, + 0, + 1, + 2000, + 0); +#endif + /* notify callback that probe is done */ if (data->plat_data.probe_callback) data->plat_data.probe_callback(data); |