misc: nct1008: add id for nct72
Chandler Zhang [Fri, 4 May 2012 02:32:36 +0000 (10:32 +0800)]
Add id for nct1008 compatible thermal sensor:
NCT72

Bug 961970

Change-Id: I792af664f73b6d1c8317a35c66330cf571cf3aba
Reviewed-on: http://git-master/r/100465
Signed-off-by: Chandler Zhang <chazhang@nvidia.com>
[danifu@nvidia.com: resolved conflicits in nct1008.c]
Signed-off-by: Daniel Fu <danifu@nvidia.com>
Reviewed-on: http://git-master/r/103581
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

drivers/misc/nct1008.c
include/linux/nct1008.h

index 56678a7..d58757f 100644 (file)
@@ -32,8 +32,6 @@
 #include <linux/delay.h>
 #include <linux/regulator/consumer.h>
 
-#define DRIVER_NAME "nct1008"
-
 /* Register Addresses */
 #define LOCAL_TEMP_RD                  0x00
 #define EXT_TEMP_RD_HI                 0x01
@@ -403,7 +401,7 @@ static void print_reg(const char *reg_name, struct seq_file *s,
 
 static int dbg_nct1008_show(struct seq_file *s, void *unused)
 {
-       seq_printf(s, "nct1008 Registers\n");
+       seq_printf(s, "nct1008 nct72 Registers\n");
        seq_printf(s, "------------------\n");
        print_reg("Local Temp Value    ",     s, 0x00);
        print_reg("Ext Temp Value Hi   ",     s, 0x01);
@@ -442,8 +440,12 @@ static int __init nct1008_debuginit(struct nct1008_data *nct)
 {
        int err = 0;
        struct dentry *d;
-       d = debugfs_create_file("nct1008", S_IRUGO, NULL,
-                       (void *)nct, &debug_fops);
+       if (nct->chip == NCT72)
+               d = debugfs_create_file("nct72", S_IRUGO, NULL,
+                               (void *)nct, &debug_fops);
+       else
+               d = debugfs_create_file("nct1008", S_IRUGO, NULL,
+                               (void *)nct, &debug_fops);
        if ((!d) || IS_ERR(d)) {
                dev_err(&nct->client->dev, "Error: %s debugfs_create_file"
                        " returned an error\n", __func__);
@@ -563,12 +565,14 @@ static void nct1008_power_control(struct nct1008_data *data, bool is_enable)
                ret = regulator_disable(data->nct_reg);
 
        if (ret < 0)
-               dev_err(&data->client->dev, "Error in %s rail vdd_nct1008, "
+               dev_err(&data->client->dev, "Error in %s rail vdd_nct%s, "
                        "error %d\n", (is_enable) ? "enabling" : "disabling",
+                       (data->chip == NCT72) ? "72" : "1008",
                        ret);
        else
-               dev_info(&data->client->dev, "success in %s rail vdd_nct1008\n",
-                       (is_enable) ? "enabling" : "disabling");
+               dev_info(&data->client->dev, "success in %s rail vdd_nct%s\n",
+                       (is_enable) ? "enabling" : "disabling",
+                       (data->chip == NCT72) ? "72" : "1008");
 }
 
 static int __devinit nct1008_configure_sensor(struct nct1008_data* data)
@@ -692,7 +696,8 @@ error:
 
 static int __devinit nct1008_configure_irq(struct nct1008_data *data)
 {
-       data->workqueue = create_singlethread_workqueue("nct1008");
+       data->workqueue = create_singlethread_workqueue((data->chip == NCT72) \
+                                                       ? "nct72" : "nct1008");
 
        INIT_WORK(&data->work, nct1008_work_func);
 
@@ -701,7 +706,8 @@ static int __devinit nct1008_configure_irq(struct nct1008_data *data)
        else
                return request_irq(data->client->irq, nct1008_irq,
                        IRQF_TRIGGER_LOW,
-                       DRIVER_NAME, data);
+                       (data->chip == NCT72) ? "nct72" : "nct1008",
+                       data);
 }
 
 int nct1008_thermal_get_temp(struct nct1008_data *data, long *temp)
@@ -816,6 +822,7 @@ static int __devinit nct1008_probe(struct i2c_client *client,
                return -ENOMEM;
 
        data->client = client;
+       data->chip = id->driver_data;
        memcpy(&data->plat_data, client->dev.platform_data,
                sizeof(struct nct1008_platform_data));
        i2c_set_clientdata(client, data);
@@ -911,14 +918,15 @@ static int nct1008_resume(struct i2c_client *client)
 #endif
 
 static const struct i2c_device_id nct1008_id[] = {
-       { DRIVER_NAME, 0 },
-       { }
+       { "nct1008", NCT1008 },
+       { "nct72", NCT72},
+       {}
 };
 MODULE_DEVICE_TABLE(i2c, nct1008_id);
 
 static struct i2c_driver nct1008_driver = {
        .driver = {
-               .name   = DRIVER_NAME,
+               .name   = "nct1008_nct72",
        },
        .probe          = nct1008_probe,
        .remove         = __devexit_p(nct1008_remove),
@@ -939,7 +947,7 @@ static void __exit nct1008_exit(void)
        i2c_del_driver(&nct1008_driver);
 }
 
-MODULE_DESCRIPTION("Temperature sensor driver for OnSemi NCT1008");
+MODULE_DESCRIPTION("Temperature sensor driver for OnSemi NCT1008/NCT72");
 MODULE_LICENSE("GPL");
 
 module_init(nct1008_init);
index 0a517f1..9227f4a 100644 (file)
@@ -31,6 +31,8 @@
 
 struct nct1008_data;
 
+enum nct1008_chip { NCT1008, NCT72 };
+
 struct nct1008_platform_data {
        bool supported_hwrev;
        bool ext_range;
@@ -56,6 +58,7 @@ struct nct1008_data {
        u8 config;
        s8 *limits;
        u8 limits_sz;
+       enum nct1008_chip chip;
        void (*alarm_fn)(bool raised);
        struct regulator *nct_reg;
        long current_lo_limit;