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
nexedi
linux
Commits
c3efc929
Commit
c3efc929
authored
Apr 24, 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
00ed39d3
36a113db
Changes
24
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
1190 additions
and
491 deletions
+1190
-491
drivers/i2c/busses/i2c-viapro.c
drivers/i2c/busses/i2c-viapro.c
+149
-172
drivers/i2c/chips/Kconfig
drivers/i2c/chips/Kconfig
+12
-2
drivers/i2c/chips/Makefile
drivers/i2c/chips/Makefile
+1
-0
drivers/i2c/chips/adm1021.c
drivers/i2c/chips/adm1021.c
+4
-126
drivers/i2c/chips/it87.c
drivers/i2c/chips/it87.c
+924
-0
drivers/i2c/chips/lm75.c
drivers/i2c/chips/lm75.c
+4
-4
drivers/i2c/chips/via686a.c
drivers/i2c/chips/via686a.c
+4
-4
drivers/i2c/chips/w83781d.c
drivers/i2c/chips/w83781d.c
+5
-5
drivers/i2c/i2c-core.c
drivers/i2c/i2c-core.c
+4
-4
drivers/i2c/i2c-sensor.c
drivers/i2c/i2c-sensor.c
+17
-29
drivers/media/video/msp3400.c
drivers/media/video/msp3400.c
+2
-4
drivers/media/video/saa5249.c
drivers/media/video/saa5249.c
+1
-1
drivers/media/video/saa7111.c
drivers/media/video/saa7111.c
+1
-1
drivers/media/video/tda7432.c
drivers/media/video/tda7432.c
+1
-2
drivers/media/video/tda9840.c
drivers/media/video/tda9840.c
+1
-1
drivers/media/video/tda9875.c
drivers/media/video/tda9875.c
+1
-2
drivers/media/video/tda9887.c
drivers/media/video/tda9887.c
+1
-2
drivers/media/video/tea6415c.c
drivers/media/video/tea6415c.c
+1
-1
drivers/media/video/tea6420.c
drivers/media/video/tea6420.c
+1
-1
drivers/media/video/tuner-3036.c
drivers/media/video/tuner-3036.c
+1
-2
drivers/media/video/tuner.c
drivers/media/video/tuner.c
+1
-2
drivers/media/video/tvaudio.c
drivers/media/video/tvaudio.c
+1
-2
include/linux/i2c-sensor.h
include/linux/i2c-sensor.h
+39
-113
include/linux/i2c.h
include/linux/i2c.h
+14
-11
No files found.
drivers/i2c/busses/i2c-viapro.c
View file @
c3efc929
...
...
@@ -47,18 +47,19 @@
#define SMBBA3 0xD0
/* SMBus address offsets */
#define SMBHSTSTS (0 + vt596_smba)
#define SMBHSLVSTS (1 + vt596_smba)
#define SMBHSTCNT (2 + vt596_smba)
#define SMBHSTCMD (3 + vt596_smba)
#define SMBHSTADD (4 + vt596_smba)
#define SMBHSTDAT0 (5 + vt596_smba)
#define SMBHSTDAT1 (6 + vt596_smba)
#define SMBBLKDAT (7 + vt596_smba)
#define SMBSLVCNT (8 + vt596_smba)
#define SMBSHDWCMD (9 + vt596_smba)
#define SMBSLVEVT (0xA + vt596_smba)
#define SMBSLVDAT (0xC + vt596_smba)
static
unsigned
short
vt596_smba
;
#define SMBHSTSTS (vt596_smba + 0)
#define SMBHSLVSTS (vt596_smba + 1)
#define SMBHSTCNT (vt596_smba + 2)
#define SMBHSTCMD (vt596_smba + 3)
#define SMBHSTADD (vt596_smba + 4)
#define SMBHSTDAT0 (vt596_smba + 5)
#define SMBHSTDAT1 (vt596_smba + 6)
#define SMBBLKDAT (vt596_smba + 7)
#define SMBSLVCNT (vt596_smba + 8)
#define SMBSHDWCMD (vt596_smba + 9)
#define SMBSLVEVT (vt596_smba + 0xA)
#define SMBSLVDAT (vt596_smba + 0xC)
/* PCI Address Constants */
...
...
@@ -68,10 +69,10 @@
static
unsigned
short
smb_cf_hstcfg
=
0xD2
;
#define SMBHSTCFG (smb_cf_hstcfg)
#define SMBSLVC (
SMBHSTCFG+
1)
#define SMBSHDW1 (
SMBHSTCFG+
2)
#define SMBSHDW2 (
SMBHSTCFG+
3)
#define SMBREV (
SMBHSTCFG+
4)
#define SMBSLVC (
smb_cf_hstcfg +
1)
#define SMBSHDW1 (
smb_cf_hstcfg +
2)
#define SMBSHDW2 (
smb_cf_hstcfg +
3)
#define SMBREV (
smb_cf_hstcfg +
4)
/* Other settings */
#define MAX_TIMEOUT 500
...
...
@@ -84,144 +85,33 @@ static unsigned short smb_cf_hstcfg = 0xD2;
#define VT596_WORD_DATA 0x0C
#define VT596_BLOCK_DATA 0x14
/* insmod parameters */
/* If force is set to anything different from 0, we forcibly enable the
VT596. DANGEROUS! */
static
int
force
=
0
;
static
int
force
;
MODULE_PARM
(
force
,
"i"
);
MODULE_PARM_DESC
(
force
,
"Forcibly enable the SMBus. DANGEROUS!"
);
/* If force_addr is set to anything different from 0, we forcibly enable
the VT596 at the given address. VERY DANGEROUS! */
static
int
force_addr
=
0
;
static
int
force_addr
;
MODULE_PARM
(
force_addr
,
"i"
);
MODULE_PARM_DESC
(
force_addr
,
"Forcibly enable the SMBus at the given address. "
"EXTREMELY DANGEROUS!"
);
static
void
vt596_do_pause
(
unsigned
int
amount
);
static
int
vt596_transaction
(
void
);
s32
vt596_access
(
struct
i2c_adapter
*
adap
,
u16
addr
,
unsigned
short
flags
,
char
read_write
,
u8
command
,
int
size
,
union
i2c_smbus_data
*
data
);
u32
vt596_func
(
struct
i2c_adapter
*
adapter
);
static
struct
i2c_algorithm
smbus_algorithm
=
{
.
name
=
"Non-I2C SMBus adapter"
,
.
id
=
I2C_ALGO_SMBUS
,
.
smbus_xfer
=
vt596_access
,
.
functionality
=
vt596_func
,
};
static
struct
i2c_adapter
vt596_adapter
=
{
.
owner
=
THIS_MODULE
,
.
id
=
I2C_ALGO_SMBUS
|
I2C_HW_SMBUS_VIA2
,
.
algo
=
&
smbus_algorithm
,
.
dev
=
{
.
name
=
"unset"
,
},
};
static
unsigned
short
vt596_smba
=
0
;
/* Detect whether a compatible device can be found, and initialize it. */
int
vt596_setup
(
struct
pci_dev
*
VT596_dev
,
struct
pci_device_id
const
*
id
)
{
unsigned
char
temp
;
dev_info
(
&
VT596_dev
->
dev
,
"Found Via %s device
\n
"
,
VT596_dev
->
dev
.
name
);
/* Determine the address of the SMBus areas */
if
(
force_addr
)
{
vt596_smba
=
force_addr
&
0xfff0
;
force
=
0
;
}
else
{
if
((
pci_read_config_word
(
VT596_dev
,
id
->
driver_data
,
&
vt596_smba
))
||
!
(
vt596_smba
&
0x1
))
{
/* try 2nd address and config reg. for 596 */
if
((
id
->
device
==
PCI_DEVICE_ID_VIA_82C596_3
)
&&
(
!
pci_read_config_word
(
VT596_dev
,
SMBBA2
,
&
vt596_smba
))
&&
(
vt596_smba
&
0x1
))
{
smb_cf_hstcfg
=
0x84
;
}
else
{
/* no matches at all */
dev_err
(
&
VT596_dev
->
dev
,
"Cannot configure "
"SMBus I/O Base address
\n
"
);
return
(
-
ENODEV
);
}
}
vt596_smba
&=
0xfff0
;
if
(
vt596_smba
==
0
)
{
dev_err
(
&
VT596_dev
->
dev
,
"SMBus base address "
"uninitialized - upgrade BIOS or use "
"force_addr=0xaddr
\n
"
);
return
-
ENODEV
;
}
}
if
(
!
request_region
(
vt596_smba
,
8
,
"viapro-smbus"
))
{
dev_err
(
&
VT596_dev
->
dev
,
"SMBus region 0x%x already in use!
\n
"
,
vt596_smba
);
return
(
-
ENODEV
);
}
pci_read_config_byte
(
VT596_dev
,
SMBHSTCFG
,
&
temp
);
/* If force_addr is set, we program the new address here. Just to make
sure, we disable the VT596 first. */
if
(
force_addr
)
{
pci_write_config_byte
(
VT596_dev
,
SMBHSTCFG
,
temp
&
0xfe
);
pci_write_config_word
(
VT596_dev
,
id
->
driver_data
,
vt596_smba
);
pci_write_config_byte
(
VT596_dev
,
SMBHSTCFG
,
temp
|
0x01
);
dev_warn
(
&
VT596_dev
->
dev
,
"WARNING: SMBus interface set to new "
"address 0x%04x!
\n
"
,
vt596_smba
);
}
else
if
((
temp
&
1
)
==
0
)
{
if
(
force
)
{
/* NOTE: This assumes I/O space and other allocations
* WERE done by the Bios! Don't complain if your
* hardware does weird things after enabling this.
* :') Check for Bios updates before resorting to
* this.
*/
pci_write_config_byte
(
VT596_dev
,
SMBHSTCFG
,
temp
|
1
);
dev_info
(
&
VT596_dev
->
dev
,
"Enabling SMBus device
\n
"
);
}
else
{
dev_err
(
&
VT596_dev
->
dev
,
"SMBUS: Error: Host SMBus "
"controller not enabled! - upgrade BIOS or "
"use force=1
\n
"
);
return
(
-
ENODEV
);
}
}
if
((
temp
&
0x0E
)
==
8
)
dev_dbg
(
&
VT596_dev
->
dev
,
"using Interrupt 9 for SMBus.
\n
"
);
else
if
((
temp
&
0x0E
)
==
0
)
dev_dbg
(
&
VT596_dev
->
dev
,
"using Interrupt SMI# for SMBus.
\n
"
);
else
dev_dbg
(
&
VT596_dev
->
dev
,
"Illegal Interrupt configuration "
"(or code out of date)!
\n
"
);
pci_read_config_byte
(
VT596_dev
,
SMBREV
,
&
temp
);
dev_dbg
(
&
VT596_dev
->
dev
,
"SMBREV = 0x%X
\n
"
,
temp
);
dev_dbg
(
&
VT596_dev
->
dev
,
"VT596_smba = 0x%X
\n
"
,
vt596_smba
);
return
(
0
);
}
static
struct
i2c_adapter
vt596_adapter
;
/* Internally used pause function */
void
vt596_do_pause
(
unsigned
int
amount
)
static
void
vt596_do_pause
(
unsigned
int
amount
)
{
current
->
state
=
TASK_INTERRUPTIBLE
;
schedule_timeout
(
amount
);
}
/* Another internally used function */
int
vt596_transaction
(
void
)
static
int
vt596_transaction
(
void
)
{
int
temp
;
int
result
=
0
;
...
...
@@ -296,15 +186,16 @@ int vt596_transaction(void)
}
/* Return -1 on error. */
s
32
vt596_access
(
struct
i2c_adapter
*
adap
,
u16
addr
,
unsigned
short
flags
,
char
read_write
,
u8
command
,
int
size
,
union
i2c_smbus_data
*
data
)
s
tatic
s32
vt596_access
(
struct
i2c_adapter
*
adap
,
u16
addr
,
unsigned
short
flags
,
char
read_write
,
u8
command
,
int
size
,
union
i2c_smbus_data
*
data
)
{
int
i
,
len
;
switch
(
size
)
{
case
I2C_SMBUS_PROC_CALL
:
dev_info
(
&
vt596_adapter
.
dev
,
"I2C_SMBUS_PROC_CALL not supported!
\n
"
);
dev_info
(
&
vt596_adapter
.
dev
,
"I2C_SMBUS_PROC_CALL not supported!
\n
"
);
return
-
1
;
case
I2C_SMBUS_QUICK
:
outb_p
(((
addr
&
0x7f
)
<<
1
)
|
(
read_write
&
0x01
),
...
...
@@ -363,7 +254,6 @@ s32 vt596_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
if
((
read_write
==
I2C_SMBUS_WRITE
)
||
(
size
==
VT596_QUICK
))
return
0
;
switch
(
size
)
{
case
VT596_BYTE
:
/* Where is the result put? I assume here it is in
...
...
@@ -388,15 +278,127 @@ s32 vt596_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
return
0
;
}
u32
vt596_func
(
struct
i2c_adapter
*
adapter
)
static
u32
vt596_func
(
struct
i2c_adapter
*
adapter
)
{
return
I2C_FUNC_SMBUS_QUICK
|
I2C_FUNC_SMBUS_BYTE
|
I2C_FUNC_SMBUS_BYTE_DATA
|
I2C_FUNC_SMBUS_WORD_DATA
|
I2C_FUNC_SMBUS_BLOCK_DATA
;
}
static
struct
i2c_algorithm
smbus_algorithm
=
{
.
name
=
"Non-I2C SMBus adapter"
,
.
id
=
I2C_ALGO_SMBUS
,
.
smbus_xfer
=
vt596_access
,
.
functionality
=
vt596_func
,
};
static
struct
i2c_adapter
vt596_adapter
=
{
.
owner
=
THIS_MODULE
,
.
id
=
I2C_ALGO_SMBUS
|
I2C_HW_SMBUS_VIA2
,
.
algo
=
&
smbus_algorithm
,
.
dev
=
{
.
name
=
"unset"
,
},
};
static
int
__devinit
vt596_probe
(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
id
)
{
unsigned
char
temp
;
int
error
=
-
ENODEV
;
/* Determine the address of the SMBus areas */
if
(
force_addr
)
{
vt596_smba
=
force_addr
&
0xfff0
;
force
=
0
;
goto
found
;
}
if
((
pci_read_config_word
(
pdev
,
id
->
driver_data
,
&
vt596_smba
))
||
!
(
vt596_smba
&
0x1
))
{
/* try 2nd address and config reg. for 596 */
if
(
id
->
device
==
PCI_DEVICE_ID_VIA_82C596_3
&&
!
pci_read_config_word
(
pdev
,
SMBBA2
,
&
vt596_smba
)
&&
(
vt596_smba
&
0x1
))
{
smb_cf_hstcfg
=
0x84
;
}
else
{
/* no matches at all */
dev_err
(
&
pdev
->
dev
,
"Cannot configure "
"SMBus I/O Base address
\n
"
);
return
-
ENODEV
;
}
}
vt596_smba
&=
0xfff0
;
if
(
vt596_smba
==
0
)
{
dev_err
(
&
pdev
->
dev
,
"SMBus base address "
"uninitialized - upgrade BIOS or use "
"force_addr=0xaddr
\n
"
);
return
-
ENODEV
;
}
found:
if
(
!
request_region
(
vt596_smba
,
8
,
"viapro-smbus"
))
{
dev_err
(
&
pdev
->
dev
,
"SMBus region 0x%x already in use!
\n
"
,
vt596_smba
);
return
-
ENODEV
;
}
pci_read_config_byte
(
pdev
,
SMBHSTCFG
,
&
temp
);
/* If force_addr is set, we program the new address here. Just to make
sure, we disable the VT596 first. */
if
(
force_addr
)
{
pci_write_config_byte
(
pdev
,
SMBHSTCFG
,
temp
&
0xfe
);
pci_write_config_word
(
pdev
,
id
->
driver_data
,
vt596_smba
);
pci_write_config_byte
(
pdev
,
SMBHSTCFG
,
temp
|
0x01
);
dev_warn
(
&
pdev
->
dev
,
"WARNING: SMBus interface set to new "
"address 0x%04x!
\n
"
,
vt596_smba
);
}
else
if
((
temp
&
1
)
==
0
)
{
if
(
force
)
{
/* NOTE: This assumes I/O space and other allocations
* WERE done by the Bios! Don't complain if your
* hardware does weird things after enabling this.
* :') Check for Bios updates before resorting to
* this.
*/
pci_write_config_byte
(
pdev
,
SMBHSTCFG
,
temp
|
1
);
dev_info
(
&
pdev
->
dev
,
"Enabling SMBus device
\n
"
);
}
else
{
dev_err
(
&
pdev
->
dev
,
"SMBUS: Error: Host SMBus "
"controller not enabled! - upgrade BIOS or "
"use force=1
\n
"
);
goto
release_region
;
}
}
if
((
temp
&
0x0E
)
==
8
)
dev_dbg
(
&
pdev
->
dev
,
"using Interrupt 9 for SMBus.
\n
"
);
else
if
((
temp
&
0x0E
)
==
0
)
dev_dbg
(
&
pdev
->
dev
,
"using Interrupt SMI# for SMBus.
\n
"
);
else
dev_dbg
(
&
pdev
->
dev
,
"Illegal Interrupt configuration "
"(or code out of date)!
\n
"
);
pci_read_config_byte
(
pdev
,
SMBREV
,
&
temp
);
dev_dbg
(
&
pdev
->
dev
,
"SMBREV = 0x%X
\n
"
,
temp
);
dev_dbg
(
&
pdev
->
dev
,
"VT596_smba = 0x%X
\n
"
,
vt596_smba
);
vt596_adapter
.
dev
.
parent
=
&
pdev
->
dev
;
snprintf
(
vt596_adapter
.
dev
.
name
,
DEVICE_NAME_SIZE
,
"SMBus Via Pro adapter at %04x"
,
vt596_smba
);
return
i2c_add_adapter
(
&
vt596_adapter
);
release_region:
release_region
(
vt596_smba
,
8
);
return
error
;
}
static
void
__devexit
vt596_remove
(
struct
pci_dev
*
pdev
)
{
i2c_del_adapter
(
&
vt596_adapter
);
release_region
(
vt596_smba
,
8
);
}
static
struct
pci_device_id
vt596_ids
[]
__devinitdata
=
{
{
...
...
@@ -451,29 +453,6 @@ static struct pci_device_id vt596_ids[] __devinitdata = {
{
0
,
}
};
static
int
__devinit
vt596_probe
(
struct
pci_dev
*
dev
,
const
struct
pci_device_id
*
id
)
{
int
retval
;
retval
=
vt596_setup
(
dev
,
id
);
if
(
retval
)
return
retval
;
vt596_adapter
.
dev
.
parent
=
&
dev
->
dev
;
snprintf
(
vt596_adapter
.
dev
.
name
,
DEVICE_NAME_SIZE
,
"SMBus Via Pro adapter at %04x"
,
vt596_smba
);
retval
=
i2c_add_adapter
(
&
vt596_adapter
);
return
retval
;
}
static
void
__devexit
vt596_remove
(
struct
pci_dev
*
dev
)
{
i2c_del_adapter
(
&
vt596_adapter
);
}
static
struct
pci_driver
vt596_driver
=
{
.
name
=
"vt596 smbus"
,
.
id_table
=
vt596_ids
,
...
...
@@ -490,14 +469,12 @@ static int __init i2c_vt596_init(void)
static
void
__exit
i2c_vt596_exit
(
void
)
{
pci_unregister_driver
(
&
vt596_driver
);
release_region
(
vt596_smba
,
8
);
}
MODULE_AUTHOR
(
"Frodo Looijaard <frodol@dds.nl> and
Philip Edelbrock <phil@netroedge.com>"
);
MODULE_AUTHOR
(
"Frodo Looijaard <frodol@dds.nl> and "
"
Philip Edelbrock <phil@netroedge.com>"
);
MODULE_DESCRIPTION
(
"vt82c596 SMBus driver"
);
MODULE_LICENSE
(
"GPL"
);
module_init
(
i2c_vt596_init
);
...
...
drivers/i2c/chips/Kconfig
View file @
c3efc929
...
...
@@ -22,6 +22,16 @@ config SENSORS_ADM1021
in the lm_sensors package, which you can download at
http://www.lm-sensors.nu
config SENSORS_IT87
tristate " National Semiconductors IT87 and compatibles"
depends on I2C && EXPERIMENTAL
help
The module will be called it87.
You will also need the latest user-space utilties: you can find them
in the lm_sensors package, which you can download at
http://www.lm-sensors.nu
config SENSORS_LM75
tristate " National Semiconductors LM75 and compatibles"
depends on I2C && EXPERIMENTAL
...
...
@@ -66,8 +76,8 @@ config SENSORS_W83781D
config I2C_SENSOR
tristate
default y if SENSORS_ADM1021=y || SENSORS_LM75=y || SENSORS_VIA686A=y || SENSORS_W83781D=y
default m if SENSORS_ADM1021=m || SENSORS_LM75=m || SENSORS_VIA686A=m || SENSORS_W83781D=m
default y if SENSORS_ADM1021=y || SENSORS_
IT87=y || SENSORS_
LM75=y || SENSORS_VIA686A=y || SENSORS_W83781D=y
default m if SENSORS_ADM1021=m || SENSORS_
IT87=m || SENSORS_
LM75=m || SENSORS_VIA686A=m || SENSORS_W83781D=m
default n
endmenu
drivers/i2c/chips/Makefile
View file @
c3efc929
...
...
@@ -3,6 +3,7 @@
#
obj-$(CONFIG_SENSORS_ADM1021)
+=
adm1021.o
obj-$(CONFIG_SENSORS_IT87)
+=
it87.o
obj-$(CONFIG_SENSORS_LM75)
+=
lm75.o
obj-$(CONFIG_SENSORS_VIA686A)
+=
via686a.o
obj-$(CONFIG_SENSORS_W83781D)
+=
w83781d.o
drivers/i2c/chips/adm1021.c
View file @
c3efc929
...
...
@@ -39,12 +39,12 @@
#define ADM1021_ALARM_RTEMP_NA 0x04
/* Addresses to scan */
static
unsigned
short
normal_i2c
[]
=
{
SENSORS_I2C
_END
};
static
unsigned
short
normal_i2c
[]
=
{
I2C_CLIENT
_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
0x18
,
0x1a
,
0x29
,
0x2b
,
0x4c
,
0x4e
,
SENSORS_I2C
_END
0x4c
,
0x4e
,
I2C_CLIENT
_END
};
static
unsigned
int
normal_isa
[]
=
{
SENSORS
_ISA_END
};
static
unsigned
int
normal_isa_range
[]
=
{
SENSORS
_ISA_END
};
static
unsigned
int
normal_isa
[]
=
{
I2C_CLIENT
_ISA_END
};
static
unsigned
int
normal_isa_range
[]
=
{
I2C_CLIENT
_ISA_END
};
/* Insmod parameters */
SENSORS_INSMOD_8
(
adm1021
,
adm1023
,
max1617
,
max1617a
,
thmc10
,
lm84
,
gl523sm
,
mc1066
);
...
...
@@ -416,128 +416,6 @@ static void adm1021_update_client(struct i2c_client *client)
up
(
&
data
->
update_lock
);
}
/* FIXME, remove these four functions, they are here to verify the sysfs
* conversion is correct, or not */
__attribute__
((
unused
))
static
void
adm1021_temp
(
struct
i2c_client
*
client
,
int
operation
,
int
ctl_name
,
int
*
nrels_mag
,
long
*
results
)
{
struct
adm1021_data
*
data
=
i2c_get_clientdata
(
client
);
if
(
operation
==
SENSORS_PROC_REAL_INFO
)
*
nrels_mag
=
0
;
else
if
(
operation
==
SENSORS_PROC_REAL_READ
)
{
adm1021_update_client
(
client
);
results
[
0
]
=
TEMP_FROM_REG
(
data
->
temp_max
);
results
[
1
]
=
TEMP_FROM_REG
(
data
->
temp_hyst
);
results
[
2
]
=
TEMP_FROM_REG
(
data
->
temp_input
);
*
nrels_mag
=
3
;
}
else
if
(
operation
==
SENSORS_PROC_REAL_WRITE
)
{
if
(
*
nrels_mag
>=
1
)
{
data
->
temp_max
=
TEMP_TO_REG
(
results
[
0
]);
adm1021_write_value
(
client
,
ADM1021_REG_TOS_W
,
data
->
temp_max
);
}
if
(
*
nrels_mag
>=
2
)
{
data
->
temp_hyst
=
TEMP_TO_REG
(
results
[
1
]);
adm1021_write_value
(
client
,
ADM1021_REG_THYST_W
,
data
->
temp_hyst
);
}
}
}
__attribute__
((
unused
))
static
void
adm1021_remote_temp
(
struct
i2c_client
*
client
,
int
operation
,
int
ctl_name
,
int
*
nrels_mag
,
long
*
results
)
{
struct
adm1021_data
*
data
=
i2c_get_clientdata
(
client
);
int
prec
=
0
;
if
(
operation
==
SENSORS_PROC_REAL_INFO
)
if
(
data
->
type
==
adm1023
)
{
*
nrels_mag
=
3
;
}
else
{
*
nrels_mag
=
0
;
}
else
if
(
operation
==
SENSORS_PROC_REAL_READ
)
{
adm1021_update_client
(
client
);
results
[
0
]
=
TEMP_FROM_REG
(
data
->
remote_temp_max
);
results
[
1
]
=
TEMP_FROM_REG
(
data
->
remote_temp_hyst
);
results
[
2
]
=
TEMP_FROM_REG
(
data
->
remote_temp_input
);
if
(
data
->
type
==
adm1023
)
{
results
[
0
]
=
results
[
0
]
*
1000
+
((
data
->
remote_temp_os_prec
>>
5
)
*
125
);
results
[
1
]
=
results
[
1
]
*
1000
+
((
data
->
remote_temp_hyst_prec
>>
5
)
*
125
);
results
[
2
]
=
(
TEMP_FROM_REG
(
data
->
remote_temp_offset
)
*
1000
)
+
((
data
->
remote_temp_offset_prec
>>
5
)
*
125
);
results
[
3
]
=
(
TEMP_FROM_REG
(
data
->
remote_temp_input
)
*
1000
)
+
((
data
->
remote_temp_prec
>>
5
)
*
125
);
*
nrels_mag
=
4
;
}
else
{
*
nrels_mag
=
3
;
}
}
else
if
(
operation
==
SENSORS_PROC_REAL_WRITE
)
{
if
(
*
nrels_mag
>=
1
)
{
if
(
data
->
type
==
adm1023
)
{
prec
=
((
results
[
0
]
-
((
results
[
0
]
/
1000
)
*
1000
))
/
125
)
<<
5
;
adm1021_write_value
(
client
,
ADM1021_REG_REM_TOS_PREC
,
prec
);
results
[
0
]
=
results
[
0
]
/
1000
;
data
->
remote_temp_os_prec
=
prec
;
}
data
->
remote_temp_max
=
TEMP_TO_REG
(
results
[
0
]);
adm1021_write_value
(
client
,
ADM1021_REG_REMOTE_TOS_W
,
data
->
remote_temp_max
);
}
if
(
*
nrels_mag
>=
2
)
{
if
(
data
->
type
==
adm1023
)
{
prec
=
((
results
[
1
]
-
((
results
[
1
]
/
1000
)
*
1000
))
/
125
)
<<
5
;
adm1021_write_value
(
client
,
ADM1021_REG_REM_THYST_PREC
,
prec
);
results
[
1
]
=
results
[
1
]
/
1000
;
data
->
remote_temp_hyst_prec
=
prec
;
}
data
->
remote_temp_hyst
=
TEMP_TO_REG
(
results
[
1
]);
adm1021_write_value
(
client
,
ADM1021_REG_REMOTE_THYST_W
,
data
->
remote_temp_hyst
);
}
if
(
*
nrels_mag
>=
3
)
{
if
(
data
->
type
==
adm1023
)
{
prec
=
((
results
[
2
]
-
((
results
[
2
]
/
1000
)
*
1000
))
/
125
)
<<
5
;
adm1021_write_value
(
client
,
ADM1021_REG_REM_OFFSET_PREC
,
prec
);
results
[
2
]
=
results
[
2
]
/
1000
;
data
->
remote_temp_offset_prec
=
prec
;
data
->
remote_temp_offset
=
results
[
2
];
adm1021_write_value
(
client
,
ADM1021_REG_REM_OFFSET
,
data
->
remote_temp_offset
);
}
}
}
}
__attribute__
((
unused
))
static
void
adm1021_die_code
(
struct
i2c_client
*
client
,
int
operation
,
int
ctl_name
,
int
*
nrels_mag
,
long
*
results
)
{
struct
adm1021_data
*
data
=
i2c_get_clientdata
(
client
);
if
(
operation
==
SENSORS_PROC_REAL_INFO
)
*
nrels_mag
=
0
;
else
if
(
operation
==
SENSORS_PROC_REAL_READ
)
{
adm1021_update_client
(
client
);
results
[
0
]
=
data
->
die_code
;
*
nrels_mag
=
1
;
}
else
if
(
operation
==
SENSORS_PROC_REAL_WRITE
)
{
/* Can't write to it */
}
}
__attribute__
((
unused
))
static
void
adm1021_alarms
(
struct
i2c_client
*
client
,
int
operation
,
int
ctl_name
,
int
*
nrels_mag
,
long
*
results
)
{
struct
adm1021_data
*
data
=
i2c_get_clientdata
(
client
);
if
(
operation
==
SENSORS_PROC_REAL_INFO
)
*
nrels_mag
=
0
;
else
if
(
operation
==
SENSORS_PROC_REAL_READ
)
{
adm1021_update_client
(
client
);
results
[
0
]
=
data
->
alarms
;
*
nrels_mag
=
1
;
}
else
if
(
operation
==
SENSORS_PROC_REAL_WRITE
)
{
/* Can't write to it */
}
}
static
int
__init
sensors_adm1021_init
(
void
)
{
return
i2c_add_driver
(
&
adm1021_driver
);
...
...
drivers/i2c/chips/it87.c
0 → 100644
View file @
c3efc929
/*
it87.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring.
Supports: IT8705F Super I/O chip w/LPC interface
IT8712F Super I/O chup w/LPC interface & SMbus
Sis950 A clone of the IT8705F
Copyright (c) 2001 Chris Gauthron <chrisg@0-in.com>
Largely inspired by lm78.c of the same package
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
djg@pdp8.net David Gesswein 7/18/01
Modified to fix bug with not all alarms enabled.
Added ability to read battery voltage and select temperature sensor
type at module load time.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <asm/io.h>
/* Addresses to scan */
static
unsigned
short
normal_i2c
[]
=
{
I2C_CLIENT_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
0x20
,
0x2f
,
I2C_CLIENT_END
};
static
unsigned
int
normal_isa
[]
=
{
0x0290
,
I2C_CLIENT_ISA_END
};
static
unsigned
int
normal_isa_range
[]
=
{
I2C_CLIENT_ISA_END
};
/* Insmod parameters */
SENSORS_INSMOD_4
(
it87
,
it8705
,
it8712
,
sis950
);
/* Update battery voltage after every reading if true */
static
int
update_vbat
=
0
;
/* Enable Temp1 as thermal resistor */
/* Enable Temp2 as thermal diode */
/* Enable Temp3 as thermal resistor */
static
int
temp_type
=
0x2a
;
/* Many IT87 constants specified below */
/* Length of ISA address segment */
#define IT87_EXTENT 8
/* Where are the ISA address/data registers relative to the base address */
#define IT87_ADDR_REG_OFFSET 5
#define IT87_DATA_REG_OFFSET 6
/*----- The IT87 registers -----*/
#define IT87_REG_CONFIG 0x00
#define IT87_REG_ALARM1 0x01
#define IT87_REG_ALARM2 0x02
#define IT87_REG_ALARM3 0x03
#define IT87_REG_VID 0x0a
#define IT87_REG_FAN_DIV 0x0b
/* Monitors: 9 voltage (0 to 7, battery), 3 temp (1 to 3), 3 fan (1 to 3) */
#define IT87_REG_FAN(nr) (0x0c + (nr))
#define IT87_REG_FAN_MIN(nr) (0x0f + (nr))
#define IT87_REG_FAN_CTRL 0x13
#define IT87_REG_VIN(nr) (0x20 + (nr))
#define IT87_REG_TEMP(nr) (0x28 + (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) (0x3e + (nr) * 2)
#define IT87_REG_TEMP_LOW(nr) (0x3f + (nr) * 2)
#define IT87_REG_I2C_ADDR 0x48
#define IT87_REG_VIN_ENABLE 0x50
#define IT87_REG_TEMP_ENABLE 0x51
#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
);
}
static
inline
u8
FAN_TO_REG
(
long
rpm
,
int
div
)
{
if
(
rpm
==
0
)
return
255
;
rpm
=
SENSORS_LIMIT
(
rpm
,
1
,
1000000
);
return
SENSORS_LIMIT
((
1350000
+
rpm
*
div
/
2
)
/
(
rpm
*
div
),
1
,
254
);
}
#define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==255?0:1350000/((val)*(div)))
#define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)<0?(((val)-5)/10):\
((val)+5)/10),0,255))
#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10)
#define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\
205-(val)*5)
#define ALARMS_FROM_REG(val) (val)
#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)
#define DIV_FROM_REG(val) (1 << (val))
/* Initial limits. Use the config file to set better limits. */
#define IT87_INIT_IN_0 170
#define IT87_INIT_IN_1 250
#define IT87_INIT_IN_2 (330 / 2)
#define IT87_INIT_IN_3 (((500) * 100)/168)
#define IT87_INIT_IN_4 (((1200) * 10)/38)
#define IT87_INIT_IN_5 (((1200) * 10)/72)
#define IT87_INIT_IN_6 (((500) * 10)/56)
#define IT87_INIT_IN_7 (((500) * 100)/168)
#define IT87_INIT_IN_PERCENTAGE 10
#define IT87_INIT_IN_MIN_0 \
(IT87_INIT_IN_0 - IT87_INIT_IN_0 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MAX_0 \
(IT87_INIT_IN_0 + IT87_INIT_IN_0 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MIN_1 \
(IT87_INIT_IN_1 - IT87_INIT_IN_1 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MAX_1 \
(IT87_INIT_IN_1 + IT87_INIT_IN_1 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MIN_2 \
(IT87_INIT_IN_2 - IT87_INIT_IN_2 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MAX_2 \
(IT87_INIT_IN_2 + IT87_INIT_IN_2 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MIN_3 \
(IT87_INIT_IN_3 - IT87_INIT_IN_3 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MAX_3 \
(IT87_INIT_IN_3 + IT87_INIT_IN_3 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MIN_4 \
(IT87_INIT_IN_4 - IT87_INIT_IN_4 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MAX_4 \
(IT87_INIT_IN_4 + IT87_INIT_IN_4 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MIN_5 \
(IT87_INIT_IN_5 - IT87_INIT_IN_5 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MAX_5 \
(IT87_INIT_IN_5 + IT87_INIT_IN_5 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MIN_6 \
(IT87_INIT_IN_6 - IT87_INIT_IN_6 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MAX_6 \
(IT87_INIT_IN_6 + IT87_INIT_IN_6 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MIN_7 \
(IT87_INIT_IN_7 - IT87_INIT_IN_7 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_IN_MAX_7 \
(IT87_INIT_IN_7 + IT87_INIT_IN_7 * IT87_INIT_IN_PERCENTAGE / 100)
#define IT87_INIT_FAN_MIN_1 3000
#define IT87_INIT_FAN_MIN_2 3000
#define IT87_INIT_FAN_MIN_3 3000
#define IT87_INIT_TEMP_HIGH_1 600
#define IT87_INIT_TEMP_LOW_1 200
#define IT87_INIT_TEMP_HIGH_2 600
#define IT87_INIT_TEMP_LOW_2 200
#define IT87_INIT_TEMP_HIGH_3 600
#define IT87_INIT_TEMP_LOW_3 200
/* For each registered IT87, we need to keep some data in memory. That
data is pointed to by it87_list[NR]->data. The structure itself is
dynamically allocated, at the same time when a new it87 client is
allocated. */
struct
it87_data
{
struct
semaphore
lock
;
enum
chips
type
;
struct
semaphore
update_lock
;
char
valid
;
/* !=0 if following fields are valid */
unsigned
long
last_updated
;
/* In jiffies */
u8
in
[
9
];
/* Register value */
u8
in_max
[
9
];
/* Register value */
u8
in_min
[
9
];
/* Register value */
u8
fan
[
3
];
/* Register value */
u8
fan_min
[
3
];
/* Register value */
u8
temp
[
3
];
/* Register value */
u8
temp_high
[
3
];
/* Register value */
u8
temp_low
[
3
];
/* Register value */
u8
fan_div
[
3
];
/* Register encoding, shifted right */
u8
vid
;
/* Register encoding, combined */
u32
alarms
;
/* Register encoding, combined */
};
static
int
it87_attach_adapter
(
struct
i2c_adapter
*
adapter
);
static
int
it87_detect
(
struct
i2c_adapter
*
adapter
,
int
address
,
int
kind
);
static
int
it87_detach_client
(
struct
i2c_client
*
client
);
static
int
it87_read_value
(
struct
i2c_client
*
client
,
u8
register
);
static
int
it87_write_value
(
struct
i2c_client
*
client
,
u8
register
,
u8
value
);
static
void
it87_update_client
(
struct
i2c_client
*
client
);
static
void
it87_init_client
(
struct
i2c_client
*
client
);
static
struct
i2c_driver
it87_driver
=
{
.
owner
=
THIS_MODULE
,
.
name
=
"IT87xx"
,
.
id
=
I2C_DRIVERID_IT87
,
.
flags
=
I2C_DF_NOTIFY
,
.
attach_adapter
=
it87_attach_adapter
,
.
detach_client
=
it87_detach_client
,
};
static
int
it87_id
=
0
;
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
);
}
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
);
}
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
);
}
static
ssize_t
set_in_min
(
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
);
unsigned
long
val
=
simple_strtoul
(
buf
,
NULL
,
10
)
/
10
;
data
->
in_min
[
nr
]
=
IN_TO_REG
(
val
,
nr
);
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
nr
),
data
->
in_min
[
nr
]);
return
count
;
}
static
ssize_t
set_in_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
);
unsigned
long
val
=
simple_strtoul
(
buf
,
NULL
,
10
)
/
10
;
data
->
in_max
[
nr
]
=
IN_TO_REG
(
val
,
nr
);
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
nr
),
data
->
in_max
[
nr
]);
return
count
;
}
#define show_in_offset(offset) \
static ssize_t \
show_in##offset (struct device *dev, char *buf) \
{ \
return show_in(dev, buf, 0x##offset); \
} \
static ssize_t \
show_in##offset##_min (struct device *dev, char *buf) \
{ \
return show_in_min(dev, buf, 0x##offset); \
} \
static ssize_t \
show_in##offset##_max (struct device *dev, char *buf) \
{ \
return show_in_max(dev, buf, 0x##offset); \
} \
static ssize_t set_in##offset##_min (struct device *dev, \
const char *buf, size_t count) \
{ \
return set_in_min(dev, buf, count, 0x##offset); \
} \
static ssize_t set_in##offset##_max (struct device *dev, \
const char *buf, size_t count) \
{ \
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
);
show_in_offset
(
1
);
show_in_offset
(
2
);
show_in_offset
(
3
);
show_in_offset
(
4
);
/* 3 temperatures */
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
);
}
/* more like overshoot temperature */
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
);
}
/* more like hysteresis temperature */
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
);
}
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
;
data
->
temp_high
[
nr
]
=
TEMP_TO_REG
(
val
);
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
nr
),
data
->
temp_high
[
nr
]);
return
count
;
}
static
ssize_t
set_temp_min
(
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
;
data
->
temp_low
[
nr
]
=
TEMP_TO_REG
(
val
);
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
nr
),
data
->
temp_low
[
nr
]);
return
count
;
}
#define show_temp_offset(offset) \
static ssize_t show_temp_##offset (struct device *dev, char *buf) \
{ \
return show_temp(dev, buf, 0x##offset - 1); \
} \
static ssize_t \
show_temp_##offset##_max (struct device *dev, char *buf) \
{ \
return show_temp_max(dev, buf, 0x##offset - 1); \
} \
static ssize_t \
show_temp_##offset##_min (struct device *dev, char *buf) \
{ \
return show_temp_min(dev, buf, 0x##offset - 1); \
} \
static ssize_t set_temp_##offset##_max (struct device *dev, \
const char *buf, size_t count) \
{ \
return set_temp_max(dev, buf, count, 0x##offset - 1); \
} \
static ssize_t set_temp_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
{ \
return set_temp_min(dev, buf, count, 0x##offset - 1); \
} \
static DEVICE_ATTR(temp_input##offset, S_IRUGO, show_temp_##offset, NULL) \
static DEVICE_ATTR(temp_max##offset, S_IRUGO | S_IWUSR, \
show_temp_##offset##_max, set_temp_##offset##_max) \
static DEVICE_ATTR(temp_min##offset, S_IRUGO | S_IWUSR, \
show_temp_##offset##_min, set_temp_##offset##_min)
show_temp_offset
(
1
);
show_temp_offset
(
2
);
show_temp_offset
(
3
);
/* 2 Fans */
static
ssize_t
show_fan
(
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
"
,
FAN_FROM_REG
(
data
->
fan
[
nr
],
DIV_FROM_REG
(
data
->
fan_div
[
nr
]))
);
}
static
ssize_t
show_fan_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
"
,
FAN_FROM_REG
(
data
->
fan_min
[
nr
],
DIV_FROM_REG
(
data
->
fan_div
[
nr
]))
);
}
static
ssize_t
show_fan_div
(
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
"
,
DIV_FROM_REG
(
data
->
fan_div
[
nr
])
);
}
static
ssize_t
set_fan_min
(
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
);
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
]);
return
count
;
}
static
ssize_t
set_fan_div
(
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
);
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
);
return
count
;
}
#define show_fan_offset(offset) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
{ \
return show_fan(dev, buf, 0x##offset - 1); \
} \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
{ \
return show_fan_min(dev, buf, 0x##offset - 1); \
} \
static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \
{ \
return show_fan_div(dev, buf, 0x##offset - 1); \
} \
static ssize_t set_fan_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
{ \
return set_fan_min(dev, buf, count, 0x##offset - 1); \
} \
static ssize_t set_fan_##offset##_div (struct device *dev, \
const char *buf, size_t count) \
{ \
return set_fan_div(dev, buf, count, 0x##offset - 1); \
} \
static DEVICE_ATTR(fan_input##offset, S_IRUGO, show_fan_##offset, NULL) \
static DEVICE_ATTR(fan_min##offset, S_IRUGO | S_IWUSR, \
show_fan_##offset##_min, set_fan_##offset##_min) \
static DEVICE_ATTR(fan_div##offset, S_IRUGO | S_IWUSR, \
show_fan_##offset##_div, set_fan_##offset##_div)
show_fan_offset
(
1
);
show_fan_offset
(
2
);
/* Alarm */
static
ssize_t
show_alarm
(
struct
device
*
dev
,
char
*
buf
)
{
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
"
,
ALARMS_FROM_REG
(
data
->
alarms
));
}
static
DEVICE_ATTR
(
alarm
,
S_IRUGO
|
S_IWUSR
,
show_alarm
,
NULL
);
/* This function is called when:
* it87_driver is inserted (when this module is loaded), for each
available adapter
* when a new adapter is inserted (and it87_driver is still present) */
static
int
it87_attach_adapter
(
struct
i2c_adapter
*
adapter
)
{
return
i2c_detect
(
adapter
,
&
addr_data
,
it87_detect
);
}
/* This function is called by i2c_detect */
int
it87_detect
(
struct
i2c_adapter
*
adapter
,
int
address
,
int
kind
)
{
int
i
;
struct
i2c_client
*
new_client
=
NULL
;
struct
it87_data
*
data
;
int
err
=
0
;
const
char
*
name
=
""
;
const
char
*
client_name
=
""
;
int
is_isa
=
i2c_is_isa_adapter
(
adapter
);
if
(
!
is_isa
&&
!
i2c_check_functionality
(
adapter
,
I2C_FUNC_SMBUS_BYTE_DATA
))
goto
ERROR0
;
/* Reserve the ISA region */
if
(
is_isa
)
if
(
!
request_region
(
address
,
IT87_EXTENT
,
name
))
goto
ERROR0
;
/* Probe whether there is anything available on this address. Already
done for SMBus clients */
if
(
kind
<
0
)
{
if
(
is_isa
)
{
#define REALLY_SLOW_IO
/* We need the timeouts for at least some IT87-like chips. But only
if we read 'undefined' registers. */
i
=
inb_p
(
address
+
1
);
if
(
inb_p
(
address
+
2
)
!=
i
)
goto
ERROR1
;
if
(
inb_p
(
address
+
3
)
!=
i
)
goto
ERROR1
;
if
(
inb_p
(
address
+
7
)
!=
i
)
goto
ERROR1
;
#undef REALLY_SLOW_IO
/* Let's just hope nothing breaks here */
i
=
inb_p
(
address
+
5
)
&
0x7f
;
outb_p
(
~
i
&
0x7f
,
address
+
5
);
if
((
inb_p
(
address
+
5
)
&
0x7f
)
!=
(
~
i
&
0x7f
))
{
outb_p
(
i
,
address
+
5
);
return
0
;
}
}
}
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access it87_{read,write}_value. */
if
(
!
(
new_client
=
kmalloc
((
sizeof
(
struct
i2c_client
))
+
sizeof
(
struct
it87_data
),
GFP_KERNEL
)))
{
err
=
-
ENOMEM
;
goto
ERROR1
;
}
data
=
(
struct
it87_data
*
)
(
new_client
+
1
);
if
(
is_isa
)
init_MUTEX
(
&
data
->
lock
);
i2c_set_clientdata
(
new_client
,
data
);
new_client
->
addr
=
address
;
new_client
->
adapter
=
adapter
;
new_client
->
driver
=
&
it87_driver
;
new_client
->
flags
=
0
;
/* Now, we do the remaining detection. */
if
(
kind
<
0
)
{
if
(
it87_read_value
(
new_client
,
IT87_REG_CONFIG
)
&
0x80
)
goto
ERROR1
;
if
(
!
is_isa
&&
(
it87_read_value
(
new_client
,
IT87_REG_I2C_ADDR
)
!=
address
))
goto
ERROR1
;
}
/* Determine the chip type. */
if
(
kind
<=
0
)
{
i
=
it87_read_value
(
new_client
,
IT87_REG_CHIPID
);
if
(
i
==
0x90
)
{
kind
=
it87
;
}
else
{
if
(
kind
==
0
)
printk
(
"it87.o: Ignoring 'force' parameter for unknown chip at "
"adapter %d, address 0x%02x
\n
"
,
i2c_adapter_id
(
adapter
),
address
);
goto
ERROR1
;
}
}
if
(
kind
==
it87
)
{
name
=
"it87"
;
client_name
=
"IT87 chip"
;
}
/* else if (kind == it8712) {
name = "it8712";
client_name = "IT87-J chip";
} */
else
{
dev_dbg
(
&
adapter
->
dev
,
"Internal error: unknown kind (%d)?!?"
,
kind
);
goto
ERROR1
;
}
/* Fill in the remaining client fields and put it into the global list */
strncpy
(
new_client
->
dev
.
name
,
name
,
DEVICE_NAME_SIZE
);
data
->
type
=
kind
;
new_client
->
id
=
it87_id
++
;
data
->
valid
=
0
;
init_MUTEX
(
&
data
->
update_lock
);
/* Tell the I2C layer a new client has arrived */
if
((
err
=
i2c_attach_client
(
new_client
)))
goto
ERROR1
;
/* register sysfs hooks */
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_input0
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_input1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_input2
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_input3
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_input4
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_min0
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_min1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_min2
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_min3
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_min4
);
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
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_max3
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_in_max4
);
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
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp_max1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp_max2
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp_max3
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp_min1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp_min2
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_temp_min3
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan_input1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan_input2
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan_min1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan_min2
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan_div1
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_fan_div2
);
device_create_file
(
&
new_client
->
dev
,
&
dev_attr_alarm
);
/* Initialize the IT87 chip */
it87_init_client
(
new_client
);
return
0
;
ERROR1:
kfree
(
new_client
);
if
(
is_isa
)
release_region
(
address
,
IT87_EXTENT
);
ERROR0:
return
err
;
}
static
int
it87_detach_client
(
struct
i2c_client
*
client
)
{
int
err
;
if
((
err
=
i2c_detach_client
(
client
)))
{
dev_err
(
&
client
->
dev
,
"Client deregistration failed, client not detached.
\n
"
);
return
err
;
}
if
(
i2c_is_isa_client
(
client
))
release_region
(
client
->
addr
,
IT87_EXTENT
);
kfree
(
client
);
return
0
;
}
/* The SMBus locks itself, but ISA access must be locked explicitely!
We don't want to lock the whole ISA bus, so we lock each client
separately.
We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
would slow down the IT87 access and should not be necessary.
There are some ugly typecasts here, but the good new is - they should
nowhere else be necessary! */
static
int
it87_read_value
(
struct
i2c_client
*
client
,
u8
reg
)
{
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
int
res
;
if
(
i2c_is_isa_client
(
client
))
{
down
(
&
data
->
lock
);
outb_p
(
reg
,
client
->
addr
+
IT87_ADDR_REG_OFFSET
);
res
=
inb_p
(
client
->
addr
+
IT87_DATA_REG_OFFSET
);
up
(
&
data
->
lock
);
return
res
;
}
else
return
i2c_smbus_read_byte_data
(
client
,
reg
);
}
/* The SMBus locks itself, but ISA access muse be locked explicitely!
We don't want to lock the whole ISA bus, so we lock each client
separately.
We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
would slow down the IT87 access and should not be necessary.
There are some ugly typecasts here, but the good new is - they should
nowhere else be necessary! */
static
int
it87_write_value
(
struct
i2c_client
*
client
,
u8
reg
,
u8
value
)
{
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
if
(
i2c_is_isa_client
(
client
))
{
down
(
&
data
->
lock
);
outb_p
(
reg
,
client
->
addr
+
IT87_ADDR_REG_OFFSET
);
outb_p
(
value
,
client
->
addr
+
IT87_DATA_REG_OFFSET
);
up
(
&
data
->
lock
);
return
0
;
}
else
return
i2c_smbus_write_byte_data
(
client
,
reg
,
value
);
}
/* Called when we have found a new IT87. It should set limits, etc. */
static
void
it87_init_client
(
struct
i2c_client
*
client
)
{
/* Reset all except Watchdog values and last conversion values
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
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
0
),
IN_TO_REG
(
IT87_INIT_IN_MAX_0
,
0
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
1
),
IN_TO_REG
(
IT87_INIT_IN_MIN_1
,
1
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
1
),
IN_TO_REG
(
IT87_INIT_IN_MAX_1
,
1
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
2
),
IN_TO_REG
(
IT87_INIT_IN_MIN_2
,
2
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
2
),
IN_TO_REG
(
IT87_INIT_IN_MAX_2
,
2
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
3
),
IN_TO_REG
(
IT87_INIT_IN_MIN_3
,
3
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
3
),
IN_TO_REG
(
IT87_INIT_IN_MAX_3
,
3
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
4
),
IN_TO_REG
(
IT87_INIT_IN_MIN_4
,
4
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
4
),
IN_TO_REG
(
IT87_INIT_IN_MAX_4
,
4
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
5
),
IN_TO_REG
(
IT87_INIT_IN_MIN_5
,
5
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
5
),
IN_TO_REG
(
IT87_INIT_IN_MAX_5
,
5
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
6
),
IN_TO_REG
(
IT87_INIT_IN_MIN_6
,
6
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
6
),
IN_TO_REG
(
IT87_INIT_IN_MAX_6
,
6
));
it87_write_value
(
client
,
IT87_REG_VIN_MIN
(
7
),
IN_TO_REG
(
IT87_INIT_IN_MIN_7
,
7
));
it87_write_value
(
client
,
IT87_REG_VIN_MAX
(
7
),
IN_TO_REG
(
IT87_INIT_IN_MAX_7
,
7
));
/* Note: Battery voltage does not have limit registers */
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
1
),
FAN_TO_REG
(
IT87_INIT_FAN_MIN_1
,
2
));
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
2
),
FAN_TO_REG
(
IT87_INIT_FAN_MIN_2
,
2
));
it87_write_value
(
client
,
IT87_REG_FAN_MIN
(
3
),
FAN_TO_REG
(
IT87_INIT_FAN_MIN_3
,
2
));
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
1
),
TEMP_TO_REG
(
IT87_INIT_TEMP_HIGH_1
));
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
1
),
TEMP_TO_REG
(
IT87_INIT_TEMP_LOW_1
));
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
2
),
TEMP_TO_REG
(
IT87_INIT_TEMP_HIGH_2
));
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
2
),
TEMP_TO_REG
(
IT87_INIT_TEMP_LOW_2
));
it87_write_value
(
client
,
IT87_REG_TEMP_HIGH
(
3
),
TEMP_TO_REG
(
IT87_INIT_TEMP_HIGH_3
));
it87_write_value
(
client
,
IT87_REG_TEMP_LOW
(
3
),
TEMP_TO_REG
(
IT87_INIT_TEMP_LOW_3
));
/* Enable voltage monitors */
it87_write_value
(
client
,
IT87_REG_VIN_ENABLE
,
0xff
);
/* Enable Temp1-Temp3 */
it87_write_value
(
client
,
IT87_REG_TEMP_ENABLE
,
(
it87_read_value
(
client
,
IT87_REG_TEMP_ENABLE
)
&
0xc0
)
|
(
temp_type
&
0x3f
));
/* Enable fans */
it87_write_value
(
client
,
IT87_REG_FAN_CTRL
,
(
it87_read_value
(
client
,
IT87_REG_FAN_CTRL
)
&
0x8f
)
|
0x70
);
/* Start monitoring */
it87_write_value
(
client
,
IT87_REG_CONFIG
,
(
it87_read_value
(
client
,
IT87_REG_CONFIG
)
&
0xb7
)
|
(
update_vbat
?
0x41
:
0x01
));
}
static
void
it87_update_client
(
struct
i2c_client
*
client
)
{
struct
it87_data
*
data
=
i2c_get_clientdata
(
client
);
int
i
;
down
(
&
data
->
update_lock
);
if
((
jiffies
-
data
->
last_updated
>
HZ
+
HZ
/
2
)
||
(
jiffies
<
data
->
last_updated
)
||
!
data
->
valid
)
{
if
(
update_vbat
)
{
/* Cleared after each update, so reenable. Value
returned by this read will be previous value */
it87_write_value
(
client
,
IT87_REG_CONFIG
,
it87_read_value
(
client
,
IT87_REG_CONFIG
)
|
0x40
);
}
for
(
i
=
0
;
i
<=
7
;
i
++
)
{
data
->
in
[
i
]
=
it87_read_value
(
client
,
IT87_REG_VIN
(
i
));
data
->
in_min
[
i
]
=
it87_read_value
(
client
,
IT87_REG_VIN_MIN
(
i
));
data
->
in_max
[
i
]
=
it87_read_value
(
client
,
IT87_REG_VIN_MAX
(
i
));
}
data
->
in
[
8
]
=
it87_read_value
(
client
,
IT87_REG_VIN
(
8
));
/* Temperature sensor doesn't have limit registers, set
to min and max value */
data
->
in_min
[
8
]
=
0
;
data
->
in_max
[
8
]
=
255
;
for
(
i
=
1
;
i
<=
3
;
i
++
)
{
data
->
fan
[
i
-
1
]
=
it87_read_value
(
client
,
IT87_REG_FAN
(
i
));
data
->
fan_min
[
i
-
1
]
=
it87_read_value
(
client
,
IT87_REG_FAN_MIN
(
i
));
}
for
(
i
=
1
;
i
<=
3
;
i
++
)
{
data
->
temp
[
i
-
1
]
=
it87_read_value
(
client
,
IT87_REG_TEMP
(
i
));
data
->
temp_high
[
i
-
1
]
=
it87_read_value
(
client
,
IT87_REG_TEMP_HIGH
(
i
));
data
->
temp_low
[
i
-
1
]
=
it87_read_value
(
client
,
IT87_REG_TEMP_LOW
(
i
));
}
/* The 8705 does not have VID capability */
/*if (data->type == it8712) {
data->vid = it87_read_value(client, IT87_REG_VID);
data->vid &= 0x1f;
}
else */
{
data
->
vid
=
0x1f
;
}
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
->
alarms
=
it87_read_value
(
client
,
IT87_REG_ALARM1
)
|
(
it87_read_value
(
client
,
IT87_REG_ALARM2
)
<<
8
)
|
(
it87_read_value
(
client
,
IT87_REG_ALARM3
)
<<
16
);
data
->
last_updated
=
jiffies
;
data
->
valid
=
1
;
}
up
(
&
data
->
update_lock
);
}
static
int
__init
sm_it87_init
(
void
)
{
return
i2c_add_driver
(
&
it87_driver
);
}
static
void
__exit
sm_it87_exit
(
void
)
{
i2c_del_driver
(
&
it87_driver
);
}
MODULE_AUTHOR
(
"Chris Gauthron <chrisg@0-in.com>"
);
MODULE_DESCRIPTION
(
"IT8705F, IT8712F, Sis950 driver"
);
MODULE_PARM
(
update_vbat
,
"i"
);
MODULE_PARM_DESC
(
update_vbat
,
"Update vbat if set else return powerup value"
);
MODULE_PARM
(
temp_type
,
"i"
);
MODULE_PARM_DESC
(
temp_type
,
"Temperature sensor type, normally leave unset"
);
MODULE_LICENSE
(
"GPL"
);
module_init
(
sm_it87_init
);
module_exit
(
sm_it87_exit
);
drivers/i2c/chips/lm75.c
View file @
c3efc929
...
...
@@ -28,10 +28,10 @@
/* Addresses to scan */
static
unsigned
short
normal_i2c
[]
=
{
SENSORS_I2C
_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
0x48
,
0x4f
,
SENSORS_I2C
_END
};
static
unsigned
int
normal_isa
[]
=
{
SENSORS
_ISA_END
};
static
unsigned
int
normal_isa_range
[]
=
{
SENSORS
_ISA_END
};
static
unsigned
short
normal_i2c
[]
=
{
I2C_CLIENT
_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
0x48
,
0x4f
,
I2C_CLIENT
_END
};
static
unsigned
int
normal_isa
[]
=
{
I2C_CLIENT
_ISA_END
};
static
unsigned
int
normal_isa_range
[]
=
{
I2C_CLIENT
_ISA_END
};
/* Insmod parameters */
SENSORS_INSMOD_1
(
lm75
);
...
...
drivers/i2c/chips/via686a.c
View file @
c3efc929
...
...
@@ -51,10 +51,10 @@ MODULE_PARM_DESC(force_addr,
/* Addresses to scan.
Note that we can't determine the ISA address until we have initialized
our module */
static
unsigned
short
normal_i2c
[]
=
{
SENSORS_I2C
_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
SENSORS_I2C
_END
};
static
unsigned
int
normal_isa
[]
=
{
0x0000
,
SENSORS
_ISA_END
};
static
unsigned
int
normal_isa_range
[]
=
{
SENSORS
_ISA_END
};
static
unsigned
short
normal_i2c
[]
=
{
I2C_CLIENT
_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
I2C_CLIENT
_END
};
static
unsigned
int
normal_isa
[]
=
{
0x0000
,
I2C_CLIENT
_ISA_END
};
static
unsigned
int
normal_isa_range
[]
=
{
I2C_CLIENT
_ISA_END
};
/* Insmod parameters */
SENSORS_INSMOD_1
(
via686a
);
...
...
drivers/i2c/chips/w83781d.c
View file @
c3efc929
...
...
@@ -46,14 +46,14 @@
#define W83781D_RT 1
/* Addresses to scan */
static
unsigned
short
normal_i2c
[]
=
{
SENSORS_I2C
_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
0x20
,
0x2f
,
SENSORS_I2C
_END
};
static
unsigned
int
normal_isa
[]
=
{
0x0290
,
SENSORS
_ISA_END
};
static
unsigned
int
normal_isa_range
[]
=
{
SENSORS
_ISA_END
};
static
unsigned
short
normal_i2c
[]
=
{
I2C_CLIENT
_END
};
static
unsigned
short
normal_i2c_range
[]
=
{
0x20
,
0x2f
,
I2C_CLIENT
_END
};
static
unsigned
int
normal_isa
[]
=
{
0x0290
,
I2C_CLIENT
_ISA_END
};
static
unsigned
int
normal_isa_range
[]
=
{
I2C_CLIENT
_ISA_END
};
/* Insmod parameters */
SENSORS_INSMOD_6
(
w83781d
,
w83782d
,
w83783s
,
w83627hf
,
as99127f
,
w83697hf
);
SENSORS
_MODULE_PARM
(
force_subclients
,
"List of subclient addresses: "
I2C_CLIENT
_MODULE_PARM
(
force_subclients
,
"List of subclient addresses: "
"{bus, clientaddr, subclientaddr1, subclientaddr2}"
);
static
int
init
=
1
;
...
...
drivers/i2c/i2c-core.c
View file @
c3efc929
...
...
@@ -619,7 +619,7 @@ int i2c_control(struct i2c_client *client,
*/
int
i2c_probe
(
struct
i2c_adapter
*
adapter
,
struct
i2c_client_address_data
*
address_data
,
i2c_client_found_addr_proc
*
found_proc
)
int
(
*
found_proc
)
(
struct
i2c_adapter
*
,
int
,
int
)
)
{
int
addr
,
i
,
found
,
err
;
int
adap_id
=
i2c_adapter_id
(
adapter
);
...
...
@@ -644,7 +644,7 @@ int i2c_probe(struct i2c_adapter *adapter,
(
addr
==
address_data
->
force
[
i
+
1
]))
{
DEB2
(
printk
(
KERN_DEBUG
"i2c-core.o: found force parameter for adapter %d, addr %04x
\n
"
,
adap_id
,
addr
));
if
((
err
=
found_proc
(
adapter
,
addr
,
0
,
0
)))
if
((
err
=
found_proc
(
adapter
,
addr
,
0
)))
return
err
;
found
=
1
;
}
...
...
@@ -732,7 +732,7 @@ int i2c_probe(struct i2c_adapter *adapter,
/* OK, so we really should examine this address. First check
whether there is some client here at all! */
if
(
i2c_smbus_xfer
(
adapter
,
addr
,
0
,
0
,
0
,
I2C_SMBUS_QUICK
,
NULL
)
>=
0
)
if
((
err
=
found_proc
(
adapter
,
addr
,
0
,
-
1
)))
if
((
err
=
found_proc
(
adapter
,
addr
,
-
1
)))
return
err
;
}
return
0
;
...
...
drivers/i2c/i2c-sensor.c
View file @
c3efc929
...
...
@@ -36,13 +36,13 @@
/* Very inefficient for ISA detects, and won't work for 10-bit addresses! */
int
i2c_detect
(
struct
i2c_adapter
*
adapter
,
struct
i2c_address_data
*
address_data
,
i2c_found_addr_proc
*
found_proc
)
int
(
*
found_proc
)
(
struct
i2c_adapter
*
,
int
,
int
)
)
{
int
addr
,
i
,
found
,
j
,
err
;
struct
i2c_force_data
*
this_force
;
int
is_isa
=
i2c_is_isa_adapter
(
adapter
);
int
adapter_id
=
is_isa
?
SENSORS
_ISA_BUS
:
i2c_adapter_id
(
adapter
);
is_isa
?
ANY_I2C
_ISA_BUS
:
i2c_adapter_id
(
adapter
);
/* Forget it if we can't probe using SMBUS_QUICK */
if
((
!
is_isa
)
&&
...
...
@@ -59,9 +59,9 @@ int i2c_detect(struct i2c_adapter *adapter,
detection at all */
found
=
0
;
for
(
i
=
0
;
!
found
&&
(
this_force
=
address_data
->
forces
+
i
,
this_force
->
force
);
i
++
)
{
for
(
j
=
0
;
!
found
&&
(
this_force
->
force
[
j
]
!=
SENSORS_I2C
_END
);
j
+=
2
)
{
for
(
j
=
0
;
!
found
&&
(
this_force
->
force
[
j
]
!=
I2C_CLIENT
_END
);
j
+=
2
)
{
if
(
((
adapter_id
==
this_force
->
force
[
j
])
||
((
this_force
->
force
[
j
]
==
SENSORS_
ANY_I2C_BUS
)
&&
!
is_isa
))
&&
((
this_force
->
force
[
j
]
==
ANY_I2C_BUS
)
&&
!
is_isa
))
&&
(
addr
==
this_force
->
force
[
j
+
1
])
)
{
dev_dbg
(
&
adapter
->
dev
,
"found force parameter for adapter %d, addr %04x
\n
"
,
adapter_id
,
addr
);
if
((
err
=
found_proc
(
adapter
,
addr
,
this_force
->
kind
)))
...
...
@@ -75,18 +75,18 @@ int i2c_detect(struct i2c_adapter *adapter,
/* If this address is in one of the ignores, we can forget about it
right now */
for
(
i
=
0
;
!
found
&&
(
address_data
->
ignore
[
i
]
!=
SENSORS_I2C
_END
);
i
+=
2
)
{
for
(
i
=
0
;
!
found
&&
(
address_data
->
ignore
[
i
]
!=
I2C_CLIENT
_END
);
i
+=
2
)
{
if
(
((
adapter_id
==
address_data
->
ignore
[
i
])
||
((
address_data
->
ignore
[
i
]
==
SENSORS_
ANY_I2C_BUS
)
&&
((
address_data
->
ignore
[
i
]
==
ANY_I2C_BUS
)
&&
!
is_isa
))
&&
(
addr
==
address_data
->
ignore
[
i
+
1
]))
{
dev_dbg
(
&
adapter
->
dev
,
"found ignore parameter for adapter %d, addr %04x
\n
"
,
adapter_id
,
addr
);
found
=
1
;
}
}
for
(
i
=
0
;
!
found
&&
(
address_data
->
ignore_range
[
i
]
!=
SENSORS_I2C
_END
);
i
+=
3
)
{
for
(
i
=
0
;
!
found
&&
(
address_data
->
ignore_range
[
i
]
!=
I2C_CLIENT
_END
);
i
+=
3
)
{
if
(
((
adapter_id
==
address_data
->
ignore_range
[
i
])
||
((
address_data
->
ignore_range
[
i
]
==
SENSORS_
ANY_I2C_BUS
)
&
((
address_data
->
ignore_range
[
i
]
==
ANY_I2C_BUS
)
&
!
is_isa
))
&&
(
addr
>=
address_data
->
ignore_range
[
i
+
1
])
&&
(
addr
<=
address_data
->
ignore_range
[
i
+
2
]))
{
...
...
@@ -100,13 +100,13 @@ int i2c_detect(struct i2c_adapter *adapter,
/* Now, we will do a detection, but only if it is in the normal or
probe entries */
if
(
is_isa
)
{
for
(
i
=
0
;
!
found
&&
(
address_data
->
normal_isa
[
i
]
!=
SENSORS
_ISA_END
);
i
+=
1
)
{
for
(
i
=
0
;
!
found
&&
(
address_data
->
normal_isa
[
i
]
!=
I2C_CLIENT
_ISA_END
);
i
+=
1
)
{
if
(
addr
==
address_data
->
normal_isa
[
i
])
{
dev_dbg
(
&
adapter
->
dev
,
"found normal isa entry for adapter %d, addr %04x
\n
"
,
adapter_id
,
addr
);
found
=
1
;
}
}
for
(
i
=
0
;
!
found
&&
(
address_data
->
normal_isa_range
[
i
]
!=
SENSORS
_ISA_END
);
i
+=
3
)
{
for
(
i
=
0
;
!
found
&&
(
address_data
->
normal_isa_range
[
i
]
!=
I2C_CLIENT
_ISA_END
);
i
+=
3
)
{
if
((
addr
>=
address_data
->
normal_isa_range
[
i
])
&&
(
addr
<=
address_data
->
normal_isa_range
[
i
+
1
])
&&
((
addr
-
address_data
->
normal_isa_range
[
i
])
%
address_data
->
normal_isa_range
[
i
+
2
]
==
0
))
{
...
...
@@ -115,13 +115,13 @@ int i2c_detect(struct i2c_adapter *adapter,
}
}
}
else
{
for
(
i
=
0
;
!
found
&&
(
address_data
->
normal_i2c
[
i
]
!=
SENSORS_I2C
_END
);
i
+=
1
)
{
for
(
i
=
0
;
!
found
&&
(
address_data
->
normal_i2c
[
i
]
!=
I2C_CLIENT
_END
);
i
+=
1
)
{
if
(
addr
==
address_data
->
normal_i2c
[
i
])
{
found
=
1
;
dev_dbg
(
&
adapter
->
dev
,
"found normal i2c entry for adapter %d, addr %02x"
,
adapter_id
,
addr
);
}
}
for
(
i
=
0
;
!
found
&&
(
address_data
->
normal_i2c_range
[
i
]
!=
SENSORS_I2C
_END
);
i
+=
2
)
{
for
(
i
=
0
;
!
found
&&
(
address_data
->
normal_i2c_range
[
i
]
!=
I2C_CLIENT
_END
);
i
+=
2
)
{
if
((
addr
>=
address_data
->
normal_i2c_range
[
i
])
&&
(
addr
<=
address_data
->
normal_i2c_range
[
i
+
1
]))
{
dev_dbg
(
&
adapter
->
dev
,
"found normal i2c_range entry for adapter %d, addr %04x
\n
"
,
adapter_id
,
addr
);
...
...
@@ -131,19 +131,19 @@ int i2c_detect(struct i2c_adapter *adapter,
}
for
(
i
=
0
;
!
found
&&
(
address_data
->
probe
[
i
]
!=
SENSORS_I2C
_END
);
!
found
&&
(
address_data
->
probe
[
i
]
!=
I2C_CLIENT
_END
);
i
+=
2
)
{
if
(((
adapter_id
==
address_data
->
probe
[
i
])
||
((
address_data
->
probe
[
i
]
==
SENSORS_
ANY_I2C_BUS
)
&
!
is_isa
))
probe
[
i
]
==
ANY_I2C_BUS
)
&
!
is_isa
))
&&
(
addr
==
address_data
->
probe
[
i
+
1
]))
{
dev_dbg
(
&
adapter
->
dev
,
"found probe parameter for adapter %d, addr %04x
\n
"
,
adapter_id
,
addr
);
found
=
1
;
}
}
for
(
i
=
0
;
!
found
&&
(
address_data
->
probe_range
[
i
]
!=
SENSORS_I2C
_END
);
i
+=
3
)
{
for
(
i
=
0
;
!
found
&&
(
address_data
->
probe_range
[
i
]
!=
I2C_CLIENT
_END
);
i
+=
3
)
{
if
(
((
adapter_id
==
address_data
->
probe_range
[
i
])
||
((
address_data
->
probe_range
[
i
]
==
SENSORS_
ANY_I2C_BUS
)
&
!
is_isa
))
&&
((
address_data
->
probe_range
[
i
]
==
ANY_I2C_BUS
)
&
!
is_isa
))
&&
(
addr
>=
address_data
->
probe_range
[
i
+
1
])
&&
(
addr
<=
address_data
->
probe_range
[
i
+
2
]))
{
found
=
1
;
...
...
@@ -163,20 +163,8 @@ int i2c_detect(struct i2c_adapter *adapter,
return
0
;
}
static
int
__init
i2c_sensor_init
(
void
)
{
return
0
;
}
static
void
__exit
i2c_sensor_exit
(
void
)
{
}
EXPORT_SYMBOL
(
i2c_detect
);
MODULE_AUTHOR
(
"Frodo Looijaard <frodol@dds.nl>"
);
MODULE_DESCRIPTION
(
"i2c-sensor driver"
);
MODULE_LICENSE
(
"GPL"
);
module_init
(
i2c_sensor_init
);
module_exit
(
i2c_sensor_exit
);
drivers/media/video/msp3400.c
View file @
c3efc929
...
...
@@ -1208,8 +1208,7 @@ static int msp3410d_thread(void *data)
/* ----------------------------------------------------------------------- */
static
int
msp_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
);
static
int
msp_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
int
kind
);
static
int
msp_detach
(
struct
i2c_client
*
client
);
static
int
msp_probe
(
struct
i2c_adapter
*
adap
);
static
int
msp_command
(
struct
i2c_client
*
client
,
unsigned
int
cmd
,
void
*
arg
);
...
...
@@ -1233,8 +1232,7 @@ static struct i2c_client client_template =
},
};
static
int
msp_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
static
int
msp_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
int
kind
)
{
DECLARE_MUTEX_LOCKED
(
sem
);
struct
msp3400c
*
msp
;
...
...
drivers/media/video/saa5249.c
View file @
c3efc929
...
...
@@ -149,7 +149,7 @@ static struct i2c_client_address_data addr_data = {
static
struct
i2c_client
client_template
;
static
int
saa5249_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
static
int
saa5249_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
int
kind
)
{
int
pgbuf
;
int
err
;
...
...
drivers/media/video/saa7111.c
View file @
c3efc929
...
...
@@ -66,7 +66,7 @@ static struct i2c_client client_template;
/* ----------------------------------------------------------------------- */
static
int
saa7111_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
static
int
saa7111_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
int
kind
)
{
int
i
;
struct
saa7111
*
decoder
;
...
...
drivers/media/video/tda7432.c
View file @
c3efc929
...
...
@@ -312,8 +312,7 @@ static void do_tda7432_init(struct i2c_client *client)
* i2c interface functions *
* *********************** */
static
int
tda7432_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
static
int
tda7432_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
int
kind
)
{
struct
tda7432
*
t
;
struct
i2c_client
*
client
;
...
...
drivers/media/video/tda9840.c
View file @
c3efc929
...
...
@@ -178,7 +178,7 @@ static int tda9840_command(struct i2c_client *client, unsigned int cmd, void* ar
return
0
;
}
static
int
tda9840_detect
(
struct
i2c_adapter
*
adapter
,
int
address
,
unsigned
short
flags
,
int
kind
)
static
int
tda9840_detect
(
struct
i2c_adapter
*
adapter
,
int
address
,
int
kind
)
{
struct
i2c_client
*
client
;
int
result
=
0
;
...
...
drivers/media/video/tda9875.c
View file @
c3efc929
...
...
@@ -240,8 +240,7 @@ static int tda9875_checkit(struct i2c_adapter *adap, int addr)
return
(
0
);
}
static
int
tda9875_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
static
int
tda9875_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
int
kind
)
{
struct
tda9875
*
t
;
struct
i2c_client
*
client
;
...
...
drivers/media/video/tda9887.c
View file @
c3efc929
...
...
@@ -345,8 +345,7 @@ static int tda9887_configure(struct tda9887 *t)
/* ---------------------------------------------------------------------- */
static
int
tda9887_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
static
int
tda9887_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
int
kind
)
{
struct
tda9887
*
t
;
...
...
drivers/media/video/tea6415c.c
View file @
c3efc929
...
...
@@ -55,7 +55,7 @@ static struct i2c_driver driver;
static
int
tea6415c_id
=
0
;
/* this function is called by i2c_probe */
static
int
tea6415c_detect
(
struct
i2c_adapter
*
adapter
,
int
address
,
unsigned
short
flags
,
int
kind
)
static
int
tea6415c_detect
(
struct
i2c_adapter
*
adapter
,
int
address
,
int
kind
)
{
struct
i2c_client
*
client
=
0
;
int
err
=
0
;
...
...
drivers/media/video/tea6420.c
View file @
c3efc929
...
...
@@ -95,7 +95,7 @@ static int tea6420_switch(struct i2c_client *client, int i, int o, int g)
}
/* this function is called by i2c_probe */
static
int
tea6420_detect
(
struct
i2c_adapter
*
adapter
,
int
address
,
unsigned
short
flags
,
int
kind
)
static
int
tea6420_detect
(
struct
i2c_adapter
*
adapter
,
int
address
,
int
kind
)
{
struct
i2c_client
*
client
;
int
err
=
0
,
i
=
0
;
...
...
drivers/media/video/tuner-3036.c
View file @
c3efc929
...
...
@@ -114,8 +114,7 @@ set_tv_freq(struct i2c_client *c, int freq)
/* ---------------------------------------------------------------------- */
static
int
tuner_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
tuner_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
int
kind
)
{
static
unsigned
char
buffer
[]
=
{
0x29
,
0x32
,
0x2a
,
0
,
0x2b
,
0
};
...
...
drivers/media/video/tuner.c
View file @
c3efc929
...
...
@@ -776,8 +776,7 @@ static void set_radio_freq(struct i2c_client *c, int freq)
/* ---------------------------------------------------------------------- */
static
int
tuner_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
static
int
tuner_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
int
kind
)
{
struct
tuner
*
t
;
struct
i2c_client
*
client
;
...
...
drivers/media/video/tvaudio.c
View file @
c3efc929
...
...
@@ -1326,8 +1326,7 @@ static struct CHIPDESC chiplist[] = {
/* ---------------------------------------------------------------------- */
/* i2c registration */
static
int
chip_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
unsigned
short
flags
,
int
kind
)
static
int
chip_attach
(
struct
i2c_adapter
*
adap
,
int
addr
,
int
kind
)
{
struct
CHIPSTATE
*
chip
;
struct
CHIPDESC
*
desc
;
...
...
include/linux/i2c-sensor.h
View file @
c3efc929
...
...
@@ -22,18 +22,6 @@
#ifndef _LINUX_I2C_SENSOR_H
#define _LINUX_I2C_SENSOR_H
#include <linux/sysctl.h>
/* The type of callback functions used in sensors_{proc,sysctl}_real */
typedef
void
(
*
i2c_real_callback
)
(
struct
i2c_client
*
client
,
int
operation
,
int
ctl_name
,
int
*
nrels_mag
,
long
*
results
);
/* Values for the operation field in the above function type */
#define SENSORS_PROC_REAL_INFO 1
#define SENSORS_PROC_REAL_READ 2
#define SENSORS_PROC_REAL_WRITE 3
/* A structure containing detect information.
Force variables overrule all other variables; they force a detection on
that place. If a specific chip is given, the module blindly assumes this
...
...
@@ -41,8 +29,8 @@ typedef void (*i2c_real_callback) (struct i2c_client * client,
will still try to figure out what type of chip is present. This is useful
if for some reasons the detect for SMBus or ISA address space filled
fails.
probe: insmod parameter. Initialize this list with
SENSORS_I2C
_END values.
A list of pairs. The first value is a bus number (
SENSORS
_ISA_BUS for
probe: insmod parameter. Initialize this list with
I2C_CLIENT_ISA
_END values.
A list of pairs. The first value is a bus number (
ANY_I2C
_ISA_BUS for
the ISA bus, -1 for any I2C bus), the second is the address.
kind: The kind of chip. 0 equals any chip.
*/
...
...
@@ -52,10 +40,10 @@ struct i2c_force_data {
};
/* A structure containing the detect information.
normal_i2c: filled in by the module writer. Terminated by
SENSORS_I2C
_END.
normal_i2c: filled in by the module writer. Terminated by
I2C_CLIENT_ISA
_END.
A list of I2C addresses which should normally be examined.
normal_i2c_range: filled in by the module writer. Terminated by
SENSORS_I2C
_END
I2C_CLIENT_ISA
_END
A list of pairs of I2C addresses, each pair being an inclusive range of
addresses which should normally be examined.
normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.
...
...
@@ -66,24 +54,24 @@ struct i2c_force_data {
range of addresses which should normally be examined. The third is the
modulo parameter: only addresses which are 0 module this value relative
to the first address of the range are actually considered.
probe: insmod parameter. Initialize this list with
SENSORS_I2C
_END values.
A list of pairs. The first value is a bus number (
SENSORS
_ISA_BUS for
probe: insmod parameter. Initialize this list with
I2C_CLIENT_ISA
_END values.
A list of pairs. The first value is a bus number (
ANY_I2C
_ISA_BUS for
the ISA bus, -1 for any I2C bus), the second is the address. These
addresses are also probed, as if they were in the 'normal' list.
probe_range: insmod parameter. Initialize this list with
SENSORS_I2C
_END
probe_range: insmod parameter. Initialize this list with
I2C_CLIENT_ISA
_END
values.
A list of triples. The first value is a bus number (
SENSORS
_ISA_BUS for
A list of triples. The first value is a bus number (
ANY_I2C
_ISA_BUS for
the ISA bus, -1 for any I2C bus), the second and third are addresses.
These form an inclusive range of addresses that are also probed, as
if they were in the 'normal' list.
ignore: insmod parameter. Initialize this list with
SENSORS_I2C
_END values.
A list of pairs. The first value is a bus number (
SENSORS
_ISA_BUS for
ignore: insmod parameter. Initialize this list with
I2C_CLIENT_ISA
_END values.
A list of pairs. The first value is a bus number (
ANY_I2C
_ISA_BUS for
the ISA bus, -1 for any I2C bus), the second is the I2C address. These
addresses are never probed. This parameter overrules 'normal' and
'probe', but not the 'force' lists.
ignore_range: insmod parameter. Initialize this list with
SENSORS_I2C
_END
ignore_range: insmod parameter. Initialize this list with
I2C_CLIENT_ISA
_END
values.
A list of triples. The first value is a bus number (
SENSORS
_ISA_BUS for
A list of triples. The first value is a bus number (
ANY_I2C
_ISA_BUS for
the ISA bus, -1 for any I2C bus), the second and third are addresses.
These form an inclusive range of I2C addresses that are never probed.
This parameter overrules 'normal' and 'probe', but not the 'force' lists.
...
...
@@ -102,74 +90,35 @@ struct i2c_address_data {
struct
i2c_force_data
*
forces
;
};
/* Internal numbers to terminate lists */
#define SENSORS_I2C_END 0xfffe
#define SENSORS_ISA_END 0xfffefffe
/* The numbers to use to set an ISA or I2C bus address */
#define SENSORS_ISA_BUS 9191
#define SENSORS_ANY_I2C_BUS 0xffff
/* The length of the option lists */
#define SENSORS_MAX_OPTS 48
/* Default fill of many variables */
#define SENSORS_DEFAULTS {SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END, \
SENSORS_I2C_END, SENSORS_I2C_END, SENSORS_I2C_END}
/* This is ugly. We need to evaluate SENSORS_MAX_OPTS before it is
stringified */
#define SENSORS_MODPARM_AUX1(x) "1-" #x "h"
#define SENSORS_MODPARM_AUX(x) SENSORS_MODPARM_AUX1(x)
#define SENSORS_MODPARM SENSORS_MODPARM_AUX(SENSORS_MAX_OPTS)
/* SENSORS_MODULE_PARM creates a module parameter, and puts it in the
module header */
#define SENSORS_MODULE_PARM(var,desc) \
static unsigned short var[SENSORS_MAX_OPTS] = SENSORS_DEFAULTS; \
MODULE_PARM(var,SENSORS_MODPARM); \
MODULE_PARM_DESC(var,desc)
/* SENSORS_MODULE_PARM creates a 'force_*' module parameter, and puts it in
the module header */
#define SENSORS_MODULE_PARM_FORCE(name) \
SENSORS
_MODULE_PARM(force_ ## name, \
I2C_CLIENT
_MODULE_PARM(force_ ## name, \
"List of adapter,address pairs which are unquestionably" \
" assumed to contain a `" # name "' chip")
/* This defines several insmod variables, and the addr_data structure */
#define SENSORS_INSMOD \
SENSORS
_MODULE_PARM(probe, \
I2C_CLIENT
_MODULE_PARM(probe, \
"List of adapter,address pairs to scan additionally"); \
SENSORS
_MODULE_PARM(probe_range, \
I2C_CLIENT
_MODULE_PARM(probe_range, \
"List of adapter,start-addr,end-addr triples to scan " \
"additionally"); \
SENSORS
_MODULE_PARM(ignore, \
I2C_CLIENT
_MODULE_PARM(ignore, \
"List of adapter,address pairs not to scan"); \
SENSORS
_MODULE_PARM(ignore_range, \
I2C_CLIENT
_MODULE_PARM(ignore_range, \
"List of adapter,start-addr,end-addr triples not to " \
"scan"); \
static struct i2c_address_data addr_data = \
{normal_i2c, normal_i2c_range, \
normal_isa, normal_isa_range, \
probe, probe_range, \
ignore, ignore_range, \
forces}
static struct i2c_address_data addr_data = { \
.normal_i2c = normal_i2c, \
.normal_i2c_range = normal_i2c_range, \
.normal_isa = normal_isa, \
.normal_isa_range = normal_isa_range, \
.probe = probe, \
.probe_range = probe_range, \
.ignore = ignore, \
.ignore_range = ignore_range, \
.forces = forces, \
}
/* The following functions create an enum with the chip names as elements.
The first element of the enum is any_chip. These are the only macros
...
...
@@ -177,7 +126,7 @@ struct i2c_address_data {
#define SENSORS_INSMOD_0 \
enum chips { any_chip }; \
SENSORS
_MODULE_PARM(force, \
I2C_CLIENT
_MODULE_PARM(force, \
"List of adapter,address pairs to boldly assume " \
"to be present"); \
static struct i2c_force_data forces[] = {{force,any_chip},{NULL}}; \
...
...
@@ -185,7 +134,7 @@ struct i2c_address_data {
#define SENSORS_INSMOD_1(chip1) \
enum chips { any_chip, chip1 }; \
SENSORS
_MODULE_PARM(force, \
I2C_CLIENT
_MODULE_PARM(force, \
"List of adapter,address pairs to boldly assume " \
"to be present"); \
SENSORS_MODULE_PARM_FORCE(chip1); \
...
...
@@ -196,7 +145,7 @@ struct i2c_address_data {
#define SENSORS_INSMOD_2(chip1,chip2) \
enum chips { any_chip, chip1, chip2 }; \
SENSORS
_MODULE_PARM(force, \
I2C_CLIENT
_MODULE_PARM(force, \
"List of adapter,address pairs to boldly assume " \
"to be present"); \
SENSORS_MODULE_PARM_FORCE(chip1); \
...
...
@@ -209,7 +158,7 @@ struct i2c_address_data {
#define SENSORS_INSMOD_3(chip1,chip2,chip3) \
enum chips { any_chip, chip1, chip2, chip3 }; \
SENSORS
_MODULE_PARM(force, \
I2C_CLIENT
_MODULE_PARM(force, \
"List of adapter,address pairs to boldly assume " \
"to be present"); \
SENSORS_MODULE_PARM_FORCE(chip1); \
...
...
@@ -224,7 +173,7 @@ struct i2c_address_data {
#define SENSORS_INSMOD_4(chip1,chip2,chip3,chip4) \
enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
SENSORS
_MODULE_PARM(force, \
I2C_CLIENT
_MODULE_PARM(force, \
"List of adapter,address pairs to boldly assume " \
"to be present"); \
SENSORS_MODULE_PARM_FORCE(chip1); \
...
...
@@ -241,7 +190,7 @@ struct i2c_address_data {
#define SENSORS_INSMOD_5(chip1,chip2,chip3,chip4,chip5) \
enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
SENSORS
_MODULE_PARM(force, \
I2C_CLIENT
_MODULE_PARM(force, \
"List of adapter,address pairs to boldly assume " \
"to be present"); \
SENSORS_MODULE_PARM_FORCE(chip1); \
...
...
@@ -260,7 +209,7 @@ struct i2c_address_data {
#define SENSORS_INSMOD_6(chip1,chip2,chip3,chip4,chip5,chip6) \
enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
SENSORS
_MODULE_PARM(force, \
I2C_CLIENT
_MODULE_PARM(force, \
"List of adapter,address pairs to boldly assume " \
"to be present"); \
SENSORS_MODULE_PARM_FORCE(chip1); \
...
...
@@ -281,7 +230,7 @@ struct i2c_address_data {
#define SENSORS_INSMOD_7(chip1,chip2,chip3,chip4,chip5,chip6,chip7) \
enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7 }; \
SENSORS
_MODULE_PARM(force, \
I2C_CLIENT
_MODULE_PARM(force, \
"List of adapter,address pairs to boldly assume " \
"to be present"); \
SENSORS_MODULE_PARM_FORCE(chip1); \
...
...
@@ -304,7 +253,7 @@ struct i2c_address_data {
#define SENSORS_INSMOD_8(chip1,chip2,chip3,chip4,chip5,chip6,chip7,chip8) \
enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8 }; \
SENSORS
_MODULE_PARM(force, \
I2C_CLIENT
_MODULE_PARM(force, \
"List of adapter,address pairs to boldly assume " \
"to be present"); \
SENSORS_MODULE_PARM_FORCE(chip1); \
...
...
@@ -327,16 +276,13 @@ struct i2c_address_data {
{NULL}}; \
SENSORS_INSMOD
typedef
int
i2c_found_addr_proc
(
struct
i2c_adapter
*
adapter
,
int
addr
,
int
kind
);
/* Detect function. It iterates over all possible addresses itself. For
SMBus addresses, it will only call found_proc if some client is connected
to the SMBus (unless a 'force' matched); for ISA detections, this is not
done. */
extern
int
i2c_detect
(
struct
i2c_adapter
*
adapter
,
struct
i2c_address_data
*
address_data
,
i2c_found_addr_proc
*
found_proc
);
int
(
*
found_proc
)
(
struct
i2c_adapter
*
,
int
,
int
)
);
/* This macro is used to scale user-input to sensible values in almost all
...
...
@@ -350,24 +296,4 @@ static inline int SENSORS_LIMIT(long value, long low, long high)
else
return
value
;
}
/* The maximum length of the prefix */
#define SENSORS_PREFIX_MAX 20
/* Sysctl IDs */
#ifdef DEV_HWMON
#define DEV_SENSORS DEV_HWMON
#else
/* ndef DEV_HWMOM */
#define DEV_SENSORS 2
/* The id of the lm_sensors directory within the
dev table */
#endif
/* def DEV_HWMON */
#define SENSORS_CHIPS 1
struct
i2c_chips_data
{
int
sysctl_id
;
char
name
[
SENSORS_PREFIX_MAX
+
13
];
};
#endif
/* def _LINUX_I2C_SENSOR_H */
include/linux/i2c.h
View file @
c3efc929
...
...
@@ -291,9 +291,11 @@ struct i2c_client_address_data {
/* Internal numbers to terminate lists */
#define I2C_CLIENT_END 0xfffe
#define I2C_CLIENT_ISA_END 0xfffefffe
/* The numbers to use to set I2C bus address */
#define ANY_I2C_BUS 0xffff
#define ANY_I2C_ISA_BUS 9191
/* The length of the option lists */
#define I2C_CLIENT_MAX_OPTS 48
...
...
@@ -338,12 +340,9 @@ extern int i2c_check_addr (struct i2c_adapter *adapter, int addr);
* It will only call found_proc if some client is connected at the
* specific address (unless a 'force' matched);
*/
typedef
int
i2c_client_found_addr_proc
(
struct
i2c_adapter
*
adapter
,
int
addr
,
unsigned
short
flags
,
int
kind
);
extern
int
i2c_probe
(
struct
i2c_adapter
*
adapter
,
struct
i2c_client_address_data
*
address_data
,
i
2c_client_found_addr_proc
*
found_proc
);
i
nt
(
*
found_proc
)
(
struct
i2c_adapter
*
,
int
,
int
)
);
/* An ioctl like call to set div. parameters of the adapter.
*/
...
...
@@ -559,11 +558,15 @@ union i2c_smbus_data {
I2C_CLIENT_MODULE_PARM(force, \
"List of adapter,address pairs to boldly assume " \
"to be present"); \
static struct i2c_client_address_data addr_data = \
{normal_i2c, normal_i2c_range, \
probe, probe_range, \
ignore, ignore_range, \
force}
static struct i2c_client_address_data addr_data = { \
.normal_i2c = normal_i2c, \
.normal_i2c_range = normal_i2c_range, \
.probe = probe, \
.probe_range = probe_range, \
.ignore = ignore, \
.ignore_range = ignore_range, \
.force = force, \
}
/* Detect whether we are on the isa bus. If this returns true, all i2c
access will fail! */
...
...
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