misc: nct1008: allow to program fractional offsets
Diwakar Tundlam [Fri, 26 Aug 2011 00:48:42 +0000 (17:48 -0700)]
to adjust for sku specific guardbanding of temperatures
bug 844025

Original-Change-Id: I1193eae50736ae3dbf3ce0a26653e01962c21c8d
Reviewed-on: http://git-master/r/49316
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
Tested-by: Diwakar Tundlam <dtundlam@nvidia.com>
Reviewed-by: Aleksandr Frid <afrid@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>

Rebase-Id: Rc6f03d281542bff48b2d41ff29cd0c90d2ad65c3

drivers/misc/nct1008.c

index 6e0f7a4..ef157c3 100644 (file)
@@ -54,6 +54,7 @@
 #define EXT_TEMP_HI_LIMIT_HI_BYTE_WR   0x0D
 #define EXT_TEMP_LO_LIMIT_HI_BYTE_WR   0x0E
 #define OFFSET_WR                      0x11
+#define OFFSET_QUARTER_WR              0x12
 #define EXT_THERM_LIMIT_WR             0x19
 #define LOCAL_THERM_LIMIT_WR           0x20
 #define THERM_HYSTERESIS_WR            0x21
@@ -683,7 +684,13 @@ static int __devinit nct1008_configure_sensor(struct nct1008_data* data)
                dev_dbg(&client->dev, "\n initial ext temp = %d.0 deg", temp);
 
        /* Remote channel offset */
-       err = i2c_smbus_write_byte_data(client, OFFSET_WR, pdata->offset);
+       err = i2c_smbus_write_byte_data(client, OFFSET_WR, pdata->offset / 4);
+       if (err < 0)
+               goto error;
+
+       /* Remote channel offset fraction (quarters) */
+       err = i2c_smbus_write_byte_data(client, OFFSET_QUARTER_WR,
+                                       (pdata->offset % 4) << 6);
        if (err < 0)
                goto error;