Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | lm85.c - Part of lm_sensors, Linux kernel modules for hardware |
| 3 | monitoring |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 4 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com> |
| 6 | Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de> |
| 7 | Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com> |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 8 | Copyright (C) 2007, 2008 Jean Delvare <khali@linux-fr.org> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
| 10 | Chip details at <http://www.national.com/ds/LM/LM85.pdf> |
| 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/module.h> |
| 28 | #include <linux/init.h> |
| 29 | #include <linux/slab.h> |
| 30 | #include <linux/jiffies.h> |
| 31 | #include <linux/i2c.h> |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 32 | #include <linux/hwmon.h> |
Jean Delvare | 303760b | 2005-07-31 21:52:01 +0200 | [diff] [blame] | 33 | #include <linux/hwmon-vid.h> |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 34 | #include <linux/hwmon-sysfs.h> |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 35 | #include <linux/err.h> |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 36 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | /* Addresses to scan */ |
Mark M. Hoffman | 25e9c86 | 2008-02-17 22:28:03 -0500 | [diff] [blame] | 39 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | /* Insmod parameters */ |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 42 | I2C_CLIENT_INSMOD_7(lm85b, lm85c, adm1027, adt7463, adt7468, emc6d100, |
| 43 | emc6d102); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | /* The LM85 registers */ |
| 46 | |
| 47 | #define LM85_REG_IN(nr) (0x20 + (nr)) |
| 48 | #define LM85_REG_IN_MIN(nr) (0x44 + (nr) * 2) |
| 49 | #define LM85_REG_IN_MAX(nr) (0x45 + (nr) * 2) |
| 50 | |
| 51 | #define LM85_REG_TEMP(nr) (0x25 + (nr)) |
| 52 | #define LM85_REG_TEMP_MIN(nr) (0x4e + (nr) * 2) |
| 53 | #define LM85_REG_TEMP_MAX(nr) (0x4f + (nr) * 2) |
| 54 | |
| 55 | /* Fan speeds are LSB, MSB (2 bytes) */ |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 56 | #define LM85_REG_FAN(nr) (0x28 + (nr) * 2) |
| 57 | #define LM85_REG_FAN_MIN(nr) (0x54 + (nr) * 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | #define LM85_REG_PWM(nr) (0x30 + (nr)) |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #define LM85_REG_COMPANY 0x3e |
| 62 | #define LM85_REG_VERSTEP 0x3f |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 63 | |
| 64 | #define ADT7468_REG_CFG5 0x7c |
| 65 | #define ADT7468_OFF64 0x01 |
| 66 | #define IS_ADT7468_OFF64(data) \ |
| 67 | ((data)->type == adt7468 && !((data)->cfg5 & ADT7468_OFF64)) |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | /* These are the recognized values for the above regs */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #define LM85_COMPANY_NATIONAL 0x01 |
| 71 | #define LM85_COMPANY_ANALOG_DEV 0x41 |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 72 | #define LM85_COMPANY_SMSC 0x5c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | #define LM85_VERSTEP_VMASK 0xf0 |
| 74 | #define LM85_VERSTEP_GENERIC 0x60 |
Darrick J. Wong | c15ade6 | 2009-03-10 12:55:47 -0700 | [diff] [blame] | 75 | #define LM85_VERSTEP_GENERIC2 0x70 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | #define LM85_VERSTEP_LM85C 0x60 |
| 77 | #define LM85_VERSTEP_LM85B 0x62 |
| 78 | #define LM85_VERSTEP_ADM1027 0x60 |
| 79 | #define LM85_VERSTEP_ADT7463 0x62 |
| 80 | #define LM85_VERSTEP_ADT7463C 0x6A |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 81 | #define LM85_VERSTEP_ADT7468_1 0x71 |
| 82 | #define LM85_VERSTEP_ADT7468_2 0x72 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #define LM85_VERSTEP_EMC6D100_A0 0x60 |
| 84 | #define LM85_VERSTEP_EMC6D100_A1 0x61 |
| 85 | #define LM85_VERSTEP_EMC6D102 0x65 |
| 86 | |
| 87 | #define LM85_REG_CONFIG 0x40 |
| 88 | |
| 89 | #define LM85_REG_ALARM1 0x41 |
| 90 | #define LM85_REG_ALARM2 0x42 |
| 91 | |
| 92 | #define LM85_REG_VID 0x43 |
| 93 | |
| 94 | /* Automated FAN control */ |
| 95 | #define LM85_REG_AFAN_CONFIG(nr) (0x5c + (nr)) |
| 96 | #define LM85_REG_AFAN_RANGE(nr) (0x5f + (nr)) |
| 97 | #define LM85_REG_AFAN_SPIKE1 0x62 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #define LM85_REG_AFAN_MINPWM(nr) (0x64 + (nr)) |
| 99 | #define LM85_REG_AFAN_LIMIT(nr) (0x67 + (nr)) |
| 100 | #define LM85_REG_AFAN_CRITICAL(nr) (0x6a + (nr)) |
| 101 | #define LM85_REG_AFAN_HYST1 0x6d |
| 102 | #define LM85_REG_AFAN_HYST2 0x6e |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | #define ADM1027_REG_EXTEND_ADC1 0x76 |
| 105 | #define ADM1027_REG_EXTEND_ADC2 0x77 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
| 107 | #define EMC6D100_REG_ALARM3 0x7d |
| 108 | /* IN5, IN6 and IN7 */ |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 109 | #define EMC6D100_REG_IN(nr) (0x70 + ((nr) - 5)) |
| 110 | #define EMC6D100_REG_IN_MIN(nr) (0x73 + ((nr) - 5) * 2) |
| 111 | #define EMC6D100_REG_IN_MAX(nr) (0x74 + ((nr) - 5) * 2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | #define EMC6D102_REG_EXTEND_ADC1 0x85 |
| 113 | #define EMC6D102_REG_EXTEND_ADC2 0x86 |
| 114 | #define EMC6D102_REG_EXTEND_ADC3 0x87 |
| 115 | #define EMC6D102_REG_EXTEND_ADC4 0x88 |
| 116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 118 | /* Conversions. Rounding and limit checking is only done on the TO_REG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | variants. Note that you should be a bit careful with which arguments |
| 120 | these macros are called: arguments may be evaluated more than once. |
| 121 | */ |
| 122 | |
| 123 | /* IN are scaled acording to built-in resistors */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 124 | static const int lm85_scaling[] = { /* .001 Volts */ |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 125 | 2500, 2250, 3300, 5000, 12000, |
| 126 | 3300, 1500, 1800 /*EMC6D100*/ |
| 127 | }; |
| 128 | #define SCALE(val, from, to) (((val) * (to) + ((from) / 2)) / (from)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 130 | #define INS_TO_REG(n, val) \ |
| 131 | SENSORS_LIMIT(SCALE(val, lm85_scaling[n], 192), 0, 255) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 133 | #define INSEXT_FROM_REG(n, val, ext) \ |
Jean Delvare | 5a4d3ef | 2007-07-05 20:38:32 +0200 | [diff] [blame] | 134 | SCALE(((val) << 4) + (ext), 192 << 4, lm85_scaling[n]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 136 | #define INS_FROM_REG(n, val) SCALE((val), 192, lm85_scaling[n]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
| 138 | /* FAN speed is measured using 90kHz clock */ |
Jean Delvare | 63f281a | 2007-07-05 20:39:40 +0200 | [diff] [blame] | 139 | static inline u16 FAN_TO_REG(unsigned long val) |
| 140 | { |
| 141 | if (!val) |
| 142 | return 0xffff; |
| 143 | return SENSORS_LIMIT(5400000 / val, 1, 0xfffe); |
| 144 | } |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 145 | #define FAN_FROM_REG(val) ((val) == 0 ? -1 : (val) == 0xffff ? 0 : \ |
| 146 | 5400000 / (val)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
| 148 | /* Temperature is reported in .001 degC increments */ |
| 149 | #define TEMP_TO_REG(val) \ |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 150 | SENSORS_LIMIT(SCALE(val, 1000, 1), -127, 127) |
| 151 | #define TEMPEXT_FROM_REG(val, ext) \ |
Jean Delvare | 5a4d3ef | 2007-07-05 20:38:32 +0200 | [diff] [blame] | 152 | SCALE(((val) << 4) + (ext), 16, 1000) |
| 153 | #define TEMP_FROM_REG(val) ((val) * 1000) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 155 | #define PWM_TO_REG(val) SENSORS_LIMIT(val, 0, 255) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | #define PWM_FROM_REG(val) (val) |
| 157 | |
| 158 | |
| 159 | /* ZONEs have the following parameters: |
| 160 | * Limit (low) temp, 1. degC |
| 161 | * Hysteresis (below limit), 1. degC (0-15) |
| 162 | * Range of speed control, .1 degC (2-80) |
| 163 | * Critical (high) temp, 1. degC |
| 164 | * |
| 165 | * FAN PWMs have the following parameters: |
| 166 | * Reference Zone, 1, 2, 3, etc. |
| 167 | * Spinup time, .05 sec |
| 168 | * PWM value at limit/low temp, 1 count |
| 169 | * PWM Frequency, 1. Hz |
| 170 | * PWM is Min or OFF below limit, flag |
| 171 | * Invert PWM output, flag |
| 172 | * |
| 173 | * Some chips filter the temp, others the fan. |
| 174 | * Filter constant (or disabled) .1 seconds |
| 175 | */ |
| 176 | |
| 177 | /* These are the zone temperature range encodings in .001 degree C */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 178 | static const int lm85_range_map[] = { |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 179 | 2000, 2500, 3300, 4000, 5000, 6600, 8000, 10000, |
| 180 | 13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000 |
| 181 | }; |
| 182 | |
| 183 | static int RANGE_TO_REG(int range) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | { |
| 185 | int i; |
| 186 | |
Jean Delvare | d38b149 | 2008-04-03 10:40:39 +0200 | [diff] [blame] | 187 | /* Find the closest match */ |
Jean Delvare | 1b92ada | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 188 | for (i = 0; i < 15; ++i) { |
| 189 | if (range <= (lm85_range_map[i] + lm85_range_map[i + 1]) / 2) |
| 190 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | } |
Jean Delvare | d38b149 | 2008-04-03 10:40:39 +0200 | [diff] [blame] | 192 | |
Jean Delvare | 1b92ada | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 193 | return i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | } |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 195 | #define RANGE_FROM_REG(val) lm85_range_map[(val) & 0x0f] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | /* These are the PWM frequency encodings */ |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 198 | static const int lm85_freq_map[8] = { /* 1 Hz */ |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 199 | 10, 15, 23, 30, 38, 47, 61, 94 |
| 200 | }; |
| 201 | static const int adm1027_freq_map[8] = { /* 1 Hz */ |
| 202 | 11, 15, 22, 29, 35, 44, 59, 88 |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 203 | }; |
| 204 | |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 205 | static int FREQ_TO_REG(const int *map, int freq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | { |
| 207 | int i; |
| 208 | |
Jean Delvare | 86010c9 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 209 | /* Find the closest match */ |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 210 | for (i = 0; i < 7; ++i) |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 211 | if (freq <= (map[i] + map[i + 1]) / 2) |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 212 | break; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 213 | return i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | } |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 215 | |
| 216 | static int FREQ_FROM_REG(const int *map, u8 reg) |
| 217 | { |
| 218 | return map[reg & 0x07]; |
| 219 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
| 221 | /* Since we can't use strings, I'm abusing these numbers |
| 222 | * to stand in for the following meanings: |
| 223 | * 1 -- PWM responds to Zone 1 |
| 224 | * 2 -- PWM responds to Zone 2 |
| 225 | * 3 -- PWM responds to Zone 3 |
| 226 | * 23 -- PWM responds to the higher temp of Zone 2 or 3 |
| 227 | * 123 -- PWM responds to highest of Zone 1, 2, or 3 |
| 228 | * 0 -- PWM is always at 0% (ie, off) |
| 229 | * -1 -- PWM is always at 100% |
| 230 | * -2 -- PWM responds to manual control |
| 231 | */ |
| 232 | |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 233 | static const int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 }; |
| 234 | #define ZONE_FROM_REG(val) lm85_zone_map[(val) >> 5] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 236 | static int ZONE_TO_REG(int zone) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | { |
| 238 | int i; |
| 239 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 240 | for (i = 0; i <= 7; ++i) |
| 241 | if (zone == lm85_zone_map[i]) |
| 242 | break; |
| 243 | if (i > 7) /* Not found. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | i = 3; /* Always 100% */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 245 | return i << 5; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | } |
| 247 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 248 | #define HYST_TO_REG(val) SENSORS_LIMIT(((val) + 500) / 1000, 0, 15) |
| 249 | #define HYST_FROM_REG(val) ((val) * 1000) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | /* Chip sampling rates |
| 252 | * |
| 253 | * Some sensors are not updated more frequently than once per second |
| 254 | * so it doesn't make sense to read them more often than that. |
| 255 | * We cache the results and return the saved data if the driver |
| 256 | * is called again before a second has elapsed. |
| 257 | * |
| 258 | * Also, there is significant configuration data for this chip |
| 259 | * given the automatic PWM fan control that is possible. There |
| 260 | * are about 47 bytes of config data to only 22 bytes of actual |
| 261 | * readings. So, we keep the config data up to date in the cache |
| 262 | * when it is written and only sample it once every 1 *minute* |
| 263 | */ |
| 264 | #define LM85_DATA_INTERVAL (HZ + HZ / 2) |
| 265 | #define LM85_CONFIG_INTERVAL (1 * 60 * HZ) |
| 266 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | /* LM85 can automatically adjust fan speeds based on temperature |
| 268 | * This structure encapsulates an entire Zone config. There are |
| 269 | * three zones (one for each temperature input) on the lm85 |
| 270 | */ |
| 271 | struct lm85_zone { |
| 272 | s8 limit; /* Low temp limit */ |
| 273 | u8 hyst; /* Low limit hysteresis. (0-15) */ |
| 274 | u8 range; /* Temp range, encoded */ |
| 275 | s8 critical; /* "All fans ON" temp limit */ |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 276 | u8 off_desired; /* Actual "off" temperature specified. Preserved |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | * to prevent "drift" as other autofan control |
| 278 | * values change. |
| 279 | */ |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 280 | u8 max_desired; /* Actual "max" temperature specified. Preserved |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | * to prevent "drift" as other autofan control |
| 282 | * values change. |
| 283 | */ |
| 284 | }; |
| 285 | |
| 286 | struct lm85_autofan { |
| 287 | u8 config; /* Register value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | u8 min_pwm; /* Minimum PWM value, encoded */ |
| 289 | u8 min_off; /* Min PWM or OFF below "limit", flag */ |
| 290 | }; |
| 291 | |
Jean Delvare | ed6bafb | 2007-02-14 21:15:03 +0100 | [diff] [blame] | 292 | /* For each registered chip, we need to keep some data in memory. |
| 293 | The structure is dynamically allocated. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | struct lm85_data { |
Tony Jones | 1beeffe | 2007-08-20 13:46:20 -0700 | [diff] [blame] | 295 | struct device *hwmon_dev; |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 296 | const int *freq_map; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | enum chips type; |
| 298 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 299 | struct mutex update_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | int valid; /* !=0 if following fields are valid */ |
| 301 | unsigned long last_reading; /* In jiffies */ |
| 302 | unsigned long last_config; /* In jiffies */ |
| 303 | |
| 304 | u8 in[8]; /* Register value */ |
| 305 | u8 in_max[8]; /* Register value */ |
| 306 | u8 in_min[8]; /* Register value */ |
| 307 | s8 temp[3]; /* Register value */ |
| 308 | s8 temp_min[3]; /* Register value */ |
| 309 | s8 temp_max[3]; /* Register value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | u16 fan[4]; /* Register value */ |
| 311 | u16 fan_min[4]; /* Register value */ |
| 312 | u8 pwm[3]; /* Register value */ |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 313 | u8 pwm_freq[3]; /* Register encoding */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | u8 temp_ext[3]; /* Decoded values */ |
| 315 | u8 in_ext[8]; /* Decoded values */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | u8 vid; /* Register value */ |
| 317 | u8 vrm; /* VRM version */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | u32 alarms; /* Register encoding, combined */ |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 319 | u8 cfg5; /* Config Register 5 on ADT7468 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | struct lm85_autofan autofan[3]; |
| 321 | struct lm85_zone zone[3]; |
| 322 | }; |
| 323 | |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 324 | static int lm85_detect(struct i2c_client *client, int kind, |
| 325 | struct i2c_board_info *info); |
| 326 | static int lm85_probe(struct i2c_client *client, |
| 327 | const struct i2c_device_id *id); |
| 328 | static int lm85_remove(struct i2c_client *client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
Darren Jenkins | f6c27fc | 2006-02-27 23:14:58 +0100 | [diff] [blame] | 330 | static int lm85_read_value(struct i2c_client *client, u8 reg); |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 331 | static void lm85_write_value(struct i2c_client *client, u8 reg, int value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | static struct lm85_data *lm85_update_device(struct device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | |
| 334 | |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 335 | static const struct i2c_device_id lm85_id[] = { |
| 336 | { "adm1027", adm1027 }, |
| 337 | { "adt7463", adt7463 }, |
Darrick J. Wong | c15ade6 | 2009-03-10 12:55:47 -0700 | [diff] [blame] | 338 | { "adt7468", adt7468 }, |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 339 | { "lm85", any_chip }, |
| 340 | { "lm85b", lm85b }, |
| 341 | { "lm85c", lm85c }, |
| 342 | { "emc6d100", emc6d100 }, |
| 343 | { "emc6d101", emc6d100 }, |
| 344 | { "emc6d102", emc6d102 }, |
| 345 | { } |
| 346 | }; |
| 347 | MODULE_DEVICE_TABLE(i2c, lm85_id); |
| 348 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | static struct i2c_driver lm85_driver = { |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 350 | .class = I2C_CLASS_HWMON, |
Laurent Riffard | cdaf793 | 2005-11-26 20:37:41 +0100 | [diff] [blame] | 351 | .driver = { |
Laurent Riffard | cdaf793 | 2005-11-26 20:37:41 +0100 | [diff] [blame] | 352 | .name = "lm85", |
| 353 | }, |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 354 | .probe = lm85_probe, |
| 355 | .remove = lm85_remove, |
| 356 | .id_table = lm85_id, |
| 357 | .detect = lm85_detect, |
| 358 | .address_data = &addr_data, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | }; |
| 360 | |
| 361 | |
| 362 | /* 4 Fans */ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 363 | static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
| 364 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 366 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 368 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 370 | |
| 371 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
| 372 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 374 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 376 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 378 | |
| 379 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
| 380 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 382 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | struct i2c_client *client = to_i2c_client(dev); |
| 384 | struct lm85_data *data = i2c_get_clientdata(client); |
Jean Delvare | 63f281a | 2007-07-05 20:39:40 +0200 | [diff] [blame] | 385 | unsigned long val = simple_strtoul(buf, NULL, 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 387 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | data->fan_min[nr] = FAN_TO_REG(val); |
| 389 | lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 390 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | return count; |
| 392 | } |
| 393 | |
| 394 | #define show_fan_offset(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 395 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ |
| 396 | show_fan, NULL, offset - 1); \ |
| 397 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
| 398 | show_fan_min, set_fan_min, offset - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | |
| 400 | show_fan_offset(1); |
| 401 | show_fan_offset(2); |
| 402 | show_fan_offset(3); |
| 403 | show_fan_offset(4); |
| 404 | |
| 405 | /* vid, vrm, alarms */ |
| 406 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 407 | static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, |
| 408 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | { |
| 410 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 9c516ef | 2005-11-26 20:07:54 +0100 | [diff] [blame] | 411 | int vid; |
| 412 | |
Darrick J. Wong | 8ef1f02 | 2009-03-10 12:55:48 -0700 | [diff] [blame^] | 413 | if ((data->type == adt7463 || data->type == adt7468) && |
| 414 | (data->vid & 0x80)) { |
Jean Delvare | 9c516ef | 2005-11-26 20:07:54 +0100 | [diff] [blame] | 415 | /* 6-pin VID (VRM 10) */ |
| 416 | vid = vid_from_reg(data->vid & 0x3f, data->vrm); |
| 417 | } else { |
| 418 | /* 5-pin VID (VRM 9) */ |
| 419 | vid = vid_from_reg(data->vid & 0x1f, data->vrm); |
| 420 | } |
| 421 | |
| 422 | return sprintf(buf, "%d\n", vid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); |
| 426 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 427 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, |
| 428 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | { |
Jean Delvare | 90d6619 | 2007-10-08 18:24:35 +0200 | [diff] [blame] | 430 | struct lm85_data *data = dev_get_drvdata(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | return sprintf(buf, "%ld\n", (long) data->vrm); |
| 432 | } |
| 433 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 434 | static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, |
| 435 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | { |
Jean Delvare | 8f74efe | 2007-12-01 11:25:33 +0100 | [diff] [blame] | 437 | struct lm85_data *data = dev_get_drvdata(dev); |
| 438 | data->vrm = simple_strtoul(buf, NULL, 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | return count; |
| 440 | } |
| 441 | |
| 442 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); |
| 443 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 444 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute |
| 445 | *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | { |
| 447 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 68188ba | 2005-05-16 18:52:38 +0200 | [diff] [blame] | 448 | return sprintf(buf, "%u\n", data->alarms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); |
| 452 | |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 453 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
| 454 | char *buf) |
| 455 | { |
| 456 | int nr = to_sensor_dev_attr(attr)->index; |
| 457 | struct lm85_data *data = lm85_update_device(dev); |
| 458 | return sprintf(buf, "%u\n", (data->alarms >> nr) & 1); |
| 459 | } |
| 460 | |
| 461 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); |
| 462 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); |
| 463 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); |
| 464 | static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); |
| 465 | static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); |
| 466 | static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 18); |
| 467 | static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 16); |
| 468 | static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 17); |
| 469 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); |
| 470 | static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_alarm, NULL, 14); |
| 471 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5); |
| 472 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 6); |
| 473 | static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 15); |
| 474 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 10); |
| 475 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 11); |
| 476 | static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 12); |
| 477 | static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 13); |
| 478 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | /* pwm */ |
| 480 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 481 | static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, |
| 482 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 484 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 486 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 488 | |
| 489 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
| 490 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 492 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | struct i2c_client *client = to_i2c_client(dev); |
| 494 | struct lm85_data *data = i2c_get_clientdata(client); |
| 495 | long val = simple_strtol(buf, NULL, 10); |
| 496 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 497 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | data->pwm[nr] = PWM_TO_REG(val); |
| 499 | lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 500 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | return count; |
| 502 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 503 | |
| 504 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute |
| 505 | *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 507 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 4b4df95 | 2007-12-03 23:23:21 +0100 | [diff] [blame] | 509 | int pwm_zone, enable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | |
| 511 | pwm_zone = ZONE_FROM_REG(data->autofan[nr].config); |
Jean Delvare | 4b4df95 | 2007-12-03 23:23:21 +0100 | [diff] [blame] | 512 | switch (pwm_zone) { |
| 513 | case -1: /* PWM is always at 100% */ |
| 514 | enable = 0; |
| 515 | break; |
| 516 | case 0: /* PWM is always at 0% */ |
| 517 | case -2: /* PWM responds to manual control */ |
| 518 | enable = 1; |
| 519 | break; |
| 520 | default: /* PWM in automatic mode */ |
| 521 | enable = 2; |
| 522 | } |
| 523 | return sprintf(buf, "%d\n", enable); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | } |
| 525 | |
Jean Delvare | 455f791 | 2007-12-03 23:28:42 +0100 | [diff] [blame] | 526 | static ssize_t set_pwm_enable(struct device *dev, struct device_attribute |
| 527 | *attr, const char *buf, size_t count) |
| 528 | { |
| 529 | int nr = to_sensor_dev_attr(attr)->index; |
| 530 | struct i2c_client *client = to_i2c_client(dev); |
| 531 | struct lm85_data *data = i2c_get_clientdata(client); |
| 532 | long val = simple_strtol(buf, NULL, 10); |
| 533 | u8 config; |
| 534 | |
| 535 | switch (val) { |
| 536 | case 0: |
| 537 | config = 3; |
| 538 | break; |
| 539 | case 1: |
| 540 | config = 7; |
| 541 | break; |
| 542 | case 2: |
| 543 | /* Here we have to choose arbitrarily one of the 5 possible |
| 544 | configurations; I go for the safest */ |
| 545 | config = 6; |
| 546 | break; |
| 547 | default: |
| 548 | return -EINVAL; |
| 549 | } |
| 550 | |
| 551 | mutex_lock(&data->update_lock); |
| 552 | data->autofan[nr].config = lm85_read_value(client, |
| 553 | LM85_REG_AFAN_CONFIG(nr)); |
| 554 | data->autofan[nr].config = (data->autofan[nr].config & ~0xe0) |
| 555 | | (config << 5); |
| 556 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), |
| 557 | data->autofan[nr].config); |
| 558 | mutex_unlock(&data->update_lock); |
| 559 | return count; |
| 560 | } |
| 561 | |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 562 | static ssize_t show_pwm_freq(struct device *dev, |
| 563 | struct device_attribute *attr, char *buf) |
| 564 | { |
| 565 | int nr = to_sensor_dev_attr(attr)->index; |
| 566 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 567 | return sprintf(buf, "%d\n", FREQ_FROM_REG(data->freq_map, |
| 568 | data->pwm_freq[nr])); |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | static ssize_t set_pwm_freq(struct device *dev, |
| 572 | struct device_attribute *attr, const char *buf, size_t count) |
| 573 | { |
| 574 | int nr = to_sensor_dev_attr(attr)->index; |
| 575 | struct i2c_client *client = to_i2c_client(dev); |
| 576 | struct lm85_data *data = i2c_get_clientdata(client); |
| 577 | long val = simple_strtol(buf, NULL, 10); |
| 578 | |
| 579 | mutex_lock(&data->update_lock); |
Jean Delvare | 8a0795d | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 580 | data->pwm_freq[nr] = FREQ_TO_REG(data->freq_map, val); |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 581 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
| 582 | (data->zone[nr].range << 4) |
| 583 | | data->pwm_freq[nr]); |
| 584 | mutex_unlock(&data->update_lock); |
| 585 | return count; |
| 586 | } |
| 587 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | #define show_pwm_reg(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 589 | static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ |
| 590 | show_pwm, set_pwm, offset - 1); \ |
Jean Delvare | 455f791 | 2007-12-03 23:28:42 +0100 | [diff] [blame] | 591 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 592 | show_pwm_enable, set_pwm_enable, offset - 1); \ |
| 593 | static SENSOR_DEVICE_ATTR(pwm##offset##_freq, S_IRUGO | S_IWUSR, \ |
| 594 | show_pwm_freq, set_pwm_freq, offset - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | |
| 596 | show_pwm_reg(1); |
| 597 | show_pwm_reg(2); |
| 598 | show_pwm_reg(3); |
| 599 | |
| 600 | /* Voltages */ |
| 601 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 602 | static ssize_t show_in(struct device *dev, struct device_attribute *attr, |
| 603 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 605 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 607 | return sprintf(buf, "%d\n", INSEXT_FROM_REG(nr, data->in[nr], |
| 608 | data->in_ext[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 610 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 611 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 612 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 614 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 616 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_min[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 618 | |
| 619 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
| 620 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 622 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | struct i2c_client *client = to_i2c_client(dev); |
| 624 | struct lm85_data *data = i2c_get_clientdata(client); |
| 625 | long val = simple_strtol(buf, NULL, 10); |
| 626 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 627 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | data->in_min[nr] = INS_TO_REG(nr, val); |
| 629 | lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 630 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | return count; |
| 632 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 633 | |
| 634 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
| 635 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 637 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 639 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_max[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 641 | |
| 642 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
| 643 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 645 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | struct i2c_client *client = to_i2c_client(dev); |
| 647 | struct lm85_data *data = i2c_get_clientdata(client); |
| 648 | long val = simple_strtol(buf, NULL, 10); |
| 649 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 650 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | data->in_max[nr] = INS_TO_REG(nr, val); |
| 652 | lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 653 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | return count; |
| 655 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 656 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | #define show_in_reg(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 658 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
| 659 | show_in, NULL, offset); \ |
| 660 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ |
| 661 | show_in_min, set_in_min, offset); \ |
| 662 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ |
| 663 | show_in_max, set_in_max, offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | |
| 665 | show_in_reg(0); |
| 666 | show_in_reg(1); |
| 667 | show_in_reg(2); |
| 668 | show_in_reg(3); |
| 669 | show_in_reg(4); |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 670 | show_in_reg(5); |
| 671 | show_in_reg(6); |
| 672 | show_in_reg(7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | |
| 674 | /* Temps */ |
| 675 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 676 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, |
| 677 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 679 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 681 | return sprintf(buf, "%d\n", TEMPEXT_FROM_REG(data->temp[nr], |
| 682 | data->temp_ext[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 684 | |
| 685 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, |
| 686 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 688 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 690 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 692 | |
| 693 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
| 694 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 696 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | struct i2c_client *client = to_i2c_client(dev); |
| 698 | struct lm85_data *data = i2c_get_clientdata(client); |
| 699 | long val = simple_strtol(buf, NULL, 10); |
| 700 | |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 701 | if (IS_ADT7468_OFF64(data)) |
| 702 | val += 64; |
| 703 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 704 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | data->temp_min[nr] = TEMP_TO_REG(val); |
| 706 | lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 707 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | return count; |
| 709 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 710 | |
| 711 | static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
| 712 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 714 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 716 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 718 | |
| 719 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
| 720 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 722 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | struct i2c_client *client = to_i2c_client(dev); |
| 724 | struct lm85_data *data = i2c_get_clientdata(client); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 725 | long val = simple_strtol(buf, NULL, 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 727 | if (IS_ADT7468_OFF64(data)) |
| 728 | val += 64; |
| 729 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 730 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | data->temp_max[nr] = TEMP_TO_REG(val); |
| 732 | lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 733 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | return count; |
| 735 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 736 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | #define show_temp_reg(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 738 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ |
| 739 | show_temp, NULL, offset - 1); \ |
| 740 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
| 741 | show_temp_min, set_temp_min, offset - 1); \ |
| 742 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
| 743 | show_temp_max, set_temp_max, offset - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | |
| 745 | show_temp_reg(1); |
| 746 | show_temp_reg(2); |
| 747 | show_temp_reg(3); |
| 748 | |
| 749 | |
| 750 | /* Automatic PWM control */ |
| 751 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 752 | static ssize_t show_pwm_auto_channels(struct device *dev, |
| 753 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 755 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 757 | return sprintf(buf, "%d\n", ZONE_FROM_REG(data->autofan[nr].config)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 759 | |
| 760 | static ssize_t set_pwm_auto_channels(struct device *dev, |
| 761 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 763 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | struct i2c_client *client = to_i2c_client(dev); |
| 765 | struct lm85_data *data = i2c_get_clientdata(client); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 766 | long val = simple_strtol(buf, NULL, 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 768 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 770 | | ZONE_TO_REG(val); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), |
| 772 | data->autofan[nr].config); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 773 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | return count; |
| 775 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 776 | |
| 777 | static ssize_t show_pwm_auto_pwm_min(struct device *dev, |
| 778 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 780 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 782 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 784 | |
| 785 | static ssize_t set_pwm_auto_pwm_min(struct device *dev, |
| 786 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 788 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | struct i2c_client *client = to_i2c_client(dev); |
| 790 | struct lm85_data *data = i2c_get_clientdata(client); |
| 791 | long val = simple_strtol(buf, NULL, 10); |
| 792 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 793 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | data->autofan[nr].min_pwm = PWM_TO_REG(val); |
| 795 | lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr), |
| 796 | data->autofan[nr].min_pwm); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 797 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | return count; |
| 799 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 800 | |
| 801 | static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, |
| 802 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 804 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 806 | return sprintf(buf, "%d\n", data->autofan[nr].min_off); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 808 | |
| 809 | static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, |
| 810 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 812 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | struct i2c_client *client = to_i2c_client(dev); |
| 814 | struct lm85_data *data = i2c_get_clientdata(client); |
| 815 | long val = simple_strtol(buf, NULL, 10); |
Jean Delvare | 7133e56 | 2008-04-12 19:56:35 +0200 | [diff] [blame] | 816 | u8 tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 818 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | data->autofan[nr].min_off = val; |
Jean Delvare | 7133e56 | 2008-04-12 19:56:35 +0200 | [diff] [blame] | 820 | tmp = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); |
| 821 | tmp &= ~(0x20 << nr); |
| 822 | if (data->autofan[nr].min_off) |
| 823 | tmp |= 0x20 << nr; |
| 824 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, tmp); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 825 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | return count; |
| 827 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 828 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | #define pwm_auto(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 830 | static SENSOR_DEVICE_ATTR(pwm##offset##_auto_channels, \ |
| 831 | S_IRUGO | S_IWUSR, show_pwm_auto_channels, \ |
| 832 | set_pwm_auto_channels, offset - 1); \ |
| 833 | static SENSOR_DEVICE_ATTR(pwm##offset##_auto_pwm_min, \ |
| 834 | S_IRUGO | S_IWUSR, show_pwm_auto_pwm_min, \ |
| 835 | set_pwm_auto_pwm_min, offset - 1); \ |
| 836 | static SENSOR_DEVICE_ATTR(pwm##offset##_auto_pwm_minctl, \ |
| 837 | S_IRUGO | S_IWUSR, show_pwm_auto_pwm_minctl, \ |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 838 | set_pwm_auto_pwm_minctl, offset - 1) |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 839 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | pwm_auto(1); |
| 841 | pwm_auto(2); |
| 842 | pwm_auto(3); |
| 843 | |
| 844 | /* Temperature settings for automatic PWM control */ |
| 845 | |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 846 | static ssize_t show_temp_auto_temp_off(struct device *dev, |
| 847 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 849 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 851 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit) - |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | HYST_FROM_REG(data->zone[nr].hyst)); |
| 853 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 854 | |
| 855 | static ssize_t set_temp_auto_temp_off(struct device *dev, |
| 856 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 858 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | struct i2c_client *client = to_i2c_client(dev); |
| 860 | struct lm85_data *data = i2c_get_clientdata(client); |
| 861 | int min; |
| 862 | long val = simple_strtol(buf, NULL, 10); |
| 863 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 864 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | min = TEMP_FROM_REG(data->zone[nr].limit); |
| 866 | data->zone[nr].off_desired = TEMP_TO_REG(val); |
| 867 | data->zone[nr].hyst = HYST_TO_REG(min - val); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 868 | if (nr == 0 || nr == 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | lm85_write_value(client, LM85_REG_AFAN_HYST1, |
| 870 | (data->zone[0].hyst << 4) |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 871 | | data->zone[1].hyst); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | } else { |
| 873 | lm85_write_value(client, LM85_REG_AFAN_HYST2, |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 874 | (data->zone[2].hyst << 4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | } |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 876 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | return count; |
| 878 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 879 | |
| 880 | static ssize_t show_temp_auto_temp_min(struct device *dev, |
| 881 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 883 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 885 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 887 | |
| 888 | static ssize_t set_temp_auto_temp_min(struct device *dev, |
| 889 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 891 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | struct i2c_client *client = to_i2c_client(dev); |
| 893 | struct lm85_data *data = i2c_get_clientdata(client); |
| 894 | long val = simple_strtol(buf, NULL, 10); |
| 895 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 896 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | data->zone[nr].limit = TEMP_TO_REG(val); |
| 898 | lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr), |
| 899 | data->zone[nr].limit); |
| 900 | |
| 901 | /* Update temp_auto_max and temp_auto_range */ |
| 902 | data->zone[nr].range = RANGE_TO_REG( |
| 903 | TEMP_FROM_REG(data->zone[nr].max_desired) - |
| 904 | TEMP_FROM_REG(data->zone[nr].limit)); |
| 905 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
| 906 | ((data->zone[nr].range & 0x0f) << 4) |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 907 | | (data->pwm_freq[nr] & 0x07)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | |
| 909 | /* Update temp_auto_hyst and temp_auto_off */ |
| 910 | data->zone[nr].hyst = HYST_TO_REG(TEMP_FROM_REG( |
| 911 | data->zone[nr].limit) - TEMP_FROM_REG( |
| 912 | data->zone[nr].off_desired)); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 913 | if (nr == 0 || nr == 1) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | lm85_write_value(client, LM85_REG_AFAN_HYST1, |
| 915 | (data->zone[0].hyst << 4) |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 916 | | data->zone[1].hyst); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | } else { |
| 918 | lm85_write_value(client, LM85_REG_AFAN_HYST2, |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 919 | (data->zone[2].hyst << 4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | } |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 921 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | return count; |
| 923 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 924 | |
| 925 | static ssize_t show_temp_auto_temp_max(struct device *dev, |
| 926 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 928 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 930 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit) + |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | RANGE_FROM_REG(data->zone[nr].range)); |
| 932 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 933 | |
| 934 | static ssize_t set_temp_auto_temp_max(struct device *dev, |
| 935 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 937 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | struct i2c_client *client = to_i2c_client(dev); |
| 939 | struct lm85_data *data = i2c_get_clientdata(client); |
| 940 | int min; |
| 941 | long val = simple_strtol(buf, NULL, 10); |
| 942 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 943 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | min = TEMP_FROM_REG(data->zone[nr].limit); |
| 945 | data->zone[nr].max_desired = TEMP_TO_REG(val); |
| 946 | data->zone[nr].range = RANGE_TO_REG( |
| 947 | val - min); |
| 948 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
| 949 | ((data->zone[nr].range & 0x0f) << 4) |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 950 | | (data->pwm_freq[nr] & 0x07)); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 951 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | return count; |
| 953 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 954 | |
| 955 | static ssize_t show_temp_auto_temp_crit(struct device *dev, |
| 956 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 958 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | struct lm85_data *data = lm85_update_device(dev); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 960 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].critical)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 962 | |
| 963 | static ssize_t set_temp_auto_temp_crit(struct device *dev, |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 964 | struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 966 | int nr = to_sensor_dev_attr(attr)->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | struct i2c_client *client = to_i2c_client(dev); |
| 968 | struct lm85_data *data = i2c_get_clientdata(client); |
| 969 | long val = simple_strtol(buf, NULL, 10); |
| 970 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 971 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | data->zone[nr].critical = TEMP_TO_REG(val); |
| 973 | lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr), |
| 974 | data->zone[nr].critical); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 975 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | return count; |
| 977 | } |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 978 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | #define temp_auto(offset) \ |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 980 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_off, \ |
| 981 | S_IRUGO | S_IWUSR, show_temp_auto_temp_off, \ |
| 982 | set_temp_auto_temp_off, offset - 1); \ |
| 983 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_min, \ |
| 984 | S_IRUGO | S_IWUSR, show_temp_auto_temp_min, \ |
| 985 | set_temp_auto_temp_min, offset - 1); \ |
| 986 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_max, \ |
| 987 | S_IRUGO | S_IWUSR, show_temp_auto_temp_max, \ |
| 988 | set_temp_auto_temp_max, offset - 1); \ |
| 989 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_crit, \ |
| 990 | S_IRUGO | S_IWUSR, show_temp_auto_temp_crit, \ |
| 991 | set_temp_auto_temp_crit, offset - 1); |
| 992 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | temp_auto(1); |
| 994 | temp_auto(2); |
| 995 | temp_auto(3); |
| 996 | |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 997 | static struct attribute *lm85_attributes[] = { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 998 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
| 999 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
| 1000 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
| 1001 | &sensor_dev_attr_fan4_input.dev_attr.attr, |
| 1002 | &sensor_dev_attr_fan1_min.dev_attr.attr, |
| 1003 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
| 1004 | &sensor_dev_attr_fan3_min.dev_attr.attr, |
| 1005 | &sensor_dev_attr_fan4_min.dev_attr.attr, |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 1006 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, |
| 1007 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, |
| 1008 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, |
| 1009 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1010 | |
| 1011 | &sensor_dev_attr_pwm1.dev_attr.attr, |
| 1012 | &sensor_dev_attr_pwm2.dev_attr.attr, |
| 1013 | &sensor_dev_attr_pwm3.dev_attr.attr, |
| 1014 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, |
| 1015 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, |
| 1016 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1017 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, |
| 1018 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, |
| 1019 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1020 | |
| 1021 | &sensor_dev_attr_in0_input.dev_attr.attr, |
| 1022 | &sensor_dev_attr_in1_input.dev_attr.attr, |
| 1023 | &sensor_dev_attr_in2_input.dev_attr.attr, |
| 1024 | &sensor_dev_attr_in3_input.dev_attr.attr, |
| 1025 | &sensor_dev_attr_in0_min.dev_attr.attr, |
| 1026 | &sensor_dev_attr_in1_min.dev_attr.attr, |
| 1027 | &sensor_dev_attr_in2_min.dev_attr.attr, |
| 1028 | &sensor_dev_attr_in3_min.dev_attr.attr, |
| 1029 | &sensor_dev_attr_in0_max.dev_attr.attr, |
| 1030 | &sensor_dev_attr_in1_max.dev_attr.attr, |
| 1031 | &sensor_dev_attr_in2_max.dev_attr.attr, |
| 1032 | &sensor_dev_attr_in3_max.dev_attr.attr, |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 1033 | &sensor_dev_attr_in0_alarm.dev_attr.attr, |
| 1034 | &sensor_dev_attr_in1_alarm.dev_attr.attr, |
| 1035 | &sensor_dev_attr_in2_alarm.dev_attr.attr, |
| 1036 | &sensor_dev_attr_in3_alarm.dev_attr.attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1037 | |
| 1038 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
| 1039 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
| 1040 | &sensor_dev_attr_temp3_input.dev_attr.attr, |
| 1041 | &sensor_dev_attr_temp1_min.dev_attr.attr, |
| 1042 | &sensor_dev_attr_temp2_min.dev_attr.attr, |
| 1043 | &sensor_dev_attr_temp3_min.dev_attr.attr, |
| 1044 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
| 1045 | &sensor_dev_attr_temp2_max.dev_attr.attr, |
| 1046 | &sensor_dev_attr_temp3_max.dev_attr.attr, |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 1047 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, |
| 1048 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, |
| 1049 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, |
| 1050 | &sensor_dev_attr_temp1_fault.dev_attr.attr, |
| 1051 | &sensor_dev_attr_temp3_fault.dev_attr.attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1052 | |
| 1053 | &sensor_dev_attr_pwm1_auto_channels.dev_attr.attr, |
| 1054 | &sensor_dev_attr_pwm2_auto_channels.dev_attr.attr, |
| 1055 | &sensor_dev_attr_pwm3_auto_channels.dev_attr.attr, |
| 1056 | &sensor_dev_attr_pwm1_auto_pwm_min.dev_attr.attr, |
| 1057 | &sensor_dev_attr_pwm2_auto_pwm_min.dev_attr.attr, |
| 1058 | &sensor_dev_attr_pwm3_auto_pwm_min.dev_attr.attr, |
| 1059 | &sensor_dev_attr_pwm1_auto_pwm_minctl.dev_attr.attr, |
| 1060 | &sensor_dev_attr_pwm2_auto_pwm_minctl.dev_attr.attr, |
| 1061 | &sensor_dev_attr_pwm3_auto_pwm_minctl.dev_attr.attr, |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1062 | |
| 1063 | &sensor_dev_attr_temp1_auto_temp_off.dev_attr.attr, |
| 1064 | &sensor_dev_attr_temp2_auto_temp_off.dev_attr.attr, |
| 1065 | &sensor_dev_attr_temp3_auto_temp_off.dev_attr.attr, |
| 1066 | &sensor_dev_attr_temp1_auto_temp_min.dev_attr.attr, |
| 1067 | &sensor_dev_attr_temp2_auto_temp_min.dev_attr.attr, |
| 1068 | &sensor_dev_attr_temp3_auto_temp_min.dev_attr.attr, |
| 1069 | &sensor_dev_attr_temp1_auto_temp_max.dev_attr.attr, |
| 1070 | &sensor_dev_attr_temp2_auto_temp_max.dev_attr.attr, |
| 1071 | &sensor_dev_attr_temp3_auto_temp_max.dev_attr.attr, |
| 1072 | &sensor_dev_attr_temp1_auto_temp_crit.dev_attr.attr, |
| 1073 | &sensor_dev_attr_temp2_auto_temp_crit.dev_attr.attr, |
| 1074 | &sensor_dev_attr_temp3_auto_temp_crit.dev_attr.attr, |
| 1075 | |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1076 | &dev_attr_vrm.attr, |
| 1077 | &dev_attr_cpu0_vid.attr, |
| 1078 | &dev_attr_alarms.attr, |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1079 | NULL |
| 1080 | }; |
| 1081 | |
| 1082 | static const struct attribute_group lm85_group = { |
| 1083 | .attrs = lm85_attributes, |
| 1084 | }; |
| 1085 | |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1086 | static struct attribute *lm85_attributes_in4[] = { |
Jean Delvare | b353a48 | 2007-07-05 20:36:12 +0200 | [diff] [blame] | 1087 | &sensor_dev_attr_in4_input.dev_attr.attr, |
| 1088 | &sensor_dev_attr_in4_min.dev_attr.attr, |
| 1089 | &sensor_dev_attr_in4_max.dev_attr.attr, |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 1090 | &sensor_dev_attr_in4_alarm.dev_attr.attr, |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1091 | NULL |
| 1092 | }; |
| 1093 | |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1094 | static const struct attribute_group lm85_group_in4 = { |
| 1095 | .attrs = lm85_attributes_in4, |
| 1096 | }; |
| 1097 | |
| 1098 | static struct attribute *lm85_attributes_in567[] = { |
| 1099 | &sensor_dev_attr_in5_input.dev_attr.attr, |
| 1100 | &sensor_dev_attr_in6_input.dev_attr.attr, |
| 1101 | &sensor_dev_attr_in7_input.dev_attr.attr, |
| 1102 | &sensor_dev_attr_in5_min.dev_attr.attr, |
| 1103 | &sensor_dev_attr_in6_min.dev_attr.attr, |
| 1104 | &sensor_dev_attr_in7_min.dev_attr.attr, |
| 1105 | &sensor_dev_attr_in5_max.dev_attr.attr, |
| 1106 | &sensor_dev_attr_in6_max.dev_attr.attr, |
| 1107 | &sensor_dev_attr_in7_max.dev_attr.attr, |
Jean Delvare | bf76e9d | 2007-07-05 20:37:58 +0200 | [diff] [blame] | 1108 | &sensor_dev_attr_in5_alarm.dev_attr.attr, |
| 1109 | &sensor_dev_attr_in6_alarm.dev_attr.attr, |
| 1110 | &sensor_dev_attr_in7_alarm.dev_attr.attr, |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1111 | NULL |
| 1112 | }; |
| 1113 | |
| 1114 | static const struct attribute_group lm85_group_in567 = { |
| 1115 | .attrs = lm85_attributes_in567, |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1116 | }; |
| 1117 | |
Jean Delvare | 5f4475947 | 2008-06-25 09:10:30 -0400 | [diff] [blame] | 1118 | static void lm85_init_client(struct i2c_client *client) |
| 1119 | { |
| 1120 | int value; |
| 1121 | |
| 1122 | /* Start monitoring if needed */ |
| 1123 | value = lm85_read_value(client, LM85_REG_CONFIG); |
| 1124 | if (!(value & 0x01)) { |
| 1125 | dev_info(&client->dev, "Starting monitoring\n"); |
| 1126 | lm85_write_value(client, LM85_REG_CONFIG, value | 0x01); |
| 1127 | } |
| 1128 | |
| 1129 | /* Warn about unusual configuration bits */ |
| 1130 | if (value & 0x02) |
| 1131 | dev_warn(&client->dev, "Device configuration is locked\n"); |
| 1132 | if (!(value & 0x04)) |
| 1133 | dev_warn(&client->dev, "Device is not ready\n"); |
| 1134 | } |
| 1135 | |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1136 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
| 1137 | static int lm85_detect(struct i2c_client *client, int kind, |
| 1138 | struct i2c_board_info *info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1139 | { |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1140 | struct i2c_adapter *adapter = client->adapter; |
| 1141 | int address = client->addr; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1142 | const char *type_name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1143 | |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1144 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | /* We need to be able to do byte I/O */ |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1146 | return -ENODEV; |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1147 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | |
Jean Delvare | 69fc1fe | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1149 | /* If auto-detecting, determine the chip type */ |
| 1150 | if (kind < 0) { |
| 1151 | int company = lm85_read_value(client, LM85_REG_COMPANY); |
| 1152 | int verstep = lm85_read_value(client, LM85_REG_VERSTEP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | |
Jean Delvare | 69fc1fe | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1154 | dev_dbg(&adapter->dev, "Detecting device at 0x%02x with " |
| 1155 | "COMPANY: 0x%02x and VERSTEP: 0x%02x\n", |
| 1156 | address, company, verstep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1157 | |
Jean Delvare | 69fc1fe | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1158 | /* All supported chips have the version in common */ |
Darrick J. Wong | c15ade6 | 2009-03-10 12:55:47 -0700 | [diff] [blame] | 1159 | if ((verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC && |
| 1160 | (verstep & LM85_VERSTEP_VMASK) != LM85_VERSTEP_GENERIC2) { |
Jean Delvare | 69fc1fe | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1161 | dev_dbg(&adapter->dev, "Autodetection failed: " |
| 1162 | "unsupported version\n"); |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1163 | return -ENODEV; |
Jean Delvare | 69fc1fe | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1164 | } |
| 1165 | kind = any_chip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | |
Jean Delvare | 69fc1fe | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1167 | /* Now, refine the detection */ |
| 1168 | if (company == LM85_COMPANY_NATIONAL) { |
| 1169 | switch (verstep) { |
| 1170 | case LM85_VERSTEP_LM85C: |
| 1171 | kind = lm85c; |
| 1172 | break; |
| 1173 | case LM85_VERSTEP_LM85B: |
| 1174 | kind = lm85b; |
| 1175 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | } |
Jean Delvare | 69fc1fe | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1177 | } else if (company == LM85_COMPANY_ANALOG_DEV) { |
| 1178 | switch (verstep) { |
| 1179 | case LM85_VERSTEP_ADM1027: |
| 1180 | kind = adm1027; |
| 1181 | break; |
| 1182 | case LM85_VERSTEP_ADT7463: |
| 1183 | case LM85_VERSTEP_ADT7463C: |
| 1184 | kind = adt7463; |
| 1185 | break; |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 1186 | case LM85_VERSTEP_ADT7468_1: |
| 1187 | case LM85_VERSTEP_ADT7468_2: |
| 1188 | kind = adt7468; |
| 1189 | break; |
Jean Delvare | 69fc1fe | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1190 | } |
| 1191 | } else if (company == LM85_COMPANY_SMSC) { |
| 1192 | switch (verstep) { |
| 1193 | case LM85_VERSTEP_EMC6D100_A0: |
| 1194 | case LM85_VERSTEP_EMC6D100_A1: |
| 1195 | /* Note: we can't tell a '100 from a '101 */ |
| 1196 | kind = emc6d100; |
| 1197 | break; |
| 1198 | case LM85_VERSTEP_EMC6D102: |
| 1199 | kind = emc6d102; |
| 1200 | break; |
| 1201 | } |
| 1202 | } else { |
| 1203 | dev_dbg(&adapter->dev, "Autodetection failed: " |
| 1204 | "unknown vendor\n"); |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1205 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | } |
| 1207 | } |
| 1208 | |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1209 | switch (kind) { |
| 1210 | case lm85b: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | type_name = "lm85b"; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1212 | break; |
| 1213 | case lm85c: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | type_name = "lm85c"; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1215 | break; |
| 1216 | case adm1027: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | type_name = "adm1027"; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1218 | break; |
| 1219 | case adt7463: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | type_name = "adt7463"; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1221 | break; |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 1222 | case adt7468: |
| 1223 | type_name = "adt7468"; |
| 1224 | break; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1225 | case emc6d100: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | type_name = "emc6d100"; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1227 | break; |
| 1228 | case emc6d102: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1229 | type_name = "emc6d102"; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1230 | break; |
| 1231 | default: |
| 1232 | type_name = "lm85"; |
| 1233 | } |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1234 | strlcpy(info->type, type_name, I2C_NAME_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1235 | |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1236 | return 0; |
| 1237 | } |
| 1238 | |
| 1239 | static int lm85_probe(struct i2c_client *client, |
| 1240 | const struct i2c_device_id *id) |
| 1241 | { |
| 1242 | struct lm85_data *data; |
| 1243 | int err; |
| 1244 | |
| 1245 | data = kzalloc(sizeof(struct lm85_data), GFP_KERNEL); |
| 1246 | if (!data) |
| 1247 | return -ENOMEM; |
| 1248 | |
| 1249 | i2c_set_clientdata(client, data); |
| 1250 | data->type = id->driver_data; |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1251 | mutex_init(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1253 | /* Fill in the chip specific driver values */ |
| 1254 | switch (data->type) { |
| 1255 | case adm1027: |
| 1256 | case adt7463: |
| 1257 | case emc6d100: |
| 1258 | case emc6d102: |
| 1259 | data->freq_map = adm1027_freq_map; |
| 1260 | break; |
| 1261 | default: |
| 1262 | data->freq_map = lm85_freq_map; |
| 1263 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1264 | |
| 1265 | /* Set the VRM version */ |
Jean Delvare | 303760b | 2005-07-31 21:52:01 +0200 | [diff] [blame] | 1266 | data->vrm = vid_which_vrm(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | |
| 1268 | /* Initialize the LM85 chip */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1269 | lm85_init_client(client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1270 | |
| 1271 | /* Register sysfs hooks */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1272 | err = sysfs_create_group(&client->dev.kobj, &lm85_group); |
| 1273 | if (err) |
Jean Delvare | f908037 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1274 | goto err_kfree; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1275 | |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 1276 | /* The ADT7463/68 have an optional VRM 10 mode where pin 21 is used |
Jean Delvare | 9c516ef | 2005-11-26 20:07:54 +0100 | [diff] [blame] | 1277 | as a sixth digital VID input rather than an analog input. */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1278 | data->vid = lm85_read_value(client, LM85_REG_VID); |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 1279 | if (!((data->type == adt7463 || data->type == adt7468) && |
| 1280 | (data->vid & 0x80))) |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1281 | if ((err = sysfs_create_group(&client->dev.kobj, |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1282 | &lm85_group_in4))) |
Jean Delvare | f908037 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1283 | goto err_remove_files; |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1284 | |
| 1285 | /* The EMC6D100 has 3 additional voltage inputs */ |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1286 | if (data->type == emc6d100) |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1287 | if ((err = sysfs_create_group(&client->dev.kobj, |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1288 | &lm85_group_in567))) |
Jean Delvare | f908037 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1289 | goto err_remove_files; |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1290 | |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1291 | data->hwmon_dev = hwmon_device_register(&client->dev); |
Tony Jones | 1beeffe | 2007-08-20 13:46:20 -0700 | [diff] [blame] | 1292 | if (IS_ERR(data->hwmon_dev)) { |
| 1293 | err = PTR_ERR(data->hwmon_dev); |
Jean Delvare | f908037 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1294 | goto err_remove_files; |
Jean Delvare | 9c516ef | 2005-11-26 20:07:54 +0100 | [diff] [blame] | 1295 | } |
| 1296 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1297 | return 0; |
| 1298 | |
| 1299 | /* Error out and cleanup code */ |
Jean Delvare | f908037 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1300 | err_remove_files: |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1301 | sysfs_remove_group(&client->dev.kobj, &lm85_group); |
| 1302 | sysfs_remove_group(&client->dev.kobj, &lm85_group_in4); |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1303 | if (data->type == emc6d100) |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1304 | sysfs_remove_group(&client->dev.kobj, &lm85_group_in567); |
Jean Delvare | f908037 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1305 | err_kfree: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1306 | kfree(data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1307 | return err; |
| 1308 | } |
| 1309 | |
Jean Delvare | 67712d0 | 2008-10-17 17:51:14 +0200 | [diff] [blame] | 1310 | static int lm85_remove(struct i2c_client *client) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1311 | { |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 1312 | struct lm85_data *data = i2c_get_clientdata(client); |
Tony Jones | 1beeffe | 2007-08-20 13:46:20 -0700 | [diff] [blame] | 1313 | hwmon_device_unregister(data->hwmon_dev); |
Mark M. Hoffman | 0501a38 | 2006-09-24 21:14:35 +0200 | [diff] [blame] | 1314 | sysfs_remove_group(&client->dev.kobj, &lm85_group); |
Jean Delvare | 6b9aad2 | 2007-07-05 20:37:21 +0200 | [diff] [blame] | 1315 | sysfs_remove_group(&client->dev.kobj, &lm85_group_in4); |
| 1316 | if (data->type == emc6d100) |
| 1317 | sysfs_remove_group(&client->dev.kobj, &lm85_group_in567); |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 1318 | kfree(data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1319 | return 0; |
| 1320 | } |
| 1321 | |
| 1322 | |
Ben Dooks | d8d2061 | 2005-10-26 21:05:46 +0200 | [diff] [blame] | 1323 | static int lm85_read_value(struct i2c_client *client, u8 reg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | { |
| 1325 | int res; |
| 1326 | |
| 1327 | /* What size location is it? */ |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1328 | switch (reg) { |
| 1329 | case LM85_REG_FAN(0): /* Read WORD data */ |
| 1330 | case LM85_REG_FAN(1): |
| 1331 | case LM85_REG_FAN(2): |
| 1332 | case LM85_REG_FAN(3): |
| 1333 | case LM85_REG_FAN_MIN(0): |
| 1334 | case LM85_REG_FAN_MIN(1): |
| 1335 | case LM85_REG_FAN_MIN(2): |
| 1336 | case LM85_REG_FAN_MIN(3): |
| 1337 | case LM85_REG_ALARM1: /* Read both bytes at once */ |
| 1338 | res = i2c_smbus_read_byte_data(client, reg) & 0xff; |
| 1339 | res |= i2c_smbus_read_byte_data(client, reg + 1) << 8; |
| 1340 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1341 | default: /* Read BYTE data */ |
| 1342 | res = i2c_smbus_read_byte_data(client, reg); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1343 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1344 | } |
| 1345 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1346 | return res; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | } |
| 1348 | |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1349 | static void lm85_write_value(struct i2c_client *client, u8 reg, int value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1350 | { |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1351 | switch (reg) { |
| 1352 | case LM85_REG_FAN(0): /* Write WORD data */ |
| 1353 | case LM85_REG_FAN(1): |
| 1354 | case LM85_REG_FAN(2): |
| 1355 | case LM85_REG_FAN(3): |
| 1356 | case LM85_REG_FAN_MIN(0): |
| 1357 | case LM85_REG_FAN_MIN(1): |
| 1358 | case LM85_REG_FAN_MIN(2): |
| 1359 | case LM85_REG_FAN_MIN(3): |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1360 | /* NOTE: ALARM is read only, so not included here */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1361 | i2c_smbus_write_byte_data(client, reg, value & 0xff); |
| 1362 | i2c_smbus_write_byte_data(client, reg + 1, value >> 8); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1363 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1364 | default: /* Write BYTE data */ |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1365 | i2c_smbus_write_byte_data(client, reg, value); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1366 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1367 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1368 | } |
| 1369 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1370 | static struct lm85_data *lm85_update_device(struct device *dev) |
| 1371 | { |
| 1372 | struct i2c_client *client = to_i2c_client(dev); |
| 1373 | struct lm85_data *data = i2c_get_clientdata(client); |
| 1374 | int i; |
| 1375 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1376 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1377 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1378 | if (!data->valid || |
| 1379 | time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | /* Things that change quickly */ |
| 1381 | dev_dbg(&client->dev, "Reading sensor values\n"); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | /* Have to read extended bits first to "freeze" the |
| 1384 | * more significant bits that are read later. |
Jean Delvare | 5a4d3ef | 2007-07-05 20:38:32 +0200 | [diff] [blame] | 1385 | * There are 2 additional resolution bits per channel and we |
| 1386 | * have room for 4, so we shift them to the left. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1387 | */ |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 1388 | if (data->type == adm1027 || data->type == adt7463 || |
| 1389 | data->type == adt7468) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1390 | int ext1 = lm85_read_value(client, |
| 1391 | ADM1027_REG_EXTEND_ADC1); |
| 1392 | int ext2 = lm85_read_value(client, |
| 1393 | ADM1027_REG_EXTEND_ADC2); |
| 1394 | int val = (ext1 << 8) + ext2; |
| 1395 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1396 | for (i = 0; i <= 4; i++) |
| 1397 | data->in_ext[i] = |
| 1398 | ((val >> (i * 2)) & 0x03) << 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1399 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1400 | for (i = 0; i <= 2; i++) |
| 1401 | data->temp_ext[i] = |
| 1402 | (val >> ((i + 4) * 2)) & 0x0c; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1403 | } |
| 1404 | |
Jean Delvare | 9c516ef | 2005-11-26 20:07:54 +0100 | [diff] [blame] | 1405 | data->vid = lm85_read_value(client, LM85_REG_VID); |
| 1406 | |
| 1407 | for (i = 0; i <= 3; ++i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1408 | data->in[i] = |
| 1409 | lm85_read_value(client, LM85_REG_IN(i)); |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1410 | data->fan[i] = |
| 1411 | lm85_read_value(client, LM85_REG_FAN(i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1412 | } |
| 1413 | |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 1414 | if (!((data->type == adt7463 || data->type == adt7468) && |
| 1415 | (data->vid & 0x80))) { |
Jean Delvare | 9c516ef | 2005-11-26 20:07:54 +0100 | [diff] [blame] | 1416 | data->in[4] = lm85_read_value(client, |
| 1417 | LM85_REG_IN(4)); |
| 1418 | } |
| 1419 | |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 1420 | if (data->type == adt7468) |
| 1421 | data->cfg5 = lm85_read_value(client, ADT7468_REG_CFG5); |
| 1422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | for (i = 0; i <= 2; ++i) { |
| 1424 | data->temp[i] = |
| 1425 | lm85_read_value(client, LM85_REG_TEMP(i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1426 | data->pwm[i] = |
| 1427 | lm85_read_value(client, LM85_REG_PWM(i)); |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 1428 | |
| 1429 | if (IS_ADT7468_OFF64(data)) |
| 1430 | data->temp[i] -= 64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | } |
| 1432 | |
| 1433 | data->alarms = lm85_read_value(client, LM85_REG_ALARM1); |
| 1434 | |
Jean Delvare | dd1ac53 | 2008-05-01 08:47:33 +0200 | [diff] [blame] | 1435 | if (data->type == emc6d100) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | /* Three more voltage sensors */ |
| 1437 | for (i = 5; i <= 7; ++i) { |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1438 | data->in[i] = lm85_read_value(client, |
| 1439 | EMC6D100_REG_IN(i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1440 | } |
| 1441 | /* More alarm bits */ |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1442 | data->alarms |= lm85_read_value(client, |
| 1443 | EMC6D100_REG_ALARM3) << 16; |
| 1444 | } else if (data->type == emc6d102) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1445 | /* Have to read LSB bits after the MSB ones because |
| 1446 | the reading of the MSB bits has frozen the |
| 1447 | LSBs (backward from the ADM1027). |
| 1448 | */ |
| 1449 | int ext1 = lm85_read_value(client, |
| 1450 | EMC6D102_REG_EXTEND_ADC1); |
| 1451 | int ext2 = lm85_read_value(client, |
| 1452 | EMC6D102_REG_EXTEND_ADC2); |
| 1453 | int ext3 = lm85_read_value(client, |
| 1454 | EMC6D102_REG_EXTEND_ADC3); |
| 1455 | int ext4 = lm85_read_value(client, |
| 1456 | EMC6D102_REG_EXTEND_ADC4); |
| 1457 | data->in_ext[0] = ext3 & 0x0f; |
| 1458 | data->in_ext[1] = ext4 & 0x0f; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1459 | data->in_ext[2] = ext4 >> 4; |
| 1460 | data->in_ext[3] = ext3 >> 4; |
| 1461 | data->in_ext[4] = ext2 >> 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | |
| 1463 | data->temp_ext[0] = ext1 & 0x0f; |
| 1464 | data->temp_ext[1] = ext2 & 0x0f; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1465 | data->temp_ext[2] = ext1 >> 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1466 | } |
| 1467 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1468 | data->last_reading = jiffies; |
| 1469 | } /* last_reading */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1470 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1471 | if (!data->valid || |
| 1472 | time_after(jiffies, data->last_config + LM85_CONFIG_INTERVAL)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | /* Things that don't change often */ |
| 1474 | dev_dbg(&client->dev, "Reading config values\n"); |
| 1475 | |
Jean Delvare | 9c516ef | 2005-11-26 20:07:54 +0100 | [diff] [blame] | 1476 | for (i = 0; i <= 3; ++i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 | data->in_min[i] = |
| 1478 | lm85_read_value(client, LM85_REG_IN_MIN(i)); |
| 1479 | data->in_max[i] = |
| 1480 | lm85_read_value(client, LM85_REG_IN_MAX(i)); |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1481 | data->fan_min[i] = |
| 1482 | lm85_read_value(client, LM85_REG_FAN_MIN(i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1483 | } |
| 1484 | |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 1485 | if (!((data->type == adt7463 || data->type == adt7468) && |
| 1486 | (data->vid & 0x80))) { |
Jean Delvare | 9c516ef | 2005-11-26 20:07:54 +0100 | [diff] [blame] | 1487 | data->in_min[4] = lm85_read_value(client, |
| 1488 | LM85_REG_IN_MIN(4)); |
| 1489 | data->in_max[4] = lm85_read_value(client, |
| 1490 | LM85_REG_IN_MAX(4)); |
| 1491 | } |
| 1492 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1493 | if (data->type == emc6d100) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1494 | for (i = 5; i <= 7; ++i) { |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1495 | data->in_min[i] = lm85_read_value(client, |
| 1496 | EMC6D100_REG_IN_MIN(i)); |
| 1497 | data->in_max[i] = lm85_read_value(client, |
| 1498 | EMC6D100_REG_IN_MAX(i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1499 | } |
| 1500 | } |
| 1501 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1502 | for (i = 0; i <= 2; ++i) { |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1503 | int val; |
| 1504 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | data->temp_min[i] = |
| 1506 | lm85_read_value(client, LM85_REG_TEMP_MIN(i)); |
| 1507 | data->temp_max[i] = |
| 1508 | lm85_read_value(client, LM85_REG_TEMP_MAX(i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1509 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | data->autofan[i].config = |
| 1511 | lm85_read_value(client, LM85_REG_AFAN_CONFIG(i)); |
| 1512 | val = lm85_read_value(client, LM85_REG_AFAN_RANGE(i)); |
Jean Delvare | 34e7dc6 | 2008-10-17 17:51:13 +0200 | [diff] [blame] | 1513 | data->pwm_freq[i] = val & 0x07; |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1514 | data->zone[i].range = val >> 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1515 | data->autofan[i].min_pwm = |
| 1516 | lm85_read_value(client, LM85_REG_AFAN_MINPWM(i)); |
| 1517 | data->zone[i].limit = |
| 1518 | lm85_read_value(client, LM85_REG_AFAN_LIMIT(i)); |
| 1519 | data->zone[i].critical = |
| 1520 | lm85_read_value(client, LM85_REG_AFAN_CRITICAL(i)); |
Darrick J. Wong | 79b92f2 | 2008-11-12 13:26:59 -0800 | [diff] [blame] | 1521 | |
| 1522 | if (IS_ADT7468_OFF64(data)) { |
| 1523 | data->temp_min[i] -= 64; |
| 1524 | data->temp_max[i] -= 64; |
| 1525 | data->zone[i].limit -= 64; |
| 1526 | data->zone[i].critical -= 64; |
| 1527 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | } |
| 1529 | |
| 1530 | i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1531 | data->autofan[0].min_off = (i & 0x20) != 0; |
| 1532 | data->autofan[1].min_off = (i & 0x40) != 0; |
| 1533 | data->autofan[2].min_off = (i & 0x80) != 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | |
| 1535 | i = lm85_read_value(client, LM85_REG_AFAN_HYST1); |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1536 | data->zone[0].hyst = i >> 4; |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1537 | data->zone[1].hyst = i & 0x0f; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1538 | |
| 1539 | i = lm85_read_value(client, LM85_REG_AFAN_HYST2); |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1540 | data->zone[2].hyst = i >> 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1541 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1542 | data->last_config = jiffies; |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1543 | } /* last_config */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1544 | |
| 1545 | data->valid = 1; |
| 1546 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 1547 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | |
| 1549 | return data; |
| 1550 | } |
| 1551 | |
| 1552 | |
| 1553 | static int __init sm_lm85_init(void) |
| 1554 | { |
| 1555 | return i2c_add_driver(&lm85_driver); |
| 1556 | } |
| 1557 | |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1558 | static void __exit sm_lm85_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1559 | { |
| 1560 | i2c_del_driver(&lm85_driver); |
| 1561 | } |
| 1562 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | MODULE_LICENSE("GPL"); |
Jean Delvare | 1f44809 | 2008-04-29 14:03:37 +0200 | [diff] [blame] | 1564 | MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, " |
| 1565 | "Margit Schubert-While <margitsw@t-online.de>, " |
Jean Delvare | e89e22b | 2008-06-25 08:47:35 -0400 | [diff] [blame] | 1566 | "Justin Thiessen <jthiessen@penguincomputing.com>"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1567 | MODULE_DESCRIPTION("LM85-B, LM85-C driver"); |
| 1568 | |
| 1569 | module_init(sm_lm85_init); |
| 1570 | module_exit(sm_lm85_exit); |