Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | lm78.c - Part of lm_sensors, Linux kernel modules for hardware |
| 3 | monitoring |
| 4 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | */ |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/module.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/slab.h> |
| 24 | #include <linux/jiffies.h> |
| 25 | #include <linux/i2c.h> |
Jean Delvare | fde0950 | 2005-07-19 23:51:07 +0200 | [diff] [blame] | 26 | #include <linux/i2c-isa.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/i2c-sensor.h> |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 28 | #include <linux/hwmon.h> |
| 29 | #include <linux/err.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <asm/io.h> |
| 31 | |
| 32 | /* Addresses to scan */ |
| 33 | static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, |
| 34 | 0x25, 0x26, 0x27, 0x28, 0x29, |
| 35 | 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, |
| 36 | 0x2f, I2C_CLIENT_END }; |
Jean Delvare | 2d8672c | 2005-07-19 23:56:35 +0200 | [diff] [blame] | 37 | static unsigned short isa_address = 0x290; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | /* Insmod parameters */ |
Jean Delvare | 27fe048 | 2005-07-27 21:30:16 +0200 | [diff] [blame] | 40 | SENSORS_INSMOD_2(lm78, lm79); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
| 42 | /* Many LM78 constants specified below */ |
| 43 | |
| 44 | /* Length of ISA address segment */ |
| 45 | #define LM78_EXTENT 8 |
| 46 | |
| 47 | /* Where are the ISA address/data registers relative to the base address */ |
| 48 | #define LM78_ADDR_REG_OFFSET 5 |
| 49 | #define LM78_DATA_REG_OFFSET 6 |
| 50 | |
| 51 | /* The LM78 registers */ |
| 52 | #define LM78_REG_IN_MAX(nr) (0x2b + (nr) * 2) |
| 53 | #define LM78_REG_IN_MIN(nr) (0x2c + (nr) * 2) |
| 54 | #define LM78_REG_IN(nr) (0x20 + (nr)) |
| 55 | |
| 56 | #define LM78_REG_FAN_MIN(nr) (0x3b + (nr)) |
| 57 | #define LM78_REG_FAN(nr) (0x28 + (nr)) |
| 58 | |
| 59 | #define LM78_REG_TEMP 0x27 |
| 60 | #define LM78_REG_TEMP_OVER 0x39 |
| 61 | #define LM78_REG_TEMP_HYST 0x3a |
| 62 | |
| 63 | #define LM78_REG_ALARM1 0x41 |
| 64 | #define LM78_REG_ALARM2 0x42 |
| 65 | |
| 66 | #define LM78_REG_VID_FANDIV 0x47 |
| 67 | |
| 68 | #define LM78_REG_CONFIG 0x40 |
| 69 | #define LM78_REG_CHIPID 0x49 |
| 70 | #define LM78_REG_I2C_ADDR 0x48 |
| 71 | |
| 72 | |
| 73 | /* Conversions. Rounding and limit checking is only done on the TO_REG |
| 74 | variants. */ |
| 75 | |
| 76 | /* IN: mV, (0V to 4.08V) |
| 77 | REG: 16mV/bit */ |
| 78 | static inline u8 IN_TO_REG(unsigned long val) |
| 79 | { |
| 80 | unsigned long nval = SENSORS_LIMIT(val, 0, 4080); |
| 81 | return (nval + 8) / 16; |
| 82 | } |
| 83 | #define IN_FROM_REG(val) ((val) * 16) |
| 84 | |
| 85 | static inline u8 FAN_TO_REG(long rpm, int div) |
| 86 | { |
| 87 | if (rpm <= 0) |
| 88 | return 255; |
| 89 | return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 254); |
| 90 | } |
| 91 | |
| 92 | static inline int FAN_FROM_REG(u8 val, int div) |
| 93 | { |
| 94 | return val==0 ? -1 : val==255 ? 0 : 1350000/(val*div); |
| 95 | } |
| 96 | |
| 97 | /* TEMP: mC (-128C to +127C) |
| 98 | REG: 1C/bit, two's complement */ |
| 99 | static inline s8 TEMP_TO_REG(int val) |
| 100 | { |
| 101 | int nval = SENSORS_LIMIT(val, -128000, 127000) ; |
| 102 | return nval<0 ? (nval-500)/1000 : (nval+500)/1000; |
| 103 | } |
| 104 | |
| 105 | static inline int TEMP_FROM_REG(s8 val) |
| 106 | { |
| 107 | return val * 1000; |
| 108 | } |
| 109 | |
| 110 | /* VID: mV |
| 111 | REG: (see doc/vid) */ |
| 112 | static inline int VID_FROM_REG(u8 val) |
| 113 | { |
| 114 | return val==0x1f ? 0 : val>=0x10 ? 5100-val*100 : 2050-val*50; |
| 115 | } |
| 116 | |
| 117 | #define DIV_FROM_REG(val) (1 << (val)) |
| 118 | |
| 119 | /* There are some complications in a module like this. First off, LM78 chips |
| 120 | may be both present on the SMBus and the ISA bus, and we have to handle |
| 121 | those cases separately at some places. Second, there might be several |
| 122 | LM78 chips available (well, actually, that is probably never done; but |
| 123 | it is a clean illustration of how to handle a case like that). Finally, |
| 124 | a specific chip may be attached to *both* ISA and SMBus, and we would |
| 125 | not like to detect it double. Fortunately, in the case of the LM78 at |
| 126 | least, a register tells us what SMBus address we are on, so that helps |
| 127 | a bit - except if there could be more than one SMBus. Groan. No solution |
| 128 | for this yet. */ |
| 129 | |
| 130 | /* This module may seem overly long and complicated. In fact, it is not so |
| 131 | bad. Quite a lot of bookkeeping is done. A real driver can often cut |
| 132 | some corners. */ |
| 133 | |
| 134 | /* For each registered LM78, we need to keep some data in memory. That |
| 135 | data is pointed to by lm78_list[NR]->data. The structure itself is |
| 136 | dynamically allocated, at the same time when a new lm78 client is |
| 137 | allocated. */ |
| 138 | struct lm78_data { |
| 139 | struct i2c_client client; |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 140 | struct class_device *class_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | struct semaphore lock; |
| 142 | enum chips type; |
| 143 | |
| 144 | struct semaphore update_lock; |
| 145 | char valid; /* !=0 if following fields are valid */ |
| 146 | unsigned long last_updated; /* In jiffies */ |
| 147 | |
| 148 | u8 in[7]; /* Register value */ |
| 149 | u8 in_max[7]; /* Register value */ |
| 150 | u8 in_min[7]; /* Register value */ |
| 151 | u8 fan[3]; /* Register value */ |
| 152 | u8 fan_min[3]; /* Register value */ |
| 153 | s8 temp; /* Register value */ |
| 154 | s8 temp_over; /* Register value */ |
| 155 | s8 temp_hyst; /* Register value */ |
| 156 | u8 fan_div[3]; /* Register encoding, shifted right */ |
| 157 | u8 vid; /* Register encoding, combined */ |
| 158 | u16 alarms; /* Register encoding, combined */ |
| 159 | }; |
| 160 | |
| 161 | |
| 162 | static int lm78_attach_adapter(struct i2c_adapter *adapter); |
Jean Delvare | 2d8672c | 2005-07-19 23:56:35 +0200 | [diff] [blame] | 163 | static int lm78_isa_attach_adapter(struct i2c_adapter *adapter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); |
| 165 | static int lm78_detach_client(struct i2c_client *client); |
| 166 | |
| 167 | static int lm78_read_value(struct i2c_client *client, u8 register); |
| 168 | static int lm78_write_value(struct i2c_client *client, u8 register, u8 value); |
| 169 | static struct lm78_data *lm78_update_device(struct device *dev); |
| 170 | static void lm78_init_client(struct i2c_client *client); |
| 171 | |
| 172 | |
| 173 | static struct i2c_driver lm78_driver = { |
| 174 | .owner = THIS_MODULE, |
| 175 | .name = "lm78", |
| 176 | .id = I2C_DRIVERID_LM78, |
| 177 | .flags = I2C_DF_NOTIFY, |
| 178 | .attach_adapter = lm78_attach_adapter, |
| 179 | .detach_client = lm78_detach_client, |
| 180 | }; |
| 181 | |
Jean Delvare | fde0950 | 2005-07-19 23:51:07 +0200 | [diff] [blame] | 182 | static struct i2c_driver lm78_isa_driver = { |
| 183 | .owner = THIS_MODULE, |
| 184 | .name = "lm78-isa", |
Jean Delvare | 2d8672c | 2005-07-19 23:56:35 +0200 | [diff] [blame] | 185 | .attach_adapter = lm78_isa_attach_adapter, |
Jean Delvare | fde0950 | 2005-07-19 23:51:07 +0200 | [diff] [blame] | 186 | .detach_client = lm78_detach_client, |
| 187 | }; |
| 188 | |
| 189 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | /* 7 Voltages */ |
| 191 | static ssize_t show_in(struct device *dev, char *buf, int nr) |
| 192 | { |
| 193 | struct lm78_data *data = lm78_update_device(dev); |
| 194 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); |
| 195 | } |
| 196 | |
| 197 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) |
| 198 | { |
| 199 | struct lm78_data *data = lm78_update_device(dev); |
| 200 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])); |
| 201 | } |
| 202 | |
| 203 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) |
| 204 | { |
| 205 | struct lm78_data *data = lm78_update_device(dev); |
| 206 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])); |
| 207 | } |
| 208 | |
| 209 | static ssize_t set_in_min(struct device *dev, const char *buf, |
| 210 | size_t count, int nr) |
| 211 | { |
| 212 | struct i2c_client *client = to_i2c_client(dev); |
| 213 | struct lm78_data *data = i2c_get_clientdata(client); |
| 214 | unsigned long val = simple_strtoul(buf, NULL, 10); |
| 215 | |
| 216 | down(&data->update_lock); |
| 217 | data->in_min[nr] = IN_TO_REG(val); |
| 218 | lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]); |
| 219 | up(&data->update_lock); |
| 220 | return count; |
| 221 | } |
| 222 | |
| 223 | static ssize_t set_in_max(struct device *dev, const char *buf, |
| 224 | size_t count, int nr) |
| 225 | { |
| 226 | struct i2c_client *client = to_i2c_client(dev); |
| 227 | struct lm78_data *data = i2c_get_clientdata(client); |
| 228 | unsigned long val = simple_strtoul(buf, NULL, 10); |
| 229 | |
| 230 | down(&data->update_lock); |
| 231 | data->in_max[nr] = IN_TO_REG(val); |
| 232 | lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]); |
| 233 | up(&data->update_lock); |
| 234 | return count; |
| 235 | } |
| 236 | |
| 237 | #define show_in_offset(offset) \ |
| 238 | static ssize_t \ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 239 | show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | { \ |
| 241 | return show_in(dev, buf, offset); \ |
| 242 | } \ |
| 243 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
| 244 | show_in##offset, NULL); \ |
| 245 | static ssize_t \ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 246 | show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | { \ |
| 248 | return show_in_min(dev, buf, offset); \ |
| 249 | } \ |
| 250 | static ssize_t \ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 251 | show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | { \ |
| 253 | return show_in_max(dev, buf, offset); \ |
| 254 | } \ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 255 | static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | const char *buf, size_t count) \ |
| 257 | { \ |
| 258 | return set_in_min(dev, buf, count, offset); \ |
| 259 | } \ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 260 | static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | const char *buf, size_t count) \ |
| 262 | { \ |
| 263 | return set_in_max(dev, buf, count, offset); \ |
| 264 | } \ |
| 265 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ |
| 266 | show_in##offset##_min, set_in##offset##_min); \ |
| 267 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ |
| 268 | show_in##offset##_max, set_in##offset##_max); |
| 269 | |
| 270 | show_in_offset(0); |
| 271 | show_in_offset(1); |
| 272 | show_in_offset(2); |
| 273 | show_in_offset(3); |
| 274 | show_in_offset(4); |
| 275 | show_in_offset(5); |
| 276 | show_in_offset(6); |
| 277 | |
| 278 | /* Temperature */ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 279 | static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | { |
| 281 | struct lm78_data *data = lm78_update_device(dev); |
| 282 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); |
| 283 | } |
| 284 | |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 285 | static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | { |
| 287 | struct lm78_data *data = lm78_update_device(dev); |
| 288 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); |
| 289 | } |
| 290 | |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 291 | static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | { |
| 293 | struct i2c_client *client = to_i2c_client(dev); |
| 294 | struct lm78_data *data = i2c_get_clientdata(client); |
| 295 | long val = simple_strtol(buf, NULL, 10); |
| 296 | |
| 297 | down(&data->update_lock); |
| 298 | data->temp_over = TEMP_TO_REG(val); |
| 299 | lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over); |
| 300 | up(&data->update_lock); |
| 301 | return count; |
| 302 | } |
| 303 | |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 304 | static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | { |
| 306 | struct lm78_data *data = lm78_update_device(dev); |
| 307 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst)); |
| 308 | } |
| 309 | |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 310 | static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | { |
| 312 | struct i2c_client *client = to_i2c_client(dev); |
| 313 | struct lm78_data *data = i2c_get_clientdata(client); |
| 314 | long val = simple_strtol(buf, NULL, 10); |
| 315 | |
| 316 | down(&data->update_lock); |
| 317 | data->temp_hyst = TEMP_TO_REG(val); |
| 318 | lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst); |
| 319 | up(&data->update_lock); |
| 320 | return count; |
| 321 | } |
| 322 | |
| 323 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); |
| 324 | static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, |
| 325 | show_temp_over, set_temp_over); |
| 326 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, |
| 327 | show_temp_hyst, set_temp_hyst); |
| 328 | |
| 329 | /* 3 Fans */ |
| 330 | static ssize_t show_fan(struct device *dev, char *buf, int nr) |
| 331 | { |
| 332 | struct lm78_data *data = lm78_update_device(dev); |
| 333 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], |
| 334 | DIV_FROM_REG(data->fan_div[nr])) ); |
| 335 | } |
| 336 | |
| 337 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) |
| 338 | { |
| 339 | struct lm78_data *data = lm78_update_device(dev); |
| 340 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr], |
| 341 | DIV_FROM_REG(data->fan_div[nr])) ); |
| 342 | } |
| 343 | |
| 344 | static ssize_t set_fan_min(struct device *dev, const char *buf, |
| 345 | size_t count, int nr) |
| 346 | { |
| 347 | struct i2c_client *client = to_i2c_client(dev); |
| 348 | struct lm78_data *data = i2c_get_clientdata(client); |
| 349 | unsigned long val = simple_strtoul(buf, NULL, 10); |
| 350 | |
| 351 | down(&data->update_lock); |
| 352 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
| 353 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); |
| 354 | up(&data->update_lock); |
| 355 | return count; |
| 356 | } |
| 357 | |
| 358 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) |
| 359 | { |
| 360 | struct lm78_data *data = lm78_update_device(dev); |
| 361 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]) ); |
| 362 | } |
| 363 | |
| 364 | /* Note: we save and restore the fan minimum here, because its value is |
| 365 | determined in part by the fan divisor. This follows the principle of |
| 366 | least suprise; the user doesn't expect the fan minimum to change just |
| 367 | because the divisor changed. */ |
| 368 | static ssize_t set_fan_div(struct device *dev, const char *buf, |
| 369 | size_t count, int nr) |
| 370 | { |
| 371 | struct i2c_client *client = to_i2c_client(dev); |
| 372 | struct lm78_data *data = i2c_get_clientdata(client); |
| 373 | unsigned long val = simple_strtoul(buf, NULL, 10); |
| 374 | unsigned long min; |
| 375 | u8 reg; |
| 376 | |
| 377 | down(&data->update_lock); |
| 378 | min = FAN_FROM_REG(data->fan_min[nr], |
| 379 | DIV_FROM_REG(data->fan_div[nr])); |
| 380 | |
| 381 | switch (val) { |
| 382 | case 1: data->fan_div[nr] = 0; break; |
| 383 | case 2: data->fan_div[nr] = 1; break; |
| 384 | case 4: data->fan_div[nr] = 2; break; |
| 385 | case 8: data->fan_div[nr] = 3; break; |
| 386 | default: |
| 387 | dev_err(&client->dev, "fan_div value %ld not " |
| 388 | "supported. Choose one of 1, 2, 4 or 8!\n", val); |
| 389 | up(&data->update_lock); |
| 390 | return -EINVAL; |
| 391 | } |
| 392 | |
| 393 | reg = lm78_read_value(client, LM78_REG_VID_FANDIV); |
| 394 | switch (nr) { |
| 395 | case 0: |
| 396 | reg = (reg & 0xcf) | (data->fan_div[nr] << 4); |
| 397 | break; |
| 398 | case 1: |
| 399 | reg = (reg & 0x3f) | (data->fan_div[nr] << 6); |
| 400 | break; |
| 401 | } |
| 402 | lm78_write_value(client, LM78_REG_VID_FANDIV, reg); |
| 403 | |
| 404 | data->fan_min[nr] = |
| 405 | FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
| 406 | lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]); |
| 407 | up(&data->update_lock); |
| 408 | |
| 409 | return count; |
| 410 | } |
| 411 | |
| 412 | #define show_fan_offset(offset) \ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 413 | static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | { \ |
| 415 | return show_fan(dev, buf, offset - 1); \ |
| 416 | } \ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 417 | static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | { \ |
| 419 | return show_fan_min(dev, buf, offset - 1); \ |
| 420 | } \ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 421 | static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | { \ |
| 423 | return show_fan_div(dev, buf, offset - 1); \ |
| 424 | } \ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 425 | static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | const char *buf, size_t count) \ |
| 427 | { \ |
| 428 | return set_fan_min(dev, buf, count, offset - 1); \ |
| 429 | } \ |
| 430 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\ |
| 431 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
| 432 | show_fan_##offset##_min, set_fan_##offset##_min); |
| 433 | |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 434 | static ssize_t set_fan_1_div(struct device *dev, struct device_attribute *attr, const char *buf, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | size_t count) |
| 436 | { |
| 437 | return set_fan_div(dev, buf, count, 0) ; |
| 438 | } |
| 439 | |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 440 | static ssize_t set_fan_2_div(struct device *dev, struct device_attribute *attr, const char *buf, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | size_t count) |
| 442 | { |
| 443 | return set_fan_div(dev, buf, count, 1) ; |
| 444 | } |
| 445 | |
| 446 | show_fan_offset(1); |
| 447 | show_fan_offset(2); |
| 448 | show_fan_offset(3); |
| 449 | |
| 450 | /* Fan 3 divisor is locked in H/W */ |
| 451 | static DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR, |
| 452 | show_fan_1_div, set_fan_1_div); |
| 453 | static DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR, |
| 454 | show_fan_2_div, set_fan_2_div); |
| 455 | static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL); |
| 456 | |
| 457 | /* VID */ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 458 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | { |
| 460 | struct lm78_data *data = lm78_update_device(dev); |
| 461 | return sprintf(buf, "%d\n", VID_FROM_REG(data->vid)); |
| 462 | } |
| 463 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); |
| 464 | |
| 465 | /* Alarms */ |
Yani Ioannou | 8627f9b | 2005-05-17 06:42:03 -0400 | [diff] [blame] | 466 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | { |
| 468 | struct lm78_data *data = lm78_update_device(dev); |
| 469 | return sprintf(buf, "%u\n", data->alarms); |
| 470 | } |
| 471 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
| 472 | |
| 473 | /* This function is called when: |
| 474 | * lm78_driver is inserted (when this module is loaded), for each |
| 475 | available adapter |
| 476 | * when a new adapter is inserted (and lm78_driver is still present) */ |
| 477 | static int lm78_attach_adapter(struct i2c_adapter *adapter) |
| 478 | { |
| 479 | if (!(adapter->class & I2C_CLASS_HWMON)) |
| 480 | return 0; |
| 481 | return i2c_detect(adapter, &addr_data, lm78_detect); |
| 482 | } |
| 483 | |
Jean Delvare | 2d8672c | 2005-07-19 23:56:35 +0200 | [diff] [blame] | 484 | static int lm78_isa_attach_adapter(struct i2c_adapter *adapter) |
| 485 | { |
| 486 | return lm78_detect(adapter, isa_address, -1); |
| 487 | } |
| 488 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | /* This function is called by i2c_detect */ |
| 490 | int lm78_detect(struct i2c_adapter *adapter, int address, int kind) |
| 491 | { |
| 492 | int i, err; |
| 493 | struct i2c_client *new_client; |
| 494 | struct lm78_data *data; |
| 495 | const char *client_name = ""; |
| 496 | int is_isa = i2c_is_isa_adapter(adapter); |
| 497 | |
| 498 | if (!is_isa && |
| 499 | !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
| 500 | err = -ENODEV; |
| 501 | goto ERROR0; |
| 502 | } |
| 503 | |
| 504 | /* Reserve the ISA region */ |
| 505 | if (is_isa) |
Jean Delvare | fde0950 | 2005-07-19 23:51:07 +0200 | [diff] [blame] | 506 | if (!request_region(address, LM78_EXTENT, |
| 507 | lm78_isa_driver.name)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | err = -EBUSY; |
| 509 | goto ERROR0; |
| 510 | } |
| 511 | |
| 512 | /* Probe whether there is anything available on this address. Already |
| 513 | done for SMBus clients */ |
| 514 | if (kind < 0) { |
| 515 | if (is_isa) { |
| 516 | |
| 517 | #define REALLY_SLOW_IO |
| 518 | /* We need the timeouts for at least some LM78-like |
| 519 | chips. But only if we read 'undefined' registers. */ |
| 520 | i = inb_p(address + 1); |
| 521 | if (inb_p(address + 2) != i) { |
| 522 | err = -ENODEV; |
| 523 | goto ERROR1; |
| 524 | } |
| 525 | if (inb_p(address + 3) != i) { |
| 526 | err = -ENODEV; |
| 527 | goto ERROR1; |
| 528 | } |
| 529 | if (inb_p(address + 7) != i) { |
| 530 | err = -ENODEV; |
| 531 | goto ERROR1; |
| 532 | } |
| 533 | #undef REALLY_SLOW_IO |
| 534 | |
| 535 | /* Let's just hope nothing breaks here */ |
| 536 | i = inb_p(address + 5) & 0x7f; |
| 537 | outb_p(~i & 0x7f, address + 5); |
| 538 | if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) { |
| 539 | outb_p(i, address + 5); |
| 540 | err = -ENODEV; |
| 541 | goto ERROR1; |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | /* OK. For now, we presume we have a valid client. We now create the |
| 547 | client structure, even though we cannot fill it completely yet. |
| 548 | But it allows us to access lm78_{read,write}_value. */ |
| 549 | |
| 550 | if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) { |
| 551 | err = -ENOMEM; |
| 552 | goto ERROR1; |
| 553 | } |
| 554 | memset(data, 0, sizeof(struct lm78_data)); |
| 555 | |
| 556 | new_client = &data->client; |
| 557 | if (is_isa) |
| 558 | init_MUTEX(&data->lock); |
| 559 | i2c_set_clientdata(new_client, data); |
| 560 | new_client->addr = address; |
| 561 | new_client->adapter = adapter; |
Jean Delvare | fde0950 | 2005-07-19 23:51:07 +0200 | [diff] [blame] | 562 | new_client->driver = is_isa ? &lm78_isa_driver : &lm78_driver; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | new_client->flags = 0; |
| 564 | |
| 565 | /* Now, we do the remaining detection. */ |
| 566 | if (kind < 0) { |
| 567 | if (lm78_read_value(new_client, LM78_REG_CONFIG) & 0x80) { |
| 568 | err = -ENODEV; |
| 569 | goto ERROR2; |
| 570 | } |
| 571 | if (!is_isa && (lm78_read_value( |
| 572 | new_client, LM78_REG_I2C_ADDR) != address)) { |
| 573 | err = -ENODEV; |
| 574 | goto ERROR2; |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | /* Determine the chip type. */ |
| 579 | if (kind <= 0) { |
| 580 | i = lm78_read_value(new_client, LM78_REG_CHIPID); |
Jean Delvare | 27fe048 | 2005-07-27 21:30:16 +0200 | [diff] [blame] | 581 | if (i == 0x00 || i == 0x20 /* LM78 */ |
| 582 | || i == 0x40) /* LM78-J */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | kind = lm78; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | else if ((i & 0xfe) == 0xc0) |
| 585 | kind = lm79; |
| 586 | else { |
| 587 | if (kind == 0) |
| 588 | dev_warn(&adapter->dev, "Ignoring 'force' " |
| 589 | "parameter for unknown chip at " |
| 590 | "adapter %d, address 0x%02x\n", |
| 591 | i2c_adapter_id(adapter), address); |
| 592 | err = -ENODEV; |
| 593 | goto ERROR2; |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | if (kind == lm78) { |
| 598 | client_name = "lm78"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | } else if (kind == lm79) { |
| 600 | client_name = "lm79"; |
| 601 | } |
| 602 | |
| 603 | /* Fill in the remaining client fields and put into the global list */ |
| 604 | strlcpy(new_client->name, client_name, I2C_NAME_SIZE); |
| 605 | data->type = kind; |
| 606 | |
| 607 | data->valid = 0; |
| 608 | init_MUTEX(&data->update_lock); |
| 609 | |
| 610 | /* Tell the I2C layer a new client has arrived */ |
| 611 | if ((err = i2c_attach_client(new_client))) |
| 612 | goto ERROR2; |
| 613 | |
| 614 | /* Initialize the LM78 chip */ |
| 615 | lm78_init_client(new_client); |
| 616 | |
| 617 | /* A few vars need to be filled upon startup */ |
| 618 | for (i = 0; i < 3; i++) { |
| 619 | data->fan_min[i] = lm78_read_value(new_client, |
| 620 | LM78_REG_FAN_MIN(i)); |
| 621 | } |
| 622 | |
| 623 | /* Register sysfs hooks */ |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 624 | data->class_dev = hwmon_device_register(&new_client->dev); |
| 625 | if (IS_ERR(data->class_dev)) { |
| 626 | err = PTR_ERR(data->class_dev); |
| 627 | goto ERROR3; |
| 628 | } |
| 629 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | device_create_file(&new_client->dev, &dev_attr_in0_input); |
| 631 | device_create_file(&new_client->dev, &dev_attr_in0_min); |
| 632 | device_create_file(&new_client->dev, &dev_attr_in0_max); |
| 633 | device_create_file(&new_client->dev, &dev_attr_in1_input); |
| 634 | device_create_file(&new_client->dev, &dev_attr_in1_min); |
| 635 | device_create_file(&new_client->dev, &dev_attr_in1_max); |
| 636 | device_create_file(&new_client->dev, &dev_attr_in2_input); |
| 637 | device_create_file(&new_client->dev, &dev_attr_in2_min); |
| 638 | device_create_file(&new_client->dev, &dev_attr_in2_max); |
| 639 | device_create_file(&new_client->dev, &dev_attr_in3_input); |
| 640 | device_create_file(&new_client->dev, &dev_attr_in3_min); |
| 641 | device_create_file(&new_client->dev, &dev_attr_in3_max); |
| 642 | device_create_file(&new_client->dev, &dev_attr_in4_input); |
| 643 | device_create_file(&new_client->dev, &dev_attr_in4_min); |
| 644 | device_create_file(&new_client->dev, &dev_attr_in4_max); |
| 645 | device_create_file(&new_client->dev, &dev_attr_in5_input); |
| 646 | device_create_file(&new_client->dev, &dev_attr_in5_min); |
| 647 | device_create_file(&new_client->dev, &dev_attr_in5_max); |
| 648 | device_create_file(&new_client->dev, &dev_attr_in6_input); |
| 649 | device_create_file(&new_client->dev, &dev_attr_in6_min); |
| 650 | device_create_file(&new_client->dev, &dev_attr_in6_max); |
| 651 | device_create_file(&new_client->dev, &dev_attr_temp1_input); |
| 652 | device_create_file(&new_client->dev, &dev_attr_temp1_max); |
| 653 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); |
| 654 | device_create_file(&new_client->dev, &dev_attr_fan1_input); |
| 655 | device_create_file(&new_client->dev, &dev_attr_fan1_min); |
| 656 | device_create_file(&new_client->dev, &dev_attr_fan1_div); |
| 657 | device_create_file(&new_client->dev, &dev_attr_fan2_input); |
| 658 | device_create_file(&new_client->dev, &dev_attr_fan2_min); |
| 659 | device_create_file(&new_client->dev, &dev_attr_fan2_div); |
| 660 | device_create_file(&new_client->dev, &dev_attr_fan3_input); |
| 661 | device_create_file(&new_client->dev, &dev_attr_fan3_min); |
| 662 | device_create_file(&new_client->dev, &dev_attr_fan3_div); |
| 663 | device_create_file(&new_client->dev, &dev_attr_alarms); |
| 664 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); |
| 665 | |
| 666 | return 0; |
| 667 | |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 668 | ERROR3: |
| 669 | i2c_detach_client(new_client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | ERROR2: |
| 671 | kfree(data); |
| 672 | ERROR1: |
| 673 | if (is_isa) |
| 674 | release_region(address, LM78_EXTENT); |
| 675 | ERROR0: |
| 676 | return err; |
| 677 | } |
| 678 | |
| 679 | static int lm78_detach_client(struct i2c_client *client) |
| 680 | { |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 681 | struct lm78_data *data = i2c_get_clientdata(client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | int err; |
| 683 | |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 684 | hwmon_device_unregister(data->class_dev); |
| 685 | |
Jean Delvare | 7bef559 | 2005-07-27 22:14:49 +0200 | [diff] [blame^] | 686 | if ((err = i2c_detach_client(client))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | |
| 689 | if(i2c_is_isa_client(client)) |
| 690 | release_region(client->addr, LM78_EXTENT); |
| 691 | |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 692 | kfree(data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | |
| 694 | return 0; |
| 695 | } |
| 696 | |
Steven Cole | 44bbe87 | 2005-05-03 18:21:25 -0600 | [diff] [blame] | 697 | /* The SMBus locks itself, but ISA access must be locked explicitly! |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | We don't want to lock the whole ISA bus, so we lock each client |
| 699 | separately. |
| 700 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, |
| 701 | would slow down the LM78 access and should not be necessary. */ |
| 702 | static int lm78_read_value(struct i2c_client *client, u8 reg) |
| 703 | { |
| 704 | int res; |
| 705 | if (i2c_is_isa_client(client)) { |
| 706 | struct lm78_data *data = i2c_get_clientdata(client); |
| 707 | down(&data->lock); |
| 708 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); |
| 709 | res = inb_p(client->addr + LM78_DATA_REG_OFFSET); |
| 710 | up(&data->lock); |
| 711 | return res; |
| 712 | } else |
| 713 | return i2c_smbus_read_byte_data(client, reg); |
| 714 | } |
| 715 | |
Steven Cole | 44bbe87 | 2005-05-03 18:21:25 -0600 | [diff] [blame] | 716 | /* The SMBus locks itself, but ISA access muse be locked explicitly! |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | We don't want to lock the whole ISA bus, so we lock each client |
| 718 | separately. |
| 719 | We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, |
| 720 | would slow down the LM78 access and should not be necessary. |
| 721 | There are some ugly typecasts here, but the good new is - they should |
| 722 | nowhere else be necessary! */ |
| 723 | static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value) |
| 724 | { |
| 725 | if (i2c_is_isa_client(client)) { |
| 726 | struct lm78_data *data = i2c_get_clientdata(client); |
| 727 | down(&data->lock); |
| 728 | outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET); |
| 729 | outb_p(value, client->addr + LM78_DATA_REG_OFFSET); |
| 730 | up(&data->lock); |
| 731 | return 0; |
| 732 | } else |
| 733 | return i2c_smbus_write_byte_data(client, reg, value); |
| 734 | } |
| 735 | |
| 736 | /* Called when we have found a new LM78. It should set limits, etc. */ |
| 737 | static void lm78_init_client(struct i2c_client *client) |
| 738 | { |
| 739 | u8 config = lm78_read_value(client, LM78_REG_CONFIG); |
| 740 | |
| 741 | /* Start monitoring */ |
| 742 | if (!(config & 0x01)) |
| 743 | lm78_write_value(client, LM78_REG_CONFIG, |
| 744 | (config & 0xf7) | 0x01); |
| 745 | } |
| 746 | |
| 747 | static struct lm78_data *lm78_update_device(struct device *dev) |
| 748 | { |
| 749 | struct i2c_client *client = to_i2c_client(dev); |
| 750 | struct lm78_data *data = i2c_get_clientdata(client); |
| 751 | int i; |
| 752 | |
| 753 | down(&data->update_lock); |
| 754 | |
| 755 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
| 756 | || !data->valid) { |
| 757 | |
| 758 | dev_dbg(&client->dev, "Starting lm78 update\n"); |
| 759 | |
| 760 | for (i = 0; i <= 6; i++) { |
| 761 | data->in[i] = |
| 762 | lm78_read_value(client, LM78_REG_IN(i)); |
| 763 | data->in_min[i] = |
| 764 | lm78_read_value(client, LM78_REG_IN_MIN(i)); |
| 765 | data->in_max[i] = |
| 766 | lm78_read_value(client, LM78_REG_IN_MAX(i)); |
| 767 | } |
| 768 | for (i = 0; i < 3; i++) { |
| 769 | data->fan[i] = |
| 770 | lm78_read_value(client, LM78_REG_FAN(i)); |
| 771 | data->fan_min[i] = |
| 772 | lm78_read_value(client, LM78_REG_FAN_MIN(i)); |
| 773 | } |
| 774 | data->temp = lm78_read_value(client, LM78_REG_TEMP); |
| 775 | data->temp_over = |
| 776 | lm78_read_value(client, LM78_REG_TEMP_OVER); |
| 777 | data->temp_hyst = |
| 778 | lm78_read_value(client, LM78_REG_TEMP_HYST); |
| 779 | i = lm78_read_value(client, LM78_REG_VID_FANDIV); |
| 780 | data->vid = i & 0x0f; |
| 781 | if (data->type == lm79) |
| 782 | data->vid |= |
| 783 | (lm78_read_value(client, LM78_REG_CHIPID) & |
| 784 | 0x01) << 4; |
| 785 | else |
| 786 | data->vid |= 0x10; |
| 787 | data->fan_div[0] = (i >> 4) & 0x03; |
| 788 | data->fan_div[1] = i >> 6; |
| 789 | data->alarms = lm78_read_value(client, LM78_REG_ALARM1) + |
| 790 | (lm78_read_value(client, LM78_REG_ALARM2) << 8); |
| 791 | data->last_updated = jiffies; |
| 792 | data->valid = 1; |
| 793 | |
| 794 | data->fan_div[2] = 1; |
| 795 | } |
| 796 | |
| 797 | up(&data->update_lock); |
| 798 | |
| 799 | return data; |
| 800 | } |
| 801 | |
| 802 | static int __init sm_lm78_init(void) |
| 803 | { |
Jean Delvare | fde0950 | 2005-07-19 23:51:07 +0200 | [diff] [blame] | 804 | int res; |
| 805 | |
| 806 | res = i2c_add_driver(&lm78_driver); |
| 807 | if (res) |
| 808 | return res; |
| 809 | |
| 810 | res = i2c_isa_add_driver(&lm78_isa_driver); |
| 811 | if (res) { |
| 812 | i2c_del_driver(&lm78_driver); |
| 813 | return res; |
| 814 | } |
| 815 | |
| 816 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | static void __exit sm_lm78_exit(void) |
| 820 | { |
Jean Delvare | fde0950 | 2005-07-19 23:51:07 +0200 | [diff] [blame] | 821 | i2c_isa_del_driver(&lm78_isa_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | i2c_del_driver(&lm78_driver); |
| 823 | } |
| 824 | |
| 825 | |
| 826 | |
| 827 | MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"); |
Jean Delvare | 27fe048 | 2005-07-27 21:30:16 +0200 | [diff] [blame] | 828 | MODULE_DESCRIPTION("LM78/LM79 driver"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | MODULE_LICENSE("GPL"); |
| 830 | |
| 831 | module_init(sm_lm78_init); |
| 832 | module_exit(sm_lm78_exit); |