lm95241.c (054f3040e47250ba98958175ff4e7ab61dd7725e) lm95241.c (e8172a9381f33b6a4b16871b9149171e0113bfde)
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 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
19
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 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
19
20#include <linux/bitops.h>
20#include <linux/err.h>
21#include <linux/i2c.h>
22#include <linux/init.h>
23#include <linux/jiffies.h>
24#include <linux/hwmon.h>
25#include <linux/hwmon-sysfs.h>
26#include <linux/module.h>
27#include <linux/mutex.h>

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

45#define LM95241_REG_R_REMOTE1_TEMPH 0x11
46#define LM95241_REG_R_REMOTE2_TEMPH 0x12
47#define LM95241_REG_R_LOCAL_TEMPL 0x20
48#define LM95241_REG_R_REMOTE1_TEMPL 0x21
49#define LM95241_REG_R_REMOTE2_TEMPL 0x22
50#define LM95241_REG_RW_REMOTE_MODEL 0x30
51
52/* LM95241 specific bitfields */
21#include <linux/err.h>
22#include <linux/i2c.h>
23#include <linux/init.h>
24#include <linux/jiffies.h>
25#include <linux/hwmon.h>
26#include <linux/hwmon-sysfs.h>
27#include <linux/module.h>
28#include <linux/mutex.h>

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

46#define LM95241_REG_R_REMOTE1_TEMPH 0x11
47#define LM95241_REG_R_REMOTE2_TEMPH 0x12
48#define LM95241_REG_R_LOCAL_TEMPL 0x20
49#define LM95241_REG_R_REMOTE1_TEMPL 0x21
50#define LM95241_REG_R_REMOTE2_TEMPL 0x22
51#define LM95241_REG_RW_REMOTE_MODEL 0x30
52
53/* LM95241 specific bitfields */
53#define CFG_STOP 0x40
54#define CFG_CR0076 0x00
55#define CFG_CR0182 0x10
56#define CFG_CR1000 0x20
57#define CFG_CR2700 0x30
58#define CFG_CRMASK 0x30
59#define R1MS_SHIFT 0
60#define R2MS_SHIFT 2
61#define R1MS_MASK (0x01 << (R1MS_SHIFT))
62#define R2MS_MASK (0x01 << (R2MS_SHIFT))
63#define R1DF_SHIFT 1
64#define R2DF_SHIFT 2
65#define R1DF_MASK (0x01 << (R1DF_SHIFT))
66#define R2DF_MASK (0x01 << (R2DF_SHIFT))
67#define R1FE_MASK 0x01
68#define R2FE_MASK 0x05
69#define R1DM 0x01
70#define R2DM 0x02
71#define TT1_SHIFT 0
72#define TT2_SHIFT 4
73#define TT_OFF 0
74#define TT_ON 1
75#define TT_MASK 7
54#define CFG_STOP BIT(6)
55#define CFG_CR0076 0x00
56#define CFG_CR0182 BIT(4)
57#define CFG_CR1000 BIT(5)
58#define CFG_CR2700 (BIT(4) | BIT(5))
59#define CFG_CRMASK (BIT(4) | BIT(5))
60#define R1MS_MASK BIT(0)
61#define R2MS_MASK BIT(2)
62#define R1DF_MASK BIT(1)
63#define R2DF_MASK BIT(2)
64#define R1FE_MASK BIT(0)
65#define R2FE_MASK BIT(2)
66#define R1DM BIT(0)
67#define R2DM BIT(1)
68#define TT1_SHIFT 0
69#define TT2_SHIFT 4
70#define TT_OFF 0
71#define TT_ON 1
72#define TT_MASK 7
76#define NATSEMI_MAN_ID 0x01
77#define LM95231_CHIP_ID 0xA1
78#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,

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

143/* Sysfs stuff */
144static ssize_t show_input(struct device *dev, struct device_attribute *attr,
145 char *buf)
146{
147 struct lm95241_data *data = lm95241_update_device(dev);
148 int index = to_sensor_dev_attr(attr)->index;
149
150 return snprintf(buf, PAGE_SIZE - 1, "%d\n",
73#define NATSEMI_MAN_ID 0x01
74#define LM95231_CHIP_ID 0xA1
75#define LM95241_CHIP_ID 0xA4
76
77static const u8 lm95241_reg_address[] = {
78 LM95241_REG_R_LOCAL_TEMPH,
79 LM95241_REG_R_LOCAL_TEMPL,
80 LM95241_REG_R_REMOTE1_TEMPH,

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

140/* Sysfs stuff */
141static ssize_t show_input(struct device *dev, struct device_attribute *attr,
142 char *buf)
143{
144 struct lm95241_data *data = lm95241_update_device(dev);
145 int index = to_sensor_dev_attr(attr)->index;
146
147 return snprintf(buf, PAGE_SIZE - 1, "%d\n",
151 index == 0 || (data->config & (1 << (index / 2))) ?
148 index == 0 || (data->config & BIT(index / 2)) ?
152 temp_from_reg_signed(data->temp[index], data->temp[index + 1]) :
153 temp_from_reg_unsigned(data->temp[index],
154 data->temp[index + 1]));
155}
156
157static ssize_t show_type(struct device *dev, struct device_attribute *attr,
158 char *buf)
159{

--- 305 unchanged lines hidden ---
149 temp_from_reg_signed(data->temp[index], data->temp[index + 1]) :
150 temp_from_reg_unsigned(data->temp[index],
151 data->temp[index + 1]));
152}
153
154static ssize_t show_type(struct device *dev, struct device_attribute *attr,
155 char *buf)
156{

--- 305 unchanged lines hidden ---