| 1 | /* |
|---|
| 2 | adm1024.c - Part of lm_sensors, Linux kernel modules for hardware |
|---|
| 3 | monitoring |
|---|
| 4 | Add by Ken Bowley <ken@opnix.com> from the adm1025.c written by |
|---|
| 5 | Gordon Wu <gwu@esoft.com> and from adm9240.c written by |
|---|
| 6 | Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> |
|---|
| 7 | and Philip Edelbrock <phil@netroedge.com> |
|---|
| 8 | |
|---|
| 9 | This program is free software; you can redistribute it and/or modify |
|---|
| 10 | it under the terms of the GNU General Public License as published by |
|---|
| 11 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | (at your option) any later version. |
|---|
| 13 | |
|---|
| 14 | This program is distributed in the hope that it will be useful, |
|---|
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | GNU General Public License for more details. |
|---|
| 18 | |
|---|
| 19 | You should have received a copy of the GNU General Public License |
|---|
| 20 | along with this program; if not, write to the Free Software |
|---|
| 21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | /* Supports the Analog Devices ADM1024. See doc/chips/adm1024 for details */ |
|---|
| 25 | |
|---|
| 26 | #include <linux/module.h> |
|---|
| 27 | #include <linux/slab.h> |
|---|
| 28 | #include <linux/i2c.h> |
|---|
| 29 | #include <linux/i2c-proc.h> |
|---|
| 30 | #include <linux/init.h> |
|---|
| 31 | #include "version.h" |
|---|
| 32 | |
|---|
| 33 | /* Addresses to scan */ |
|---|
| 34 | static unsigned short normal_i2c[] = { SENSORS_I2C_END }; |
|---|
| 35 | static unsigned short normal_i2c_range[] = { 0x2c, 0x2e, SENSORS_I2C_END }; |
|---|
| 36 | static unsigned int normal_isa[] = { SENSORS_ISA_END }; |
|---|
| 37 | static unsigned int normal_isa_range[] = { SENSORS_ISA_END }; |
|---|
| 38 | |
|---|
| 39 | /* Insmod parameters */ |
|---|
| 40 | SENSORS_INSMOD_1(adm1024); |
|---|
| 41 | |
|---|
| 42 | /* Many ADM1024 constants specified below */ |
|---|
| 43 | |
|---|
| 44 | #define ADM1024_REG_IN_MAX(nr) (0x2b + (nr) * 2) |
|---|
| 45 | #define ADM1024_REG_IN_MIN(nr) (0x2c + (nr) * 2) |
|---|
| 46 | #define ADM1024_REG_IN(nr) (0x20 + (nr)) |
|---|
| 47 | |
|---|
| 48 | /* The ADM1024 registers */ |
|---|
| 49 | #define ADM1024_REG_INT_TEMP_TRIP_SET 0x13 |
|---|
| 50 | #define ADM1024_REG_EXT_TEMP_TRIP_SET 0x14 |
|---|
| 51 | #define ADM1024_REG_TEST 0x15 |
|---|
| 52 | #define ADM1024_REG_CHANNEL_MODE 0x16 |
|---|
| 53 | #define ADM1024_REG_INT_TEMP_TRIP 0x17 /* read only */ |
|---|
| 54 | #define ADM1024_REG_EXT_TEMP_TRIP 0x18 /* read only */ |
|---|
| 55 | #define ADM1024_REG_ANALOG_OUT 0x19 |
|---|
| 56 | #define ADM1024_REG_AIN1_LOW_LIMIT 0x1A |
|---|
| 57 | #define ADM1024_REG_AIN2_LOW_LIMIT 0x1B |
|---|
| 58 | /* These are all read-only */ |
|---|
| 59 | #define ADM1024_REG_2_5V 0x20 /* 2.5V Measured Value/EXT Temp 2 */ |
|---|
| 60 | #define ADM1024_REG_VCCP1 0x21 |
|---|
| 61 | #define ADM1024_REG_3_3V 0x22 /* VCC Measured Value */ |
|---|
| 62 | #define ADM1024_REG_5V 0x23 |
|---|
| 63 | #define ADM1024_REG_12V 0x24 |
|---|
| 64 | #define ADM1024_REG_VCCP2 0x25 |
|---|
| 65 | #define ADM1024_REG_EXT_TEMP1 0x26 |
|---|
| 66 | #define ADM1024_REG_TEMP 0x27 |
|---|
| 67 | #define ADM1024_REG_FAN1 0x28 /* FAN1/AIN1 Value */ |
|---|
| 68 | #define ADM1024_REG_FAN2 0x29 /* FAN2/AIN2 Value */ |
|---|
| 69 | #define ADM1024_REG_COMPANY_ID 0x3E /* 0x41 for ADM1024 */ |
|---|
| 70 | #define ADM1024_REG_DIE_REV 0x3F |
|---|
| 71 | /* These are read/write */ |
|---|
| 72 | #define ADM1024_REG_2_5V_HIGH 0x2B /* 2.5V/Ext Temp2 High Limit */ |
|---|
| 73 | #define ADM1024_REG_2_5V_LOW 0x2C /* 2.5V/Ext Temp2 Low Limit */ |
|---|
| 74 | #define ADM1024_REG_VCCP1_HIGH 0x2D |
|---|
| 75 | #define ADM1024_REG_VCCP1_LOW 0x2E |
|---|
| 76 | #define ADM1024_REG_3_3V_HIGH 0x2F /* VCC High Limit */ |
|---|
| 77 | #define ADM1024_REG_3_3V_LOW 0x30 /* VCC Low Limit */ |
|---|
| 78 | #define ADM1024_REG_5V_HIGH 0x31 |
|---|
| 79 | #define ADM1024_REG_5V_LOW 0x32 |
|---|
| 80 | #define ADM1024_REG_12V_HIGH 0x33 |
|---|
| 81 | #define ADM1024_REG_12V_LOW 0x34 |
|---|
| 82 | #define ADM1024_REG_VCCP2_HIGH 0x35 |
|---|
| 83 | #define ADM1024_REG_VCCP2_LOW 0x36 |
|---|
| 84 | #define ADM1024_REG_EXT_TEMP1_HIGH 0x37 |
|---|
| 85 | #define ADM1024_REG_EXT_TEMP1_LOW 0x38 |
|---|
| 86 | #define ADM1024_REG_TOS 0x39 |
|---|
| 87 | #define ADM1024_REG_THYST 0x3A |
|---|
| 88 | #define ADM1024_REG_FAN1_MIN 0x3B |
|---|
| 89 | #define ADM1024_REG_FAN2_MIN 0x3C |
|---|
| 90 | |
|---|
| 91 | #define ADM1024_REG_CONFIG 0x40 |
|---|
| 92 | #define ADM1024_REG_INT1_STAT 0x41 |
|---|
| 93 | #define ADM1024_REG_INT2_STAT 0x42 |
|---|
| 94 | #define ADM1024_REG_INT1_MASK 0x43 |
|---|
| 95 | #define ADM1024_REG_INT2_MASK 0x44 |
|---|
| 96 | |
|---|
| 97 | #define ADM1024_REG_CHASSIS_CLEAR 0x46 |
|---|
| 98 | #define ADM1024_REG_VID_FAN_DIV 0x47 |
|---|
| 99 | #define ADM1024_REG_I2C_ADDR 0x48 |
|---|
| 100 | #define ADM1024_REG_VID4 0x49 |
|---|
| 101 | #define ADM1024_REG_CONFIG2 0x4A |
|---|
| 102 | #define ADM1024_REG_TEMP_CONFIG 0x4B |
|---|
| 103 | #define ADM1024_REG_EXTMODE1 0x4C /* Interupt Status Register Mirror No. 1 */ |
|---|
| 104 | #define ADM1024_REG_EXTMODE2 0x4D /* Interupt Status Register Mirror No. 2 */ |
|---|
| 105 | |
|---|
| 106 | /* Conversions. Rounding and limit checking is only done on the TO_REG |
|---|
| 107 | variants. Note that you should be a bit careful with which arguments |
|---|
| 108 | these macros are called: arguments may be evaluated more than once. |
|---|
| 109 | Fixing this is just not worth it. */ |
|---|
| 110 | #define IN_TO_REG(val,nr) (SENSORS_LIMIT(((val) & 0xff),0,255)) |
|---|
| 111 | #define IN_FROM_REG(val,nr) (val) |
|---|
| 112 | |
|---|
| 113 | static inline u8 FAN_TO_REG(long rpm, int div) |
|---|
| 114 | { |
|---|
| 115 | if (rpm == 0) |
|---|
| 116 | return 255; |
|---|
| 117 | rpm = SENSORS_LIMIT(rpm, 1, 1000000); |
|---|
| 118 | return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, |
|---|
| 119 | 254); |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | #define FAN_FROM_REG(val,div) ((val)==0?-1:\ |
|---|
| 123 | (val)==255?0:1350000/((div)*(val))) |
|---|
| 124 | |
|---|
| 125 | #define TEMP_FROM_REG(temp) \ |
|---|
| 126 | ((temp)<256?((((temp)&0x1fe) >> 1) * 10) + ((temp) & 1) * 5: \ |
|---|
| 127 | ((((temp)&0x1fe) >> 1) -255) * 10 - ((temp) & 1) * 5) \ |
|---|
| 128 | |
|---|
| 129 | #define EXT_TEMP_FROM_REG(temp) (((temp)>0x80?(temp)-0x100:(temp))*10) |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | #define TEMP_LIMIT_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10) |
|---|
| 133 | |
|---|
| 134 | #define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT(((val)<0?(((val)-5)/10):\ |
|---|
| 135 | ((val)+5)/10), \ |
|---|
| 136 | 0,255) |
|---|
| 137 | |
|---|
| 138 | #define ALARMS_FROM_REG(val) (val) |
|---|
| 139 | |
|---|
| 140 | #define DIV_FROM_REG(val) (1 << (val)) |
|---|
| 141 | #define DIV_TO_REG(val) ((val)==1?0:((val)==8?3:((val)==4?2:1))) |
|---|
| 142 | |
|---|
| 143 | #define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\ |
|---|
| 144 | 205-(val)*5) |
|---|
| 145 | |
|---|
| 146 | /* For each registered ADM1024, we need to keep some data in memory. That |
|---|
| 147 | data is pointed to by adm1024_list[NR]->data. The structure itself is |
|---|
| 148 | dynamically allocated, at the same time when a new adm1024 client is |
|---|
| 149 | allocated. */ |
|---|
| 150 | struct adm1024_data { |
|---|
| 151 | int sysctl_id; |
|---|
| 152 | enum chips type; |
|---|
| 153 | |
|---|
| 154 | struct semaphore update_lock; |
|---|
| 155 | char valid; /* !=0 if following fields are valid */ |
|---|
| 156 | unsigned long last_updated; /* In jiffies */ |
|---|
| 157 | |
|---|
| 158 | u8 in[6]; /* Register value */ |
|---|
| 159 | u8 in_max[6]; /* Register value */ |
|---|
| 160 | u8 in_min[6]; /* Register value */ |
|---|
| 161 | u8 fan[2]; /* Register value */ |
|---|
| 162 | u8 fan_min[2]; /* Register value */ |
|---|
| 163 | u8 fan_div[2]; /* Register encoding, shifted right */ |
|---|
| 164 | int temp; /* Temp, shifted right */ |
|---|
| 165 | u8 temp_os_max; /* Register value */ |
|---|
| 166 | u8 temp_os_hyst; /* Register value */ |
|---|
| 167 | int temp1; /* Ext Temp 1 */ |
|---|
| 168 | u8 temp1_os_max; |
|---|
| 169 | u8 temp1_os_hyst; |
|---|
| 170 | int temp2; /* Ext Temp 2 */ |
|---|
| 171 | u8 temp2_os_max; |
|---|
| 172 | u8 temp2_os_hyst; |
|---|
| 173 | u16 alarms; /* Register encoding, combined */ |
|---|
| 174 | u8 analog_out; /* Register value */ |
|---|
| 175 | u8 vid; /* Register value combined */ |
|---|
| 176 | }; |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | static int adm1024_attach_adapter(struct i2c_adapter *adapter); |
|---|
| 181 | static int adm1024_detect(struct i2c_adapter *adapter, int address, |
|---|
| 182 | unsigned short flags, int kind); |
|---|
| 183 | static int adm1024_detach_client(struct i2c_client *client); |
|---|
| 184 | |
|---|
| 185 | static int adm1024_read_value(struct i2c_client *client, u8 register); |
|---|
| 186 | static int adm1024_write_value(struct i2c_client *client, u8 register, |
|---|
| 187 | u8 value); |
|---|
| 188 | static void adm1024_update_client(struct i2c_client *client); |
|---|
| 189 | static void adm1024_init_client(struct i2c_client *client); |
|---|
| 190 | |
|---|
| 191 | |
|---|
| 192 | static void adm1024_in(struct i2c_client *client, int operation, |
|---|
| 193 | int ctl_name, int *nrels_mag, long *results); |
|---|
| 194 | static void adm1024_fan(struct i2c_client *client, int operation, |
|---|
| 195 | int ctl_name, int *nrels_mag, long *results); |
|---|
| 196 | static void adm1024_temp(struct i2c_client *client, int operation, |
|---|
| 197 | int ctl_name, int *nrels_mag, long *results); |
|---|
| 198 | static void adm1024_temp1(struct i2c_client *client, int operation, |
|---|
| 199 | int ctl_name, int *nrels_mag, long *results); |
|---|
| 200 | static void adm1024_temp2(struct i2c_client *client, int operation, |
|---|
| 201 | int ctl_name, int *nrels_mag, long *results); |
|---|
| 202 | static void adm1024_alarms(struct i2c_client *client, int operation, |
|---|
| 203 | int ctl_name, int *nrels_mag, long *results); |
|---|
| 204 | static void adm1024_fan_div(struct i2c_client *client, int operation, |
|---|
| 205 | int ctl_name, int *nrels_mag, long *results); |
|---|
| 206 | static void adm1024_analog_out(struct i2c_client *client, int operation, |
|---|
| 207 | int ctl_name, int *nrels_mag, |
|---|
| 208 | long *results); |
|---|
| 209 | static void adm1024_vid(struct i2c_client *client, int operation, |
|---|
| 210 | int ctl_name, int *nrels_mag, long *results); |
|---|
| 211 | |
|---|
| 212 | /* I choose here for semi-static ADM1024 allocation. Complete dynamic |
|---|
| 213 | allocation could also be used; the code needed for this would probably |
|---|
| 214 | take more memory than the datastructure takes now. */ |
|---|
| 215 | static int adm1024_id = 0; |
|---|
| 216 | |
|---|
| 217 | static struct i2c_driver adm1024_driver = { |
|---|
| 218 | .owner = THIS_MODULE, |
|---|
| 219 | .name = "ADM1024 sensor driver", |
|---|
| 220 | .id = I2C_DRIVERID_ADM1024, |
|---|
| 221 | .flags = I2C_DF_NOTIFY, |
|---|
| 222 | .attach_adapter = adm1024_attach_adapter, |
|---|
| 223 | .detach_client = adm1024_detach_client, |
|---|
| 224 | }; |
|---|
| 225 | |
|---|
| 226 | /* The /proc/sys entries */ |
|---|
| 227 | /* -- SENSORS SYSCTL START -- */ |
|---|
| 228 | |
|---|
| 229 | #define ADM1024_SYSCTL_IN0 1000 /* Volts * 100 */ |
|---|
| 230 | #define ADM1024_SYSCTL_IN1 1001 |
|---|
| 231 | #define ADM1024_SYSCTL_IN2 1002 |
|---|
| 232 | #define ADM1024_SYSCTL_IN3 1003 |
|---|
| 233 | #define ADM1024_SYSCTL_IN4 1004 |
|---|
| 234 | #define ADM1024_SYSCTL_IN5 1005 |
|---|
| 235 | #define ADM1024_SYSCTL_FAN1 1101 /* Rotations/min */ |
|---|
| 236 | #define ADM1024_SYSCTL_FAN2 1102 |
|---|
| 237 | #define ADM1024_SYSCTL_TEMP 1250 /* Degrees Celcius * 100 */ |
|---|
| 238 | #define ADM1024_SYSCTL_TEMP1 1290 /* Degrees Celcius */ |
|---|
| 239 | #define ADM1024_SYSCTL_TEMP2 1295 /* Degrees Celcius */ |
|---|
| 240 | #define ADM1024_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ |
|---|
| 241 | #define ADM1024_SYSCTL_ALARMS 2001 /* bitvector */ |
|---|
| 242 | #define ADM1024_SYSCTL_ANALOG_OUT 2002 |
|---|
| 243 | #define ADM1024_SYSCTL_VID 2003 |
|---|
| 244 | |
|---|
| 245 | #define ADM1024_ALARM_IN0 0x0001 |
|---|
| 246 | #define ADM1024_ALARM_IN1 0x0002 |
|---|
| 247 | #define ADM1024_ALARM_IN2 0x0004 |
|---|
| 248 | #define ADM1024_ALARM_IN3 0x0008 |
|---|
| 249 | #define ADM1024_ALARM_IN4 0x0100 |
|---|
| 250 | #define ADM1024_ALARM_IN5 0x0200 |
|---|
| 251 | #define ADM1024_ALARM_FAN1 0x0040 |
|---|
| 252 | #define ADM1024_ALARM_FAN2 0x0080 |
|---|
| 253 | #define ADM1024_ALARM_TEMP 0x0010 |
|---|
| 254 | #define ADM1024_ALARM_TEMP1 0x0020 |
|---|
| 255 | #define ADM1024_ALARM_TEMP2 0x0001 |
|---|
| 256 | #define ADM1024_ALARM_CHAS 0x1000 |
|---|
| 257 | |
|---|
| 258 | /* -- SENSORS SYSCTL END -- */ |
|---|
| 259 | |
|---|
| 260 | /* These files are created for each detected ADM1024. This is just a template; |
|---|
| 261 | though at first sight, you might think we could use a statically |
|---|
| 262 | allocated list, we need some way to get back to the parent - which |
|---|
| 263 | is done through one of the 'extra' fields which are initialized |
|---|
| 264 | when a new copy is allocated. */ |
|---|
| 265 | static ctl_table adm1024_dir_table_template[] = { |
|---|
| 266 | {ADM1024_SYSCTL_IN0, "in0", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 267 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 268 | {ADM1024_SYSCTL_IN1, "in1", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 269 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 270 | {ADM1024_SYSCTL_IN2, "in2", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 271 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 272 | {ADM1024_SYSCTL_IN3, "in3", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 273 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 274 | {ADM1024_SYSCTL_IN4, "in4", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 275 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 276 | {ADM1024_SYSCTL_IN5, "in5", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 277 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 278 | {ADM1024_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 279 | &i2c_sysctl_real, NULL, &adm1024_fan}, |
|---|
| 280 | {ADM1024_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 281 | &i2c_sysctl_real, NULL, &adm1024_fan}, |
|---|
| 282 | {ADM1024_SYSCTL_TEMP, "temp1", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 283 | &i2c_sysctl_real, NULL, &adm1024_temp}, |
|---|
| 284 | {ADM1024_SYSCTL_TEMP1, "temp2", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 285 | &i2c_sysctl_real, NULL, &adm1024_temp1}, |
|---|
| 286 | {ADM1024_SYSCTL_TEMP2, "temp3", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 287 | &i2c_sysctl_real, NULL, &adm1024_temp2}, |
|---|
| 288 | {ADM1024_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 289 | &i2c_sysctl_real, NULL, &adm1024_fan_div}, |
|---|
| 290 | {ADM1024_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &i2c_proc_real, |
|---|
| 291 | &i2c_sysctl_real, NULL, &adm1024_alarms}, |
|---|
| 292 | {ADM1024_SYSCTL_ANALOG_OUT, "analog_out", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 293 | &i2c_sysctl_real, NULL, &adm1024_analog_out}, |
|---|
| 294 | {ADM1024_SYSCTL_VID, "vid", NULL, 0, 0444, NULL, &i2c_proc_real, |
|---|
| 295 | &i2c_sysctl_real, NULL, &adm1024_vid}, |
|---|
| 296 | {0} |
|---|
| 297 | }; |
|---|
| 298 | |
|---|
| 299 | static int adm1024_attach_adapter(struct i2c_adapter *adapter) |
|---|
| 300 | { |
|---|
| 301 | return i2c_detect(adapter, &addr_data, adm1024_detect); |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | static int adm1024_detect(struct i2c_adapter *adapter, int address, |
|---|
| 305 | unsigned short flags, int kind) |
|---|
| 306 | { |
|---|
| 307 | int i; |
|---|
| 308 | struct i2c_client *new_client; |
|---|
| 309 | struct adm1024_data *data; |
|---|
| 310 | int err = 0; |
|---|
| 311 | const char *type_name = ""; |
|---|
| 312 | const char *client_name = ""; |
|---|
| 313 | |
|---|
| 314 | /* Make sure we aren't probing the ISA bus!! This is just a safety check |
|---|
| 315 | at this moment; i2c_detect really won't call us. */ |
|---|
| 316 | #ifdef DEBUG |
|---|
| 317 | if (i2c_is_isa_adapter(adapter)) { |
|---|
| 318 | printk |
|---|
| 319 | ("adm1024.o: adm1024_detect called for an ISA bus adapter?!?\n"); |
|---|
| 320 | return 0; |
|---|
| 321 | } |
|---|
| 322 | #endif |
|---|
| 323 | |
|---|
| 324 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
|---|
| 325 | goto ERROR0; |
|---|
| 326 | |
|---|
| 327 | /* OK. For now, we presume we have a valid client. We now create the |
|---|
| 328 | client structure, even though we cannot fill it completely yet. |
|---|
| 329 | But it allows us to access adm1024_{read,write}_value. */ |
|---|
| 330 | |
|---|
| 331 | if (!(new_client = kmalloc(sizeof(struct i2c_client) + |
|---|
| 332 | sizeof(struct adm1024_data), |
|---|
| 333 | GFP_KERNEL))) { |
|---|
| 334 | err = -ENOMEM; |
|---|
| 335 | goto ERROR0; |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | data = (struct adm1024_data *) (new_client + 1); |
|---|
| 339 | new_client->addr = address; |
|---|
| 340 | new_client->data = data; |
|---|
| 341 | new_client->adapter = adapter; |
|---|
| 342 | new_client->driver = &adm1024_driver; |
|---|
| 343 | new_client->flags = 0; |
|---|
| 344 | |
|---|
| 345 | /* Now, we do the remaining detection. */ |
|---|
| 346 | |
|---|
| 347 | if (kind < 0) { |
|---|
| 348 | if((adm1024_read_value(new_client, ADM1024_REG_CONFIG) & 0x80) != 0x00) |
|---|
| 349 | goto ERROR1; |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | /* Determine the chip type. */ |
|---|
| 353 | if (kind <= 0) { |
|---|
| 354 | i = adm1024_read_value(new_client, ADM1024_REG_COMPANY_ID); |
|---|
| 355 | if (i == 0x41) |
|---|
| 356 | kind = adm1024; |
|---|
| 357 | else { |
|---|
| 358 | if (kind == 0) |
|---|
| 359 | printk |
|---|
| 360 | ("adm1024.o: Ignoring 'force' parameter for unknown chip at " |
|---|
| 361 | "adapter %d, address 0x%02x\n", |
|---|
| 362 | i2c_adapter_id(adapter), address); |
|---|
| 363 | goto ERROR1; |
|---|
| 364 | } |
|---|
| 365 | } |
|---|
| 366 | |
|---|
| 367 | if (kind == adm1024) { |
|---|
| 368 | type_name = "adm1024"; |
|---|
| 369 | client_name = "ADM1024 chip"; |
|---|
| 370 | } else { |
|---|
| 371 | #ifdef DEBUG |
|---|
| 372 | printk("adm1024.o: Internal error: unknown kind (%d)?!?", |
|---|
| 373 | kind); |
|---|
| 374 | #endif |
|---|
| 375 | goto ERROR1; |
|---|
| 376 | } |
|---|
| 377 | |
|---|
| 378 | /* Fill in the remaining client fields and put it into the global list */ |
|---|
| 379 | strcpy(new_client->name, client_name); |
|---|
| 380 | data->type = kind; |
|---|
| 381 | |
|---|
| 382 | new_client->id = adm1024_id++; |
|---|
| 383 | data->valid = 0; |
|---|
| 384 | init_MUTEX(&data->update_lock); |
|---|
| 385 | |
|---|
| 386 | /* Tell the I2C layer a new client has arrived */ |
|---|
| 387 | if ((err = i2c_attach_client(new_client))) |
|---|
| 388 | goto ERROR3; |
|---|
| 389 | |
|---|
| 390 | /* Register a new directory entry with module sensors */ |
|---|
| 391 | if ((i = i2c_register_entry(new_client, |
|---|
| 392 | type_name, |
|---|
| 393 | adm1024_dir_table_template)) < 0) { |
|---|
| 394 | err = i; |
|---|
| 395 | goto ERROR4; |
|---|
| 396 | } |
|---|
| 397 | data->sysctl_id = i; |
|---|
| 398 | |
|---|
| 399 | /* Initialize the ADM1024 chip */ |
|---|
| 400 | adm1024_init_client(new_client); |
|---|
| 401 | return 0; |
|---|
| 402 | |
|---|
| 403 | /* OK, this is not exactly good programming practice, usually. But it is |
|---|
| 404 | very code-efficient in this case. */ |
|---|
| 405 | |
|---|
| 406 | ERROR4: |
|---|
| 407 | i2c_detach_client(new_client); |
|---|
| 408 | ERROR3: |
|---|
| 409 | ERROR1: |
|---|
| 410 | kfree(new_client); |
|---|
| 411 | ERROR0: |
|---|
| 412 | return err; |
|---|
| 413 | } |
|---|
| 414 | |
|---|
| 415 | static int adm1024_detach_client(struct i2c_client *client) |
|---|
| 416 | { |
|---|
| 417 | int err; |
|---|
| 418 | |
|---|
| 419 | i2c_deregister_entry(((struct adm1024_data *) (client->data))-> |
|---|
| 420 | sysctl_id); |
|---|
| 421 | |
|---|
| 422 | if ((err = i2c_detach_client(client))) { |
|---|
| 423 | printk |
|---|
| 424 | ("adm1024.o: Client deregistration failed, client not detached.\n"); |
|---|
| 425 | return err; |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | kfree(client); |
|---|
| 429 | |
|---|
| 430 | return 0; |
|---|
| 431 | |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | static int adm1024_read_value(struct i2c_client *client, u8 reg) |
|---|
| 435 | { |
|---|
| 436 | return 0xFF & i2c_smbus_read_byte_data(client, reg); |
|---|
| 437 | } |
|---|
| 438 | |
|---|
| 439 | static int adm1024_write_value(struct i2c_client *client, u8 reg, u8 value) |
|---|
| 440 | { |
|---|
| 441 | return i2c_smbus_write_byte_data(client, reg, value); |
|---|
| 442 | } |
|---|
| 443 | |
|---|
| 444 | static void adm1024_init_client(struct i2c_client *client) |
|---|
| 445 | { |
|---|
| 446 | /* Enable temperature channel 2 */ |
|---|
| 447 | adm1024_write_value(client, ADM1024_REG_CHANNEL_MODE, adm1024_read_value(client, ADM1024_REG_CHANNEL_MODE) | 0x04); |
|---|
| 448 | |
|---|
| 449 | /* Start monitoring */ |
|---|
| 450 | adm1024_write_value(client, ADM1024_REG_CONFIG, 0x07); |
|---|
| 451 | } |
|---|
| 452 | |
|---|
| 453 | static void adm1024_update_client(struct i2c_client *client) |
|---|
| 454 | { |
|---|
| 455 | struct adm1024_data *data = client->data; |
|---|
| 456 | u8 i; |
|---|
| 457 | |
|---|
| 458 | down(&data->update_lock); |
|---|
| 459 | |
|---|
| 460 | if ( |
|---|
| 461 | (jiffies - data->last_updated > |
|---|
| 462 | (data->type == adm1024 ? HZ / 2 : HZ * 2)) |
|---|
| 463 | || (jiffies < data->last_updated) || !data->valid) { |
|---|
| 464 | |
|---|
| 465 | #ifdef DEBUG |
|---|
| 466 | printk("Starting adm1024 update\n"); |
|---|
| 467 | #endif |
|---|
| 468 | for (i = 0; i <= 5; i++) { |
|---|
| 469 | data->in[i] = |
|---|
| 470 | adm1024_read_value(client, ADM1024_REG_IN(i)); |
|---|
| 471 | data->in_min[i] = |
|---|
| 472 | adm1024_read_value(client, |
|---|
| 473 | ADM1024_REG_IN_MIN(i)); |
|---|
| 474 | data->in_max[i] = |
|---|
| 475 | adm1024_read_value(client, |
|---|
| 476 | ADM1024_REG_IN_MAX(i)); |
|---|
| 477 | } |
|---|
| 478 | data->fan[0] = |
|---|
| 479 | adm1024_read_value(client, ADM1024_REG_FAN1); |
|---|
| 480 | data->fan_min[0] = |
|---|
| 481 | adm1024_read_value(client, ADM1024_REG_FAN1_MIN); |
|---|
| 482 | data->fan[1] = |
|---|
| 483 | adm1024_read_value(client, ADM1024_REG_FAN2); |
|---|
| 484 | data->fan_min[1] = |
|---|
| 485 | adm1024_read_value(client, ADM1024_REG_FAN2_MIN); |
|---|
| 486 | data->temp = |
|---|
| 487 | (adm1024_read_value(client, ADM1024_REG_TEMP) << 1) + |
|---|
| 488 | ((adm1024_read_value |
|---|
| 489 | (client, ADM1024_REG_TEMP_CONFIG) & 0x80) >> 7); |
|---|
| 490 | data->temp_os_max = |
|---|
| 491 | adm1024_read_value(client, ADM1024_REG_TOS); |
|---|
| 492 | data->temp_os_hyst = |
|---|
| 493 | adm1024_read_value(client, ADM1024_REG_THYST); |
|---|
| 494 | data->temp1 = |
|---|
| 495 | adm1024_read_value(client, ADM1024_REG_EXT_TEMP1); |
|---|
| 496 | data->temp1_os_max = |
|---|
| 497 | adm1024_read_value(client, ADM1024_REG_EXT_TEMP1_HIGH); |
|---|
| 498 | data->temp1_os_hyst = |
|---|
| 499 | adm1024_read_value(client, ADM1024_REG_EXT_TEMP1_LOW); |
|---|
| 500 | data->temp2 = |
|---|
| 501 | adm1024_read_value(client, ADM1024_REG_2_5V); |
|---|
| 502 | data->temp2_os_max = |
|---|
| 503 | adm1024_read_value(client, ADM1024_REG_2_5V_HIGH); |
|---|
| 504 | data->temp2_os_hyst = |
|---|
| 505 | adm1024_read_value(client, ADM1024_REG_2_5V_LOW); |
|---|
| 506 | |
|---|
| 507 | i = adm1024_read_value(client, ADM1024_REG_VID_FAN_DIV); |
|---|
| 508 | data->fan_div[0] = (i >> 4) & 0x03; |
|---|
| 509 | data->fan_div[1] = (i >> 6) & 0x03; |
|---|
| 510 | data->vid = i & 0x0f; |
|---|
| 511 | data->vid |= |
|---|
| 512 | (adm1024_read_value(client, ADM1024_REG_VID4) & 0x01) |
|---|
| 513 | << 4; |
|---|
| 514 | |
|---|
| 515 | data->alarms = |
|---|
| 516 | adm1024_read_value(client, |
|---|
| 517 | ADM1024_REG_INT1_STAT) + |
|---|
| 518 | (adm1024_read_value(client, ADM1024_REG_INT2_STAT) << |
|---|
| 519 | 8); |
|---|
| 520 | data->analog_out = |
|---|
| 521 | adm1024_read_value(client, ADM1024_REG_ANALOG_OUT); |
|---|
| 522 | data->last_updated = jiffies; |
|---|
| 523 | data->valid = 1; |
|---|
| 524 | } |
|---|
| 525 | |
|---|
| 526 | up(&data->update_lock); |
|---|
| 527 | } |
|---|
| 528 | |
|---|
| 529 | |
|---|
| 530 | /* The next few functions are the call-back functions of the /proc/sys and |
|---|
| 531 | sysctl files. Which function is used is defined in the ctl_table in |
|---|
| 532 | the extra1 field. |
|---|
| 533 | Each function must return the magnitude (power of 10 to divide the date |
|---|
| 534 | with) if it is called with operation==SENSORS_PROC_REAL_INFO. It must |
|---|
| 535 | put a maximum of *nrels elements in results reflecting the data of this |
|---|
| 536 | file, and set *nrels to the number it actually put in it, if operation== |
|---|
| 537 | SENSORS_PROC_REAL_READ. Finally, it must get upto *nrels elements from |
|---|
| 538 | results and write them to the chip, if operations==SENSORS_PROC_REAL_WRITE. |
|---|
| 539 | Note that on SENSORS_PROC_REAL_READ, I do not check whether results is |
|---|
| 540 | large enough (by checking the incoming value of *nrels). This is not very |
|---|
| 541 | good practice, but as long as you put less than about 5 values in results, |
|---|
| 542 | you can assume it is large enough. */ |
|---|
| 543 | void adm1024_in(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 544 | int *nrels_mag, long *results) |
|---|
| 545 | { |
|---|
| 546 | |
|---|
| 547 | int scales[6] = { 250, 225, 330, 500, 1200, 270 }; |
|---|
| 548 | |
|---|
| 549 | struct adm1024_data *data = client->data; |
|---|
| 550 | int nr = ctl_name - ADM1024_SYSCTL_IN0; |
|---|
| 551 | |
|---|
| 552 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 553 | *nrels_mag = 2; |
|---|
| 554 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 555 | adm1024_update_client(client); |
|---|
| 556 | results[0] = |
|---|
| 557 | IN_FROM_REG(data->in_min[nr], nr) * scales[nr] / 192; |
|---|
| 558 | results[1] = |
|---|
| 559 | IN_FROM_REG(data->in_max[nr], nr) * scales[nr] / 192; |
|---|
| 560 | results[2] = |
|---|
| 561 | IN_FROM_REG(data->in[nr], nr) * scales[nr] / 192; |
|---|
| 562 | *nrels_mag = 3; |
|---|
| 563 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 564 | if (*nrels_mag >= 1) { |
|---|
| 565 | data->in_min[nr] = |
|---|
| 566 | IN_TO_REG((results[0] * 192) / scales[nr], nr); |
|---|
| 567 | adm1024_write_value(client, ADM1024_REG_IN_MIN(nr), |
|---|
| 568 | data->in_min[nr]); |
|---|
| 569 | } |
|---|
| 570 | if (*nrels_mag >= 2) { |
|---|
| 571 | data->in_max[nr] = |
|---|
| 572 | IN_TO_REG((results[1] * 192) / scales[nr], nr); |
|---|
| 573 | adm1024_write_value(client, ADM1024_REG_IN_MAX(nr), |
|---|
| 574 | data->in_max[nr]); |
|---|
| 575 | } |
|---|
| 576 | } |
|---|
| 577 | } |
|---|
| 578 | |
|---|
| 579 | void adm1024_fan(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 580 | int *nrels_mag, long *results) |
|---|
| 581 | { |
|---|
| 582 | struct adm1024_data *data = client->data; |
|---|
| 583 | int nr = ctl_name - ADM1024_SYSCTL_FAN1 + 1; |
|---|
| 584 | |
|---|
| 585 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 586 | *nrels_mag = 0; |
|---|
| 587 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 588 | adm1024_update_client(client); |
|---|
| 589 | results[0] = FAN_FROM_REG(data->fan_min[nr - 1], |
|---|
| 590 | DIV_FROM_REG(data-> |
|---|
| 591 | fan_div[nr - 1])); |
|---|
| 592 | results[1] = |
|---|
| 593 | FAN_FROM_REG(data->fan[nr - 1], |
|---|
| 594 | DIV_FROM_REG(data->fan_div[nr - 1])); |
|---|
| 595 | *nrels_mag = 2; |
|---|
| 596 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 597 | if (*nrels_mag >= 1) { |
|---|
| 598 | data->fan_min[nr - 1] = FAN_TO_REG(results[0], |
|---|
| 599 | DIV_FROM_REG |
|---|
| 600 | (data-> |
|---|
| 601 | fan_div[nr - |
|---|
| 602 | 1])); |
|---|
| 603 | adm1024_write_value(client, |
|---|
| 604 | nr == |
|---|
| 605 | 1 ? ADM1024_REG_FAN1_MIN : |
|---|
| 606 | ADM1024_REG_FAN2_MIN, |
|---|
| 607 | data->fan_min[nr - 1]); |
|---|
| 608 | } |
|---|
| 609 | } |
|---|
| 610 | } |
|---|
| 611 | |
|---|
| 612 | |
|---|
| 613 | void adm1024_temp(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 614 | int *nrels_mag, long *results) |
|---|
| 615 | { |
|---|
| 616 | struct adm1024_data *data = client->data; |
|---|
| 617 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 618 | *nrels_mag = 1; |
|---|
| 619 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 620 | adm1024_update_client(client); |
|---|
| 621 | results[0] = TEMP_LIMIT_FROM_REG(data->temp_os_max); |
|---|
| 622 | results[1] = TEMP_LIMIT_FROM_REG(data->temp_os_hyst); |
|---|
| 623 | results[2] = TEMP_FROM_REG(data->temp); |
|---|
| 624 | *nrels_mag = 3; |
|---|
| 625 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 626 | if (*nrels_mag >= 1) { |
|---|
| 627 | data->temp_os_max = TEMP_LIMIT_TO_REG(results[0]); |
|---|
| 628 | adm1024_write_value(client, ADM1024_REG_TOS, |
|---|
| 629 | data->temp_os_max); |
|---|
| 630 | } |
|---|
| 631 | if (*nrels_mag >= 2) { |
|---|
| 632 | data->temp_os_hyst = TEMP_LIMIT_TO_REG(results[1]); |
|---|
| 633 | adm1024_write_value(client, ADM1024_REG_THYST, |
|---|
| 634 | data->temp_os_hyst); |
|---|
| 635 | } |
|---|
| 636 | } |
|---|
| 637 | } |
|---|
| 638 | |
|---|
| 639 | void adm1024_temp1(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 640 | int *nrels_mag, long *results) |
|---|
| 641 | { |
|---|
| 642 | struct adm1024_data *data = client->data; |
|---|
| 643 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 644 | *nrels_mag = 1; |
|---|
| 645 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 646 | adm1024_update_client(client); |
|---|
| 647 | results[0] = TEMP_LIMIT_FROM_REG(data->temp1_os_max); |
|---|
| 648 | results[1] = TEMP_LIMIT_FROM_REG(data->temp1_os_hyst); |
|---|
| 649 | results[2] = EXT_TEMP_FROM_REG(data->temp1); |
|---|
| 650 | *nrels_mag = 3; |
|---|
| 651 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 652 | if (*nrels_mag >= 1) { |
|---|
| 653 | data->temp1_os_max = TEMP_LIMIT_TO_REG(results[0]); |
|---|
| 654 | adm1024_write_value(client, ADM1024_REG_EXT_TEMP1_HIGH, |
|---|
| 655 | data->temp1_os_max); |
|---|
| 656 | } |
|---|
| 657 | if (*nrels_mag >= 2) { |
|---|
| 658 | data->temp1_os_hyst = TEMP_LIMIT_TO_REG(results[1]); |
|---|
| 659 | adm1024_write_value(client, ADM1024_REG_EXT_TEMP1_LOW, |
|---|
| 660 | data->temp1_os_hyst); |
|---|
| 661 | } |
|---|
| 662 | } |
|---|
| 663 | } |
|---|
| 664 | |
|---|
| 665 | void adm1024_temp2(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 666 | int *nrels_mag, long *results) |
|---|
| 667 | { |
|---|
| 668 | struct adm1024_data *data = client->data; |
|---|
| 669 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 670 | *nrels_mag = 1; |
|---|
| 671 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 672 | adm1024_update_client(client); |
|---|
| 673 | results[0] = TEMP_LIMIT_FROM_REG(data->temp2_os_max); |
|---|
| 674 | results[1] = TEMP_LIMIT_FROM_REG(data->temp2_os_hyst); |
|---|
| 675 | results[2] = EXT_TEMP_FROM_REG(data->temp2); |
|---|
| 676 | *nrels_mag = 3; |
|---|
| 677 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 678 | if (*nrels_mag >= 1) { |
|---|
| 679 | data->temp2_os_max = TEMP_LIMIT_TO_REG(results[0]); |
|---|
| 680 | adm1024_write_value(client, ADM1024_REG_2_5V_HIGH, |
|---|
| 681 | data->temp2_os_max); |
|---|
| 682 | } |
|---|
| 683 | if (*nrels_mag >= 2) { |
|---|
| 684 | data->temp2_os_hyst = TEMP_LIMIT_TO_REG(results[1]); |
|---|
| 685 | adm1024_write_value(client, ADM1024_REG_2_5V_LOW, |
|---|
| 686 | data->temp2_os_hyst); |
|---|
| 687 | } |
|---|
| 688 | } |
|---|
| 689 | } |
|---|
| 690 | |
|---|
| 691 | void adm1024_alarms(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 692 | int *nrels_mag, long *results) |
|---|
| 693 | { |
|---|
| 694 | struct adm1024_data *data = client->data; |
|---|
| 695 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 696 | *nrels_mag = 0; |
|---|
| 697 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 698 | adm1024_update_client(client); |
|---|
| 699 | results[0] = ALARMS_FROM_REG(data->alarms); |
|---|
| 700 | *nrels_mag = 1; |
|---|
| 701 | } |
|---|
| 702 | } |
|---|
| 703 | |
|---|
| 704 | void adm1024_fan_div(struct i2c_client *client, int operation, |
|---|
| 705 | int ctl_name, int *nrels_mag, long *results) |
|---|
| 706 | { |
|---|
| 707 | struct adm1024_data *data = client->data; |
|---|
| 708 | int old; |
|---|
| 709 | |
|---|
| 710 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 711 | *nrels_mag = 0; |
|---|
| 712 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 713 | adm1024_update_client(client); |
|---|
| 714 | results[0] = DIV_FROM_REG(data->fan_div[0]); |
|---|
| 715 | results[1] = DIV_FROM_REG(data->fan_div[1]); |
|---|
| 716 | *nrels_mag = 2; |
|---|
| 717 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 718 | old = adm1024_read_value(client, ADM1024_REG_VID_FAN_DIV); |
|---|
| 719 | if (*nrels_mag >= 2) { |
|---|
| 720 | data->fan_div[1] = DIV_TO_REG(results[1]); |
|---|
| 721 | old = (old & 0x3f) | (data->fan_div[1] << 6); |
|---|
| 722 | } |
|---|
| 723 | if (*nrels_mag >= 1) { |
|---|
| 724 | data->fan_div[0] = DIV_TO_REG(results[0]); |
|---|
| 725 | old = (old & 0xcf) | (data->fan_div[0] << 4); |
|---|
| 726 | adm1024_write_value(client, |
|---|
| 727 | ADM1024_REG_VID_FAN_DIV, old); |
|---|
| 728 | } |
|---|
| 729 | } |
|---|
| 730 | } |
|---|
| 731 | |
|---|
| 732 | void adm1024_analog_out(struct i2c_client *client, int operation, |
|---|
| 733 | int ctl_name, int *nrels_mag, long *results) |
|---|
| 734 | { |
|---|
| 735 | struct adm1024_data *data = client->data; |
|---|
| 736 | |
|---|
| 737 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 738 | *nrels_mag = 0; |
|---|
| 739 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 740 | adm1024_update_client(client); |
|---|
| 741 | results[0] = data->analog_out; |
|---|
| 742 | *nrels_mag = 1; |
|---|
| 743 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 744 | if (*nrels_mag >= 1) { |
|---|
| 745 | data->analog_out = results[0]; |
|---|
| 746 | adm1024_write_value(client, ADM1024_REG_ANALOG_OUT, |
|---|
| 747 | data->analog_out); |
|---|
| 748 | } |
|---|
| 749 | } |
|---|
| 750 | } |
|---|
| 751 | |
|---|
| 752 | void adm1024_vid(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 753 | int *nrels_mag, long *results) |
|---|
| 754 | { |
|---|
| 755 | struct adm1024_data *data = client->data; |
|---|
| 756 | |
|---|
| 757 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 758 | *nrels_mag = 2; |
|---|
| 759 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 760 | adm1024_update_client(client); |
|---|
| 761 | results[0] = VID_FROM_REG(data->vid); |
|---|
| 762 | *nrels_mag = 1; |
|---|
| 763 | } |
|---|
| 764 | } |
|---|
| 765 | |
|---|
| 766 | static int __init sm_adm1024_init(void) |
|---|
| 767 | { |
|---|
| 768 | printk("adm1024.o version %s (%s)\n", LM_VERSION, LM_DATE); |
|---|
| 769 | return i2c_add_driver(&adm1024_driver); |
|---|
| 770 | } |
|---|
| 771 | |
|---|
| 772 | static void __exit sm_adm1024_exit(void) |
|---|
| 773 | { |
|---|
| 774 | i2c_del_driver(&adm1024_driver); |
|---|
| 775 | } |
|---|
| 776 | |
|---|
| 777 | |
|---|
| 778 | |
|---|
| 779 | MODULE_AUTHOR |
|---|
| 780 | ("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>"); |
|---|
| 781 | MODULE_DESCRIPTION("ADM1024 driver"); |
|---|
| 782 | |
|---|
| 783 | MODULE_LICENSE("GPL"); |
|---|
| 784 | |
|---|
| 785 | module_init(sm_adm1024_init); |
|---|
| 786 | module_exit(sm_adm1024_exit); |
|---|