Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
fb1a2653
Commit
fb1a2653
authored
May 09, 2003
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Plain Diff
Merge kroah.com:/home/greg/linux/BK/bleed-2.5
into kroah.com:/home/greg/linux/BK/i2c-2.5
parents
55f3c6b7
392e687b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
133 additions
and
108 deletions
+133
-108
drivers/i2c/chips/it87.c
drivers/i2c/chips/it87.c
+98
-97
drivers/i2c/i2c-core.c
drivers/i2c/i2c-core.c
+27
-6
include/linux/i2c.h
include/linux/i2c.h
+8
-5
No files found.
drivers/i2c/chips/it87.c
View file @
fb1a2653
...
...
@@ -80,17 +80,17 @@ static int temp_type = 0x2a;
/* Monitors: 9 voltage (0 to 7, battery), 3 temp (1 to 3), 3 fan (1 to 3) */
#define IT87_REG_FAN(nr) (0x0
c
+ (nr))
#define IT87_REG_FAN_MIN(nr) (0x
0f
+ (nr))
#define IT87_REG_FAN(nr) (0x0
d
+ (nr))
#define IT87_REG_FAN_MIN(nr) (0x
10
+ (nr))
#define IT87_REG_FAN_CTRL 0x13
#define IT87_REG_VIN(nr) (0x20 + (nr))
#define IT87_REG_TEMP(nr) (0x2
8
+ (nr))
#define IT87_REG_TEMP(nr) (0x2
9
+ (nr))
#define IT87_REG_VIN_MAX(nr) (0x30 + (nr) * 2)
#define IT87_REG_VIN_MIN(nr) (0x31 + (nr) * 2)
#define IT87_REG_TEMP_HIGH(nr) (0x
3e + (nr) * 2
)
#define IT87_REG_TEMP_LOW(nr) (0x
3f + (nr) * 2
)
#define IT87_REG_TEMP_HIGH(nr) (0x
40 + ((nr) * 2)
)
#define IT87_REG_TEMP_LOW(nr) (0x
41 + ((nr) * 2)
)
#define IT87_REG_I2C_ADDR 0x48
...
...
@@ -99,46 +99,8 @@ static int temp_type = 0x2a;
#define IT87_REG_CHIPID 0x58
static
inline
u8
IN_TO_REG
(
long
val
,
int
inNum
)
{
/* to avoid floating point, we multiply everything by 100.
val is guaranteed to be positive, so we can achieve the effect of
rounding by (...*10+5)/10. Note that the *10 is hidden in the
/250 (which should really be /2500).
At the end, we need to /100 because we *100 everything and we need
to /10 because of the rounding thing, so we /1000. */
if
(
inNum
<=
1
)
return
(
u8
)
SENSORS_LIMIT
(((
val
*
210240
-
13300
)
/
250
+
5
)
/
1000
,
0
,
255
);
else
if
(
inNum
==
2
)
return
(
u8
)
SENSORS_LIMIT
(((
val
*
157370
-
13300
)
/
250
+
5
)
/
1000
,
0
,
255
);
else
if
(
inNum
==
3
)
return
(
u8
)
SENSORS_LIMIT
(((
val
*
101080
-
13300
)
/
250
+
5
)
/
1000
,
0
,
255
);
else
return
(
u8
)
SENSORS_LIMIT
(((
val
*
41714
-
13300
)
/
250
+
5
)
/
1000
,
0
,
255
);
}
static
inline
long
IN_FROM_REG
(
u8
val
,
int
inNum
)
{
/* to avoid floating point, we multiply everything by 100.
val is guaranteed to be positive, so we can achieve the effect of
rounding by adding 0.5. Or, to avoid fp math, we do (...*10+5)/10.
We need to scale with *100 anyway, so no need to /100 at the end. */
if
(
inNum
<=
1
)
return
(
long
)
(((
250000
*
val
+
13300
)
/
210240
*
10
+
5
)
/
10
);
else
if
(
inNum
==
2
)
return
(
long
)
(((
250000
*
val
+
13300
)
/
157370
*
10
+
5
)
/
10
);
else
if
(
inNum
==
3
)
return
(
long
)
(((
250000
*
val
+
13300
)
/
101080
*
10
+
5
)
/
10
);
else
return
(
long
)
(((
250000
*
val
+
13300
)
/
41714
*
10
+
5
)
/
10
);
}
#define IN_TO_REG(val) (SENSORS_LIMIT((((val) * 10 + 8)/16),0,255))
#define IN_FROM_REG(val) (((val) * 16) / 10)
static
inline
u8
FAN_TO_REG
(
long
rpm
,
int
div
)
{
...
...
@@ -159,7 +121,14 @@ static inline u8 FAN_TO_REG(long rpm, int div)
205-(val)*5)
#define ALARMS_FROM_REG(val) (val)
#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)
static
int
log2
(
int
val
)
{
int
answer
=
0
;
while
((
val
>>=
1
))
answer
++
;
return
answer
;
}
#define DIV_TO_REG(val) log2(val)
#define DIV_FROM_REG(val) (1 << (val))
/* Initial limits. Use the config file to set better limits. */
...
...
@@ -272,7 +241,7 @@ static ssize_t show_in(struct device *dev, char *buf, int nr)
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
it87_update_client
(
client
);
return
sprintf
(
buf
,
"%
ld
\n
"
,
IN_FROM_REG
(
data
->
in
[
nr
],
nr
)
*
10
);
return
sprintf
(
buf
,
"%
d
\n
"
,
IN_FROM_REG
(
data
->
in
[
nr
]
)
*
10
);
}
static
ssize_t
show_in_min
(
struct
device
*
dev
,
char
*
buf
,
int
nr
)
...
...
@@ -280,7 +249,7 @@ static ssize_t show_in_min(struct device *dev, char *buf, int nr)
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
it87_update_client
(
client
);
return
sprintf
(
buf
,
"%
ld
\n
"
,
IN_FROM_REG
(
data
->
in_min
[
nr
],
nr
)
*
10
);
return
sprintf
(
buf
,
"%
d
\n
"
,
IN_FROM_REG
(
data
->
in_min
[
nr
]
)
*
10
);
}
static
ssize_t
show_in_max
(
struct
device
*
dev
,
char
*
buf
,
int
nr
)
...
...
@@ -288,7 +257,7 @@ static ssize_t show_in_max(struct device *dev, char *buf, int nr)
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
it87_update_client
(
client
);
return
sprintf
(
buf
,
"%
ld
\n
"
,
IN_FROM_REG
(
data
->
in_max
[
nr
],
nr
)
*
10
);
return
sprintf
(
buf
,
"%
d
\n
"
,
IN_FROM_REG
(
data
->
in_max
[
nr
]
)
*
10
);
}
static
ssize_t
set_in_min
(
struct
device
*
dev
,
const
char
*
buf
,
...
...
@@ -297,7 +266,7 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
unsigned
long
val
=
simple_strtoul
(
buf
,
NULL
,
10
)
/
10
;
data
->
in_min
[
nr
]
=
IN_TO_REG
(
val
,
nr
);
data
->
in_min
[
nr
]
=
IN_TO_REG
(
val
);
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
nr
),
data
->
in_min
[
nr
]);
return
count
;
...
...
@@ -308,7 +277,7 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
unsigned
long
val
=
simple_strtoul
(
buf
,
NULL
,
10
)
/
10
;
data
->
in_max
[
nr
]
=
IN_TO_REG
(
val
,
nr
);
data
->
in_max
[
nr
]
=
IN_TO_REG
(
val
);
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
nr
),
data
->
in_max
[
nr
]);
return
count
;
...
...
@@ -320,6 +289,9 @@ static ssize_t \
{ \
return show_in(dev, buf, 0x##offset); \
} \
static DEVICE_ATTR(in_input##offset, S_IRUGO, show_in##offset, NULL)
#define limit_in_offset(offset) \
static ssize_t \
show_in##offset##_min (struct device *dev, char *buf) \
{ \
...
...
@@ -340,20 +312,27 @@ static ssize_t set_in##offset##_max (struct device *dev, \
{ \
return set_in_max(dev, buf, count, 0x##offset); \
} \
static DEVICE_ATTR(in_input##offset, S_IRUGO, show_in##offset, NULL) \
static DEVICE_ATTR(in_min##offset, S_IRUGO | S_IWUSR, \
show_in##offset##_min, set_in##offset##_min) \
static DEVICE_ATTR(in_max##offset, S_IRUGO | S_IWUSR, \
show_in##offset##_max, set_in##offset##_max)
show_in_offset
(
0
);
limit_in_offset
(
0
);
show_in_offset
(
1
);
limit_in_offset
(
1
);
show_in_offset
(
2
);
limit_in_offset
(
2
);
show_in_offset
(
3
);
limit_in_offset
(
3
);
show_in_offset
(
4
);
limit_in_offset
(
4
);
show_in_offset
(
5
);
limit_in_offset
(
5
);
show_in_offset
(
6
);
limit_in_offset
(
6
);
show_in_offset
(
7
);
limit_in_offset
(
7
);
show_in_offset
(
8
);
/* 3 temperatures */
...
...
@@ -362,7 +341,7 @@ static ssize_t show_temp(struct device *dev, char *buf, int nr)
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
it87_update_client
(
client
);
return
sprintf
(
buf
,
"%d
\n
"
,
TEMP_FROM_REG
(
data
->
temp
[
nr
])
*
10
);
return
sprintf
(
buf
,
"%d
\n
"
,
TEMP_FROM_REG
(
data
->
temp
[
nr
])
*
10
0
);
}
/* more like overshoot temperature */
static
ssize_t
show_temp_max
(
struct
device
*
dev
,
char
*
buf
,
int
nr
)
...
...
@@ -370,7 +349,7 @@ static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
it87_update_client
(
client
);
return
sprintf
(
buf
,
"%d
\n
"
,
TEMP_FROM_REG
(
data
->
temp_high
[
nr
])
*
10
);
return
sprintf
(
buf
,
"%d
\n
"
,
TEMP_FROM_REG
(
data
->
temp_high
[
nr
])
*
10
0
);
}
/* more like hysteresis temperature */
static
ssize_t
show_temp_min
(
struct
device
*
dev
,
char
*
buf
,
int
nr
)
...
...
@@ -378,14 +357,14 @@ static ssize_t show_temp_min(struct device *dev, char *buf, int nr)
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
it87_update_client
(
client
);
return
sprintf
(
buf
,
"%d
\n
"
,
TEMP_FROM_REG
(
data
->
temp_low
[
nr
])
*
10
);
return
sprintf
(
buf
,
"%d
\n
"
,
TEMP_FROM_REG
(
data
->
temp_low
[
nr
])
*
10
0
);
}
static
ssize_t
set_temp_max
(
struct
device
*
dev
,
const
char
*
buf
,
size_t
count
,
int
nr
)
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
int
val
=
simple_strtol
(
buf
,
NULL
,
10
)
/
10
;
int
val
=
simple_strtol
(
buf
,
NULL
,
10
)
/
10
0
;
data
->
temp_high
[
nr
]
=
TEMP_TO_REG
(
val
);
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
nr
),
data
->
temp_high
[
nr
]);
return
count
;
...
...
@@ -395,7 +374,7 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
{
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
int
val
=
simple_strtol
(
buf
,
NULL
,
10
)
/
10
;
int
val
=
simple_strtol
(
buf
,
NULL
,
10
)
/
10
0
;
data
->
temp_low
[
nr
]
=
TEMP_TO_REG
(
val
);
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
nr
),
data
->
temp_low
[
nr
]);
return
count
;
...
...
@@ -511,7 +490,7 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
int
val
=
simple_strtol
(
buf
,
NULL
,
10
);
data
->
fan_min
[
nr
]
=
FAN_TO_REG
(
val
,
DIV_FROM_REG
(
data
->
fan_div
[
nr
]));
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
nr
+
1
),
data
->
fan_min
[
nr
]);
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
nr
),
data
->
fan_min
[
nr
]);
return
count
;
}
static
ssize_t
set_fan_div
(
struct
device
*
dev
,
const
char
*
buf
,
...
...
@@ -520,10 +499,34 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
struct
i2c_client
*
client
=
to_i2c_client
(
dev
);
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
int
val
=
simple_strtol
(
buf
,
NULL
,
10
);
int
old
=
it87_read_value
(
client
,
IT87_REG_FAN_DIV
);
data
->
fan_div
[
nr
]
=
DIV_TO_REG
(
val
);
old
=
(
old
&
0x0f
)
|
(
data
->
fan_div
[
1
]
<<
6
)
|
(
data
->
fan_div
[
0
]
<<
4
);
it87_write_value
(
client
,
IT87_REG_FAN_DIV
,
old
);
int
i
,
min
[
3
];
u8
old
=
it87_read_value
(
client
,
IT87_REG_FAN_DIV
);
for
(
i
=
0
;
i
<
3
;
i
++
)
min
[
i
]
=
FAN_FROM_REG
(
data
->
fan_min
[
i
],
DIV_FROM_REG
(
data
->
fan_div
[
i
]));
switch
(
nr
)
{
case
0
:
case
1
:
data
->
fan_div
[
nr
]
=
DIV_TO_REG
(
val
);
break
;
case
2
:
if
(
val
<
8
)
data
->
fan_div
[
nr
]
=
1
;
else
data
->
fan_div
[
nr
]
=
3
;
}
val
=
old
&
0x100
;
val
|=
(
data
->
fan_div
[
0
]
&
0x07
);
val
|=
(
data
->
fan_div
[
1
]
&
0x07
)
<<
3
;
if
(
data
->
fan_div
[
2
]
==
3
)
val
|=
0x1
<<
6
;
it87_write_value
(
client
,
IT87_REG_FAN_DIV
,
val
);
for
(
i
=
0
;
i
<
3
;
i
++
)
{
data
->
fan_min
[
i
]
=
FAN_TO_REG
(
min
[
i
],
DIV_FROM_REG
(
data
->
fan_div
[
i
]));
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
i
),
data
->
fan_min
[
i
]);
}
return
count
;
}
...
...
@@ -720,7 +723,6 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_min5
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_min6
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_min7
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_min8
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_max0
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_max1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_max2
);
...
...
@@ -729,7 +731,6 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_max5
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_max6
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_max7
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_max8
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp_input1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp_input2
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp_input3
);
...
...
@@ -833,55 +834,55 @@ static void it87_init_client(struct i2c_client *client, struct it87_data *data)
This sets fan-divs to 2, among others */
it87_write_value
(
client
,
IT87_REG_CONFIG
,
0x80
);
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
0
),
IN_TO_REG
(
IT87_INIT_IN_MIN_0
,
0
));
IN_TO_REG
(
IT87_INIT_IN_MIN_0
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
0
),
IN_TO_REG
(
IT87_INIT_IN_MAX_0
,
0
));
IN_TO_REG
(
IT87_INIT_IN_MAX_0
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
1
),
IN_TO_REG
(
IT87_INIT_IN_MIN_1
,
1
));
IN_TO_REG
(
IT87_INIT_IN_MIN_1
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
1
),
IN_TO_REG
(
IT87_INIT_IN_MAX_1
,
1
));
IN_TO_REG
(
IT87_INIT_IN_MAX_1
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
2
),
IN_TO_REG
(
IT87_INIT_IN_MIN_2
,
2
));
IN_TO_REG
(
IT87_INIT_IN_MIN_2
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
2
),
IN_TO_REG
(
IT87_INIT_IN_MAX_2
,
2
));
IN_TO_REG
(
IT87_INIT_IN_MAX_2
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
3
),
IN_TO_REG
(
IT87_INIT_IN_MIN_3
,
3
));
IN_TO_REG
(
IT87_INIT_IN_MIN_3
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
3
),
IN_TO_REG
(
IT87_INIT_IN_MAX_3
,
3
));
IN_TO_REG
(
IT87_INIT_IN_MAX_3
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
4
),
IN_TO_REG
(
IT87_INIT_IN_MIN_4
,
4
));
IN_TO_REG
(
IT87_INIT_IN_MIN_4
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
4
),
IN_TO_REG
(
IT87_INIT_IN_MAX_4
,
4
));
IN_TO_REG
(
IT87_INIT_IN_MAX_4
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
5
),
IN_TO_REG
(
IT87_INIT_IN_MIN_5
,
5
));
IN_TO_REG
(
IT87_INIT_IN_MIN_5
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
5
),
IN_TO_REG
(
IT87_INIT_IN_MAX_5
,
5
));
IN_TO_REG
(
IT87_INIT_IN_MAX_5
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
6
),
IN_TO_REG
(
IT87_INIT_IN_MIN_6
,
6
));
IN_TO_REG
(
IT87_INIT_IN_MIN_6
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
6
),
IN_TO_REG
(
IT87_INIT_IN_MAX_6
,
6
));
IN_TO_REG
(
IT87_INIT_IN_MAX_6
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
7
),
IN_TO_REG
(
IT87_INIT_IN_MIN_7
,
7
));
IN_TO_REG
(
IT87_INIT_IN_MIN_7
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
7
),
IN_TO_REG
(
IT87_INIT_IN_MAX_7
,
7
));
IN_TO_REG
(
IT87_INIT_IN_MAX_7
));
/* Note: Battery voltage does not have limit registers */
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
1
),
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
0
),
FAN_TO_REG
(
IT87_INIT_FAN_MIN_1
,
2
));
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
2
),
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
1
),
FAN_TO_REG
(
IT87_INIT_FAN_MIN_2
,
2
));
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
3
),
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
2
),
FAN_TO_REG
(
IT87_INIT_FAN_MIN_3
,
2
));
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
1
),
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
0
),
TEMP_TO_REG
(
IT87_INIT_TEMP_HIGH_1
));
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
1
),
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
0
),
TEMP_TO_REG
(
IT87_INIT_TEMP_LOW_1
));
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
2
),
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
1
),
TEMP_TO_REG
(
IT87_INIT_TEMP_HIGH_2
));
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
2
),
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
1
),
TEMP_TO_REG
(
IT87_INIT_TEMP_LOW_2
));
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
3
),
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
2
),
TEMP_TO_REG
(
IT87_INIT_TEMP_HIGH_3
));
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
3
),
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
2
),
TEMP_TO_REG
(
IT87_INIT_TEMP_LOW_3
));
/* Enable voltage monitors */
...
...
@@ -934,18 +935,18 @@ static void it87_update_client(struct i2c_client *client)
data
->
in_min
[
8
]
=
0
;
data
->
in_max
[
8
]
=
255
;
for
(
i
=
1
;
i
<=
3
;
i
++
)
{
data
->
fan
[
i
-
1
]
=
for
(
i
=
0
;
i
<
3
;
i
++
)
{
data
->
fan
[
i
]
=
it87_read_value
(
client
,
IT87_REG_FAN
(
i
));
data
->
fan_min
[
i
-
1
]
=
data
->
fan_min
[
i
]
=
it87_read_value
(
client
,
IT87_REG_FAN_MIN
(
i
));
}
for
(
i
=
1
;
i
<=
3
;
i
++
)
{
data
->
temp
[
i
-
1
]
=
for
(
i
=
0
;
i
<
3
;
i
++
)
{
data
->
temp
[
i
]
=
it87_read_value
(
client
,
IT87_REG_TEMP
(
i
));
data
->
temp_high
[
i
-
1
]
=
data
->
temp_high
[
i
]
=
it87_read_value
(
client
,
IT87_REG_TEMP_HIGH
(
i
));
data
->
temp_low
[
i
-
1
]
=
data
->
temp_low
[
i
]
=
it87_read_value
(
client
,
IT87_REG_TEMP_LOW
(
i
));
}
...
...
@@ -961,7 +962,7 @@ static void it87_update_client(struct i2c_client *client)
i
=
it87_read_value
(
client
,
IT87_REG_FAN_DIV
);
data
->
fan_div
[
0
]
=
i
&
0x07
;
data
->
fan_div
[
1
]
=
(
i
>>
3
)
&
0x07
;
data
->
fan_div
[
2
]
=
1
;
data
->
fan_div
[
2
]
=
(
i
&
0x40
)
?
3
:
1
;
data
->
alarms
=
it87_read_value
(
client
,
IT87_REG_ALARM1
)
|
...
...
drivers/i2c/i2c-core.c
View file @
fb1a2653
...
...
@@ -55,13 +55,17 @@ int i2c_device_remove(struct device *dev)
return
0
;
}
static
struct
device_driver
i2c_
generic
_driver
=
{
.
name
=
"i2c"
,
static
struct
device_driver
i2c_
adapter
_driver
=
{
.
name
=
"i2c
_adapter
"
,
.
bus
=
&
i2c_bus_type
,
.
probe
=
i2c_device_probe
,
.
remove
=
i2c_device_remove
,
};
static
struct
class
i2c_adapter_class
=
{
.
name
=
"i2c-adapter"
};
/* ---------------------------------------------------
* registering functions
...
...
@@ -94,9 +98,16 @@ int i2c_add_adapter(struct i2c_adapter *adap)
if
(
adap
->
dev
.
parent
==
NULL
)
adap
->
dev
.
parent
=
&
legacy_bus
;
sprintf
(
adap
->
dev
.
bus_id
,
"i2c-%d"
,
adap
->
nr
);
adap
->
dev
.
driver
=
&
i2c_
generic
_driver
;
adap
->
dev
.
driver
=
&
i2c_
adapter
_driver
;
device_register
(
&
adap
->
dev
);
/* Add this adapter to the i2c_adapter class */
memset
(
&
adap
->
class_dev
,
0x00
,
sizeof
(
struct
class_device
));
adap
->
class_dev
.
dev
=
&
adap
->
dev
;
adap
->
class_dev
.
class
=
&
i2c_adapter_class
;
strncpy
(
adap
->
class_dev
.
class_id
,
adap
->
dev
.
bus_id
,
BUS_ID_SIZE
);
class_device_register
(
&
adap
->
class_dev
);
/* inform drivers of new adapters */
list_for_each
(
item
,
&
drivers
)
{
driver
=
list_entry
(
item
,
struct
i2c_driver
,
list
);
...
...
@@ -150,6 +161,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
}
/* clean up the sysfs representation */
class_device_unregister
(
&
adap
->
class_dev
);
device_unregister
(
&
adap
->
dev
);
list_del
(
&
adap
->
list
);
...
...
@@ -443,14 +455,23 @@ struct bus_type i2c_bus_type = {
.
match
=
i2c_device_match
,
};
static
int
__init
i2c_init
(
void
)
{
return
bus_register
(
&
i2c_bus_type
);
int
retval
;
retval
=
bus_register
(
&
i2c_bus_type
);
if
(
retval
)
return
retval
;
retval
=
driver_register
(
&
i2c_adapter_driver
);
if
(
retval
)
return
retval
;
return
class_register
(
&
i2c_adapter_class
);
}
static
void
__exit
i2c_exit
(
void
)
{
class_unregister
(
&
i2c_adapter_class
);
driver_unregister
(
&
i2c_adapter_driver
);
bus_unregister
(
&
i2c_bus_type
);
}
...
...
@@ -475,7 +496,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg msgs[],int num)
return
ret
;
}
else
{
dev_err
(
&
adap
->
dev
,
"I2C level transfers not supported
\n
"
);
DEB2
(
dev_dbg
(
&
adap
->
dev
,
"I2C level transfers not supported
\n
"
)
);
return
-
ENOSYS
;
}
}
...
...
include/linux/i2c.h
View file @
fb1a2653
...
...
@@ -240,7 +240,8 @@ struct i2c_adapter {
int
timeout
;
int
retries
;
struct
device
dev
;
/* the adapter device */
struct
device
dev
;
/* the adapter device */
struct
class_device
class_dev
;
/* the class device */
#ifdef CONFIG_PROC_FS
/* No need to set this when you initialize the adapter */
...
...
@@ -280,10 +281,12 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
/* Must equal I2C_M_TEN below */
/* i2c adapter classes (bitmask) */
#define I2C_ADAP_CLASS_SMBUS (1<<0)
/* lm_sensors, ... */
#define I2C_ADAP_CLASS_TV_ANALOG (1<<1)
/* bttv + friends */
#define I2C_ADAP_CLASS_TV_DIGINAL (1<<2)
/* dbv cards */
#define I2C_ADAP_CLASS_DDC (1<<3)
/* i2c-matroxfb ? */
#define I2C_ADAP_CLASS_SMBUS (1<<0)
/* lm_sensors, ... */
#define I2C_ADAP_CLASS_TV_ANALOG (1<<1)
/* bttv + friends */
#define I2C_ADAP_CLASS_TV_DIGITAL (1<<2)
/* dbv cards */
#define I2C_ADAP_CLASS_DDC (1<<3)
/* i2c-matroxfb ? */
#define I2C_ADAP_CLASS_CAM_ANALOG (1<<4)
/* camera with analog CCD */
#define I2C_ADAP_CLASS_CAM_DIGITAL (1<<5)
/* most webcams */
/* i2c_client_address_data is the struct for holding default client
* addresses for a driver and for the parameters supplied on the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment