diff options
Diffstat (limited to 'drivers/i2c/chips/via686a.c')
| -rw-r--r-- | drivers/i2c/chips/via686a.c | 337 |
1 files changed, 167 insertions, 170 deletions
diff --git a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c index 6614a59cecd4..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,54 +351,54 @@ 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; |
| 386 | } | 379 | } |
| 387 | #define show_in_offset(offset) \ | 380 | #define show_in_offset(offset) \ |
| 388 | static ssize_t \ | 381 | static ssize_t \ |
| 389 | show_in##offset (struct device *dev, char *buf) \ | 382 | show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 390 | { \ | 383 | { \ |
| 391 | return show_in(dev, buf, offset); \ | 384 | return show_in(dev, buf, offset); \ |
| 392 | } \ | 385 | } \ |
| 393 | static ssize_t \ | 386 | static ssize_t \ |
| 394 | show_in##offset##_min (struct device *dev, char *buf) \ | 387 | show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 395 | { \ | 388 | { \ |
| 396 | return show_in_min(dev, buf, offset); \ | 389 | return show_in_min(dev, buf, offset); \ |
| 397 | } \ | 390 | } \ |
| 398 | static ssize_t \ | 391 | static ssize_t \ |
| 399 | show_in##offset##_max (struct device *dev, char *buf) \ | 392 | show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 400 | { \ | 393 | { \ |
| 401 | return show_in_max(dev, buf, offset); \ | 394 | return show_in_max(dev, buf, offset); \ |
| 402 | } \ | 395 | } \ |
| 403 | static ssize_t set_in##offset##_min (struct device *dev, \ | 396 | static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \ |
| 404 | const char *buf, size_t count) \ | 397 | const char *buf, size_t count) \ |
| 405 | { \ | 398 | { \ |
| 406 | return set_in_min(dev, buf, count, offset); \ | 399 | return set_in_min(dev, buf, count, offset); \ |
| 407 | } \ | 400 | } \ |
| 408 | static ssize_t set_in##offset##_max (struct device *dev, \ | 401 | static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \ |
| 409 | const char *buf, size_t count) \ | 402 | const char *buf, size_t count) \ |
| 410 | { \ | 403 | { \ |
| 411 | return set_in_max(dev, buf, count, offset); \ | 404 | return set_in_max(dev, buf, count, offset); \ |
| @@ -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,31 +449,32 @@ 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 | } |
| 462 | #define show_temp_offset(offset) \ | 457 | #define show_temp_offset(offset) \ |
| 463 | static ssize_t show_temp_##offset (struct device *dev, char *buf) \ | 458 | static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 464 | { \ | 459 | { \ |
| 465 | return show_temp(dev, buf, offset - 1); \ | 460 | return show_temp(dev, buf, offset - 1); \ |
| 466 | } \ | 461 | } \ |
| 467 | static ssize_t \ | 462 | static ssize_t \ |
| 468 | show_temp_##offset##_over (struct device *dev, char *buf) \ | 463 | show_temp_##offset##_over (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 469 | { \ | 464 | { \ |
| 470 | return show_temp_over(dev, buf, offset - 1); \ | 465 | return show_temp_over(dev, buf, offset - 1); \ |
| 471 | } \ | 466 | } \ |
| 472 | static ssize_t \ | 467 | static ssize_t \ |
| 473 | show_temp_##offset##_hyst (struct device *dev, char *buf) \ | 468 | show_temp_##offset##_hyst (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 474 | { \ | 469 | { \ |
| 475 | return show_temp_hyst(dev, buf, offset - 1); \ | 470 | return show_temp_hyst(dev, buf, offset - 1); \ |
| 476 | } \ | 471 | } \ |
| 477 | static ssize_t set_temp_##offset##_over (struct device *dev, \ | 472 | static ssize_t set_temp_##offset##_over (struct device *dev, struct device_attribute *attr, \ |
| 478 | const char *buf, size_t count) \ | 473 | const char *buf, size_t count) \ |
| 479 | { \ | 474 | { \ |
| 480 | return set_temp_over(dev, buf, count, offset - 1); \ | 475 | return set_temp_over(dev, buf, count, offset - 1); \ |
| 481 | } \ | 476 | } \ |
| 482 | static ssize_t set_temp_##offset##_hyst (struct device *dev, \ | 477 | static ssize_t set_temp_##offset##_hyst (struct device *dev, struct device_attribute *attr, \ |
| 483 | const char *buf, size_t count) \ | 478 | const char *buf, size_t count) \ |
| 484 | { \ | 479 | { \ |
| 485 | return set_temp_hyst(dev, buf, count, offset - 1); \ | 480 | return set_temp_hyst(dev, buf, count, offset - 1); \ |
| @@ -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); |
| @@ -538,24 +533,24 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, | |||
| 538 | } | 533 | } |
| 539 | 534 | ||
| 540 | #define show_fan_offset(offset) \ | 535 | #define show_fan_offset(offset) \ |
| 541 | static ssize_t show_fan_##offset (struct device *dev, char *buf) \ | 536 | static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 542 | { \ | 537 | { \ |
| 543 | return show_fan(dev, buf, offset - 1); \ | 538 | return show_fan(dev, buf, offset - 1); \ |
| 544 | } \ | 539 | } \ |
| 545 | static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ | 540 | static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 546 | { \ | 541 | { \ |
| 547 | return show_fan_min(dev, buf, offset - 1); \ | 542 | return show_fan_min(dev, buf, offset - 1); \ |
| 548 | } \ | 543 | } \ |
| 549 | static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ | 544 | static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ |
| 550 | { \ | 545 | { \ |
| 551 | return show_fan_div(dev, buf, offset - 1); \ | 546 | return show_fan_div(dev, buf, offset - 1); \ |
| 552 | } \ | 547 | } \ |
| 553 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | 548 | static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
| 554 | const char *buf, size_t count) \ | 549 | const char *buf, size_t count) \ |
| 555 | { \ | 550 | { \ |
| 556 | return set_fan_min(dev, buf, count, offset - 1); \ | 551 | return set_fan_min(dev, buf, count, offset - 1); \ |
| 557 | } \ | 552 | } \ |
| 558 | static ssize_t set_fan_##offset##_div (struct device *dev, \ | 553 | static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \ |
| 559 | const char *buf, size_t count) \ | 554 | const char *buf, size_t count) \ |
| 560 | { \ | 555 | { \ |
| 561 | return set_fan_div(dev, buf, count, offset - 1); \ | 556 | return set_fan_div(dev, buf, count, offset - 1); \ |
| @@ -570,9 +565,9 @@ show_fan_offset(1); | |||
| 570 | show_fan_offset(2); | 565 | show_fan_offset(2); |
| 571 | 566 | ||
| 572 | /* Alarms */ | 567 | /* Alarms */ |
| 573 | static ssize_t show_alarms(struct device *dev, 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 | ||
