lm95241.c (48d67fe03511c8ded54c39561dfedbdf7c78c743) lm95241.c (8c1d04192e2ef1e6d38e9d5e9c500e5330d20339)
1/*
2 * Copyright (C) 2008, 2010 Davide Rizzo <elpa.rizzo@gmail.com>
3 *
4 * The LM95241 is a sensor chip made by National Semiconductors.
5 * It reports up to three temperatures (its own plus up to two external ones).
6 * Complete datasheet can be obtained from National's website at:
7 * http://www.national.com/ds.cgi/LM/LM95241.pdf
8 *

--- 60 unchanged lines hidden (view full) ---

69#define R2DF_MASK (0x01 << (R2DF_SHIFT))
70#define R1FE_MASK 0x01
71#define R2FE_MASK 0x05
72#define TT1_SHIFT 0
73#define TT2_SHIFT 4
74#define TT_OFF 0
75#define TT_ON 1
76#define TT_MASK 7
1/*
2 * Copyright (C) 2008, 2010 Davide Rizzo <elpa.rizzo@gmail.com>
3 *
4 * The LM95241 is a sensor chip made by National Semiconductors.
5 * It reports up to three temperatures (its own plus up to two external ones).
6 * Complete datasheet can be obtained from National's website at:
7 * http://www.national.com/ds.cgi/LM/LM95241.pdf
8 *

--- 60 unchanged lines hidden (view full) ---

69#define R2DF_MASK (0x01 << (R2DF_SHIFT))
70#define R1FE_MASK 0x01
71#define R2FE_MASK 0x05
72#define TT1_SHIFT 0
73#define TT2_SHIFT 4
74#define TT_OFF 0
75#define TT_ON 1
76#define TT_MASK 7
77#define MANUFACTURER_ID 0x01
78#define DEFAULT_REVISION 0xA4
77#define NATSEMI_MAN_ID 0x01
78#define LM95231_CHIP_ID 0xA1
79#define LM95241_CHIP_ID 0xA4
79
80static const u8 lm95241_reg_address[] = {
81 LM95241_REG_R_LOCAL_TEMPH,
82 LM95241_REG_R_LOCAL_TEMPL,
83 LM95241_REG_R_REMOTE1_TEMPH,
84 LM95241_REG_R_REMOTE1_TEMPL,
85 LM95241_REG_R_REMOTE2_TEMPH,
86 LM95241_REG_R_REMOTE2_TEMPL

--- 246 unchanged lines hidden (view full) ---

333 .attrs = lm95241_attributes,
334};
335
336/* Return 0 if detection is successful, -ENODEV otherwise */
337static int lm95241_detect(struct i2c_client *new_client,
338 struct i2c_board_info *info)
339{
340 struct i2c_adapter *adapter = new_client->adapter;
80
81static const u8 lm95241_reg_address[] = {
82 LM95241_REG_R_LOCAL_TEMPH,
83 LM95241_REG_R_LOCAL_TEMPL,
84 LM95241_REG_R_REMOTE1_TEMPH,
85 LM95241_REG_R_REMOTE1_TEMPL,
86 LM95241_REG_R_REMOTE2_TEMPH,
87 LM95241_REG_R_REMOTE2_TEMPL

--- 246 unchanged lines hidden (view full) ---

334 .attrs = lm95241_attributes,
335};
336
337/* Return 0 if detection is successful, -ENODEV otherwise */
338static int lm95241_detect(struct i2c_client *new_client,
339 struct i2c_board_info *info)
340{
341 struct i2c_adapter *adapter = new_client->adapter;
341 int address = new_client->addr;
342 const char *name;
342 const char *name;
343 int mfg_id, chip_id;
343
344 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
345 return -ENODEV;
346
344
345 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
346 return -ENODEV;
347
347 if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID)
348 == MANUFACTURER_ID)
349 && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID)
350 == DEFAULT_REVISION)) {
351 name = DEVNAME;
352 } else {
353 dev_dbg(&adapter->dev, "LM95241 detection failed at 0x%02x\n",
354 address);
348 mfg_id = i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID);
349 if (mfg_id != NATSEMI_MAN_ID)
355 return -ENODEV;
350 return -ENODEV;
351
352 chip_id = i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID);
353 switch (chip_id) {
354 case LM95231_CHIP_ID:
355 name = "lm95231";
356 break;
357 case LM95241_CHIP_ID:
358 name = "lm95241";
359 break;
360 default:
361 return -ENODEV;
356 }
357
358 /* Fill the i2c board info */
359 strlcpy(info->type, name, I2C_NAME_SIZE);
360 return 0;
361}
362
363static void lm95241_init_client(struct i2c_client *client)

--- 62 unchanged lines hidden (view full) ---

426 sysfs_remove_group(&client->dev.kobj, &lm95241_group);
427
428 kfree(data);
429 return 0;
430}
431
432/* Driver data (common to all clients) */
433static const struct i2c_device_id lm95241_id[] = {
362 }
363
364 /* Fill the i2c board info */
365 strlcpy(info->type, name, I2C_NAME_SIZE);
366 return 0;
367}
368
369static void lm95241_init_client(struct i2c_client *client)

--- 62 unchanged lines hidden (view full) ---

432 sysfs_remove_group(&client->dev.kobj, &lm95241_group);
433
434 kfree(data);
435 return 0;
436}
437
438/* Driver data (common to all clients) */
439static const struct i2c_device_id lm95241_id[] = {
434 { DEVNAME, 0 },
440 { "lm95231", 0 },
441 { "lm95241", 0 },
435 { }
436};
437MODULE_DEVICE_TABLE(i2c, lm95241_id);
438
439static struct i2c_driver lm95241_driver = {
440 .class = I2C_CLASS_HWMON,
441 .driver = {
442 .name = DEVNAME,

--- 24 unchanged lines hidden ---
442 { }
443};
444MODULE_DEVICE_TABLE(i2c, lm95241_id);
445
446static struct i2c_driver lm95241_driver = {
447 .class = I2C_CLASS_HWMON,
448 .driver = {
449 .name = DEVNAME,

--- 24 unchanged lines hidden ---