diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-22 13:42:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-22 13:42:54 -0400 |
commit | 4e93d3e8859c834ee18dfd33051d24df8669d0c0 (patch) | |
tree | 13f5b39730857257b5040471618e9bcce30ed9cc /drivers | |
parent | a0cd30fd26a398c0c6e50c6760610d4529f17a84 (diff) | |
parent | 0087e5ef577d0d6e664be7ab4be513b6a482e7ec (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6
Diffstat (limited to 'drivers')
109 files changed, 5013 insertions, 1173 deletions
diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c index ad7ae7ab8920..141b4c237a50 100644 --- a/drivers/acorn/char/pcf8583.c +++ b/drivers/acorn/char/pcf8583.c | |||
@@ -26,11 +26,8 @@ static unsigned short normal_addr[] = { 0x50, I2C_CLIENT_END }; | |||
26 | 26 | ||
27 | static struct i2c_client_address_data addr_data = { | 27 | static struct i2c_client_address_data addr_data = { |
28 | .normal_i2c = normal_addr, | 28 | .normal_i2c = normal_addr, |
29 | .normal_i2c_range = ignore, | ||
30 | .probe = ignore, | 29 | .probe = ignore, |
31 | .probe_range = ignore, | ||
32 | .ignore = ignore, | 30 | .ignore = ignore, |
33 | .ignore_range = ignore, | ||
34 | .force = ignore, | 31 | .force = ignore, |
35 | }; | 32 | }; |
36 | 33 | ||
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index c3d912cbbbc3..cc3a952401f2 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c | |||
@@ -49,7 +49,7 @@ static int i2c_debug=0; | |||
49 | /* | 49 | /* |
50 | * Generate a start condition on the i2c bus. | 50 | * Generate a start condition on the i2c bus. |
51 | * | 51 | * |
52 | * returns after the start condition has occured | 52 | * returns after the start condition has occurred |
53 | */ | 53 | */ |
54 | static void pca_start(struct i2c_algo_pca_data *adap) | 54 | static void pca_start(struct i2c_algo_pca_data *adap) |
55 | { | 55 | { |
@@ -62,9 +62,9 @@ static void pca_start(struct i2c_algo_pca_data *adap) | |||
62 | } | 62 | } |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * Generate a repeated start condition on the i2c bus | 65 | * Generate a repeated start condition on the i2c bus |
66 | * | 66 | * |
67 | * return after the repeated start condition has occured | 67 | * return after the repeated start condition has occurred |
68 | */ | 68 | */ |
69 | static void pca_repeated_start(struct i2c_algo_pca_data *adap) | 69 | static void pca_repeated_start(struct i2c_algo_pca_data *adap) |
70 | { | 70 | { |
@@ -82,7 +82,7 @@ static void pca_repeated_start(struct i2c_algo_pca_data *adap) | |||
82 | * returns after the stop condition has been generated | 82 | * returns after the stop condition has been generated |
83 | * | 83 | * |
84 | * STOPs do not generate an interrupt or set the SI flag, since the | 84 | * STOPs do not generate an interrupt or set the SI flag, since the |
85 | * part returns the the idle state (0xf8). Hence we don't need to | 85 | * part returns the idle state (0xf8). Hence we don't need to |
86 | * pca_wait here. | 86 | * pca_wait here. |
87 | */ | 87 | */ |
88 | static void pca_stop(struct i2c_algo_pca_data *adap) | 88 | static void pca_stop(struct i2c_algo_pca_data *adap) |
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c index 35789bb7126a..f2785499237b 100644 --- a/drivers/i2c/algos/i2c-algo-sibyte.c +++ b/drivers/i2c/algos/i2c-algo-sibyte.c | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | /* Ported for SiByte SOCs by Broadcom Corporation. */ | 25 | /* Ported for SiByte SOCs by Broadcom Corporation. */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index a0018de3bef4..916ba5e40a96 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -7,7 +7,7 @@ menu "I2C Hardware Bus support" | |||
7 | 7 | ||
8 | config I2C_ALI1535 | 8 | config I2C_ALI1535 |
9 | tristate "ALI 1535" | 9 | tristate "ALI 1535" |
10 | depends on I2C && PCI && EXPERIMENTAL | 10 | depends on I2C && PCI |
11 | help | 11 | help |
12 | If you say yes to this option, support will be included for the SMB | 12 | If you say yes to this option, support will be included for the SMB |
13 | Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB | 13 | Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB |
@@ -31,7 +31,7 @@ config I2C_ALI1563 | |||
31 | 31 | ||
32 | config I2C_ALI15X3 | 32 | config I2C_ALI15X3 |
33 | tristate "ALI 15x3" | 33 | tristate "ALI 15x3" |
34 | depends on I2C && PCI && EXPERIMENTAL | 34 | depends on I2C && PCI |
35 | help | 35 | help |
36 | If you say yes to this option, support will be included for the | 36 | If you say yes to this option, support will be included for the |
37 | Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces. | 37 | Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces. |
@@ -41,7 +41,7 @@ config I2C_ALI15X3 | |||
41 | 41 | ||
42 | config I2C_AMD756 | 42 | config I2C_AMD756 |
43 | tristate "AMD 756/766/768/8111 and nVidia nForce" | 43 | tristate "AMD 756/766/768/8111 and nVidia nForce" |
44 | depends on I2C && PCI && EXPERIMENTAL | 44 | depends on I2C && PCI |
45 | help | 45 | help |
46 | If you say yes to this option, support will be included for the AMD | 46 | If you say yes to this option, support will be included for the AMD |
47 | 756/766/768 mainboard I2C interfaces. The driver also includes | 47 | 756/766/768 mainboard I2C interfaces. The driver also includes |
@@ -66,7 +66,7 @@ config I2C_AMD756_S4882 | |||
66 | 66 | ||
67 | config I2C_AMD8111 | 67 | config I2C_AMD8111 |
68 | tristate "AMD 8111" | 68 | tristate "AMD 8111" |
69 | depends on I2C && PCI && EXPERIMENTAL | 69 | depends on I2C && PCI |
70 | help | 70 | help |
71 | If you say yes to this option, support will be included for the | 71 | If you say yes to this option, support will be included for the |
72 | second (SMBus 2.0) AMD 8111 mainboard I2C interface. | 72 | second (SMBus 2.0) AMD 8111 mainboard I2C interface. |
@@ -109,7 +109,7 @@ config I2C_HYDRA | |||
109 | 109 | ||
110 | config I2C_I801 | 110 | config I2C_I801 |
111 | tristate "Intel 82801 (ICH)" | 111 | tristate "Intel 82801 (ICH)" |
112 | depends on I2C && PCI && EXPERIMENTAL | 112 | depends on I2C && PCI |
113 | help | 113 | help |
114 | If you say yes to this option, support will be included for the Intel | 114 | If you say yes to this option, support will be included for the Intel |
115 | 801 family of mainboard I2C interfaces. Specifically, the following | 115 | 801 family of mainboard I2C interfaces. Specifically, the following |
@@ -130,7 +130,7 @@ config I2C_I801 | |||
130 | 130 | ||
131 | config I2C_I810 | 131 | config I2C_I810 |
132 | tristate "Intel 810/815" | 132 | tristate "Intel 810/815" |
133 | depends on I2C && PCI && EXPERIMENTAL | 133 | depends on I2C && PCI |
134 | select I2C_ALGOBIT | 134 | select I2C_ALGOBIT |
135 | help | 135 | help |
136 | If you say yes to this option, support will be included for the Intel | 136 | If you say yes to this option, support will be included for the Intel |
@@ -183,7 +183,7 @@ config I2C_IOP3XX | |||
183 | 183 | ||
184 | config I2C_ISA | 184 | config I2C_ISA |
185 | tristate "ISA Bus support" | 185 | tristate "ISA Bus support" |
186 | depends on I2C && EXPERIMENTAL | 186 | depends on I2C |
187 | help | 187 | help |
188 | If you say yes to this option, support will be included for i2c | 188 | If you say yes to this option, support will be included for i2c |
189 | interfaces that are on the ISA bus. | 189 | interfaces that are on the ISA bus. |
@@ -248,12 +248,11 @@ config I2C_MPC | |||
248 | will be called i2c-mpc. | 248 | will be called i2c-mpc. |
249 | 249 | ||
250 | config I2C_NFORCE2 | 250 | config I2C_NFORCE2 |
251 | tristate "Nvidia Nforce2" | 251 | tristate "Nvidia nForce2, nForce3 and nForce4" |
252 | depends on I2C && PCI && EXPERIMENTAL | 252 | depends on I2C && PCI |
253 | help | 253 | help |
254 | If you say yes to this option, support will be included for the Nvidia | 254 | If you say yes to this option, support will be included for the Nvidia |
255 | Nforce2 family of mainboard I2C interfaces. | 255 | nForce2, nForce3 and nForce4 families of mainboard I2C interfaces. |
256 | This driver also supports the nForce3 Pro 150 MCP. | ||
257 | 256 | ||
258 | This driver can also be built as a module. If so, the module | 257 | This driver can also be built as a module. If so, the module |
259 | will be called i2c-nforce2. | 258 | will be called i2c-nforce2. |
@@ -305,7 +304,7 @@ config I2C_PARPORT_LIGHT | |||
305 | 304 | ||
306 | config I2C_PROSAVAGE | 305 | config I2C_PROSAVAGE |
307 | tristate "S3/VIA (Pro)Savage" | 306 | tristate "S3/VIA (Pro)Savage" |
308 | depends on I2C && PCI && EXPERIMENTAL | 307 | depends on I2C && PCI |
309 | select I2C_ALGOBIT | 308 | select I2C_ALGOBIT |
310 | help | 309 | help |
311 | If you say yes to this option, support will be included for the | 310 | If you say yes to this option, support will be included for the |
@@ -388,7 +387,7 @@ config SCx200_ACB | |||
388 | 387 | ||
389 | config I2C_SIS5595 | 388 | config I2C_SIS5595 |
390 | tristate "SiS 5595" | 389 | tristate "SiS 5595" |
391 | depends on I2C && PCI && EXPERIMENTAL | 390 | depends on I2C && PCI |
392 | help | 391 | help |
393 | If you say yes to this option, support will be included for the | 392 | If you say yes to this option, support will be included for the |
394 | SiS5595 SMBus (a subset of I2C) interface. | 393 | SiS5595 SMBus (a subset of I2C) interface. |
@@ -398,7 +397,7 @@ config I2C_SIS5595 | |||
398 | 397 | ||
399 | config I2C_SIS630 | 398 | config I2C_SIS630 |
400 | tristate "SiS 630/730" | 399 | tristate "SiS 630/730" |
401 | depends on I2C && PCI && EXPERIMENTAL | 400 | depends on I2C && PCI |
402 | help | 401 | help |
403 | If you say yes to this option, support will be included for the | 402 | If you say yes to this option, support will be included for the |
404 | SiS630 and SiS730 SMBus (a subset of I2C) interface. | 403 | SiS630 and SiS730 SMBus (a subset of I2C) interface. |
@@ -408,7 +407,7 @@ config I2C_SIS630 | |||
408 | 407 | ||
409 | config I2C_SIS96X | 408 | config I2C_SIS96X |
410 | tristate "SiS 96x" | 409 | tristate "SiS 96x" |
411 | depends on I2C && PCI && EXPERIMENTAL | 410 | depends on I2C && PCI |
412 | help | 411 | help |
413 | If you say yes to this option, support will be included for the SiS | 412 | If you say yes to this option, support will be included for the SiS |
414 | 96x SMBus (a subset of I2C) interfaces. Specifically, the following | 413 | 96x SMBus (a subset of I2C) interfaces. Specifically, the following |
@@ -419,6 +418,7 @@ config I2C_SIS96X | |||
419 | 648/961 | 418 | 648/961 |
420 | 650/961 | 419 | 650/961 |
421 | 735 | 420 | 735 |
421 | 745 | ||
422 | 422 | ||
423 | This driver can also be built as a module. If so, the module | 423 | This driver can also be built as a module. If so, the module |
424 | will be called i2c-sis96x. | 424 | will be called i2c-sis96x. |
@@ -449,7 +449,7 @@ config I2C_VIA | |||
449 | 449 | ||
450 | config I2C_VIAPRO | 450 | config I2C_VIAPRO |
451 | tristate "VIA 82C596/82C686/823x" | 451 | tristate "VIA 82C596/82C686/823x" |
452 | depends on I2C && PCI && EXPERIMENTAL | 452 | depends on I2C && PCI |
453 | help | 453 | help |
454 | If you say yes to this option, support will be included for the VIA | 454 | If you say yes to this option, support will be included for the VIA |
455 | 82C596/82C686/823x I2C interfaces. Specifically, the following | 455 | 82C596/82C686/823x I2C interfaces. Specifically, the following |
@@ -467,7 +467,7 @@ config I2C_VIAPRO | |||
467 | 467 | ||
468 | config I2C_VOODOO3 | 468 | config I2C_VOODOO3 |
469 | tristate "Voodoo 3" | 469 | tristate "Voodoo 3" |
470 | depends on I2C && PCI && EXPERIMENTAL | 470 | depends on I2C && PCI |
471 | select I2C_ALGOBIT | 471 | select I2C_ALGOBIT |
472 | help | 472 | help |
473 | If you say yes to this option, support will be included for the | 473 | If you say yes to this option, support will be included for the |
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index b00cd4098221..f634a0780cf0 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c | |||
@@ -53,7 +53,6 @@ | |||
53 | 53 | ||
54 | /* Note: we assume there can only be one ALI1535, with one SMBus interface */ | 54 | /* Note: we assume there can only be one ALI1535, with one SMBus interface */ |
55 | 55 | ||
56 | #include <linux/config.h> | ||
57 | #include <linux/module.h> | 56 | #include <linux/module.h> |
58 | #include <linux/pci.h> | 57 | #include <linux/pci.h> |
59 | #include <linux/kernel.h> | 58 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index 5bd6a4a77c1e..0f781a1a3323 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c | |||
@@ -60,7 +60,6 @@ | |||
60 | 60 | ||
61 | /* Note: we assume there can only be one ALI15X3, with one SMBus interface */ | 61 | /* Note: we assume there can only be one ALI15X3, with one SMBus interface */ |
62 | 62 | ||
63 | #include <linux/config.h> | ||
64 | #include <linux/module.h> | 63 | #include <linux/module.h> |
65 | #include <linux/pci.h> | 64 | #include <linux/pci.h> |
66 | #include <linux/kernel.h> | 65 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index eca5ed3738b8..6347ebc6fb53 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c | |||
@@ -37,7 +37,6 @@ | |||
37 | Note: we assume there can only be one device, with one SMBus interface. | 37 | Note: we assume there can only be one device, with one SMBus interface. |
38 | */ | 38 | */ |
39 | 39 | ||
40 | #include <linux/config.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
43 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index af22b401a38b..d6644481d2a0 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * the Free Software Foundation version 2. | 8 | * the Free Software Foundation version 2. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/config.h> | ||
12 | #include <linux/module.h> | 11 | #include <linux/module.h> |
13 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
14 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c index 75831a20b0bd..a7ff112e49bf 100644 --- a/drivers/i2c/busses/i2c-au1550.c +++ b/drivers/i2c/busses/i2c-au1550.c | |||
@@ -27,7 +27,6 @@ | |||
27 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 27 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
32 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
33 | #include <linux/module.h> | 32 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c index 0a7720000a0c..6930b660e508 100644 --- a/drivers/i2c/busses/i2c-elektor.c +++ b/drivers/i2c/busses/i2c-elektor.c | |||
@@ -25,7 +25,6 @@ | |||
25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of | 25 | /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of |
26 | for Alpha Processor Inc. UP-2000(+) boards */ | 26 | for Alpha Processor Inc. UP-2000(+) boards */ |
27 | 27 | ||
28 | #include <linux/config.h> | ||
29 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
30 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
31 | #include <linux/module.h> | 30 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-frodo.c b/drivers/i2c/busses/i2c-frodo.c index e093829a0bf7..b6f52f5a4138 100644 --- a/drivers/i2c/busses/i2c-frodo.c +++ b/drivers/i2c/busses/i2c-frodo.c | |||
@@ -12,7 +12,6 @@ | |||
12 | * version 2 as published by the Free Software Foundation. | 12 | * version 2 as published by the Free Software Foundation. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/config.h> | ||
16 | #include <linux/module.h> | 15 | #include <linux/module.h> |
17 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
18 | #include <linux/init.h> | 17 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 59c238c42e8c..45e6efb1dcd1 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -41,7 +41,6 @@ | |||
41 | 41 | ||
42 | /* Note: we assume there can only be one I801, with one SMBus interface */ | 42 | /* Note: we assume there can only be one I801, with one SMBus interface */ |
43 | 43 | ||
44 | #include <linux/config.h> | ||
45 | #include <linux/module.h> | 44 | #include <linux/module.h> |
46 | #include <linux/pci.h> | 45 | #include <linux/pci.h> |
47 | #include <linux/kernel.h> | 46 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c index ef358bd9c3da..0ff7016e0629 100644 --- a/drivers/i2c/busses/i2c-i810.c +++ b/drivers/i2c/busses/i2c-i810.c | |||
@@ -34,7 +34,6 @@ | |||
34 | i815 1132 | 34 | i815 1132 |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include <linux/config.h> | ||
38 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
39 | #include <linux/module.h> | 38 | #include <linux/module.h> |
40 | #include <linux/init.h> | 39 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index bb885215c08d..93ca36dc777e 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
@@ -695,7 +695,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ | |||
695 | 695 | ||
696 | dev->irq = iic_force_poll ? -1 : ocp->def->irq; | 696 | dev->irq = iic_force_poll ? -1 : ocp->def->irq; |
697 | if (dev->irq >= 0){ | 697 | if (dev->irq >= 0){ |
698 | /* Disable interrupts until we finish intialization, | 698 | /* Disable interrupts until we finish initialization, |
699 | assumes level-sensitive IRQ setup... | 699 | assumes level-sensitive IRQ setup... |
700 | */ | 700 | */ |
701 | iic_interrupt_mode(dev, 0); | 701 | iic_interrupt_mode(dev, 0); |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.h b/drivers/i2c/busses/i2c-ibm_iic.h index d819a955d890..2b3219d00e92 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.h +++ b/drivers/i2c/busses/i2c-ibm_iic.h | |||
@@ -22,7 +22,6 @@ | |||
22 | #ifndef __I2C_IBM_IIC_H_ | 22 | #ifndef __I2C_IBM_IIC_H_ |
23 | #define __I2C_IBM_IIC_H_ | 23 | #define __I2C_IBM_IIC_H_ |
24 | 24 | ||
25 | #include <linux/config.h> | ||
26 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
27 | 26 | ||
28 | struct iic_regs { | 27 | struct iic_regs { |
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index c961ba4cfb32..6b682e903f09 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c | |||
@@ -85,7 +85,7 @@ iop3xx_i2c_enable(struct i2c_algo_iop3xx_data *iop3xx_adap) | |||
85 | u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE; | 85 | u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE; |
86 | 86 | ||
87 | /* | 87 | /* |
88 | * Everytime unit enable is asserted, GPOD needs to be cleared | 88 | * Every time unit enable is asserted, GPOD needs to be cleared |
89 | * on IOP321 to avoid data corruption on the bus. | 89 | * on IOP321 to avoid data corruption on the bus. |
90 | */ | 90 | */ |
91 | #ifdef CONFIG_ARCH_IOP321 | 91 | #ifdef CONFIG_ARCH_IOP321 |
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 0f54a2a0afa5..00e7f7157b75 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -24,7 +24,6 @@ | |||
24 | the SMBus and the ISA bus very much easier. See lm78.c for an example | 24 | the SMBus and the ISA bus very much easier. See lm78.c for an example |
25 | of this. */ | 25 | of this. */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c index 702e3def1b81..5f5d2944808b 100644 --- a/drivers/i2c/busses/i2c-ite.c +++ b/drivers/i2c/busses/i2c-ite.c | |||
@@ -33,7 +33,6 @@ | |||
33 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even | 33 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even |
34 | Frodo Looijaard <frodol@dds.nl> */ | 34 | Frodo Looijaard <frodol@dds.nl> */ |
35 | 35 | ||
36 | #include <linux/config.h> | ||
37 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
38 | #include <linux/ioport.h> | 37 | #include <linux/ioport.h> |
39 | #include <linux/module.h> | 38 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c index 21cd54d02302..ec943cad2314 100644 --- a/drivers/i2c/busses/i2c-ixp2000.c +++ b/drivers/i2c/busses/i2c-ixp2000.c | |||
@@ -26,11 +26,6 @@ | |||
26 | * 'enabled' to drive the GPIOs. | 26 | * 'enabled' to drive the GPIOs. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #ifdef CONFIG_I2C_DEBUG_BUS | ||
31 | #define DEBUG 1 | ||
32 | #endif | ||
33 | |||
34 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
35 | #include <linux/init.h> | 30 | #include <linux/init.h> |
36 | #include <linux/device.h> | 31 | #include <linux/device.h> |
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index 8c55eafc3a09..f6f5ca31fdba 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -26,11 +26,6 @@ | |||
26 | * that is passed as the platform_data to this driver. | 26 | * that is passed as the platform_data to this driver. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #ifdef CONFIG_I2C_DEBUG_BUS | ||
31 | #define DEBUG 1 | ||
32 | #endif | ||
33 | |||
34 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
35 | #include <linux/init.h> | 30 | #include <linux/init.h> |
36 | #include <linux/device.h> | 31 | #include <linux/device.h> |
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c index 867d443e7133..363e545fc01f 100644 --- a/drivers/i2c/busses/i2c-keywest.c +++ b/drivers/i2c/busses/i2c-keywest.c | |||
@@ -46,7 +46,6 @@ | |||
46 | sound driver to be happy | 46 | sound driver to be happy |
47 | */ | 47 | */ |
48 | 48 | ||
49 | #include <linux/config.h> | ||
50 | #include <linux/module.h> | 49 | #include <linux/module.h> |
51 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
52 | #include <linux/ioport.h> | 51 | #include <linux/ioport.h> |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 6f33496d31c3..d41ca31dbcb2 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -325,7 +325,7 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
325 | if (i2c->irq != OCP_IRQ_NA) | 325 | if (i2c->irq != OCP_IRQ_NA) |
326 | { | 326 | { |
327 | if ((result = request_irq(ocp->def->irq, mpc_i2c_isr, | 327 | if ((result = request_irq(ocp->def->irq, mpc_i2c_isr, |
328 | 0, "i2c-mpc", i2c)) < 0) { | 328 | SA_SHIRQ, "i2c-mpc", i2c)) < 0) { |
329 | printk(KERN_ERR | 329 | printk(KERN_ERR |
330 | "i2c-mpc - failed to attach interrupt\n"); | 330 | "i2c-mpc - failed to attach interrupt\n"); |
331 | goto fail_irq; | 331 | goto fail_irq; |
@@ -333,6 +333,9 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
333 | } else | 333 | } else |
334 | i2c->irq = 0; | 334 | i2c->irq = 0; |
335 | 335 | ||
336 | mpc_i2c_setclock(i2c); | ||
337 | ocp_set_drvdata(ocp, i2c); | ||
338 | |||
336 | i2c->adap = mpc_ops; | 339 | i2c->adap = mpc_ops; |
337 | i2c_set_adapdata(&i2c->adap, i2c); | 340 | i2c_set_adapdata(&i2c->adap, i2c); |
338 | 341 | ||
@@ -341,8 +344,6 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
341 | goto fail_add; | 344 | goto fail_add; |
342 | } | 345 | } |
343 | 346 | ||
344 | mpc_i2c_setclock(i2c); | ||
345 | ocp_set_drvdata(ocp, i2c); | ||
346 | return result; | 347 | return result; |
347 | 348 | ||
348 | fail_add: | 349 | fail_add: |
@@ -358,8 +359,8 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
358 | static void __devexit mpc_i2c_remove(struct ocp_device *ocp) | 359 | static void __devexit mpc_i2c_remove(struct ocp_device *ocp) |
359 | { | 360 | { |
360 | struct mpc_i2c *i2c = ocp_get_drvdata(ocp); | 361 | struct mpc_i2c *i2c = ocp_get_drvdata(ocp); |
361 | ocp_set_drvdata(ocp, NULL); | ||
362 | i2c_del_adapter(&i2c->adap); | 362 | i2c_del_adapter(&i2c->adap); |
363 | ocp_set_drvdata(ocp, NULL); | ||
363 | 364 | ||
364 | if (ocp->def->irq != OCP_IRQ_NA) | 365 | if (ocp->def->irq != OCP_IRQ_NA) |
365 | free_irq(i2c->irq, i2c); | 366 | free_irq(i2c->irq, i2c); |
@@ -424,12 +425,15 @@ static int fsl_i2c_probe(struct device *device) | |||
424 | 425 | ||
425 | if (i2c->irq != 0) | 426 | if (i2c->irq != 0) |
426 | if ((result = request_irq(i2c->irq, mpc_i2c_isr, | 427 | if ((result = request_irq(i2c->irq, mpc_i2c_isr, |
427 | 0, "fsl-i2c", i2c)) < 0) { | 428 | SA_SHIRQ, "i2c-mpc", i2c)) < 0) { |
428 | printk(KERN_ERR | 429 | printk(KERN_ERR |
429 | "i2c-mpc - failed to attach interrupt\n"); | 430 | "i2c-mpc - failed to attach interrupt\n"); |
430 | goto fail_irq; | 431 | goto fail_irq; |
431 | } | 432 | } |
432 | 433 | ||
434 | mpc_i2c_setclock(i2c); | ||
435 | dev_set_drvdata(device, i2c); | ||
436 | |||
433 | i2c->adap = mpc_ops; | 437 | i2c->adap = mpc_ops; |
434 | i2c_set_adapdata(&i2c->adap, i2c); | 438 | i2c_set_adapdata(&i2c->adap, i2c); |
435 | i2c->adap.dev.parent = &pdev->dev; | 439 | i2c->adap.dev.parent = &pdev->dev; |
@@ -438,8 +442,6 @@ static int fsl_i2c_probe(struct device *device) | |||
438 | goto fail_add; | 442 | goto fail_add; |
439 | } | 443 | } |
440 | 444 | ||
441 | mpc_i2c_setclock(i2c); | ||
442 | dev_set_drvdata(device, i2c); | ||
443 | return result; | 445 | return result; |
444 | 446 | ||
445 | fail_add: | 447 | fail_add: |
@@ -456,8 +458,8 @@ static int fsl_i2c_remove(struct device *device) | |||
456 | { | 458 | { |
457 | struct mpc_i2c *i2c = dev_get_drvdata(device); | 459 | struct mpc_i2c *i2c = dev_get_drvdata(device); |
458 | 460 | ||
459 | dev_set_drvdata(device, NULL); | ||
460 | i2c_del_adapter(&i2c->adap); | 461 | i2c_del_adapter(&i2c->adap); |
462 | dev_set_drvdata(device, NULL); | ||
461 | 463 | ||
462 | if (i2c->irq != 0) | 464 | if (i2c->irq != 0) |
463 | free_irq(i2c->irq, i2c); | 465 | free_irq(i2c->irq, i2c); |
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 6d13127c8c4e..74eb89aa9350 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
@@ -37,7 +37,6 @@ | |||
37 | 37 | ||
38 | /* Note: we assume there can only be one nForce2, with two SMBus interfaces */ | 38 | /* Note: we assume there can only be one nForce2, with two SMBus interfaces */ |
39 | 39 | ||
40 | #include <linux/config.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
43 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c index cb5e722301d8..3e5eba9fcacb 100644 --- a/drivers/i2c/busses/i2c-parport-light.c +++ b/drivers/i2c/busses/i2c-parport-light.c | |||
@@ -24,7 +24,6 @@ | |||
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | * ------------------------------------------------------------------------ */ | 25 | * ------------------------------------------------------------------------ */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index e9560bab51c4..71a2502fe069 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c | |||
@@ -24,7 +24,6 @@ | |||
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | * ------------------------------------------------------------------------ */ | 25 | * ------------------------------------------------------------------------ */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
@@ -131,7 +130,7 @@ static int parport_getsda(void *data) | |||
131 | /* Encapsulate the functions above in the correct structure. | 130 | /* Encapsulate the functions above in the correct structure. |
132 | Note that this is only a template, from which the real structures are | 131 | Note that this is only a template, from which the real structures are |
133 | copied. The attaching code will set getscl to NULL for adapters that | 132 | copied. The attaching code will set getscl to NULL for adapters that |
134 | cannot read SCL back, and will also make the the data field point to | 133 | cannot read SCL back, and will also make the data field point to |
135 | the parallel port structure. */ | 134 | the parallel port structure. */ |
136 | static struct i2c_algo_bit_data parport_algo_data = { | 135 | static struct i2c_algo_bit_data parport_algo_data = { |
137 | .setsda = parport_setsda, | 136 | .setsda = parport_setsda, |
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c index 9c611134db9c..d9b4ddbad7e0 100644 --- a/drivers/i2c/busses/i2c-pca-isa.c +++ b/drivers/i2c/busses/i2c-pca-isa.c | |||
@@ -17,7 +17,6 @@ | |||
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/config.h> | ||
21 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
22 | #include <linux/ioport.h> | 21 | #include <linux/ioport.h> |
23 | #include <linux/module.h> | 22 | #include <linux/module.h> |
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index 646381b6b3bf..1f80ba9da6f1 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c | |||
@@ -28,7 +28,6 @@ | |||
28 | Note: we assume there can only be one device, with one SMBus interface. | 28 | Note: we assume there can only be one device, with one SMBus interface. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/config.h> | ||
32 | #include <linux/module.h> | 31 | #include <linux/module.h> |
33 | #include <linux/moduleparam.h> | 32 | #include <linux/moduleparam.h> |
34 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c index 13d66289933b..83fd16d61ce5 100644 --- a/drivers/i2c/busses/i2c-prosavage.c +++ b/drivers/i2c/busses/i2c-prosavage.c | |||
@@ -54,7 +54,6 @@ | |||
54 | * (Additional documentation needed :( | 54 | * (Additional documentation needed :( |
55 | */ | 55 | */ |
56 | 56 | ||
57 | #include <linux/config.h> | ||
58 | #include <linux/module.h> | 57 | #include <linux/module.h> |
59 | #include <linux/init.h> | 58 | #include <linux/init.h> |
60 | #include <linux/pci.h> | 59 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-rpx.c b/drivers/i2c/busses/i2c-rpx.c index 9497b1b6852f..0ebec3c1a54e 100644 --- a/drivers/i2c/busses/i2c-rpx.c +++ b/drivers/i2c/busses/i2c-rpx.c | |||
@@ -11,7 +11,6 @@ | |||
11 | * changed to eliminate RPXLite references. | 11 | * changed to eliminate RPXLite references. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/config.h> | ||
15 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
16 | #include <linux/module.h> | 15 | #include <linux/module.h> |
17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index fcfa51c1436b..a3b38257cc3d 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -20,6 +20,7 @@ | |||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/config.h> | ||
23 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | 26 | ||
@@ -533,7 +534,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int | |||
533 | /* s3c24xx_i2c_xfer | 534 | /* s3c24xx_i2c_xfer |
534 | * | 535 | * |
535 | * first port of call from the i2c bus code when an message needs | 536 | * first port of call from the i2c bus code when an message needs |
536 | * transfering across the i2c bus. | 537 | * transferring across the i2c bus. |
537 | */ | 538 | */ |
538 | 539 | ||
539 | static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, | 540 | static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, |
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c index 092d0323c6c6..0c8518298e4d 100644 --- a/drivers/i2c/busses/i2c-savage4.c +++ b/drivers/i2c/busses/i2c-savage4.c | |||
@@ -29,7 +29,6 @@ | |||
29 | it easier to add later. | 29 | it easier to add later. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <linux/config.h> | ||
33 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/init.h> | 34 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c index e5dd90bdb04a..1c99536b673b 100644 --- a/drivers/i2c/busses/i2c-sibyte.c +++ b/drivers/i2c/busses/i2c-sibyte.c | |||
@@ -17,7 +17,6 @@ | |||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/config.h> | ||
21 | #include <linux/module.h> | 20 | #include <linux/module.h> |
22 | #include <linux/i2c-algo-sibyte.h> | 21 | #include <linux/i2c-algo-sibyte.h> |
23 | #include <asm/sibyte/sb1250_regs.h> | 22 | #include <asm/sibyte/sb1250_regs.h> |
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c index 425733b019b6..2b5911cfb7b5 100644 --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c | |||
@@ -55,7 +55,6 @@ | |||
55 | * Add adapter resets | 55 | * Add adapter resets |
56 | */ | 56 | */ |
57 | 57 | ||
58 | #include <linux/config.h> | ||
59 | #include <linux/kernel.h> | 58 | #include <linux/kernel.h> |
60 | #include <linux/module.h> | 59 | #include <linux/module.h> |
61 | #include <linux/delay.h> | 60 | #include <linux/delay.h> |
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c index 58df63df1540..f58455e7689e 100644 --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c | |||
@@ -48,7 +48,6 @@ | |||
48 | Note: we assume there can only be one device, with one SMBus interface. | 48 | Note: we assume there can only be one device, with one SMBus interface. |
49 | */ | 49 | */ |
50 | 50 | ||
51 | #include <linux/config.h> | ||
52 | #include <linux/kernel.h> | 51 | #include <linux/kernel.h> |
53 | #include <linux/module.h> | 52 | #include <linux/module.h> |
54 | #include <linux/delay.h> | 53 | #include <linux/delay.h> |
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c index 3cac6d43bce5..6484792e23a1 100644 --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c | |||
@@ -32,7 +32,6 @@ | |||
32 | We assume there can only be one SiS96x with one SMBus interface. | 32 | We assume there can only be one SiS96x with one SMBus interface. |
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/config.h> | ||
36 | #include <linux/module.h> | 35 | #include <linux/module.h> |
37 | #include <linux/pci.h> | 36 | #include <linux/pci.h> |
38 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c index 19c805ead4d8..00d94e886955 100644 --- a/drivers/i2c/busses/i2c-stub.c +++ b/drivers/i2c/busses/i2c-stub.c | |||
@@ -21,7 +21,6 @@ | |||
21 | 21 | ||
22 | #define DEBUG 1 | 22 | #define DEBUG 1 |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/init.h> | 24 | #include <linux/init.h> |
26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
27 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c index 2cbc4cd22366..040b8abeabba 100644 --- a/drivers/i2c/busses/i2c-via.c +++ b/drivers/i2c/busses/i2c-via.c | |||
@@ -21,7 +21,6 @@ | |||
21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
27 | #include <linux/pci.h> | 26 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 0bb60a636e16..6b5008005c6f 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c | |||
@@ -33,7 +33,6 @@ | |||
33 | Note: we assume there can only be one device, with one SMBus interface. | 33 | Note: we assume there can only be one device, with one SMBus interface. |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <linux/config.h> | ||
37 | #include <linux/module.h> | 36 | #include <linux/module.h> |
38 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
39 | #include <linux/pci.h> | 38 | #include <linux/pci.h> |
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c index 3edf0e34155e..b675773b0cc1 100644 --- a/drivers/i2c/busses/i2c-voodoo3.c +++ b/drivers/i2c/busses/i2c-voodoo3.c | |||
@@ -27,7 +27,6 @@ | |||
27 | /* This interfaces to the I2C bus of the Voodoo3 to gain access to | 27 | /* This interfaces to the I2C bus of the Voodoo3 to gain access to |
28 | the BT869 and possibly other I2C devices. */ | 28 | the BT869 and possibly other I2C devices. */ |
29 | 29 | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
32 | #include <linux/module.h> | 31 | #include <linux/module.h> |
33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 1c4159a93623..a18bdd9aa7ba 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -24,7 +24,6 @@ | |||
24 | 24 | ||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/config.h> | ||
28 | #include <linux/module.h> | 27 | #include <linux/module.h> |
29 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
30 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index 74d23cfce2a3..a0982da09803 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig | |||
@@ -1,5 +1,5 @@ | |||
1 | # | 1 | # |
2 | # I2C Sensor device configuration | 2 | # I2C Sensor and "other" chip configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Hardware Sensors Chip support" | 5 | menu "Hardware Sensors Chip support" |
@@ -11,7 +11,7 @@ config I2C_SENSOR | |||
11 | 11 | ||
12 | config SENSORS_ADM1021 | 12 | config SENSORS_ADM1021 |
13 | tristate "Analog Devices ADM1021 and compatibles" | 13 | tristate "Analog Devices ADM1021 and compatibles" |
14 | depends on I2C && EXPERIMENTAL | 14 | depends on I2C |
15 | select I2C_SENSOR | 15 | select I2C_SENSOR |
16 | help | 16 | help |
17 | If you say yes here you get support for Analog Devices ADM1021 | 17 | If you say yes here you get support for Analog Devices ADM1021 |
@@ -29,6 +29,7 @@ config SENSORS_ADM1025 | |||
29 | help | 29 | help |
30 | If you say yes here you get support for Analog Devices ADM1025 | 30 | If you say yes here you get support for Analog Devices ADM1025 |
31 | and Philips NE1619 sensor chips. | 31 | and Philips NE1619 sensor chips. |
32 | |||
32 | This driver can also be built as a module. If so, the module | 33 | This driver can also be built as a module. If so, the module |
33 | will be called adm1025. | 34 | will be called adm1025. |
34 | 35 | ||
@@ -38,6 +39,8 @@ config SENSORS_ADM1026 | |||
38 | select I2C_SENSOR | 39 | select I2C_SENSOR |
39 | help | 40 | help |
40 | If you say yes here you get support for Analog Devices ADM1026 | 41 | If you say yes here you get support for Analog Devices ADM1026 |
42 | sensor chip. | ||
43 | |||
41 | This driver can also be built as a module. If so, the module | 44 | This driver can also be built as a module. If so, the module |
42 | will be called adm1026. | 45 | will be called adm1026. |
43 | 46 | ||
@@ -48,9 +51,21 @@ config SENSORS_ADM1031 | |||
48 | help | 51 | help |
49 | If you say yes here you get support for Analog Devices ADM1031 | 52 | If you say yes here you get support for Analog Devices ADM1031 |
50 | and ADM1030 sensor chips. | 53 | and ADM1030 sensor chips. |
54 | |||
51 | This driver can also be built as a module. If so, the module | 55 | This driver can also be built as a module. If so, the module |
52 | will be called adm1031. | 56 | will be called adm1031. |
53 | 57 | ||
58 | config SENSORS_ADM9240 | ||
59 | tristate "Analog Devices ADM9240 and compatibles" | ||
60 | depends on I2C && EXPERIMENTAL | ||
61 | select I2C_SENSOR | ||
62 | help | ||
63 | If you say yes here you get support for Analog Devices ADM9240, | ||
64 | Dallas DS1780, National Semiconductor LM81 sensor chips. | ||
65 | |||
66 | This driver can also be built as a module. If so, the module | ||
67 | will be called adm9240. | ||
68 | |||
54 | config SENSORS_ASB100 | 69 | config SENSORS_ASB100 |
55 | tristate "Asus ASB100 Bach" | 70 | tristate "Asus ASB100 Bach" |
56 | depends on I2C && EXPERIMENTAL | 71 | depends on I2C && EXPERIMENTAL |
@@ -62,6 +77,19 @@ config SENSORS_ASB100 | |||
62 | This driver can also be built as a module. If so, the module | 77 | This driver can also be built as a module. If so, the module |
63 | will be called asb100. | 78 | will be called asb100. |
64 | 79 | ||
80 | config SENSORS_ATXP1 | ||
81 | tristate "Attansic ATXP1 VID controller" | ||
82 | depends on I2C && EXPERIMENTAL | ||
83 | help | ||
84 | If you say yes here you get support for the Attansic ATXP1 VID | ||
85 | controller. | ||
86 | |||
87 | If your board have such a chip, you are able to control your CPU | ||
88 | core and other voltages. | ||
89 | |||
90 | This driver can also be built as a module. If so, the module | ||
91 | will be called atxp1. | ||
92 | |||
65 | config SENSORS_DS1621 | 93 | config SENSORS_DS1621 |
66 | tristate "Dallas Semiconductor DS1621 and DS1625" | 94 | tristate "Dallas Semiconductor DS1621 and DS1625" |
67 | depends on I2C && EXPERIMENTAL | 95 | depends on I2C && EXPERIMENTAL |
@@ -97,7 +125,7 @@ config SENSORS_FSCPOS | |||
97 | 125 | ||
98 | config SENSORS_GL518SM | 126 | config SENSORS_GL518SM |
99 | tristate "Genesys Logic GL518SM" | 127 | tristate "Genesys Logic GL518SM" |
100 | depends on I2C && EXPERIMENTAL | 128 | depends on I2C |
101 | select I2C_SENSOR | 129 | select I2C_SENSOR |
102 | help | 130 | help |
103 | If you say yes here you get support for Genesys Logic GL518SM | 131 | If you say yes here you get support for Genesys Logic GL518SM |
@@ -119,7 +147,7 @@ config SENSORS_GL520SM | |||
119 | 147 | ||
120 | config SENSORS_IT87 | 148 | config SENSORS_IT87 |
121 | tristate "ITE IT87xx and compatibles" | 149 | tristate "ITE IT87xx and compatibles" |
122 | depends on I2C && EXPERIMENTAL | 150 | depends on I2C |
123 | select I2C_SENSOR | 151 | select I2C_SENSOR |
124 | help | 152 | help |
125 | If you say yes here you get support for ITE IT87xx sensor chips | 153 | If you say yes here you get support for ITE IT87xx sensor chips |
@@ -143,7 +171,7 @@ config SENSORS_LM63 | |||
143 | 171 | ||
144 | config SENSORS_LM75 | 172 | config SENSORS_LM75 |
145 | tristate "National Semiconductor LM75 and compatibles" | 173 | tristate "National Semiconductor LM75 and compatibles" |
146 | depends on I2C && EXPERIMENTAL | 174 | depends on I2C |
147 | select I2C_SENSOR | 175 | select I2C_SENSOR |
148 | help | 176 | help |
149 | If you say yes here you get support for National Semiconductor LM75 | 177 | If you say yes here you get support for National Semiconductor LM75 |
@@ -174,8 +202,7 @@ config SENSORS_LM78 | |||
174 | select I2C_SENSOR | 202 | select I2C_SENSOR |
175 | help | 203 | help |
176 | If you say yes here you get support for National Semiconductor LM78, | 204 | If you say yes here you get support for National Semiconductor LM78, |
177 | LM78-J and LM79. This can also be built as a module which can be | 205 | LM78-J and LM79. |
178 | inserted and removed while the kernel is running. | ||
179 | 206 | ||
180 | This driver can also be built as a module. If so, the module | 207 | This driver can also be built as a module. If so, the module |
181 | will be called lm78. | 208 | will be called lm78. |
@@ -208,7 +235,7 @@ config SENSORS_LM85 | |||
208 | select I2C_SENSOR | 235 | select I2C_SENSOR |
209 | help | 236 | help |
210 | If you say yes here you get support for National Semiconductor LM85 | 237 | If you say yes here you get support for National Semiconductor LM85 |
211 | sensor chips and clones: ADT7463 and ADM1027. | 238 | sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027. |
212 | 239 | ||
213 | This driver can also be built as a module. If so, the module | 240 | This driver can also be built as a module. If so, the module |
214 | will be called lm85. | 241 | will be called lm85. |
@@ -307,14 +334,14 @@ config SENSORS_SMSC47M1 | |||
307 | help | 334 | help |
308 | If you say yes here you get support for the integrated fan | 335 | If you say yes here you get support for the integrated fan |
309 | monitoring and control capabilities of the SMSC LPC47B27x, | 336 | monitoring and control capabilities of the SMSC LPC47B27x, |
310 | LPC47M10x, LPC47M13x and LPC47M14x chips. | 337 | LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 chips. |
311 | 338 | ||
312 | This driver can also be built as a module. If so, the module | 339 | This driver can also be built as a module. If so, the module |
313 | will be called smsc47m1. | 340 | will be called smsc47m1. |
314 | 341 | ||
315 | config SENSORS_VIA686A | 342 | config SENSORS_VIA686A |
316 | tristate "VIA686A" | 343 | tristate "VIA686A" |
317 | depends on I2C && PCI && EXPERIMENTAL | 344 | depends on I2C && PCI |
318 | select I2C_SENSOR | 345 | select I2C_SENSOR |
319 | select I2C_ISA | 346 | select I2C_ISA |
320 | help | 347 | help |
@@ -326,7 +353,7 @@ config SENSORS_VIA686A | |||
326 | 353 | ||
327 | config SENSORS_W83781D | 354 | config SENSORS_W83781D |
328 | tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" | 355 | tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" |
329 | depends on I2C && EXPERIMENTAL | 356 | depends on I2C |
330 | select I2C_SENSOR | 357 | select I2C_SENSOR |
331 | help | 358 | help |
332 | If you say yes here you get support for the Winbond W8378x series | 359 | If you say yes here you get support for the Winbond W8378x series |
@@ -360,22 +387,47 @@ config SENSORS_W83627HF | |||
360 | This driver can also be built as a module. If so, the module | 387 | This driver can also be built as a module. If so, the module |
361 | will be called w83627hf. | 388 | will be called w83627hf. |
362 | 389 | ||
390 | config SENSORS_W83627EHF | ||
391 | tristate "Winbond W83627EHF" | ||
392 | depends on I2C && EXPERIMENTAL | ||
393 | select I2C_SENSOR | ||
394 | select I2C_ISA | ||
395 | help | ||
396 | If you say yes here you get preliminary support for the hardware | ||
397 | monitoring functionality of the Winbond W83627EHF Super-I/O chip. | ||
398 | Only fan and temperature inputs are supported at the moment, while | ||
399 | the chip does much more than that. | ||
400 | |||
401 | This driver can also be built as a module. If so, the module | ||
402 | will be called w83627ehf. | ||
403 | |||
363 | endmenu | 404 | endmenu |
364 | 405 | ||
365 | menu "Other I2C Chip support" | 406 | menu "Other I2C Chip support" |
366 | depends on I2C | 407 | depends on I2C |
367 | 408 | ||
368 | config SENSORS_DS1337 | 409 | config SENSORS_DS1337 |
369 | tristate "Dallas Semiconductor DS1337 Real Time Clock" | 410 | tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock" |
370 | depends on I2C && EXPERIMENTAL | 411 | depends on I2C && EXPERIMENTAL |
371 | select I2C_SENSOR | 412 | select I2C_SENSOR |
372 | help | 413 | help |
373 | If you say yes here you get support for Dallas Semiconductor | 414 | If you say yes here you get support for Dallas Semiconductor |
374 | DS1337 real-time clock chips. | 415 | DS1337 and DS1339 real-time clock chips. |
375 | 416 | ||
376 | This driver can also be built as a module. If so, the module | 417 | This driver can also be built as a module. If so, the module |
377 | will be called ds1337. | 418 | will be called ds1337. |
378 | 419 | ||
420 | config SENSORS_DS1374 | ||
421 | tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock" | ||
422 | depends on I2C && EXPERIMENTAL | ||
423 | select I2C_SENSOR | ||
424 | help | ||
425 | If you say yes here you get support for Dallas Semiconductor | ||
426 | DS1374 real-time clock chips. | ||
427 | |||
428 | This driver can also be built as a module. If so, the module | ||
429 | will be called ds1374. | ||
430 | |||
379 | config SENSORS_EEPROM | 431 | config SENSORS_EEPROM |
380 | tristate "EEPROM reader" | 432 | tristate "EEPROM reader" |
381 | depends on I2C && EXPERIMENTAL | 433 | depends on I2C && EXPERIMENTAL |
@@ -399,6 +451,16 @@ config SENSORS_PCF8574 | |||
399 | This driver can also be built as a module. If so, the module | 451 | This driver can also be built as a module. If so, the module |
400 | will be called pcf8574. | 452 | will be called pcf8574. |
401 | 453 | ||
454 | config SENSORS_PCA9539 | ||
455 | tristate "Philips PCA9539 16-bit I/O port" | ||
456 | depends on I2C && EXPERIMENTAL | ||
457 | help | ||
458 | If you say yes here you get support for the Philips PCA9539 | ||
459 | 16-bit I/O port. | ||
460 | |||
461 | This driver can also be built as a module. If so, the module | ||
462 | will be called pca9539. | ||
463 | |||
402 | config SENSORS_PCF8591 | 464 | config SENSORS_PCF8591 |
403 | tristate "Philips PCF8591" | 465 | tristate "Philips PCF8591" |
404 | depends on I2C && EXPERIMENTAL | 466 | depends on I2C && EXPERIMENTAL |
@@ -431,6 +493,23 @@ config ISP1301_OMAP | |||
431 | This driver can also be built as a module. If so, the module | 493 | This driver can also be built as a module. If so, the module |
432 | will be called isp1301_omap. | 494 | will be called isp1301_omap. |
433 | 495 | ||
496 | # NOTE: This isn't really OMAP-specific, except for the current | ||
497 | # interface location in <include/asm-arm/arch-omap/tps65010.h> | ||
498 | # and having mostly OMAP-specific board support | ||
499 | config TPS65010 | ||
500 | tristate "TPS6501x Power Management chips" | ||
501 | depends on I2C && ARCH_OMAP | ||
502 | default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK | ||
503 | help | ||
504 | If you say yes here you get support for the TPS6501x series of | ||
505 | Power Management chips. These include voltage regulators, | ||
506 | lithium ion/polymer battery charging, and other features that | ||
507 | are often used in portable devices like cell phones and cameras. | ||
508 | |||
509 | This driver can also be built as a module. If so, the module | ||
510 | will be called tps65010. | ||
511 | |||
512 | |||
434 | config SENSORS_M41T00 | 513 | config SENSORS_M41T00 |
435 | tristate "ST M41T00 RTC chip" | 514 | tristate "ST M41T00 RTC chip" |
436 | depends on I2C && PPC32 | 515 | depends on I2C && PPC32 |
@@ -440,4 +519,16 @@ config SENSORS_M41T00 | |||
440 | This driver can also be built as a module. If so, the module | 519 | This driver can also be built as a module. If so, the module |
441 | will be called m41t00. | 520 | will be called m41t00. |
442 | 521 | ||
522 | config SENSORS_MAX6875 | ||
523 | tristate "MAXIM MAX6875 Power supply supervisor" | ||
524 | depends on I2C && EXPERIMENTAL | ||
525 | help | ||
526 | If you say yes here you get support for the MAX6875 | ||
527 | EEPROM-Programmable, Hex/Quad, Power-Suppy Sequencers/Supervisors. | ||
528 | |||
529 | This provides a interface to program the EEPROM and reset the chip. | ||
530 | |||
531 | This driver can also be built as a module. If so, the module | ||
532 | will be called max6875. | ||
533 | |||
443 | endmenu | 534 | endmenu |
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index 65599161a172..b5e6d2f84f97 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | # | 1 | # |
2 | # Makefile for the kernel hardware sensors chip drivers. | 2 | # Makefile for sensor and "other" I2C chip drivers. |
3 | # | 3 | # |
4 | 4 | ||
5 | # asb100, then w83781d go first, as they can override other drivers' addresses. | 5 | # asb100, then w83781d go first, as they can override other drivers' addresses. |
@@ -11,7 +11,10 @@ obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o | |||
11 | obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o | 11 | obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o |
12 | obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o | 12 | obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o |
13 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o | 13 | obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o |
14 | obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o | ||
15 | obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o | ||
14 | obj-$(CONFIG_SENSORS_DS1337) += ds1337.o | 16 | obj-$(CONFIG_SENSORS_DS1337) += ds1337.o |
17 | obj-$(CONFIG_SENSORS_DS1374) += ds1374.o | ||
15 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o | 18 | obj-$(CONFIG_SENSORS_DS1621) += ds1621.o |
16 | obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o | 19 | obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o |
17 | obj-$(CONFIG_SENSORS_FSCHER) += fscher.o | 20 | obj-$(CONFIG_SENSORS_FSCHER) += fscher.o |
@@ -30,8 +33,10 @@ obj-$(CONFIG_SENSORS_LM87) += lm87.o | |||
30 | obj-$(CONFIG_SENSORS_LM90) += lm90.o | 33 | obj-$(CONFIG_SENSORS_LM90) += lm90.o |
31 | obj-$(CONFIG_SENSORS_LM92) += lm92.o | 34 | obj-$(CONFIG_SENSORS_LM92) += lm92.o |
32 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o | 35 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o |
36 | obj-$(CONFIG_SENSORS_MAX6875) += max6875.o | ||
33 | obj-$(CONFIG_SENSORS_M41T00) += m41t00.o | 37 | obj-$(CONFIG_SENSORS_M41T00) += m41t00.o |
34 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o | 38 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o |
39 | obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o | ||
35 | obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o | 40 | obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o |
36 | obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o | 41 | obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o |
37 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o | 42 | obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o |
@@ -39,8 +44,11 @@ obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o | |||
39 | obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o | 44 | obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o |
40 | obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o | 45 | obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o |
41 | obj-$(CONFIG_SENSORS_VIA686A) += via686a.o | 46 | obj-$(CONFIG_SENSORS_VIA686A) += via686a.o |
47 | obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o | ||
42 | obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o | 48 | obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o |
49 | |||
43 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o | 50 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o |
51 | obj-$(CONFIG_TPS65010) += tps65010.o | ||
44 | 52 | ||
45 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) | 53 | ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) |
46 | EXTRA_CFLAGS += -DDEBUG | 54 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c index 9058c3956710..d2c774c32f45 100644 --- a/drivers/i2c/chips/adm1021.c +++ b/drivers/i2c/chips/adm1021.c | |||
@@ -19,7 +19,6 @@ | |||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/config.h> | ||
23 | #include <linux/module.h> | 22 | #include <linux/module.h> |
24 | #include <linux/init.h> | 23 | #include <linux/init.h> |
25 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
@@ -103,8 +102,6 @@ struct adm1021_data { | |||
103 | u8 remote_temp_hyst; | 102 | u8 remote_temp_hyst; |
104 | u8 remote_temp_input; | 103 | u8 remote_temp_input; |
105 | u8 alarms; | 104 | u8 alarms; |
106 | /* special values for ADM1021 only */ | ||
107 | u8 die_code; | ||
108 | /* Special values for ADM1023 only */ | 105 | /* Special values for ADM1023 only */ |
109 | u8 remote_temp_prec; | 106 | u8 remote_temp_prec; |
110 | u8 remote_temp_os_prec; | 107 | u8 remote_temp_os_prec; |
@@ -156,7 +153,6 @@ static ssize_t show_##value(struct device *dev, struct device_attribute *attr, c | |||
156 | return sprintf(buf, "%d\n", data->value); \ | 153 | return sprintf(buf, "%d\n", data->value); \ |
157 | } | 154 | } |
158 | show2(alarms); | 155 | show2(alarms); |
159 | show2(die_code); | ||
160 | 156 | ||
161 | #define set(value, reg) \ | 157 | #define set(value, reg) \ |
162 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ | 158 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ |
@@ -183,7 +179,6 @@ static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_remote_temp_max, set_remot | |||
183 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst); | 179 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst); |
184 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL); | 180 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL); |
185 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 181 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
186 | static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL); | ||
187 | 182 | ||
188 | 183 | ||
189 | static int adm1021_attach_adapter(struct i2c_adapter *adapter) | 184 | static int adm1021_attach_adapter(struct i2c_adapter *adapter) |
@@ -307,8 +302,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | |||
307 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 302 | device_create_file(&new_client->dev, &dev_attr_temp2_min); |
308 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 303 | device_create_file(&new_client->dev, &dev_attr_temp2_input); |
309 | device_create_file(&new_client->dev, &dev_attr_alarms); | 304 | device_create_file(&new_client->dev, &dev_attr_alarms); |
310 | if (data->type == adm1021) | ||
311 | device_create_file(&new_client->dev, &dev_attr_die_code); | ||
312 | 305 | ||
313 | return 0; | 306 | return 0; |
314 | 307 | ||
@@ -371,8 +364,6 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
371 | data->remote_temp_max = adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R); | 364 | data->remote_temp_max = adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R); |
372 | data->remote_temp_hyst = adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R); | 365 | data->remote_temp_hyst = adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R); |
373 | data->alarms = adm1021_read_value(client, ADM1021_REG_STATUS) & 0x7c; | 366 | data->alarms = adm1021_read_value(client, ADM1021_REG_STATUS) & 0x7c; |
374 | if (data->type == adm1021) | ||
375 | data->die_code = adm1021_read_value(client, ADM1021_REG_DIE_CODE); | ||
376 | if (data->type == adm1023) { | 367 | if (data->type == adm1023) { |
377 | data->remote_temp_prec = adm1021_read_value(client, ADM1021_REG_REM_TEMP_PREC); | 368 | data->remote_temp_prec = adm1021_read_value(client, ADM1021_REG_REM_TEMP_PREC); |
378 | data->remote_temp_os_prec = adm1021_read_value(client, ADM1021_REG_REM_TOS_PREC); | 369 | data->remote_temp_os_prec = adm1021_read_value(client, ADM1021_REG_REM_TOS_PREC); |
diff --git a/drivers/i2c/chips/adm1025.c b/drivers/i2c/chips/adm1025.c index 111f0c86c933..e452d0daf906 100644 --- a/drivers/i2c/chips/adm1025.c +++ b/drivers/i2c/chips/adm1025.c | |||
@@ -45,7 +45,6 @@ | |||
45 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 45 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
46 | */ | 46 | */ |
47 | 47 | ||
48 | #include <linux/config.h> | ||
49 | #include <linux/module.h> | 48 | #include <linux/module.h> |
50 | #include <linux/init.h> | 49 | #include <linux/init.h> |
51 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
@@ -287,7 +286,9 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char | |||
287 | struct adm1025_data *data = adm1025_update_device(dev); | 286 | struct adm1025_data *data = adm1025_update_device(dev); |
288 | return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); | 287 | return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); |
289 | } | 288 | } |
289 | /* in1_ref is deprecated in favour of cpu0_vid, remove after 2005-11-11 */ | ||
290 | static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); | 290 | static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); |
291 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | ||
291 | 292 | ||
292 | static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) | 293 | static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) |
293 | { | 294 | { |
@@ -437,7 +438,9 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) | |||
437 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 438 | device_create_file(&new_client->dev, &dev_attr_temp1_max); |
438 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 439 | device_create_file(&new_client->dev, &dev_attr_temp2_max); |
439 | device_create_file(&new_client->dev, &dev_attr_alarms); | 440 | device_create_file(&new_client->dev, &dev_attr_alarms); |
441 | /* in1_ref is deprecated, remove after 2005-11-11 */ | ||
440 | device_create_file(&new_client->dev, &dev_attr_in1_ref); | 442 | device_create_file(&new_client->dev, &dev_attr_in1_ref); |
443 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
441 | device_create_file(&new_client->dev, &dev_attr_vrm); | 444 | device_create_file(&new_client->dev, &dev_attr_vrm); |
442 | 445 | ||
443 | /* Pin 11 is either in4 (+12V) or VID4 */ | 446 | /* Pin 11 is either in4 (+12V) or VID4 */ |
diff --git a/drivers/i2c/chips/adm1026.c b/drivers/i2c/chips/adm1026.c index b15fafe8f111..3c85fe150cd7 100644 --- a/drivers/i2c/chips/adm1026.c +++ b/drivers/i2c/chips/adm1026.c | |||
@@ -23,15 +23,14 @@ | |||
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/config.h> | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
30 | #include <linux/jiffies.h> | 29 | #include <linux/jiffies.h> |
31 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
32 | #include <linux/i2c-sensor.h> | 31 | #include <linux/i2c-sensor.h> |
33 | #include <linux/i2c-sysfs.h> | ||
34 | #include <linux/i2c-vid.h> | 32 | #include <linux/i2c-vid.h> |
33 | #include <linux/hwmon-sysfs.h> | ||
35 | 34 | ||
36 | /* Addresses to scan */ | 35 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | 36 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
@@ -1225,8 +1224,9 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, c | |||
1225 | struct adm1026_data *data = adm1026_update_device(dev); | 1224 | struct adm1026_data *data = adm1026_update_device(dev); |
1226 | return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); | 1225 | return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); |
1227 | } | 1226 | } |
1228 | 1227 | /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ | |
1229 | static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); | 1228 | static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); |
1229 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); | ||
1230 | 1230 | ||
1231 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1231 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1232 | { | 1232 | { |
@@ -1666,7 +1666,9 @@ int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1666 | device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); | 1666 | device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); |
1667 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); | 1667 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); |
1668 | device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); | 1668 | device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); |
1669 | /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ | ||
1669 | device_create_file(&new_client->dev, &dev_attr_vid); | 1670 | device_create_file(&new_client->dev, &dev_attr_vid); |
1671 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
1670 | device_create_file(&new_client->dev, &dev_attr_vrm); | 1672 | device_create_file(&new_client->dev, &dev_attr_vrm); |
1671 | device_create_file(&new_client->dev, &dev_attr_alarms); | 1673 | device_create_file(&new_client->dev, &dev_attr_alarms); |
1672 | device_create_file(&new_client->dev, &dev_attr_alarm_mask); | 1674 | device_create_file(&new_client->dev, &dev_attr_alarm_mask); |
diff --git a/drivers/i2c/chips/adm1031.c b/drivers/i2c/chips/adm1031.c index 2163dba467c4..9168e983ca1d 100644 --- a/drivers/i2c/chips/adm1031.c +++ b/drivers/i2c/chips/adm1031.c | |||
@@ -440,7 +440,7 @@ pwm_reg(2); | |||
440 | 440 | ||
441 | /* | 441 | /* |
442 | * That function checks the cases where the fan reading is not | 442 | * That function checks the cases where the fan reading is not |
443 | * relevent. It is used to provide 0 as fan reading when the fan is | 443 | * relevant. It is used to provide 0 as fan reading when the fan is |
444 | * not supposed to run | 444 | * not supposed to run |
445 | */ | 445 | */ |
446 | static int trust_fan_readings(struct adm1031_data *data, int chan) | 446 | static int trust_fan_readings(struct adm1031_data *data, int chan) |
diff --git a/drivers/i2c/chips/adm9240.c b/drivers/i2c/chips/adm9240.c new file mode 100644 index 000000000000..5c68e9c311aa --- /dev/null +++ b/drivers/i2c/chips/adm9240.c | |||
@@ -0,0 +1,791 @@ | |||
1 | /* | ||
2 | * adm9240.c Part of lm_sensors, Linux kernel modules for hardware | ||
3 | * monitoring | ||
4 | * | ||
5 | * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl> | ||
6 | * Philip Edelbrock <phil@netroedge.com> | ||
7 | * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl> | ||
8 | * Copyright (C) 2005 Grant Coady <gcoady@gmail.com> with valuable | ||
9 | * guidance from Jean Delvare | ||
10 | * | ||
11 | * Driver supports Analog Devices ADM9240 | ||
12 | * Dallas Semiconductor DS1780 | ||
13 | * National Semiconductor LM81 | ||
14 | * | ||
15 | * ADM9240 is the reference, DS1780 and LM81 are register compatibles | ||
16 | * | ||
17 | * Voltage Six inputs are scaled by chip, VID also reported | ||
18 | * Temperature Chip temperature to 0.5'C, maximum and max_hysteris | ||
19 | * Fans 2 fans, low speed alarm, automatic fan clock divider | ||
20 | * Alarms 16-bit map of active alarms | ||
21 | * Analog Out 0..1250 mV output | ||
22 | * | ||
23 | * Chassis Intrusion: clear CI latch with 'echo 1 > chassis_clear' | ||
24 | * | ||
25 | * Test hardware: Intel SE440BX-2 desktop motherboard --Grant | ||
26 | * | ||
27 | * LM81 extended temp reading not implemented | ||
28 | * | ||
29 | * This program is free software; you can redistribute it and/or modify | ||
30 | * it under the terms of the GNU General Public License as published by | ||
31 | * the Free Software Foundation; either version 2 of the License, or | ||
32 | * (at your option) any later version. | ||
33 | * | ||
34 | * This program is distributed in the hope that it will be useful, | ||
35 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
36 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
37 | * GNU General Public License for more details. | ||
38 | * | ||
39 | * You should have received a copy of the GNU General Public License | ||
40 | * along with this program; if not, write to the Free Software | ||
41 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
42 | */ | ||
43 | |||
44 | #include <linux/init.h> | ||
45 | #include <linux/module.h> | ||
46 | #include <linux/slab.h> | ||
47 | #include <linux/i2c.h> | ||
48 | #include <linux/i2c-sensor.h> | ||
49 | #include <linux/i2c-vid.h> | ||
50 | |||
51 | /* Addresses to scan */ | ||
52 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, | ||
53 | I2C_CLIENT_END }; | ||
54 | |||
55 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
56 | |||
57 | /* Insmod parameters */ | ||
58 | SENSORS_INSMOD_3(adm9240, ds1780, lm81); | ||
59 | |||
60 | /* ADM9240 registers */ | ||
61 | #define ADM9240_REG_MAN_ID 0x3e | ||
62 | #define ADM9240_REG_DIE_REV 0x3f | ||
63 | #define ADM9240_REG_CONFIG 0x40 | ||
64 | |||
65 | #define ADM9240_REG_IN(nr) (0x20 + (nr)) /* 0..5 */ | ||
66 | #define ADM9240_REG_IN_MAX(nr) (0x2b + (nr) * 2) | ||
67 | #define ADM9240_REG_IN_MIN(nr) (0x2c + (nr) * 2) | ||
68 | #define ADM9240_REG_FAN(nr) (0x28 + (nr)) /* 0..1 */ | ||
69 | #define ADM9240_REG_FAN_MIN(nr) (0x3b + (nr)) | ||
70 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) | ||
71 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) | ||
72 | #define ADM9240_REG_TEMP 0x27 | ||
73 | #define ADM9240_REG_TEMP_HIGH 0x39 | ||
74 | #define ADM9240_REG_TEMP_HYST 0x3a | ||
75 | #define ADM9240_REG_ANALOG_OUT 0x19 | ||
76 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 | ||
77 | #define ADM9240_REG_VID_FAN_DIV 0x47 | ||
78 | #define ADM9240_REG_I2C_ADDR 0x48 | ||
79 | #define ADM9240_REG_VID4 0x49 | ||
80 | #define ADM9240_REG_TEMP_CONF 0x4b | ||
81 | |||
82 | /* generalised scaling with integer rounding */ | ||
83 | static inline int SCALE(long val, int mul, int div) | ||
84 | { | ||
85 | if (val < 0) | ||
86 | return (val * mul - div / 2) / div; | ||
87 | else | ||
88 | return (val * mul + div / 2) / div; | ||
89 | } | ||
90 | |||
91 | /* adm9240 internally scales voltage measurements */ | ||
92 | static const u16 nom_mv[] = { 2500, 2700, 3300, 5000, 12000, 2700 }; | ||
93 | |||
94 | static inline unsigned int IN_FROM_REG(u8 reg, int n) | ||
95 | { | ||
96 | return SCALE(reg, nom_mv[n], 192); | ||
97 | } | ||
98 | |||
99 | static inline u8 IN_TO_REG(unsigned long val, int n) | ||
100 | { | ||
101 | return SENSORS_LIMIT(SCALE(val, 192, nom_mv[n]), 0, 255); | ||
102 | } | ||
103 | |||
104 | /* temperature range: -40..125, 127 disables temperature alarm */ | ||
105 | static inline s8 TEMP_TO_REG(long val) | ||
106 | { | ||
107 | return SENSORS_LIMIT(SCALE(val, 1, 1000), -40, 127); | ||
108 | } | ||
109 | |||
110 | /* two fans, each with low fan speed limit */ | ||
111 | static inline unsigned int FAN_FROM_REG(u8 reg, u8 div) | ||
112 | { | ||
113 | if (!reg) /* error */ | ||
114 | return -1; | ||
115 | |||
116 | if (reg == 255) | ||
117 | return 0; | ||
118 | |||
119 | return SCALE(1350000, 1, reg * div); | ||
120 | } | ||
121 | |||
122 | /* analog out 0..1250mV */ | ||
123 | static inline u8 AOUT_TO_REG(unsigned long val) | ||
124 | { | ||
125 | return SENSORS_LIMIT(SCALE(val, 255, 1250), 0, 255); | ||
126 | } | ||
127 | |||
128 | static inline unsigned int AOUT_FROM_REG(u8 reg) | ||
129 | { | ||
130 | return SCALE(reg, 1250, 255); | ||
131 | } | ||
132 | |||
133 | static int adm9240_attach_adapter(struct i2c_adapter *adapter); | ||
134 | static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind); | ||
135 | static void adm9240_init_client(struct i2c_client *client); | ||
136 | static int adm9240_detach_client(struct i2c_client *client); | ||
137 | static struct adm9240_data *adm9240_update_device(struct device *dev); | ||
138 | |||
139 | /* driver data */ | ||
140 | static struct i2c_driver adm9240_driver = { | ||
141 | .owner = THIS_MODULE, | ||
142 | .name = "adm9240", | ||
143 | .id = I2C_DRIVERID_ADM9240, | ||
144 | .flags = I2C_DF_NOTIFY, | ||
145 | .attach_adapter = adm9240_attach_adapter, | ||
146 | .detach_client = adm9240_detach_client, | ||
147 | }; | ||
148 | |||
149 | /* per client data */ | ||
150 | struct adm9240_data { | ||
151 | enum chips type; | ||
152 | struct i2c_client client; | ||
153 | struct semaphore update_lock; | ||
154 | char valid; | ||
155 | unsigned long last_updated_measure; | ||
156 | unsigned long last_updated_config; | ||
157 | |||
158 | u8 in[6]; /* ro in0_input */ | ||
159 | u8 in_max[6]; /* rw in0_max */ | ||
160 | u8 in_min[6]; /* rw in0_min */ | ||
161 | u8 fan[2]; /* ro fan1_input */ | ||
162 | u8 fan_min[2]; /* rw fan1_min */ | ||
163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ | ||
164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ | ||
165 | s8 temp_high; /* rw temp1_max */ | ||
166 | s8 temp_hyst; /* rw temp1_max_hyst */ | ||
167 | u16 alarms; /* ro alarms */ | ||
168 | u8 aout; /* rw aout_output */ | ||
169 | u8 vid; /* ro vid */ | ||
170 | u8 vrm; /* -- vrm set on startup, no accessor */ | ||
171 | }; | ||
172 | |||
173 | /* i2c byte read/write interface */ | ||
174 | static int adm9240_read_value(struct i2c_client *client, u8 reg) | ||
175 | { | ||
176 | return i2c_smbus_read_byte_data(client, reg); | ||
177 | } | ||
178 | |||
179 | static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value) | ||
180 | { | ||
181 | return i2c_smbus_write_byte_data(client, reg, value); | ||
182 | } | ||
183 | |||
184 | /*** sysfs accessors ***/ | ||
185 | |||
186 | /* temperature */ | ||
187 | #define show_temp(value, scale) \ | ||
188 | static ssize_t show_##value(struct device *dev, \ | ||
189 | struct device_attribute *attr, \ | ||
190 | char *buf) \ | ||
191 | { \ | ||
192 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
193 | return sprintf(buf, "%d\n", data->value * scale); \ | ||
194 | } | ||
195 | show_temp(temp_high, 1000); | ||
196 | show_temp(temp_hyst, 1000); | ||
197 | show_temp(temp, 500); /* 0.5'C per bit */ | ||
198 | |||
199 | #define set_temp(value, reg) \ | ||
200 | static ssize_t set_##value(struct device *dev, \ | ||
201 | struct device_attribute *attr, \ | ||
202 | const char *buf, size_t count) \ | ||
203 | { \ | ||
204 | struct i2c_client *client = to_i2c_client(dev); \ | ||
205 | struct adm9240_data *data = adm9240_update_device(dev); \ | ||
206 | long temp = simple_strtoul(buf, NULL, 10); \ | ||
207 | \ | ||
208 | down(&data->update_lock); \ | ||
209 | data->value = TEMP_TO_REG(temp); \ | ||
210 | adm9240_write_value(client, reg, data->value); \ | ||
211 | up(&data->update_lock); \ | ||
212 | return count; \ | ||
213 | } | ||
214 | |||
215 | set_temp(temp_high, ADM9240_REG_TEMP_HIGH); | ||
216 | set_temp(temp_hyst, ADM9240_REG_TEMP_HYST); | ||
217 | |||
218 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
219 | show_temp_high, set_temp_high); | ||
220 | static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
221 | show_temp_hyst, set_temp_hyst); | ||
222 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); | ||
223 | |||
224 | /* voltage */ | ||
225 | static ssize_t show_in(struct device *dev, char *buf, int nr) | ||
226 | { | ||
227 | struct adm9240_data *data = adm9240_update_device(dev); | ||
228 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr)); | ||
229 | } | ||
230 | |||
231 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | ||
232 | { | ||
233 | struct adm9240_data *data = adm9240_update_device(dev); | ||
234 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr)); | ||
235 | } | ||
236 | |||
237 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | ||
238 | { | ||
239 | struct adm9240_data *data = adm9240_update_device(dev); | ||
240 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr)); | ||
241 | } | ||
242 | |||
243 | static ssize_t set_in_min(struct device *dev, const char *buf, | ||
244 | size_t count, int nr) | ||
245 | { | ||
246 | struct i2c_client *client = to_i2c_client(dev); | ||
247 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
248 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
249 | |||
250 | down(&data->update_lock); | ||
251 | data->in_min[nr] = IN_TO_REG(val, nr); | ||
252 | adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]); | ||
253 | up(&data->update_lock); | ||
254 | return count; | ||
255 | } | ||
256 | |||
257 | static ssize_t set_in_max(struct device *dev, const char *buf, | ||
258 | size_t count, int nr) | ||
259 | { | ||
260 | struct i2c_client *client = to_i2c_client(dev); | ||
261 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
262 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
263 | |||
264 | down(&data->update_lock); | ||
265 | data->in_max[nr] = IN_TO_REG(val, nr); | ||
266 | adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]); | ||
267 | up(&data->update_lock); | ||
268 | return count; | ||
269 | } | ||
270 | |||
271 | #define show_in_offset(offset) \ | ||
272 | static ssize_t show_in##offset(struct device *dev, \ | ||
273 | struct device_attribute *attr, \ | ||
274 | char *buf) \ | ||
275 | { \ | ||
276 | return show_in(dev, buf, offset); \ | ||
277 | } \ | ||
278 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ | ||
279 | static ssize_t show_in##offset##_min(struct device *dev, \ | ||
280 | struct device_attribute *attr, \ | ||
281 | char *buf) \ | ||
282 | { \ | ||
283 | return show_in_min(dev, buf, offset); \ | ||
284 | } \ | ||
285 | static ssize_t show_in##offset##_max(struct device *dev, \ | ||
286 | struct device_attribute *attr, \ | ||
287 | char *buf) \ | ||
288 | { \ | ||
289 | return show_in_max(dev, buf, offset); \ | ||
290 | } \ | ||
291 | static ssize_t \ | ||
292 | set_in##offset##_min(struct device *dev, \ | ||
293 | struct device_attribute *attr, const char *buf, \ | ||
294 | size_t count) \ | ||
295 | { \ | ||
296 | return set_in_min(dev, buf, count, offset); \ | ||
297 | } \ | ||
298 | static ssize_t \ | ||
299 | set_in##offset##_max(struct device *dev, \ | ||
300 | struct device_attribute *attr, const char *buf, \ | ||
301 | size_t count) \ | ||
302 | { \ | ||
303 | return set_in_max(dev, buf, count, offset); \ | ||
304 | } \ | ||
305 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
306 | show_in##offset##_min, set_in##offset##_min); \ | ||
307 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
308 | show_in##offset##_max, set_in##offset##_max); | ||
309 | |||
310 | show_in_offset(0); | ||
311 | show_in_offset(1); | ||
312 | show_in_offset(2); | ||
313 | show_in_offset(3); | ||
314 | show_in_offset(4); | ||
315 | show_in_offset(5); | ||
316 | |||
317 | /* fans */ | ||
318 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | ||
319 | { | ||
320 | struct adm9240_data *data = adm9240_update_device(dev); | ||
321 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], | ||
322 | 1 << data->fan_div[nr])); | ||
323 | } | ||
324 | |||
325 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | ||
326 | { | ||
327 | struct adm9240_data *data = adm9240_update_device(dev); | ||
328 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], | ||
329 | 1 << data->fan_div[nr])); | ||
330 | } | ||
331 | |||
332 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | ||
333 | { | ||
334 | struct adm9240_data *data = adm9240_update_device(dev); | ||
335 | return sprintf(buf, "%d\n", 1 << data->fan_div[nr]); | ||
336 | } | ||
337 | |||
338 | /* write new fan div, callers must hold data->update_lock */ | ||
339 | static void adm9240_write_fan_div(struct i2c_client *client, int nr, | ||
340 | u8 fan_div) | ||
341 | { | ||
342 | u8 reg, old, shift = (nr + 2) * 2; | ||
343 | |||
344 | reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | ||
345 | old = (reg >> shift) & 3; | ||
346 | reg &= ~(3 << shift); | ||
347 | reg |= (fan_div << shift); | ||
348 | adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg); | ||
349 | dev_dbg(&client->dev, "fan%d clock divider changed from %u " | ||
350 | "to %u\n", nr + 1, 1 << old, 1 << fan_div); | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | * set fan speed low limit: | ||
355 | * | ||
356 | * - value is zero: disable fan speed low limit alarm | ||
357 | * | ||
358 | * - value is below fan speed measurement range: enable fan speed low | ||
359 | * limit alarm to be asserted while fan speed too slow to measure | ||
360 | * | ||
361 | * - otherwise: select fan clock divider to suit fan speed low limit, | ||
362 | * measurement code may adjust registers to ensure fan speed reading | ||
363 | */ | ||
364 | static ssize_t set_fan_min(struct device *dev, const char *buf, | ||
365 | size_t count, int nr) | ||
366 | { | ||
367 | struct i2c_client *client = to_i2c_client(dev); | ||
368 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
369 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
370 | u8 new_div; | ||
371 | |||
372 | down(&data->update_lock); | ||
373 | |||
374 | if (!val) { | ||
375 | data->fan_min[nr] = 255; | ||
376 | new_div = data->fan_div[nr]; | ||
377 | |||
378 | dev_dbg(&client->dev, "fan%u low limit set disabled\n", | ||
379 | nr + 1); | ||
380 | |||
381 | } else if (val < 1350000 / (8 * 254)) { | ||
382 | new_div = 3; | ||
383 | data->fan_min[nr] = 254; | ||
384 | |||
385 | dev_dbg(&client->dev, "fan%u low limit set minimum %u\n", | ||
386 | nr + 1, FAN_FROM_REG(254, 1 << new_div)); | ||
387 | |||
388 | } else { | ||
389 | unsigned int new_min = 1350000 / val; | ||
390 | |||
391 | new_div = 0; | ||
392 | while (new_min > 192 && new_div < 3) { | ||
393 | new_div++; | ||
394 | new_min /= 2; | ||
395 | } | ||
396 | if (!new_min) /* keep > 0 */ | ||
397 | new_min++; | ||
398 | |||
399 | data->fan_min[nr] = new_min; | ||
400 | |||
401 | dev_dbg(&client->dev, "fan%u low limit set fan speed %u\n", | ||
402 | nr + 1, FAN_FROM_REG(new_min, 1 << new_div)); | ||
403 | } | ||
404 | |||
405 | if (new_div != data->fan_div[nr]) { | ||
406 | data->fan_div[nr] = new_div; | ||
407 | adm9240_write_fan_div(client, nr, new_div); | ||
408 | } | ||
409 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr), | ||
410 | data->fan_min[nr]); | ||
411 | |||
412 | up(&data->update_lock); | ||
413 | return count; | ||
414 | } | ||
415 | |||
416 | #define show_fan_offset(offset) \ | ||
417 | static ssize_t show_fan_##offset (struct device *dev, \ | ||
418 | struct device_attribute *attr, \ | ||
419 | char *buf) \ | ||
420 | { \ | ||
421 | return show_fan(dev, buf, offset - 1); \ | ||
422 | } \ | ||
423 | static ssize_t show_fan_##offset##_div (struct device *dev, \ | ||
424 | struct device_attribute *attr, \ | ||
425 | char *buf) \ | ||
426 | { \ | ||
427 | return show_fan_div(dev, buf, offset - 1); \ | ||
428 | } \ | ||
429 | static ssize_t show_fan_##offset##_min (struct device *dev, \ | ||
430 | struct device_attribute *attr, \ | ||
431 | char *buf) \ | ||
432 | { \ | ||
433 | return show_fan_min(dev, buf, offset - 1); \ | ||
434 | } \ | ||
435 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | ||
436 | struct device_attribute *attr, \ | ||
437 | const char *buf, size_t count) \ | ||
438 | { \ | ||
439 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
440 | } \ | ||
441 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
442 | show_fan_##offset, NULL); \ | ||
443 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | ||
444 | show_fan_##offset##_div, NULL); \ | ||
445 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
446 | show_fan_##offset##_min, set_fan_##offset##_min); | ||
447 | |||
448 | show_fan_offset(1); | ||
449 | show_fan_offset(2); | ||
450 | |||
451 | /* alarms */ | ||
452 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | ||
453 | { | ||
454 | struct adm9240_data *data = adm9240_update_device(dev); | ||
455 | return sprintf(buf, "%u\n", data->alarms); | ||
456 | } | ||
457 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | ||
458 | |||
459 | /* vid */ | ||
460 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | ||
461 | { | ||
462 | struct adm9240_data *data = adm9240_update_device(dev); | ||
463 | return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); | ||
464 | } | ||
465 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | ||
466 | |||
467 | /* analog output */ | ||
468 | static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf) | ||
469 | { | ||
470 | struct adm9240_data *data = adm9240_update_device(dev); | ||
471 | return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); | ||
472 | } | ||
473 | |||
474 | static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
475 | { | ||
476 | struct i2c_client *client = to_i2c_client(dev); | ||
477 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
478 | unsigned long val = simple_strtol(buf, NULL, 10); | ||
479 | |||
480 | down(&data->update_lock); | ||
481 | data->aout = AOUT_TO_REG(val); | ||
482 | adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout); | ||
483 | up(&data->update_lock); | ||
484 | return count; | ||
485 | } | ||
486 | static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); | ||
487 | |||
488 | /* chassis_clear */ | ||
489 | static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
490 | { | ||
491 | struct i2c_client *client = to_i2c_client(dev); | ||
492 | unsigned long val = simple_strtol(buf, NULL, 10); | ||
493 | |||
494 | if (val == 1) { | ||
495 | adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80); | ||
496 | dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); | ||
497 | } | ||
498 | return count; | ||
499 | } | ||
500 | static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear); | ||
501 | |||
502 | |||
503 | /*** sensor chip detect and driver install ***/ | ||
504 | |||
505 | static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | ||
506 | { | ||
507 | struct i2c_client *new_client; | ||
508 | struct adm9240_data *data; | ||
509 | int err = 0; | ||
510 | const char *name = ""; | ||
511 | u8 man_id, die_rev; | ||
512 | |||
513 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
514 | goto exit; | ||
515 | |||
516 | if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) { | ||
517 | err = -ENOMEM; | ||
518 | goto exit; | ||
519 | } | ||
520 | memset(data, 0, sizeof(struct adm9240_data)); | ||
521 | |||
522 | new_client = &data->client; | ||
523 | i2c_set_clientdata(new_client, data); | ||
524 | new_client->addr = address; | ||
525 | new_client->adapter = adapter; | ||
526 | new_client->driver = &adm9240_driver; | ||
527 | new_client->flags = 0; | ||
528 | |||
529 | if (kind == 0) { | ||
530 | kind = adm9240; | ||
531 | } | ||
532 | |||
533 | if (kind < 0) { | ||
534 | |||
535 | /* verify chip: reg address should match i2c address */ | ||
536 | if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR) | ||
537 | != address) { | ||
538 | dev_err(&adapter->dev, "detect fail: address match, " | ||
539 | "0x%02x\n", address); | ||
540 | goto exit_free; | ||
541 | } | ||
542 | |||
543 | /* check known chip manufacturer */ | ||
544 | man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID); | ||
545 | |||
546 | if (man_id == 0x23) { | ||
547 | kind = adm9240; | ||
548 | } else if (man_id == 0xda) { | ||
549 | kind = ds1780; | ||
550 | } else if (man_id == 0x01) { | ||
551 | kind = lm81; | ||
552 | } else { | ||
553 | dev_err(&adapter->dev, "detect fail: unknown manuf, " | ||
554 | "0x%02x\n", man_id); | ||
555 | goto exit_free; | ||
556 | } | ||
557 | |||
558 | /* successful detect, print chip info */ | ||
559 | die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV); | ||
560 | dev_info(&adapter->dev, "found %s revision %u\n", | ||
561 | man_id == 0x23 ? "ADM9240" : | ||
562 | man_id == 0xda ? "DS1780" : "LM81", die_rev); | ||
563 | } | ||
564 | |||
565 | /* either forced or detected chip kind */ | ||
566 | if (kind == adm9240) { | ||
567 | name = "adm9240"; | ||
568 | } else if (kind == ds1780) { | ||
569 | name = "ds1780"; | ||
570 | } else if (kind == lm81) { | ||
571 | name = "lm81"; | ||
572 | } | ||
573 | |||
574 | /* fill in the remaining client fields and attach */ | ||
575 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | ||
576 | data->type = kind; | ||
577 | init_MUTEX(&data->update_lock); | ||
578 | |||
579 | if ((err = i2c_attach_client(new_client))) | ||
580 | goto exit_free; | ||
581 | |||
582 | adm9240_init_client(new_client); | ||
583 | |||
584 | /* populate sysfs filesystem */ | ||
585 | device_create_file(&new_client->dev, &dev_attr_in0_input); | ||
586 | device_create_file(&new_client->dev, &dev_attr_in0_min); | ||
587 | device_create_file(&new_client->dev, &dev_attr_in0_max); | ||
588 | device_create_file(&new_client->dev, &dev_attr_in1_input); | ||
589 | device_create_file(&new_client->dev, &dev_attr_in1_min); | ||
590 | device_create_file(&new_client->dev, &dev_attr_in1_max); | ||
591 | device_create_file(&new_client->dev, &dev_attr_in2_input); | ||
592 | device_create_file(&new_client->dev, &dev_attr_in2_min); | ||
593 | device_create_file(&new_client->dev, &dev_attr_in2_max); | ||
594 | device_create_file(&new_client->dev, &dev_attr_in3_input); | ||
595 | device_create_file(&new_client->dev, &dev_attr_in3_min); | ||
596 | device_create_file(&new_client->dev, &dev_attr_in3_max); | ||
597 | device_create_file(&new_client->dev, &dev_attr_in4_input); | ||
598 | device_create_file(&new_client->dev, &dev_attr_in4_min); | ||
599 | device_create_file(&new_client->dev, &dev_attr_in4_max); | ||
600 | device_create_file(&new_client->dev, &dev_attr_in5_input); | ||
601 | device_create_file(&new_client->dev, &dev_attr_in5_min); | ||
602 | device_create_file(&new_client->dev, &dev_attr_in5_max); | ||
603 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | ||
604 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | ||
605 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | ||
606 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | ||
607 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | ||
608 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | ||
609 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | ||
610 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | ||
611 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | ||
612 | device_create_file(&new_client->dev, &dev_attr_alarms); | ||
613 | device_create_file(&new_client->dev, &dev_attr_aout_output); | ||
614 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); | ||
615 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
616 | |||
617 | return 0; | ||
618 | exit_free: | ||
619 | kfree(new_client); | ||
620 | exit: | ||
621 | return err; | ||
622 | } | ||
623 | |||
624 | static int adm9240_attach_adapter(struct i2c_adapter *adapter) | ||
625 | { | ||
626 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
627 | return 0; | ||
628 | return i2c_detect(adapter, &addr_data, adm9240_detect); | ||
629 | } | ||
630 | |||
631 | static int adm9240_detach_client(struct i2c_client *client) | ||
632 | { | ||
633 | int err; | ||
634 | |||
635 | if ((err = i2c_detach_client(client))) { | ||
636 | dev_err(&client->dev, "Client deregistration failed, " | ||
637 | "client not detached.\n"); | ||
638 | return err; | ||
639 | } | ||
640 | |||
641 | kfree(i2c_get_clientdata(client)); | ||
642 | return 0; | ||
643 | } | ||
644 | |||
645 | static void adm9240_init_client(struct i2c_client *client) | ||
646 | { | ||
647 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
648 | u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); | ||
649 | u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; | ||
650 | |||
651 | data->vrm = i2c_which_vrm(); /* need this to report vid as mV */ | ||
652 | |||
653 | dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10, | ||
654 | data->vrm % 10); | ||
655 | |||
656 | if (conf & 1) { /* measurement cycle running: report state */ | ||
657 | |||
658 | dev_info(&client->dev, "status: config 0x%02x mode %u\n", | ||
659 | conf, mode); | ||
660 | |||
661 | } else { /* cold start: open limits before starting chip */ | ||
662 | int i; | ||
663 | |||
664 | for (i = 0; i < 6; i++) | ||
665 | { | ||
666 | adm9240_write_value(client, | ||
667 | ADM9240_REG_IN_MIN(i), 0); | ||
668 | adm9240_write_value(client, | ||
669 | ADM9240_REG_IN_MAX(i), 255); | ||
670 | } | ||
671 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255); | ||
672 | adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255); | ||
673 | adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127); | ||
674 | adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127); | ||
675 | |||
676 | /* start measurement cycle */ | ||
677 | adm9240_write_value(client, ADM9240_REG_CONFIG, 1); | ||
678 | |||
679 | dev_info(&client->dev, "cold start: config was 0x%02x " | ||
680 | "mode %u\n", conf, mode); | ||
681 | } | ||
682 | } | ||
683 | |||
684 | static struct adm9240_data *adm9240_update_device(struct device *dev) | ||
685 | { | ||
686 | struct i2c_client *client = to_i2c_client(dev); | ||
687 | struct adm9240_data *data = i2c_get_clientdata(client); | ||
688 | int i; | ||
689 | |||
690 | down(&data->update_lock); | ||
691 | |||
692 | /* minimum measurement cycle: 1.75 seconds */ | ||
693 | if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) | ||
694 | || !data->valid) { | ||
695 | |||
696 | for (i = 0; i < 6; i++) /* read voltages */ | ||
697 | { | ||
698 | data->in[i] = adm9240_read_value(client, | ||
699 | ADM9240_REG_IN(i)); | ||
700 | } | ||
701 | data->alarms = adm9240_read_value(client, | ||
702 | ADM9240_REG_INT(0)) | | ||
703 | adm9240_read_value(client, | ||
704 | ADM9240_REG_INT(1)) << 8; | ||
705 | |||
706 | /* read temperature: assume temperature changes less than | ||
707 | * 0.5'C per two measurement cycles thus ignore possible | ||
708 | * but unlikely aliasing error on lsb reading. --Grant */ | ||
709 | data->temp = ((adm9240_read_value(client, | ||
710 | ADM9240_REG_TEMP) << 8) | | ||
711 | adm9240_read_value(client, | ||
712 | ADM9240_REG_TEMP_CONF)) / 128; | ||
713 | |||
714 | for (i = 0; i < 2; i++) /* read fans */ | ||
715 | { | ||
716 | data->fan[i] = adm9240_read_value(client, | ||
717 | ADM9240_REG_FAN(i)); | ||
718 | |||
719 | /* adjust fan clock divider on overflow */ | ||
720 | if (data->valid && data->fan[i] == 255 && | ||
721 | data->fan_div[i] < 3) { | ||
722 | |||
723 | adm9240_write_fan_div(client, i, | ||
724 | ++data->fan_div[i]); | ||
725 | |||
726 | /* adjust fan_min if active, but not to 0 */ | ||
727 | if (data->fan_min[i] < 255 && | ||
728 | data->fan_min[i] >= 2) | ||
729 | data->fan_min[i] /= 2; | ||
730 | } | ||
731 | } | ||
732 | data->last_updated_measure = jiffies; | ||
733 | } | ||
734 | |||
735 | /* minimum config reading cycle: 300 seconds */ | ||
736 | if (time_after(jiffies, data->last_updated_config + (HZ * 300)) | ||
737 | || !data->valid) { | ||
738 | |||
739 | for (i = 0; i < 6; i++) | ||
740 | { | ||
741 | data->in_min[i] = adm9240_read_value(client, | ||
742 | ADM9240_REG_IN_MIN(i)); | ||
743 | data->in_max[i] = adm9240_read_value(client, | ||
744 | ADM9240_REG_IN_MAX(i)); | ||
745 | } | ||
746 | for (i = 0; i < 2; i++) | ||
747 | { | ||
748 | data->fan_min[i] = adm9240_read_value(client, | ||
749 | ADM9240_REG_FAN_MIN(i)); | ||
750 | } | ||
751 | data->temp_high = adm9240_read_value(client, | ||
752 | ADM9240_REG_TEMP_HIGH); | ||
753 | data->temp_hyst = adm9240_read_value(client, | ||
754 | ADM9240_REG_TEMP_HYST); | ||
755 | |||
756 | /* read fan divs and 5-bit VID */ | ||
757 | i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); | ||
758 | data->fan_div[0] = (i >> 4) & 3; | ||
759 | data->fan_div[1] = (i >> 6) & 3; | ||
760 | data->vid = i & 0x0f; | ||
761 | data->vid |= (adm9240_read_value(client, | ||
762 | ADM9240_REG_VID4) & 1) << 4; | ||
763 | /* read analog out */ | ||
764 | data->aout = adm9240_read_value(client, | ||
765 | ADM9240_REG_ANALOG_OUT); | ||
766 | |||
767 | data->last_updated_config = jiffies; | ||
768 | data->valid = 1; | ||
769 | } | ||
770 | up(&data->update_lock); | ||
771 | return data; | ||
772 | } | ||
773 | |||
774 | static int __init sensors_adm9240_init(void) | ||
775 | { | ||
776 | return i2c_add_driver(&adm9240_driver); | ||
777 | } | ||
778 | |||
779 | static void __exit sensors_adm9240_exit(void) | ||
780 | { | ||
781 | i2c_del_driver(&adm9240_driver); | ||
782 | } | ||
783 | |||
784 | MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, " | ||
785 | "Grant Coady <gcoady@gmail.com> and others"); | ||
786 | MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver"); | ||
787 | MODULE_LICENSE("GPL"); | ||
788 | |||
789 | module_init(sensors_adm9240_init); | ||
790 | module_exit(sensors_adm9240_exit); | ||
791 | |||
diff --git a/drivers/i2c/chips/asb100.c b/drivers/i2c/chips/asb100.c index 4a47b4493e34..70d996d6fe0a 100644 --- a/drivers/i2c/chips/asb100.c +++ b/drivers/i2c/chips/asb100.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/i2c-sensor.h> | 42 | #include <linux/i2c-sensor.h> |
43 | #include <linux/i2c-vid.h> | 43 | #include <linux/i2c-vid.h> |
44 | #include <linux/init.h> | 44 | #include <linux/init.h> |
45 | #include <linux/jiffies.h> | ||
45 | #include "lm75.h" | 46 | #include "lm75.h" |
46 | 47 | ||
47 | /* | 48 | /* |
@@ -168,8 +169,6 @@ static int ASB100_PWM_FROM_REG(u8 reg) | |||
168 | return reg * 16; | 169 | return reg * 16; |
169 | } | 170 | } |
170 | 171 | ||
171 | #define ALARMS_FROM_REG(val) (val) | ||
172 | |||
173 | #define DIV_FROM_REG(val) (1 << (val)) | 172 | #define DIV_FROM_REG(val) (1 << (val)) |
174 | 173 | ||
175 | /* FAN DIV: 1, 2, 4, or 8 (defaults to 2) | 174 | /* FAN DIV: 1, 2, 4, or 8 (defaults to 2) |
@@ -556,7 +555,7 @@ device_create_file(&client->dev, &dev_attr_vrm); | |||
556 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 555 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
557 | { | 556 | { |
558 | struct asb100_data *data = asb100_update_device(dev); | 557 | struct asb100_data *data = asb100_update_device(dev); |
559 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms)); | 558 | return sprintf(buf, "%u\n", data->alarms); |
560 | } | 559 | } |
561 | 560 | ||
562 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 561 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
diff --git a/drivers/i2c/chips/atxp1.c b/drivers/i2c/chips/atxp1.c new file mode 100644 index 000000000000..5c6597aa2c7f --- /dev/null +++ b/drivers/i2c/chips/atxp1.c | |||
@@ -0,0 +1,361 @@ | |||
1 | /* | ||
2 | atxp1.c - kernel module for setting CPU VID and general purpose | ||
3 | I/Os using the Attansic ATXP1 chip. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | |||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/i2c.h> | ||
25 | #include <linux/i2c-sensor.h> | ||
26 | #include <linux/i2c-vid.h> | ||
27 | |||
28 | MODULE_LICENSE("GPL"); | ||
29 | MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); | ||
30 | MODULE_VERSION("0.6.2"); | ||
31 | MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>"); | ||
32 | |||
33 | #define ATXP1_VID 0x00 | ||
34 | #define ATXP1_CVID 0x01 | ||
35 | #define ATXP1_GPIO1 0x06 | ||
36 | #define ATXP1_GPIO2 0x0a | ||
37 | #define ATXP1_VIDENA 0x20 | ||
38 | #define ATXP1_VIDMASK 0x1f | ||
39 | #define ATXP1_GPIO1MASK 0x0f | ||
40 | |||
41 | static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; | ||
42 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
43 | |||
44 | SENSORS_INSMOD_1(atxp1); | ||
45 | |||
46 | static int atxp1_attach_adapter(struct i2c_adapter * adapter); | ||
47 | static int atxp1_detach_client(struct i2c_client * client); | ||
48 | static struct atxp1_data * atxp1_update_device(struct device *dev); | ||
49 | static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind); | ||
50 | |||
51 | static struct i2c_driver atxp1_driver = { | ||
52 | .owner = THIS_MODULE, | ||
53 | .name = "atxp1", | ||
54 | .flags = I2C_DF_NOTIFY, | ||
55 | .attach_adapter = atxp1_attach_adapter, | ||
56 | .detach_client = atxp1_detach_client, | ||
57 | }; | ||
58 | |||
59 | struct atxp1_data { | ||
60 | struct i2c_client client; | ||
61 | struct semaphore update_lock; | ||
62 | unsigned long last_updated; | ||
63 | u8 valid; | ||
64 | struct { | ||
65 | u8 vid; /* VID output register */ | ||
66 | u8 cpu_vid; /* VID input from CPU */ | ||
67 | u8 gpio1; /* General purpose I/O register 1 */ | ||
68 | u8 gpio2; /* General purpose I/O register 2 */ | ||
69 | } reg; | ||
70 | u8 vrm; /* Detected CPU VRM */ | ||
71 | }; | ||
72 | |||
73 | static struct atxp1_data * atxp1_update_device(struct device *dev) | ||
74 | { | ||
75 | struct i2c_client *client; | ||
76 | struct atxp1_data *data; | ||
77 | |||
78 | client = to_i2c_client(dev); | ||
79 | data = i2c_get_clientdata(client); | ||
80 | |||
81 | down(&data->update_lock); | ||
82 | |||
83 | if ((jiffies - data->last_updated > HZ) || | ||
84 | (jiffies < data->last_updated) || | ||
85 | !data->valid) { | ||
86 | |||
87 | /* Update local register data */ | ||
88 | data->reg.vid = i2c_smbus_read_byte_data(client, ATXP1_VID); | ||
89 | data->reg.cpu_vid = i2c_smbus_read_byte_data(client, ATXP1_CVID); | ||
90 | data->reg.gpio1 = i2c_smbus_read_byte_data(client, ATXP1_GPIO1); | ||
91 | data->reg.gpio2 = i2c_smbus_read_byte_data(client, ATXP1_GPIO2); | ||
92 | |||
93 | data->valid = 1; | ||
94 | } | ||
95 | |||
96 | up(&data->update_lock); | ||
97 | |||
98 | return(data); | ||
99 | } | ||
100 | |||
101 | /* sys file functions for cpu0_vid */ | ||
102 | static ssize_t atxp1_showvcore(struct device *dev, struct device_attribute *attr, char *buf) | ||
103 | { | ||
104 | int size; | ||
105 | struct atxp1_data *data; | ||
106 | |||
107 | data = atxp1_update_device(dev); | ||
108 | |||
109 | size = sprintf(buf, "%d\n", vid_from_reg(data->reg.vid & ATXP1_VIDMASK, data->vrm)); | ||
110 | |||
111 | return size; | ||
112 | } | ||
113 | |||
114 | static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
115 | { | ||
116 | struct atxp1_data *data; | ||
117 | struct i2c_client *client; | ||
118 | char vid; | ||
119 | char cvid; | ||
120 | unsigned int vcore; | ||
121 | |||
122 | client = to_i2c_client(dev); | ||
123 | data = atxp1_update_device(dev); | ||
124 | |||
125 | vcore = simple_strtoul(buf, NULL, 10); | ||
126 | vcore /= 25; | ||
127 | vcore *= 25; | ||
128 | |||
129 | /* Calculate VID */ | ||
130 | vid = vid_to_reg(vcore, data->vrm); | ||
131 | |||
132 | if (vid < 0) { | ||
133 | dev_err(dev, "VID calculation failed.\n"); | ||
134 | return -1; | ||
135 | } | ||
136 | |||
137 | /* If output enabled, use control register value. Otherwise original CPU VID */ | ||
138 | if (data->reg.vid & ATXP1_VIDENA) | ||
139 | cvid = data->reg.vid & ATXP1_VIDMASK; | ||
140 | else | ||
141 | cvid = data->reg.cpu_vid; | ||
142 | |||
143 | /* Nothing changed, aborting */ | ||
144 | if (vid == cvid) | ||
145 | return count; | ||
146 | |||
147 | dev_info(dev, "Setting VCore to %d mV (0x%02x)\n", vcore, vid); | ||
148 | |||
149 | /* Write every 25 mV step to increase stability */ | ||
150 | if (cvid > vid) { | ||
151 | for (; cvid >= vid; cvid--) { | ||
152 | i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA); | ||
153 | } | ||
154 | } | ||
155 | else { | ||
156 | for (; cvid <= vid; cvid++) { | ||
157 | i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | data->valid = 0; | ||
162 | |||
163 | return count; | ||
164 | } | ||
165 | |||
166 | /* CPU core reference voltage | ||
167 | unit: millivolt | ||
168 | */ | ||
169 | static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore); | ||
170 | |||
171 | /* sys file functions for GPIO1 */ | ||
172 | static ssize_t atxp1_showgpio1(struct device *dev, struct device_attribute *attr, char *buf) | ||
173 | { | ||
174 | int size; | ||
175 | struct atxp1_data *data; | ||
176 | |||
177 | data = atxp1_update_device(dev); | ||
178 | |||
179 | size = sprintf(buf, "0x%02x\n", data->reg.gpio1 & ATXP1_GPIO1MASK); | ||
180 | |||
181 | return size; | ||
182 | } | ||
183 | |||
184 | static ssize_t atxp1_storegpio1(struct device *dev, struct device_attribute *attr, const char*buf, size_t count) | ||
185 | { | ||
186 | struct atxp1_data *data; | ||
187 | struct i2c_client *client; | ||
188 | unsigned int value; | ||
189 | |||
190 | client = to_i2c_client(dev); | ||
191 | data = atxp1_update_device(dev); | ||
192 | |||
193 | value = simple_strtoul(buf, NULL, 16); | ||
194 | |||
195 | value &= ATXP1_GPIO1MASK; | ||
196 | |||
197 | if (value != (data->reg.gpio1 & ATXP1_GPIO1MASK)) { | ||
198 | dev_info(dev, "Writing 0x%x to GPIO1.\n", value); | ||
199 | |||
200 | i2c_smbus_write_byte_data(client, ATXP1_GPIO1, value); | ||
201 | |||
202 | data->valid = 0; | ||
203 | } | ||
204 | |||
205 | return count; | ||
206 | } | ||
207 | |||
208 | /* GPIO1 data register | ||
209 | unit: Four bit as hex (e.g. 0x0f) | ||
210 | */ | ||
211 | static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1); | ||
212 | |||
213 | /* sys file functions for GPIO2 */ | ||
214 | static ssize_t atxp1_showgpio2(struct device *dev, struct device_attribute *attr, char *buf) | ||
215 | { | ||
216 | int size; | ||
217 | struct atxp1_data *data; | ||
218 | |||
219 | data = atxp1_update_device(dev); | ||
220 | |||
221 | size = sprintf(buf, "0x%02x\n", data->reg.gpio2); | ||
222 | |||
223 | return size; | ||
224 | } | ||
225 | |||
226 | static ssize_t atxp1_storegpio2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | ||
227 | { | ||
228 | struct atxp1_data *data; | ||
229 | struct i2c_client *client; | ||
230 | unsigned int value; | ||
231 | |||
232 | client = to_i2c_client(dev); | ||
233 | data = atxp1_update_device(dev); | ||
234 | |||
235 | value = simple_strtoul(buf, NULL, 16) & 0xff; | ||
236 | |||
237 | if (value != data->reg.gpio2) { | ||
238 | dev_info(dev, "Writing 0x%x to GPIO1.\n", value); | ||
239 | |||
240 | i2c_smbus_write_byte_data(client, ATXP1_GPIO2, value); | ||
241 | |||
242 | data->valid = 0; | ||
243 | } | ||
244 | |||
245 | return count; | ||
246 | } | ||
247 | |||
248 | /* GPIO2 data register | ||
249 | unit: Eight bit as hex (e.g. 0xff) | ||
250 | */ | ||
251 | static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); | ||
252 | |||
253 | |||
254 | static int atxp1_attach_adapter(struct i2c_adapter *adapter) | ||
255 | { | ||
256 | return i2c_detect(adapter, &addr_data, &atxp1_detect); | ||
257 | }; | ||
258 | |||
259 | static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) | ||
260 | { | ||
261 | struct i2c_client * new_client; | ||
262 | struct atxp1_data * data; | ||
263 | int err = 0; | ||
264 | u8 temp; | ||
265 | |||
266 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
267 | goto exit; | ||
268 | |||
269 | if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { | ||
270 | err = -ENOMEM; | ||
271 | goto exit; | ||
272 | } | ||
273 | |||
274 | memset(data, 0, sizeof(struct atxp1_data)); | ||
275 | new_client = &data->client; | ||
276 | i2c_set_clientdata(new_client, data); | ||
277 | |||
278 | new_client->addr = address; | ||
279 | new_client->adapter = adapter; | ||
280 | new_client->driver = &atxp1_driver; | ||
281 | new_client->flags = 0; | ||
282 | |||
283 | /* Detect ATXP1, checking if vendor ID registers are all zero */ | ||
284 | if (!((i2c_smbus_read_byte_data(new_client, 0x3e) == 0) && | ||
285 | (i2c_smbus_read_byte_data(new_client, 0x3f) == 0) && | ||
286 | (i2c_smbus_read_byte_data(new_client, 0xfe) == 0) && | ||
287 | (i2c_smbus_read_byte_data(new_client, 0xff) == 0) )) { | ||
288 | |||
289 | /* No vendor ID, now checking if registers 0x10,0x11 (non-existent) | ||
290 | * showing the same as register 0x00 */ | ||
291 | temp = i2c_smbus_read_byte_data(new_client, 0x00); | ||
292 | |||
293 | if (!((i2c_smbus_read_byte_data(new_client, 0x10) == temp) && | ||
294 | (i2c_smbus_read_byte_data(new_client, 0x11) == temp) )) | ||
295 | goto exit_free; | ||
296 | } | ||
297 | |||
298 | /* Get VRM */ | ||
299 | data->vrm = i2c_which_vrm(); | ||
300 | |||
301 | if ((data->vrm != 90) && (data->vrm != 91)) { | ||
302 | dev_err(&new_client->dev, "Not supporting VRM %d.%d\n", | ||
303 | data->vrm / 10, data->vrm % 10); | ||
304 | goto exit_free; | ||
305 | } | ||
306 | |||
307 | strncpy(new_client->name, "atxp1", I2C_NAME_SIZE); | ||
308 | |||
309 | data->valid = 0; | ||
310 | |||
311 | init_MUTEX(&data->update_lock); | ||
312 | |||
313 | err = i2c_attach_client(new_client); | ||
314 | |||
315 | if (err) | ||
316 | { | ||
317 | dev_err(&new_client->dev, "Attach client error.\n"); | ||
318 | goto exit_free; | ||
319 | } | ||
320 | |||
321 | device_create_file(&new_client->dev, &dev_attr_gpio1); | ||
322 | device_create_file(&new_client->dev, &dev_attr_gpio2); | ||
323 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | ||
324 | |||
325 | dev_info(&new_client->dev, "Using VRM: %d.%d\n", | ||
326 | data->vrm / 10, data->vrm % 10); | ||
327 | |||
328 | return 0; | ||
329 | |||
330 | exit_free: | ||
331 | kfree(data); | ||
332 | exit: | ||
333 | return err; | ||
334 | }; | ||
335 | |||
336 | static int atxp1_detach_client(struct i2c_client * client) | ||
337 | { | ||
338 | int err; | ||
339 | |||
340 | err = i2c_detach_client(client); | ||
341 | |||
342 | if (err) | ||
343 | dev_err(&client->dev, "Failed to detach client.\n"); | ||
344 | else | ||
345 | kfree(i2c_get_clientdata(client)); | ||
346 | |||
347 | return err; | ||
348 | }; | ||
349 | |||
350 | static int __init atxp1_init(void) | ||
351 | { | ||
352 | return i2c_add_driver(&atxp1_driver); | ||
353 | }; | ||
354 | |||
355 | static void __exit atxp1_exit(void) | ||
356 | { | ||
357 | i2c_del_driver(&atxp1_driver); | ||
358 | }; | ||
359 | |||
360 | module_init(atxp1_init); | ||
361 | module_exit(atxp1_exit); | ||
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 07f16c3fb084..74ece8ac1c23 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c | |||
@@ -3,17 +3,16 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2005 James Chapman <jchapman@katalix.com> | 4 | * Copyright (C) 2005 James Chapman <jchapman@katalix.com> |
5 | * | 5 | * |
6 | * based on linux/drivers/acron/char/pcf8583.c | 6 | * based on linux/drivers/acorn/char/pcf8583.c |
7 | * Copyright (C) 2000 Russell King | 7 | * Copyright (C) 2000 Russell King |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License version 2 as | 10 | * it under the terms of the GNU General Public License version 2 as |
11 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
12 | * | 12 | * |
13 | * Driver for Dallas Semiconductor DS1337 real time clock chip | 13 | * Driver for Dallas Semiconductor DS1337 and DS1339 real time clock chip |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/config.h> | ||
17 | #include <linux/module.h> | 16 | #include <linux/module.h> |
18 | #include <linux/init.h> | 17 | #include <linux/init.h> |
19 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
@@ -69,13 +68,11 @@ static struct i2c_driver ds1337_driver = { | |||
69 | struct ds1337_data { | 68 | struct ds1337_data { |
70 | struct i2c_client client; | 69 | struct i2c_client client; |
71 | struct list_head list; | 70 | struct list_head list; |
72 | int id; | ||
73 | }; | 71 | }; |
74 | 72 | ||
75 | /* | 73 | /* |
76 | * Internal variables | 74 | * Internal variables |
77 | */ | 75 | */ |
78 | static int ds1337_id; | ||
79 | static LIST_HEAD(ds1337_clients); | 76 | static LIST_HEAD(ds1337_clients); |
80 | 77 | ||
81 | static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) | 78 | static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) |
@@ -95,7 +92,6 @@ static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) | |||
95 | */ | 92 | */ |
96 | static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) | 93 | static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) |
97 | { | 94 | { |
98 | struct ds1337_data *data = i2c_get_clientdata(client); | ||
99 | int result; | 95 | int result; |
100 | u8 buf[7]; | 96 | u8 buf[7]; |
101 | u8 val; | 97 | u8 val; |
@@ -103,9 +99,7 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) | |||
103 | u8 offs = 0; | 99 | u8 offs = 0; |
104 | 100 | ||
105 | if (!dt) { | 101 | if (!dt) { |
106 | dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n", | 102 | dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__); |
107 | __FUNCTION__); | ||
108 | |||
109 | return -EINVAL; | 103 | return -EINVAL; |
110 | } | 104 | } |
111 | 105 | ||
@@ -119,98 +113,86 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) | |||
119 | msg[1].len = sizeof(buf); | 113 | msg[1].len = sizeof(buf); |
120 | msg[1].buf = &buf[0]; | 114 | msg[1].buf = &buf[0]; |
121 | 115 | ||
122 | result = client->adapter->algo->master_xfer(client->adapter, | 116 | result = i2c_transfer(client->adapter, msg, 2); |
123 | &msg[0], 2); | ||
124 | 117 | ||
125 | dev_dbg(&client->adapter->dev, | 118 | dev_dbg(&client->dev, "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n", |
126 | "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n", | ||
127 | __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3], | 119 | __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3], |
128 | buf[4], buf[5], buf[6]); | 120 | buf[4], buf[5], buf[6]); |
129 | 121 | ||
130 | if (result >= 0) { | 122 | if (result == 2) { |
131 | dt->tm_sec = BCD_TO_BIN(buf[0]); | 123 | dt->tm_sec = BCD2BIN(buf[0]); |
132 | dt->tm_min = BCD_TO_BIN(buf[1]); | 124 | dt->tm_min = BCD2BIN(buf[1]); |
133 | val = buf[2] & 0x3f; | 125 | val = buf[2] & 0x3f; |
134 | dt->tm_hour = BCD_TO_BIN(val); | 126 | dt->tm_hour = BCD2BIN(val); |
135 | dt->tm_wday = BCD_TO_BIN(buf[3]) - 1; | 127 | dt->tm_wday = BCD2BIN(buf[3]) - 1; |
136 | dt->tm_mday = BCD_TO_BIN(buf[4]); | 128 | dt->tm_mday = BCD2BIN(buf[4]); |
137 | val = buf[5] & 0x7f; | 129 | val = buf[5] & 0x7f; |
138 | dt->tm_mon = BCD_TO_BIN(val); | 130 | dt->tm_mon = BCD2BIN(val) - 1; |
139 | dt->tm_year = 1900 + BCD_TO_BIN(buf[6]); | 131 | dt->tm_year = BCD2BIN(buf[6]); |
140 | if (buf[5] & 0x80) | 132 | if (buf[5] & 0x80) |
141 | dt->tm_year += 100; | 133 | dt->tm_year += 100; |
142 | 134 | ||
143 | dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, " | 135 | dev_dbg(&client->dev, "%s: secs=%d, mins=%d, " |
144 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", | 136 | "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", |
145 | __FUNCTION__, dt->tm_sec, dt->tm_min, | 137 | __FUNCTION__, dt->tm_sec, dt->tm_min, |
146 | dt->tm_hour, dt->tm_mday, | 138 | dt->tm_hour, dt->tm_mday, |
147 | dt->tm_mon, dt->tm_year, dt->tm_wday); | 139 | dt->tm_mon, dt->tm_year, dt->tm_wday); |
148 | } else { | 140 | |
149 | dev_err(&client->adapter->dev, "ds1337[%d]: error reading " | 141 | return 0; |
150 | "data! %d\n", data->id, result); | ||
151 | result = -EIO; | ||
152 | } | 142 | } |
153 | 143 | ||
154 | return result; | 144 | dev_err(&client->dev, "error reading data! %d\n", result); |
145 | return -EIO; | ||
155 | } | 146 | } |
156 | 147 | ||
157 | static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) | 148 | static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) |
158 | { | 149 | { |
159 | struct ds1337_data *data = i2c_get_clientdata(client); | ||
160 | int result; | 150 | int result; |
161 | u8 buf[8]; | 151 | u8 buf[8]; |
162 | u8 val; | 152 | u8 val; |
163 | struct i2c_msg msg[1]; | 153 | struct i2c_msg msg[1]; |
164 | 154 | ||
165 | if (!dt) { | 155 | if (!dt) { |
166 | dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n", | 156 | dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__); |
167 | __FUNCTION__); | ||
168 | |||
169 | return -EINVAL; | 157 | return -EINVAL; |
170 | } | 158 | } |
171 | 159 | ||
172 | dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, hours=%d, " | 160 | dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " |
173 | "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__, | 161 | "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__, |
174 | dt->tm_sec, dt->tm_min, dt->tm_hour, | 162 | dt->tm_sec, dt->tm_min, dt->tm_hour, |
175 | dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday); | 163 | dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday); |
176 | 164 | ||
177 | buf[0] = 0; /* reg offset */ | 165 | buf[0] = 0; /* reg offset */ |
178 | buf[1] = BIN_TO_BCD(dt->tm_sec); | 166 | buf[1] = BIN2BCD(dt->tm_sec); |
179 | buf[2] = BIN_TO_BCD(dt->tm_min); | 167 | buf[2] = BIN2BCD(dt->tm_min); |
180 | buf[3] = BIN_TO_BCD(dt->tm_hour) | (1 << 6); | 168 | buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6); |
181 | buf[4] = BIN_TO_BCD(dt->tm_wday) + 1; | 169 | buf[4] = BIN2BCD(dt->tm_wday) + 1; |
182 | buf[5] = BIN_TO_BCD(dt->tm_mday); | 170 | buf[5] = BIN2BCD(dt->tm_mday); |
183 | buf[6] = BIN_TO_BCD(dt->tm_mon); | 171 | buf[6] = BIN2BCD(dt->tm_mon) + 1; |
184 | if (dt->tm_year >= 2000) { | 172 | val = dt->tm_year; |
185 | val = dt->tm_year - 2000; | 173 | if (val >= 100) { |
174 | val -= 100; | ||
186 | buf[6] |= (1 << 7); | 175 | buf[6] |= (1 << 7); |
187 | } else { | ||
188 | val = dt->tm_year - 1900; | ||
189 | } | 176 | } |
190 | buf[7] = BIN_TO_BCD(val); | 177 | buf[7] = BIN2BCD(val); |
191 | 178 | ||
192 | msg[0].addr = client->addr; | 179 | msg[0].addr = client->addr; |
193 | msg[0].flags = 0; | 180 | msg[0].flags = 0; |
194 | msg[0].len = sizeof(buf); | 181 | msg[0].len = sizeof(buf); |
195 | msg[0].buf = &buf[0]; | 182 | msg[0].buf = &buf[0]; |
196 | 183 | ||
197 | result = client->adapter->algo->master_xfer(client->adapter, | 184 | result = i2c_transfer(client->adapter, msg, 1); |
198 | &msg[0], 1); | 185 | if (result == 1) |
199 | if (result < 0) { | 186 | return 0; |
200 | dev_err(&client->adapter->dev, "ds1337[%d]: error " | ||
201 | "writing data! %d\n", data->id, result); | ||
202 | result = -EIO; | ||
203 | } else { | ||
204 | result = 0; | ||
205 | } | ||
206 | 187 | ||
207 | return result; | 188 | dev_err(&client->dev, "error writing data! %d\n", result); |
189 | return -EIO; | ||
208 | } | 190 | } |
209 | 191 | ||
210 | static int ds1337_command(struct i2c_client *client, unsigned int cmd, | 192 | static int ds1337_command(struct i2c_client *client, unsigned int cmd, |
211 | void *arg) | 193 | void *arg) |
212 | { | 194 | { |
213 | dev_dbg(&client->adapter->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); | 195 | dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); |
214 | 196 | ||
215 | switch (cmd) { | 197 | switch (cmd) { |
216 | case DS1337_GET_DATE: | 198 | case DS1337_GET_DATE: |
@@ -228,7 +210,7 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd, | |||
228 | * Public API for access to specific device. Useful for low-level | 210 | * Public API for access to specific device. Useful for low-level |
229 | * RTC access from kernel code. | 211 | * RTC access from kernel code. |
230 | */ | 212 | */ |
231 | int ds1337_do_command(int id, int cmd, void *arg) | 213 | int ds1337_do_command(int bus, int cmd, void *arg) |
232 | { | 214 | { |
233 | struct list_head *walk; | 215 | struct list_head *walk; |
234 | struct list_head *tmp; | 216 | struct list_head *tmp; |
@@ -236,7 +218,7 @@ int ds1337_do_command(int id, int cmd, void *arg) | |||
236 | 218 | ||
237 | list_for_each_safe(walk, tmp, &ds1337_clients) { | 219 | list_for_each_safe(walk, tmp, &ds1337_clients) { |
238 | data = list_entry(walk, struct ds1337_data, list); | 220 | data = list_entry(walk, struct ds1337_data, list); |
239 | if (data->id == id) | 221 | if (data->client.adapter->nr == bus) |
240 | return ds1337_command(&data->client, cmd, arg); | 222 | return ds1337_command(&data->client, cmd, arg); |
241 | } | 223 | } |
242 | 224 | ||
@@ -346,7 +328,6 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind) | |||
346 | ds1337_init_client(new_client); | 328 | ds1337_init_client(new_client); |
347 | 329 | ||
348 | /* Add client to local list */ | 330 | /* Add client to local list */ |
349 | data->id = ds1337_id++; | ||
350 | list_add(&data->list, &ds1337_clients); | 331 | list_add(&data->list, &ds1337_clients); |
351 | 332 | ||
352 | return 0; | 333 | return 0; |
@@ -398,5 +379,7 @@ MODULE_AUTHOR("James Chapman <jchapman@katalix.com>"); | |||
398 | MODULE_DESCRIPTION("DS1337 RTC driver"); | 379 | MODULE_DESCRIPTION("DS1337 RTC driver"); |
399 | MODULE_LICENSE("GPL"); | 380 | MODULE_LICENSE("GPL"); |
400 | 381 | ||
382 | EXPORT_SYMBOL_GPL(ds1337_do_command); | ||
383 | |||
401 | module_init(ds1337_init); | 384 | module_init(ds1337_init); |
402 | module_exit(ds1337_exit); | 385 | module_exit(ds1337_exit); |
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c new file mode 100644 index 000000000000..a445736d8838 --- /dev/null +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -0,0 +1,260 @@ | |||
1 | /* | ||
2 | * drivers/i2c/chips/ds1374.c | ||
3 | * | ||
4 | * I2C client/driver for the Maxim/Dallas DS1374 Real-Time Clock | ||
5 | * | ||
6 | * Author: Randy Vinson <rvinson@mvista.com> | ||
7 | * | ||
8 | * Based on the m41t00.c by Mark Greer <mgreer@mvista.com> | ||
9 | * | ||
10 | * 2005 (c) MontaVista Software, Inc. This file is licensed under | ||
11 | * the terms of the GNU General Public License version 2. This program | ||
12 | * is licensed "as is" without any warranty of any kind, whether express | ||
13 | * or implied. | ||
14 | */ | ||
15 | /* | ||
16 | * This i2c client/driver wedges between the drivers/char/genrtc.c RTC | ||
17 | * interface and the SMBus interface of the i2c subsystem. | ||
18 | * It would be more efficient to use i2c msgs/i2c_transfer directly but, as | ||
19 | * recommened in .../Documentation/i2c/writing-clients section | ||
20 | * "Sending and receiving", using SMBus level communication is preferred. | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | #include <linux/i2c.h> | ||
27 | #include <linux/rtc.h> | ||
28 | #include <linux/bcd.h> | ||
29 | |||
30 | #define DS1374_REG_TOD0 0x00 | ||
31 | #define DS1374_REG_TOD1 0x01 | ||
32 | #define DS1374_REG_TOD2 0x02 | ||
33 | #define DS1374_REG_TOD3 0x03 | ||
34 | #define DS1374_REG_WDALM0 0x04 | ||
35 | #define DS1374_REG_WDALM1 0x05 | ||
36 | #define DS1374_REG_WDALM2 0x06 | ||
37 | #define DS1374_REG_CR 0x07 | ||
38 | #define DS1374_REG_SR 0x08 | ||
39 | #define DS1374_REG_SR_OSF 0x80 | ||
40 | #define DS1374_REG_TCR 0x09 | ||
41 | |||
42 | #define DS1374_DRV_NAME "ds1374" | ||
43 | |||
44 | static DECLARE_MUTEX(ds1374_mutex); | ||
45 | |||
46 | static struct i2c_driver ds1374_driver; | ||
47 | static struct i2c_client *save_client; | ||
48 | |||
49 | static unsigned short ignore[] = { I2C_CLIENT_END }; | ||
50 | static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END }; | ||
51 | |||
52 | static struct i2c_client_address_data addr_data = { | ||
53 | .normal_i2c = normal_addr, | ||
54 | .probe = ignore, | ||
55 | .ignore = ignore, | ||
56 | .force = ignore, | ||
57 | }; | ||
58 | |||
59 | static ulong ds1374_read_rtc(void) | ||
60 | { | ||
61 | ulong time = 0; | ||
62 | int reg = DS1374_REG_WDALM0; | ||
63 | |||
64 | while (reg--) { | ||
65 | s32 tmp; | ||
66 | if ((tmp = i2c_smbus_read_byte_data(save_client, reg)) < 0) { | ||
67 | dev_warn(&save_client->dev, | ||
68 | "can't read from rtc chip\n"); | ||
69 | return 0; | ||
70 | } | ||
71 | time = (time << 8) | (tmp & 0xff); | ||
72 | } | ||
73 | return time; | ||
74 | } | ||
75 | |||
76 | static void ds1374_write_rtc(ulong time) | ||
77 | { | ||
78 | int reg; | ||
79 | |||
80 | for (reg = DS1374_REG_TOD0; reg < DS1374_REG_WDALM0; reg++) { | ||
81 | if (i2c_smbus_write_byte_data(save_client, reg, time & 0xff) | ||
82 | < 0) { | ||
83 | dev_warn(&save_client->dev, | ||
84 | "can't write to rtc chip\n"); | ||
85 | break; | ||
86 | } | ||
87 | time = time >> 8; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | static void ds1374_check_rtc_status(void) | ||
92 | { | ||
93 | s32 tmp; | ||
94 | |||
95 | tmp = i2c_smbus_read_byte_data(save_client, DS1374_REG_SR); | ||
96 | if (tmp < 0) { | ||
97 | dev_warn(&save_client->dev, | ||
98 | "can't read status from rtc chip\n"); | ||
99 | return; | ||
100 | } | ||
101 | if (tmp & DS1374_REG_SR_OSF) { | ||
102 | dev_warn(&save_client->dev, | ||
103 | "oscillator discontinuity flagged, time unreliable\n"); | ||
104 | tmp &= ~DS1374_REG_SR_OSF; | ||
105 | tmp = i2c_smbus_write_byte_data(save_client, DS1374_REG_SR, | ||
106 | tmp & 0xff); | ||
107 | if (tmp < 0) | ||
108 | dev_warn(&save_client->dev, | ||
109 | "can't clear discontinuity notification\n"); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | ulong ds1374_get_rtc_time(void) | ||
114 | { | ||
115 | ulong t1, t2; | ||
116 | int limit = 10; /* arbitrary retry limit */ | ||
117 | |||
118 | down(&ds1374_mutex); | ||
119 | |||
120 | /* | ||
121 | * Since the reads are being performed one byte at a time using | ||
122 | * the SMBus vs a 4-byte i2c transfer, there is a chance that a | ||
123 | * carry will occur during the read. To detect this, 2 reads are | ||
124 | * performed and compared. | ||
125 | */ | ||
126 | do { | ||
127 | t1 = ds1374_read_rtc(); | ||
128 | t2 = ds1374_read_rtc(); | ||
129 | } while (t1 != t2 && limit--); | ||
130 | |||
131 | up(&ds1374_mutex); | ||
132 | |||
133 | if (t1 != t2) { | ||
134 | dev_warn(&save_client->dev, | ||
135 | "can't get consistent time from rtc chip\n"); | ||
136 | t1 = 0; | ||
137 | } | ||
138 | |||
139 | return t1; | ||
140 | } | ||
141 | |||
142 | static void ds1374_set_tlet(ulong arg) | ||
143 | { | ||
144 | ulong t1, t2; | ||
145 | int limit = 10; /* arbitrary retry limit */ | ||
146 | |||
147 | t1 = *(ulong *) arg; | ||
148 | |||
149 | down(&ds1374_mutex); | ||
150 | |||
151 | /* | ||
152 | * Since the writes are being performed one byte at a time using | ||
153 | * the SMBus vs a 4-byte i2c transfer, there is a chance that a | ||
154 | * carry will occur during the write. To detect this, the write | ||
155 | * value is read back and compared. | ||
156 | */ | ||
157 | do { | ||
158 | ds1374_write_rtc(t1); | ||
159 | t2 = ds1374_read_rtc(); | ||
160 | } while (t1 != t2 && limit--); | ||
161 | |||
162 | up(&ds1374_mutex); | ||
163 | |||
164 | if (t1 != t2) | ||
165 | dev_warn(&save_client->dev, | ||
166 | "can't confirm time set from rtc chip\n"); | ||
167 | } | ||
168 | |||
169 | ulong new_time; | ||
170 | |||
171 | DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time); | ||
172 | |||
173 | int ds1374_set_rtc_time(ulong nowtime) | ||
174 | { | ||
175 | new_time = nowtime; | ||
176 | |||
177 | if (in_interrupt()) | ||
178 | tasklet_schedule(&ds1374_tasklet); | ||
179 | else | ||
180 | ds1374_set_tlet((ulong) & new_time); | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | ***************************************************************************** | ||
187 | * | ||
188 | * Driver Interface | ||
189 | * | ||
190 | ***************************************************************************** | ||
191 | */ | ||
192 | static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind) | ||
193 | { | ||
194 | struct i2c_client *client; | ||
195 | int rc; | ||
196 | |||
197 | client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
198 | if (!client) | ||
199 | return -ENOMEM; | ||
200 | |||
201 | memset(client, 0, sizeof(struct i2c_client)); | ||
202 | strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE); | ||
203 | client->flags = I2C_DF_NOTIFY; | ||
204 | client->addr = addr; | ||
205 | client->adapter = adap; | ||
206 | client->driver = &ds1374_driver; | ||
207 | |||
208 | if ((rc = i2c_attach_client(client)) != 0) { | ||
209 | kfree(client); | ||
210 | return rc; | ||
211 | } | ||
212 | |||
213 | save_client = client; | ||
214 | |||
215 | ds1374_check_rtc_status(); | ||
216 | |||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static int ds1374_attach(struct i2c_adapter *adap) | ||
221 | { | ||
222 | return i2c_probe(adap, &addr_data, ds1374_probe); | ||
223 | } | ||
224 | |||
225 | static int ds1374_detach(struct i2c_client *client) | ||
226 | { | ||
227 | int rc; | ||
228 | |||
229 | if ((rc = i2c_detach_client(client)) == 0) { | ||
230 | kfree(i2c_get_clientdata(client)); | ||
231 | tasklet_kill(&ds1374_tasklet); | ||
232 | } | ||
233 | return rc; | ||
234 | } | ||
235 | |||
236 | static struct i2c_driver ds1374_driver = { | ||
237 | .owner = THIS_MODULE, | ||
238 | .name = DS1374_DRV_NAME, | ||
239 | .id = I2C_DRIVERID_DS1374, | ||
240 | .flags = I2C_DF_NOTIFY, | ||
241 | .attach_adapter = ds1374_attach, | ||
242 | .detach_client = ds1374_detach, | ||
243 | }; | ||
244 | |||
245 | static int __init ds1374_init(void) | ||
246 | { | ||
247 | return i2c_add_driver(&ds1374_driver); | ||
248 | } | ||
249 | |||
250 | static void __exit ds1374_exit(void) | ||
251 | { | ||
252 | i2c_del_driver(&ds1374_driver); | ||
253 | } | ||
254 | |||
255 | module_init(ds1374_init); | ||
256 | module_exit(ds1374_exit); | ||
257 | |||
258 | MODULE_AUTHOR("Randy Vinson <rvinson@mvista.com>"); | ||
259 | MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC I2C Client Driver"); | ||
260 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/i2c/chips/ds1621.c b/drivers/i2c/chips/ds1621.c index 4ae15bd5dcfb..5360d58804f6 100644 --- a/drivers/i2c/chips/ds1621.c +++ b/drivers/i2c/chips/ds1621.c | |||
@@ -121,7 +121,7 @@ static int ds1621_write_value(struct i2c_client *client, u8 reg, u16 value) | |||
121 | static void ds1621_init_client(struct i2c_client *client) | 121 | static void ds1621_init_client(struct i2c_client *client) |
122 | { | 122 | { |
123 | int reg = ds1621_read_value(client, DS1621_REG_CONF); | 123 | int reg = ds1621_read_value(client, DS1621_REG_CONF); |
124 | /* switch to continous conversion mode */ | 124 | /* switch to continuous conversion mode */ |
125 | reg &= ~ DS1621_REG_CONFIG_1SHOT; | 125 | reg &= ~ DS1621_REG_CONFIG_1SHOT; |
126 | 126 | ||
127 | /* setup output polarity */ | 127 | /* setup output polarity */ |
@@ -303,7 +303,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) | |||
303 | data->temp_max = ds1621_read_value(client, | 303 | data->temp_max = ds1621_read_value(client, |
304 | DS1621_REG_TEMP_MAX); | 304 | DS1621_REG_TEMP_MAX); |
305 | 305 | ||
306 | /* reset alarms if neccessary */ | 306 | /* reset alarms if necessary */ |
307 | new_conf = data->conf; | 307 | new_conf = data->conf; |
308 | if (data->temp < data->temp_min) | 308 | if (data->temp < data->temp_min) |
309 | new_conf &= ~DS1621_ALARM_TEMP_LOW; | 309 | new_conf &= ~DS1621_ALARM_TEMP_LOW; |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index cbdfa2db6f7c..addf0adc24d4 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -26,7 +26,6 @@ | |||
26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/module.h> | 31 | #include <linux/module.h> |
diff --git a/drivers/i2c/chips/fscher.c b/drivers/i2c/chips/fscher.c index c3f37dbec11a..da411741c2c5 100644 --- a/drivers/i2c/chips/fscher.c +++ b/drivers/i2c/chips/fscher.c | |||
@@ -26,7 +26,6 @@ | |||
26 | * and Philip Edelbrock <phil@netroedge.com> | 26 | * and Philip Edelbrock <phil@netroedge.com> |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #include <linux/module.h> | 29 | #include <linux/module.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/gl518sm.c b/drivers/i2c/chips/gl518sm.c index 4316a1562251..6bedf729dcf5 100644 --- a/drivers/i2c/chips/gl518sm.c +++ b/drivers/i2c/chips/gl518sm.c | |||
@@ -36,7 +36,6 @@ | |||
36 | * 2004-01-31 Code review and approval. (Jean Delvare) | 36 | * 2004-01-31 Code review and approval. (Jean Delvare) |
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include <linux/config.h> | ||
40 | #include <linux/module.h> | 39 | #include <linux/module.h> |
41 | #include <linux/init.h> | 40 | #include <linux/init.h> |
42 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 7f29a8aff165..354a26295672 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c | |||
@@ -145,7 +145,6 @@ static inline void notresponding(struct isp1301 *isp) | |||
145 | static unsigned short normal_i2c[] = { | 145 | static unsigned short normal_i2c[] = { |
146 | ISP_BASE, ISP_BASE + 1, | 146 | ISP_BASE, ISP_BASE + 1, |
147 | I2C_CLIENT_END }; | 147 | I2C_CLIENT_END }; |
148 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
149 | 148 | ||
150 | I2C_CLIENT_INSMOD; | 149 | I2C_CLIENT_INSMOD; |
151 | 150 | ||
diff --git a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c index 007bdf9e7e2a..db20c9e47393 100644 --- a/drivers/i2c/chips/it87.c +++ b/drivers/i2c/chips/it87.c | |||
@@ -31,7 +31,6 @@ | |||
31 | type at module load time. | 31 | type at module load time. |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/config.h> | ||
35 | #include <linux/module.h> | 34 | #include <linux/module.h> |
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
37 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
@@ -39,6 +38,7 @@ | |||
39 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
40 | #include <linux/i2c-sensor.h> | 39 | #include <linux/i2c-sensor.h> |
41 | #include <linux/i2c-vid.h> | 40 | #include <linux/i2c-vid.h> |
41 | #include <linux/hwmon-sysfs.h> | ||
42 | #include <asm/io.h> | 42 | #include <asm/io.h> |
43 | 43 | ||
44 | 44 | ||
@@ -173,8 +173,6 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
173 | ((val)+500)/1000),-128,127)) | 173 | ((val)+500)/1000),-128,127)) |
174 | #define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000) | 174 | #define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000) |
175 | 175 | ||
176 | #define ALARMS_FROM_REG(val) (val) | ||
177 | |||
178 | #define PWM_TO_REG(val) ((val) >> 1) | 176 | #define PWM_TO_REG(val) ((val) >> 1) |
179 | #define PWM_FROM_REG(val) (((val)&0x7f) << 1) | 177 | #define PWM_FROM_REG(val) (((val)&0x7f) << 1) |
180 | 178 | ||
@@ -241,27 +239,42 @@ static struct i2c_driver it87_driver = { | |||
241 | .detach_client = it87_detach_client, | 239 | .detach_client = it87_detach_client, |
242 | }; | 240 | }; |
243 | 241 | ||
244 | static ssize_t show_in(struct device *dev, char *buf, int nr) | 242 | static ssize_t show_in(struct device *dev, struct device_attribute *attr, |
243 | char *buf) | ||
245 | { | 244 | { |
245 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
246 | int nr = sensor_attr->index; | ||
247 | |||
246 | struct it87_data *data = it87_update_device(dev); | 248 | struct it87_data *data = it87_update_device(dev); |
247 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); | 249 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); |
248 | } | 250 | } |
249 | 251 | ||
250 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | 252 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, |
253 | char *buf) | ||
251 | { | 254 | { |
255 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
256 | int nr = sensor_attr->index; | ||
257 | |||
252 | struct it87_data *data = it87_update_device(dev); | 258 | struct it87_data *data = it87_update_device(dev); |
253 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])); | 259 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])); |
254 | } | 260 | } |
255 | 261 | ||
256 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 262 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
263 | char *buf) | ||
257 | { | 264 | { |
265 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
266 | int nr = sensor_attr->index; | ||
267 | |||
258 | struct it87_data *data = it87_update_device(dev); | 268 | struct it87_data *data = it87_update_device(dev); |
259 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])); | 269 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])); |
260 | } | 270 | } |
261 | 271 | ||
262 | static ssize_t set_in_min(struct device *dev, const char *buf, | 272 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
263 | size_t count, int nr) | 273 | const char *buf, size_t count) |
264 | { | 274 | { |
275 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
276 | int nr = sensor_attr->index; | ||
277 | |||
265 | struct i2c_client *client = to_i2c_client(dev); | 278 | struct i2c_client *client = to_i2c_client(dev); |
266 | struct it87_data *data = i2c_get_clientdata(client); | 279 | struct it87_data *data = i2c_get_clientdata(client); |
267 | unsigned long val = simple_strtoul(buf, NULL, 10); | 280 | unsigned long val = simple_strtoul(buf, NULL, 10); |
@@ -273,9 +286,12 @@ static ssize_t set_in_min(struct device *dev, const char *buf, | |||
273 | up(&data->update_lock); | 286 | up(&data->update_lock); |
274 | return count; | 287 | return count; |
275 | } | 288 | } |
276 | static ssize_t set_in_max(struct device *dev, const char *buf, | 289 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
277 | size_t count, int nr) | 290 | const char *buf, size_t count) |
278 | { | 291 | { |
292 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
293 | int nr = sensor_attr->index; | ||
294 | |||
279 | struct i2c_client *client = to_i2c_client(dev); | 295 | struct i2c_client *client = to_i2c_client(dev); |
280 | struct it87_data *data = i2c_get_clientdata(client); | 296 | struct it87_data *data = i2c_get_clientdata(client); |
281 | unsigned long val = simple_strtoul(buf, NULL, 10); | 297 | unsigned long val = simple_strtoul(buf, NULL, 10); |
@@ -289,38 +305,14 @@ static ssize_t set_in_max(struct device *dev, const char *buf, | |||
289 | } | 305 | } |
290 | 306 | ||
291 | #define show_in_offset(offset) \ | 307 | #define show_in_offset(offset) \ |
292 | static ssize_t \ | 308 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
293 | show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | 309 | show_in, NULL, offset); |
294 | { \ | ||
295 | return show_in(dev, buf, offset); \ | ||
296 | } \ | ||
297 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); | ||
298 | 310 | ||
299 | #define limit_in_offset(offset) \ | 311 | #define limit_in_offset(offset) \ |
300 | static ssize_t \ | 312 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ |
301 | show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ | 313 | show_in_min, set_in_min, offset); \ |
302 | { \ | 314 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ |
303 | return show_in_min(dev, buf, offset); \ | 315 | show_in_max, set_in_max, offset); |
304 | } \ | ||
305 | static ssize_t \ | ||
306 | show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ | ||
307 | { \ | ||
308 | return show_in_max(dev, buf, offset); \ | ||
309 | } \ | ||
310 | static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \ | ||
311 | const char *buf, size_t count) \ | ||
312 | { \ | ||
313 | return set_in_min(dev, buf, count, offset); \ | ||
314 | } \ | ||
315 | static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \ | ||
316 | const char *buf, size_t count) \ | ||
317 | { \ | ||
318 | return set_in_max(dev, buf, count, offset); \ | ||
319 | } \ | ||
320 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
321 | show_in##offset##_min, set_in##offset##_min); \ | ||
322 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
323 | show_in##offset##_max, set_in##offset##_max); | ||
324 | 316 | ||
325 | show_in_offset(0); | 317 | show_in_offset(0); |
326 | limit_in_offset(0); | 318 | limit_in_offset(0); |
@@ -341,24 +333,39 @@ limit_in_offset(7); | |||
341 | show_in_offset(8); | 333 | show_in_offset(8); |
342 | 334 | ||
343 | /* 3 temperatures */ | 335 | /* 3 temperatures */ |
344 | static ssize_t show_temp(struct device *dev, char *buf, int nr) | 336 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, |
337 | char *buf) | ||
345 | { | 338 | { |
339 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
340 | int nr = sensor_attr->index; | ||
341 | |||
346 | struct it87_data *data = it87_update_device(dev); | 342 | struct it87_data *data = it87_update_device(dev); |
347 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); | 343 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); |
348 | } | 344 | } |
349 | static ssize_t show_temp_max(struct device *dev, char *buf, int nr) | 345 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
346 | char *buf) | ||
350 | { | 347 | { |
348 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
349 | int nr = sensor_attr->index; | ||
350 | |||
351 | struct it87_data *data = it87_update_device(dev); | 351 | struct it87_data *data = it87_update_device(dev); |
352 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])); | 352 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])); |
353 | } | 353 | } |
354 | static ssize_t show_temp_min(struct device *dev, char *buf, int nr) | 354 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, |
355 | char *buf) | ||
355 | { | 356 | { |
357 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
358 | int nr = sensor_attr->index; | ||
359 | |||
356 | struct it87_data *data = it87_update_device(dev); | 360 | struct it87_data *data = it87_update_device(dev); |
357 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])); | 361 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])); |
358 | } | 362 | } |
359 | static ssize_t set_temp_max(struct device *dev, const char *buf, | 363 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
360 | size_t count, int nr) | 364 | const char *buf, size_t count) |
361 | { | 365 | { |
366 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
367 | int nr = sensor_attr->index; | ||
368 | |||
362 | struct i2c_client *client = to_i2c_client(dev); | 369 | struct i2c_client *client = to_i2c_client(dev); |
363 | struct it87_data *data = i2c_get_clientdata(client); | 370 | struct it87_data *data = i2c_get_clientdata(client); |
364 | int val = simple_strtol(buf, NULL, 10); | 371 | int val = simple_strtol(buf, NULL, 10); |
@@ -369,9 +376,12 @@ static ssize_t set_temp_max(struct device *dev, const char *buf, | |||
369 | up(&data->update_lock); | 376 | up(&data->update_lock); |
370 | return count; | 377 | return count; |
371 | } | 378 | } |
372 | static ssize_t set_temp_min(struct device *dev, const char *buf, | 379 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
373 | size_t count, int nr) | 380 | const char *buf, size_t count) |
374 | { | 381 | { |
382 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
383 | int nr = sensor_attr->index; | ||
384 | |||
375 | struct i2c_client *client = to_i2c_client(dev); | 385 | struct i2c_client *client = to_i2c_client(dev); |
376 | struct it87_data *data = i2c_get_clientdata(client); | 386 | struct it87_data *data = i2c_get_clientdata(client); |
377 | int val = simple_strtol(buf, NULL, 10); | 387 | int val = simple_strtol(buf, NULL, 10); |
@@ -383,42 +393,23 @@ static ssize_t set_temp_min(struct device *dev, const char *buf, | |||
383 | return count; | 393 | return count; |
384 | } | 394 | } |
385 | #define show_temp_offset(offset) \ | 395 | #define show_temp_offset(offset) \ |
386 | static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | 396 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ |
387 | { \ | 397 | show_temp, NULL, offset - 1); \ |
388 | return show_temp(dev, buf, offset - 1); \ | 398 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
389 | } \ | 399 | show_temp_max, set_temp_max, offset - 1); \ |
390 | static ssize_t \ | 400 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
391 | show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ | 401 | show_temp_min, set_temp_min, offset - 1); |
392 | { \ | ||
393 | return show_temp_max(dev, buf, offset - 1); \ | ||
394 | } \ | ||
395 | static ssize_t \ | ||
396 | show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ | ||
397 | { \ | ||
398 | return show_temp_min(dev, buf, offset - 1); \ | ||
399 | } \ | ||
400 | static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \ | ||
401 | const char *buf, size_t count) \ | ||
402 | { \ | ||
403 | return set_temp_max(dev, buf, count, offset - 1); \ | ||
404 | } \ | ||
405 | static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \ | ||
406 | const char *buf, size_t count) \ | ||
407 | { \ | ||
408 | return set_temp_min(dev, buf, count, offset - 1); \ | ||
409 | } \ | ||
410 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \ | ||
411 | static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | ||
412 | show_temp_##offset##_max, set_temp_##offset##_max); \ | ||
413 | static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ | ||
414 | show_temp_##offset##_min, set_temp_##offset##_min); | ||
415 | 402 | ||
416 | show_temp_offset(1); | 403 | show_temp_offset(1); |
417 | show_temp_offset(2); | 404 | show_temp_offset(2); |
418 | show_temp_offset(3); | 405 | show_temp_offset(3); |
419 | 406 | ||
420 | static ssize_t show_sensor(struct device *dev, char *buf, int nr) | 407 | static ssize_t show_sensor(struct device *dev, struct device_attribute *attr, |
408 | char *buf) | ||
421 | { | 409 | { |
410 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
411 | int nr = sensor_attr->index; | ||
412 | |||
422 | struct it87_data *data = it87_update_device(dev); | 413 | struct it87_data *data = it87_update_device(dev); |
423 | u8 reg = data->sensor; /* In case the value is updated while we use it */ | 414 | u8 reg = data->sensor; /* In case the value is updated while we use it */ |
424 | 415 | ||
@@ -428,9 +419,12 @@ static ssize_t show_sensor(struct device *dev, char *buf, int nr) | |||
428 | return sprintf(buf, "2\n"); /* thermistor */ | 419 | return sprintf(buf, "2\n"); /* thermistor */ |
429 | return sprintf(buf, "0\n"); /* disabled */ | 420 | return sprintf(buf, "0\n"); /* disabled */ |
430 | } | 421 | } |
431 | static ssize_t set_sensor(struct device *dev, const char *buf, | 422 | static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, |
432 | size_t count, int nr) | 423 | const char *buf, size_t count) |
433 | { | 424 | { |
425 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
426 | int nr = sensor_attr->index; | ||
427 | |||
434 | struct i2c_client *client = to_i2c_client(dev); | 428 | struct i2c_client *client = to_i2c_client(dev); |
435 | struct it87_data *data = i2c_get_clientdata(client); | 429 | struct it87_data *data = i2c_get_clientdata(client); |
436 | int val = simple_strtol(buf, NULL, 10); | 430 | int val = simple_strtol(buf, NULL, 10); |
@@ -453,53 +447,67 @@ static ssize_t set_sensor(struct device *dev, const char *buf, | |||
453 | return count; | 447 | return count; |
454 | } | 448 | } |
455 | #define show_sensor_offset(offset) \ | 449 | #define show_sensor_offset(offset) \ |
456 | static ssize_t show_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | 450 | static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \ |
457 | { \ | 451 | show_sensor, set_sensor, offset - 1); |
458 | return show_sensor(dev, buf, offset - 1); \ | ||
459 | } \ | ||
460 | static ssize_t set_sensor_##offset (struct device *dev, struct device_attribute *attr, \ | ||
461 | const char *buf, size_t count) \ | ||
462 | { \ | ||
463 | return set_sensor(dev, buf, count, offset - 1); \ | ||
464 | } \ | ||
465 | static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \ | ||
466 | show_sensor_##offset, set_sensor_##offset); | ||
467 | 452 | ||
468 | show_sensor_offset(1); | 453 | show_sensor_offset(1); |
469 | show_sensor_offset(2); | 454 | show_sensor_offset(2); |
470 | show_sensor_offset(3); | 455 | show_sensor_offset(3); |
471 | 456 | ||
472 | /* 3 Fans */ | 457 | /* 3 Fans */ |
473 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | 458 | static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
459 | char *buf) | ||
474 | { | 460 | { |
461 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
462 | int nr = sensor_attr->index; | ||
463 | |||
475 | struct it87_data *data = it87_update_device(dev); | 464 | struct it87_data *data = it87_update_device(dev); |
476 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], | 465 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], |
477 | DIV_FROM_REG(data->fan_div[nr]))); | 466 | DIV_FROM_REG(data->fan_div[nr]))); |
478 | } | 467 | } |
479 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | 468 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
469 | char *buf) | ||
480 | { | 470 | { |
471 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
472 | int nr = sensor_attr->index; | ||
473 | |||
481 | struct it87_data *data = it87_update_device(dev); | 474 | struct it87_data *data = it87_update_device(dev); |
482 | return sprintf(buf,"%d\n", | 475 | return sprintf(buf,"%d\n", |
483 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]))); | 476 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]))); |
484 | } | 477 | } |
485 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | 478 | static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, |
479 | char *buf) | ||
486 | { | 480 | { |
481 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
482 | int nr = sensor_attr->index; | ||
483 | |||
487 | struct it87_data *data = it87_update_device(dev); | 484 | struct it87_data *data = it87_update_device(dev); |
488 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); | 485 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); |
489 | } | 486 | } |
490 | static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) | 487 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, |
488 | char *buf) | ||
491 | { | 489 | { |
490 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
491 | int nr = sensor_attr->index; | ||
492 | |||
492 | struct it87_data *data = it87_update_device(dev); | 493 | struct it87_data *data = it87_update_device(dev); |
493 | return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0); | 494 | return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0); |
494 | } | 495 | } |
495 | static ssize_t show_pwm(struct device *dev, char *buf, int nr) | 496 | static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, |
497 | char *buf) | ||
496 | { | 498 | { |
499 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
500 | int nr = sensor_attr->index; | ||
501 | |||
497 | struct it87_data *data = it87_update_device(dev); | 502 | struct it87_data *data = it87_update_device(dev); |
498 | return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]); | 503 | return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]); |
499 | } | 504 | } |
500 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 505 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
501 | size_t count, int nr) | 506 | const char *buf, size_t count) |
502 | { | 507 | { |
508 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
509 | int nr = sensor_attr->index; | ||
510 | |||
503 | struct i2c_client *client = to_i2c_client(dev); | 511 | struct i2c_client *client = to_i2c_client(dev); |
504 | struct it87_data *data = i2c_get_clientdata(client); | 512 | struct it87_data *data = i2c_get_clientdata(client); |
505 | int val = simple_strtol(buf, NULL, 10); | 513 | int val = simple_strtol(buf, NULL, 10); |
@@ -510,9 +518,12 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
510 | up(&data->update_lock); | 518 | up(&data->update_lock); |
511 | return count; | 519 | return count; |
512 | } | 520 | } |
513 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 521 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
514 | size_t count, int nr) | 522 | const char *buf, size_t count) |
515 | { | 523 | { |
524 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
525 | int nr = sensor_attr->index; | ||
526 | |||
516 | struct i2c_client *client = to_i2c_client(dev); | 527 | struct i2c_client *client = to_i2c_client(dev); |
517 | struct it87_data *data = i2c_get_clientdata(client); | 528 | struct it87_data *data = i2c_get_clientdata(client); |
518 | int val = simple_strtol(buf, NULL, 10); | 529 | int val = simple_strtol(buf, NULL, 10); |
@@ -550,9 +561,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
550 | up(&data->update_lock); | 561 | up(&data->update_lock); |
551 | return count; | 562 | return count; |
552 | } | 563 | } |
553 | static ssize_t set_pwm_enable(struct device *dev, const char *buf, | 564 | static ssize_t set_pwm_enable(struct device *dev, |
554 | size_t count, int nr) | 565 | struct device_attribute *attr, const char *buf, size_t count) |
555 | { | 566 | { |
567 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
568 | int nr = sensor_attr->index; | ||
569 | |||
556 | struct i2c_client *client = to_i2c_client(dev); | 570 | struct i2c_client *client = to_i2c_client(dev); |
557 | struct it87_data *data = i2c_get_clientdata(client); | 571 | struct it87_data *data = i2c_get_clientdata(client); |
558 | int val = simple_strtol(buf, NULL, 10); | 572 | int val = simple_strtol(buf, NULL, 10); |
@@ -581,9 +595,12 @@ static ssize_t set_pwm_enable(struct device *dev, const char *buf, | |||
581 | up(&data->update_lock); | 595 | up(&data->update_lock); |
582 | return count; | 596 | return count; |
583 | } | 597 | } |
584 | static ssize_t set_pwm(struct device *dev, const char *buf, | 598 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
585 | size_t count, int nr) | 599 | const char *buf, size_t count) |
586 | { | 600 | { |
601 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
602 | int nr = sensor_attr->index; | ||
603 | |||
587 | struct i2c_client *client = to_i2c_client(dev); | 604 | struct i2c_client *client = to_i2c_client(dev); |
588 | struct it87_data *data = i2c_get_clientdata(client); | 605 | struct it87_data *data = i2c_get_clientdata(client); |
589 | int val = simple_strtol(buf, NULL, 10); | 606 | int val = simple_strtol(buf, NULL, 10); |
@@ -599,64 +616,23 @@ static ssize_t set_pwm(struct device *dev, const char *buf, | |||
599 | return count; | 616 | return count; |
600 | } | 617 | } |
601 | 618 | ||
602 | #define show_fan_offset(offset) \ | 619 | #define show_fan_offset(offset) \ |
603 | static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | 620 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ |
604 | { \ | 621 | show_fan, NULL, offset - 1); \ |
605 | return show_fan(dev, buf, offset - 1); \ | 622 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
606 | } \ | 623 | show_fan_min, set_fan_min, offset - 1); \ |
607 | static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ | 624 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ |
608 | { \ | 625 | show_fan_div, set_fan_div, offset - 1); |
609 | return show_fan_min(dev, buf, offset - 1); \ | ||
610 | } \ | ||
611 | static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ | ||
612 | { \ | ||
613 | return show_fan_div(dev, buf, offset - 1); \ | ||
614 | } \ | ||
615 | static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ | ||
616 | const char *buf, size_t count) \ | ||
617 | { \ | ||
618 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
619 | } \ | ||
620 | static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \ | ||
621 | const char *buf, size_t count) \ | ||
622 | { \ | ||
623 | return set_fan_div(dev, buf, count, offset - 1); \ | ||
624 | } \ | ||
625 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \ | ||
626 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
627 | show_fan_##offset##_min, set_fan_##offset##_min); \ | ||
628 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | ||
629 | show_fan_##offset##_div, set_fan_##offset##_div); | ||
630 | 626 | ||
631 | show_fan_offset(1); | 627 | show_fan_offset(1); |
632 | show_fan_offset(2); | 628 | show_fan_offset(2); |
633 | show_fan_offset(3); | 629 | show_fan_offset(3); |
634 | 630 | ||
635 | #define show_pwm_offset(offset) \ | 631 | #define show_pwm_offset(offset) \ |
636 | static ssize_t show_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \ | 632 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ |
637 | char *buf) \ | 633 | show_pwm_enable, set_pwm_enable, offset - 1); \ |
638 | { \ | 634 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ |
639 | return show_pwm_enable(dev, buf, offset - 1); \ | 635 | show_pwm, set_pwm, offset - 1); |
640 | } \ | ||
641 | static ssize_t show_pwm##offset (struct device *dev, struct device_attribute *attr, char *buf) \ | ||
642 | { \ | ||
643 | return show_pwm(dev, buf, offset - 1); \ | ||
644 | } \ | ||
645 | static ssize_t set_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \ | ||
646 | const char *buf, size_t count) \ | ||
647 | { \ | ||
648 | return set_pwm_enable(dev, buf, count, offset - 1); \ | ||
649 | } \ | ||
650 | static ssize_t set_pwm##offset (struct device *dev, struct device_attribute *attr, \ | ||
651 | const char *buf, size_t count) \ | ||
652 | { \ | ||
653 | return set_pwm(dev, buf, count, offset - 1); \ | ||
654 | } \ | ||
655 | static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ | ||
656 | show_pwm##offset##_enable, \ | ||
657 | set_pwm##offset##_enable); \ | ||
658 | static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ | ||
659 | show_pwm##offset , set_pwm##offset ); | ||
660 | 636 | ||
661 | show_pwm_offset(1); | 637 | show_pwm_offset(1); |
662 | show_pwm_offset(2); | 638 | show_pwm_offset(2); |
@@ -666,7 +642,7 @@ show_pwm_offset(3); | |||
666 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 642 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
667 | { | 643 | { |
668 | struct it87_data *data = it87_update_device(dev); | 644 | struct it87_data *data = it87_update_device(dev); |
669 | return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); | 645 | return sprintf(buf, "%u\n", data->alarms); |
670 | } | 646 | } |
671 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 647 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
672 | 648 | ||
@@ -864,60 +840,60 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
864 | it87_init_client(new_client, data); | 840 | it87_init_client(new_client, data); |
865 | 841 | ||
866 | /* Register sysfs hooks */ | 842 | /* Register sysfs hooks */ |
867 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 843 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); |
868 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 844 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); |
869 | device_create_file(&new_client->dev, &dev_attr_in2_input); | 845 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); |
870 | device_create_file(&new_client->dev, &dev_attr_in3_input); | 846 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); |
871 | device_create_file(&new_client->dev, &dev_attr_in4_input); | 847 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); |
872 | device_create_file(&new_client->dev, &dev_attr_in5_input); | 848 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); |
873 | device_create_file(&new_client->dev, &dev_attr_in6_input); | 849 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); |
874 | device_create_file(&new_client->dev, &dev_attr_in7_input); | 850 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); |
875 | device_create_file(&new_client->dev, &dev_attr_in8_input); | 851 | device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); |
876 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 852 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); |
877 | device_create_file(&new_client->dev, &dev_attr_in1_min); | 853 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr); |
878 | device_create_file(&new_client->dev, &dev_attr_in2_min); | 854 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr); |
879 | device_create_file(&new_client->dev, &dev_attr_in3_min); | 855 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr); |
880 | device_create_file(&new_client->dev, &dev_attr_in4_min); | 856 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr); |
881 | device_create_file(&new_client->dev, &dev_attr_in5_min); | 857 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr); |
882 | device_create_file(&new_client->dev, &dev_attr_in6_min); | 858 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr); |
883 | device_create_file(&new_client->dev, &dev_attr_in7_min); | 859 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr); |
884 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 860 | device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); |
885 | device_create_file(&new_client->dev, &dev_attr_in1_max); | 861 | device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr); |
886 | device_create_file(&new_client->dev, &dev_attr_in2_max); | 862 | device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr); |
887 | device_create_file(&new_client->dev, &dev_attr_in3_max); | 863 | device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr); |
888 | device_create_file(&new_client->dev, &dev_attr_in4_max); | 864 | device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr); |
889 | device_create_file(&new_client->dev, &dev_attr_in5_max); | 865 | device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr); |
890 | device_create_file(&new_client->dev, &dev_attr_in6_max); | 866 | device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr); |
891 | device_create_file(&new_client->dev, &dev_attr_in7_max); | 867 | device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr); |
892 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 868 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); |
893 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 869 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); |
894 | device_create_file(&new_client->dev, &dev_attr_temp3_input); | 870 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr); |
895 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 871 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); |
896 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 872 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); |
897 | device_create_file(&new_client->dev, &dev_attr_temp3_max); | 873 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr); |
898 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | 874 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); |
899 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 875 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); |
900 | device_create_file(&new_client->dev, &dev_attr_temp3_min); | 876 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr); |
901 | device_create_file(&new_client->dev, &dev_attr_temp1_type); | 877 | device_create_file(&new_client->dev, &sensor_dev_attr_temp1_type.dev_attr); |
902 | device_create_file(&new_client->dev, &dev_attr_temp2_type); | 878 | device_create_file(&new_client->dev, &sensor_dev_attr_temp2_type.dev_attr); |
903 | device_create_file(&new_client->dev, &dev_attr_temp3_type); | 879 | device_create_file(&new_client->dev, &sensor_dev_attr_temp3_type.dev_attr); |
904 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 880 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr); |
905 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | 881 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_input.dev_attr); |
906 | device_create_file(&new_client->dev, &dev_attr_fan3_input); | 882 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_input.dev_attr); |
907 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 883 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_min.dev_attr); |
908 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | 884 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_min.dev_attr); |
909 | device_create_file(&new_client->dev, &dev_attr_fan3_min); | 885 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_min.dev_attr); |
910 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 886 | device_create_file(&new_client->dev, &sensor_dev_attr_fan1_div.dev_attr); |
911 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | 887 | device_create_file(&new_client->dev, &sensor_dev_attr_fan2_div.dev_attr); |
912 | device_create_file(&new_client->dev, &dev_attr_fan3_div); | 888 | device_create_file(&new_client->dev, &sensor_dev_attr_fan3_div.dev_attr); |
913 | device_create_file(&new_client->dev, &dev_attr_alarms); | 889 | device_create_file(&new_client->dev, &dev_attr_alarms); |
914 | if (enable_pwm_interface) { | 890 | if (enable_pwm_interface) { |
915 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); | 891 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm1_enable.dev_attr); |
916 | device_create_file(&new_client->dev, &dev_attr_pwm2_enable); | 892 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm2_enable.dev_attr); |
917 | device_create_file(&new_client->dev, &dev_attr_pwm3_enable); | 893 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm3_enable.dev_attr); |
918 | device_create_file(&new_client->dev, &dev_attr_pwm1); | 894 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr); |
919 | device_create_file(&new_client->dev, &dev_attr_pwm2); | 895 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr); |
920 | device_create_file(&new_client->dev, &dev_attr_pwm3); | 896 | device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr); |
921 | } | 897 | } |
922 | 898 | ||
923 | if (data->type == it8712) { | 899 | if (data->type == it8712) { |
@@ -954,7 +930,7 @@ static int it87_detach_client(struct i2c_client *client) | |||
954 | return 0; | 930 | return 0; |
955 | } | 931 | } |
956 | 932 | ||
957 | /* The SMBus locks itself, but ISA access must be locked explicitely! | 933 | /* The SMBus locks itself, but ISA access must be locked explicitly! |
958 | We don't want to lock the whole ISA bus, so we lock each client | 934 | We don't want to lock the whole ISA bus, so we lock each client |
959 | separately. | 935 | separately. |
960 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, | 936 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, |
@@ -974,7 +950,7 @@ static int it87_read_value(struct i2c_client *client, u8 reg) | |||
974 | return i2c_smbus_read_byte_data(client, reg); | 950 | return i2c_smbus_read_byte_data(client, reg); |
975 | } | 951 | } |
976 | 952 | ||
977 | /* The SMBus locks itself, but ISA access muse be locked explicitely! | 953 | /* The SMBus locks itself, but ISA access muse be locked explicitly! |
978 | We don't want to lock the whole ISA bus, so we lock each client | 954 | We don't want to lock the whole ISA bus, so we lock each client |
979 | separately. | 955 | separately. |
980 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, | 956 | We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, |
diff --git a/drivers/i2c/chips/lm63.c b/drivers/i2c/chips/lm63.c index bc68e031392b..7c6f9ea5a254 100644 --- a/drivers/i2c/chips/lm63.c +++ b/drivers/i2c/chips/lm63.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm63.c - driver for the National Semiconductor LM63 temperature sensor | 2 | * lm63.c - driver for the National Semiconductor LM63 temperature sensor |
3 | * with integrated fan control | 3 | * with integrated fan control |
4 | * Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2004-2005 Jean Delvare <khali@linux-fr.org> |
5 | * Based on the lm90 driver. | 5 | * Based on the lm90 driver. |
6 | * | 6 | * |
7 | * The LM63 is a sensor chip made by National Semiconductor. It measures | 7 | * The LM63 is a sensor chip made by National Semiconductor. It measures |
@@ -37,13 +37,13 @@ | |||
37 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 37 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
38 | */ | 38 | */ |
39 | 39 | ||
40 | #include <linux/config.h> | ||
41 | #include <linux/module.h> | 40 | #include <linux/module.h> |
42 | #include <linux/init.h> | 41 | #include <linux/init.h> |
43 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
44 | #include <linux/jiffies.h> | 43 | #include <linux/jiffies.h> |
45 | #include <linux/i2c.h> | 44 | #include <linux/i2c.h> |
46 | #include <linux/i2c-sensor.h> | 45 | #include <linux/i2c-sensor.h> |
46 | #include <linux/hwmon-sysfs.h> | ||
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Addresses to scan | 49 | * Addresses to scan |
@@ -99,9 +99,9 @@ SENSORS_INSMOD_1(lm63); | |||
99 | * Conversions and various macros | 99 | * Conversions and various macros |
100 | * For tachometer counts, the LM63 uses 16-bit values. | 100 | * For tachometer counts, the LM63 uses 16-bit values. |
101 | * For local temperature and high limit, remote critical limit and hysteresis | 101 | * For local temperature and high limit, remote critical limit and hysteresis |
102 | * value, it uses signed 8-bit values with LSB = 1 degree Celcius. | 102 | * value, it uses signed 8-bit values with LSB = 1 degree Celsius. |
103 | * For remote temperature, low and high limits, it uses signed 11-bit values | 103 | * For remote temperature, low and high limits, it uses signed 11-bit values |
104 | * with LSB = 0.125 degree Celcius, left-justified in 16-bit registers. | 104 | * with LSB = 0.125 degree Celsius, left-justified in 16-bit registers. |
105 | */ | 105 | */ |
106 | 106 | ||
107 | #define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \ | 107 | #define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \ |
@@ -158,16 +158,16 @@ struct lm63_data { | |||
158 | 158 | ||
159 | /* registers values */ | 159 | /* registers values */ |
160 | u8 config, config_fan; | 160 | u8 config, config_fan; |
161 | u16 fan1_input; | 161 | u16 fan[2]; /* 0: input |
162 | u16 fan1_low; | 162 | 1: low limit */ |
163 | u8 pwm1_freq; | 163 | u8 pwm1_freq; |
164 | u8 pwm1_value; | 164 | u8 pwm1_value; |
165 | s8 temp1_input; | 165 | s8 temp8[3]; /* 0: local input |
166 | s8 temp1_high; | 166 | 1: local high limit |
167 | s16 temp2_input; | 167 | 2: remote critical limit */ |
168 | s16 temp2_high; | 168 | s16 temp11[3]; /* 0: remote input |
169 | s16 temp2_low; | 169 | 1: remote low limit |
170 | s8 temp2_crit; | 170 | 2: remote high limit */ |
171 | u8 temp2_crit_hyst; | 171 | u8 temp2_crit_hyst; |
172 | u8 alarms; | 172 | u8 alarms; |
173 | }; | 173 | }; |
@@ -176,33 +176,33 @@ struct lm63_data { | |||
176 | * Sysfs callback functions and files | 176 | * Sysfs callback functions and files |
177 | */ | 177 | */ |
178 | 178 | ||
179 | #define show_fan(value) \ | 179 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, |
180 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | 180 | char *buf) |
181 | { \ | 181 | { |
182 | struct lm63_data *data = lm63_update_device(dev); \ | 182 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
183 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->value)); \ | 183 | struct lm63_data *data = lm63_update_device(dev); |
184 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index])); | ||
184 | } | 185 | } |
185 | show_fan(fan1_input); | ||
186 | show_fan(fan1_low); | ||
187 | 186 | ||
188 | static ssize_t set_fan1_low(struct device *dev, struct device_attribute *attr, const char *buf, | 187 | static ssize_t set_fan(struct device *dev, struct device_attribute *dummy, |
189 | size_t count) | 188 | const char *buf, size_t count) |
190 | { | 189 | { |
191 | struct i2c_client *client = to_i2c_client(dev); | 190 | struct i2c_client *client = to_i2c_client(dev); |
192 | struct lm63_data *data = i2c_get_clientdata(client); | 191 | struct lm63_data *data = i2c_get_clientdata(client); |
193 | unsigned long val = simple_strtoul(buf, NULL, 10); | 192 | unsigned long val = simple_strtoul(buf, NULL, 10); |
194 | 193 | ||
195 | down(&data->update_lock); | 194 | down(&data->update_lock); |
196 | data->fan1_low = FAN_TO_REG(val); | 195 | data->fan[1] = FAN_TO_REG(val); |
197 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, | 196 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, |
198 | data->fan1_low & 0xFF); | 197 | data->fan[1] & 0xFF); |
199 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, | 198 | i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, |
200 | data->fan1_low >> 8); | 199 | data->fan[1] >> 8); |
201 | up(&data->update_lock); | 200 | up(&data->update_lock); |
202 | return count; | 201 | return count; |
203 | } | 202 | } |
204 | 203 | ||
205 | static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf) | 204 | static ssize_t show_pwm1(struct device *dev, struct device_attribute *dummy, |
205 | char *buf) | ||
206 | { | 206 | { |
207 | struct lm63_data *data = lm63_update_device(dev); | 207 | struct lm63_data *data = lm63_update_device(dev); |
208 | return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ? | 208 | return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ? |
@@ -210,7 +210,8 @@ static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char | |||
210 | (2 * data->pwm1_freq)); | 210 | (2 * data->pwm1_freq)); |
211 | } | 211 | } |
212 | 212 | ||
213 | static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 213 | static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy, |
214 | const char *buf, size_t count) | ||
214 | { | 215 | { |
215 | struct i2c_client *client = to_i2c_client(dev); | 216 | struct i2c_client *client = to_i2c_client(dev); |
216 | struct lm63_data *data = i2c_get_clientdata(client); | 217 | struct lm63_data *data = i2c_get_clientdata(client); |
@@ -229,77 +230,83 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const | |||
229 | return count; | 230 | return count; |
230 | } | 231 | } |
231 | 232 | ||
232 | static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *attr, char *buf) | 233 | static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *dummy, |
234 | char *buf) | ||
233 | { | 235 | { |
234 | struct lm63_data *data = lm63_update_device(dev); | 236 | struct lm63_data *data = lm63_update_device(dev); |
235 | return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); | 237 | return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); |
236 | } | 238 | } |
237 | 239 | ||
238 | #define show_temp8(value) \ | 240 | static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, |
239 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | 241 | char *buf) |
240 | { \ | 242 | { |
241 | struct lm63_data *data = lm63_update_device(dev); \ | 243 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
242 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->value)); \ | 244 | struct lm63_data *data = lm63_update_device(dev); |
245 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index])); | ||
243 | } | 246 | } |
244 | #define show_temp11(value) \ | 247 | |
245 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | 248 | static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy, |
246 | { \ | 249 | const char *buf, size_t count) |
247 | struct lm63_data *data = lm63_update_device(dev); \ | 250 | { |
248 | return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->value)); \ | 251 | struct i2c_client *client = to_i2c_client(dev); |
252 | struct lm63_data *data = i2c_get_clientdata(client); | ||
253 | long val = simple_strtol(buf, NULL, 10); | ||
254 | |||
255 | down(&data->update_lock); | ||
256 | data->temp8[1] = TEMP8_TO_REG(val); | ||
257 | i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); | ||
258 | up(&data->update_lock); | ||
259 | return count; | ||
249 | } | 260 | } |
250 | show_temp8(temp1_input); | 261 | |
251 | show_temp8(temp1_high); | 262 | static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr, |
252 | show_temp11(temp2_input); | 263 | char *buf) |
253 | show_temp11(temp2_high); | 264 | { |
254 | show_temp11(temp2_low); | 265 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
255 | show_temp8(temp2_crit); | 266 | struct lm63_data *data = lm63_update_device(dev); |
256 | 267 | return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->temp11[attr->index])); | |
257 | #define set_temp8(value, reg) \ | ||
258 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ | ||
259 | size_t count) \ | ||
260 | { \ | ||
261 | struct i2c_client *client = to_i2c_client(dev); \ | ||
262 | struct lm63_data *data = i2c_get_clientdata(client); \ | ||
263 | long val = simple_strtol(buf, NULL, 10); \ | ||
264 | \ | ||
265 | down(&data->update_lock); \ | ||
266 | data->value = TEMP8_TO_REG(val); \ | ||
267 | i2c_smbus_write_byte_data(client, reg, data->value); \ | ||
268 | up(&data->update_lock); \ | ||
269 | return count; \ | ||
270 | } | 268 | } |
271 | #define set_temp11(value, reg_msb, reg_lsb) \ | 269 | |
272 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ | 270 | static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, |
273 | size_t count) \ | 271 | const char *buf, size_t count) |
274 | { \ | 272 | { |
275 | struct i2c_client *client = to_i2c_client(dev); \ | 273 | static const u8 reg[4] = { |
276 | struct lm63_data *data = i2c_get_clientdata(client); \ | 274 | LM63_REG_REMOTE_LOW_MSB, |
277 | long val = simple_strtol(buf, NULL, 10); \ | 275 | LM63_REG_REMOTE_LOW_LSB, |
278 | \ | 276 | LM63_REG_REMOTE_HIGH_MSB, |
279 | down(&data->update_lock); \ | 277 | LM63_REG_REMOTE_HIGH_LSB, |
280 | data->value = TEMP11_TO_REG(val); \ | 278 | }; |
281 | i2c_smbus_write_byte_data(client, reg_msb, data->value >> 8); \ | 279 | |
282 | i2c_smbus_write_byte_data(client, reg_lsb, data->value & 0xff); \ | 280 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
283 | up(&data->update_lock); \ | 281 | struct i2c_client *client = to_i2c_client(dev); |
284 | return count; \ | 282 | struct lm63_data *data = i2c_get_clientdata(client); |
283 | long val = simple_strtol(buf, NULL, 10); | ||
284 | int nr = attr->index; | ||
285 | |||
286 | down(&data->update_lock); | ||
287 | data->temp11[nr] = TEMP11_TO_REG(val); | ||
288 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], | ||
289 | data->temp11[nr] >> 8); | ||
290 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | ||
291 | data->temp11[nr] & 0xff); | ||
292 | up(&data->update_lock); | ||
293 | return count; | ||
285 | } | 294 | } |
286 | set_temp8(temp1_high, LM63_REG_LOCAL_HIGH); | ||
287 | set_temp11(temp2_high, LM63_REG_REMOTE_HIGH_MSB, LM63_REG_REMOTE_HIGH_LSB); | ||
288 | set_temp11(temp2_low, LM63_REG_REMOTE_LOW_MSB, LM63_REG_REMOTE_LOW_LSB); | ||
289 | 295 | ||
290 | /* Hysteresis register holds a relative value, while we want to present | 296 | /* Hysteresis register holds a relative value, while we want to present |
291 | an absolute to user-space */ | 297 | an absolute to user-space */ |
292 | static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf) | 298 | static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy, |
299 | char *buf) | ||
293 | { | 300 | { |
294 | struct lm63_data *data = lm63_update_device(dev); | 301 | struct lm63_data *data = lm63_update_device(dev); |
295 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp2_crit) | 302 | return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[2]) |
296 | - TEMP8_FROM_REG(data->temp2_crit_hyst)); | 303 | - TEMP8_FROM_REG(data->temp2_crit_hyst)); |
297 | } | 304 | } |
298 | 305 | ||
299 | /* And now the other way around, user-space provides an absolute | 306 | /* And now the other way around, user-space provides an absolute |
300 | hysteresis value and we have to store a relative one */ | 307 | hysteresis value and we have to store a relative one */ |
301 | static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf, | 308 | static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy, |
302 | size_t count) | 309 | const char *buf, size_t count) |
303 | { | 310 | { |
304 | struct i2c_client *client = to_i2c_client(dev); | 311 | struct i2c_client *client = to_i2c_client(dev); |
305 | struct lm63_data *data = i2c_get_clientdata(client); | 312 | struct lm63_data *data = i2c_get_clientdata(client); |
@@ -307,36 +314,37 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute * | |||
307 | long hyst; | 314 | long hyst; |
308 | 315 | ||
309 | down(&data->update_lock); | 316 | down(&data->update_lock); |
310 | hyst = TEMP8_FROM_REG(data->temp2_crit) - val; | 317 | hyst = TEMP8_FROM_REG(data->temp8[2]) - val; |
311 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, | 318 | i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, |
312 | HYST_TO_REG(hyst)); | 319 | HYST_TO_REG(hyst)); |
313 | up(&data->update_lock); | 320 | up(&data->update_lock); |
314 | return count; | 321 | return count; |
315 | } | 322 | } |
316 | 323 | ||
317 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 324 | static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, |
325 | char *buf) | ||
318 | { | 326 | { |
319 | struct lm63_data *data = lm63_update_device(dev); | 327 | struct lm63_data *data = lm63_update_device(dev); |
320 | return sprintf(buf, "%u\n", data->alarms); | 328 | return sprintf(buf, "%u\n", data->alarms); |
321 | } | 329 | } |
322 | 330 | ||
323 | static DEVICE_ATTR(fan1_input, S_IRUGO, show_fan1_input, NULL); | 331 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); |
324 | static DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan1_low, | 332 | static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan, |
325 | set_fan1_low); | 333 | set_fan, 1); |
326 | 334 | ||
327 | static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); | 335 | static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); |
328 | static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); | 336 | static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); |
329 | 337 | ||
330 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL); | 338 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); |
331 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp1_high, | 339 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, |
332 | set_temp1_high); | 340 | set_temp8, 1); |
333 | 341 | ||
334 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp2_input, NULL); | 342 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); |
335 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp2_low, | 343 | static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, |
336 | set_temp2_low); | 344 | set_temp11, 1); |
337 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp2_high, | 345 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, |
338 | set_temp2_high); | 346 | set_temp11, 2); |
339 | static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp2_crit, NULL); | 347 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp8, NULL, 2); |
340 | static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, | 348 | static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, |
341 | set_temp2_crit_hyst); | 349 | set_temp2_crit_hyst); |
342 | 350 | ||
@@ -430,17 +438,25 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
430 | 438 | ||
431 | /* Register sysfs hooks */ | 439 | /* Register sysfs hooks */ |
432 | if (data->config & 0x04) { /* tachometer enabled */ | 440 | if (data->config & 0x04) { /* tachometer enabled */ |
433 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 441 | device_create_file(&new_client->dev, |
434 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 442 | &sensor_dev_attr_fan1_input.dev_attr); |
443 | device_create_file(&new_client->dev, | ||
444 | &sensor_dev_attr_fan1_min.dev_attr); | ||
435 | } | 445 | } |
436 | device_create_file(&new_client->dev, &dev_attr_pwm1); | 446 | device_create_file(&new_client->dev, &dev_attr_pwm1); |
437 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); | 447 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); |
438 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 448 | device_create_file(&new_client->dev, |
439 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 449 | &sensor_dev_attr_temp1_input.dev_attr); |
440 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 450 | device_create_file(&new_client->dev, |
441 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 451 | &sensor_dev_attr_temp2_input.dev_attr); |
442 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 452 | device_create_file(&new_client->dev, |
443 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | 453 | &sensor_dev_attr_temp2_min.dev_attr); |
454 | device_create_file(&new_client->dev, | ||
455 | &sensor_dev_attr_temp1_max.dev_attr); | ||
456 | device_create_file(&new_client->dev, | ||
457 | &sensor_dev_attr_temp2_max.dev_attr); | ||
458 | device_create_file(&new_client->dev, | ||
459 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
444 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); | 460 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); |
445 | device_create_file(&new_client->dev, &dev_attr_alarms); | 461 | device_create_file(&new_client->dev, &dev_attr_alarms); |
446 | 462 | ||
@@ -511,14 +527,14 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
511 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { | 527 | if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
512 | if (data->config & 0x04) { /* tachometer enabled */ | 528 | if (data->config & 0x04) { /* tachometer enabled */ |
513 | /* order matters for fan1_input */ | 529 | /* order matters for fan1_input */ |
514 | data->fan1_input = i2c_smbus_read_byte_data(client, | 530 | data->fan[0] = i2c_smbus_read_byte_data(client, |
515 | LM63_REG_TACH_COUNT_LSB) & 0xFC; | 531 | LM63_REG_TACH_COUNT_LSB) & 0xFC; |
516 | data->fan1_input |= i2c_smbus_read_byte_data(client, | 532 | data->fan[0] |= i2c_smbus_read_byte_data(client, |
517 | LM63_REG_TACH_COUNT_MSB) << 8; | 533 | LM63_REG_TACH_COUNT_MSB) << 8; |
518 | data->fan1_low = (i2c_smbus_read_byte_data(client, | 534 | data->fan[1] = (i2c_smbus_read_byte_data(client, |
519 | LM63_REG_TACH_LIMIT_LSB) & 0xFC) | 535 | LM63_REG_TACH_LIMIT_LSB) & 0xFC) |
520 | | (i2c_smbus_read_byte_data(client, | 536 | | (i2c_smbus_read_byte_data(client, |
521 | LM63_REG_TACH_LIMIT_MSB) << 8); | 537 | LM63_REG_TACH_LIMIT_MSB) << 8); |
522 | } | 538 | } |
523 | 539 | ||
524 | data->pwm1_freq = i2c_smbus_read_byte_data(client, | 540 | data->pwm1_freq = i2c_smbus_read_byte_data(client, |
@@ -528,26 +544,26 @@ static struct lm63_data *lm63_update_device(struct device *dev) | |||
528 | data->pwm1_value = i2c_smbus_read_byte_data(client, | 544 | data->pwm1_value = i2c_smbus_read_byte_data(client, |
529 | LM63_REG_PWM_VALUE); | 545 | LM63_REG_PWM_VALUE); |
530 | 546 | ||
531 | data->temp1_input = i2c_smbus_read_byte_data(client, | 547 | data->temp8[0] = i2c_smbus_read_byte_data(client, |
532 | LM63_REG_LOCAL_TEMP); | 548 | LM63_REG_LOCAL_TEMP); |
533 | data->temp1_high = i2c_smbus_read_byte_data(client, | 549 | data->temp8[1] = i2c_smbus_read_byte_data(client, |
534 | LM63_REG_LOCAL_HIGH); | 550 | LM63_REG_LOCAL_HIGH); |
535 | 551 | ||
536 | /* order matters for temp2_input */ | 552 | /* order matters for temp2_input */ |
537 | data->temp2_input = i2c_smbus_read_byte_data(client, | 553 | data->temp11[0] = i2c_smbus_read_byte_data(client, |
538 | LM63_REG_REMOTE_TEMP_MSB) << 8; | 554 | LM63_REG_REMOTE_TEMP_MSB) << 8; |
539 | data->temp2_input |= i2c_smbus_read_byte_data(client, | 555 | data->temp11[0] |= i2c_smbus_read_byte_data(client, |
540 | LM63_REG_REMOTE_TEMP_LSB); | 556 | LM63_REG_REMOTE_TEMP_LSB); |
541 | data->temp2_high = (i2c_smbus_read_byte_data(client, | 557 | data->temp11[1] = (i2c_smbus_read_byte_data(client, |
542 | LM63_REG_REMOTE_HIGH_MSB) << 8) | ||
543 | | i2c_smbus_read_byte_data(client, | ||
544 | LM63_REG_REMOTE_HIGH_LSB); | ||
545 | data->temp2_low = (i2c_smbus_read_byte_data(client, | ||
546 | LM63_REG_REMOTE_LOW_MSB) << 8) | 558 | LM63_REG_REMOTE_LOW_MSB) << 8) |
547 | | i2c_smbus_read_byte_data(client, | 559 | | i2c_smbus_read_byte_data(client, |
548 | LM63_REG_REMOTE_LOW_LSB); | 560 | LM63_REG_REMOTE_LOW_LSB); |
549 | data->temp2_crit = i2c_smbus_read_byte_data(client, | 561 | data->temp11[2] = (i2c_smbus_read_byte_data(client, |
550 | LM63_REG_REMOTE_TCRIT); | 562 | LM63_REG_REMOTE_HIGH_MSB) << 8) |
563 | | i2c_smbus_read_byte_data(client, | ||
564 | LM63_REG_REMOTE_HIGH_LSB); | ||
565 | data->temp8[2] = i2c_smbus_read_byte_data(client, | ||
566 | LM63_REG_REMOTE_TCRIT); | ||
551 | data->temp2_crit_hyst = i2c_smbus_read_byte_data(client, | 567 | data->temp2_crit_hyst = i2c_smbus_read_byte_data(client, |
552 | LM63_REG_REMOTE_TCRIT_HYST); | 568 | LM63_REG_REMOTE_TCRIT_HYST); |
553 | 569 | ||
diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c index 57c51ac37c04..5be164ed278e 100644 --- a/drivers/i2c/chips/lm75.c +++ b/drivers/i2c/chips/lm75.c | |||
@@ -18,7 +18,6 @@ | |||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/config.h> | ||
22 | #include <linux/module.h> | 21 | #include <linux/module.h> |
23 | #include <linux/init.h> | 22 | #include <linux/init.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/lm77.c b/drivers/i2c/chips/lm77.c index 9d15cd5189f6..b98f44952997 100644 --- a/drivers/i2c/chips/lm77.c +++ b/drivers/i2c/chips/lm77.c | |||
@@ -25,7 +25,6 @@ | |||
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <linux/config.h> | ||
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
30 | #include <linux/init.h> | 29 | #include <linux/init.h> |
31 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/lm78.c b/drivers/i2c/chips/lm78.c index 21b195ff3871..29241469dcba 100644 --- a/drivers/i2c/chips/lm78.c +++ b/drivers/i2c/chips/lm78.c | |||
@@ -18,7 +18,6 @@ | |||
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/config.h> | ||
22 | #include <linux/module.h> | 21 | #include <linux/module.h> |
23 | #include <linux/init.h> | 22 | #include <linux/init.h> |
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
@@ -671,7 +670,7 @@ static int lm78_detach_client(struct i2c_client *client) | |||
671 | return 0; | 670 | return 0; |
672 | } | 671 | } |
673 | 672 | ||
674 | /* The SMBus locks itself, but ISA access must be locked explicitely! | 673 | /* The SMBus locks itself, but ISA access must be locked explicitly! |
675 | We don't want to lock the whole ISA bus, so we lock each client | 674 | We don't want to lock the whole ISA bus, so we lock each client |
676 | separately. | 675 | separately. |
677 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, | 676 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, |
@@ -690,7 +689,7 @@ static int lm78_read_value(struct i2c_client *client, u8 reg) | |||
690 | return i2c_smbus_read_byte_data(client, reg); | 689 | return i2c_smbus_read_byte_data(client, reg); |
691 | } | 690 | } |
692 | 691 | ||
693 | /* The SMBus locks itself, but ISA access muse be locked explicitely! | 692 | /* The SMBus locks itself, but ISA access muse be locked explicitly! |
694 | We don't want to lock the whole ISA bus, so we lock each client | 693 | We don't want to lock the whole ISA bus, so we lock each client |
695 | separately. | 694 | separately. |
696 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, | 695 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, |
diff --git a/drivers/i2c/chips/lm80.c b/drivers/i2c/chips/lm80.c index 404057b70e90..8100595feb44 100644 --- a/drivers/i2c/chips/lm80.c +++ b/drivers/i2c/chips/lm80.c | |||
@@ -21,7 +21,6 @@ | |||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | #include <linux/init.h> | 25 | #include <linux/init.h> |
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c index 4d6d7d21e14b..a49008b444c8 100644 --- a/drivers/i2c/chips/lm83.c +++ b/drivers/i2c/chips/lm83.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm83.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * lm83.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | * monitoring | 3 | * monitoring |
4 | * Copyright (C) 2003 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2003-2005 Jean Delvare <khali@linux-fr.org> |
5 | * | 5 | * |
6 | * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is | 6 | * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is |
7 | * a sensor chip made by National Semiconductor. It reports up to four | 7 | * a sensor chip made by National Semiconductor. It reports up to four |
@@ -27,13 +27,13 @@ | |||
27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/config.h> | ||
31 | #include <linux/module.h> | 30 | #include <linux/module.h> |
32 | #include <linux/init.h> | 31 | #include <linux/init.h> |
33 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
34 | #include <linux/jiffies.h> | 33 | #include <linux/jiffies.h> |
35 | #include <linux/i2c.h> | 34 | #include <linux/i2c.h> |
36 | #include <linux/i2c-sensor.h> | 35 | #include <linux/i2c-sensor.h> |
36 | #include <linux/hwmon-sysfs.h> | ||
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Addresses to scan | 39 | * Addresses to scan |
@@ -81,7 +81,7 @@ SENSORS_INSMOD_1(lm83); | |||
81 | 81 | ||
82 | /* | 82 | /* |
83 | * Conversions and various macros | 83 | * Conversions and various macros |
84 | * The LM83 uses signed 8-bit values with LSB = 1 degree Celcius. | 84 | * The LM83 uses signed 8-bit values with LSB = 1 degree Celsius. |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #define TEMP_FROM_REG(val) ((val) * 1000) | 87 | #define TEMP_FROM_REG(val) ((val) * 1000) |
@@ -94,21 +94,20 @@ static const u8 LM83_REG_R_TEMP[] = { | |||
94 | LM83_REG_R_LOCAL_TEMP, | 94 | LM83_REG_R_LOCAL_TEMP, |
95 | LM83_REG_R_REMOTE1_TEMP, | 95 | LM83_REG_R_REMOTE1_TEMP, |
96 | LM83_REG_R_REMOTE2_TEMP, | 96 | LM83_REG_R_REMOTE2_TEMP, |
97 | LM83_REG_R_REMOTE3_TEMP | 97 | LM83_REG_R_REMOTE3_TEMP, |
98 | }; | ||
99 | |||
100 | static const u8 LM83_REG_R_HIGH[] = { | ||
101 | LM83_REG_R_LOCAL_HIGH, | 98 | LM83_REG_R_LOCAL_HIGH, |
102 | LM83_REG_R_REMOTE1_HIGH, | 99 | LM83_REG_R_REMOTE1_HIGH, |
103 | LM83_REG_R_REMOTE2_HIGH, | 100 | LM83_REG_R_REMOTE2_HIGH, |
104 | LM83_REG_R_REMOTE3_HIGH | 101 | LM83_REG_R_REMOTE3_HIGH, |
102 | LM83_REG_R_TCRIT, | ||
105 | }; | 103 | }; |
106 | 104 | ||
107 | static const u8 LM83_REG_W_HIGH[] = { | 105 | static const u8 LM83_REG_W_HIGH[] = { |
108 | LM83_REG_W_LOCAL_HIGH, | 106 | LM83_REG_W_LOCAL_HIGH, |
109 | LM83_REG_W_REMOTE1_HIGH, | 107 | LM83_REG_W_REMOTE1_HIGH, |
110 | LM83_REG_W_REMOTE2_HIGH, | 108 | LM83_REG_W_REMOTE2_HIGH, |
111 | LM83_REG_W_REMOTE3_HIGH | 109 | LM83_REG_W_REMOTE3_HIGH, |
110 | LM83_REG_W_TCRIT, | ||
112 | }; | 111 | }; |
113 | 112 | ||
114 | /* | 113 | /* |
@@ -144,9 +143,9 @@ struct lm83_data { | |||
144 | unsigned long last_updated; /* in jiffies */ | 143 | unsigned long last_updated; /* in jiffies */ |
145 | 144 | ||
146 | /* registers values */ | 145 | /* registers values */ |
147 | s8 temp_input[4]; | 146 | s8 temp[9]; /* 0..3: input 1-4, |
148 | s8 temp_high[4]; | 147 | 4..7: high limit 1-4, |
149 | s8 temp_crit; | 148 | 8 : critical limit */ |
150 | u16 alarms; /* bitvector, combined */ | 149 | u16 alarms; /* bitvector, combined */ |
151 | }; | 150 | }; |
152 | 151 | ||
@@ -154,65 +153,55 @@ struct lm83_data { | |||
154 | * Sysfs stuff | 153 | * Sysfs stuff |
155 | */ | 154 | */ |
156 | 155 | ||
157 | #define show_temp(suffix, value) \ | 156 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
158 | static ssize_t show_temp_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ | 157 | char *buf) |
159 | { \ | 158 | { |
160 | struct lm83_data *data = lm83_update_device(dev); \ | 159 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
161 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ | 160 | struct lm83_data *data = lm83_update_device(dev); |
161 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); | ||
162 | } | 162 | } |
163 | show_temp(input1, temp_input[0]); | 163 | |
164 | show_temp(input2, temp_input[1]); | 164 | static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, |
165 | show_temp(input3, temp_input[2]); | 165 | const char *buf, size_t count) |
166 | show_temp(input4, temp_input[3]); | 166 | { |
167 | show_temp(high1, temp_high[0]); | 167 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
168 | show_temp(high2, temp_high[1]); | 168 | struct i2c_client *client = to_i2c_client(dev); |
169 | show_temp(high3, temp_high[2]); | 169 | struct lm83_data *data = i2c_get_clientdata(client); |
170 | show_temp(high4, temp_high[3]); | 170 | long val = simple_strtol(buf, NULL, 10); |
171 | show_temp(crit, temp_crit); | 171 | int nr = attr->index; |
172 | 172 | ||
173 | #define set_temp(suffix, value, reg) \ | 173 | down(&data->update_lock); |
174 | static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ | 174 | data->temp[nr] = TEMP_TO_REG(val); |
175 | size_t count) \ | 175 | i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], |
176 | { \ | 176 | data->temp[nr]); |
177 | struct i2c_client *client = to_i2c_client(dev); \ | 177 | up(&data->update_lock); |
178 | struct lm83_data *data = i2c_get_clientdata(client); \ | 178 | return count; |
179 | long val = simple_strtol(buf, NULL, 10); \ | ||
180 | \ | ||
181 | down(&data->update_lock); \ | ||
182 | data->value = TEMP_TO_REG(val); \ | ||
183 | i2c_smbus_write_byte_data(client, reg, data->value); \ | ||
184 | up(&data->update_lock); \ | ||
185 | return count; \ | ||
186 | } | 179 | } |
187 | set_temp(high1, temp_high[0], LM83_REG_W_LOCAL_HIGH); | ||
188 | set_temp(high2, temp_high[1], LM83_REG_W_REMOTE1_HIGH); | ||
189 | set_temp(high3, temp_high[2], LM83_REG_W_REMOTE2_HIGH); | ||
190 | set_temp(high4, temp_high[3], LM83_REG_W_REMOTE3_HIGH); | ||
191 | set_temp(crit, temp_crit, LM83_REG_W_TCRIT); | ||
192 | 180 | ||
193 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 181 | static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, |
182 | char *buf) | ||
194 | { | 183 | { |
195 | struct lm83_data *data = lm83_update_device(dev); | 184 | struct lm83_data *data = lm83_update_device(dev); |
196 | return sprintf(buf, "%d\n", data->alarms); | 185 | return sprintf(buf, "%d\n", data->alarms); |
197 | } | 186 | } |
198 | 187 | ||
199 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); | 188 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
200 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); | 189 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); |
201 | static DEVICE_ATTR(temp3_input, S_IRUGO, show_temp_input3, NULL); | 190 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); |
202 | static DEVICE_ATTR(temp4_input, S_IRUGO, show_temp_input4, NULL); | 191 | static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); |
203 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, | 192 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, |
204 | set_temp_high1); | 193 | set_temp, 4); |
205 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, | 194 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp, |
206 | set_temp_high2); | 195 | set_temp, 5); |
207 | static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_high3, | 196 | static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp, |
208 | set_temp_high3); | 197 | set_temp, 6); |
209 | static DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp_high4, | 198 | static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp, |
210 | set_temp_high4); | 199 | set_temp, 7); |
211 | static DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit, NULL); | 200 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, 8); |
212 | static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit, NULL); | 201 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp, NULL, 8); |
213 | static DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp_crit, | 202 | static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp, |
214 | set_temp_crit); | 203 | set_temp, 8); |
215 | static DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp_crit, NULL); | 204 | static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8); |
216 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 205 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
217 | 206 | ||
218 | /* | 207 | /* |
@@ -323,18 +312,30 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind) | |||
323 | */ | 312 | */ |
324 | 313 | ||
325 | /* Register sysfs hooks */ | 314 | /* Register sysfs hooks */ |
326 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 315 | device_create_file(&new_client->dev, |
327 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 316 | &sensor_dev_attr_temp1_input.dev_attr); |
328 | device_create_file(&new_client->dev, &dev_attr_temp3_input); | 317 | device_create_file(&new_client->dev, |
329 | device_create_file(&new_client->dev, &dev_attr_temp4_input); | 318 | &sensor_dev_attr_temp2_input.dev_attr); |
330 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 319 | device_create_file(&new_client->dev, |
331 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 320 | &sensor_dev_attr_temp3_input.dev_attr); |
332 | device_create_file(&new_client->dev, &dev_attr_temp3_max); | 321 | device_create_file(&new_client->dev, |
333 | device_create_file(&new_client->dev, &dev_attr_temp4_max); | 322 | &sensor_dev_attr_temp4_input.dev_attr); |
334 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); | 323 | device_create_file(&new_client->dev, |
335 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | 324 | &sensor_dev_attr_temp1_max.dev_attr); |
336 | device_create_file(&new_client->dev, &dev_attr_temp3_crit); | 325 | device_create_file(&new_client->dev, |
337 | device_create_file(&new_client->dev, &dev_attr_temp4_crit); | 326 | &sensor_dev_attr_temp2_max.dev_attr); |
327 | device_create_file(&new_client->dev, | ||
328 | &sensor_dev_attr_temp3_max.dev_attr); | ||
329 | device_create_file(&new_client->dev, | ||
330 | &sensor_dev_attr_temp4_max.dev_attr); | ||
331 | device_create_file(&new_client->dev, | ||
332 | &sensor_dev_attr_temp1_crit.dev_attr); | ||
333 | device_create_file(&new_client->dev, | ||
334 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
335 | device_create_file(&new_client->dev, | ||
336 | &sensor_dev_attr_temp3_crit.dev_attr); | ||
337 | device_create_file(&new_client->dev, | ||
338 | &sensor_dev_attr_temp4_crit.dev_attr); | ||
338 | device_create_file(&new_client->dev, &dev_attr_alarms); | 339 | device_create_file(&new_client->dev, &dev_attr_alarms); |
339 | 340 | ||
340 | return 0; | 341 | return 0; |
@@ -370,16 +371,11 @@ static struct lm83_data *lm83_update_device(struct device *dev) | |||
370 | int nr; | 371 | int nr; |
371 | 372 | ||
372 | dev_dbg(&client->dev, "Updating lm83 data.\n"); | 373 | dev_dbg(&client->dev, "Updating lm83 data.\n"); |
373 | for (nr = 0; nr < 4 ; nr++) { | 374 | for (nr = 0; nr < 9; nr++) { |
374 | data->temp_input[nr] = | 375 | data->temp[nr] = |
375 | i2c_smbus_read_byte_data(client, | 376 | i2c_smbus_read_byte_data(client, |
376 | LM83_REG_R_TEMP[nr]); | 377 | LM83_REG_R_TEMP[nr]); |
377 | data->temp_high[nr] = | ||
378 | i2c_smbus_read_byte_data(client, | ||
379 | LM83_REG_R_HIGH[nr]); | ||
380 | } | 378 | } |
381 | data->temp_crit = | ||
382 | i2c_smbus_read_byte_data(client, LM83_REG_R_TCRIT); | ||
383 | data->alarms = | 379 | data->alarms = |
384 | i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1) | 380 | i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1) |
385 | + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2) | 381 | + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2) |
diff --git a/drivers/i2c/chips/lm85.c b/drivers/i2c/chips/lm85.c index b1976775b4ba..b4d7fd418264 100644 --- a/drivers/i2c/chips/lm85.c +++ b/drivers/i2c/chips/lm85.c | |||
@@ -23,7 +23,6 @@ | |||
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/config.h> | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
@@ -285,8 +284,6 @@ static int ZONE_TO_REG( int zone ) | |||
285 | /* i2c-vid.h defines vid_from_reg() */ | 284 | /* i2c-vid.h defines vid_from_reg() */ |
286 | #define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) | 285 | #define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) |
287 | 286 | ||
288 | #define ALARMS_FROM_REG(val) (val) | ||
289 | |||
290 | /* Unlike some other drivers we DO NOT set initial limits. Use | 287 | /* Unlike some other drivers we DO NOT set initial limits. Use |
291 | * the config file to set limits. Some users have reported | 288 | * the config file to set limits. Some users have reported |
292 | * motherboards shutting down when we set limits in a previous | 289 | * motherboards shutting down when we set limits in a previous |
@@ -481,7 +478,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); | |||
481 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | 478 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) |
482 | { | 479 | { |
483 | struct lm85_data *data = lm85_update_device(dev); | 480 | struct lm85_data *data = lm85_update_device(dev); |
484 | return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); | 481 | return sprintf(buf, "%u\n", data->alarms); |
485 | } | 482 | } |
486 | 483 | ||
487 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | 484 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); |
diff --git a/drivers/i2c/chips/lm87.c b/drivers/i2c/chips/lm87.c index 4372b61a0882..1921ed1af182 100644 --- a/drivers/i2c/chips/lm87.c +++ b/drivers/i2c/chips/lm87.c | |||
@@ -52,7 +52,6 @@ | |||
52 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 52 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
53 | */ | 53 | */ |
54 | 54 | ||
55 | #include <linux/config.h> | ||
56 | #include <linux/module.h> | 55 | #include <linux/module.h> |
57 | #include <linux/init.h> | 56 | #include <linux/init.h> |
58 | #include <linux/slab.h> | 57 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/lm90.c b/drivers/i2c/chips/lm90.c index 9b127a07f56b..a67dcadf7cb0 100644 --- a/drivers/i2c/chips/lm90.c +++ b/drivers/i2c/chips/lm90.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm90.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | * lm90.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | * monitoring | 3 | * monitoring |
4 | * Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2003-2005 Jean Delvare <khali@linux-fr.org> |
5 | * | 5 | * |
6 | * Based on the lm83 driver. The LM90 is a sensor chip made by National | 6 | * Based on the lm83 driver. The LM90 is a sensor chip made by National |
7 | * Semiconductor. It reports up to two temperatures (its own plus up to | 7 | * Semiconductor. It reports up to two temperatures (its own plus up to |
@@ -19,7 +19,7 @@ | |||
19 | * Complete datasheets can be obtained from National's website at: | 19 | * Complete datasheets can be obtained from National's website at: |
20 | * http://www.national.com/pf/LM/LM89.html | 20 | * http://www.national.com/pf/LM/LM89.html |
21 | * http://www.national.com/pf/LM/LM99.html | 21 | * http://www.national.com/pf/LM/LM99.html |
22 | * Note that there is no way to differenciate between both chips. | 22 | * Note that there is no way to differentiate between both chips. |
23 | * | 23 | * |
24 | * This driver also supports the LM86, another sensor chip made by | 24 | * This driver also supports the LM86, another sensor chip made by |
25 | * National Semiconductor. It is exactly similar to the LM90 except it | 25 | * National Semiconductor. It is exactly similar to the LM90 except it |
@@ -39,7 +39,7 @@ | |||
39 | * chips made by Maxim. These chips are similar to the LM86. Complete | 39 | * chips made by Maxim. These chips are similar to the LM86. Complete |
40 | * datasheet can be obtained at Maxim's website at: | 40 | * datasheet can be obtained at Maxim's website at: |
41 | * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 | 41 | * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 |
42 | * Note that there is no easy way to differenciate between the three | 42 | * Note that there is no easy way to differentiate between the three |
43 | * variants. The extra address and features of the MAX6659 are not | 43 | * variants. The extra address and features of the MAX6659 are not |
44 | * supported by this driver. | 44 | * supported by this driver. |
45 | * | 45 | * |
@@ -70,13 +70,13 @@ | |||
70 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 70 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
71 | */ | 71 | */ |
72 | 72 | ||
73 | #include <linux/config.h> | ||
74 | #include <linux/module.h> | 73 | #include <linux/module.h> |
75 | #include <linux/init.h> | 74 | #include <linux/init.h> |
76 | #include <linux/slab.h> | 75 | #include <linux/slab.h> |
77 | #include <linux/jiffies.h> | 76 | #include <linux/jiffies.h> |
78 | #include <linux/i2c.h> | 77 | #include <linux/i2c.h> |
79 | #include <linux/i2c-sensor.h> | 78 | #include <linux/i2c-sensor.h> |
79 | #include <linux/hwmon-sysfs.h> | ||
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Addresses to scan | 82 | * Addresses to scan |
@@ -139,9 +139,9 @@ SENSORS_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461); | |||
139 | /* | 139 | /* |
140 | * Conversions and various macros | 140 | * Conversions and various macros |
141 | * For local temperatures and limits, critical limits and the hysteresis | 141 | * For local temperatures and limits, critical limits and the hysteresis |
142 | * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celcius. | 142 | * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celsius. |
143 | * For remote temperatures and limits, it uses signed 11-bit values with | 143 | * For remote temperatures and limits, it uses signed 11-bit values with |
144 | * LSB = 0.125 degree Celcius, left-justified in 16-bit registers. | 144 | * LSB = 0.125 degree Celsius, left-justified in 16-bit registers. |
145 | */ | 145 | */ |
146 | 146 | ||
147 | #define TEMP1_FROM_REG(val) ((val) * 1000) | 147 | #define TEMP1_FROM_REG(val) ((val) * 1000) |
@@ -206,9 +206,14 @@ struct lm90_data { | |||
206 | int kind; | 206 | int kind; |
207 | 207 | ||
208 | /* registers values */ | 208 | /* registers values */ |
209 | s8 temp_input1, temp_low1, temp_high1; /* local */ | 209 | s8 temp8[5]; /* 0: local input |
210 | s16 temp_input2, temp_low2, temp_high2; /* remote, combined */ | 210 | 1: local low limit |
211 | s8 temp_crit1, temp_crit2; | 211 | 2: local high limit |
212 | 3: local critical limit | ||
213 | 4: remote critical limit */ | ||
214 | s16 temp11[3]; /* 0: remote input | ||
215 | 1: remote low limit | ||
216 | 2: remote high limit */ | ||
212 | u8 temp_hyst; | 217 | u8 temp_hyst; |
213 | u8 alarms; /* bitvector */ | 218 | u8 alarms; /* bitvector */ |
214 | }; | 219 | }; |
@@ -217,75 +222,88 @@ struct lm90_data { | |||
217 | * Sysfs stuff | 222 | * Sysfs stuff |
218 | */ | 223 | */ |
219 | 224 | ||
220 | #define show_temp(value, converter) \ | 225 | static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, |
221 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | 226 | char *buf) |
222 | { \ | 227 | { |
223 | struct lm90_data *data = lm90_update_device(dev); \ | 228 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
224 | return sprintf(buf, "%d\n", converter(data->value)); \ | 229 | struct lm90_data *data = lm90_update_device(dev); |
230 | return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index])); | ||
231 | } | ||
232 | |||
233 | static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, | ||
234 | const char *buf, size_t count) | ||
235 | { | ||
236 | static const u8 reg[4] = { | ||
237 | LM90_REG_W_LOCAL_LOW, | ||
238 | LM90_REG_W_LOCAL_HIGH, | ||
239 | LM90_REG_W_LOCAL_CRIT, | ||
240 | LM90_REG_W_REMOTE_CRIT, | ||
241 | }; | ||
242 | |||
243 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
244 | struct i2c_client *client = to_i2c_client(dev); | ||
245 | struct lm90_data *data = i2c_get_clientdata(client); | ||
246 | long val = simple_strtol(buf, NULL, 10); | ||
247 | int nr = attr->index; | ||
248 | |||
249 | down(&data->update_lock); | ||
250 | if (data->kind == adt7461) | ||
251 | data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); | ||
252 | else | ||
253 | data->temp8[nr] = TEMP1_TO_REG(val); | ||
254 | i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); | ||
255 | up(&data->update_lock); | ||
256 | return count; | ||
225 | } | 257 | } |
226 | show_temp(temp_input1, TEMP1_FROM_REG); | 258 | |
227 | show_temp(temp_input2, TEMP2_FROM_REG); | 259 | static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr, |
228 | show_temp(temp_low1, TEMP1_FROM_REG); | 260 | char *buf) |
229 | show_temp(temp_low2, TEMP2_FROM_REG); | 261 | { |
230 | show_temp(temp_high1, TEMP1_FROM_REG); | 262 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
231 | show_temp(temp_high2, TEMP2_FROM_REG); | 263 | struct lm90_data *data = lm90_update_device(dev); |
232 | show_temp(temp_crit1, TEMP1_FROM_REG); | 264 | return sprintf(buf, "%d\n", TEMP2_FROM_REG(data->temp11[attr->index])); |
233 | show_temp(temp_crit2, TEMP1_FROM_REG); | ||
234 | |||
235 | #define set_temp1(value, reg) \ | ||
236 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ | ||
237 | size_t count) \ | ||
238 | { \ | ||
239 | struct i2c_client *client = to_i2c_client(dev); \ | ||
240 | struct lm90_data *data = i2c_get_clientdata(client); \ | ||
241 | long val = simple_strtol(buf, NULL, 10); \ | ||
242 | \ | ||
243 | down(&data->update_lock); \ | ||
244 | if (data->kind == adt7461) \ | ||
245 | data->value = TEMP1_TO_REG_ADT7461(val); \ | ||
246 | else \ | ||
247 | data->value = TEMP1_TO_REG(val); \ | ||
248 | i2c_smbus_write_byte_data(client, reg, data->value); \ | ||
249 | up(&data->update_lock); \ | ||
250 | return count; \ | ||
251 | } | 265 | } |
252 | #define set_temp2(value, regh, regl) \ | 266 | |
253 | static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ | 267 | static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, |
254 | size_t count) \ | 268 | const char *buf, size_t count) |
255 | { \ | 269 | { |
256 | struct i2c_client *client = to_i2c_client(dev); \ | 270 | static const u8 reg[4] = { |
257 | struct lm90_data *data = i2c_get_clientdata(client); \ | 271 | LM90_REG_W_REMOTE_LOWH, |
258 | long val = simple_strtol(buf, NULL, 10); \ | 272 | LM90_REG_W_REMOTE_LOWL, |
259 | \ | 273 | LM90_REG_W_REMOTE_HIGHH, |
260 | down(&data->update_lock); \ | 274 | LM90_REG_W_REMOTE_HIGHL, |
261 | if (data->kind == adt7461) \ | 275 | }; |
262 | data->value = TEMP2_TO_REG_ADT7461(val); \ | 276 | |
263 | else \ | 277 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
264 | data->value = TEMP2_TO_REG(val); \ | 278 | struct i2c_client *client = to_i2c_client(dev); |
265 | i2c_smbus_write_byte_data(client, regh, data->value >> 8); \ | 279 | struct lm90_data *data = i2c_get_clientdata(client); |
266 | i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \ | 280 | long val = simple_strtol(buf, NULL, 10); |
267 | up(&data->update_lock); \ | 281 | int nr = attr->index; |
268 | return count; \ | 282 | |
283 | down(&data->update_lock); | ||
284 | if (data->kind == adt7461) | ||
285 | data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); | ||
286 | else | ||
287 | data->temp11[nr] = TEMP2_TO_REG(val); | ||
288 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], | ||
289 | data->temp11[nr] >> 8); | ||
290 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], | ||
291 | data->temp11[nr] & 0xff); | ||
292 | up(&data->update_lock); | ||
293 | return count; | ||
269 | } | 294 | } |
270 | set_temp1(temp_low1, LM90_REG_W_LOCAL_LOW); | 295 | |
271 | set_temp2(temp_low2, LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL); | 296 | static ssize_t show_temphyst(struct device *dev, struct device_attribute *devattr, |
272 | set_temp1(temp_high1, LM90_REG_W_LOCAL_HIGH); | 297 | char *buf) |
273 | set_temp2(temp_high2, LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL); | 298 | { |
274 | set_temp1(temp_crit1, LM90_REG_W_LOCAL_CRIT); | 299 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
275 | set_temp1(temp_crit2, LM90_REG_W_REMOTE_CRIT); | 300 | struct lm90_data *data = lm90_update_device(dev); |
276 | 301 | return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index]) | |
277 | #define show_temp_hyst(value, basereg) \ | 302 | - TEMP1_FROM_REG(data->temp_hyst)); |
278 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | ||
279 | { \ | ||
280 | struct lm90_data *data = lm90_update_device(dev); \ | ||
281 | return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \ | ||
282 | - TEMP1_FROM_REG(data->temp_hyst)); \ | ||
283 | } | 303 | } |
284 | show_temp_hyst(temp_hyst1, temp_crit1); | ||
285 | show_temp_hyst(temp_hyst2, temp_crit2); | ||
286 | 304 | ||
287 | static ssize_t set_temp_hyst1(struct device *dev, struct device_attribute *attr, const char *buf, | 305 | static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, |
288 | size_t count) | 306 | const char *buf, size_t count) |
289 | { | 307 | { |
290 | struct i2c_client *client = to_i2c_client(dev); | 308 | struct i2c_client *client = to_i2c_client(dev); |
291 | struct lm90_data *data = i2c_get_clientdata(client); | 309 | struct lm90_data *data = i2c_get_clientdata(client); |
@@ -293,36 +311,37 @@ static ssize_t set_temp_hyst1(struct device *dev, struct device_attribute *attr, | |||
293 | long hyst; | 311 | long hyst; |
294 | 312 | ||
295 | down(&data->update_lock); | 313 | down(&data->update_lock); |
296 | hyst = TEMP1_FROM_REG(data->temp_crit1) - val; | 314 | hyst = TEMP1_FROM_REG(data->temp8[3]) - val; |
297 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, | 315 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, |
298 | HYST_TO_REG(hyst)); | 316 | HYST_TO_REG(hyst)); |
299 | up(&data->update_lock); | 317 | up(&data->update_lock); |
300 | return count; | 318 | return count; |
301 | } | 319 | } |
302 | 320 | ||
303 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 321 | static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, |
322 | char *buf) | ||
304 | { | 323 | { |
305 | struct lm90_data *data = lm90_update_device(dev); | 324 | struct lm90_data *data = lm90_update_device(dev); |
306 | return sprintf(buf, "%d\n", data->alarms); | 325 | return sprintf(buf, "%d\n", data->alarms); |
307 | } | 326 | } |
308 | 327 | ||
309 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); | 328 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); |
310 | static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); | 329 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); |
311 | static DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_low1, | 330 | static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp8, |
312 | set_temp_low1); | 331 | set_temp8, 1); |
313 | static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_low2, | 332 | static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, |
314 | set_temp_low2); | 333 | set_temp11, 1); |
315 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, | 334 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, |
316 | set_temp_high1); | 335 | set_temp8, 2); |
317 | static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, | 336 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, |
318 | set_temp_high2); | 337 | set_temp11, 2); |
319 | static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit1, | 338 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp8, |
320 | set_temp_crit1); | 339 | set_temp8, 3); |
321 | static DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit2, | 340 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp8, |
322 | set_temp_crit2); | 341 | set_temp8, 4); |
323 | static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst1, | 342 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, |
324 | set_temp_hyst1); | 343 | set_temphyst, 3); |
325 | static DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_hyst2, NULL); | 344 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); |
326 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 345 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
327 | 346 | ||
328 | /* | 347 | /* |
@@ -481,16 +500,26 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
481 | lm90_init_client(new_client); | 500 | lm90_init_client(new_client); |
482 | 501 | ||
483 | /* Register sysfs hooks */ | 502 | /* Register sysfs hooks */ |
484 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 503 | device_create_file(&new_client->dev, |
485 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | 504 | &sensor_dev_attr_temp1_input.dev_attr); |
486 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | 505 | device_create_file(&new_client->dev, |
487 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | 506 | &sensor_dev_attr_temp2_input.dev_attr); |
488 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 507 | device_create_file(&new_client->dev, |
489 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | 508 | &sensor_dev_attr_temp1_min.dev_attr); |
490 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); | 509 | device_create_file(&new_client->dev, |
491 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | 510 | &sensor_dev_attr_temp2_min.dev_attr); |
492 | device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); | 511 | device_create_file(&new_client->dev, |
493 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); | 512 | &sensor_dev_attr_temp1_max.dev_attr); |
513 | device_create_file(&new_client->dev, | ||
514 | &sensor_dev_attr_temp2_max.dev_attr); | ||
515 | device_create_file(&new_client->dev, | ||
516 | &sensor_dev_attr_temp1_crit.dev_attr); | ||
517 | device_create_file(&new_client->dev, | ||
518 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
519 | device_create_file(&new_client->dev, | ||
520 | &sensor_dev_attr_temp1_crit_hyst.dev_attr); | ||
521 | device_create_file(&new_client->dev, | ||
522 | &sensor_dev_attr_temp2_crit_hyst.dev_attr); | ||
494 | device_create_file(&new_client->dev, &dev_attr_alarms); | 523 | device_create_file(&new_client->dev, &dev_attr_alarms); |
495 | 524 | ||
496 | return 0; | 525 | return 0; |
@@ -541,16 +570,16 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
541 | u8 oldh, newh; | 570 | u8 oldh, newh; |
542 | 571 | ||
543 | dev_dbg(&client->dev, "Updating lm90 data.\n"); | 572 | dev_dbg(&client->dev, "Updating lm90 data.\n"); |
544 | data->temp_input1 = i2c_smbus_read_byte_data(client, | 573 | data->temp8[0] = i2c_smbus_read_byte_data(client, |
545 | LM90_REG_R_LOCAL_TEMP); | 574 | LM90_REG_R_LOCAL_TEMP); |
546 | data->temp_high1 = i2c_smbus_read_byte_data(client, | 575 | data->temp8[1] = i2c_smbus_read_byte_data(client, |
547 | LM90_REG_R_LOCAL_HIGH); | 576 | LM90_REG_R_LOCAL_LOW); |
548 | data->temp_low1 = i2c_smbus_read_byte_data(client, | 577 | data->temp8[2] = i2c_smbus_read_byte_data(client, |
549 | LM90_REG_R_LOCAL_LOW); | 578 | LM90_REG_R_LOCAL_HIGH); |
550 | data->temp_crit1 = i2c_smbus_read_byte_data(client, | 579 | data->temp8[3] = i2c_smbus_read_byte_data(client, |
551 | LM90_REG_R_LOCAL_CRIT); | 580 | LM90_REG_R_LOCAL_CRIT); |
552 | data->temp_crit2 = i2c_smbus_read_byte_data(client, | 581 | data->temp8[4] = i2c_smbus_read_byte_data(client, |
553 | LM90_REG_R_REMOTE_CRIT); | 582 | LM90_REG_R_REMOTE_CRIT); |
554 | data->temp_hyst = i2c_smbus_read_byte_data(client, | 583 | data->temp_hyst = i2c_smbus_read_byte_data(client, |
555 | LM90_REG_R_TCRIT_HYST); | 584 | LM90_REG_R_TCRIT_HYST); |
556 | 585 | ||
@@ -570,13 +599,13 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
570 | */ | 599 | */ |
571 | oldh = i2c_smbus_read_byte_data(client, | 600 | oldh = i2c_smbus_read_byte_data(client, |
572 | LM90_REG_R_REMOTE_TEMPH); | 601 | LM90_REG_R_REMOTE_TEMPH); |
573 | data->temp_input2 = i2c_smbus_read_byte_data(client, | 602 | data->temp11[0] = i2c_smbus_read_byte_data(client, |
574 | LM90_REG_R_REMOTE_TEMPL); | 603 | LM90_REG_R_REMOTE_TEMPL); |
575 | newh = i2c_smbus_read_byte_data(client, | 604 | newh = i2c_smbus_read_byte_data(client, |
576 | LM90_REG_R_REMOTE_TEMPH); | 605 | LM90_REG_R_REMOTE_TEMPH); |
577 | if (newh != oldh) { | 606 | if (newh != oldh) { |
578 | data->temp_input2 = i2c_smbus_read_byte_data(client, | 607 | data->temp11[0] = i2c_smbus_read_byte_data(client, |
579 | LM90_REG_R_REMOTE_TEMPL); | 608 | LM90_REG_R_REMOTE_TEMPL); |
580 | #ifdef DEBUG | 609 | #ifdef DEBUG |
581 | oldh = i2c_smbus_read_byte_data(client, | 610 | oldh = i2c_smbus_read_byte_data(client, |
582 | LM90_REG_R_REMOTE_TEMPH); | 611 | LM90_REG_R_REMOTE_TEMPH); |
@@ -586,16 +615,16 @@ static struct lm90_data *lm90_update_device(struct device *dev) | |||
586 | "wrong.\n"); | 615 | "wrong.\n"); |
587 | #endif | 616 | #endif |
588 | } | 617 | } |
589 | data->temp_input2 |= (newh << 8); | 618 | data->temp11[0] |= (newh << 8); |
590 | 619 | ||
591 | data->temp_high2 = (i2c_smbus_read_byte_data(client, | 620 | data->temp11[1] = (i2c_smbus_read_byte_data(client, |
621 | LM90_REG_R_REMOTE_LOWH) << 8) + | ||
622 | i2c_smbus_read_byte_data(client, | ||
623 | LM90_REG_R_REMOTE_LOWL); | ||
624 | data->temp11[2] = (i2c_smbus_read_byte_data(client, | ||
592 | LM90_REG_R_REMOTE_HIGHH) << 8) + | 625 | LM90_REG_R_REMOTE_HIGHH) << 8) + |
593 | i2c_smbus_read_byte_data(client, | 626 | i2c_smbus_read_byte_data(client, |
594 | LM90_REG_R_REMOTE_HIGHL); | 627 | LM90_REG_R_REMOTE_HIGHL); |
595 | data->temp_low2 = (i2c_smbus_read_byte_data(client, | ||
596 | LM90_REG_R_REMOTE_LOWH) << 8) + | ||
597 | i2c_smbus_read_byte_data(client, | ||
598 | LM90_REG_R_REMOTE_LOWL); | ||
599 | data->alarms = i2c_smbus_read_byte_data(client, | 628 | data->alarms = i2c_smbus_read_byte_data(client, |
600 | LM90_REG_R_STATUS); | 629 | LM90_REG_R_STATUS); |
601 | 630 | ||
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index e771566dffa8..5e463c47bfbc 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -40,11 +40,8 @@ static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END }; | |||
40 | 40 | ||
41 | static struct i2c_client_address_data addr_data = { | 41 | static struct i2c_client_address_data addr_data = { |
42 | .normal_i2c = normal_addr, | 42 | .normal_i2c = normal_addr, |
43 | .normal_i2c_range = ignore, | ||
44 | .probe = ignore, | 43 | .probe = ignore, |
45 | .probe_range = ignore, | ||
46 | .ignore = ignore, | 44 | .ignore = ignore, |
47 | .ignore_range = ignore, | ||
48 | .force = ignore, | 45 | .force = ignore, |
49 | }; | 46 | }; |
50 | 47 | ||
diff --git a/drivers/i2c/chips/max1619.c b/drivers/i2c/chips/max1619.c index 30a196155fd9..bf553dcd97d6 100644 --- a/drivers/i2c/chips/max1619.c +++ b/drivers/i2c/chips/max1619.c | |||
@@ -26,7 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #include <linux/config.h> | ||
30 | #include <linux/module.h> | 29 | #include <linux/module.h> |
31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
32 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c new file mode 100644 index 000000000000..fe6b150ec4c2 --- /dev/null +++ b/drivers/i2c/chips/max6875.c | |||
@@ -0,0 +1,473 @@ | |||
1 | /* | ||
2 | max6875.c - driver for MAX6874/MAX6875 | ||
3 | |||
4 | Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com> | ||
5 | |||
6 | Based on i2c/chips/eeprom.c | ||
7 | |||
8 | The MAX6875 has two EEPROM sections: config and user. | ||
9 | At reset, the config EEPROM is read into the registers. | ||
10 | |||
11 | This driver make 3 binary files available in sysfs: | ||
12 | reg_config - direct access to the registers | ||
13 | eeprom_config - acesses configuration eeprom space | ||
14 | eeprom_user - free for application use | ||
15 | |||
16 | In our application, we put device serial & model numbers in user eeprom. | ||
17 | |||
18 | Notes: | ||
19 | 1) The datasheet says that register 0x44 / EEPROM 0x8044 should NOT | ||
20 | be overwritten, so the driver explicitly prevents that. | ||
21 | 2) It's a good idea to keep the config (0x45) locked in config EEPROM. | ||
22 | You can temporarily enable config writes by changing register 0x45. | ||
23 | |||
24 | This program is free software; you can redistribute it and/or modify | ||
25 | it under the terms of the GNU General Public License as published by | ||
26 | the Free Software Foundation; version 2 of the License. | ||
27 | */ | ||
28 | |||
29 | #include <linux/config.h> | ||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/init.h> | ||
32 | #include <linux/module.h> | ||
33 | #include <linux/slab.h> | ||
34 | #include <linux/sched.h> | ||
35 | #include <linux/delay.h> | ||
36 | #include <linux/i2c.h> | ||
37 | #include <linux/i2c-sensor.h> | ||
38 | |||
39 | /* Addresses to scan */ | ||
40 | static unsigned short normal_i2c[] = {0x50, 0x52, I2C_CLIENT_END}; | ||
41 | static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; | ||
42 | |||
43 | /* Insmod parameters */ | ||
44 | SENSORS_INSMOD_1(max6875); | ||
45 | |||
46 | /* this param will prevent 'accidental' writes to the eeprom */ | ||
47 | static int allow_write = 0; | ||
48 | module_param(allow_write, int, 0); | ||
49 | MODULE_PARM_DESC(allow_write, | ||
50 | "Enable write access:\n" | ||
51 | "*0: Read only\n" | ||
52 | " 1: Read/Write access"); | ||
53 | |||
54 | /* The MAX6875 can only read/write 16 bytes at a time */ | ||
55 | #define SLICE_SIZE 16 | ||
56 | #define SLICE_BITS 4 | ||
57 | |||
58 | /* CONFIG EEPROM is at addresses 0x8000 - 0x8045, registers are at 0 - 0x45 */ | ||
59 | #define CONFIG_EEPROM_BASE 0x8000 | ||
60 | #define CONFIG_EEPROM_SIZE 0x0046 | ||
61 | #define CONFIG_EEPROM_SLICES 5 | ||
62 | |||
63 | /* USER EEPROM is at addresses 0x8100 - 0x82FF */ | ||
64 | #define USER_EEPROM_BASE 0x8100 | ||
65 | #define USER_EEPROM_SIZE 0x0200 | ||
66 | #define USER_EEPROM_SLICES 32 | ||
67 | |||
68 | /* MAX6875 commands */ | ||
69 | #define MAX6875_CMD_BLOCK_WRITE 0x83 | ||
70 | #define MAX6875_CMD_BLOCK_READ 0x84 | ||
71 | #define MAX6875_CMD_REBOOT 0x88 | ||
72 | |||
73 | enum max6875_area_type { | ||
74 | max6875_register_config=0, | ||
75 | max6875_eeprom_config, | ||
76 | max6875_eeprom_user, | ||
77 | max6857_max | ||
78 | }; | ||
79 | |||
80 | struct eeprom_block { | ||
81 | enum max6875_area_type type; | ||
82 | u8 slices; | ||
83 | u32 size; | ||
84 | u32 valid; | ||
85 | u32 base; | ||
86 | unsigned long *updated; | ||
87 | u8 *data; | ||
88 | }; | ||
89 | |||
90 | /* Each client has this additional data */ | ||
91 | struct max6875_data { | ||
92 | struct i2c_client client; | ||
93 | struct semaphore update_lock; | ||
94 | struct eeprom_block blocks[max6857_max]; | ||
95 | /* the above structs point into the arrays below */ | ||
96 | u8 data[USER_EEPROM_SIZE + (CONFIG_EEPROM_SIZE*2)]; | ||
97 | unsigned long last_updated[USER_EEPROM_SLICES + (CONFIG_EEPROM_SLICES*2)]; | ||
98 | }; | ||
99 | |||
100 | static int max6875_attach_adapter(struct i2c_adapter *adapter); | ||
101 | static int max6875_detect(struct i2c_adapter *adapter, int address, int kind); | ||
102 | static int max6875_detach_client(struct i2c_client *client); | ||
103 | |||
104 | /* This is the driver that will be inserted */ | ||
105 | static struct i2c_driver max6875_driver = { | ||
106 | .owner = THIS_MODULE, | ||
107 | .name = "max6875", | ||
108 | .flags = I2C_DF_NOTIFY, | ||
109 | .attach_adapter = max6875_attach_adapter, | ||
110 | .detach_client = max6875_detach_client, | ||
111 | }; | ||
112 | |||
113 | static int max6875_update_slice(struct i2c_client *client, | ||
114 | struct eeprom_block *blk, | ||
115 | int slice) | ||
116 | { | ||
117 | struct max6875_data *data = i2c_get_clientdata(client); | ||
118 | int i, j, addr, count; | ||
119 | u8 rdbuf[SLICE_SIZE]; | ||
120 | int retval = 0; | ||
121 | |||
122 | if (slice >= blk->slices) | ||
123 | return -1; | ||
124 | |||
125 | down(&data->update_lock); | ||
126 | |||
127 | if (!(blk->valid & (1 << slice)) || | ||
128 | (jiffies - blk->updated[slice] > 300 * HZ) || | ||
129 | (jiffies < blk->updated[slice])) { | ||
130 | dev_dbg(&client->dev, "Starting eeprom update, slice %u, base %u\n", | ||
131 | slice, blk->base); | ||
132 | |||
133 | addr = blk->base + (slice << SLICE_BITS); | ||
134 | count = blk->size - (slice << SLICE_BITS); | ||
135 | if (count > SLICE_SIZE) { | ||
136 | count = SLICE_SIZE; | ||
137 | } | ||
138 | |||
139 | /* Preset the read address */ | ||
140 | if (addr < 0x100) { | ||
141 | /* select the register */ | ||
142 | if (i2c_smbus_write_byte(client, addr & 0xFF)) { | ||
143 | dev_dbg(&client->dev, "max6875 register select has failed!\n"); | ||
144 | retval = -1; | ||
145 | goto exit; | ||
146 | } | ||
147 | } else { | ||
148 | /* select the eeprom */ | ||
149 | if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) { | ||
150 | dev_dbg(&client->dev, "max6875 address set has failed!\n"); | ||
151 | retval = -1; | ||
152 | goto exit; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { | ||
157 | if (i2c_smbus_read_i2c_block_data(client, MAX6875_CMD_BLOCK_READ, | ||
158 | rdbuf) != SLICE_SIZE) | ||
159 | { | ||
160 | retval = -1; | ||
161 | goto exit; | ||
162 | } | ||
163 | |||
164 | memcpy(&blk->data[slice << SLICE_BITS], rdbuf, count); | ||
165 | } else { | ||
166 | for (i = 0; i < count; i++) { | ||
167 | j = i2c_smbus_read_byte(client); | ||
168 | if (j < 0) | ||
169 | { | ||
170 | retval = -1; | ||
171 | goto exit; | ||
172 | } | ||
173 | blk->data[(slice << SLICE_BITS) + i] = (u8) j; | ||
174 | } | ||
175 | } | ||
176 | blk->updated[slice] = jiffies; | ||
177 | blk->valid |= (1 << slice); | ||
178 | } | ||
179 | exit: | ||
180 | up(&data->update_lock); | ||
181 | return retval; | ||
182 | } | ||
183 | |||
184 | static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, size_t count, | ||
185 | enum max6875_area_type area_type) | ||
186 | { | ||
187 | struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); | ||
188 | struct max6875_data *data = i2c_get_clientdata(client); | ||
189 | struct eeprom_block *blk; | ||
190 | int slice; | ||
191 | |||
192 | blk = &data->blocks[area_type]; | ||
193 | |||
194 | if (off > blk->size) | ||
195 | return 0; | ||
196 | if (off + count > blk->size) | ||
197 | count = blk->size - off; | ||
198 | |||
199 | /* Only refresh slices which contain requested bytes */ | ||
200 | for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) | ||
201 | max6875_update_slice(client, blk, slice); | ||
202 | |||
203 | memcpy(buf, &blk->data[off], count); | ||
204 | |||
205 | return count; | ||
206 | } | ||
207 | |||
208 | static ssize_t max6875_user_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
209 | { | ||
210 | return max6875_read(kobj, buf, off, count, max6875_eeprom_user); | ||
211 | } | ||
212 | |||
213 | static ssize_t max6875_config_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
214 | { | ||
215 | return max6875_read(kobj, buf, off, count, max6875_eeprom_config); | ||
216 | } | ||
217 | |||
218 | static ssize_t max6875_cfgreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
219 | { | ||
220 | return max6875_read(kobj, buf, off, count, max6875_register_config); | ||
221 | } | ||
222 | |||
223 | |||
224 | static ssize_t max6875_write(struct kobject *kobj, char *buf, loff_t off, size_t count, | ||
225 | enum max6875_area_type area_type) | ||
226 | { | ||
227 | struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); | ||
228 | struct max6875_data *data = i2c_get_clientdata(client); | ||
229 | struct eeprom_block *blk; | ||
230 | int slice, addr, retval; | ||
231 | ssize_t sent = 0; | ||
232 | |||
233 | blk = &data->blocks[area_type]; | ||
234 | |||
235 | if (off > blk->size) | ||
236 | return 0; | ||
237 | if ((off + count) > blk->size) | ||
238 | count = blk->size - off; | ||
239 | |||
240 | if (down_interruptible(&data->update_lock)) | ||
241 | return -EAGAIN; | ||
242 | |||
243 | /* writing to a register is done with i2c_smbus_write_byte_data() */ | ||
244 | if (blk->type == max6875_register_config) { | ||
245 | for (sent = 0; sent < count; sent++) { | ||
246 | addr = off + sent; | ||
247 | if (addr == 0x44) | ||
248 | continue; | ||
249 | |||
250 | retval = i2c_smbus_write_byte_data(client, addr, buf[sent]); | ||
251 | } | ||
252 | } else { | ||
253 | int cmd, val; | ||
254 | |||
255 | /* We are writing to EEPROM */ | ||
256 | for (sent = 0; sent < count; sent++) { | ||
257 | addr = blk->base + off + sent; | ||
258 | cmd = addr >> 8; | ||
259 | val = (addr & 0xff) | (buf[sent] << 8); // reversed | ||
260 | |||
261 | if (addr == 0x8044) | ||
262 | continue; | ||
263 | |||
264 | retval = i2c_smbus_write_word_data(client, cmd, val); | ||
265 | |||
266 | if (retval) { | ||
267 | goto error_exit; | ||
268 | } | ||
269 | |||
270 | /* A write takes up to 11 ms */ | ||
271 | msleep(11); | ||
272 | } | ||
273 | } | ||
274 | |||
275 | /* Invalidate the scratch buffer */ | ||
276 | for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) | ||
277 | blk->valid &= ~(1 << slice); | ||
278 | |||
279 | error_exit: | ||
280 | up(&data->update_lock); | ||
281 | |||
282 | return sent; | ||
283 | } | ||
284 | |||
285 | static ssize_t max6875_user_write(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
286 | { | ||
287 | return max6875_write(kobj, buf, off, count, max6875_eeprom_user); | ||
288 | } | ||
289 | |||
290 | static ssize_t max6875_config_write(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
291 | { | ||
292 | return max6875_write(kobj, buf, off, count, max6875_eeprom_config); | ||
293 | } | ||
294 | |||
295 | static ssize_t max6875_cfgreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count) | ||
296 | { | ||
297 | return max6875_write(kobj, buf, off, count, max6875_register_config); | ||
298 | } | ||
299 | |||
300 | static struct bin_attribute user_eeprom_attr = { | ||
301 | .attr = { | ||
302 | .name = "eeprom_user", | ||
303 | .mode = S_IRUGO | S_IWUSR | S_IWGRP, | ||
304 | .owner = THIS_MODULE, | ||
305 | }, | ||
306 | .size = USER_EEPROM_SIZE, | ||
307 | .read = max6875_user_read, | ||
308 | .write = max6875_user_write, | ||
309 | }; | ||
310 | |||
311 | static struct bin_attribute config_eeprom_attr = { | ||
312 | .attr = { | ||
313 | .name = "eeprom_config", | ||
314 | .mode = S_IRUGO | S_IWUSR, | ||
315 | .owner = THIS_MODULE, | ||
316 | }, | ||
317 | .size = CONFIG_EEPROM_SIZE, | ||
318 | .read = max6875_config_read, | ||
319 | .write = max6875_config_write, | ||
320 | }; | ||
321 | |||
322 | static struct bin_attribute config_register_attr = { | ||
323 | .attr = { | ||
324 | .name = "reg_config", | ||
325 | .mode = S_IRUGO | S_IWUSR, | ||
326 | .owner = THIS_MODULE, | ||
327 | }, | ||
328 | .size = CONFIG_EEPROM_SIZE, | ||
329 | .read = max6875_cfgreg_read, | ||
330 | .write = max6875_cfgreg_write, | ||
331 | }; | ||
332 | |||
333 | static int max6875_attach_adapter(struct i2c_adapter *adapter) | ||
334 | { | ||
335 | return i2c_detect(adapter, &addr_data, max6875_detect); | ||
336 | } | ||
337 | |||
338 | /* This function is called by i2c_detect */ | ||
339 | static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) | ||
340 | { | ||
341 | struct i2c_client *new_client; | ||
342 | struct max6875_data *data; | ||
343 | int err = 0; | ||
344 | |||
345 | /* There are three ways we can read the EEPROM data: | ||
346 | (1) I2C block reads (faster, but unsupported by most adapters) | ||
347 | (2) Consecutive byte reads (100% overhead) | ||
348 | (3) Regular byte data reads (200% overhead) | ||
349 | The third method is not implemented by this driver because all | ||
350 | known adapters support at least the second. */ | ||
351 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA | | ||
352 | I2C_FUNC_SMBUS_BYTE | | ||
353 | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) | ||
354 | goto exit; | ||
355 | |||
356 | /* OK. For now, we presume we have a valid client. We now create the | ||
357 | client structure, even though we cannot fill it completely yet. | ||
358 | But it allows us to access eeprom_{read,write}_value. */ | ||
359 | if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) { | ||
360 | err = -ENOMEM; | ||
361 | goto exit; | ||
362 | } | ||
363 | memset(data, 0, sizeof(struct max6875_data)); | ||
364 | |||
365 | new_client = &data->client; | ||
366 | i2c_set_clientdata(new_client, data); | ||
367 | new_client->addr = address; | ||
368 | new_client->adapter = adapter; | ||
369 | new_client->driver = &max6875_driver; | ||
370 | new_client->flags = 0; | ||
371 | |||
372 | /* Setup the user section */ | ||
373 | data->blocks[max6875_eeprom_user].type = max6875_eeprom_user; | ||
374 | data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES; | ||
375 | data->blocks[max6875_eeprom_user].size = USER_EEPROM_SIZE; | ||
376 | data->blocks[max6875_eeprom_user].base = USER_EEPROM_BASE; | ||
377 | data->blocks[max6875_eeprom_user].data = data->data; | ||
378 | data->blocks[max6875_eeprom_user].updated = data->last_updated; | ||
379 | |||
380 | /* Setup the config section */ | ||
381 | data->blocks[max6875_eeprom_config].type = max6875_eeprom_config; | ||
382 | data->blocks[max6875_eeprom_config].slices = CONFIG_EEPROM_SLICES; | ||
383 | data->blocks[max6875_eeprom_config].size = CONFIG_EEPROM_SIZE; | ||
384 | data->blocks[max6875_eeprom_config].base = CONFIG_EEPROM_BASE; | ||
385 | data->blocks[max6875_eeprom_config].data = &data->data[USER_EEPROM_SIZE]; | ||
386 | data->blocks[max6875_eeprom_config].updated = &data->last_updated[USER_EEPROM_SLICES]; | ||
387 | |||
388 | /* Setup the register section */ | ||
389 | data->blocks[max6875_register_config].type = max6875_register_config; | ||
390 | data->blocks[max6875_register_config].slices = CONFIG_EEPROM_SLICES; | ||
391 | data->blocks[max6875_register_config].size = CONFIG_EEPROM_SIZE; | ||
392 | data->blocks[max6875_register_config].base = 0; | ||
393 | data->blocks[max6875_register_config].data = &data->data[USER_EEPROM_SIZE+CONFIG_EEPROM_SIZE]; | ||
394 | data->blocks[max6875_register_config].updated = &data->last_updated[USER_EEPROM_SLICES+CONFIG_EEPROM_SLICES]; | ||
395 | |||
396 | /* Init the data */ | ||
397 | memset(data->data, 0xff, sizeof(data->data)); | ||
398 | |||
399 | /* Fill in the remaining client fields */ | ||
400 | strlcpy(new_client->name, "max6875", I2C_NAME_SIZE); | ||
401 | init_MUTEX(&data->update_lock); | ||
402 | |||
403 | /* Verify that the chip is really what we think it is */ | ||
404 | if ((max6875_update_slice(new_client, &data->blocks[max6875_eeprom_config], 4) < 0) || | ||
405 | (max6875_update_slice(new_client, &data->blocks[max6875_register_config], 4) < 0)) | ||
406 | goto exit_kfree; | ||
407 | |||
408 | /* 0x41,0x42 must be zero and 0x40 must match in eeprom and registers */ | ||
409 | if ((data->blocks[max6875_eeprom_config].data[0x41] != 0) || | ||
410 | (data->blocks[max6875_eeprom_config].data[0x42] != 0) || | ||
411 | (data->blocks[max6875_register_config].data[0x41] != 0) || | ||
412 | (data->blocks[max6875_register_config].data[0x42] != 0) || | ||
413 | (data->blocks[max6875_eeprom_config].data[0x40] != | ||
414 | data->blocks[max6875_register_config].data[0x40])) | ||
415 | goto exit_kfree; | ||
416 | |||
417 | /* Tell the I2C layer a new client has arrived */ | ||
418 | if ((err = i2c_attach_client(new_client))) | ||
419 | goto exit_kfree; | ||
420 | |||
421 | /* create the sysfs eeprom files with the correct permissions */ | ||
422 | if (allow_write == 0) { | ||
423 | user_eeprom_attr.attr.mode &= ~S_IWUGO; | ||
424 | user_eeprom_attr.write = NULL; | ||
425 | config_eeprom_attr.attr.mode &= ~S_IWUGO; | ||
426 | config_eeprom_attr.write = NULL; | ||
427 | config_register_attr.attr.mode &= ~S_IWUGO; | ||
428 | config_register_attr.write = NULL; | ||
429 | } | ||
430 | sysfs_create_bin_file(&new_client->dev.kobj, &user_eeprom_attr); | ||
431 | sysfs_create_bin_file(&new_client->dev.kobj, &config_eeprom_attr); | ||
432 | sysfs_create_bin_file(&new_client->dev.kobj, &config_register_attr); | ||
433 | |||
434 | return 0; | ||
435 | |||
436 | exit_kfree: | ||
437 | kfree(data); | ||
438 | exit: | ||
439 | return err; | ||
440 | } | ||
441 | |||
442 | static int max6875_detach_client(struct i2c_client *client) | ||
443 | { | ||
444 | int err; | ||
445 | |||
446 | err = i2c_detach_client(client); | ||
447 | if (err) { | ||
448 | dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); | ||
449 | return err; | ||
450 | } | ||
451 | |||
452 | kfree(i2c_get_clientdata(client)); | ||
453 | |||
454 | return 0; | ||
455 | } | ||
456 | |||
457 | static int __init max6875_init(void) | ||
458 | { | ||
459 | return i2c_add_driver(&max6875_driver); | ||
460 | } | ||
461 | |||
462 | static void __exit max6875_exit(void) | ||
463 | { | ||
464 | i2c_del_driver(&max6875_driver); | ||
465 | } | ||
466 | |||
467 | |||
468 | MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>"); | ||
469 | MODULE_DESCRIPTION("MAX6875 driver"); | ||
470 | MODULE_LICENSE("GPL"); | ||
471 | |||
472 | module_init(max6875_init); | ||
473 | module_exit(max6875_exit); | ||
diff --git a/drivers/i2c/chips/pc87360.c b/drivers/i2c/chips/pc87360.c index 65637b2cd170..876c68f3af31 100644 --- a/drivers/i2c/chips/pc87360.c +++ b/drivers/i2c/chips/pc87360.c | |||
@@ -33,7 +33,6 @@ | |||
33 | * the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F). | 33 | * the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F). |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <linux/config.h> | ||
37 | #include <linux/module.h> | 36 | #include <linux/module.h> |
38 | #include <linux/init.h> | 37 | #include <linux/init.h> |
39 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c new file mode 100644 index 000000000000..9f3ad45daae2 --- /dev/null +++ b/drivers/i2c/chips/pca9539.c | |||
@@ -0,0 +1,192 @@ | |||
1 | /* | ||
2 | pca9539.c - 16-bit I/O port with interrupt and reset | ||
3 | |||
4 | Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com> | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; version 2 of the License. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/i2c.h> | ||
15 | #include <linux/hwmon-sysfs.h> | ||
16 | #include <linux/i2c-sensor.h> | ||
17 | |||
18 | /* Addresses to scan */ | ||
19 | static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END}; | ||
20 | static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; | ||
21 | |||
22 | /* Insmod parameters */ | ||
23 | SENSORS_INSMOD_1(pca9539); | ||
24 | |||
25 | enum pca9539_cmd | ||
26 | { | ||
27 | PCA9539_INPUT_0 = 0, | ||
28 | PCA9539_INPUT_1 = 1, | ||
29 | PCA9539_OUTPUT_0 = 2, | ||
30 | PCA9539_OUTPUT_1 = 3, | ||
31 | PCA9539_INVERT_0 = 4, | ||
32 | PCA9539_INVERT_1 = 5, | ||
33 | PCA9539_DIRECTION_0 = 6, | ||
34 | PCA9539_DIRECTION_1 = 7, | ||
35 | }; | ||
36 | |||
37 | static int pca9539_attach_adapter(struct i2c_adapter *adapter); | ||
38 | static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind); | ||
39 | static int pca9539_detach_client(struct i2c_client *client); | ||
40 | |||
41 | /* This is the driver that will be inserted */ | ||
42 | static struct i2c_driver pca9539_driver = { | ||
43 | .owner = THIS_MODULE, | ||
44 | .name = "pca9539", | ||
45 | .flags = I2C_DF_NOTIFY, | ||
46 | .attach_adapter = pca9539_attach_adapter, | ||
47 | .detach_client = pca9539_detach_client, | ||
48 | }; | ||
49 | |||
50 | struct pca9539_data { | ||
51 | struct i2c_client client; | ||
52 | }; | ||
53 | |||
54 | /* following are the sysfs callback functions */ | ||
55 | static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr, | ||
56 | char *buf) | ||
57 | { | ||
58 | struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); | ||
59 | struct i2c_client *client = to_i2c_client(dev); | ||
60 | return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(client, | ||
61 | psa->index)); | ||
62 | } | ||
63 | |||
64 | static ssize_t pca9539_store(struct device *dev, struct device_attribute *attr, | ||
65 | const char *buf, size_t count) | ||
66 | { | ||
67 | struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); | ||
68 | struct i2c_client *client = to_i2c_client(dev); | ||
69 | unsigned long val = simple_strtoul(buf, NULL, 0); | ||
70 | if (val > 0xff) | ||
71 | return -EINVAL; | ||
72 | i2c_smbus_write_byte_data(client, psa->index, val); | ||
73 | return count; | ||
74 | } | ||
75 | |||
76 | /* Define the device attributes */ | ||
77 | |||
78 | #define PCA9539_ENTRY_RO(name, cmd_idx) \ | ||
79 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, pca9539_show, NULL, cmd_idx) | ||
80 | |||
81 | #define PCA9539_ENTRY_RW(name, cmd_idx) \ | ||
82 | static SENSOR_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, pca9539_show, \ | ||
83 | pca9539_store, cmd_idx) | ||
84 | |||
85 | PCA9539_ENTRY_RO(input0, PCA9539_INPUT_0); | ||
86 | PCA9539_ENTRY_RO(input1, PCA9539_INPUT_1); | ||
87 | PCA9539_ENTRY_RW(output0, PCA9539_OUTPUT_0); | ||
88 | PCA9539_ENTRY_RW(output1, PCA9539_OUTPUT_1); | ||
89 | PCA9539_ENTRY_RW(invert0, PCA9539_INVERT_0); | ||
90 | PCA9539_ENTRY_RW(invert1, PCA9539_INVERT_1); | ||
91 | PCA9539_ENTRY_RW(direction0, PCA9539_DIRECTION_0); | ||
92 | PCA9539_ENTRY_RW(direction1, PCA9539_DIRECTION_1); | ||
93 | |||
94 | static struct attribute *pca9539_attributes[] = { | ||
95 | &sensor_dev_attr_input0.dev_attr.attr, | ||
96 | &sensor_dev_attr_input1.dev_attr.attr, | ||
97 | &sensor_dev_attr_output0.dev_attr.attr, | ||
98 | &sensor_dev_attr_output1.dev_attr.attr, | ||
99 | &sensor_dev_attr_invert0.dev_attr.attr, | ||
100 | &sensor_dev_attr_invert1.dev_attr.attr, | ||
101 | &sensor_dev_attr_direction0.dev_attr.attr, | ||
102 | &sensor_dev_attr_direction1.dev_attr.attr, | ||
103 | NULL | ||
104 | }; | ||
105 | |||
106 | static struct attribute_group pca9539_defattr_group = { | ||
107 | .attrs = pca9539_attributes, | ||
108 | }; | ||
109 | |||
110 | static int pca9539_attach_adapter(struct i2c_adapter *adapter) | ||
111 | { | ||
112 | return i2c_detect(adapter, &addr_data, pca9539_detect); | ||
113 | } | ||
114 | |||
115 | /* This function is called by i2c_detect */ | ||
116 | static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind) | ||
117 | { | ||
118 | struct i2c_client *new_client; | ||
119 | struct pca9539_data *data; | ||
120 | int err = 0; | ||
121 | |||
122 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
123 | goto exit; | ||
124 | |||
125 | /* OK. For now, we presume we have a valid client. We now create the | ||
126 | client structure, even though we cannot fill it completely yet. */ | ||
127 | if (!(data = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { | ||
128 | err = -ENOMEM; | ||
129 | goto exit; | ||
130 | } | ||
131 | memset(data, 0, sizeof(struct pca9539_data)); | ||
132 | |||
133 | new_client = &data->client; | ||
134 | i2c_set_clientdata(new_client, data); | ||
135 | new_client->addr = address; | ||
136 | new_client->adapter = adapter; | ||
137 | new_client->driver = &pca9539_driver; | ||
138 | new_client->flags = 0; | ||
139 | |||
140 | /* Detection: the pca9539 only has 8 registers (0-7). | ||
141 | A read of 7 should succeed, but a read of 8 should fail. */ | ||
142 | if ((i2c_smbus_read_byte_data(new_client, 7) < 0) || | ||
143 | (i2c_smbus_read_byte_data(new_client, 8) >= 0)) | ||
144 | goto exit_kfree; | ||
145 | |||
146 | strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE); | ||
147 | |||
148 | /* Tell the I2C layer a new client has arrived */ | ||
149 | if ((err = i2c_attach_client(new_client))) | ||
150 | goto exit_kfree; | ||
151 | |||
152 | /* Register sysfs hooks (don't care about failure) */ | ||
153 | sysfs_create_group(&new_client->dev.kobj, &pca9539_defattr_group); | ||
154 | |||
155 | return 0; | ||
156 | |||
157 | exit_kfree: | ||
158 | kfree(data); | ||
159 | exit: | ||
160 | return err; | ||
161 | } | ||
162 | |||
163 | static int pca9539_detach_client(struct i2c_client *client) | ||
164 | { | ||
165 | int err; | ||
166 | |||
167 | if ((err = i2c_detach_client(client))) { | ||
168 | dev_err(&client->dev, "Client deregistration failed.\n"); | ||
169 | return err; | ||
170 | } | ||
171 | |||
172 | kfree(i2c_get_clientdata(client)); | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static int __init pca9539_init(void) | ||
177 | { | ||
178 | return i2c_add_driver(&pca9539_driver); | ||
179 | } | ||
180 | |||
181 | static void __exit pca9539_exit(void) | ||
182 | { | ||
183 | i2c_del_driver(&pca9539_driver); | ||
184 | } | ||
185 | |||
186 | MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>"); | ||
187 | MODULE_DESCRIPTION("PCA9539 driver"); | ||
188 | MODULE_LICENSE("GPL"); | ||
189 | |||
190 | module_init(pca9539_init); | ||
191 | module_exit(pca9539_exit); | ||
192 | |||
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index 4956e9effd75..cfcf64654080 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c | |||
@@ -57,7 +57,7 @@ SENSORS_INSMOD_2(pcf8574, pcf8574a); | |||
57 | struct pcf8574_data { | 57 | struct pcf8574_data { |
58 | struct i2c_client client; | 58 | struct i2c_client client; |
59 | 59 | ||
60 | u8 read, write; /* Register values */ | 60 | u8 write; /* Remember last written value */ |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static int pcf8574_attach_adapter(struct i2c_adapter *adapter); | 63 | static int pcf8574_attach_adapter(struct i2c_adapter *adapter); |
@@ -79,9 +79,7 @@ static struct i2c_driver pcf8574_driver = { | |||
79 | static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf) | 79 | static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf) |
80 | { | 80 | { |
81 | struct i2c_client *client = to_i2c_client(dev); | 81 | struct i2c_client *client = to_i2c_client(dev); |
82 | struct pcf8574_data *data = i2c_get_clientdata(client); | 82 | return sprintf(buf, "%u\n", i2c_smbus_read_byte(client)); |
83 | data->read = i2c_smbus_read_byte(client); | ||
84 | return sprintf(buf, "%u\n", data->read); | ||
85 | } | 83 | } |
86 | 84 | ||
87 | static DEVICE_ATTR(read, S_IRUGO, show_read, NULL); | 85 | static DEVICE_ATTR(read, S_IRUGO, show_read, NULL); |
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 5a9deddb626b..588fc2261a91 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/rtc.h> /* get the user-level API */ | 20 | #include <linux/rtc.h> /* get the user-level API */ |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/init.h> | ||
23 | 22 | ||
24 | #include "rtc8564.h" | 23 | #include "rtc8564.h" |
25 | 24 | ||
@@ -66,11 +65,8 @@ static unsigned short normal_addr[] = { 0x51, I2C_CLIENT_END }; | |||
66 | 65 | ||
67 | static struct i2c_client_address_data addr_data = { | 66 | static struct i2c_client_address_data addr_data = { |
68 | .normal_i2c = normal_addr, | 67 | .normal_i2c = normal_addr, |
69 | .normal_i2c_range = ignore, | ||
70 | .probe = ignore, | 68 | .probe = ignore, |
71 | .probe_range = ignore, | ||
72 | .ignore = ignore, | 69 | .ignore = ignore, |
73 | .ignore_range = ignore, | ||
74 | .force = ignore, | 70 | .force = ignore, |
75 | }; | 71 | }; |
76 | 72 | ||
diff --git a/drivers/i2c/chips/sis5595.c b/drivers/i2c/chips/sis5595.c index c6650727a27d..6bbfc8fb4f13 100644 --- a/drivers/i2c/chips/sis5595.c +++ b/drivers/i2c/chips/sis5595.c | |||
@@ -57,6 +57,7 @@ | |||
57 | #include <linux/i2c.h> | 57 | #include <linux/i2c.h> |
58 | #include <linux/i2c-sensor.h> | 58 | #include <linux/i2c-sensor.h> |
59 | #include <linux/init.h> | 59 | #include <linux/init.h> |
60 | #include <linux/jiffies.h> | ||
60 | #include <asm/io.h> | 61 | #include <asm/io.h> |
61 | 62 | ||
62 | 63 | ||
diff --git a/drivers/i2c/chips/smsc47m1.c b/drivers/i2c/chips/smsc47m1.c index 13d6d4a8bc7d..897117a7213f 100644 --- a/drivers/i2c/chips/smsc47m1.c +++ b/drivers/i2c/chips/smsc47m1.c | |||
@@ -372,14 +372,16 @@ static int smsc47m1_find(int *address) | |||
372 | * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id | 372 | * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id |
373 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. | 373 | * 0x5F) and LPC47B27x (device id 0x51) have fan control. |
374 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" | 374 | * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" |
375 | * can do much more besides (device id 0x60, unsupported). | 375 | * can do much more besides (device id 0x60). |
376 | */ | 376 | */ |
377 | if (val == 0x51) | 377 | if (val == 0x51) |
378 | printk(KERN_INFO "smsc47m1: Found SMSC47B27x\n"); | 378 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); |
379 | else if (val == 0x59) | 379 | else if (val == 0x59) |
380 | printk(KERN_INFO "smsc47m1: Found SMSC47M10x/SMSC47M13x\n"); | 380 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M10x/LPC47M13x\n"); |
381 | else if (val == 0x5F) | 381 | else if (val == 0x5F) |
382 | printk(KERN_INFO "smsc47m1: Found SMSC47M14x\n"); | 382 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); |
383 | else if (val == 0x60) | ||
384 | printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n"); | ||
383 | else { | 385 | else { |
384 | superio_exit(); | 386 | superio_exit(); |
385 | return -ENODEV; | 387 | return -ENODEV; |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c new file mode 100644 index 000000000000..c0ac01b60039 --- /dev/null +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -0,0 +1,1072 @@ | |||
1 | /* | ||
2 | * tps65010 - driver for tps6501x power management chips | ||
3 | * | ||
4 | * Copyright (C) 2004 Texas Instruments | ||
5 | * Copyright (C) 2004-2005 David Brownell | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | #undef DEBUG | ||
22 | |||
23 | #include <linux/config.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/device.h> | ||
30 | #include <linux/i2c.h> | ||
31 | #include <linux/delay.h> | ||
32 | #include <linux/workqueue.h> | ||
33 | #include <linux/suspend.h> | ||
34 | #include <linux/debugfs.h> | ||
35 | #include <linux/seq_file.h> | ||
36 | |||
37 | #include <asm/irq.h> | ||
38 | #include <asm/mach-types.h> | ||
39 | |||
40 | #include <asm/arch/gpio.h> | ||
41 | #include <asm/arch/mux.h> | ||
42 | #include <asm/arch/tps65010.h> | ||
43 | |||
44 | /*-------------------------------------------------------------------------*/ | ||
45 | |||
46 | #define DRIVER_VERSION "2 May 2005" | ||
47 | #define DRIVER_NAME (tps65010_driver.name) | ||
48 | |||
49 | MODULE_DESCRIPTION("TPS6501x Power Management Driver"); | ||
50 | MODULE_LICENSE("GPL"); | ||
51 | |||
52 | /* only two addresses possible */ | ||
53 | #define TPS_BASE 0x48 | ||
54 | static unsigned short normal_i2c[] = { | ||
55 | TPS_BASE, | ||
56 | I2C_CLIENT_END }; | ||
57 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
58 | |||
59 | I2C_CLIENT_INSMOD; | ||
60 | |||
61 | static struct i2c_driver tps65010_driver; | ||
62 | |||
63 | /*-------------------------------------------------------------------------*/ | ||
64 | |||
65 | /* This driver handles a family of multipurpose chips, which incorporate | ||
66 | * voltage regulators, lithium ion/polymer battery charging, GPIOs, LEDs, | ||
67 | * and other features often needed in portable devices like cell phones | ||
68 | * or digital cameras. | ||
69 | * | ||
70 | * The tps65011 and tps65013 have different voltage settings compared | ||
71 | * to tps65010 and tps65012. The tps65013 has a NO_CHG status/irq. | ||
72 | * All except tps65010 have "wait" mode, possibly defaulted so that | ||
73 | * battery-insert != device-on. | ||
74 | * | ||
75 | * We could distinguish between some models by checking VDCDC1.UVLO or | ||
76 | * other registers, unless they've been changed already after powerup | ||
77 | * as part of board setup by a bootloader. | ||
78 | */ | ||
79 | enum tps_model { | ||
80 | TPS_UNKNOWN = 0, | ||
81 | TPS65010, | ||
82 | TPS65011, | ||
83 | TPS65012, | ||
84 | TPS65013, | ||
85 | }; | ||
86 | |||
87 | struct tps65010 { | ||
88 | struct i2c_client client; | ||
89 | struct semaphore lock; | ||
90 | int irq; | ||
91 | struct work_struct work; | ||
92 | struct dentry *file; | ||
93 | unsigned charging:1; | ||
94 | unsigned por:1; | ||
95 | unsigned model:8; | ||
96 | u16 vbus; | ||
97 | unsigned long flags; | ||
98 | #define FLAG_VBUS_CHANGED 0 | ||
99 | #define FLAG_IRQ_ENABLE 1 | ||
100 | |||
101 | /* copies of last register state */ | ||
102 | u8 chgstatus, regstatus, chgconf; | ||
103 | u8 nmask1, nmask2; | ||
104 | |||
105 | /* plus four GPIOs, probably used to switch power */ | ||
106 | }; | ||
107 | |||
108 | #define POWER_POLL_DELAY msecs_to_jiffies(800) | ||
109 | |||
110 | /*-------------------------------------------------------------------------*/ | ||
111 | |||
112 | #if defined(DEBUG) || defined(CONFIG_DEBUG_FS) | ||
113 | |||
114 | static void dbg_chgstat(char *buf, size_t len, u8 chgstatus) | ||
115 | { | ||
116 | snprintf(buf, len, "%02x%s%s%s%s%s%s%s%s\n", | ||
117 | chgstatus, | ||
118 | (chgstatus & TPS_CHG_USB) ? " USB" : "", | ||
119 | (chgstatus & TPS_CHG_AC) ? " AC" : "", | ||
120 | (chgstatus & TPS_CHG_THERM) ? " therm" : "", | ||
121 | (chgstatus & TPS_CHG_TERM) ? " done" : | ||
122 | ((chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) | ||
123 | ? " (charging)" : ""), | ||
124 | (chgstatus & TPS_CHG_TAPER_TMO) ? " taper_tmo" : "", | ||
125 | (chgstatus & TPS_CHG_CHG_TMO) ? " charge_tmo" : "", | ||
126 | (chgstatus & TPS_CHG_PRECHG_TMO) ? " prechg_tmo" : "", | ||
127 | (chgstatus & TPS_CHG_TEMP_ERR) ? " temp_err" : ""); | ||
128 | } | ||
129 | |||
130 | static void dbg_regstat(char *buf, size_t len, u8 regstatus) | ||
131 | { | ||
132 | snprintf(buf, len, "%02x %s%s%s%s%s%s%s%s\n", | ||
133 | regstatus, | ||
134 | (regstatus & TPS_REG_ONOFF) ? "off" : "(on)", | ||
135 | (regstatus & TPS_REG_COVER) ? " uncover" : "", | ||
136 | (regstatus & TPS_REG_UVLO) ? " UVLO" : "", | ||
137 | (regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "", | ||
138 | (regstatus & TPS_REG_PG_LD02) ? " ld01_bad" : "", | ||
139 | (regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "", | ||
140 | (regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "", | ||
141 | (regstatus & TPS_REG_PG_CORE) ? " core_bad" : ""); | ||
142 | } | ||
143 | |||
144 | static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig) | ||
145 | { | ||
146 | char *hibit; | ||
147 | |||
148 | if (por) | ||
149 | hibit = (chgconfig & TPS_CHARGE_POR) | ||
150 | ? "POR=69ms" : "POR=1sec"; | ||
151 | else | ||
152 | hibit = (chgconfig & TPS65013_AUA) ? "AUA" : ""; | ||
153 | |||
154 | snprintf(buf, len, "%02x %s%s%s AC=%d%% USB=%dmA %sCharge\n", | ||
155 | chgconfig, hibit, | ||
156 | (chgconfig & TPS_CHARGE_RESET) ? " reset" : "", | ||
157 | (chgconfig & TPS_CHARGE_FAST) ? " fast" : "", | ||
158 | ({int p; switch ((chgconfig >> 3) & 3) { | ||
159 | case 3: p = 100; break; | ||
160 | case 2: p = 75; break; | ||
161 | case 1: p = 50; break; | ||
162 | default: p = 25; break; | ||
163 | }; p; }), | ||
164 | (chgconfig & TPS_VBUS_CHARGING) | ||
165 | ? ((chgconfig & TPS_VBUS_500MA) ? 500 : 100) | ||
166 | : 0, | ||
167 | (chgconfig & TPS_CHARGE_ENABLE) ? "" : "No"); | ||
168 | } | ||
169 | |||
170 | #endif | ||
171 | |||
172 | #ifdef DEBUG | ||
173 | |||
174 | static void show_chgstatus(const char *label, u8 chgstatus) | ||
175 | { | ||
176 | char buf [100]; | ||
177 | |||
178 | dbg_chgstat(buf, sizeof buf, chgstatus); | ||
179 | pr_debug("%s: %s %s", DRIVER_NAME, label, buf); | ||
180 | } | ||
181 | |||
182 | static void show_regstatus(const char *label, u8 regstatus) | ||
183 | { | ||
184 | char buf [100]; | ||
185 | |||
186 | dbg_regstat(buf, sizeof buf, regstatus); | ||
187 | pr_debug("%s: %s %s", DRIVER_NAME, label, buf); | ||
188 | } | ||
189 | |||
190 | static void show_chgconfig(int por, const char *label, u8 chgconfig) | ||
191 | { | ||
192 | char buf [100]; | ||
193 | |||
194 | dbg_chgconf(por, buf, sizeof buf, chgconfig); | ||
195 | pr_debug("%s: %s %s", DRIVER_NAME, label, buf); | ||
196 | } | ||
197 | |||
198 | #else | ||
199 | |||
200 | static inline void show_chgstatus(const char *label, u8 chgstatus) { } | ||
201 | static inline void show_regstatus(const char *label, u8 chgstatus) { } | ||
202 | static inline void show_chgconfig(int por, const char *label, u8 chgconfig) { } | ||
203 | |||
204 | #endif | ||
205 | |||
206 | #ifdef CONFIG_DEBUG_FS | ||
207 | |||
208 | static int dbg_show(struct seq_file *s, void *_) | ||
209 | { | ||
210 | struct tps65010 *tps = s->private; | ||
211 | u8 value, v2; | ||
212 | unsigned i; | ||
213 | char buf[100]; | ||
214 | const char *chip; | ||
215 | |||
216 | switch (tps->model) { | ||
217 | case TPS65010: chip = "tps65010"; break; | ||
218 | case TPS65011: chip = "tps65011"; break; | ||
219 | case TPS65012: chip = "tps65012"; break; | ||
220 | case TPS65013: chip = "tps65013"; break; | ||
221 | default: chip = NULL; break; | ||
222 | } | ||
223 | seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", | ||
224 | DRIVER_NAME, DRIVER_VERSION, chip); | ||
225 | |||
226 | down(&tps->lock); | ||
227 | |||
228 | /* FIXME how can we tell whether a battery is present? | ||
229 | * likely involves a charge gauging chip (like BQ26501). | ||
230 | */ | ||
231 | |||
232 | seq_printf(s, "%scharging\n\n", tps->charging ? "" : "(not) "); | ||
233 | |||
234 | |||
235 | /* registers for monitoring battery charging and status; note | ||
236 | * that reading chgstat and regstat may ack IRQs... | ||
237 | */ | ||
238 | value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); | ||
239 | dbg_chgconf(tps->por, buf, sizeof buf, value); | ||
240 | seq_printf(s, "chgconfig %s", buf); | ||
241 | |||
242 | value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS); | ||
243 | dbg_chgstat(buf, sizeof buf, value); | ||
244 | seq_printf(s, "chgstat %s", buf); | ||
245 | value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK1); | ||
246 | dbg_chgstat(buf, sizeof buf, value); | ||
247 | seq_printf(s, "mask1 %s", buf); | ||
248 | /* ignore ackint1 */ | ||
249 | |||
250 | value = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS); | ||
251 | dbg_regstat(buf, sizeof buf, value); | ||
252 | seq_printf(s, "regstat %s", buf); | ||
253 | value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK2); | ||
254 | dbg_regstat(buf, sizeof buf, value); | ||
255 | seq_printf(s, "mask2 %s\n", buf); | ||
256 | /* ignore ackint2 */ | ||
257 | |||
258 | (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY); | ||
259 | |||
260 | |||
261 | /* VMAIN voltage, enable lowpower, etc */ | ||
262 | value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1); | ||
263 | seq_printf(s, "vdcdc1 %02x\n", value); | ||
264 | |||
265 | /* VCORE voltage, vibrator on/off */ | ||
266 | value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2); | ||
267 | seq_printf(s, "vdcdc2 %02x\n", value); | ||
268 | |||
269 | /* both LD0s, and their lowpower behavior */ | ||
270 | value = i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1); | ||
271 | seq_printf(s, "vregs1 %02x\n\n", value); | ||
272 | |||
273 | |||
274 | /* LEDs and GPIOs */ | ||
275 | value = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_ON); | ||
276 | v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_PER); | ||
277 | seq_printf(s, "led1 %s, on=%02x, per=%02x, %d/%d msec\n", | ||
278 | (value & 0x80) | ||
279 | ? ((v2 & 0x80) ? "on" : "off") | ||
280 | : ((v2 & 0x80) ? "blink" : "(nPG)"), | ||
281 | value, v2, | ||
282 | (value & 0x7f) * 10, (v2 & 0x7f) * 100); | ||
283 | |||
284 | value = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_ON); | ||
285 | v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_PER); | ||
286 | seq_printf(s, "led2 %s, on=%02x, per=%02x, %d/%d msec\n", | ||
287 | (value & 0x80) | ||
288 | ? ((v2 & 0x80) ? "on" : "off") | ||
289 | : ((v2 & 0x80) ? "blink" : "off"), | ||
290 | value, v2, | ||
291 | (value & 0x7f) * 10, (v2 & 0x7f) * 100); | ||
292 | |||
293 | value = i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO); | ||
294 | v2 = i2c_smbus_read_byte_data(&tps->client, TPS_MASK3); | ||
295 | seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2); | ||
296 | |||
297 | for (i = 0; i < 4; i++) { | ||
298 | if (value & (1 << (4 +i))) | ||
299 | seq_printf(s, " gpio%d-out %s\n", i + 1, | ||
300 | (value & (1 << i)) ? "low" : "hi "); | ||
301 | else | ||
302 | seq_printf(s, " gpio%d-in %s %s %s\n", i + 1, | ||
303 | (value & (1 << i)) ? "hi " : "low", | ||
304 | (v2 & (1 << i)) ? "no-irq" : "irq", | ||
305 | (v2 & (1 << (4 + i))) ? "rising" : "falling"); | ||
306 | } | ||
307 | |||
308 | up(&tps->lock); | ||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | static int dbg_tps_open(struct inode *inode, struct file *file) | ||
313 | { | ||
314 | return single_open(file, dbg_show, inode->u.generic_ip); | ||
315 | } | ||
316 | |||
317 | static struct file_operations debug_fops = { | ||
318 | .open = dbg_tps_open, | ||
319 | .read = seq_read, | ||
320 | .llseek = seq_lseek, | ||
321 | .release = single_release, | ||
322 | }; | ||
323 | |||
324 | #define DEBUG_FOPS &debug_fops | ||
325 | |||
326 | #else | ||
327 | #define DEBUG_FOPS NULL | ||
328 | #endif | ||
329 | |||
330 | /*-------------------------------------------------------------------------*/ | ||
331 | |||
332 | /* handle IRQS in a task context, so we can use I2C calls */ | ||
333 | static void tps65010_interrupt(struct tps65010 *tps) | ||
334 | { | ||
335 | u8 tmp = 0, mask, poll; | ||
336 | |||
337 | /* IRQs won't trigger irqs for certain events, but we can get | ||
338 | * others by polling (normally, with external power applied). | ||
339 | */ | ||
340 | poll = 0; | ||
341 | |||
342 | /* regstatus irqs */ | ||
343 | if (tps->nmask2) { | ||
344 | tmp = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS); | ||
345 | mask = tmp ^ tps->regstatus; | ||
346 | tps->regstatus = tmp; | ||
347 | mask &= tps->nmask2; | ||
348 | } else | ||
349 | mask = 0; | ||
350 | if (mask) { | ||
351 | tps->regstatus = tmp; | ||
352 | /* may need to shut something down ... */ | ||
353 | |||
354 | /* "off" usually means deep sleep */ | ||
355 | if (tmp & TPS_REG_ONOFF) { | ||
356 | pr_info("%s: power off button\n", DRIVER_NAME); | ||
357 | #if 0 | ||
358 | /* REVISIT: this might need its own workqueue | ||
359 | * plus tweaks including deadlock avoidance ... | ||
360 | */ | ||
361 | software_suspend(); | ||
362 | #endif | ||
363 | poll = 1; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | /* chgstatus irqs */ | ||
368 | if (tps->nmask1) { | ||
369 | tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS); | ||
370 | mask = tmp ^ tps->chgstatus; | ||
371 | tps->chgstatus = tmp; | ||
372 | mask &= tps->nmask1; | ||
373 | } else | ||
374 | mask = 0; | ||
375 | if (mask) { | ||
376 | unsigned charging = 0; | ||
377 | |||
378 | show_chgstatus("chg/irq", tmp); | ||
379 | if (tmp & (TPS_CHG_USB|TPS_CHG_AC)) | ||
380 | show_chgconfig(tps->por, "conf", tps->chgconf); | ||
381 | |||
382 | /* Unless it was turned off or disabled, we charge any | ||
383 | * battery whenever there's power available for it | ||
384 | * and the charger hasn't been disabled. | ||
385 | */ | ||
386 | if (!(tps->chgstatus & ~(TPS_CHG_USB|TPS_CHG_AC)) | ||
387 | && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) | ||
388 | && (tps->chgconf & TPS_CHARGE_ENABLE) | ||
389 | ) { | ||
390 | if (tps->chgstatus & TPS_CHG_USB) { | ||
391 | /* VBUS options are readonly until reconnect */ | ||
392 | if (mask & TPS_CHG_USB) | ||
393 | set_bit(FLAG_VBUS_CHANGED, &tps->flags); | ||
394 | charging = 1; | ||
395 | } else if (tps->chgstatus & TPS_CHG_AC) | ||
396 | charging = 1; | ||
397 | } | ||
398 | if (charging != tps->charging) { | ||
399 | tps->charging = charging; | ||
400 | pr_info("%s: battery %scharging\n", | ||
401 | DRIVER_NAME, charging ? "" : | ||
402 | ((tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) | ||
403 | ? "NOT " : "dis")); | ||
404 | } | ||
405 | } | ||
406 | |||
407 | /* always poll to detect (a) power removal, without tps65013 | ||
408 | * NO_CHG IRQ; or (b) restart of charging after stop. | ||
409 | */ | ||
410 | if ((tps->model != TPS65013 || !tps->charging) | ||
411 | && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))) | ||
412 | poll = 1; | ||
413 | if (poll) | ||
414 | (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY); | ||
415 | |||
416 | /* also potentially gpio-in rise or fall */ | ||
417 | } | ||
418 | |||
419 | /* handle IRQs and polling using keventd for now */ | ||
420 | static void tps65010_work(void *_tps) | ||
421 | { | ||
422 | struct tps65010 *tps = _tps; | ||
423 | |||
424 | down(&tps->lock); | ||
425 | |||
426 | tps65010_interrupt(tps); | ||
427 | |||
428 | if (test_and_clear_bit(FLAG_VBUS_CHANGED, &tps->flags)) { | ||
429 | int status; | ||
430 | u8 chgconfig, tmp; | ||
431 | |||
432 | chgconfig = i2c_smbus_read_byte_data(&tps->client, | ||
433 | TPS_CHGCONFIG); | ||
434 | chgconfig &= ~(TPS_VBUS_500MA | TPS_VBUS_CHARGING); | ||
435 | if (tps->vbus == 500) | ||
436 | chgconfig |= TPS_VBUS_500MA | TPS_VBUS_CHARGING; | ||
437 | else if (tps->vbus >= 100) | ||
438 | chgconfig |= TPS_VBUS_CHARGING; | ||
439 | |||
440 | status = i2c_smbus_write_byte_data(&tps->client, | ||
441 | TPS_CHGCONFIG, chgconfig); | ||
442 | |||
443 | /* vbus update fails unless VBUS is connected! */ | ||
444 | tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); | ||
445 | tps->chgconf = tmp; | ||
446 | show_chgconfig(tps->por, "update vbus", tmp); | ||
447 | } | ||
448 | |||
449 | if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) | ||
450 | enable_irq(tps->irq); | ||
451 | |||
452 | up(&tps->lock); | ||
453 | } | ||
454 | |||
455 | static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) | ||
456 | { | ||
457 | struct tps65010 *tps = _tps; | ||
458 | |||
459 | disable_irq_nosync(irq); | ||
460 | set_bit(FLAG_IRQ_ENABLE, &tps->flags); | ||
461 | (void) schedule_work(&tps->work); | ||
462 | return IRQ_HANDLED; | ||
463 | } | ||
464 | |||
465 | /*-------------------------------------------------------------------------*/ | ||
466 | |||
467 | static struct tps65010 *the_tps; | ||
468 | |||
469 | static int __exit tps65010_detach_client(struct i2c_client *client) | ||
470 | { | ||
471 | struct tps65010 *tps; | ||
472 | |||
473 | tps = container_of(client, struct tps65010, client); | ||
474 | #ifdef CONFIG_ARM | ||
475 | if (machine_is_omap_h2()) | ||
476 | omap_free_gpio(58); | ||
477 | if (machine_is_omap_osk()) | ||
478 | omap_free_gpio(OMAP_MPUIO(1)); | ||
479 | #endif | ||
480 | free_irq(tps->irq, tps); | ||
481 | debugfs_remove(tps->file); | ||
482 | if (i2c_detach_client(client) == 0) | ||
483 | kfree(tps); | ||
484 | the_tps = 0; | ||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | static int tps65010_noscan(struct i2c_adapter *bus) | ||
489 | { | ||
490 | /* pure paranoia, in case someone adds another i2c bus | ||
491 | * after our init section's gone... | ||
492 | */ | ||
493 | return -ENODEV; | ||
494 | } | ||
495 | |||
496 | /* no error returns, they'd just make bus scanning stop */ | ||
497 | static int __init | ||
498 | tps65010_probe(struct i2c_adapter *bus, int address, int kind) | ||
499 | { | ||
500 | struct tps65010 *tps; | ||
501 | int status; | ||
502 | |||
503 | if (the_tps) { | ||
504 | dev_dbg(&bus->dev, "only one %s for now\n", DRIVER_NAME); | ||
505 | return 0; | ||
506 | } | ||
507 | |||
508 | tps = kmalloc(sizeof *tps, GFP_KERNEL); | ||
509 | if (!tps) | ||
510 | return 0; | ||
511 | |||
512 | memset(tps, 0, sizeof *tps); | ||
513 | init_MUTEX(&tps->lock); | ||
514 | INIT_WORK(&tps->work, tps65010_work, tps); | ||
515 | tps->irq = -1; | ||
516 | tps->client.addr = address; | ||
517 | i2c_set_clientdata(&tps->client, tps); | ||
518 | tps->client.adapter = bus; | ||
519 | tps->client.driver = &tps65010_driver; | ||
520 | strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE); | ||
521 | |||
522 | status = i2c_attach_client(&tps->client); | ||
523 | if (status < 0) { | ||
524 | dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n", | ||
525 | DRIVER_NAME, address, status); | ||
526 | fail1: | ||
527 | kfree(tps); | ||
528 | return 0; | ||
529 | } | ||
530 | |||
531 | #ifdef CONFIG_ARM | ||
532 | if (machine_is_omap_h2()) { | ||
533 | tps->model = TPS65010; | ||
534 | omap_cfg_reg(W4_GPIO58); | ||
535 | tps->irq = OMAP_GPIO_IRQ(58); | ||
536 | omap_request_gpio(58); | ||
537 | omap_set_gpio_direction(58, 1); | ||
538 | omap_set_gpio_edge_ctrl(58, OMAP_GPIO_FALLING_EDGE); | ||
539 | } | ||
540 | if (machine_is_omap_osk()) { | ||
541 | tps->model = TPS65010; | ||
542 | // omap_cfg_reg(U19_1610_MPUIO1); | ||
543 | tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)); | ||
544 | omap_request_gpio(OMAP_MPUIO(1)); | ||
545 | omap_set_gpio_direction(OMAP_MPUIO(1), 1); | ||
546 | omap_set_gpio_edge_ctrl(OMAP_MPUIO(1), OMAP_GPIO_FALLING_EDGE); | ||
547 | } | ||
548 | if (machine_is_omap_h3()) { | ||
549 | tps->model = TPS65013; | ||
550 | |||
551 | // FIXME set up this board's IRQ ... | ||
552 | } | ||
553 | #else | ||
554 | #define set_irq_type(num,trigger) do{}while(0) | ||
555 | #endif | ||
556 | |||
557 | if (tps->irq > 0) { | ||
558 | set_irq_type(tps->irq, IRQT_LOW); | ||
559 | status = request_irq(tps->irq, tps65010_irq, | ||
560 | SA_SAMPLE_RANDOM, DRIVER_NAME, tps); | ||
561 | if (status < 0) { | ||
562 | dev_dbg(&tps->client.dev, "can't get IRQ %d, err %d\n", | ||
563 | tps->irq, status); | ||
564 | i2c_detach_client(&tps->client); | ||
565 | goto fail1; | ||
566 | } | ||
567 | #ifdef CONFIG_ARM | ||
568 | /* annoying race here, ideally we'd have an option | ||
569 | * to claim the irq now and enable it later. | ||
570 | */ | ||
571 | disable_irq(tps->irq); | ||
572 | set_bit(FLAG_IRQ_ENABLE, &tps->flags); | ||
573 | #endif | ||
574 | } else | ||
575 | printk(KERN_WARNING "%s: IRQ not configured!\n", | ||
576 | DRIVER_NAME); | ||
577 | |||
578 | |||
579 | switch (tps->model) { | ||
580 | case TPS65010: | ||
581 | case TPS65012: | ||
582 | tps->por = 1; | ||
583 | break; | ||
584 | case TPS_UNKNOWN: | ||
585 | printk(KERN_WARNING "%s: unknown TPS chip\n", DRIVER_NAME); | ||
586 | break; | ||
587 | /* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */ | ||
588 | } | ||
589 | tps->chgconf = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); | ||
590 | show_chgconfig(tps->por, "conf/init", tps->chgconf); | ||
591 | |||
592 | show_chgstatus("chg/init", | ||
593 | i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS)); | ||
594 | show_regstatus("reg/init", | ||
595 | i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS)); | ||
596 | |||
597 | pr_debug("%s: vdcdc1 0x%02x, vdcdc2 %02x, vregs1 %02x\n", DRIVER_NAME, | ||
598 | i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1), | ||
599 | i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2), | ||
600 | i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1)); | ||
601 | pr_debug("%s: defgpio 0x%02x, mask3 0x%02x\n", DRIVER_NAME, | ||
602 | i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO), | ||
603 | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); | ||
604 | |||
605 | tps65010_driver.attach_adapter = tps65010_noscan; | ||
606 | the_tps = tps; | ||
607 | |||
608 | #if defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG) | ||
609 | /* USB hosts can't draw VBUS. OTG devices could, later | ||
610 | * when OTG infrastructure enables it. USB peripherals | ||
611 | * could be relying on VBUS while booting, though. | ||
612 | */ | ||
613 | tps->vbus = 100; | ||
614 | #endif | ||
615 | |||
616 | /* unmask the "interesting" irqs, then poll once to | ||
617 | * kickstart monitoring, initialize shadowed status | ||
618 | * registers, and maybe disable VBUS draw. | ||
619 | */ | ||
620 | tps->nmask1 = ~0; | ||
621 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK1, ~tps->nmask1); | ||
622 | |||
623 | tps->nmask2 = TPS_REG_ONOFF; | ||
624 | if (tps->model == TPS65013) | ||
625 | tps->nmask2 |= TPS_REG_NO_CHG; | ||
626 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK2, ~tps->nmask2); | ||
627 | |||
628 | (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f | ||
629 | | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); | ||
630 | |||
631 | tps65010_work(tps); | ||
632 | |||
633 | tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, | ||
634 | tps, DEBUG_FOPS); | ||
635 | return 0; | ||
636 | } | ||
637 | |||
638 | static int __init tps65010_scan_bus(struct i2c_adapter *bus) | ||
639 | { | ||
640 | if (!i2c_check_functionality(bus, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
641 | return -EINVAL; | ||
642 | return i2c_probe(bus, &addr_data, tps65010_probe); | ||
643 | } | ||
644 | |||
645 | static struct i2c_driver tps65010_driver = { | ||
646 | .owner = THIS_MODULE, | ||
647 | .name = "tps65010", | ||
648 | .id = 888, /* FIXME assign "official" value */ | ||
649 | .flags = I2C_DF_NOTIFY, | ||
650 | .attach_adapter = tps65010_scan_bus, | ||
651 | .detach_client = __exit_p(tps65010_detach_client), | ||
652 | }; | ||
653 | |||
654 | /*-------------------------------------------------------------------------*/ | ||
655 | |||
656 | /* Draw from VBUS: | ||
657 | * 0 mA -- DON'T DRAW (might supply power instead) | ||
658 | * 100 mA -- usb unit load (slowest charge rate) | ||
659 | * 500 mA -- usb high power (fast battery charge) | ||
660 | */ | ||
661 | int tps65010_set_vbus_draw(unsigned mA) | ||
662 | { | ||
663 | unsigned long flags; | ||
664 | |||
665 | if (!the_tps) | ||
666 | return -ENODEV; | ||
667 | |||
668 | /* assumes non-SMP */ | ||
669 | local_irq_save(flags); | ||
670 | if (mA >= 500) | ||
671 | mA = 500; | ||
672 | else if (mA >= 100) | ||
673 | mA = 100; | ||
674 | else | ||
675 | mA = 0; | ||
676 | the_tps->vbus = mA; | ||
677 | if ((the_tps->chgstatus & TPS_CHG_USB) | ||
678 | && test_and_set_bit( | ||
679 | FLAG_VBUS_CHANGED, &the_tps->flags)) { | ||
680 | /* gadget drivers call this in_irq() */ | ||
681 | (void) schedule_work(&the_tps->work); | ||
682 | } | ||
683 | local_irq_restore(flags); | ||
684 | |||
685 | return 0; | ||
686 | } | ||
687 | EXPORT_SYMBOL(tps65010_set_vbus_draw); | ||
688 | |||
689 | /*-------------------------------------------------------------------------*/ | ||
690 | /* tps65010_set_gpio_out_value parameter: | ||
691 | * gpio: GPIO1, GPIO2, GPIO3 or GPIO4 | ||
692 | * value: LOW or HIGH | ||
693 | */ | ||
694 | int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) | ||
695 | { | ||
696 | int status; | ||
697 | unsigned defgpio; | ||
698 | |||
699 | if (!the_tps) | ||
700 | return -ENODEV; | ||
701 | if ((gpio < GPIO1) || (gpio > GPIO4)) | ||
702 | return -EINVAL; | ||
703 | |||
704 | down(&the_tps->lock); | ||
705 | |||
706 | defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); | ||
707 | |||
708 | /* Configure GPIO for output */ | ||
709 | defgpio |= 1 << (gpio + 3); | ||
710 | |||
711 | /* Writing 1 forces a logic 0 on that GPIO and vice versa */ | ||
712 | switch (value) { | ||
713 | case LOW: | ||
714 | defgpio |= 1 << (gpio - 1); /* set GPIO low by writing 1 */ | ||
715 | break; | ||
716 | /* case HIGH: */ | ||
717 | default: | ||
718 | defgpio &= ~(1 << (gpio - 1)); /* set GPIO high by writing 0 */ | ||
719 | break; | ||
720 | } | ||
721 | |||
722 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
723 | TPS_DEFGPIO, defgpio); | ||
724 | |||
725 | pr_debug("%s: gpio%dout = %s, defgpio 0x%02x\n", DRIVER_NAME, | ||
726 | gpio, value ? "high" : "low", | ||
727 | i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); | ||
728 | |||
729 | up(&the_tps->lock); | ||
730 | return status; | ||
731 | } | ||
732 | EXPORT_SYMBOL(tps65010_set_gpio_out_value); | ||
733 | |||
734 | /*-------------------------------------------------------------------------*/ | ||
735 | /* tps65010_set_led parameter: | ||
736 | * led: LED1 or LED2 | ||
737 | * mode: ON, OFF or BLINK | ||
738 | */ | ||
739 | int tps65010_set_led(unsigned led, unsigned mode) | ||
740 | { | ||
741 | int status; | ||
742 | unsigned led_on, led_per, offs; | ||
743 | |||
744 | if (!the_tps) | ||
745 | return -ENODEV; | ||
746 | |||
747 | if(led == LED1) | ||
748 | offs = 0; | ||
749 | else { | ||
750 | offs = 2; | ||
751 | led = LED2; | ||
752 | } | ||
753 | |||
754 | down(&the_tps->lock); | ||
755 | |||
756 | dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, | ||
757 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); | ||
758 | |||
759 | dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, | ||
760 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); | ||
761 | |||
762 | switch (mode) { | ||
763 | case OFF: | ||
764 | led_on = 1 << 7; | ||
765 | led_per = 0 << 7; | ||
766 | break; | ||
767 | case ON: | ||
768 | led_on = 1 << 7; | ||
769 | led_per = 1 << 7; | ||
770 | break; | ||
771 | case BLINK: | ||
772 | led_on = 0x30 | (0 << 7); | ||
773 | led_per = 0x08 | (1 << 7); | ||
774 | break; | ||
775 | default: | ||
776 | printk(KERN_ERR "%s: Wrong mode parameter for tps65010_set_led()\n", | ||
777 | DRIVER_NAME); | ||
778 | up(&the_tps->lock); | ||
779 | return -EINVAL; | ||
780 | } | ||
781 | |||
782 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
783 | TPS_LED1_ON + offs, led_on); | ||
784 | |||
785 | if (status != 0) { | ||
786 | printk(KERN_ERR "%s: Failed to write led%i_on register\n", | ||
787 | DRIVER_NAME, led); | ||
788 | up(&the_tps->lock); | ||
789 | return status; | ||
790 | } | ||
791 | |||
792 | dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, | ||
793 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); | ||
794 | |||
795 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
796 | TPS_LED1_PER + offs, led_per); | ||
797 | |||
798 | if (status != 0) { | ||
799 | printk(KERN_ERR "%s: Failed to write led%i_per register\n", | ||
800 | DRIVER_NAME, led); | ||
801 | up(&the_tps->lock); | ||
802 | return status; | ||
803 | } | ||
804 | |||
805 | dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, | ||
806 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); | ||
807 | |||
808 | up(&the_tps->lock); | ||
809 | |||
810 | return status; | ||
811 | } | ||
812 | EXPORT_SYMBOL(tps65010_set_led); | ||
813 | |||
814 | /*-------------------------------------------------------------------------*/ | ||
815 | /* tps65010_set_vib parameter: | ||
816 | * value: ON or OFF | ||
817 | */ | ||
818 | int tps65010_set_vib(unsigned value) | ||
819 | { | ||
820 | int status; | ||
821 | unsigned vdcdc2; | ||
822 | |||
823 | if (!the_tps) | ||
824 | return -ENODEV; | ||
825 | |||
826 | down(&the_tps->lock); | ||
827 | |||
828 | vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); | ||
829 | vdcdc2 &= ~(1 << 1); | ||
830 | if (value) | ||
831 | vdcdc2 |= (1 << 1); | ||
832 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
833 | TPS_VDCDC2, vdcdc2); | ||
834 | |||
835 | pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); | ||
836 | |||
837 | up(&the_tps->lock); | ||
838 | return status; | ||
839 | } | ||
840 | EXPORT_SYMBOL(tps65010_set_vib); | ||
841 | |||
842 | /*-------------------------------------------------------------------------*/ | ||
843 | /* tps65010_set_low_pwr parameter: | ||
844 | * mode: ON or OFF | ||
845 | */ | ||
846 | int tps65010_set_low_pwr(unsigned mode) | ||
847 | { | ||
848 | int status; | ||
849 | unsigned vdcdc1; | ||
850 | |||
851 | if (!the_tps) | ||
852 | return -ENODEV; | ||
853 | |||
854 | down(&the_tps->lock); | ||
855 | |||
856 | pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, | ||
857 | mode ? "enable" : "disable", | ||
858 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
859 | |||
860 | vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1); | ||
861 | |||
862 | switch (mode) { | ||
863 | case OFF: | ||
864 | vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */ | ||
865 | break; | ||
866 | /* case ON: */ | ||
867 | default: | ||
868 | vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */ | ||
869 | break; | ||
870 | } | ||
871 | |||
872 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
873 | TPS_VDCDC1, vdcdc1); | ||
874 | |||
875 | if (status != 0) | ||
876 | printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", | ||
877 | DRIVER_NAME); | ||
878 | else | ||
879 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | ||
880 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
881 | |||
882 | up(&the_tps->lock); | ||
883 | |||
884 | return status; | ||
885 | } | ||
886 | EXPORT_SYMBOL(tps65010_set_low_pwr); | ||
887 | |||
888 | /*-------------------------------------------------------------------------*/ | ||
889 | /* tps65010_config_vregs1 parameter: | ||
890 | * value to be written to VREGS1 register | ||
891 | * Note: The complete register is written, set all bits you need | ||
892 | */ | ||
893 | int tps65010_config_vregs1(unsigned value) | ||
894 | { | ||
895 | int status; | ||
896 | |||
897 | if (!the_tps) | ||
898 | return -ENODEV; | ||
899 | |||
900 | down(&the_tps->lock); | ||
901 | |||
902 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | ||
903 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | ||
904 | |||
905 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
906 | TPS_VREGS1, value); | ||
907 | |||
908 | if (status != 0) | ||
909 | printk(KERN_ERR "%s: Failed to write vregs1 register\n", | ||
910 | DRIVER_NAME); | ||
911 | else | ||
912 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | ||
913 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | ||
914 | |||
915 | up(&the_tps->lock); | ||
916 | |||
917 | return status; | ||
918 | } | ||
919 | EXPORT_SYMBOL(tps65010_config_vregs1); | ||
920 | |||
921 | /*-------------------------------------------------------------------------*/ | ||
922 | /* tps65013_set_low_pwr parameter: | ||
923 | * mode: ON or OFF | ||
924 | */ | ||
925 | |||
926 | /* FIXME: Assumes AC or USB power is present. Setting AUA bit is not | ||
927 | required if power supply is through a battery */ | ||
928 | |||
929 | int tps65013_set_low_pwr(unsigned mode) | ||
930 | { | ||
931 | int status; | ||
932 | unsigned vdcdc1, chgconfig; | ||
933 | |||
934 | if (!the_tps || the_tps->por) | ||
935 | return -ENODEV; | ||
936 | |||
937 | down(&the_tps->lock); | ||
938 | |||
939 | pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", | ||
940 | DRIVER_NAME, | ||
941 | mode ? "enable" : "disable", | ||
942 | i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG), | ||
943 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
944 | |||
945 | chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG); | ||
946 | vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1); | ||
947 | |||
948 | switch (mode) { | ||
949 | case OFF: | ||
950 | chgconfig &= ~TPS65013_AUA; /* disable AUA bit */ | ||
951 | vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */ | ||
952 | break; | ||
953 | /* case ON: */ | ||
954 | default: | ||
955 | chgconfig |= TPS65013_AUA; /* enable AUA bit */ | ||
956 | vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */ | ||
957 | break; | ||
958 | } | ||
959 | |||
960 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
961 | TPS_CHGCONFIG, chgconfig); | ||
962 | if (status != 0) { | ||
963 | printk(KERN_ERR "%s: Failed to write chconfig register\n", | ||
964 | DRIVER_NAME); | ||
965 | up(&the_tps->lock); | ||
966 | return status; | ||
967 | } | ||
968 | |||
969 | chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG); | ||
970 | the_tps->chgconf = chgconfig; | ||
971 | show_chgconfig(0, "chgconf", chgconfig); | ||
972 | |||
973 | status = i2c_smbus_write_byte_data(&the_tps->client, | ||
974 | TPS_VDCDC1, vdcdc1); | ||
975 | |||
976 | if (status != 0) | ||
977 | printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", | ||
978 | DRIVER_NAME); | ||
979 | else | ||
980 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | ||
981 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | ||
982 | |||
983 | up(&the_tps->lock); | ||
984 | |||
985 | return status; | ||
986 | } | ||
987 | EXPORT_SYMBOL(tps65013_set_low_pwr); | ||
988 | |||
989 | /*-------------------------------------------------------------------------*/ | ||
990 | |||
991 | static int __init tps_init(void) | ||
992 | { | ||
993 | u32 tries = 3; | ||
994 | int status = -ENODEV; | ||
995 | |||
996 | printk(KERN_INFO "%s: version %s\n", DRIVER_NAME, DRIVER_VERSION); | ||
997 | |||
998 | /* some boards have startup glitches */ | ||
999 | while (tries--) { | ||
1000 | status = i2c_add_driver(&tps65010_driver); | ||
1001 | if (the_tps) | ||
1002 | break; | ||
1003 | i2c_del_driver(&tps65010_driver); | ||
1004 | if (!tries) { | ||
1005 | printk(KERN_ERR "%s: no chip?\n", DRIVER_NAME); | ||
1006 | return -ENODEV; | ||
1007 | } | ||
1008 | pr_debug("%s: re-probe ...\n", DRIVER_NAME); | ||
1009 | msleep(10); | ||
1010 | } | ||
1011 | |||
1012 | #if defined(CONFIG_ARM) | ||
1013 | if (machine_is_omap_osk()) { | ||
1014 | |||
1015 | // FIXME: More should be placed in the initialization code | ||
1016 | // of the submodules (DSP, ethernet, power management, | ||
1017 | // board-osk.c). Careful: I2C is initialized "late". | ||
1018 | |||
1019 | /* Let LED1 (D9) blink */ | ||
1020 | tps65010_set_led(LED1, BLINK); | ||
1021 | |||
1022 | /* Disable LED 2 (D2) */ | ||
1023 | tps65010_set_led(LED2, OFF); | ||
1024 | |||
1025 | /* Set GPIO 1 HIGH to disable VBUS power supply; | ||
1026 | * OHCI driver powers it up/down as needed. | ||
1027 | */ | ||
1028 | tps65010_set_gpio_out_value(GPIO1, HIGH); | ||
1029 | |||
1030 | /* Set GPIO 2 low to turn on LED D3 */ | ||
1031 | tps65010_set_gpio_out_value(GPIO2, HIGH); | ||
1032 | |||
1033 | /* Set GPIO 3 low to take ethernet out of reset */ | ||
1034 | tps65010_set_gpio_out_value(GPIO3, LOW); | ||
1035 | |||
1036 | /* gpio4 for VDD_DSP */ | ||
1037 | |||
1038 | /* Enable LOW_PWR */ | ||
1039 | tps65010_set_low_pwr(ON); | ||
1040 | |||
1041 | /* Switch VLDO2 to 3.0V for AIC23 */ | ||
1042 | tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V | TPS_LDO1_ENABLE); | ||
1043 | |||
1044 | } else if (machine_is_omap_h2()) { | ||
1045 | /* gpio3 for SD, gpio4 for VDD_DSP */ | ||
1046 | |||
1047 | /* Enable LOW_PWR */ | ||
1048 | tps65010_set_low_pwr(ON); | ||
1049 | } else if (machine_is_omap_h3()) { | ||
1050 | /* gpio4 for SD, gpio3 for VDD_DSP */ | ||
1051 | #ifdef CONFIG_PM | ||
1052 | /* Enable LOW_PWR */ | ||
1053 | tps65013_set_low_pwr(ON); | ||
1054 | #endif | ||
1055 | } | ||
1056 | #endif | ||
1057 | |||
1058 | return status; | ||
1059 | } | ||
1060 | /* NOTE: this MUST be initialized before the other parts of the system | ||
1061 | * that rely on it ... but after the i2c bus on which this relies. | ||
1062 | * That is, much earlier than on PC-type systems, which don't often use | ||
1063 | * I2C as a core system bus. | ||
1064 | */ | ||
1065 | subsys_initcall(tps_init); | ||
1066 | |||
1067 | static void __exit tps_exit(void) | ||
1068 | { | ||
1069 | i2c_del_driver(&tps65010_driver); | ||
1070 | } | ||
1071 | module_exit(tps_exit); | ||
1072 | |||
diff --git a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c index fefc24a9251a..137d9b7cacd4 100644 --- a/drivers/i2c/chips/via686a.c +++ b/drivers/i2c/chips/via686a.c | |||
@@ -1,12 +1,12 @@ | |||
1 | /* | 1 | /* |
2 | via686a.c - Part of lm_sensors, Linux kernel modules | 2 | via686a.c - Part of lm_sensors, Linux kernel modules |
3 | for hardware monitoring | 3 | for hardware monitoring |
4 | 4 | ||
5 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, | 5 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, |
6 | Kyösti Mälkki <kmalkki@cc.hut.fi>, | 6 | Kyösti Mälkki <kmalkki@cc.hut.fi>, |
7 | Mark Studebaker <mdsxyz123@yahoo.com>, | 7 | Mark Studebaker <mdsxyz123@yahoo.com>, |
8 | and Bob Dougherty <bobd@stanford.edu> | 8 | and Bob Dougherty <bobd@stanford.edu> |
9 | (Some conversion-factor data were contributed by Jonathan Teh Soon Yew | 9 | (Some conversion-factor data were contributed by Jonathan Teh Soon Yew |
10 | <j.teh@iname.com> and Alex van Kaam <darkside@chello.nl>.) | 10 | <j.teh@iname.com> and Alex van Kaam <darkside@chello.nl>.) |
11 | 11 | ||
12 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
@@ -30,11 +30,9 @@ | |||
30 | Warning - only supports a single device. | 30 | Warning - only supports a single device. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/config.h> | ||
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
36 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
37 | #include <linux/delay.h> | ||
38 | #include <linux/jiffies.h> | 36 | #include <linux/jiffies.h> |
39 | #include <linux/i2c.h> | 37 | #include <linux/i2c.h> |
40 | #include <linux/i2c-sensor.h> | 38 | #include <linux/i2c-sensor.h> |
@@ -66,49 +64,46 @@ SENSORS_INSMOD_1(via686a); | |||
66 | /* Many VIA686A constants specified below */ | 64 | /* Many VIA686A constants specified below */ |
67 | 65 | ||
68 | /* Length of ISA address segment */ | 66 | /* Length of ISA address segment */ |
69 | #define VIA686A_EXTENT 0x80 | 67 | #define VIA686A_EXTENT 0x80 |
70 | #define VIA686A_BASE_REG 0x70 | 68 | #define VIA686A_BASE_REG 0x70 |
71 | #define VIA686A_ENABLE_REG 0x74 | 69 | #define VIA686A_ENABLE_REG 0x74 |
72 | 70 | ||
73 | /* The VIA686A registers */ | 71 | /* The VIA686A registers */ |
74 | /* ins numbered 0-4 */ | 72 | /* ins numbered 0-4 */ |
75 | #define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2)) | 73 | #define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2)) |
76 | #define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2)) | 74 | #define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2)) |
77 | #define VIA686A_REG_IN(nr) (0x22 + (nr)) | 75 | #define VIA686A_REG_IN(nr) (0x22 + (nr)) |
78 | 76 | ||
79 | /* fans numbered 1-2 */ | 77 | /* fans numbered 1-2 */ |
80 | #define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr)) | 78 | #define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr)) |
81 | #define VIA686A_REG_FAN(nr) (0x28 + (nr)) | 79 | #define VIA686A_REG_FAN(nr) (0x28 + (nr)) |
82 | |||
83 | /* the following values are as speced by VIA: */ | ||
84 | static const u8 regtemp[] = { 0x20, 0x21, 0x1f }; | ||
85 | static const u8 regover[] = { 0x39, 0x3d, 0x1d }; | ||
86 | static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e }; | ||
87 | 80 | ||
88 | /* temps numbered 1-3 */ | 81 | /* temps numbered 1-3 */ |
89 | #define VIA686A_REG_TEMP(nr) (regtemp[nr]) | 82 | static const u8 VIA686A_REG_TEMP[] = { 0x20, 0x21, 0x1f }; |
90 | #define VIA686A_REG_TEMP_OVER(nr) (regover[nr]) | 83 | static const u8 VIA686A_REG_TEMP_OVER[] = { 0x39, 0x3d, 0x1d }; |
91 | #define VIA686A_REG_TEMP_HYST(nr) (reghyst[nr]) | 84 | static const u8 VIA686A_REG_TEMP_HYST[] = { 0x3a, 0x3e, 0x1e }; |
92 | #define VIA686A_REG_TEMP_LOW1 0x4b // bits 7-6 | 85 | /* bits 7-6 */ |
93 | #define VIA686A_REG_TEMP_LOW23 0x49 // 2 = bits 5-4, 3 = bits 7-6 | 86 | #define VIA686A_REG_TEMP_LOW1 0x4b |
94 | 87 | /* 2 = bits 5-4, 3 = bits 7-6 */ | |
95 | #define VIA686A_REG_ALARM1 0x41 | 88 | #define VIA686A_REG_TEMP_LOW23 0x49 |
96 | #define VIA686A_REG_ALARM2 0x42 | 89 | |
97 | #define VIA686A_REG_FANDIV 0x47 | 90 | #define VIA686A_REG_ALARM1 0x41 |
98 | #define VIA686A_REG_CONFIG 0x40 | 91 | #define VIA686A_REG_ALARM2 0x42 |
99 | /* The following register sets temp interrupt mode (bits 1-0 for temp1, | 92 | #define VIA686A_REG_FANDIV 0x47 |
93 | #define VIA686A_REG_CONFIG 0x40 | ||
94 | /* The following register sets temp interrupt mode (bits 1-0 for temp1, | ||
100 | 3-2 for temp2, 5-4 for temp3). Modes are: | 95 | 3-2 for temp2, 5-4 for temp3). Modes are: |
101 | 00 interrupt stays as long as value is out-of-range | 96 | 00 interrupt stays as long as value is out-of-range |
102 | 01 interrupt is cleared once register is read (default) | 97 | 01 interrupt is cleared once register is read (default) |
103 | 10 comparator mode- like 00, but ignores hysteresis | 98 | 10 comparator mode- like 00, but ignores hysteresis |
104 | 11 same as 00 */ | 99 | 11 same as 00 */ |
105 | #define VIA686A_REG_TEMP_MODE 0x4b | 100 | #define VIA686A_REG_TEMP_MODE 0x4b |
106 | /* We'll just assume that you want to set all 3 simultaneously: */ | 101 | /* We'll just assume that you want to set all 3 simultaneously: */ |
107 | #define VIA686A_TEMP_MODE_MASK 0x3F | 102 | #define VIA686A_TEMP_MODE_MASK 0x3F |
108 | #define VIA686A_TEMP_MODE_CONTINUOUS (0x00) | 103 | #define VIA686A_TEMP_MODE_CONTINUOUS 0x00 |
109 | 104 | ||
110 | /* Conversions. Limit checking is only done on the TO_REG | 105 | /* Conversions. Limit checking is only done on the TO_REG |
111 | variants. | 106 | variants. |
112 | 107 | ||
113 | ********* VOLTAGE CONVERSIONS (Bob Dougherty) ******** | 108 | ********* VOLTAGE CONVERSIONS (Bob Dougherty) ******** |
114 | From HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew): | 109 | From HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew): |
@@ -121,7 +116,7 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e }; | |||
121 | That is: | 116 | That is: |
122 | volts = (25*regVal+133)*factor | 117 | volts = (25*regVal+133)*factor |
123 | regVal = (volts/factor-133)/25 | 118 | regVal = (volts/factor-133)/25 |
124 | (These conversions were contributed by Jonathan Teh Soon Yew | 119 | (These conversions were contributed by Jonathan Teh Soon Yew |
125 | <j.teh@iname.com>) */ | 120 | <j.teh@iname.com>) */ |
126 | static inline u8 IN_TO_REG(long val, int inNum) | 121 | static inline u8 IN_TO_REG(long val, int inNum) |
127 | { | 122 | { |
@@ -182,55 +177,55 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
182 | else | 177 | else |
183 | return double(temp)*0.924-127.33; | 178 | return double(temp)*0.924-127.33; |
184 | 179 | ||
185 | A fifth-order polynomial fits the unofficial data (provided by Alex van | 180 | A fifth-order polynomial fits the unofficial data (provided by Alex van |
186 | Kaam <darkside@chello.nl>) a bit better. It also give more reasonable | 181 | Kaam <darkside@chello.nl>) a bit better. It also give more reasonable |
187 | numbers on my machine (ie. they agree with what my BIOS tells me). | 182 | numbers on my machine (ie. they agree with what my BIOS tells me). |
188 | Here's the fifth-order fit to the 8-bit data: | 183 | Here's the fifth-order fit to the 8-bit data: |
189 | temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - | 184 | temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - |
190 | 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0. | 185 | 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0. |
191 | 186 | ||
192 | (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for | 187 | (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for |
193 | finding my typos in this formula!) | 188 | finding my typos in this formula!) |
194 | 189 | ||
195 | Alas, none of the elegant function-fit solutions will work because we | 190 | Alas, none of the elegant function-fit solutions will work because we |
196 | aren't allowed to use floating point in the kernel and doing it with | 191 | aren't allowed to use floating point in the kernel and doing it with |
197 | integers doesn't rpovide enough precision. So we'll do boring old | 192 | integers doesn't provide enough precision. So we'll do boring old |
198 | look-up table stuff. The unofficial data (see below) have effectively | 193 | look-up table stuff. The unofficial data (see below) have effectively |
199 | 7-bit resolution (they are rounded to the nearest degree). I'm assuming | 194 | 7-bit resolution (they are rounded to the nearest degree). I'm assuming |
200 | that the transfer function of the device is monotonic and smooth, so a | 195 | that the transfer function of the device is monotonic and smooth, so a |
201 | smooth function fit to the data will allow us to get better precision. | 196 | smooth function fit to the data will allow us to get better precision. |
202 | I used the 5th-order poly fit described above and solved for | 197 | I used the 5th-order poly fit described above and solved for |
203 | VIA register values 0-255. I *10 before rounding, so we get tenth-degree | 198 | VIA register values 0-255. I *10 before rounding, so we get tenth-degree |
204 | precision. (I could have done all 1024 values for our 10-bit readings, | 199 | precision. (I could have done all 1024 values for our 10-bit readings, |
205 | but the function is very linear in the useful range (0-80 deg C), so | 200 | but the function is very linear in the useful range (0-80 deg C), so |
206 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT | 201 | we'll just use linear interpolation for 10-bit readings.) So, tempLUT |
207 | is the temp at via register values 0-255: */ | 202 | is the temp at via register values 0-255: */ |
208 | static const long tempLUT[] = | 203 | static const long tempLUT[] = |
209 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, | 204 | { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, |
210 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, | 205 | -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, |
211 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, | 206 | -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, |
212 | -255, -246, -237, -229, -220, -212, -204, -196, -188, -180, | 207 | -255, -246, -237, -229, -220, -212, -204, -196, -188, -180, |
213 | -173, -166, -159, -152, -145, -139, -132, -126, -120, -114, | 208 | -173, -166, -159, -152, -145, -139, -132, -126, -120, -114, |
214 | -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49, | 209 | -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49, |
215 | -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16, | 210 | -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16, |
216 | 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84, | 211 | 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84, |
217 | 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138, | 212 | 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138, |
218 | 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189, | 213 | 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189, |
219 | 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241, | 214 | 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241, |
220 | 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294, | 215 | 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294, |
221 | 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348, | 216 | 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348, |
222 | 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404, | 217 | 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404, |
223 | 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464, | 218 | 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464, |
224 | 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532, | 219 | 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532, |
225 | 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614, | 220 | 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614, |
226 | 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718, | 221 | 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718, |
227 | 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856, | 222 | 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856, |
228 | 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044, | 223 | 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044, |
229 | 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252, | 224 | 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252, |
230 | 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462 | 225 | 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462 |
231 | }; | 226 | }; |
232 | 227 | ||
233 | /* the original LUT values from Alex van Kaam <darkside@chello.nl> | 228 | /* the original LUT values from Alex van Kaam <darkside@chello.nl> |
234 | (for via register values 12-240): | 229 | (for via register values 12-240): |
235 | {-50,-49,-47,-45,-43,-41,-39,-38,-37,-35,-34,-33,-32,-31, | 230 | {-50,-49,-47,-45,-43,-41,-39,-38,-37,-35,-34,-33,-32,-31, |
236 | -30,-29,-28,-27,-26,-25,-24,-24,-23,-22,-21,-20,-20,-19,-18,-17,-17,-16,-15, | 231 | -30,-29,-28,-27,-26,-25,-24,-24,-23,-22,-21,-20,-20,-19,-18,-17,-17,-16,-15, |
@@ -245,26 +240,26 @@ static const long tempLUT[] = | |||
245 | 240 | ||
246 | 241 | ||
247 | Here's the reverse LUT. I got it by doing a 6-th order poly fit (needed | 242 | Here's the reverse LUT. I got it by doing a 6-th order poly fit (needed |
248 | an extra term for a good fit to these inverse data!) and then | 243 | an extra term for a good fit to these inverse data!) and then |
249 | solving for each temp value from -50 to 110 (the useable range for | 244 | solving for each temp value from -50 to 110 (the useable range for |
250 | this chip). Here's the fit: | 245 | this chip). Here's the fit: |
251 | viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4 | 246 | viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4 |
252 | - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01) | 247 | - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01) |
253 | Note that n=161: */ | 248 | Note that n=161: */ |
254 | static const u8 viaLUT[] = | 249 | static const u8 viaLUT[] = |
255 | { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23, | 250 | { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23, |
256 | 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, | 251 | 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, |
257 | 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66, | 252 | 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66, |
258 | 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100, | 253 | 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100, |
259 | 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129, | 254 | 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129, |
260 | 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156, | 255 | 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156, |
261 | 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, | 256 | 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, |
262 | 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199, | 257 | 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199, |
263 | 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, | 258 | 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, |
264 | 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224, | 259 | 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224, |
265 | 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, | 260 | 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, |
266 | 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, | 261 | 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, |
267 | 239, 240 | 262 | 239, 240 |
268 | }; | 263 | }; |
269 | 264 | ||
270 | /* Converting temps to (8-bit) hyst and over registers | 265 | /* Converting temps to (8-bit) hyst and over registers |
@@ -272,7 +267,7 @@ static const u8 viaLUT[] = | |||
272 | The +50 is because the temps start at -50 */ | 267 | The +50 is because the temps start at -50 */ |
273 | static inline u8 TEMP_TO_REG(long val) | 268 | static inline u8 TEMP_TO_REG(long val) |
274 | { | 269 | { |
275 | return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 : | 270 | return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 : |
276 | (val < 0 ? val - 500 : val + 500) / 1000 + 50]; | 271 | (val < 0 ? val - 500 : val + 500) / 1000 + 50]; |
277 | } | 272 | } |
278 | 273 | ||
@@ -291,11 +286,9 @@ static inline long TEMP_FROM_REG10(u16 val) | |||
291 | 286 | ||
292 | /* do some linear interpolation */ | 287 | /* do some linear interpolation */ |
293 | return (tempLUT[eightBits] * (4 - twoBits) + | 288 | return (tempLUT[eightBits] * (4 - twoBits) + |
294 | tempLUT[eightBits + 1] * twoBits) * 25; | 289 | tempLUT[eightBits + 1] * twoBits) * 25; |
295 | } | 290 | } |
296 | 291 | ||
297 | #define ALARMS_FROM_REG(val) (val) | ||
298 | |||
299 | #define DIV_FROM_REG(val) (1 << (val)) | 292 | #define DIV_FROM_REG(val) (1 << (val)) |
300 | #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) | 293 | #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) |
301 | 294 | ||
@@ -358,28 +351,28 @@ static ssize_t show_in_max(struct device *dev, char *buf, int nr) { | |||
358 | return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr)); | 351 | return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr)); |
359 | } | 352 | } |
360 | 353 | ||
361 | static ssize_t set_in_min(struct device *dev, const char *buf, | 354 | static ssize_t set_in_min(struct device *dev, const char *buf, |
362 | size_t count, int nr) { | 355 | size_t count, int nr) { |
363 | struct i2c_client *client = to_i2c_client(dev); | 356 | struct i2c_client *client = to_i2c_client(dev); |
364 | struct via686a_data *data = i2c_get_clientdata(client); | 357 | struct via686a_data *data = i2c_get_clientdata(client); |
365 | unsigned long val = simple_strtoul(buf, NULL, 10); | 358 | unsigned long val = simple_strtoul(buf, NULL, 10); |
366 | 359 | ||
367 | down(&data->update_lock); | 360 | down(&data->update_lock); |
368 | data->in_min[nr] = IN_TO_REG(val,nr); | 361 | data->in_min[nr] = IN_TO_REG(val, nr); |
369 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), | 362 | via686a_write_value(client, VIA686A_REG_IN_MIN(nr), |
370 | data->in_min[nr]); | 363 | data->in_min[nr]); |
371 | up(&data->update_lock); | 364 | up(&data->update_lock); |
372 | return count; | 365 | return count; |
373 | } | 366 | } |
374 | static ssize_t set_in_max(struct device *dev, const char *buf, | 367 | static ssize_t set_in_max(struct device *dev, const char *buf, |
375 | size_t count, int nr) { | 368 | size_t count, int nr) { |
376 | struct i2c_client *client = to_i2c_client(dev); | 369 | struct i2c_client *client = to_i2c_client(dev); |
377 | struct via686a_data *data = i2c_get_clientdata(client); | 370 | struct via686a_data *data = i2c_get_clientdata(client); |
378 | unsigned long val = simple_strtoul(buf, NULL, 10); | 371 | unsigned long val = simple_strtoul(buf, NULL, 10); |
379 | 372 | ||
380 | down(&data->update_lock); | 373 | down(&data->update_lock); |
381 | data->in_max[nr] = IN_TO_REG(val,nr); | 374 | data->in_max[nr] = IN_TO_REG(val, nr); |
382 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), | 375 | via686a_write_value(client, VIA686A_REG_IN_MAX(nr), |
383 | data->in_max[nr]); | 376 | data->in_max[nr]); |
384 | up(&data->update_lock); | 377 | up(&data->update_lock); |
385 | return count; | 378 | return count; |
@@ -435,7 +428,7 @@ static ssize_t show_temp_hyst(struct device *dev, char *buf, int nr) { | |||
435 | struct via686a_data *data = via686a_update_device(dev); | 428 | struct via686a_data *data = via686a_update_device(dev); |
436 | return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr])); | 429 | return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr])); |
437 | } | 430 | } |
438 | static ssize_t set_temp_over(struct device *dev, const char *buf, | 431 | static ssize_t set_temp_over(struct device *dev, const char *buf, |
439 | size_t count, int nr) { | 432 | size_t count, int nr) { |
440 | struct i2c_client *client = to_i2c_client(dev); | 433 | struct i2c_client *client = to_i2c_client(dev); |
441 | struct via686a_data *data = i2c_get_clientdata(client); | 434 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -443,11 +436,12 @@ static ssize_t set_temp_over(struct device *dev, const char *buf, | |||
443 | 436 | ||
444 | down(&data->update_lock); | 437 | down(&data->update_lock); |
445 | data->temp_over[nr] = TEMP_TO_REG(val); | 438 | data->temp_over[nr] = TEMP_TO_REG(val); |
446 | via686a_write_value(client, VIA686A_REG_TEMP_OVER(nr), data->temp_over[nr]); | 439 | via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], |
440 | data->temp_over[nr]); | ||
447 | up(&data->update_lock); | 441 | up(&data->update_lock); |
448 | return count; | 442 | return count; |
449 | } | 443 | } |
450 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, | 444 | static ssize_t set_temp_hyst(struct device *dev, const char *buf, |
451 | size_t count, int nr) { | 445 | size_t count, int nr) { |
452 | struct i2c_client *client = to_i2c_client(dev); | 446 | struct i2c_client *client = to_i2c_client(dev); |
453 | struct via686a_data *data = i2c_get_clientdata(client); | 447 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -455,7 +449,8 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf, | |||
455 | 449 | ||
456 | down(&data->update_lock); | 450 | down(&data->update_lock); |
457 | data->temp_hyst[nr] = TEMP_TO_REG(val); | 451 | data->temp_hyst[nr] = TEMP_TO_REG(val); |
458 | via686a_write_value(client, VIA686A_REG_TEMP_HYST(nr), data->temp_hyst[nr]); | 452 | via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], |
453 | data->temp_hyst[nr]); | ||
459 | up(&data->update_lock); | 454 | up(&data->update_lock); |
460 | return count; | 455 | return count; |
461 | } | 456 | } |
@@ -488,7 +483,7 @@ static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);\ | |||
488 | static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | 483 | static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
489 | show_temp_##offset##_over, set_temp_##offset##_over); \ | 484 | show_temp_##offset##_over, set_temp_##offset##_over); \ |
490 | static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ | 485 | static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ |
491 | show_temp_##offset##_hyst, set_temp_##offset##_hyst); | 486 | show_temp_##offset##_hyst, set_temp_##offset##_hyst); |
492 | 487 | ||
493 | show_temp_offset(1); | 488 | show_temp_offset(1); |
494 | show_temp_offset(2); | 489 | show_temp_offset(2); |
@@ -497,19 +492,19 @@ show_temp_offset(3); | |||
497 | /* 2 Fans */ | 492 | /* 2 Fans */ |
498 | static ssize_t show_fan(struct device *dev, char *buf, int nr) { | 493 | static ssize_t show_fan(struct device *dev, char *buf, int nr) { |
499 | struct via686a_data *data = via686a_update_device(dev); | 494 | struct via686a_data *data = via686a_update_device(dev); |
500 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], | 495 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], |
501 | DIV_FROM_REG(data->fan_div[nr])) ); | 496 | DIV_FROM_REG(data->fan_div[nr])) ); |
502 | } | 497 | } |
503 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { | 498 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { |
504 | struct via686a_data *data = via686a_update_device(dev); | 499 | struct via686a_data *data = via686a_update_device(dev); |
505 | return sprintf(buf,"%d\n", | 500 | return sprintf(buf, "%d\n", |
506 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) ); | 501 | FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) ); |
507 | } | 502 | } |
508 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { | 503 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { |
509 | struct via686a_data *data = via686a_update_device(dev); | 504 | struct via686a_data *data = via686a_update_device(dev); |
510 | return sprintf(buf,"%d\n", DIV_FROM_REG(data->fan_div[nr]) ); | 505 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]) ); |
511 | } | 506 | } |
512 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 507 | static ssize_t set_fan_min(struct device *dev, const char *buf, |
513 | size_t count, int nr) { | 508 | size_t count, int nr) { |
514 | struct i2c_client *client = to_i2c_client(dev); | 509 | struct i2c_client *client = to_i2c_client(dev); |
515 | struct via686a_data *data = i2c_get_clientdata(client); | 510 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -521,7 +516,7 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
521 | up(&data->update_lock); | 516 | up(&data->update_lock); |
522 | return count; | 517 | return count; |
523 | } | 518 | } |
524 | static ssize_t set_fan_div(struct device *dev, const char *buf, | 519 | static ssize_t set_fan_div(struct device *dev, const char *buf, |
525 | size_t count, int nr) { | 520 | size_t count, int nr) { |
526 | struct i2c_client *client = to_i2c_client(dev); | 521 | struct i2c_client *client = to_i2c_client(dev); |
527 | struct via686a_data *data = i2c_get_clientdata(client); | 522 | struct via686a_data *data = i2c_get_clientdata(client); |
@@ -572,7 +567,7 @@ show_fan_offset(2); | |||
572 | /* Alarms */ | 567 | /* Alarms */ |
573 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) { | 568 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) { |
574 | struct via686a_data *data = via686a_update_device(dev); | 569 | struct via686a_data *data = via686a_update_device(dev); |
575 | return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); | 570 | return sprintf(buf, "%u\n", data->alarms); |
576 | } | 571 | } |
577 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 572 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
578 | 573 | ||
@@ -612,11 +607,12 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
612 | } | 607 | } |
613 | 608 | ||
614 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ | 609 | /* 8231 requires multiple of 256, we enforce that on 686 as well */ |
615 | if(force_addr) | 610 | if (force_addr) |
616 | address = force_addr & 0xFF00; | 611 | address = force_addr & 0xFF00; |
617 | 612 | ||
618 | if(force_addr) { | 613 | if (force_addr) { |
619 | dev_warn(&adapter->dev,"forcing ISA address 0x%04X\n", address); | 614 | dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", |
615 | address); | ||
620 | if (PCIBIOS_SUCCESSFUL != | 616 | if (PCIBIOS_SUCCESSFUL != |
621 | pci_write_config_word(s_bridge, VIA686A_BASE_REG, address)) | 617 | pci_write_config_word(s_bridge, VIA686A_BASE_REG, address)) |
622 | return -ENODEV; | 618 | return -ENODEV; |
@@ -625,17 +621,17 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
625 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) | 621 | pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) |
626 | return -ENODEV; | 622 | return -ENODEV; |
627 | if (!(val & 0x0001)) { | 623 | if (!(val & 0x0001)) { |
628 | dev_warn(&adapter->dev,"enabling sensors\n"); | 624 | dev_warn(&adapter->dev, "enabling sensors\n"); |
629 | if (PCIBIOS_SUCCESSFUL != | 625 | if (PCIBIOS_SUCCESSFUL != |
630 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, | 626 | pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, |
631 | val | 0x0001)) | 627 | val | 0x0001)) |
632 | return -ENODEV; | 628 | return -ENODEV; |
633 | } | 629 | } |
634 | 630 | ||
635 | /* Reserve the ISA region */ | 631 | /* Reserve the ISA region */ |
636 | if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { | 632 | if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { |
637 | dev_err(&adapter->dev,"region 0x%x already in use!\n", | 633 | dev_err(&adapter->dev, "region 0x%x already in use!\n", |
638 | address); | 634 | address); |
639 | return -ENODEV; | 635 | return -ENODEV; |
640 | } | 636 | } |
641 | 637 | ||
@@ -660,7 +656,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
660 | /* Tell the I2C layer a new client has arrived */ | 656 | /* Tell the I2C layer a new client has arrived */ |
661 | if ((err = i2c_attach_client(new_client))) | 657 | if ((err = i2c_attach_client(new_client))) |
662 | goto ERROR3; | 658 | goto ERROR3; |
663 | 659 | ||
664 | /* Initialize the VIA686A chip */ | 660 | /* Initialize the VIA686A chip */ |
665 | via686a_init_client(new_client); | 661 | via686a_init_client(new_client); |
666 | 662 | ||
@@ -699,9 +695,9 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) | |||
699 | 695 | ||
700 | return 0; | 696 | return 0; |
701 | 697 | ||
702 | ERROR3: | 698 | ERROR3: |
703 | kfree(data); | 699 | kfree(data); |
704 | ERROR0: | 700 | ERROR0: |
705 | release_region(address, VIA686A_EXTENT); | 701 | release_region(address, VIA686A_EXTENT); |
706 | return err; | 702 | return err; |
707 | } | 703 | } |
@@ -732,7 +728,7 @@ static void via686a_init_client(struct i2c_client *client) | |||
732 | via686a_write_value(client, VIA686A_REG_CONFIG, (reg|0x01)&0x7F); | 728 | via686a_write_value(client, VIA686A_REG_CONFIG, (reg|0x01)&0x7F); |
733 | 729 | ||
734 | /* Configure temp interrupt mode for continuous-interrupt operation */ | 730 | /* Configure temp interrupt mode for continuous-interrupt operation */ |
735 | via686a_write_value(client, VIA686A_REG_TEMP_MODE, | 731 | via686a_write_value(client, VIA686A_REG_TEMP_MODE, |
736 | via686a_read_value(client, VIA686A_REG_TEMP_MODE) & | 732 | via686a_read_value(client, VIA686A_REG_TEMP_MODE) & |
737 | !(VIA686A_TEMP_MODE_MASK | VIA686A_TEMP_MODE_CONTINUOUS)); | 733 | !(VIA686A_TEMP_MODE_MASK | VIA686A_TEMP_MODE_CONTINUOUS)); |
738 | } | 734 | } |
@@ -764,15 +760,15 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
764 | } | 760 | } |
765 | for (i = 0; i <= 2; i++) { | 761 | for (i = 0; i <= 2; i++) { |
766 | data->temp[i] = via686a_read_value(client, | 762 | data->temp[i] = via686a_read_value(client, |
767 | VIA686A_REG_TEMP(i)) << 2; | 763 | VIA686A_REG_TEMP[i]) << 2; |
768 | data->temp_over[i] = | 764 | data->temp_over[i] = |
769 | via686a_read_value(client, | 765 | via686a_read_value(client, |
770 | VIA686A_REG_TEMP_OVER(i)); | 766 | VIA686A_REG_TEMP_OVER[i]); |
771 | data->temp_hyst[i] = | 767 | data->temp_hyst[i] = |
772 | via686a_read_value(client, | 768 | via686a_read_value(client, |
773 | VIA686A_REG_TEMP_HYST(i)); | 769 | VIA686A_REG_TEMP_HYST[i]); |
774 | } | 770 | } |
775 | /* add in lower 2 bits | 771 | /* add in lower 2 bits |
776 | temp1 uses bits 7-6 of VIA686A_REG_TEMP_LOW1 | 772 | temp1 uses bits 7-6 of VIA686A_REG_TEMP_LOW1 |
777 | temp2 uses bits 5-4 of VIA686A_REG_TEMP_LOW23 | 773 | temp2 uses bits 5-4 of VIA686A_REG_TEMP_LOW23 |
778 | temp3 uses bits 7-6 of VIA686A_REG_TEMP_LOW23 | 774 | temp3 uses bits 7-6 of VIA686A_REG_TEMP_LOW23 |
@@ -804,35 +800,36 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
804 | } | 800 | } |
805 | 801 | ||
806 | static struct pci_device_id via686a_pci_ids[] = { | 802 | static struct pci_device_id via686a_pci_ids[] = { |
807 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, | 803 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, |
808 | { 0, } | 804 | { 0, } |
809 | }; | 805 | }; |
810 | 806 | ||
811 | MODULE_DEVICE_TABLE(pci, via686a_pci_ids); | 807 | MODULE_DEVICE_TABLE(pci, via686a_pci_ids); |
812 | 808 | ||
813 | static int __devinit via686a_pci_probe(struct pci_dev *dev, | 809 | static int __devinit via686a_pci_probe(struct pci_dev *dev, |
814 | const struct pci_device_id *id) | 810 | const struct pci_device_id *id) |
815 | { | 811 | { |
816 | u16 val; | 812 | u16 val; |
817 | int addr = 0; | 813 | int addr = 0; |
818 | 814 | ||
819 | if (PCIBIOS_SUCCESSFUL != | 815 | if (PCIBIOS_SUCCESSFUL != |
820 | pci_read_config_word(dev, VIA686A_BASE_REG, &val)) | 816 | pci_read_config_word(dev, VIA686A_BASE_REG, &val)) |
821 | return -ENODEV; | 817 | return -ENODEV; |
822 | 818 | ||
823 | addr = val & ~(VIA686A_EXTENT - 1); | 819 | addr = val & ~(VIA686A_EXTENT - 1); |
824 | if (addr == 0 && force_addr == 0) { | 820 | if (addr == 0 && force_addr == 0) { |
825 | dev_err(&dev->dev,"base address not set - upgrade BIOS or use force_addr=0xaddr\n"); | 821 | dev_err(&dev->dev, "base address not set - upgrade BIOS " |
826 | return -ENODEV; | 822 | "or use force_addr=0xaddr\n"); |
827 | } | 823 | return -ENODEV; |
828 | if (force_addr) | 824 | } |
829 | addr = force_addr; /* so detect will get called */ | 825 | if (force_addr) |
830 | 826 | addr = force_addr; /* so detect will get called */ | |
831 | if (!addr) { | 827 | |
832 | dev_err(&dev->dev,"No Via 686A sensors found.\n"); | 828 | if (!addr) { |
833 | return -ENODEV; | 829 | dev_err(&dev->dev, "No Via 686A sensors found.\n"); |
834 | } | 830 | return -ENODEV; |
835 | normal_isa[0] = addr; | 831 | } |
832 | normal_isa[0] = addr; | ||
836 | 833 | ||
837 | s_bridge = pci_dev_get(dev); | 834 | s_bridge = pci_dev_get(dev); |
838 | if (i2c_add_driver(&via686a_driver)) { | 835 | if (i2c_add_driver(&via686a_driver)) { |
@@ -848,14 +845,14 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev, | |||
848 | } | 845 | } |
849 | 846 | ||
850 | static struct pci_driver via686a_pci_driver = { | 847 | static struct pci_driver via686a_pci_driver = { |
851 | .name = "via686a", | 848 | .name = "via686a", |
852 | .id_table = via686a_pci_ids, | 849 | .id_table = via686a_pci_ids, |
853 | .probe = via686a_pci_probe, | 850 | .probe = via686a_pci_probe, |
854 | }; | 851 | }; |
855 | 852 | ||
856 | static int __init sm_via686a_init(void) | 853 | static int __init sm_via686a_init(void) |
857 | { | 854 | { |
858 | return pci_register_driver(&via686a_pci_driver); | 855 | return pci_register_driver(&via686a_pci_driver); |
859 | } | 856 | } |
860 | 857 | ||
861 | static void __exit sm_via686a_exit(void) | 858 | static void __exit sm_via686a_exit(void) |
@@ -869,8 +866,8 @@ static void __exit sm_via686a_exit(void) | |||
869 | } | 866 | } |
870 | 867 | ||
871 | MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>, " | 868 | MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>, " |
872 | "Mark Studebaker <mdsxyz123@yahoo.com> " | 869 | "Mark Studebaker <mdsxyz123@yahoo.com> " |
873 | "and Bob Dougherty <bobd@stanford.edu>"); | 870 | "and Bob Dougherty <bobd@stanford.edu>"); |
874 | MODULE_DESCRIPTION("VIA 686A Sensor device"); | 871 | MODULE_DESCRIPTION("VIA 686A Sensor device"); |
875 | MODULE_LICENSE("GPL"); | 872 | MODULE_LICENSE("GPL"); |
876 | 873 | ||
diff --git a/drivers/i2c/chips/w83627ehf.c b/drivers/i2c/chips/w83627ehf.c new file mode 100644 index 000000000000..8a40b6976e1a --- /dev/null +++ b/drivers/i2c/chips/w83627ehf.c | |||
@@ -0,0 +1,846 @@ | |||
1 | /* | ||
2 | w83627ehf - Driver for the hardware monitoring functionality of | ||
3 | the Winbond W83627EHF Super-I/O chip | ||
4 | Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> | ||
5 | |||
6 | Shamelessly ripped from the w83627hf driver | ||
7 | Copyright (C) 2003 Mark Studebaker | ||
8 | |||
9 | Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help | ||
10 | in testing and debugging this driver. | ||
11 | |||
12 | This program is free software; you can redistribute it and/or modify | ||
13 | it under the terms of the GNU General Public License as published by | ||
14 | the Free Software Foundation; either version 2 of the License, or | ||
15 | (at your option) any later version. | ||
16 | |||
17 | This program is distributed in the hope that it will be useful, | ||
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | GNU General Public License for more details. | ||
21 | |||
22 | You should have received a copy of the GNU General Public License | ||
23 | along with this program; if not, write to the Free Software | ||
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | |||
26 | |||
27 | Supports the following chips: | ||
28 | |||
29 | Chip #vin #fan #pwm #temp chip_id man_id | ||
30 | w83627ehf - 5 - 3 0x88 0x5ca3 | ||
31 | |||
32 | This is a preliminary version of the driver, only supporting the | ||
33 | fan and temperature inputs. The chip does much more than that. | ||
34 | */ | ||
35 | |||
36 | #include <linux/module.h> | ||
37 | #include <linux/init.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/i2c.h> | ||
40 | #include <linux/i2c-sensor.h> | ||
41 | #include <asm/io.h> | ||
42 | #include "lm75.h" | ||
43 | |||
44 | /* Addresses to scan | ||
45 | The actual ISA address is read from Super-I/O configuration space */ | ||
46 | static unsigned short normal_i2c[] = { I2C_CLIENT_END }; | ||
47 | static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END }; | ||
48 | |||
49 | /* Insmod parameters */ | ||
50 | SENSORS_INSMOD_1(w83627ehf); | ||
51 | |||
52 | /* | ||
53 | * Super-I/O constants and functions | ||
54 | */ | ||
55 | |||
56 | static int REG; /* The register to read/write */ | ||
57 | static int VAL; /* The value to read/write */ | ||
58 | |||
59 | #define W83627EHF_LD_HWM 0x0b | ||
60 | |||
61 | #define SIO_REG_LDSEL 0x07 /* Logical device select */ | ||
62 | #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ | ||
63 | #define SIO_REG_ENABLE 0x30 /* Logical device enable */ | ||
64 | #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ | ||
65 | |||
66 | #define SIO_W83627EHF_ID 0x8840 | ||
67 | #define SIO_ID_MASK 0xFFC0 | ||
68 | |||
69 | static inline void | ||
70 | superio_outb(int reg, int val) | ||
71 | { | ||
72 | outb(reg, REG); | ||
73 | outb(val, VAL); | ||
74 | } | ||
75 | |||
76 | static inline int | ||
77 | superio_inb(int reg) | ||
78 | { | ||
79 | outb(reg, REG); | ||
80 | return inb(VAL); | ||
81 | } | ||
82 | |||
83 | static inline void | ||
84 | superio_select(int ld) | ||
85 | { | ||
86 | outb(SIO_REG_LDSEL, REG); | ||
87 | outb(ld, VAL); | ||
88 | } | ||
89 | |||
90 | static inline void | ||
91 | superio_enter(void) | ||
92 | { | ||
93 | outb(0x87, REG); | ||
94 | outb(0x87, REG); | ||
95 | } | ||
96 | |||
97 | static inline void | ||
98 | superio_exit(void) | ||
99 | { | ||
100 | outb(0x02, REG); | ||
101 | outb(0x02, VAL); | ||
102 | } | ||
103 | |||
104 | /* | ||
105 | * ISA constants | ||
106 | */ | ||
107 | |||
108 | #define REGION_LENGTH 8 | ||
109 | #define ADDR_REG_OFFSET 5 | ||
110 | #define DATA_REG_OFFSET 6 | ||
111 | |||
112 | #define W83627EHF_REG_BANK 0x4E | ||
113 | #define W83627EHF_REG_CONFIG 0x40 | ||
114 | #define W83627EHF_REG_CHIP_ID 0x49 | ||
115 | #define W83627EHF_REG_MAN_ID 0x4F | ||
116 | |||
117 | static const u16 W83627EHF_REG_FAN[] = { 0x28, 0x29, 0x2a, 0x3f, 0x553 }; | ||
118 | static const u16 W83627EHF_REG_FAN_MIN[] = { 0x3b, 0x3c, 0x3d, 0x3e, 0x55c }; | ||
119 | |||
120 | #define W83627EHF_REG_TEMP1 0x27 | ||
121 | #define W83627EHF_REG_TEMP1_HYST 0x3a | ||
122 | #define W83627EHF_REG_TEMP1_OVER 0x39 | ||
123 | static const u16 W83627EHF_REG_TEMP[] = { 0x150, 0x250 }; | ||
124 | static const u16 W83627EHF_REG_TEMP_HYST[] = { 0x153, 0x253 }; | ||
125 | static const u16 W83627EHF_REG_TEMP_OVER[] = { 0x155, 0x255 }; | ||
126 | static const u16 W83627EHF_REG_TEMP_CONFIG[] = { 0x152, 0x252 }; | ||
127 | |||
128 | /* Fan clock dividers are spread over the following five registers */ | ||
129 | #define W83627EHF_REG_FANDIV1 0x47 | ||
130 | #define W83627EHF_REG_FANDIV2 0x4B | ||
131 | #define W83627EHF_REG_VBAT 0x5D | ||
132 | #define W83627EHF_REG_DIODE 0x59 | ||
133 | #define W83627EHF_REG_SMI_OVT 0x4C | ||
134 | |||
135 | /* | ||
136 | * Conversions | ||
137 | */ | ||
138 | |||
139 | static inline unsigned int | ||
140 | fan_from_reg(u8 reg, unsigned int div) | ||
141 | { | ||
142 | if (reg == 0 || reg == 255) | ||
143 | return 0; | ||
144 | return 1350000U / (reg * div); | ||
145 | } | ||
146 | |||
147 | static inline unsigned int | ||
148 | div_from_reg(u8 reg) | ||
149 | { | ||
150 | return 1 << reg; | ||
151 | } | ||
152 | |||
153 | static inline int | ||
154 | temp1_from_reg(s8 reg) | ||
155 | { | ||
156 | return reg * 1000; | ||
157 | } | ||
158 | |||
159 | static inline s8 | ||
160 | temp1_to_reg(int temp) | ||
161 | { | ||
162 | if (temp <= -128000) | ||
163 | return -128; | ||
164 | if (temp >= 127000) | ||
165 | return 127; | ||
166 | if (temp < 0) | ||
167 | return (temp - 500) / 1000; | ||
168 | return (temp + 500) / 1000; | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * Data structures and manipulation thereof | ||
173 | */ | ||
174 | |||
175 | struct w83627ehf_data { | ||
176 | struct i2c_client client; | ||
177 | struct semaphore lock; | ||
178 | |||
179 | struct semaphore update_lock; | ||
180 | char valid; /* !=0 if following fields are valid */ | ||
181 | unsigned long last_updated; /* In jiffies */ | ||
182 | |||
183 | /* Register values */ | ||
184 | u8 fan[5]; | ||
185 | u8 fan_min[5]; | ||
186 | u8 fan_div[5]; | ||
187 | u8 has_fan; /* some fan inputs can be disabled */ | ||
188 | s8 temp1; | ||
189 | s8 temp1_max; | ||
190 | s8 temp1_max_hyst; | ||
191 | s16 temp[2]; | ||
192 | s16 temp_max[2]; | ||
193 | s16 temp_max_hyst[2]; | ||
194 | }; | ||
195 | |||
196 | static inline int is_word_sized(u16 reg) | ||
197 | { | ||
198 | return (((reg & 0xff00) == 0x100 | ||
199 | || (reg & 0xff00) == 0x200) | ||
200 | && ((reg & 0x00ff) == 0x50 | ||
201 | || (reg & 0x00ff) == 0x53 | ||
202 | || (reg & 0x00ff) == 0x55)); | ||
203 | } | ||
204 | |||
205 | /* We assume that the default bank is 0, thus the following two functions do | ||
206 | nothing for registers which live in bank 0. For others, they respectively | ||
207 | set the bank register to the correct value (before the register is | ||
208 | accessed), and back to 0 (afterwards). */ | ||
209 | static inline void w83627ehf_set_bank(struct i2c_client *client, u16 reg) | ||
210 | { | ||
211 | if (reg & 0xff00) { | ||
212 | outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET); | ||
213 | outb_p(reg >> 8, client->addr + DATA_REG_OFFSET); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | static inline void w83627ehf_reset_bank(struct i2c_client *client, u16 reg) | ||
218 | { | ||
219 | if (reg & 0xff00) { | ||
220 | outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET); | ||
221 | outb_p(0, client->addr + DATA_REG_OFFSET); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) | ||
226 | { | ||
227 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
228 | int res, word_sized = is_word_sized(reg); | ||
229 | |||
230 | down(&data->lock); | ||
231 | |||
232 | w83627ehf_set_bank(client, reg); | ||
233 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | ||
234 | res = inb_p(client->addr + DATA_REG_OFFSET); | ||
235 | if (word_sized) { | ||
236 | outb_p((reg & 0xff) + 1, | ||
237 | client->addr + ADDR_REG_OFFSET); | ||
238 | res = (res << 8) + inb_p(client->addr + DATA_REG_OFFSET); | ||
239 | } | ||
240 | w83627ehf_reset_bank(client, reg); | ||
241 | |||
242 | up(&data->lock); | ||
243 | |||
244 | return res; | ||
245 | } | ||
246 | |||
247 | static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) | ||
248 | { | ||
249 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
250 | int word_sized = is_word_sized(reg); | ||
251 | |||
252 | down(&data->lock); | ||
253 | |||
254 | w83627ehf_set_bank(client, reg); | ||
255 | outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); | ||
256 | if (word_sized) { | ||
257 | outb_p(value >> 8, client->addr + DATA_REG_OFFSET); | ||
258 | outb_p((reg & 0xff) + 1, | ||
259 | client->addr + ADDR_REG_OFFSET); | ||
260 | } | ||
261 | outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); | ||
262 | w83627ehf_reset_bank(client, reg); | ||
263 | |||
264 | up(&data->lock); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | /* This function assumes that the caller holds data->update_lock */ | ||
269 | static void w83627ehf_write_fan_div(struct i2c_client *client, int nr) | ||
270 | { | ||
271 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
272 | u8 reg; | ||
273 | |||
274 | switch (nr) { | ||
275 | case 0: | ||
276 | reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0xcf) | ||
277 | | ((data->fan_div[0] & 0x03) << 4); | ||
278 | w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); | ||
279 | reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xdf) | ||
280 | | ((data->fan_div[0] & 0x04) << 3); | ||
281 | w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); | ||
282 | break; | ||
283 | case 1: | ||
284 | reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0x3f) | ||
285 | | ((data->fan_div[1] & 0x03) << 6); | ||
286 | w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); | ||
287 | reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xbf) | ||
288 | | ((data->fan_div[1] & 0x04) << 4); | ||
289 | w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); | ||
290 | break; | ||
291 | case 2: | ||
292 | reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV2) & 0x3f) | ||
293 | | ((data->fan_div[2] & 0x03) << 6); | ||
294 | w83627ehf_write_value(client, W83627EHF_REG_FANDIV2, reg); | ||
295 | reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0x7f) | ||
296 | | ((data->fan_div[2] & 0x04) << 5); | ||
297 | w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); | ||
298 | break; | ||
299 | case 3: | ||
300 | reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0xfc) | ||
301 | | (data->fan_div[3] & 0x03); | ||
302 | w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg); | ||
303 | reg = (w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT) & 0x7f) | ||
304 | | ((data->fan_div[3] & 0x04) << 5); | ||
305 | w83627ehf_write_value(client, W83627EHF_REG_SMI_OVT, reg); | ||
306 | break; | ||
307 | case 4: | ||
308 | reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0x73) | ||
309 | | ((data->fan_div[4] & 0x03) << 3) | ||
310 | | ((data->fan_div[4] & 0x04) << 5); | ||
311 | w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg); | ||
312 | break; | ||
313 | } | ||
314 | } | ||
315 | |||
316 | static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) | ||
317 | { | ||
318 | struct i2c_client *client = to_i2c_client(dev); | ||
319 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
320 | int i; | ||
321 | |||
322 | down(&data->update_lock); | ||
323 | |||
324 | if (time_after(jiffies, data->last_updated + HZ) | ||
325 | || !data->valid) { | ||
326 | /* Fan clock dividers */ | ||
327 | i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1); | ||
328 | data->fan_div[0] = (i >> 4) & 0x03; | ||
329 | data->fan_div[1] = (i >> 6) & 0x03; | ||
330 | i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV2); | ||
331 | data->fan_div[2] = (i >> 6) & 0x03; | ||
332 | i = w83627ehf_read_value(client, W83627EHF_REG_VBAT); | ||
333 | data->fan_div[0] |= (i >> 3) & 0x04; | ||
334 | data->fan_div[1] |= (i >> 4) & 0x04; | ||
335 | data->fan_div[2] |= (i >> 5) & 0x04; | ||
336 | if (data->has_fan & ((1 << 3) | (1 << 4))) { | ||
337 | i = w83627ehf_read_value(client, W83627EHF_REG_DIODE); | ||
338 | data->fan_div[3] = i & 0x03; | ||
339 | data->fan_div[4] = ((i >> 2) & 0x03) | ||
340 | | ((i >> 5) & 0x04); | ||
341 | } | ||
342 | if (data->has_fan & (1 << 3)) { | ||
343 | i = w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT); | ||
344 | data->fan_div[3] |= (i >> 5) & 0x04; | ||
345 | } | ||
346 | |||
347 | /* Measured fan speeds and limits */ | ||
348 | for (i = 0; i < 5; i++) { | ||
349 | if (!(data->has_fan & (1 << i))) | ||
350 | continue; | ||
351 | |||
352 | data->fan[i] = w83627ehf_read_value(client, | ||
353 | W83627EHF_REG_FAN[i]); | ||
354 | data->fan_min[i] = w83627ehf_read_value(client, | ||
355 | W83627EHF_REG_FAN_MIN[i]); | ||
356 | |||
357 | /* If we failed to measure the fan speed and clock | ||
358 | divider can be increased, let's try that for next | ||
359 | time */ | ||
360 | if (data->fan[i] == 0xff | ||
361 | && data->fan_div[i] < 0x07) { | ||
362 | dev_dbg(&client->dev, "Increasing fan %d " | ||
363 | "clock divider from %u to %u\n", | ||
364 | i, div_from_reg(data->fan_div[i]), | ||
365 | div_from_reg(data->fan_div[i] + 1)); | ||
366 | data->fan_div[i]++; | ||
367 | w83627ehf_write_fan_div(client, i); | ||
368 | /* Preserve min limit if possible */ | ||
369 | if (data->fan_min[i] >= 2 | ||
370 | && data->fan_min[i] != 255) | ||
371 | w83627ehf_write_value(client, | ||
372 | W83627EHF_REG_FAN_MIN[i], | ||
373 | (data->fan_min[i] /= 2)); | ||
374 | } | ||
375 | } | ||
376 | |||
377 | /* Measured temperatures and limits */ | ||
378 | data->temp1 = w83627ehf_read_value(client, | ||
379 | W83627EHF_REG_TEMP1); | ||
380 | data->temp1_max = w83627ehf_read_value(client, | ||
381 | W83627EHF_REG_TEMP1_OVER); | ||
382 | data->temp1_max_hyst = w83627ehf_read_value(client, | ||
383 | W83627EHF_REG_TEMP1_HYST); | ||
384 | for (i = 0; i < 2; i++) { | ||
385 | data->temp[i] = w83627ehf_read_value(client, | ||
386 | W83627EHF_REG_TEMP[i]); | ||
387 | data->temp_max[i] = w83627ehf_read_value(client, | ||
388 | W83627EHF_REG_TEMP_OVER[i]); | ||
389 | data->temp_max_hyst[i] = w83627ehf_read_value(client, | ||
390 | W83627EHF_REG_TEMP_HYST[i]); | ||
391 | } | ||
392 | |||
393 | data->last_updated = jiffies; | ||
394 | data->valid = 1; | ||
395 | } | ||
396 | |||
397 | up(&data->update_lock); | ||
398 | return data; | ||
399 | } | ||
400 | |||
401 | /* | ||
402 | * Sysfs callback functions | ||
403 | */ | ||
404 | |||
405 | #define show_fan_reg(reg) \ | ||
406 | static ssize_t \ | ||
407 | show_##reg(struct device *dev, char *buf, int nr) \ | ||
408 | { \ | ||
409 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | ||
410 | return sprintf(buf, "%d\n", \ | ||
411 | fan_from_reg(data->reg[nr], \ | ||
412 | div_from_reg(data->fan_div[nr]))); \ | ||
413 | } | ||
414 | show_fan_reg(fan); | ||
415 | show_fan_reg(fan_min); | ||
416 | |||
417 | static ssize_t | ||
418 | show_fan_div(struct device *dev, char *buf, int nr) | ||
419 | { | ||
420 | struct w83627ehf_data *data = w83627ehf_update_device(dev); | ||
421 | return sprintf(buf, "%u\n", | ||
422 | div_from_reg(data->fan_div[nr])); | ||
423 | } | ||
424 | |||
425 | static ssize_t | ||
426 | store_fan_min(struct device *dev, const char *buf, size_t count, int nr) | ||
427 | { | ||
428 | struct i2c_client *client = to_i2c_client(dev); | ||
429 | struct w83627ehf_data *data = i2c_get_clientdata(client); | ||
430 | unsigned int val = simple_strtoul(buf, NULL, 10); | ||
431 | unsigned int reg; | ||
432 | u8 new_div; | ||
433 | |||
434 | down(&data->update_lock); | ||
435 | if (!val) { | ||
436 | /* No min limit, alarm disabled */ | ||
437 | data->fan_min[nr] = 255; | ||
438 | new_div = data->fan_div[nr]; /* No change */ | ||
439 | dev_info(dev, "fan%u low limit and alarm disabled\n", nr + 1); | ||
440 | } else if ((reg = 1350000U / val) >= 128 * 255) { | ||
441 | /* Speed below this value cannot possibly be represented, | ||
442 | even with the highest divider (128) */ | ||
443 | data->fan_min[nr] = 254; | ||
444 | new_div = 7; /* 128 == (1 << 7) */ | ||
445 | dev_warn(dev, "fan%u low limit %u below minimum %u, set to " | ||
446 | "minimum\n", nr + 1, val, fan_from_reg(254, 128)); | ||
447 | } else if (!reg) { | ||
448 | /* Speed above this value cannot possibly be represented, | ||
449 | even with the lowest divider (1) */ | ||
450 | data->fan_min[nr] = 1; | ||
451 | new_div = 0; /* 1 == (1 << 0) */ | ||
452 | dev_warn(dev, "fan%u low limit %u above maximum %u, set to " | ||
453 | "maximum\n", nr + 1, val, fan_from_reg(1, 1)); | ||
454 | } else { | ||
455 | /* Automatically pick the best divider, i.e. the one such | ||
456 | that the min limit will correspond to a register value | ||
457 | in the 96..192 range */ | ||
458 | new_div = 0; | ||
459 | while (reg > 192 && new_div < 7) { | ||
460 | reg >>= 1; | ||
461 | new_div++; | ||
462 | } | ||
463 | data->fan_min[nr] = reg; | ||
464 | } | ||
465 | |||
466 | /* Write both the fan clock divider (if it changed) and the new | ||
467 | fan min (unconditionally) */ | ||
468 | if (new_div != data->fan_div[nr]) { | ||
469 | if (new_div > data->fan_div[nr]) | ||
470 | data->fan[nr] >>= (data->fan_div[nr] - new_div); | ||
471 | else | ||
472 | data->fan[nr] <<= (new_div - data->fan_div[nr]); | ||
473 | |||
474 | dev_dbg(dev, "fan%u clock divider changed from %u to %u\n", | ||
475 | nr + 1, div_from_reg(data->fan_div[nr]), | ||
476 | div_from_reg(new_div)); | ||
477 | data->fan_div[nr] = new_div; | ||
478 | w83627ehf_write_fan_div(client, nr); | ||
479 | } | ||
480 | w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], | ||
481 | data->fan_min[nr]); | ||
482 | up(&data->update_lock); | ||
483 | |||
484 | return count; | ||
485 | } | ||
486 | |||
487 | #define sysfs_fan_offset(offset) \ | ||
488 | static ssize_t \ | ||
489 | show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \ | ||
490 | char *buf) \ | ||
491 | { \ | ||
492 | return show_fan(dev, buf, offset-1); \ | ||
493 | } \ | ||
494 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
495 | show_reg_fan_##offset, NULL); | ||
496 | |||
497 | #define sysfs_fan_min_offset(offset) \ | ||
498 | static ssize_t \ | ||
499 | show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | ||
500 | char *buf) \ | ||
501 | { \ | ||
502 | return show_fan_min(dev, buf, offset-1); \ | ||
503 | } \ | ||
504 | static ssize_t \ | ||
505 | store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ | ||
506 | const char *buf, size_t count) \ | ||
507 | { \ | ||
508 | return store_fan_min(dev, buf, count, offset-1); \ | ||
509 | } \ | ||
510 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
511 | show_reg_fan##offset##_min, \ | ||
512 | store_reg_fan##offset##_min); | ||
513 | |||
514 | #define sysfs_fan_div_offset(offset) \ | ||
515 | static ssize_t \ | ||
516 | show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \ | ||
517 | char *buf) \ | ||
518 | { \ | ||
519 | return show_fan_div(dev, buf, offset - 1); \ | ||
520 | } \ | ||
521 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | ||
522 | show_reg_fan##offset##_div, NULL); | ||
523 | |||
524 | sysfs_fan_offset(1); | ||
525 | sysfs_fan_min_offset(1); | ||
526 | sysfs_fan_div_offset(1); | ||
527 | sysfs_fan_offset(2); | ||
528 | sysfs_fan_min_offset(2); | ||
529 | sysfs_fan_div_offset(2); | ||
530 | sysfs_fan_offset(3); | ||
531 | sysfs_fan_min_offset(3); | ||
532 | sysfs_fan_div_offset(3); | ||
533 | sysfs_fan_offset(4); | ||
534 | sysfs_fan_min_offset(4); | ||
535 | sysfs_fan_div_offset(4); | ||
536 | sysfs_fan_offset(5); | ||
537 | sysfs_fan_min_offset(5); | ||
538 | sysfs_fan_div_offset(5); | ||
539 | |||
540 | #define show_temp1_reg(reg) \ | ||
541 | static ssize_t \ | ||
542 | show_##reg(struct device *dev, struct device_attribute *attr, \ | ||
543 | char *buf) \ | ||
544 | { \ | ||
545 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | ||
546 | return sprintf(buf, "%d\n", temp1_from_reg(data->reg)); \ | ||
547 | } | ||
548 | show_temp1_reg(temp1); | ||
549 | show_temp1_reg(temp1_max); | ||
550 | show_temp1_reg(temp1_max_hyst); | ||
551 | |||
552 | #define store_temp1_reg(REG, reg) \ | ||
553 | static ssize_t \ | ||
554 | store_temp1_##reg(struct device *dev, struct device_attribute *attr, \ | ||
555 | const char *buf, size_t count) \ | ||
556 | { \ | ||
557 | struct i2c_client *client = to_i2c_client(dev); \ | ||
558 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | ||
559 | u32 val = simple_strtoul(buf, NULL, 10); \ | ||
560 | \ | ||
561 | down(&data->update_lock); \ | ||
562 | data->temp1_##reg = temp1_to_reg(val); \ | ||
563 | w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ | ||
564 | data->temp1_##reg); \ | ||
565 | up(&data->update_lock); \ | ||
566 | return count; \ | ||
567 | } | ||
568 | store_temp1_reg(OVER, max); | ||
569 | store_temp1_reg(HYST, max_hyst); | ||
570 | |||
571 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL); | ||
572 | static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR, | ||
573 | show_temp1_max, store_temp1_max); | ||
574 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR, | ||
575 | show_temp1_max_hyst, store_temp1_max_hyst); | ||
576 | |||
577 | #define show_temp_reg(reg) \ | ||
578 | static ssize_t \ | ||
579 | show_##reg (struct device *dev, char *buf, int nr) \ | ||
580 | { \ | ||
581 | struct w83627ehf_data *data = w83627ehf_update_device(dev); \ | ||
582 | return sprintf(buf, "%d\n", \ | ||
583 | LM75_TEMP_FROM_REG(data->reg[nr])); \ | ||
584 | } | ||
585 | show_temp_reg(temp); | ||
586 | show_temp_reg(temp_max); | ||
587 | show_temp_reg(temp_max_hyst); | ||
588 | |||
589 | #define store_temp_reg(REG, reg) \ | ||
590 | static ssize_t \ | ||
591 | store_##reg (struct device *dev, const char *buf, size_t count, int nr) \ | ||
592 | { \ | ||
593 | struct i2c_client *client = to_i2c_client(dev); \ | ||
594 | struct w83627ehf_data *data = i2c_get_clientdata(client); \ | ||
595 | u32 val = simple_strtoul(buf, NULL, 10); \ | ||
596 | \ | ||
597 | down(&data->update_lock); \ | ||
598 | data->reg[nr] = LM75_TEMP_TO_REG(val); \ | ||
599 | w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ | ||
600 | data->reg[nr]); \ | ||
601 | up(&data->update_lock); \ | ||
602 | return count; \ | ||
603 | } | ||
604 | store_temp_reg(OVER, temp_max); | ||
605 | store_temp_reg(HYST, temp_max_hyst); | ||
606 | |||
607 | #define sysfs_temp_offset(offset) \ | ||
608 | static ssize_t \ | ||
609 | show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \ | ||
610 | char *buf) \ | ||
611 | { \ | ||
612 | return show_temp(dev, buf, offset - 2); \ | ||
613 | } \ | ||
614 | static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | ||
615 | show_reg_temp##offset, NULL); | ||
616 | |||
617 | #define sysfs_temp_reg_offset(reg, offset) \ | ||
618 | static ssize_t \ | ||
619 | show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | ||
620 | char *buf) \ | ||
621 | { \ | ||
622 | return show_temp_##reg(dev, buf, offset - 2); \ | ||
623 | } \ | ||
624 | static ssize_t \ | ||
625 | store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ | ||
626 | const char *buf, size_t count) \ | ||
627 | { \ | ||
628 | return store_temp_##reg(dev, buf, count, offset - 2); \ | ||
629 | } \ | ||
630 | static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \ | ||
631 | show_reg_temp##offset##_##reg, \ | ||
632 | store_reg_temp##offset##_##reg); | ||
633 | |||
634 | sysfs_temp_offset(2); | ||
635 | sysfs_temp_reg_offset(max, 2); | ||
636 | sysfs_temp_reg_offset(max_hyst, 2); | ||
637 | sysfs_temp_offset(3); | ||
638 | sysfs_temp_reg_offset(max, 3); | ||
639 | sysfs_temp_reg_offset(max_hyst, 3); | ||
640 | |||
641 | /* | ||
642 | * Driver and client management | ||
643 | */ | ||
644 | |||
645 | static struct i2c_driver w83627ehf_driver; | ||
646 | |||
647 | static void w83627ehf_init_client(struct i2c_client *client) | ||
648 | { | ||
649 | int i; | ||
650 | u8 tmp; | ||
651 | |||
652 | /* Start monitoring is needed */ | ||
653 | tmp = w83627ehf_read_value(client, W83627EHF_REG_CONFIG); | ||
654 | if (!(tmp & 0x01)) | ||
655 | w83627ehf_write_value(client, W83627EHF_REG_CONFIG, | ||
656 | tmp | 0x01); | ||
657 | |||
658 | /* Enable temp2 and temp3 if needed */ | ||
659 | for (i = 0; i < 2; i++) { | ||
660 | tmp = w83627ehf_read_value(client, | ||
661 | W83627EHF_REG_TEMP_CONFIG[i]); | ||
662 | if (tmp & 0x01) | ||
663 | w83627ehf_write_value(client, | ||
664 | W83627EHF_REG_TEMP_CONFIG[i], | ||
665 | tmp & 0xfe); | ||
666 | } | ||
667 | } | ||
668 | |||
669 | static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) | ||
670 | { | ||
671 | struct i2c_client *client; | ||
672 | struct w83627ehf_data *data; | ||
673 | int i, err = 0; | ||
674 | |||
675 | if (!i2c_is_isa_adapter(adapter)) | ||
676 | return 0; | ||
677 | |||
678 | if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { | ||
679 | err = -EBUSY; | ||
680 | goto exit; | ||
681 | } | ||
682 | |||
683 | if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { | ||
684 | err = -ENOMEM; | ||
685 | goto exit_release; | ||
686 | } | ||
687 | memset(data, 0, sizeof(struct w83627ehf_data)); | ||
688 | |||
689 | client = &data->client; | ||
690 | i2c_set_clientdata(client, data); | ||
691 | client->addr = address; | ||
692 | init_MUTEX(&data->lock); | ||
693 | client->adapter = adapter; | ||
694 | client->driver = &w83627ehf_driver; | ||
695 | client->flags = 0; | ||
696 | |||
697 | strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); | ||
698 | data->valid = 0; | ||
699 | init_MUTEX(&data->update_lock); | ||
700 | |||
701 | /* Tell the i2c layer a new client has arrived */ | ||
702 | if ((err = i2c_attach_client(client))) | ||
703 | goto exit_free; | ||
704 | |||
705 | /* Initialize the chip */ | ||
706 | w83627ehf_init_client(client); | ||
707 | |||
708 | /* A few vars need to be filled upon startup */ | ||
709 | for (i = 0; i < 5; i++) | ||
710 | data->fan_min[i] = w83627ehf_read_value(client, | ||
711 | W83627EHF_REG_FAN_MIN[i]); | ||
712 | |||
713 | /* It looks like fan4 and fan5 pins can be alternatively used | ||
714 | as fan on/off switches */ | ||
715 | data->has_fan = 0x07; /* fan1, fan2 and fan3 */ | ||
716 | i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1); | ||
717 | if (i & (1 << 2)) | ||
718 | data->has_fan |= (1 << 3); | ||
719 | if (i & (1 << 0)) | ||
720 | data->has_fan |= (1 << 4); | ||
721 | |||
722 | /* Register sysfs hooks */ | ||
723 | device_create_file(&client->dev, &dev_attr_fan1_input); | ||
724 | device_create_file(&client->dev, &dev_attr_fan1_min); | ||
725 | device_create_file(&client->dev, &dev_attr_fan1_div); | ||
726 | device_create_file(&client->dev, &dev_attr_fan2_input); | ||
727 | device_create_file(&client->dev, &dev_attr_fan2_min); | ||
728 | device_create_file(&client->dev, &dev_attr_fan2_div); | ||
729 | device_create_file(&client->dev, &dev_attr_fan3_input); | ||
730 | device_create_file(&client->dev, &dev_attr_fan3_min); | ||
731 | device_create_file(&client->dev, &dev_attr_fan3_div); | ||
732 | |||
733 | if (data->has_fan & (1 << 3)) { | ||
734 | device_create_file(&client->dev, &dev_attr_fan4_input); | ||
735 | device_create_file(&client->dev, &dev_attr_fan4_min); | ||
736 | device_create_file(&client->dev, &dev_attr_fan4_div); | ||
737 | } | ||
738 | if (data->has_fan & (1 << 4)) { | ||
739 | device_create_file(&client->dev, &dev_attr_fan5_input); | ||
740 | device_create_file(&client->dev, &dev_attr_fan5_min); | ||
741 | device_create_file(&client->dev, &dev_attr_fan5_div); | ||
742 | } | ||
743 | |||
744 | device_create_file(&client->dev, &dev_attr_temp1_input); | ||
745 | device_create_file(&client->dev, &dev_attr_temp1_max); | ||
746 | device_create_file(&client->dev, &dev_attr_temp1_max_hyst); | ||
747 | device_create_file(&client->dev, &dev_attr_temp2_input); | ||
748 | device_create_file(&client->dev, &dev_attr_temp2_max); | ||
749 | device_create_file(&client->dev, &dev_attr_temp2_max_hyst); | ||
750 | device_create_file(&client->dev, &dev_attr_temp3_input); | ||
751 | device_create_file(&client->dev, &dev_attr_temp3_max); | ||
752 | device_create_file(&client->dev, &dev_attr_temp3_max_hyst); | ||
753 | |||
754 | return 0; | ||
755 | |||
756 | exit_free: | ||
757 | kfree(data); | ||
758 | exit_release: | ||
759 | release_region(address, REGION_LENGTH); | ||
760 | exit: | ||
761 | return err; | ||
762 | } | ||
763 | |||
764 | static int w83627ehf_attach_adapter(struct i2c_adapter *adapter) | ||
765 | { | ||
766 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
767 | return 0; | ||
768 | return i2c_detect(adapter, &addr_data, w83627ehf_detect); | ||
769 | } | ||
770 | |||
771 | static int w83627ehf_detach_client(struct i2c_client *client) | ||
772 | { | ||
773 | int err; | ||
774 | |||
775 | if ((err = i2c_detach_client(client))) { | ||
776 | dev_err(&client->dev, "Client deregistration failed, " | ||
777 | "client not detached.\n"); | ||
778 | return err; | ||
779 | } | ||
780 | release_region(client->addr, REGION_LENGTH); | ||
781 | kfree(i2c_get_clientdata(client)); | ||
782 | |||
783 | return 0; | ||
784 | } | ||
785 | |||
786 | static struct i2c_driver w83627ehf_driver = { | ||
787 | .owner = THIS_MODULE, | ||
788 | .name = "w83627ehf", | ||
789 | .flags = I2C_DF_NOTIFY, | ||
790 | .attach_adapter = w83627ehf_attach_adapter, | ||
791 | .detach_client = w83627ehf_detach_client, | ||
792 | }; | ||
793 | |||
794 | static int __init w83627ehf_find(int sioaddr, int *address) | ||
795 | { | ||
796 | u16 val; | ||
797 | |||
798 | REG = sioaddr; | ||
799 | VAL = sioaddr + 1; | ||
800 | superio_enter(); | ||
801 | |||
802 | val = (superio_inb(SIO_REG_DEVID) << 8) | ||
803 | | superio_inb(SIO_REG_DEVID + 1); | ||
804 | if ((val & SIO_ID_MASK) != SIO_W83627EHF_ID) { | ||
805 | superio_exit(); | ||
806 | return -ENODEV; | ||
807 | } | ||
808 | |||
809 | superio_select(W83627EHF_LD_HWM); | ||
810 | val = (superio_inb(SIO_REG_ADDR) << 8) | ||
811 | | superio_inb(SIO_REG_ADDR + 1); | ||
812 | *address = val & ~(REGION_LENGTH - 1); | ||
813 | if (*address == 0) { | ||
814 | superio_exit(); | ||
815 | return -ENODEV; | ||
816 | } | ||
817 | |||
818 | /* Activate logical device if needed */ | ||
819 | val = superio_inb(SIO_REG_ENABLE); | ||
820 | if (!(val & 0x01)) | ||
821 | superio_outb(SIO_REG_ENABLE, val | 0x01); | ||
822 | |||
823 | superio_exit(); | ||
824 | return 0; | ||
825 | } | ||
826 | |||
827 | static int __init sensors_w83627ehf_init(void) | ||
828 | { | ||
829 | if (w83627ehf_find(0x2e, &normal_isa[0]) | ||
830 | && w83627ehf_find(0x4e, &normal_isa[0])) | ||
831 | return -ENODEV; | ||
832 | |||
833 | return i2c_add_driver(&w83627ehf_driver); | ||
834 | } | ||
835 | |||
836 | static void __exit sensors_w83627ehf_exit(void) | ||
837 | { | ||
838 | i2c_del_driver(&w83627ehf_driver); | ||
839 | } | ||
840 | |||
841 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); | ||
842 | MODULE_DESCRIPTION("W83627EHF driver"); | ||
843 | MODULE_LICENSE("GPL"); | ||
844 | |||
845 | module_init(sensors_w83627ehf_init); | ||
846 | module_exit(sensors_w83627ehf_exit); | ||
diff --git a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c index 4f1bff572c1c..bd87a42e068a 100644 --- a/drivers/i2c/chips/w83627hf.c +++ b/drivers/i2c/chips/w83627hf.c | |||
@@ -264,7 +264,7 @@ static inline u8 DIV_TO_REG(long val) | |||
264 | { | 264 | { |
265 | int i; | 265 | int i; |
266 | val = SENSORS_LIMIT(val, 1, 128) >> 1; | 266 | val = SENSORS_LIMIT(val, 1, 128) >> 1; |
267 | for (i = 0; i < 6; i++) { | 267 | for (i = 0; i < 7; i++) { |
268 | if (val == 0) | 268 | if (val == 0) |
269 | break; | 269 | break; |
270 | val >>= 1; | 270 | val >>= 1; |
diff --git a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c index c3926d2d8ac6..0bb131ce09eb 100644 --- a/drivers/i2c/chips/w83781d.c +++ b/drivers/i2c/chips/w83781d.c | |||
@@ -28,14 +28,11 @@ | |||
28 | as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no | 28 | as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no |
29 | w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes | 29 | w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes |
30 | w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC) | 30 | w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC) |
31 | w83627thf 9 3 2 3 0x90 0x5ca3 no yes(LPC) | ||
32 | w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes | 31 | w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes |
33 | w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no | 32 | w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no |
34 | w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) | ||
35 | 33 | ||
36 | */ | 34 | */ |
37 | 35 | ||
38 | #include <linux/config.h> | ||
39 | #include <linux/module.h> | 36 | #include <linux/module.h> |
40 | #include <linux/init.h> | 37 | #include <linux/init.h> |
41 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
@@ -53,7 +50,7 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, | |||
53 | static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; | 50 | static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; |
54 | 51 | ||
55 | /* Insmod parameters */ | 52 | /* Insmod parameters */ |
56 | SENSORS_INSMOD_6(w83781d, w83782d, w83783s, w83627hf, as99127f, w83697hf); | 53 | SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); |
57 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " | 54 | I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " |
58 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); | 55 | "{bus, clientaddr, subclientaddr1, subclientaddr2}"); |
59 | 56 | ||
@@ -173,7 +170,6 @@ FAN_TO_REG(long rpm, int div) | |||
173 | : (val)) / 1000, 0, 0xff)) | 170 | : (val)) / 1000, 0, 0xff)) |
174 | #define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000) | 171 | #define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000) |
175 | 172 | ||
176 | #define ALARMS_FROM_REG(val) (val) | ||
177 | #define PWM_FROM_REG(val) (val) | 173 | #define PWM_FROM_REG(val) (val) |
178 | #define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255)) | 174 | #define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255)) |
179 | #define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \ | 175 | #define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \ |
@@ -193,7 +189,7 @@ DIV_TO_REG(long val, enum chips type) | |||
193 | val = SENSORS_LIMIT(val, 1, | 189 | val = SENSORS_LIMIT(val, 1, |
194 | ((type == w83781d | 190 | ((type == w83781d |
195 | || type == as99127f) ? 8 : 128)) >> 1; | 191 | || type == as99127f) ? 8 : 128)) >> 1; |
196 | for (i = 0; i < 6; i++) { | 192 | for (i = 0; i < 7; i++) { |
197 | if (val == 0) | 193 | if (val == 0) |
198 | break; | 194 | break; |
199 | val >>= 1; | 195 | val >>= 1; |
@@ -524,7 +520,7 @@ static ssize_t | |||
524 | show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | 520 | show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) |
525 | { | 521 | { |
526 | struct w83781d_data *data = w83781d_update_device(dev); | 522 | struct w83781d_data *data = w83781d_update_device(dev); |
527 | return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); | 523 | return sprintf(buf, "%u\n", data->alarms); |
528 | } | 524 | } |
529 | 525 | ||
530 | static | 526 | static |
@@ -1000,13 +996,6 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1000 | err = -EINVAL; | 996 | err = -EINVAL; |
1001 | goto ERROR0; | 997 | goto ERROR0; |
1002 | } | 998 | } |
1003 | if (!is_isa && kind == w83697hf) { | ||
1004 | dev_err(&adapter->dev, | ||
1005 | "Cannot force ISA-only chip for I2C address 0x%02x.\n", | ||
1006 | address); | ||
1007 | err = -EINVAL; | ||
1008 | goto ERROR0; | ||
1009 | } | ||
1010 | 999 | ||
1011 | if (is_isa) | 1000 | if (is_isa) |
1012 | if (!request_region(address, W83781D_EXTENT, | 1001 | if (!request_region(address, W83781D_EXTENT, |
@@ -1139,12 +1128,10 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1139 | else if (val1 == 0x40 && vendid == winbond && !is_isa | 1128 | else if (val1 == 0x40 && vendid == winbond && !is_isa |
1140 | && address == 0x2d) | 1129 | && address == 0x2d) |
1141 | kind = w83783s; | 1130 | kind = w83783s; |
1142 | else if ((val1 == 0x21 || val1 == 0x90) && vendid == winbond) | 1131 | else if (val1 == 0x21 && vendid == winbond) |
1143 | kind = w83627hf; | 1132 | kind = w83627hf; |
1144 | else if (val1 == 0x31 && !is_isa && address >= 0x28) | 1133 | else if (val1 == 0x31 && !is_isa && address >= 0x28) |
1145 | kind = as99127f; | 1134 | kind = as99127f; |
1146 | else if (val1 == 0x60 && vendid == winbond && is_isa) | ||
1147 | kind = w83697hf; | ||
1148 | else { | 1135 | else { |
1149 | if (kind == 0) | 1136 | if (kind == 0) |
1150 | dev_warn(&new_client->dev, "Ignoring 'force' " | 1137 | dev_warn(&new_client->dev, "Ignoring 'force' " |
@@ -1163,14 +1150,9 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1163 | } else if (kind == w83783s) { | 1150 | } else if (kind == w83783s) { |
1164 | client_name = "w83783s"; | 1151 | client_name = "w83783s"; |
1165 | } else if (kind == w83627hf) { | 1152 | } else if (kind == w83627hf) { |
1166 | if (val1 == 0x90) | 1153 | client_name = "w83627hf"; |
1167 | client_name = "w83627thf"; | ||
1168 | else | ||
1169 | client_name = "w83627hf"; | ||
1170 | } else if (kind == as99127f) { | 1154 | } else if (kind == as99127f) { |
1171 | client_name = "as99127f"; | 1155 | client_name = "as99127f"; |
1172 | } else if (kind == w83697hf) { | ||
1173 | client_name = "w83697hf"; | ||
1174 | } | 1156 | } |
1175 | 1157 | ||
1176 | /* Fill in the remaining client fields and put into the global list */ | 1158 | /* Fill in the remaining client fields and put into the global list */ |
@@ -1208,7 +1190,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1208 | 1190 | ||
1209 | /* Register sysfs hooks */ | 1191 | /* Register sysfs hooks */ |
1210 | device_create_file_in(new_client, 0); | 1192 | device_create_file_in(new_client, 0); |
1211 | if (kind != w83783s && kind != w83697hf) | 1193 | if (kind != w83783s) |
1212 | device_create_file_in(new_client, 1); | 1194 | device_create_file_in(new_client, 1); |
1213 | device_create_file_in(new_client, 2); | 1195 | device_create_file_in(new_client, 2); |
1214 | device_create_file_in(new_client, 3); | 1196 | device_create_file_in(new_client, 3); |
@@ -1222,24 +1204,19 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1222 | 1204 | ||
1223 | device_create_file_fan(new_client, 1); | 1205 | device_create_file_fan(new_client, 1); |
1224 | device_create_file_fan(new_client, 2); | 1206 | device_create_file_fan(new_client, 2); |
1225 | if (kind != w83697hf) | 1207 | device_create_file_fan(new_client, 3); |
1226 | device_create_file_fan(new_client, 3); | ||
1227 | 1208 | ||
1228 | device_create_file_temp(new_client, 1); | 1209 | device_create_file_temp(new_client, 1); |
1229 | device_create_file_temp(new_client, 2); | 1210 | device_create_file_temp(new_client, 2); |
1230 | if (kind != w83783s && kind != w83697hf) | 1211 | if (kind != w83783s) |
1231 | device_create_file_temp(new_client, 3); | 1212 | device_create_file_temp(new_client, 3); |
1232 | 1213 | ||
1233 | if (kind != w83697hf) | 1214 | device_create_file_vid(new_client); |
1234 | device_create_file_vid(new_client); | 1215 | device_create_file_vrm(new_client); |
1235 | |||
1236 | if (kind != w83697hf) | ||
1237 | device_create_file_vrm(new_client); | ||
1238 | 1216 | ||
1239 | device_create_file_fan_div(new_client, 1); | 1217 | device_create_file_fan_div(new_client, 1); |
1240 | device_create_file_fan_div(new_client, 2); | 1218 | device_create_file_fan_div(new_client, 2); |
1241 | if (kind != w83697hf) | 1219 | device_create_file_fan_div(new_client, 3); |
1242 | device_create_file_fan_div(new_client, 3); | ||
1243 | 1220 | ||
1244 | device_create_file_alarms(new_client); | 1221 | device_create_file_alarms(new_client); |
1245 | 1222 | ||
@@ -1258,7 +1235,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1258 | if (kind != as99127f && kind != w83781d) { | 1235 | if (kind != as99127f && kind != w83781d) { |
1259 | device_create_file_sensor(new_client, 1); | 1236 | device_create_file_sensor(new_client, 1); |
1260 | device_create_file_sensor(new_client, 2); | 1237 | device_create_file_sensor(new_client, 2); |
1261 | if (kind != w83783s && kind != w83697hf) | 1238 | if (kind != w83783s) |
1262 | device_create_file_sensor(new_client, 3); | 1239 | device_create_file_sensor(new_client, 3); |
1263 | } | 1240 | } |
1264 | 1241 | ||
@@ -1481,7 +1458,7 @@ w83781d_init_client(struct i2c_client *client) | |||
1481 | else | 1458 | else |
1482 | data->sens[i - 1] = 2; | 1459 | data->sens[i - 1] = 2; |
1483 | } | 1460 | } |
1484 | if ((type == w83783s || type == w83697hf) && (i == 2)) | 1461 | if (type == w83783s && i == 2) |
1485 | break; | 1462 | break; |
1486 | } | 1463 | } |
1487 | } | 1464 | } |
@@ -1497,7 +1474,7 @@ w83781d_init_client(struct i2c_client *client) | |||
1497 | } | 1474 | } |
1498 | 1475 | ||
1499 | /* Enable temp3 */ | 1476 | /* Enable temp3 */ |
1500 | if (type != w83783s && type != w83697hf) { | 1477 | if (type != w83783s) { |
1501 | tmp = w83781d_read_value(client, | 1478 | tmp = w83781d_read_value(client, |
1502 | W83781D_REG_TEMP3_CONFIG); | 1479 | W83781D_REG_TEMP3_CONFIG); |
1503 | if (tmp & 0x01) { | 1480 | if (tmp & 0x01) { |
@@ -1538,8 +1515,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1538 | dev_dbg(dev, "Starting device update\n"); | 1515 | dev_dbg(dev, "Starting device update\n"); |
1539 | 1516 | ||
1540 | for (i = 0; i <= 8; i++) { | 1517 | for (i = 0; i <= 8; i++) { |
1541 | if ((data->type == w83783s || data->type == w83697hf) | 1518 | if (data->type == w83783s && i == 1) |
1542 | && (i == 1)) | ||
1543 | continue; /* 783S has no in1 */ | 1519 | continue; /* 783S has no in1 */ |
1544 | data->in[i] = | 1520 | data->in[i] = |
1545 | w83781d_read_value(client, W83781D_REG_IN(i)); | 1521 | w83781d_read_value(client, W83781D_REG_IN(i)); |
@@ -1547,7 +1523,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1547 | w83781d_read_value(client, W83781D_REG_IN_MIN(i)); | 1523 | w83781d_read_value(client, W83781D_REG_IN_MIN(i)); |
1548 | data->in_max[i] = | 1524 | data->in_max[i] = |
1549 | w83781d_read_value(client, W83781D_REG_IN_MAX(i)); | 1525 | w83781d_read_value(client, W83781D_REG_IN_MAX(i)); |
1550 | if ((data->type != w83782d) && (data->type != w83697hf) | 1526 | if ((data->type != w83782d) |
1551 | && (data->type != w83627hf) && (i == 6)) | 1527 | && (data->type != w83627hf) && (i == 6)) |
1552 | break; | 1528 | break; |
1553 | } | 1529 | } |
@@ -1583,7 +1559,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1583 | w83781d_read_value(client, W83781D_REG_TEMP_OVER(2)); | 1559 | w83781d_read_value(client, W83781D_REG_TEMP_OVER(2)); |
1584 | data->temp_max_hyst_add[0] = | 1560 | data->temp_max_hyst_add[0] = |
1585 | w83781d_read_value(client, W83781D_REG_TEMP_HYST(2)); | 1561 | w83781d_read_value(client, W83781D_REG_TEMP_HYST(2)); |
1586 | if (data->type != w83783s && data->type != w83697hf) { | 1562 | if (data->type != w83783s) { |
1587 | data->temp_add[1] = | 1563 | data->temp_add[1] = |
1588 | w83781d_read_value(client, W83781D_REG_TEMP(3)); | 1564 | w83781d_read_value(client, W83781D_REG_TEMP(3)); |
1589 | data->temp_max_add[1] = | 1565 | data->temp_max_add[1] = |
@@ -1594,26 +1570,18 @@ static struct w83781d_data *w83781d_update_device(struct device *dev) | |||
1594 | W83781D_REG_TEMP_HYST(3)); | 1570 | W83781D_REG_TEMP_HYST(3)); |
1595 | } | 1571 | } |
1596 | i = w83781d_read_value(client, W83781D_REG_VID_FANDIV); | 1572 | i = w83781d_read_value(client, W83781D_REG_VID_FANDIV); |
1597 | if (data->type != w83697hf) { | 1573 | data->vid = i & 0x0f; |
1598 | data->vid = i & 0x0f; | 1574 | data->vid |= (w83781d_read_value(client, |
1599 | data->vid |= | 1575 | W83781D_REG_CHIPID) & 0x01) << 4; |
1600 | (w83781d_read_value(client, W83781D_REG_CHIPID) & | ||
1601 | 0x01) | ||
1602 | << 4; | ||
1603 | } | ||
1604 | data->fan_div[0] = (i >> 4) & 0x03; | 1576 | data->fan_div[0] = (i >> 4) & 0x03; |
1605 | data->fan_div[1] = (i >> 6) & 0x03; | 1577 | data->fan_div[1] = (i >> 6) & 0x03; |
1606 | if (data->type != w83697hf) { | 1578 | data->fan_div[2] = (w83781d_read_value(client, |
1607 | data->fan_div[2] = (w83781d_read_value(client, | 1579 | W83781D_REG_PIN) >> 6) & 0x03; |
1608 | W83781D_REG_PIN) | ||
1609 | >> 6) & 0x03; | ||
1610 | } | ||
1611 | if ((data->type != w83781d) && (data->type != as99127f)) { | 1580 | if ((data->type != w83781d) && (data->type != as99127f)) { |
1612 | i = w83781d_read_value(client, W83781D_REG_VBAT); | 1581 | i = w83781d_read_value(client, W83781D_REG_VBAT); |
1613 | data->fan_div[0] |= (i >> 3) & 0x04; | 1582 | data->fan_div[0] |= (i >> 3) & 0x04; |
1614 | data->fan_div[1] |= (i >> 4) & 0x04; | 1583 | data->fan_div[1] |= (i >> 4) & 0x04; |
1615 | if (data->type != w83697hf) | 1584 | data->fan_div[2] |= (i >> 5) & 0x04; |
1616 | data->fan_div[2] |= (i >> 5) & 0x04; | ||
1617 | } | 1585 | } |
1618 | data->alarms = | 1586 | data->alarms = |
1619 | w83781d_read_value(client, | 1587 | w83781d_read_value(client, |
diff --git a/drivers/i2c/chips/w83l785ts.c b/drivers/i2c/chips/w83l785ts.c index 74d4b58e4237..4469d52aba4c 100644 --- a/drivers/i2c/chips/w83l785ts.c +++ b/drivers/i2c/chips/w83l785ts.c | |||
@@ -30,7 +30,6 @@ | |||
30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #include <linux/config.h> | ||
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index a22e53badacb..51ce268998cd 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -21,7 +21,6 @@ | |||
21 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> | 21 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> |
22 | SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ | 22 | SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
27 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
@@ -239,7 +238,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
239 | } | 238 | } |
240 | 239 | ||
241 | /* detach any active clients. This must be done first, because | 240 | /* detach any active clients. This must be done first, because |
242 | * it can fail; in which case we give upp. */ | 241 | * it can fail; in which case we give up. */ |
243 | list_for_each_safe(item, _n, &adap->clients) { | 242 | list_for_each_safe(item, _n, &adap->clients) { |
244 | client = list_entry(item, struct i2c_client, list); | 243 | client = list_entry(item, struct i2c_client, list); |
245 | 244 | ||
@@ -612,27 +611,16 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count) | |||
612 | struct i2c_adapter *adap=client->adapter; | 611 | struct i2c_adapter *adap=client->adapter; |
613 | struct i2c_msg msg; | 612 | struct i2c_msg msg; |
614 | 613 | ||
615 | if (client->adapter->algo->master_xfer) { | 614 | msg.addr = client->addr; |
616 | msg.addr = client->addr; | 615 | msg.flags = client->flags & I2C_M_TEN; |
617 | msg.flags = client->flags & I2C_M_TEN; | 616 | msg.len = count; |
618 | msg.len = count; | 617 | msg.buf = (char *)buf; |
619 | msg.buf = (char *)buf; | ||
620 | 618 | ||
621 | dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n", | 619 | ret = i2c_transfer(adap, &msg, 1); |
622 | count); | ||
623 | |||
624 | down(&adap->bus_lock); | ||
625 | ret = adap->algo->master_xfer(adap,&msg,1); | ||
626 | up(&adap->bus_lock); | ||
627 | 620 | ||
628 | /* if everything went ok (i.e. 1 msg transmitted), return #bytes | 621 | /* If everything went ok (i.e. 1 msg transmitted), return #bytes |
629 | * transmitted, else error code. | 622 | transmitted, else error code. */ |
630 | */ | 623 | return (ret == 1) ? count : ret; |
631 | return (ret == 1 )? count : ret; | ||
632 | } else { | ||
633 | dev_err(&client->adapter->dev, "I2C level transfers not supported\n"); | ||
634 | return -ENOSYS; | ||
635 | } | ||
636 | } | 624 | } |
637 | 625 | ||
638 | int i2c_master_recv(struct i2c_client *client, char *buf ,int count) | 626 | int i2c_master_recv(struct i2c_client *client, char *buf ,int count) |
@@ -640,31 +628,18 @@ int i2c_master_recv(struct i2c_client *client, char *buf ,int count) | |||
640 | struct i2c_adapter *adap=client->adapter; | 628 | struct i2c_adapter *adap=client->adapter; |
641 | struct i2c_msg msg; | 629 | struct i2c_msg msg; |
642 | int ret; | 630 | int ret; |
643 | if (client->adapter->algo->master_xfer) { | 631 | |
644 | msg.addr = client->addr; | 632 | msg.addr = client->addr; |
645 | msg.flags = client->flags & I2C_M_TEN; | 633 | msg.flags = client->flags & I2C_M_TEN; |
646 | msg.flags |= I2C_M_RD; | 634 | msg.flags |= I2C_M_RD; |
647 | msg.len = count; | 635 | msg.len = count; |
648 | msg.buf = buf; | 636 | msg.buf = buf; |
649 | 637 | ||
650 | dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n", | 638 | ret = i2c_transfer(adap, &msg, 1); |
651 | count); | 639 | |
652 | 640 | /* If everything went ok (i.e. 1 msg transmitted), return #bytes | |
653 | down(&adap->bus_lock); | 641 | transmitted, else error code. */ |
654 | ret = adap->algo->master_xfer(adap,&msg,1); | 642 | return (ret == 1) ? count : ret; |
655 | up(&adap->bus_lock); | ||
656 | |||
657 | dev_dbg(&client->adapter->dev, "master_recv: return:%d (count:%d, addr:0x%02x)\n", | ||
658 | ret, count, client->addr); | ||
659 | |||
660 | /* if everything went ok (i.e. 1 msg transmitted), return #bytes | ||
661 | * transmitted, else error code. | ||
662 | */ | ||
663 | return (ret == 1 )? count : ret; | ||
664 | } else { | ||
665 | dev_err(&client->adapter->dev, "I2C level transfers not supported\n"); | ||
666 | return -ENOSYS; | ||
667 | } | ||
668 | } | 643 | } |
669 | 644 | ||
670 | 645 | ||
@@ -742,18 +717,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
742 | found = 1; | 717 | found = 1; |
743 | } | 718 | } |
744 | } | 719 | } |
745 | for (i = 0; | ||
746 | !found && (address_data->ignore_range[i] != I2C_CLIENT_END); | ||
747 | i += 3) { | ||
748 | if (((adap_id == address_data->ignore_range[i]) || | ||
749 | ((address_data->ignore_range[i]==ANY_I2C_BUS))) && | ||
750 | (addr >= address_data->ignore_range[i+1]) && | ||
751 | (addr <= address_data->ignore_range[i+2])) { | ||
752 | dev_dbg(&adapter->dev, "found ignore_range parameter for adapter %d, " | ||
753 | "addr %04x\n", adap_id,addr); | ||
754 | found = 1; | ||
755 | } | ||
756 | } | ||
757 | if (found) | 720 | if (found) |
758 | continue; | 721 | continue; |
759 | 722 | ||
@@ -770,17 +733,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
770 | } | 733 | } |
771 | 734 | ||
772 | for (i = 0; | 735 | for (i = 0; |
773 | !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END); | ||
774 | i += 2) { | ||
775 | if ((addr >= address_data->normal_i2c_range[i]) && | ||
776 | (addr <= address_data->normal_i2c_range[i+1])) { | ||
777 | found = 1; | ||
778 | dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, " | ||
779 | "addr %04x\n", adap_id,addr); | ||
780 | } | ||
781 | } | ||
782 | |||
783 | for (i = 0; | ||
784 | !found && (address_data->probe[i] != I2C_CLIENT_END); | 736 | !found && (address_data->probe[i] != I2C_CLIENT_END); |
785 | i += 2) { | 737 | i += 2) { |
786 | if (((adap_id == address_data->probe[i]) || | 738 | if (((adap_id == address_data->probe[i]) || |
@@ -791,18 +743,6 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
791 | "addr %04x\n", adap_id,addr); | 743 | "addr %04x\n", adap_id,addr); |
792 | } | 744 | } |
793 | } | 745 | } |
794 | for (i = 0; | ||
795 | !found && (address_data->probe_range[i] != I2C_CLIENT_END); | ||
796 | i += 3) { | ||
797 | if (((adap_id == address_data->probe_range[i]) || | ||
798 | (address_data->probe_range[i] == ANY_I2C_BUS)) && | ||
799 | (addr >= address_data->probe_range[i+1]) && | ||
800 | (addr <= address_data->probe_range[i+2])) { | ||
801 | found = 1; | ||
802 | dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, " | ||
803 | "addr %04x\n", adap_id,addr); | ||
804 | } | ||
805 | } | ||
806 | if (!found) | 746 | if (!found) |
807 | continue; | 747 | continue; |
808 | 748 | ||
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 86c4d0149e82..bc5d557e5dd9 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -29,7 +29,6 @@ | |||
29 | /* The devfs code is contributed by Philipp Matthias Hahn | 29 | /* The devfs code is contributed by Philipp Matthias Hahn |
30 | <pmhahn@titan.lahn.de> */ | 30 | <pmhahn@titan.lahn.de> */ |
31 | 31 | ||
32 | #include <linux/config.h> | ||
33 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
34 | #include <linux/module.h> | 33 | #include <linux/module.h> |
35 | #include <linux/fs.h> | 34 | #include <linux/fs.h> |
@@ -214,7 +213,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
214 | sizeof(rdwr_arg))) | 213 | sizeof(rdwr_arg))) |
215 | return -EFAULT; | 214 | return -EFAULT; |
216 | 215 | ||
217 | /* Put an arbritrary limit on the number of messages that can | 216 | /* Put an arbitrary limit on the number of messages that can |
218 | * be sent at once */ | 217 | * be sent at once */ |
219 | if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) | 218 | if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) |
220 | return -EINVAL; | 219 | return -EINVAL; |
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index 0bdb47f08c2a..61400f04015e 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c | |||
@@ -51,8 +51,10 @@ | |||
51 | static int do_probe( struct i2c_adapter *adapter, int addr, int kind); | 51 | static int do_probe( struct i2c_adapter *adapter, int addr, int kind); |
52 | 52 | ||
53 | /* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */ | 53 | /* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */ |
54 | static unsigned short normal_i2c[] = { 0x49, 0x2c, I2C_CLIENT_END }; | 54 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, |
55 | static unsigned short normal_i2c_range[] = { 0x48, 0x4f, 0x2c, 0x2f, I2C_CLIENT_END }; | 55 | 0x4c, 0x4d, 0x4e, 0x4f, |
56 | 0x2c, 0x2d, 0x2e, 0x2f, | ||
57 | I2C_CLIENT_END }; | ||
56 | 58 | ||
57 | I2C_CLIENT_INSMOD; | 59 | I2C_CLIENT_INSMOD; |
58 | 60 | ||
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 80254caa444c..48989eda2400 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
@@ -384,22 +384,14 @@ static unsigned short normal_i2c[] = | |||
384 | I2C_ADV7171 >> 1, (I2C_ADV7171 >> 1) + 1, | 384 | I2C_ADV7171 >> 1, (I2C_ADV7171 >> 1) + 1, |
385 | I2C_CLIENT_END | 385 | I2C_CLIENT_END |
386 | }; | 386 | }; |
387 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
388 | 387 | ||
389 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 388 | static unsigned short ignore = I2C_CLIENT_END; |
390 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
391 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
392 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
393 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
394 | 389 | ||
395 | static struct i2c_client_address_data addr_data = { | 390 | static struct i2c_client_address_data addr_data = { |
396 | .normal_i2c = normal_i2c, | 391 | .normal_i2c = normal_i2c, |
397 | .normal_i2c_range = normal_i2c_range, | 392 | .probe = &ignore, |
398 | .probe = probe, | 393 | .ignore = &ignore, |
399 | .probe_range = probe_range, | 394 | .force = &ignore, |
400 | .ignore = ignore, | ||
401 | .ignore_range = ignore_range, | ||
402 | .force = force | ||
403 | }; | 395 | }; |
404 | 396 | ||
405 | static struct i2c_driver i2c_driver_adv7170; | 397 | static struct i2c_driver i2c_driver_adv7170; |
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 95d0974b0ab5..f898b6586374 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c | |||
@@ -434,22 +434,14 @@ static unsigned short normal_i2c[] = | |||
434 | I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, | 434 | I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, |
435 | I2C_CLIENT_END | 435 | I2C_CLIENT_END |
436 | }; | 436 | }; |
437 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
438 | 437 | ||
439 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 438 | static unsigned short ignore = I2C_CLIENT_END; |
440 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
441 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
442 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
443 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
444 | 439 | ||
445 | static struct i2c_client_address_data addr_data = { | 440 | static struct i2c_client_address_data addr_data = { |
446 | .normal_i2c = normal_i2c, | 441 | .normal_i2c = normal_i2c, |
447 | .normal_i2c_range = normal_i2c_range, | 442 | .probe = &ignore, |
448 | .probe = probe, | 443 | .ignore = &ignore, |
449 | .probe_range = probe_range, | 444 | .force = &ignore, |
450 | .ignore = ignore, | ||
451 | .ignore_range = ignore_range, | ||
452 | .force = force | ||
453 | }; | 445 | }; |
454 | 446 | ||
455 | static struct i2c_driver i2c_driver_adv7175; | 447 | static struct i2c_driver i2c_driver_adv7175; |
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index cf0db2554a80..8733588f6db3 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c | |||
@@ -500,22 +500,14 @@ static unsigned short normal_i2c[] = { | |||
500 | I2C_BT819 >> 1, | 500 | I2C_BT819 >> 1, |
501 | I2C_CLIENT_END, | 501 | I2C_CLIENT_END, |
502 | }; | 502 | }; |
503 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
504 | 503 | ||
505 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 504 | static unsigned short ignore = I2C_CLIENT_END; |
506 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
507 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
508 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
509 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
510 | 505 | ||
511 | static struct i2c_client_address_data addr_data = { | 506 | static struct i2c_client_address_data addr_data = { |
512 | .normal_i2c = normal_i2c, | 507 | .normal_i2c = normal_i2c, |
513 | .normal_i2c_range = normal_i2c_range, | 508 | .probe = &ignore, |
514 | .probe = probe, | 509 | .ignore = &ignore, |
515 | .probe_range = probe_range, | 510 | .force = &ignore, |
516 | .ignore = ignore, | ||
517 | .ignore_range = ignore_range, | ||
518 | .force = force | ||
519 | }; | 511 | }; |
520 | 512 | ||
521 | static struct i2c_driver i2c_driver_bt819; | 513 | static struct i2c_driver i2c_driver_bt819; |
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c index efe605a113a1..07f72f64c5f7 100644 --- a/drivers/media/video/bt832.c +++ b/drivers/media/video/bt832.c | |||
@@ -39,8 +39,8 @@ | |||
39 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
40 | 40 | ||
41 | /* Addresses to scan */ | 41 | /* Addresses to scan */ |
42 | static unsigned short normal_i2c[] = {I2C_CLIENT_END}; | 42 | static unsigned short normal_i2c[] = { I2C_BT832_ALT1>>1, I2C_BT832_ALT2>>1, |
43 | static unsigned short normal_i2c_range[] = {I2C_BT832_ALT1>>1,I2C_BT832_ALT2>>1,I2C_CLIENT_END}; | 43 | I2C_CLIENT_END }; |
44 | I2C_CLIENT_INSMOD; | 44 | I2C_CLIENT_INSMOD; |
45 | 45 | ||
46 | /* ---------------------------------------------------------------------- */ | 46 | /* ---------------------------------------------------------------------- */ |
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 72c7eb0f8c24..a5d529ccf3ad 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c | |||
@@ -288,22 +288,14 @@ bt856_command (struct i2c_client *client, | |||
288 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | 288 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' |
289 | */ | 289 | */ |
290 | static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; | 290 | static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; |
291 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
292 | 291 | ||
293 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 292 | static unsigned short ignore = I2C_CLIENT_END; |
294 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
295 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
296 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
297 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
298 | 293 | ||
299 | static struct i2c_client_address_data addr_data = { | 294 | static struct i2c_client_address_data addr_data = { |
300 | .normal_i2c = normal_i2c, | 295 | .normal_i2c = normal_i2c, |
301 | .normal_i2c_range = normal_i2c_range, | 296 | .probe = &ignore, |
302 | .probe = probe, | 297 | .ignore = &ignore, |
303 | .probe_range = probe_range, | 298 | .force = &ignore, |
304 | .ignore = ignore, | ||
305 | .ignore_range = ignore_range, | ||
306 | .force = force | ||
307 | }; | 299 | }; |
308 | 300 | ||
309 | static struct i2c_driver i2c_driver_bt856; | 301 | static struct i2c_driver i2c_driver_bt856; |
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index 7fbb8581a87d..09464d624a6b 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c | |||
@@ -147,7 +147,6 @@ static unsigned short normal_i2c[] = { | |||
147 | I2C_MSP3400C_ALT >> 1, | 147 | I2C_MSP3400C_ALT >> 1, |
148 | I2C_CLIENT_END | 148 | I2C_CLIENT_END |
149 | }; | 149 | }; |
150 | static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END}; | ||
151 | I2C_CLIENT_INSMOD; | 150 | I2C_CLIENT_INSMOD; |
152 | 151 | ||
153 | /* ----------------------------------------------------------------------- */ | 152 | /* ----------------------------------------------------------------------- */ |
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c index ba69f09cbdd1..b8054da31ffd 100644 --- a/drivers/media/video/saa5246a.c +++ b/drivers/media/video/saa5246a.c | |||
@@ -64,7 +64,6 @@ static struct video_device saa_template; /* Declared near bottom */ | |||
64 | 64 | ||
65 | /* Addresses to scan */ | 65 | /* Addresses to scan */ |
66 | static unsigned short normal_i2c[] = { I2C_ADDRESS, I2C_CLIENT_END }; | 66 | static unsigned short normal_i2c[] = { I2C_ADDRESS, I2C_CLIENT_END }; |
67 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
68 | I2C_CLIENT_INSMOD; | 67 | I2C_CLIENT_INSMOD; |
69 | 68 | ||
70 | static struct i2c_client client_template; | 69 | static struct i2c_client client_template; |
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index d74caa139f0a..7ffa2e9a9bf3 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c | |||
@@ -132,7 +132,6 @@ static struct video_device saa_template; /* Declared near bottom */ | |||
132 | 132 | ||
133 | /* Addresses to scan */ | 133 | /* Addresses to scan */ |
134 | static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END}; | 134 | static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END}; |
135 | static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; | ||
136 | I2C_CLIENT_INSMOD; | 135 | I2C_CLIENT_INSMOD; |
137 | 136 | ||
138 | static struct i2c_client client_template; | 137 | static struct i2c_client client_template; |
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 64273b438530..22d055d8a695 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c | |||
@@ -463,22 +463,14 @@ static unsigned short normal_i2c[] = { | |||
463 | (I2C_SAA7110 >> 1) + 1, | 463 | (I2C_SAA7110 >> 1) + 1, |
464 | I2C_CLIENT_END | 464 | I2C_CLIENT_END |
465 | }; | 465 | }; |
466 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
467 | 466 | ||
468 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 467 | static unsigned short ignore = I2C_CLIENT_END; |
469 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
470 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
471 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
472 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
473 | 468 | ||
474 | static struct i2c_client_address_data addr_data = { | 469 | static struct i2c_client_address_data addr_data = { |
475 | .normal_i2c = normal_i2c, | 470 | .normal_i2c = normal_i2c, |
476 | .normal_i2c_range = normal_i2c_range, | 471 | .probe = &ignore, |
477 | .probe = probe, | 472 | .ignore = &ignore, |
478 | .probe_range = probe_range, | 473 | .force = &ignore, |
479 | .ignore = ignore, | ||
480 | .ignore_range = ignore_range, | ||
481 | .force = force | ||
482 | }; | 474 | }; |
483 | 475 | ||
484 | static struct i2c_driver i2c_driver_saa7110; | 476 | static struct i2c_driver i2c_driver_saa7110; |
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 0a873112ae23..fcd897382fcf 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c | |||
@@ -482,22 +482,14 @@ saa7111_command (struct i2c_client *client, | |||
482 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | 482 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' |
483 | */ | 483 | */ |
484 | static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; | 484 | static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; |
485 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
486 | 485 | ||
487 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 486 | static unsigned short ignore = I2C_CLIENT_END; |
488 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
489 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
490 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
491 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
492 | 487 | ||
493 | static struct i2c_client_address_data addr_data = { | 488 | static struct i2c_client_address_data addr_data = { |
494 | .normal_i2c = normal_i2c, | 489 | .normal_i2c = normal_i2c, |
495 | .normal_i2c_range = normal_i2c_range, | 490 | .probe = &ignore, |
496 | .probe = probe, | 491 | .ignore = &ignore, |
497 | .probe_range = probe_range, | 492 | .force = &ignore, |
498 | .ignore = ignore, | ||
499 | .ignore_range = ignore_range, | ||
500 | .force = force | ||
501 | }; | 493 | }; |
502 | 494 | ||
503 | static struct i2c_driver i2c_driver_saa7111; | 495 | static struct i2c_driver i2c_driver_saa7111; |
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index e73023695e58..2ba997f5ef1d 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c | |||
@@ -820,22 +820,14 @@ saa7114_command (struct i2c_client *client, | |||
820 | */ | 820 | */ |
821 | static unsigned short normal_i2c[] = | 821 | static unsigned short normal_i2c[] = |
822 | { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; | 822 | { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; |
823 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
824 | 823 | ||
825 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 824 | static unsigned short ignore = I2C_CLIENT_END; |
826 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
827 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
828 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
829 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
830 | 825 | ||
831 | static struct i2c_client_address_data addr_data = { | 826 | static struct i2c_client_address_data addr_data = { |
832 | .normal_i2c = normal_i2c, | 827 | .normal_i2c = normal_i2c, |
833 | .normal_i2c_range = normal_i2c_range, | 828 | .probe = &ignore, |
834 | .probe = probe, | 829 | .ignore = &ignore, |
835 | .probe_range = probe_range, | 830 | .force = &ignore, |
836 | .ignore = ignore, | ||
837 | .ignore_range = ignore_range, | ||
838 | .force = force | ||
839 | }; | 831 | }; |
840 | 832 | ||
841 | static struct i2c_driver i2c_driver_saa7114; | 833 | static struct i2c_driver i2c_driver_saa7114; |
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 1db022682980..42c2b565c9fe 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c | |||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | /* Addresses to scan */ | 23 | /* Addresses to scan */ |
24 | static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END}; | 24 | static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END}; |
25 | static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; | ||
26 | I2C_CLIENT_INSMOD; | 25 | I2C_CLIENT_INSMOD; |
27 | 26 | ||
28 | MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); | 27 | MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); |
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 5f0b224c3cb6..108e7a4a0273 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c | |||
@@ -380,22 +380,14 @@ saa7185_command (struct i2c_client *client, | |||
380 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | 380 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' |
381 | */ | 381 | */ |
382 | static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; | 382 | static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; |
383 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
384 | 383 | ||
385 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 384 | static unsigned short ignore = I2C_CLIENT_END; |
386 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
387 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
388 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
389 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
390 | 385 | ||
391 | static struct i2c_client_address_data addr_data = { | 386 | static struct i2c_client_address_data addr_data = { |
392 | .normal_i2c = normal_i2c, | 387 | .normal_i2c = normal_i2c, |
393 | .normal_i2c_range = normal_i2c_range, | 388 | .probe = &ignore, |
394 | .probe = probe, | 389 | .ignore = &ignore, |
395 | .probe_range = probe_range, | 390 | .force = &ignore, |
396 | .ignore = ignore, | ||
397 | .ignore_range = ignore_range, | ||
398 | .force = force | ||
399 | }; | 391 | }; |
400 | 392 | ||
401 | static struct i2c_driver i2c_driver_saa7185; | 393 | static struct i2c_driver i2c_driver_saa7185; |
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c index 376a4a439e9b..07ba6d3ed08c 100644 --- a/drivers/media/video/tda7432.c +++ b/drivers/media/video/tda7432.c | |||
@@ -74,7 +74,6 @@ static unsigned short normal_i2c[] = { | |||
74 | I2C_TDA7432 >> 1, | 74 | I2C_TDA7432 >> 1, |
75 | I2C_CLIENT_END, | 75 | I2C_CLIENT_END, |
76 | }; | 76 | }; |
77 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
78 | I2C_CLIENT_INSMOD; | 77 | I2C_CLIENT_INSMOD; |
79 | 78 | ||
80 | /* Structure of address and subaddresses for the tda7432 */ | 79 | /* Structure of address and subaddresses for the tda7432 */ |
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index b5177c6f54f6..c29bdfc3244e 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c | |||
@@ -43,7 +43,6 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); | |||
43 | 43 | ||
44 | /* addresses to scan, found only at 0x42 (7-Bit) */ | 44 | /* addresses to scan, found only at 0x42 (7-Bit) */ |
45 | static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END }; | 45 | static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END }; |
46 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
47 | 46 | ||
48 | /* magic definition of all other variables and things */ | 47 | /* magic definition of all other variables and things */ |
49 | I2C_CLIENT_INSMOD; | 48 | I2C_CLIENT_INSMOD; |
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index 4f1114c033a1..97b113e070f3 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c | |||
@@ -44,7 +44,6 @@ static unsigned short normal_i2c[] = { | |||
44 | I2C_TDA9875 >> 1, | 44 | I2C_TDA9875 >> 1, |
45 | I2C_CLIENT_END | 45 | I2C_CLIENT_END |
46 | }; | 46 | }; |
47 | static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; | ||
48 | I2C_CLIENT_INSMOD; | 47 | I2C_CLIENT_INSMOD; |
49 | 48 | ||
50 | /* This is a superset of the TDA9875 */ | 49 | /* This is a superset of the TDA9875 */ |
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index debef1910c37..7e6e6dd966a2 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c | |||
@@ -33,7 +33,6 @@ static unsigned short normal_i2c[] = { | |||
33 | 0x96 >>1, | 33 | 0x96 >>1, |
34 | I2C_CLIENT_END, | 34 | I2C_CLIENT_END, |
35 | }; | 35 | }; |
36 | static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END}; | ||
37 | I2C_CLIENT_INSMOD; | 36 | I2C_CLIENT_INSMOD; |
38 | 37 | ||
39 | /* insmod options */ | 38 | /* insmod options */ |
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index 3ec39550bf46..b44db8a7b94d 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c | |||
@@ -43,7 +43,6 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); | |||
43 | 43 | ||
44 | /* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */ | 44 | /* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */ |
45 | static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END }; | 45 | static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END }; |
46 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
47 | 46 | ||
48 | /* magic definition of all other variables and things */ | 47 | /* magic definition of all other variables and things */ |
49 | I2C_CLIENT_INSMOD; | 48 | I2C_CLIENT_INSMOD; |
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index bd10710fd909..48d4db7d507b 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c | |||
@@ -40,7 +40,6 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); | |||
40 | 40 | ||
41 | /* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ | 41 | /* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ |
42 | static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END }; | 42 | static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END }; |
43 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
44 | 43 | ||
45 | /* magic definition of all other variables and things */ | 44 | /* magic definition of all other variables and things */ |
46 | I2C_CLIENT_INSMOD; | 45 | I2C_CLIENT_INSMOD; |
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c index 6b20aa902a8f..51748c6578d1 100644 --- a/drivers/media/video/tuner-3036.c +++ b/drivers/media/video/tuner-3036.c | |||
@@ -34,19 +34,14 @@ static int this_adap; | |||
34 | static struct i2c_client client_template; | 34 | static struct i2c_client client_template; |
35 | 35 | ||
36 | /* Addresses to scan */ | 36 | /* Addresses to scan */ |
37 | static unsigned short normal_i2c[] = {I2C_CLIENT_END}; | 37 | static unsigned short normal_i2c[] = { 0x60, 0x61, I2C_CLIENT_END }; |
38 | static unsigned short normal_i2c_range[] = {0x60, 0x61, I2C_CLIENT_END}; | 38 | static unsigned short ignore = I2C_CLIENT_END; |
39 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
40 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
41 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
42 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
43 | static unsigned short force[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
44 | 39 | ||
45 | static struct i2c_client_address_data addr_data = { | 40 | static struct i2c_client_address_data addr_data = { |
46 | normal_i2c, normal_i2c_range, | 41 | .normal_i2c = normal_i2c, |
47 | probe, probe_range, | 42 | .probe = &ignore, |
48 | ignore, ignore_range, | 43 | .ignore = &ignore, |
49 | force | 44 | .force = &ignore, |
50 | }; | 45 | }; |
51 | 46 | ||
52 | /* ---------------------------------------------------------------------- */ | 47 | /* ---------------------------------------------------------------------- */ |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 6212388edb75..81882ddab859 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -28,10 +28,8 @@ | |||
28 | /* standard i2c insmod options */ | 28 | /* standard i2c insmod options */ |
29 | static unsigned short normal_i2c[] = { | 29 | static unsigned short normal_i2c[] = { |
30 | 0x4b, /* tda8290 */ | 30 | 0x4b, /* tda8290 */ |
31 | I2C_CLIENT_END | 31 | 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, |
32 | }; | 32 | 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, |
33 | static unsigned short normal_i2c_range[] = { | ||
34 | 0x60, 0x6f, | ||
35 | I2C_CLIENT_END | 33 | I2C_CLIENT_END |
36 | }; | 34 | }; |
37 | I2C_CLIENT_INSMOD; | 35 | I2C_CLIENT_INSMOD; |
@@ -225,9 +223,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) | |||
225 | static int tuner_probe(struct i2c_adapter *adap) | 223 | static int tuner_probe(struct i2c_adapter *adap) |
226 | { | 224 | { |
227 | if (0 != addr) { | 225 | if (0 != addr) { |
228 | normal_i2c[0] = addr; | 226 | normal_i2c[0] = addr; |
229 | normal_i2c_range[0] = addr; | 227 | normal_i2c[1] = I2C_CLIENT_END; |
230 | normal_i2c_range[1] = addr; | ||
231 | } | 228 | } |
232 | this_adap = 0; | 229 | this_adap = 0; |
233 | 230 | ||
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 80dc34f18c2c..41b635e0d3c6 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -148,7 +148,6 @@ static unsigned short normal_i2c[] = { | |||
148 | I2C_TDA9874 >> 1, | 148 | I2C_TDA9874 >> 1, |
149 | I2C_PIC16C54 >> 1, | 149 | I2C_PIC16C54 >> 1, |
150 | I2C_CLIENT_END }; | 150 | I2C_CLIENT_END }; |
151 | static unsigned short normal_i2c_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
152 | I2C_CLIENT_INSMOD; | 151 | I2C_CLIENT_INSMOD; |
153 | 152 | ||
154 | static struct i2c_driver driver; | 153 | static struct i2c_driver driver; |
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index e1443a0937e3..3d216973798c 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c | |||
@@ -482,7 +482,6 @@ static unsigned short normal_i2c[] = { | |||
482 | 0xa0 >> 1, | 482 | 0xa0 >> 1, |
483 | I2C_CLIENT_END, | 483 | I2C_CLIENT_END, |
484 | }; | 484 | }; |
485 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
486 | I2C_CLIENT_INSMOD; | 485 | I2C_CLIENT_INSMOD; |
487 | 486 | ||
488 | struct i2c_driver i2c_driver_tveeprom; | 487 | struct i2c_driver i2c_driver_tveeprom; |
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index 0fd6c9a70917..5dbd9f6bf353 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c | |||
@@ -569,22 +569,14 @@ static unsigned short normal_i2c[] = | |||
569 | { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4, | 569 | { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4, |
570 | I2C_CLIENT_END | 570 | I2C_CLIENT_END |
571 | }; | 571 | }; |
572 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | ||
573 | 572 | ||
574 | static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | 573 | static unsigned short ignore = I2C_CLIENT_END; |
575 | static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
576 | static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
577 | static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; | ||
578 | static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; | ||
579 | 574 | ||
580 | static struct i2c_client_address_data addr_data = { | 575 | static struct i2c_client_address_data addr_data = { |
581 | .normal_i2c = normal_i2c, | 576 | .normal_i2c = normal_i2c, |
582 | .normal_i2c_range = normal_i2c_range, | 577 | .probe = &ignore, |
583 | .probe = probe, | 578 | .ignore = &ignore, |
584 | .probe_range = probe_range, | 579 | .force = &ignore, |
585 | .ignore = ignore, | ||
586 | .ignore_range = ignore_range, | ||
587 | .force = force | ||
588 | }; | 580 | }; |
589 | 581 | ||
590 | static struct i2c_driver vpx3220_i2c_driver; | 582 | static struct i2c_driver vpx3220_i2c_driver; |
diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index e529841cd83d..67f85344f0cc 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c | |||
@@ -1230,7 +1230,6 @@ static int maven_shutdown_client(struct i2c_client* clnt) { | |||
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; | 1232 | static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; |
1233 | static unsigned short normal_i2c_range[] = { MAVEN_I2CID, MAVEN_I2CID, I2C_CLIENT_END }; | ||
1234 | I2C_CLIENT_INSMOD; | 1233 | I2C_CLIENT_INSMOD; |
1235 | 1234 | ||
1236 | static struct i2c_driver maven_driver; | 1235 | static struct i2c_driver maven_driver; |