| 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. It is |
|---|
| 147 | dynamically allocated, at the same time when a new adm1024 client is |
|---|
| 148 | allocated. */ |
|---|
| 149 | struct adm1024_data { |
|---|
| 150 | struct i2c_client client; |
|---|
| 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 | static struct i2c_driver adm1024_driver = { |
|---|
| 213 | .name = "ADM1024 sensor driver", |
|---|
| 214 | .id = I2C_DRIVERID_ADM1024, |
|---|
| 215 | .flags = I2C_DF_NOTIFY, |
|---|
| 216 | .attach_adapter = adm1024_attach_adapter, |
|---|
| 217 | .detach_client = adm1024_detach_client, |
|---|
| 218 | }; |
|---|
| 219 | |
|---|
| 220 | /* The /proc/sys entries */ |
|---|
| 221 | /* -- SENSORS SYSCTL START -- */ |
|---|
| 222 | |
|---|
| 223 | #define ADM1024_SYSCTL_IN0 1000 /* Volts * 100 */ |
|---|
| 224 | #define ADM1024_SYSCTL_IN1 1001 |
|---|
| 225 | #define ADM1024_SYSCTL_IN2 1002 |
|---|
| 226 | #define ADM1024_SYSCTL_IN3 1003 |
|---|
| 227 | #define ADM1024_SYSCTL_IN4 1004 |
|---|
| 228 | #define ADM1024_SYSCTL_IN5 1005 |
|---|
| 229 | #define ADM1024_SYSCTL_FAN1 1101 /* Rotations/min */ |
|---|
| 230 | #define ADM1024_SYSCTL_FAN2 1102 |
|---|
| 231 | #define ADM1024_SYSCTL_TEMP 1250 /* Degrees Celsius * 100 */ |
|---|
| 232 | #define ADM1024_SYSCTL_TEMP1 1290 /* Degrees Celsius */ |
|---|
| 233 | #define ADM1024_SYSCTL_TEMP2 1295 /* Degrees Celsius */ |
|---|
| 234 | #define ADM1024_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ |
|---|
| 235 | #define ADM1024_SYSCTL_ALARMS 2001 /* bitvector */ |
|---|
| 236 | #define ADM1024_SYSCTL_ANALOG_OUT 2002 |
|---|
| 237 | #define ADM1024_SYSCTL_VID 2003 |
|---|
| 238 | |
|---|
| 239 | #define ADM1024_ALARM_IN0 0x0001 |
|---|
| 240 | #define ADM1024_ALARM_IN1 0x0002 |
|---|
| 241 | #define ADM1024_ALARM_IN2 0x0004 |
|---|
| 242 | #define ADM1024_ALARM_IN3 0x0008 |
|---|
| 243 | #define ADM1024_ALARM_IN4 0x0100 |
|---|
| 244 | #define ADM1024_ALARM_IN5 0x0200 |
|---|
| 245 | #define ADM1024_ALARM_FAN1 0x0040 |
|---|
| 246 | #define ADM1024_ALARM_FAN2 0x0080 |
|---|
| 247 | #define ADM1024_ALARM_TEMP 0x0010 |
|---|
| 248 | #define ADM1024_ALARM_TEMP1 0x0020 |
|---|
| 249 | #define ADM1024_ALARM_TEMP2 0x0001 |
|---|
| 250 | #define ADM1024_ALARM_CHAS 0x1000 |
|---|
| 251 | |
|---|
| 252 | /* -- SENSORS SYSCTL END -- */ |
|---|
| 253 | |
|---|
| 254 | /* These files are created for each detected ADM1024. This is just a template; |
|---|
| 255 | though at first sight, you might think we could use a statically |
|---|
| 256 | allocated list, we need some way to get back to the parent - which |
|---|
| 257 | is done through one of the 'extra' fields which are initialized |
|---|
| 258 | when a new copy is allocated. */ |
|---|
| 259 | static ctl_table adm1024_dir_table_template[] = { |
|---|
| 260 | {ADM1024_SYSCTL_IN0, "in0", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 261 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 262 | {ADM1024_SYSCTL_IN1, "in1", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 263 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 264 | {ADM1024_SYSCTL_IN2, "in2", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 265 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 266 | {ADM1024_SYSCTL_IN3, "in3", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 267 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 268 | {ADM1024_SYSCTL_IN4, "in4", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 269 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 270 | {ADM1024_SYSCTL_IN5, "in5", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 271 | &i2c_sysctl_real, NULL, &adm1024_in}, |
|---|
| 272 | {ADM1024_SYSCTL_FAN1, "fan1", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 273 | &i2c_sysctl_real, NULL, &adm1024_fan}, |
|---|
| 274 | {ADM1024_SYSCTL_FAN2, "fan2", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 275 | &i2c_sysctl_real, NULL, &adm1024_fan}, |
|---|
| 276 | {ADM1024_SYSCTL_TEMP, "temp1", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 277 | &i2c_sysctl_real, NULL, &adm1024_temp}, |
|---|
| 278 | {ADM1024_SYSCTL_TEMP1, "temp2", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 279 | &i2c_sysctl_real, NULL, &adm1024_temp1}, |
|---|
| 280 | {ADM1024_SYSCTL_TEMP2, "temp3", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 281 | &i2c_sysctl_real, NULL, &adm1024_temp2}, |
|---|
| 282 | {ADM1024_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 283 | &i2c_sysctl_real, NULL, &adm1024_fan_div}, |
|---|
| 284 | {ADM1024_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &i2c_proc_real, |
|---|
| 285 | &i2c_sysctl_real, NULL, &adm1024_alarms}, |
|---|
| 286 | {ADM1024_SYSCTL_ANALOG_OUT, "analog_out", NULL, 0, 0644, NULL, &i2c_proc_real, |
|---|
| 287 | &i2c_sysctl_real, NULL, &adm1024_analog_out}, |
|---|
| 288 | {ADM1024_SYSCTL_VID, "vid", NULL, 0, 0444, NULL, &i2c_proc_real, |
|---|
| 289 | &i2c_sysctl_real, NULL, &adm1024_vid}, |
|---|
| 290 | {0} |
|---|
| 291 | }; |
|---|
| 292 | |
|---|
| 293 | static int adm1024_attach_adapter(struct i2c_adapter *adapter) |
|---|
| 294 | { |
|---|
| 295 | return i2c_detect(adapter, &addr_data, adm1024_detect); |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | static int adm1024_detect(struct i2c_adapter *adapter, int address, |
|---|
| 299 | unsigned short flags, int kind) |
|---|
| 300 | { |
|---|
| 301 | int i; |
|---|
| 302 | struct i2c_client *new_client; |
|---|
| 303 | struct adm1024_data *data; |
|---|
| 304 | int err = 0; |
|---|
| 305 | const char *type_name = ""; |
|---|
| 306 | const char *client_name = ""; |
|---|
| 307 | |
|---|
| 308 | /* Make sure we aren't probing the ISA bus!! This is just a safety check |
|---|
| 309 | at this moment; i2c_detect really won't call us. */ |
|---|
| 310 | #ifdef DEBUG |
|---|
| 311 | if (i2c_is_isa_adapter(adapter)) { |
|---|
| 312 | printk |
|---|
| 313 | ("adm1024.o: adm1024_detect called for an ISA bus adapter?!?\n"); |
|---|
| 314 | return 0; |
|---|
| 315 | } |
|---|
| 316 | #endif |
|---|
| 317 | |
|---|
| 318 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
|---|
| 319 | goto ERROR0; |
|---|
| 320 | |
|---|
| 321 | /* OK. For now, we presume we have a valid client. We now create the |
|---|
| 322 | client structure, even though we cannot fill it completely yet. |
|---|
| 323 | But it allows us to access adm1024_{read,write}_value. */ |
|---|
| 324 | |
|---|
| 325 | if (!(data = kmalloc(sizeof(struct adm1024_data), GFP_KERNEL))) { |
|---|
| 326 | err = -ENOMEM; |
|---|
| 327 | goto ERROR0; |
|---|
| 328 | } |
|---|
| 329 | |
|---|
| 330 | new_client = &data->client; |
|---|
| 331 | new_client->addr = address; |
|---|
| 332 | new_client->data = data; |
|---|
| 333 | new_client->adapter = adapter; |
|---|
| 334 | new_client->driver = &adm1024_driver; |
|---|
| 335 | new_client->flags = 0; |
|---|
| 336 | |
|---|
| 337 | /* Now, we do the remaining detection. */ |
|---|
| 338 | |
|---|
| 339 | if (kind < 0) { |
|---|
| 340 | if((adm1024_read_value(new_client, ADM1024_REG_CONFIG) & 0x80) != 0x00) |
|---|
| 341 | goto ERROR1; |
|---|
| 342 | } |
|---|
| 343 | |
|---|
| 344 | /* Determine the chip type. */ |
|---|
| 345 | if (kind <= 0) { |
|---|
| 346 | i = adm1024_read_value(new_client, ADM1024_REG_COMPANY_ID); |
|---|
| 347 | if (i == 0x41) |
|---|
| 348 | kind = adm1024; |
|---|
| 349 | else { |
|---|
| 350 | if (kind == 0) |
|---|
| 351 | printk |
|---|
| 352 | ("adm1024.o: Ignoring 'force' parameter for unknown chip at " |
|---|
| 353 | "adapter %d, address 0x%02x\n", |
|---|
| 354 | i2c_adapter_id(adapter), address); |
|---|
| 355 | goto ERROR1; |
|---|
| 356 | } |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| 359 | if (kind == adm1024) { |
|---|
| 360 | type_name = "adm1024"; |
|---|
| 361 | client_name = "ADM1024 chip"; |
|---|
| 362 | } else { |
|---|
| 363 | #ifdef DEBUG |
|---|
| 364 | printk("adm1024.o: Internal error: unknown kind (%d)?!?", |
|---|
| 365 | kind); |
|---|
| 366 | #endif |
|---|
| 367 | goto ERROR1; |
|---|
| 368 | } |
|---|
| 369 | |
|---|
| 370 | /* Fill in the remaining client fields and put it into the global list */ |
|---|
| 371 | strcpy(new_client->name, client_name); |
|---|
| 372 | data->type = kind; |
|---|
| 373 | data->valid = 0; |
|---|
| 374 | init_MUTEX(&data->update_lock); |
|---|
| 375 | |
|---|
| 376 | /* Tell the I2C layer a new client has arrived */ |
|---|
| 377 | if ((err = i2c_attach_client(new_client))) |
|---|
| 378 | goto ERROR3; |
|---|
| 379 | |
|---|
| 380 | /* Register a new directory entry with module sensors */ |
|---|
| 381 | if ((i = i2c_register_entry(new_client, |
|---|
| 382 | type_name, |
|---|
| 383 | adm1024_dir_table_template, |
|---|
| 384 | THIS_MODULE)) < 0) { |
|---|
| 385 | err = i; |
|---|
| 386 | goto ERROR4; |
|---|
| 387 | } |
|---|
| 388 | data->sysctl_id = i; |
|---|
| 389 | |
|---|
| 390 | /* Initialize the ADM1024 chip */ |
|---|
| 391 | adm1024_init_client(new_client); |
|---|
| 392 | return 0; |
|---|
| 393 | |
|---|
| 394 | /* OK, this is not exactly good programming practice, usually. But it is |
|---|
| 395 | very code-efficient in this case. */ |
|---|
| 396 | |
|---|
| 397 | ERROR4: |
|---|
| 398 | i2c_detach_client(new_client); |
|---|
| 399 | ERROR3: |
|---|
| 400 | ERROR1: |
|---|
| 401 | kfree(data); |
|---|
| 402 | ERROR0: |
|---|
| 403 | return err; |
|---|
| 404 | } |
|---|
| 405 | |
|---|
| 406 | static int adm1024_detach_client(struct i2c_client *client) |
|---|
| 407 | { |
|---|
| 408 | int err; |
|---|
| 409 | |
|---|
| 410 | i2c_deregister_entry(((struct adm1024_data *) (client->data))-> |
|---|
| 411 | sysctl_id); |
|---|
| 412 | |
|---|
| 413 | if ((err = i2c_detach_client(client))) { |
|---|
| 414 | printk |
|---|
| 415 | ("adm1024.o: Client deregistration failed, client not detached.\n"); |
|---|
| 416 | return err; |
|---|
| 417 | } |
|---|
| 418 | |
|---|
| 419 | kfree(client->data); |
|---|
| 420 | |
|---|
| 421 | return 0; |
|---|
| 422 | } |
|---|
| 423 | |
|---|
| 424 | static int adm1024_read_value(struct i2c_client *client, u8 reg) |
|---|
| 425 | { |
|---|
| 426 | return 0xFF & i2c_smbus_read_byte_data(client, reg); |
|---|
| 427 | } |
|---|
| 428 | |
|---|
| 429 | static int adm1024_write_value(struct i2c_client *client, u8 reg, u8 value) |
|---|
| 430 | { |
|---|
| 431 | return i2c_smbus_write_byte_data(client, reg, value); |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | static void adm1024_init_client(struct i2c_client *client) |
|---|
| 435 | { |
|---|
| 436 | /* Enable temperature channel 2 */ |
|---|
| 437 | adm1024_write_value(client, ADM1024_REG_CHANNEL_MODE, adm1024_read_value(client, ADM1024_REG_CHANNEL_MODE) | 0x04); |
|---|
| 438 | |
|---|
| 439 | /* Start monitoring */ |
|---|
| 440 | adm1024_write_value(client, ADM1024_REG_CONFIG, 0x07); |
|---|
| 441 | } |
|---|
| 442 | |
|---|
| 443 | static void adm1024_update_client(struct i2c_client *client) |
|---|
| 444 | { |
|---|
| 445 | struct adm1024_data *data = client->data; |
|---|
| 446 | u8 i; |
|---|
| 447 | |
|---|
| 448 | down(&data->update_lock); |
|---|
| 449 | |
|---|
| 450 | if ( |
|---|
| 451 | (jiffies - data->last_updated > |
|---|
| 452 | (data->type == adm1024 ? HZ / 2 : HZ * 2)) |
|---|
| 453 | || (jiffies < data->last_updated) || !data->valid) { |
|---|
| 454 | |
|---|
| 455 | #ifdef DEBUG |
|---|
| 456 | printk("Starting adm1024 update\n"); |
|---|
| 457 | #endif |
|---|
| 458 | for (i = 0; i <= 5; i++) { |
|---|
| 459 | data->in[i] = |
|---|
| 460 | adm1024_read_value(client, ADM1024_REG_IN(i)); |
|---|
| 461 | data->in_min[i] = |
|---|
| 462 | adm1024_read_value(client, |
|---|
| 463 | ADM1024_REG_IN_MIN(i)); |
|---|
| 464 | data->in_max[i] = |
|---|
| 465 | adm1024_read_value(client, |
|---|
| 466 | ADM1024_REG_IN_MAX(i)); |
|---|
| 467 | } |
|---|
| 468 | data->fan[0] = |
|---|
| 469 | adm1024_read_value(client, ADM1024_REG_FAN1); |
|---|
| 470 | data->fan_min[0] = |
|---|
| 471 | adm1024_read_value(client, ADM1024_REG_FAN1_MIN); |
|---|
| 472 | data->fan[1] = |
|---|
| 473 | adm1024_read_value(client, ADM1024_REG_FAN2); |
|---|
| 474 | data->fan_min[1] = |
|---|
| 475 | adm1024_read_value(client, ADM1024_REG_FAN2_MIN); |
|---|
| 476 | data->temp = |
|---|
| 477 | (adm1024_read_value(client, ADM1024_REG_TEMP) << 1) + |
|---|
| 478 | ((adm1024_read_value |
|---|
| 479 | (client, ADM1024_REG_TEMP_CONFIG) & 0x80) >> 7); |
|---|
| 480 | data->temp_os_max = |
|---|
| 481 | adm1024_read_value(client, ADM1024_REG_TOS); |
|---|
| 482 | data->temp_os_hyst = |
|---|
| 483 | adm1024_read_value(client, ADM1024_REG_THYST); |
|---|
| 484 | data->temp1 = |
|---|
| 485 | adm1024_read_value(client, ADM1024_REG_EXT_TEMP1); |
|---|
| 486 | data->temp1_os_max = |
|---|
| 487 | adm1024_read_value(client, ADM1024_REG_EXT_TEMP1_HIGH); |
|---|
| 488 | data->temp1_os_hyst = |
|---|
| 489 | adm1024_read_value(client, ADM1024_REG_EXT_TEMP1_LOW); |
|---|
| 490 | data->temp2 = |
|---|
| 491 | adm1024_read_value(client, ADM1024_REG_2_5V); |
|---|
| 492 | data->temp2_os_max = |
|---|
| 493 | adm1024_read_value(client, ADM1024_REG_2_5V_HIGH); |
|---|
| 494 | data->temp2_os_hyst = |
|---|
| 495 | adm1024_read_value(client, ADM1024_REG_2_5V_LOW); |
|---|
| 496 | |
|---|
| 497 | i = adm1024_read_value(client, ADM1024_REG_VID_FAN_DIV); |
|---|
| 498 | data->fan_div[0] = (i >> 4) & 0x03; |
|---|
| 499 | data->fan_div[1] = (i >> 6) & 0x03; |
|---|
| 500 | data->vid = i & 0x0f; |
|---|
| 501 | data->vid |= |
|---|
| 502 | (adm1024_read_value(client, ADM1024_REG_VID4) & 0x01) |
|---|
| 503 | << 4; |
|---|
| 504 | |
|---|
| 505 | data->alarms = |
|---|
| 506 | adm1024_read_value(client, |
|---|
| 507 | ADM1024_REG_INT1_STAT) + |
|---|
| 508 | (adm1024_read_value(client, ADM1024_REG_INT2_STAT) << |
|---|
| 509 | 8); |
|---|
| 510 | data->analog_out = |
|---|
| 511 | adm1024_read_value(client, ADM1024_REG_ANALOG_OUT); |
|---|
| 512 | data->last_updated = jiffies; |
|---|
| 513 | data->valid = 1; |
|---|
| 514 | } |
|---|
| 515 | |
|---|
| 516 | up(&data->update_lock); |
|---|
| 517 | } |
|---|
| 518 | |
|---|
| 519 | |
|---|
| 520 | /* The next few functions are the call-back functions of the /proc/sys and |
|---|
| 521 | sysctl files. Which function is used is defined in the ctl_table in |
|---|
| 522 | the extra1 field. |
|---|
| 523 | Each function must return the magnitude (power of 10 to divide the date |
|---|
| 524 | with) if it is called with operation==SENSORS_PROC_REAL_INFO. It must |
|---|
| 525 | put a maximum of *nrels elements in results reflecting the data of this |
|---|
| 526 | file, and set *nrels to the number it actually put in it, if operation== |
|---|
| 527 | SENSORS_PROC_REAL_READ. Finally, it must get upto *nrels elements from |
|---|
| 528 | results and write them to the chip, if operations==SENSORS_PROC_REAL_WRITE. |
|---|
| 529 | Note that on SENSORS_PROC_REAL_READ, I do not check whether results is |
|---|
| 530 | large enough (by checking the incoming value of *nrels). This is not very |
|---|
| 531 | good practice, but as long as you put less than about 5 values in results, |
|---|
| 532 | you can assume it is large enough. */ |
|---|
| 533 | void adm1024_in(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 534 | int *nrels_mag, long *results) |
|---|
| 535 | { |
|---|
| 536 | |
|---|
| 537 | int scales[6] = { 250, 225, 330, 500, 1200, 270 }; |
|---|
| 538 | |
|---|
| 539 | struct adm1024_data *data = client->data; |
|---|
| 540 | int nr = ctl_name - ADM1024_SYSCTL_IN0; |
|---|
| 541 | |
|---|
| 542 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 543 | *nrels_mag = 2; |
|---|
| 544 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 545 | adm1024_update_client(client); |
|---|
| 546 | results[0] = |
|---|
| 547 | IN_FROM_REG(data->in_min[nr], nr) * scales[nr] / 192; |
|---|
| 548 | results[1] = |
|---|
| 549 | IN_FROM_REG(data->in_max[nr], nr) * scales[nr] / 192; |
|---|
| 550 | results[2] = |
|---|
| 551 | IN_FROM_REG(data->in[nr], nr) * scales[nr] / 192; |
|---|
| 552 | *nrels_mag = 3; |
|---|
| 553 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 554 | if (*nrels_mag >= 1) { |
|---|
| 555 | data->in_min[nr] = |
|---|
| 556 | IN_TO_REG((results[0] * 192) / scales[nr], nr); |
|---|
| 557 | adm1024_write_value(client, ADM1024_REG_IN_MIN(nr), |
|---|
| 558 | data->in_min[nr]); |
|---|
| 559 | } |
|---|
| 560 | if (*nrels_mag >= 2) { |
|---|
| 561 | data->in_max[nr] = |
|---|
| 562 | IN_TO_REG((results[1] * 192) / scales[nr], nr); |
|---|
| 563 | adm1024_write_value(client, ADM1024_REG_IN_MAX(nr), |
|---|
| 564 | data->in_max[nr]); |
|---|
| 565 | } |
|---|
| 566 | } |
|---|
| 567 | } |
|---|
| 568 | |
|---|
| 569 | void adm1024_fan(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 570 | int *nrels_mag, long *results) |
|---|
| 571 | { |
|---|
| 572 | struct adm1024_data *data = client->data; |
|---|
| 573 | int nr = ctl_name - ADM1024_SYSCTL_FAN1 + 1; |
|---|
| 574 | |
|---|
| 575 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 576 | *nrels_mag = 0; |
|---|
| 577 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 578 | adm1024_update_client(client); |
|---|
| 579 | results[0] = FAN_FROM_REG(data->fan_min[nr - 1], |
|---|
| 580 | DIV_FROM_REG(data-> |
|---|
| 581 | fan_div[nr - 1])); |
|---|
| 582 | results[1] = |
|---|
| 583 | FAN_FROM_REG(data->fan[nr - 1], |
|---|
| 584 | DIV_FROM_REG(data->fan_div[nr - 1])); |
|---|
| 585 | *nrels_mag = 2; |
|---|
| 586 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 587 | if (*nrels_mag >= 1) { |
|---|
| 588 | data->fan_min[nr - 1] = FAN_TO_REG(results[0], |
|---|
| 589 | DIV_FROM_REG |
|---|
| 590 | (data-> |
|---|
| 591 | fan_div[nr - |
|---|
| 592 | 1])); |
|---|
| 593 | adm1024_write_value(client, |
|---|
| 594 | nr == |
|---|
| 595 | 1 ? ADM1024_REG_FAN1_MIN : |
|---|
| 596 | ADM1024_REG_FAN2_MIN, |
|---|
| 597 | data->fan_min[nr - 1]); |
|---|
| 598 | } |
|---|
| 599 | } |
|---|
| 600 | } |
|---|
| 601 | |
|---|
| 602 | |
|---|
| 603 | void adm1024_temp(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 604 | int *nrels_mag, long *results) |
|---|
| 605 | { |
|---|
| 606 | struct adm1024_data *data = client->data; |
|---|
| 607 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 608 | *nrels_mag = 1; |
|---|
| 609 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 610 | adm1024_update_client(client); |
|---|
| 611 | results[0] = TEMP_LIMIT_FROM_REG(data->temp_os_max); |
|---|
| 612 | results[1] = TEMP_LIMIT_FROM_REG(data->temp_os_hyst); |
|---|
| 613 | results[2] = TEMP_FROM_REG(data->temp); |
|---|
| 614 | *nrels_mag = 3; |
|---|
| 615 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 616 | if (*nrels_mag >= 1) { |
|---|
| 617 | data->temp_os_max = TEMP_LIMIT_TO_REG(results[0]); |
|---|
| 618 | adm1024_write_value(client, ADM1024_REG_TOS, |
|---|
| 619 | data->temp_os_max); |
|---|
| 620 | } |
|---|
| 621 | if (*nrels_mag >= 2) { |
|---|
| 622 | data->temp_os_hyst = TEMP_LIMIT_TO_REG(results[1]); |
|---|
| 623 | adm1024_write_value(client, ADM1024_REG_THYST, |
|---|
| 624 | data->temp_os_hyst); |
|---|
| 625 | } |
|---|
| 626 | } |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | void adm1024_temp1(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 630 | int *nrels_mag, long *results) |
|---|
| 631 | { |
|---|
| 632 | struct adm1024_data *data = client->data; |
|---|
| 633 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 634 | *nrels_mag = 1; |
|---|
| 635 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 636 | adm1024_update_client(client); |
|---|
| 637 | results[0] = TEMP_LIMIT_FROM_REG(data->temp1_os_max); |
|---|
| 638 | results[1] = TEMP_LIMIT_FROM_REG(data->temp1_os_hyst); |
|---|
| 639 | results[2] = EXT_TEMP_FROM_REG(data->temp1); |
|---|
| 640 | *nrels_mag = 3; |
|---|
| 641 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 642 | if (*nrels_mag >= 1) { |
|---|
| 643 | data->temp1_os_max = TEMP_LIMIT_TO_REG(results[0]); |
|---|
| 644 | adm1024_write_value(client, ADM1024_REG_EXT_TEMP1_HIGH, |
|---|
| 645 | data->temp1_os_max); |
|---|
| 646 | } |
|---|
| 647 | if (*nrels_mag >= 2) { |
|---|
| 648 | data->temp1_os_hyst = TEMP_LIMIT_TO_REG(results[1]); |
|---|
| 649 | adm1024_write_value(client, ADM1024_REG_EXT_TEMP1_LOW, |
|---|
| 650 | data->temp1_os_hyst); |
|---|
| 651 | } |
|---|
| 652 | } |
|---|
| 653 | } |
|---|
| 654 | |
|---|
| 655 | void adm1024_temp2(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 656 | int *nrels_mag, long *results) |
|---|
| 657 | { |
|---|
| 658 | struct adm1024_data *data = client->data; |
|---|
| 659 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 660 | *nrels_mag = 1; |
|---|
| 661 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 662 | adm1024_update_client(client); |
|---|
| 663 | results[0] = TEMP_LIMIT_FROM_REG(data->temp2_os_max); |
|---|
| 664 | results[1] = TEMP_LIMIT_FROM_REG(data->temp2_os_hyst); |
|---|
| 665 | results[2] = EXT_TEMP_FROM_REG(data->temp2); |
|---|
| 666 | *nrels_mag = 3; |
|---|
| 667 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 668 | if (*nrels_mag >= 1) { |
|---|
| 669 | data->temp2_os_max = TEMP_LIMIT_TO_REG(results[0]); |
|---|
| 670 | adm1024_write_value(client, ADM1024_REG_2_5V_HIGH, |
|---|
| 671 | data->temp2_os_max); |
|---|
| 672 | } |
|---|
| 673 | if (*nrels_mag >= 2) { |
|---|
| 674 | data->temp2_os_hyst = TEMP_LIMIT_TO_REG(results[1]); |
|---|
| 675 | adm1024_write_value(client, ADM1024_REG_2_5V_LOW, |
|---|
| 676 | data->temp2_os_hyst); |
|---|
| 677 | } |
|---|
| 678 | } |
|---|
| 679 | } |
|---|
| 680 | |
|---|
| 681 | void adm1024_alarms(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 682 | int *nrels_mag, long *results) |
|---|
| 683 | { |
|---|
| 684 | struct adm1024_data *data = client->data; |
|---|
| 685 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 686 | *nrels_mag = 0; |
|---|
| 687 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 688 | adm1024_update_client(client); |
|---|
| 689 | results[0] = ALARMS_FROM_REG(data->alarms); |
|---|
| 690 | *nrels_mag = 1; |
|---|
| 691 | } |
|---|
| 692 | } |
|---|
| 693 | |
|---|
| 694 | void adm1024_fan_div(struct i2c_client *client, int operation, |
|---|
| 695 | int ctl_name, int *nrels_mag, long *results) |
|---|
| 696 | { |
|---|
| 697 | struct adm1024_data *data = client->data; |
|---|
| 698 | int old; |
|---|
| 699 | |
|---|
| 700 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 701 | *nrels_mag = 0; |
|---|
| 702 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 703 | adm1024_update_client(client); |
|---|
| 704 | results[0] = DIV_FROM_REG(data->fan_div[0]); |
|---|
| 705 | results[1] = DIV_FROM_REG(data->fan_div[1]); |
|---|
| 706 | *nrels_mag = 2; |
|---|
| 707 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 708 | old = adm1024_read_value(client, ADM1024_REG_VID_FAN_DIV); |
|---|
| 709 | if (*nrels_mag >= 2) { |
|---|
| 710 | data->fan_div[1] = DIV_TO_REG(results[1]); |
|---|
| 711 | old = (old & 0x3f) | (data->fan_div[1] << 6); |
|---|
| 712 | } |
|---|
| 713 | if (*nrels_mag >= 1) { |
|---|
| 714 | data->fan_div[0] = DIV_TO_REG(results[0]); |
|---|
| 715 | old = (old & 0xcf) | (data->fan_div[0] << 4); |
|---|
| 716 | adm1024_write_value(client, |
|---|
| 717 | ADM1024_REG_VID_FAN_DIV, old); |
|---|
| 718 | } |
|---|
| 719 | } |
|---|
| 720 | } |
|---|
| 721 | |
|---|
| 722 | void adm1024_analog_out(struct i2c_client *client, int operation, |
|---|
| 723 | int ctl_name, int *nrels_mag, long *results) |
|---|
| 724 | { |
|---|
| 725 | struct adm1024_data *data = client->data; |
|---|
| 726 | |
|---|
| 727 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 728 | *nrels_mag = 0; |
|---|
| 729 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 730 | adm1024_update_client(client); |
|---|
| 731 | results[0] = data->analog_out; |
|---|
| 732 | *nrels_mag = 1; |
|---|
| 733 | } else if (operation == SENSORS_PROC_REAL_WRITE) { |
|---|
| 734 | if (*nrels_mag >= 1) { |
|---|
| 735 | data->analog_out = results[0]; |
|---|
| 736 | adm1024_write_value(client, ADM1024_REG_ANALOG_OUT, |
|---|
| 737 | data->analog_out); |
|---|
| 738 | } |
|---|
| 739 | } |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | void adm1024_vid(struct i2c_client *client, int operation, int ctl_name, |
|---|
| 743 | int *nrels_mag, long *results) |
|---|
| 744 | { |
|---|
| 745 | struct adm1024_data *data = client->data; |
|---|
| 746 | |
|---|
| 747 | if (operation == SENSORS_PROC_REAL_INFO) |
|---|
| 748 | *nrels_mag = 2; |
|---|
| 749 | else if (operation == SENSORS_PROC_REAL_READ) { |
|---|
| 750 | adm1024_update_client(client); |
|---|
| 751 | results[0] = VID_FROM_REG(data->vid); |
|---|
| 752 | *nrels_mag = 1; |
|---|
| 753 | } |
|---|
| 754 | } |
|---|
| 755 | |
|---|
| 756 | static int __init sm_adm1024_init(void) |
|---|
| 757 | { |
|---|
| 758 | printk("adm1024.o version %s (%s)\n", LM_VERSION, LM_DATE); |
|---|
| 759 | return i2c_add_driver(&adm1024_driver); |
|---|
| 760 | } |
|---|
| 761 | |
|---|
| 762 | static void __exit sm_adm1024_exit(void) |
|---|
| 763 | { |
|---|
| 764 | i2c_del_driver(&adm1024_driver); |
|---|
| 765 | } |
|---|
| 766 | |
|---|
| 767 | |
|---|
| 768 | |
|---|
| 769 | MODULE_AUTHOR |
|---|
| 770 | ("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>"); |
|---|
| 771 | MODULE_DESCRIPTION("ADM1024 driver"); |
|---|
| 772 | |
|---|
| 773 | MODULE_LICENSE("GPL"); |
|---|
| 774 | |
|---|
| 775 | module_init(sm_adm1024_init); |
|---|
| 776 | module_exit(sm_adm1024_exit); |
|---|