Blame view
drivers/hwmon/f71805f.c
48.1 KB
e53004e20 [PATCH] hwmon: Ne... |
1 |
/* |
51c997d80 hwmon/f71805f: Ad... |
2 3 |
* f71805f.c - driver for the Fintek F71805F/FG and F71872F/FG Super-I/O * chips integrated hardware monitoring features |
7c81c60f3 Update Jean Delva... |
4 |
* Copyright (C) 2005-2006 Jean Delvare <jdelvare@suse.de> |
e53004e20 [PATCH] hwmon: Ne... |
5 6 7 8 9 |
* * The F71805F/FG is a LPC Super-I/O chip made by Fintek. It integrates * complete hardware monitoring features: voltage, fan and temperature * sensors, and manual and automatic fan speed control. * |
51c997d80 hwmon/f71805f: Ad... |
10 11 12 |
* The F71872F/FG is almost the same, with two more voltages monitored, * and 6 VID inputs. * |
9cab0217f hwmon: (f71805f) ... |
13 14 15 |
* The F71806F/FG is essentially the same as the F71872F/FG. It even has * the same chip ID, so the driver can't differentiate between. * |
e53004e20 [PATCH] hwmon: Ne... |
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
e54c5ad61 hwmon: (f71805f) ... |
30 |
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
e53004e20 [PATCH] hwmon: Ne... |
31 32 33 34 35 36 37 38 |
#include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> #include <linux/jiffies.h> #include <linux/platform_device.h> #include <linux/hwmon.h> #include <linux/hwmon-sysfs.h> #include <linux/err.h> |
f08191849 [PATCH] hwmon: f7... |
39 |
#include <linux/mutex.h> |
0e39e01c9 hwmon: Fix unchec... |
40 |
#include <linux/sysfs.h> |
ce7ee4e80 hwmon: Request th... |
41 |
#include <linux/ioport.h> |
b9acb64a3 hwmon: Check for ... |
42 |
#include <linux/acpi.h> |
6055fae8a hwmon: Include <l... |
43 |
#include <linux/io.h> |
e53004e20 [PATCH] hwmon: Ne... |
44 |
|
67b671bce hwmon: Let the us... |
45 46 47 |
static unsigned short force_id; module_param(force_id, ushort, 0); MODULE_PARM_DESC(force_id, "Override the detected device ID"); |
e53004e20 [PATCH] hwmon: Ne... |
48 49 50 |
static struct platform_device *pdev; #define DRVNAME "f71805f" |
51c997d80 hwmon/f71805f: Ad... |
51 |
enum kinds { f71805f, f71872f }; |
e53004e20 [PATCH] hwmon: Ne... |
52 53 54 55 56 57 58 59 60 61 62 |
/* * Super-I/O constants and functions */ #define F71805F_LD_HWM 0x04 #define SIO_REG_LDSEL 0x07 /* Logical device select */ #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ #define SIO_REG_DEVREV 0x22 /* Device revision */ #define SIO_REG_MANID 0x23 /* Fintek ID (2 bytes) */ |
51c997d80 hwmon/f71805f: Ad... |
63 |
#define SIO_REG_FNSEL1 0x29 /* Multi Function Select 1 (F71872F) */ |
e53004e20 [PATCH] hwmon: Ne... |
64 65 66 67 68 |
#define SIO_REG_ENABLE 0x30 /* Logical device enable */ #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ #define SIO_FINTEK_ID 0x1934 #define SIO_F71805F_ID 0x0406 |
51c997d80 hwmon/f71805f: Ad... |
69 |
#define SIO_F71872F_ID 0x0341 |
e53004e20 [PATCH] hwmon: Ne... |
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
static inline int superio_inb(int base, int reg) { outb(reg, base); return inb(base + 1); } static int superio_inw(int base, int reg) { int val; outb(reg++, base); val = inb(base + 1) << 8; outb(reg, base); val |= inb(base + 1); return val; } static inline void superio_select(int base, int ld) { outb(SIO_REG_LDSEL, base); outb(ld, base + 1); } static inline void superio_enter(int base) { outb(0x87, base); outb(0x87, base); } static inline void superio_exit(int base) { outb(0xaa, base); } /* * ISA constants */ |
75c990291 hwmon/f71805f: Fi... |
112 113 114 |
#define REGION_LENGTH 8 #define ADDR_REG_OFFSET 5 #define DATA_REG_OFFSET 6 |
e53004e20 [PATCH] hwmon: Ne... |
115 |
|
e53004e20 [PATCH] hwmon: Ne... |
116 117 118 |
/* * Registers */ |
51c997d80 hwmon/f71805f: Ad... |
119 |
/* in nr from 0 to 10 (8-bit values) */ |
e53004e20 [PATCH] hwmon: Ne... |
120 |
#define F71805F_REG_IN(nr) (0x10 + (nr)) |
51c997d80 hwmon/f71805f: Ad... |
121 122 |
#define F71805F_REG_IN_HIGH(nr) ((nr) < 10 ? 0x40 + 2 * (nr) : 0x2E) #define F71805F_REG_IN_LOW(nr) ((nr) < 10 ? 0x41 + 2 * (nr) : 0x2F) |
e53004e20 [PATCH] hwmon: Ne... |
123 124 125 |
/* fan nr from 0 to 2 (12-bit values, two registers) */ #define F71805F_REG_FAN(nr) (0x20 + 2 * (nr)) #define F71805F_REG_FAN_LOW(nr) (0x28 + 2 * (nr)) |
315c7113b hwmon/f71805f: Ad... |
126 |
#define F71805F_REG_FAN_TARGET(nr) (0x69 + 16 * (nr)) |
e53004e20 [PATCH] hwmon: Ne... |
127 |
#define F71805F_REG_FAN_CTRL(nr) (0x60 + 16 * (nr)) |
6e2bc17b0 hwmon/f71805f: Le... |
128 |
#define F71805F_REG_PWM_FREQ(nr) (0x63 + 16 * (nr)) |
95e353127 hwmon/f71805f: Ad... |
129 |
#define F71805F_REG_PWM_DUTY(nr) (0x6B + 16 * (nr)) |
e53004e20 [PATCH] hwmon: Ne... |
130 131 132 133 134 |
/* temp nr from 0 to 2 (8-bit values) */ #define F71805F_REG_TEMP(nr) (0x1B + (nr)) #define F71805F_REG_TEMP_HIGH(nr) (0x54 + 2 * (nr)) #define F71805F_REG_TEMP_HYST(nr) (0x55 + 2 * (nr)) #define F71805F_REG_TEMP_MODE 0x01 |
aba5073d3 hwmon/f71805f: Ad... |
135 136 137 138 139 140 141 |
/* pwm/fan pwmnr from 0 to 2, auto point apnr from 0 to 2 */ /* map Fintek numbers to our numbers as follows: 9->0, 5->1, 1->2 */ #define F71805F_REG_PWM_AUTO_POINT_TEMP(pwmnr, apnr) \ (0xA0 + 0x10 * (pwmnr) + (2 - (apnr))) #define F71805F_REG_PWM_AUTO_POINT_FAN(pwmnr, apnr) \ (0xA4 + 0x10 * (pwmnr) + \ 2 * (2 - (apnr))) |
e53004e20 [PATCH] hwmon: Ne... |
142 143 144 145 |
#define F71805F_REG_START 0x00 /* status nr from 0 to 2 */ #define F71805F_REG_STATUS(nr) (0x36 + (nr)) |
6b14a546a hwmon/f71805f: St... |
146 |
/* individual register bits */ |
e196783d5 hwmon/f71805f: Su... |
147 |
#define FAN_CTRL_DC_MODE 0x10 |
315c7113b hwmon/f71805f: Ad... |
148 |
#define FAN_CTRL_LATCH_FULL 0x08 |
95e353127 hwmon/f71805f: Ad... |
149 150 151 152 |
#define FAN_CTRL_MODE_MASK 0x03 #define FAN_CTRL_MODE_SPEED 0x00 #define FAN_CTRL_MODE_TEMPERATURE 0x01 #define FAN_CTRL_MODE_MANUAL 0x02 |
6b14a546a hwmon/f71805f: St... |
153 |
|
e53004e20 [PATCH] hwmon: Ne... |
154 155 156 |
/* * Data structures and manipulation thereof */ |
aba5073d3 hwmon/f71805f: Ad... |
157 158 159 160 |
struct f71805f_auto_point { u8 temp[3]; u16 fan[3]; }; |
e53004e20 [PATCH] hwmon: Ne... |
161 162 163 |
struct f71805f_data { unsigned short addr; const char *name; |
1beeffe43 hwmon: Convert fr... |
164 |
struct device *hwmon_dev; |
e53004e20 [PATCH] hwmon: Ne... |
165 |
|
f08191849 [PATCH] hwmon: f7... |
166 |
struct mutex update_lock; |
e53004e20 [PATCH] hwmon: Ne... |
167 168 169 170 171 |
char valid; /* !=0 if following fields are valid */ unsigned long last_updated; /* In jiffies */ unsigned long last_limits; /* In jiffies */ /* Register values */ |
51c997d80 hwmon/f71805f: Ad... |
172 173 174 175 |
u8 in[11]; u8 in_high[11]; u8 in_low[11]; u16 has_in; |
e53004e20 [PATCH] hwmon: Ne... |
176 177 |
u16 fan[3]; u16 fan_low[3]; |
315c7113b hwmon/f71805f: Ad... |
178 |
u16 fan_target[3]; |
6b14a546a hwmon/f71805f: St... |
179 |
u8 fan_ctrl[3]; |
95e353127 hwmon/f71805f: Ad... |
180 |
u8 pwm[3]; |
6e2bc17b0 hwmon/f71805f: Le... |
181 |
u8 pwm_freq[3]; |
e53004e20 [PATCH] hwmon: Ne... |
182 183 184 185 |
u8 temp[3]; u8 temp_high[3]; u8 temp_hyst[3]; u8 temp_mode; |
2d45771e6 hwmon: Add indivi... |
186 |
unsigned long alarms; |
aba5073d3 hwmon/f71805f: Ad... |
187 |
struct f71805f_auto_point auto_points[3]; |
e53004e20 [PATCH] hwmon: Ne... |
188 |
}; |
51c997d80 hwmon/f71805f: Ad... |
189 190 191 192 |
struct f71805f_sio_data { enum kinds kind; u8 fnsel1; }; |
e53004e20 [PATCH] hwmon: Ne... |
193 194 |
static inline long in_from_reg(u8 reg) { |
7fe83ad87 hwmon: remove () ... |
195 |
return reg * 8; |
e53004e20 [PATCH] hwmon: Ne... |
196 197 198 199 200 201 202 203 204 |
} /* The 2 least significant bits are not used */ static inline u8 in_to_reg(long val) { if (val <= 0) return 0; if (val >= 2016) return 0xfc; |
7fe83ad87 hwmon: remove () ... |
205 |
return ((val + 16) / 32) << 2; |
e53004e20 [PATCH] hwmon: Ne... |
206 207 208 209 210 |
} /* in0 is downscaled by a factor 2 internally */ static inline long in0_from_reg(u8 reg) { |
7fe83ad87 hwmon: remove () ... |
211 |
return reg * 16; |
e53004e20 [PATCH] hwmon: Ne... |
212 213 214 215 216 217 218 219 |
} static inline u8 in0_to_reg(long val) { if (val <= 0) return 0; if (val >= 4032) return 0xfc; |
7fe83ad87 hwmon: remove () ... |
220 |
return ((val + 32) / 64) << 2; |
e53004e20 [PATCH] hwmon: Ne... |
221 222 223 224 225 226 227 228 |
} /* The 4 most significant bits are not used */ static inline long fan_from_reg(u16 reg) { reg &= 0xfff; if (!reg || reg == 0xfff) return 0; |
7fe83ad87 hwmon: remove () ... |
229 |
return 1500000 / reg; |
e53004e20 [PATCH] hwmon: Ne... |
230 231 232 233 |
} static inline u16 fan_to_reg(long rpm) { |
2fff0840c hwmon: (f71805f) ... |
234 235 236 237 238 |
/* * If the low limit is set below what the chip can measure, * store the largest possible 12-bit value in the registers, * so that no alarm will ever trigger. */ |
e53004e20 [PATCH] hwmon: Ne... |
239 240 |
if (rpm < 367) return 0xfff; |
7fe83ad87 hwmon: remove () ... |
241 |
return 1500000 / rpm; |
e53004e20 [PATCH] hwmon: Ne... |
242 |
} |
6e2bc17b0 hwmon/f71805f: Le... |
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
static inline unsigned long pwm_freq_from_reg(u8 reg) { unsigned long clock = (reg & 0x80) ? 48000000UL : 1000000UL; reg &= 0x7f; if (reg == 0) reg++; return clock / (reg << 8); } static inline u8 pwm_freq_to_reg(unsigned long val) { if (val >= 187500) /* The highest we can do */ return 0x80; if (val >= 1475) /* Use 48 MHz clock */ return 0x80 | (48000000UL / (val << 8)); if (val < 31) /* The lowest we can do */ return 0x7f; else /* Use 1 MHz clock */ return 1000000UL / (val << 8); } |
e196783d5 hwmon/f71805f: Su... |
264 265 266 267 |
static inline int pwm_mode_from_reg(u8 reg) { return !(reg & FAN_CTRL_DC_MODE); } |
e53004e20 [PATCH] hwmon: Ne... |
268 269 |
static inline long temp_from_reg(u8 reg) { |
7fe83ad87 hwmon: remove () ... |
270 |
return reg * 1000; |
e53004e20 [PATCH] hwmon: Ne... |
271 272 273 274 |
} static inline u8 temp_to_reg(long val) { |
86b2bbfdb hwmon: (f71805f) ... |
275 276 277 278 279 |
if (val <= 0) return 0; if (val >= 1000 * 0xff) return 0xff; return (val + 500) / 1000; |
e53004e20 [PATCH] hwmon: Ne... |
280 281 282 283 284 |
} /* * Device I/O access */ |
7f999aa72 hwmon: Simplify t... |
285 |
/* Must be called with data->update_lock held, except during initialization */ |
e53004e20 [PATCH] hwmon: Ne... |
286 287 |
static u8 f71805f_read8(struct f71805f_data *data, u8 reg) { |
e53004e20 [PATCH] hwmon: Ne... |
288 |
outb(reg, data->addr + ADDR_REG_OFFSET); |
7f999aa72 hwmon: Simplify t... |
289 |
return inb(data->addr + DATA_REG_OFFSET); |
e53004e20 [PATCH] hwmon: Ne... |
290 |
} |
7f999aa72 hwmon: Simplify t... |
291 |
/* Must be called with data->update_lock held, except during initialization */ |
e53004e20 [PATCH] hwmon: Ne... |
292 293 |
static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) { |
e53004e20 [PATCH] hwmon: Ne... |
294 295 |
outb(reg, data->addr + ADDR_REG_OFFSET); outb(val, data->addr + DATA_REG_OFFSET); |
e53004e20 [PATCH] hwmon: Ne... |
296 |
} |
2fff0840c hwmon: (f71805f) ... |
297 298 299 300 301 |
/* * It is important to read the MSB first, because doing so latches the * value of the LSB, so we are sure both bytes belong to the same value. * Must be called with data->update_lock held, except during initialization */ |
e53004e20 [PATCH] hwmon: Ne... |
302 303 304 |
static u16 f71805f_read16(struct f71805f_data *data, u8 reg) { u16 val; |
e53004e20 [PATCH] hwmon: Ne... |
305 306 307 308 |
outb(reg, data->addr + ADDR_REG_OFFSET); val = inb(data->addr + DATA_REG_OFFSET) << 8; outb(++reg, data->addr + ADDR_REG_OFFSET); val |= inb(data->addr + DATA_REG_OFFSET); |
e53004e20 [PATCH] hwmon: Ne... |
309 310 311 |
return val; } |
7f999aa72 hwmon: Simplify t... |
312 |
/* Must be called with data->update_lock held, except during initialization */ |
e53004e20 [PATCH] hwmon: Ne... |
313 314 |
static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) { |
e53004e20 [PATCH] hwmon: Ne... |
315 316 317 318 |
outb(reg, data->addr + ADDR_REG_OFFSET); outb(val >> 8, data->addr + DATA_REG_OFFSET); outb(++reg, data->addr + ADDR_REG_OFFSET); outb(val & 0xff, data->addr + DATA_REG_OFFSET); |
e53004e20 [PATCH] hwmon: Ne... |
319 320 321 322 323 |
} static struct f71805f_data *f71805f_update_device(struct device *dev) { struct f71805f_data *data = dev_get_drvdata(dev); |
aba5073d3 hwmon/f71805f: Ad... |
324 |
int nr, apnr; |
e53004e20 [PATCH] hwmon: Ne... |
325 |
|
f08191849 [PATCH] hwmon: f7... |
326 |
mutex_lock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
327 328 329 330 |
/* Limit registers cache is refreshed after 60 seconds */ if (time_after(jiffies, data->last_updated + 60 * HZ) || !data->valid) { |
51c997d80 hwmon/f71805f: Ad... |
331 332 333 |
for (nr = 0; nr < 11; nr++) { if (!(data->has_in & (1 << nr))) continue; |
e53004e20 [PATCH] hwmon: Ne... |
334 335 336 337 338 339 |
data->in_high[nr] = f71805f_read8(data, F71805F_REG_IN_HIGH(nr)); data->in_low[nr] = f71805f_read8(data, F71805F_REG_IN_LOW(nr)); } for (nr = 0; nr < 3; nr++) { |
6b14a546a hwmon/f71805f: St... |
340 341 |
data->fan_low[nr] = f71805f_read16(data, F71805F_REG_FAN_LOW(nr)); |
315c7113b hwmon/f71805f: Ad... |
342 343 |
data->fan_target[nr] = f71805f_read16(data, F71805F_REG_FAN_TARGET(nr)); |
6e2bc17b0 hwmon/f71805f: Le... |
344 345 |
data->pwm_freq[nr] = f71805f_read8(data, F71805F_REG_PWM_FREQ(nr)); |
e53004e20 [PATCH] hwmon: Ne... |
346 347 348 349 350 351 352 353 |
} for (nr = 0; nr < 3; nr++) { data->temp_high[nr] = f71805f_read8(data, F71805F_REG_TEMP_HIGH(nr)); data->temp_hyst[nr] = f71805f_read8(data, F71805F_REG_TEMP_HYST(nr)); } data->temp_mode = f71805f_read8(data, F71805F_REG_TEMP_MODE); |
aba5073d3 hwmon/f71805f: Ad... |
354 355 356 357 358 359 360 361 362 363 364 365 |
for (nr = 0; nr < 3; nr++) { for (apnr = 0; apnr < 3; apnr++) { data->auto_points[nr].temp[apnr] = f71805f_read8(data, F71805F_REG_PWM_AUTO_POINT_TEMP(nr, apnr)); data->auto_points[nr].fan[apnr] = f71805f_read16(data, F71805F_REG_PWM_AUTO_POINT_FAN(nr, apnr)); } } |
e53004e20 [PATCH] hwmon: Ne... |
366 367 368 369 370 371 372 |
data->last_limits = jiffies; } /* Measurement registers cache is refreshed after 1 second */ if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { |
51c997d80 hwmon/f71805f: Ad... |
373 374 375 |
for (nr = 0; nr < 11; nr++) { if (!(data->has_in & (1 << nr))) continue; |
e53004e20 [PATCH] hwmon: Ne... |
376 377 378 379 |
data->in[nr] = f71805f_read8(data, F71805F_REG_IN(nr)); } for (nr = 0; nr < 3; nr++) { |
6b14a546a hwmon/f71805f: St... |
380 381 |
data->fan[nr] = f71805f_read16(data, F71805F_REG_FAN(nr)); |
95e353127 hwmon/f71805f: Ad... |
382 383 384 385 |
data->fan_ctrl[nr] = f71805f_read8(data, F71805F_REG_FAN_CTRL(nr)); data->pwm[nr] = f71805f_read8(data, F71805F_REG_PWM_DUTY(nr)); |
e53004e20 [PATCH] hwmon: Ne... |
386 387 388 389 390 |
} for (nr = 0; nr < 3; nr++) { data->temp[nr] = f71805f_read8(data, F71805F_REG_TEMP(nr)); } |
2d45771e6 hwmon: Add indivi... |
391 392 393 |
data->alarms = f71805f_read8(data, F71805F_REG_STATUS(0)) + (f71805f_read8(data, F71805F_REG_STATUS(1)) << 8) + (f71805f_read8(data, F71805F_REG_STATUS(2)) << 16); |
e53004e20 [PATCH] hwmon: Ne... |
394 395 396 397 |
data->last_updated = jiffies; data->valid = 1; } |
f08191849 [PATCH] hwmon: f7... |
398 |
mutex_unlock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
399 400 401 402 403 404 405 406 407 408 409 410 |
return data; } /* * Sysfs interface */ static ssize_t show_in0(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); |
51c997d80 hwmon/f71805f: Ad... |
411 412 |
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
e53004e20 [PATCH] hwmon: Ne... |
413 |
|
51c997d80 hwmon/f71805f: Ad... |
414 415 |
return sprintf(buf, "%ld ", in0_from_reg(data->in[nr])); |
e53004e20 [PATCH] hwmon: Ne... |
416 417 418 419 420 421 |
} static ssize_t show_in0_max(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); |
51c997d80 hwmon/f71805f: Ad... |
422 423 |
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
e53004e20 [PATCH] hwmon: Ne... |
424 |
|
51c997d80 hwmon/f71805f: Ad... |
425 426 |
return sprintf(buf, "%ld ", in0_from_reg(data->in_high[nr])); |
e53004e20 [PATCH] hwmon: Ne... |
427 428 429 430 431 432 |
} static ssize_t show_in0_min(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); |
51c997d80 hwmon/f71805f: Ad... |
433 434 |
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
e53004e20 [PATCH] hwmon: Ne... |
435 |
|
51c997d80 hwmon/f71805f: Ad... |
436 437 |
return sprintf(buf, "%ld ", in0_from_reg(data->in_low[nr])); |
e53004e20 [PATCH] hwmon: Ne... |
438 439 440 441 442 443 |
} static ssize_t set_in0_max(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); |
51c997d80 hwmon/f71805f: Ad... |
444 445 |
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
446 447 448 449 450 451 |
long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; |
e53004e20 [PATCH] hwmon: Ne... |
452 |
|
f08191849 [PATCH] hwmon: f7... |
453 |
mutex_lock(&data->update_lock); |
51c997d80 hwmon/f71805f: Ad... |
454 455 |
data->in_high[nr] = in0_to_reg(val); f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); |
f08191849 [PATCH] hwmon: f7... |
456 |
mutex_unlock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
457 458 459 460 461 462 463 464 |
return count; } static ssize_t set_in0_min(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); |
51c997d80 hwmon/f71805f: Ad... |
465 466 |
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
467 468 469 470 471 472 |
long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; |
e53004e20 [PATCH] hwmon: Ne... |
473 |
|
f08191849 [PATCH] hwmon: f7... |
474 |
mutex_lock(&data->update_lock); |
51c997d80 hwmon/f71805f: Ad... |
475 476 |
data->in_low[nr] = in0_to_reg(val); f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); |
f08191849 [PATCH] hwmon: f7... |
477 |
mutex_unlock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
478 479 480 |
return count; } |
e53004e20 [PATCH] hwmon: Ne... |
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
static ssize_t show_in(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%ld ", in_from_reg(data->in[nr])); } static ssize_t show_in_max(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%ld ", in_from_reg(data->in_high[nr])); } static ssize_t show_in_min(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%ld ", in_from_reg(data->in_low[nr])); } static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
520 521 522 523 524 525 |
long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; |
e53004e20 [PATCH] hwmon: Ne... |
526 |
|
f08191849 [PATCH] hwmon: f7... |
527 |
mutex_lock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
528 529 |
data->in_high[nr] = in_to_reg(val); f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); |
f08191849 [PATCH] hwmon: f7... |
530 |
mutex_unlock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
531 532 533 534 535 536 537 538 539 540 |
return count; } static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
541 542 543 544 545 546 |
long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; |
e53004e20 [PATCH] hwmon: Ne... |
547 |
|
f08191849 [PATCH] hwmon: f7... |
548 |
mutex_lock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
549 550 |
data->in_low[nr] = in_to_reg(val); f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); |
f08191849 [PATCH] hwmon: f7... |
551 |
mutex_unlock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
552 553 554 |
return count; } |
e53004e20 [PATCH] hwmon: Ne... |
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%ld ", fan_from_reg(data->fan[nr])); } static ssize_t show_fan_min(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%ld ", fan_from_reg(data->fan_low[nr])); } |
315c7113b hwmon/f71805f: Ad... |
576 577 578 579 580 581 582 583 584 585 |
static ssize_t show_fan_target(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%ld ", fan_from_reg(data->fan_target[nr])); } |
e53004e20 [PATCH] hwmon: Ne... |
586 587 588 589 590 591 |
static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
592 593 594 595 596 597 |
long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; |
e53004e20 [PATCH] hwmon: Ne... |
598 |
|
f08191849 [PATCH] hwmon: f7... |
599 |
mutex_lock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
600 601 |
data->fan_low[nr] = fan_to_reg(val); f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]); |
f08191849 [PATCH] hwmon: f7... |
602 |
mutex_unlock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
603 604 605 |
return count; } |
315c7113b hwmon/f71805f: Ad... |
606 607 608 609 610 611 |
static ssize_t set_fan_target(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
612 613 614 615 616 617 |
long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; |
315c7113b hwmon/f71805f: Ad... |
618 619 620 621 622 623 624 625 626 |
mutex_lock(&data->update_lock); data->fan_target[nr] = fan_to_reg(val); f71805f_write16(data, F71805F_REG_FAN_TARGET(nr), data->fan_target[nr]); mutex_unlock(&data->update_lock); return count; } |
95e353127 hwmon/f71805f: Ad... |
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%d ", (int)data->pwm[nr]); } static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; int mode; switch (data->fan_ctrl[nr] & FAN_CTRL_MODE_MASK) { case FAN_CTRL_MODE_SPEED: mode = 3; break; case FAN_CTRL_MODE_TEMPERATURE: mode = 2; break; default: /* MANUAL */ mode = 1; } return sprintf(buf, "%d ", mode); } |
6e2bc17b0 hwmon/f71805f: Le... |
660 661 662 663 664 665 666 667 668 669 |
static ssize_t show_pwm_freq(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%lu ", pwm_freq_from_reg(data->pwm_freq[nr])); } |
e196783d5 hwmon/f71805f: Su... |
670 671 672 673 674 675 676 677 678 679 |
static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%d ", pwm_mode_from_reg(data->fan_ctrl[nr])); } |
95e353127 hwmon/f71805f: Ad... |
680 681 682 683 684 685 |
static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
686 687 688 689 690 691 |
unsigned long val; int err; err = kstrtoul(buf, 10, &val); if (err) return err; |
95e353127 hwmon/f71805f: Ad... |
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 |
if (val > 255) return -EINVAL; mutex_lock(&data->update_lock); data->pwm[nr] = val; f71805f_write8(data, F71805F_REG_PWM_DUTY(nr), data->pwm[nr]); mutex_unlock(&data->update_lock); return count; } static struct attribute *f71805f_attr_pwm[]; static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
95e353127 hwmon/f71805f: Ad... |
712 |
u8 reg; |
2fff0840c hwmon: (f71805f) ... |
713 714 715 716 717 718 |
unsigned long val; int err; err = kstrtoul(buf, 10, &val); if (err) return err; |
95e353127 hwmon/f71805f: Ad... |
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
if (val < 1 || val > 3) return -EINVAL; if (val > 1) { /* Automatic mode, user can't set PWM value */ if (sysfs_chmod_file(&dev->kobj, f71805f_attr_pwm[nr], S_IRUGO)) dev_dbg(dev, "chmod -w pwm%d failed ", nr + 1); } mutex_lock(&data->update_lock); reg = f71805f_read8(data, F71805F_REG_FAN_CTRL(nr)) & ~FAN_CTRL_MODE_MASK; switch (val) { case 1: reg |= FAN_CTRL_MODE_MANUAL; break; case 2: reg |= FAN_CTRL_MODE_TEMPERATURE; break; case 3: reg |= FAN_CTRL_MODE_SPEED; break; } data->fan_ctrl[nr] = reg; f71805f_write8(data, F71805F_REG_FAN_CTRL(nr), reg); mutex_unlock(&data->update_lock); if (val == 1) { /* Manual mode, user can set PWM value */ if (sysfs_chmod_file(&dev->kobj, f71805f_attr_pwm[nr], S_IRUGO | S_IWUSR)) dev_dbg(dev, "chmod +w pwm%d failed ", nr + 1); } return count; } |
6e2bc17b0 hwmon/f71805f: Le... |
757 758 759 760 761 762 |
static ssize_t set_pwm_freq(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
763 764 765 766 767 768 |
unsigned long val; int err; err = kstrtoul(buf, 10, &val); if (err) return err; |
6e2bc17b0 hwmon/f71805f: Le... |
769 770 771 772 773 774 775 776 |
mutex_lock(&data->update_lock); data->pwm_freq[nr] = pwm_freq_to_reg(val); f71805f_write8(data, F71805F_REG_PWM_FREQ(nr), data->pwm_freq[nr]); mutex_unlock(&data->update_lock); return count; } |
aba5073d3 hwmon/f71805f: Ad... |
777 778 |
static ssize_t show_pwm_auto_point_temp(struct device *dev, struct device_attribute *devattr, |
2fff0840c hwmon: (f71805f) ... |
779 |
char *buf) |
aba5073d3 hwmon/f71805f: Ad... |
780 781 782 783 784 785 786 787 788 789 790 791 792 |
{ struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); int pwmnr = attr->nr; int apnr = attr->index; return sprintf(buf, "%ld ", temp_from_reg(data->auto_points[pwmnr].temp[apnr])); } static ssize_t set_pwm_auto_point_temp(struct device *dev, struct device_attribute *devattr, |
2fff0840c hwmon: (f71805f) ... |
793 |
const char *buf, size_t count) |
aba5073d3 hwmon/f71805f: Ad... |
794 795 796 797 798 |
{ struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); int pwmnr = attr->nr; int apnr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
799 800 801 802 803 804 |
unsigned long val; int err; err = kstrtoul(buf, 10, &val); if (err) return err; |
aba5073d3 hwmon/f71805f: Ad... |
805 806 807 808 809 810 811 812 813 814 815 816 |
mutex_lock(&data->update_lock); data->auto_points[pwmnr].temp[apnr] = temp_to_reg(val); f71805f_write8(data, F71805F_REG_PWM_AUTO_POINT_TEMP(pwmnr, apnr), data->auto_points[pwmnr].temp[apnr]); mutex_unlock(&data->update_lock); return count; } static ssize_t show_pwm_auto_point_fan(struct device *dev, struct device_attribute *devattr, |
2fff0840c hwmon: (f71805f) ... |
817 |
char *buf) |
aba5073d3 hwmon/f71805f: Ad... |
818 819 820 821 822 823 824 825 826 827 828 829 830 |
{ struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); int pwmnr = attr->nr; int apnr = attr->index; return sprintf(buf, "%ld ", fan_from_reg(data->auto_points[pwmnr].fan[apnr])); } static ssize_t set_pwm_auto_point_fan(struct device *dev, struct device_attribute *devattr, |
2fff0840c hwmon: (f71805f) ... |
831 |
const char *buf, size_t count) |
aba5073d3 hwmon/f71805f: Ad... |
832 833 834 835 836 |
{ struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); int pwmnr = attr->nr; int apnr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
837 838 839 840 841 842 |
unsigned long val; int err; err = kstrtoul(buf, 10, &val); if (err) return err; |
aba5073d3 hwmon/f71805f: Ad... |
843 844 845 846 |
mutex_lock(&data->update_lock); data->auto_points[pwmnr].fan[apnr] = fan_to_reg(val); f71805f_write16(data, F71805F_REG_PWM_AUTO_POINT_FAN(pwmnr, apnr), |
2fff0840c hwmon: (f71805f) ... |
847 |
data->auto_points[pwmnr].fan[apnr]); |
aba5073d3 hwmon/f71805f: Ad... |
848 849 850 851 |
mutex_unlock(&data->update_lock); return count; } |
e53004e20 [PATCH] hwmon: Ne... |
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 |
static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%ld ", temp_from_reg(data->temp[nr])); } static ssize_t show_temp_max(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%ld ", temp_from_reg(data->temp_high[nr])); } static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; return sprintf(buf, "%ld ", temp_from_reg(data->temp_hyst[nr])); } static ssize_t show_temp_type(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; /* 3 is diode, 4 is thermistor */ return sprintf(buf, "%u ", (data->temp_mode & (1 << nr)) ? 3 : 4); } static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
903 904 905 906 907 908 |
long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; |
e53004e20 [PATCH] hwmon: Ne... |
909 |
|
f08191849 [PATCH] hwmon: f7... |
910 |
mutex_lock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
911 912 |
data->temp_high[nr] = temp_to_reg(val); f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]); |
f08191849 [PATCH] hwmon: f7... |
913 |
mutex_unlock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
914 915 916 917 918 919 920 921 922 923 |
return count; } static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int nr = attr->index; |
2fff0840c hwmon: (f71805f) ... |
924 925 926 927 928 929 |
long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; |
e53004e20 [PATCH] hwmon: Ne... |
930 |
|
f08191849 [PATCH] hwmon: f7... |
931 |
mutex_lock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
932 933 |
data->temp_hyst[nr] = temp_to_reg(val); f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]); |
f08191849 [PATCH] hwmon: f7... |
934 |
mutex_unlock(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
935 936 937 |
return count; } |
e53004e20 [PATCH] hwmon: Ne... |
938 939 940 941 |
static ssize_t show_alarms_in(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); |
51c997d80 hwmon/f71805f: Ad... |
942 943 |
return sprintf(buf, "%lu ", data->alarms & 0x7ff); |
e53004e20 [PATCH] hwmon: Ne... |
944 945 946 947 948 949 |
} static ssize_t show_alarms_fan(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); |
2d45771e6 hwmon: Add indivi... |
950 951 |
return sprintf(buf, "%lu ", (data->alarms >> 16) & 0x07); |
e53004e20 [PATCH] hwmon: Ne... |
952 953 954 955 956 957 |
} static ssize_t show_alarms_temp(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); |
2d45771e6 hwmon: Add indivi... |
958 959 960 961 962 963 964 965 966 967 968 969 970 |
return sprintf(buf, "%lu ", (data->alarms >> 11) & 0x07); } static ssize_t show_alarm(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); int bitnr = attr->index; return sprintf(buf, "%lu ", (data->alarms >> bitnr) & 1); |
e53004e20 [PATCH] hwmon: Ne... |
971 |
} |
e53004e20 [PATCH] hwmon: Ne... |
972 973 974 975 976 977 978 979 |
static ssize_t show_name(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = dev_get_drvdata(dev); return sprintf(buf, "%s ", data->name); } |
51c997d80 hwmon/f71805f: Ad... |
980 |
static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL, 0); |
2fff0840c hwmon: (f71805f) ... |
981 |
static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO | S_IWUSR, |
51c997d80 hwmon/f71805f: Ad... |
982 |
show_in0_max, set_in0_max, 0); |
2fff0840c hwmon: (f71805f) ... |
983 |
static SENSOR_DEVICE_ATTR(in0_min, S_IRUGO | S_IWUSR, |
51c997d80 hwmon/f71805f: Ad... |
984 |
show_in0_min, set_in0_min, 0); |
0e39e01c9 hwmon: Fix unchec... |
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 |
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1); static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR, show_in_max, set_in_max, 1); static SENSOR_DEVICE_ATTR(in1_min, S_IRUGO | S_IWUSR, show_in_min, set_in_min, 1); static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_in, NULL, 2); static SENSOR_DEVICE_ATTR(in2_max, S_IRUGO | S_IWUSR, show_in_max, set_in_max, 2); static SENSOR_DEVICE_ATTR(in2_min, S_IRUGO | S_IWUSR, show_in_min, set_in_min, 2); static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_in, NULL, 3); static SENSOR_DEVICE_ATTR(in3_max, S_IRUGO | S_IWUSR, show_in_max, set_in_max, 3); static SENSOR_DEVICE_ATTR(in3_min, S_IRUGO | S_IWUSR, show_in_min, set_in_min, 3); static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_in, NULL, 4); static SENSOR_DEVICE_ATTR(in4_max, S_IRUGO | S_IWUSR, show_in_max, set_in_max, 4); static SENSOR_DEVICE_ATTR(in4_min, S_IRUGO | S_IWUSR, show_in_min, set_in_min, 4); static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_in, NULL, 5); static SENSOR_DEVICE_ATTR(in5_max, S_IRUGO | S_IWUSR, show_in_max, set_in_max, 5); static SENSOR_DEVICE_ATTR(in5_min, S_IRUGO | S_IWUSR, show_in_min, set_in_min, 5); static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_in, NULL, 6); static SENSOR_DEVICE_ATTR(in6_max, S_IRUGO | S_IWUSR, show_in_max, set_in_max, 6); static SENSOR_DEVICE_ATTR(in6_min, S_IRUGO | S_IWUSR, show_in_min, set_in_min, 6); static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_in, NULL, 7); static SENSOR_DEVICE_ATTR(in7_max, S_IRUGO | S_IWUSR, show_in_max, set_in_max, 7); static SENSOR_DEVICE_ATTR(in7_min, S_IRUGO | S_IWUSR, show_in_min, set_in_min, 7); static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_in, NULL, 8); static SENSOR_DEVICE_ATTR(in8_max, S_IRUGO | S_IWUSR, show_in_max, set_in_max, 8); static SENSOR_DEVICE_ATTR(in8_min, S_IRUGO | S_IWUSR, show_in_min, set_in_min, 8); |
51c997d80 hwmon/f71805f: Ad... |
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 |
static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_in0, NULL, 9); static SENSOR_DEVICE_ATTR(in9_max, S_IRUGO | S_IWUSR, show_in0_max, set_in0_max, 9); static SENSOR_DEVICE_ATTR(in9_min, S_IRUGO | S_IWUSR, show_in0_min, set_in0_min, 9); static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_in0, NULL, 10); static SENSOR_DEVICE_ATTR(in10_max, S_IRUGO | S_IWUSR, show_in0_max, set_in0_max, 10); static SENSOR_DEVICE_ATTR(in10_min, S_IRUGO | S_IWUSR, show_in0_min, set_in0_min, 10); |
0e39e01c9 hwmon: Fix unchec... |
1035 1036 1037 1038 |
static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR, show_fan_min, set_fan_min, 0); |
315c7113b hwmon/f71805f: Ad... |
1039 1040 |
static SENSOR_DEVICE_ATTR(fan1_target, S_IRUGO | S_IWUSR, show_fan_target, set_fan_target, 0); |
0e39e01c9 hwmon: Fix unchec... |
1041 1042 1043 |
static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO | S_IWUSR, show_fan_min, set_fan_min, 1); |
315c7113b hwmon/f71805f: Ad... |
1044 1045 |
static SENSOR_DEVICE_ATTR(fan2_target, S_IRUGO | S_IWUSR, show_fan_target, set_fan_target, 1); |
0e39e01c9 hwmon: Fix unchec... |
1046 1047 1048 |
static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO | S_IWUSR, show_fan_min, set_fan_min, 2); |
315c7113b hwmon/f71805f: Ad... |
1049 1050 |
static SENSOR_DEVICE_ATTR(fan3_target, S_IRUGO | S_IWUSR, show_fan_target, set_fan_target, 2); |
0e39e01c9 hwmon: Fix unchec... |
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 |
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp_max, set_temp_max, 0); static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp_hyst, set_temp_hyst, 0); static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0); static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max, set_temp_max, 1); static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp_hyst, set_temp_hyst, 1); static SENSOR_DEVICE_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1); static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max, set_temp_max, 2); static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_hyst, set_temp_hyst, 2); static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2); |
2fff0840c hwmon: (f71805f) ... |
1070 1071 1072 1073 |
/* * pwm (value) files are created read-only, write permission is * then added or removed dynamically as needed */ |
95e353127 hwmon/f71805f: Ad... |
1074 1075 1076 |
static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO, show_pwm, set_pwm, 0); static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, set_pwm_enable, 0); |
6e2bc17b0 hwmon/f71805f: Le... |
1077 1078 |
static SENSOR_DEVICE_ATTR(pwm1_freq, S_IRUGO | S_IWUSR, show_pwm_freq, set_pwm_freq, 0); |
e196783d5 hwmon/f71805f: Su... |
1079 |
static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); |
95e353127 hwmon/f71805f: Ad... |
1080 1081 1082 |
static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO, show_pwm, set_pwm, 1); static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, show_pwm_enable, set_pwm_enable, 1); |
6e2bc17b0 hwmon/f71805f: Le... |
1083 1084 |
static SENSOR_DEVICE_ATTR(pwm2_freq, S_IRUGO | S_IWUSR, show_pwm_freq, set_pwm_freq, 1); |
e196783d5 hwmon/f71805f: Su... |
1085 |
static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1); |
95e353127 hwmon/f71805f: Ad... |
1086 1087 1088 |
static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO, show_pwm, set_pwm, 2); static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, show_pwm_enable, set_pwm_enable, 2); |
6e2bc17b0 hwmon/f71805f: Le... |
1089 1090 |
static SENSOR_DEVICE_ATTR(pwm3_freq, S_IRUGO | S_IWUSR, show_pwm_freq, set_pwm_freq, 2); |
e196783d5 hwmon/f71805f: Su... |
1091 |
static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2); |
95e353127 hwmon/f71805f: Ad... |
1092 |
|
aba5073d3 hwmon/f71805f: Ad... |
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 |
static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_temp, S_IRUGO | S_IWUSR, show_pwm_auto_point_temp, set_pwm_auto_point_temp, 0, 0); static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_fan, S_IRUGO | S_IWUSR, show_pwm_auto_point_fan, set_pwm_auto_point_fan, 0, 0); static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_temp, S_IRUGO | S_IWUSR, show_pwm_auto_point_temp, set_pwm_auto_point_temp, 0, 1); static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_fan, S_IRUGO | S_IWUSR, show_pwm_auto_point_fan, set_pwm_auto_point_fan, 0, 1); static SENSOR_DEVICE_ATTR_2(pwm1_auto_point3_temp, S_IRUGO | S_IWUSR, show_pwm_auto_point_temp, set_pwm_auto_point_temp, 0, 2); static SENSOR_DEVICE_ATTR_2(pwm1_auto_point3_fan, S_IRUGO | S_IWUSR, show_pwm_auto_point_fan, set_pwm_auto_point_fan, 0, 2); static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_temp, S_IRUGO | S_IWUSR, show_pwm_auto_point_temp, set_pwm_auto_point_temp, 1, 0); static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_fan, S_IRUGO | S_IWUSR, show_pwm_auto_point_fan, set_pwm_auto_point_fan, 1, 0); static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_temp, S_IRUGO | S_IWUSR, show_pwm_auto_point_temp, set_pwm_auto_point_temp, 1, 1); static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_fan, S_IRUGO | S_IWUSR, show_pwm_auto_point_fan, set_pwm_auto_point_fan, 1, 1); static SENSOR_DEVICE_ATTR_2(pwm2_auto_point3_temp, S_IRUGO | S_IWUSR, show_pwm_auto_point_temp, set_pwm_auto_point_temp, 1, 2); static SENSOR_DEVICE_ATTR_2(pwm2_auto_point3_fan, S_IRUGO | S_IWUSR, show_pwm_auto_point_fan, set_pwm_auto_point_fan, 1, 2); static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_temp, S_IRUGO | S_IWUSR, show_pwm_auto_point_temp, set_pwm_auto_point_temp, 2, 0); static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_fan, S_IRUGO | S_IWUSR, show_pwm_auto_point_fan, set_pwm_auto_point_fan, 2, 0); static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_temp, S_IRUGO | S_IWUSR, show_pwm_auto_point_temp, set_pwm_auto_point_temp, 2, 1); static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_fan, S_IRUGO | S_IWUSR, show_pwm_auto_point_fan, set_pwm_auto_point_fan, 2, 1); static SENSOR_DEVICE_ATTR_2(pwm3_auto_point3_temp, S_IRUGO | S_IWUSR, show_pwm_auto_point_temp, set_pwm_auto_point_temp, 2, 2); static SENSOR_DEVICE_ATTR_2(pwm3_auto_point3_fan, S_IRUGO | S_IWUSR, show_pwm_auto_point_fan, set_pwm_auto_point_fan, 2, 2); |
0e39e01c9 hwmon: Fix unchec... |
1149 1150 1151 1152 1153 1154 1155 1156 1157 |
static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 4); static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 5); static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6); static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7); static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 8); |
51c997d80 hwmon/f71805f: Ad... |
1158 1159 |
static SENSOR_DEVICE_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, 9); static SENSOR_DEVICE_ATTR(in10_alarm, S_IRUGO, show_alarm, NULL, 10); |
0e39e01c9 hwmon: Fix unchec... |
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 |
static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 11); static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 12); static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13); static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 16); static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 17); static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 18); static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL); static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL); static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL); static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); static struct attribute *f71805f_attributes[] = { |
51c997d80 hwmon/f71805f: Ad... |
1173 1174 1175 |
&sensor_dev_attr_in0_input.dev_attr.attr, &sensor_dev_attr_in0_max.dev_attr.attr, &sensor_dev_attr_in0_min.dev_attr.attr, |
0e39e01c9 hwmon: Fix unchec... |
1176 1177 1178 1179 1180 1181 1182 1183 1184 |
&sensor_dev_attr_in1_input.dev_attr.attr, &sensor_dev_attr_in1_max.dev_attr.attr, &sensor_dev_attr_in1_min.dev_attr.attr, &sensor_dev_attr_in2_input.dev_attr.attr, &sensor_dev_attr_in2_max.dev_attr.attr, &sensor_dev_attr_in2_min.dev_attr.attr, &sensor_dev_attr_in3_input.dev_attr.attr, &sensor_dev_attr_in3_max.dev_attr.attr, &sensor_dev_attr_in3_min.dev_attr.attr, |
0e39e01c9 hwmon: Fix unchec... |
1185 1186 1187 1188 1189 1190 1191 1192 1193 |
&sensor_dev_attr_in5_input.dev_attr.attr, &sensor_dev_attr_in5_max.dev_attr.attr, &sensor_dev_attr_in5_min.dev_attr.attr, &sensor_dev_attr_in6_input.dev_attr.attr, &sensor_dev_attr_in6_max.dev_attr.attr, &sensor_dev_attr_in6_min.dev_attr.attr, &sensor_dev_attr_in7_input.dev_attr.attr, &sensor_dev_attr_in7_max.dev_attr.attr, &sensor_dev_attr_in7_min.dev_attr.attr, |
0e39e01c9 hwmon: Fix unchec... |
1194 |
|
c7176cb51 hwmon/f71805f: Al... |
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 |
&sensor_dev_attr_fan1_input.dev_attr.attr, &sensor_dev_attr_fan1_min.dev_attr.attr, &sensor_dev_attr_fan1_alarm.dev_attr.attr, &sensor_dev_attr_fan1_target.dev_attr.attr, &sensor_dev_attr_fan2_input.dev_attr.attr, &sensor_dev_attr_fan2_min.dev_attr.attr, &sensor_dev_attr_fan2_alarm.dev_attr.attr, &sensor_dev_attr_fan2_target.dev_attr.attr, &sensor_dev_attr_fan3_input.dev_attr.attr, &sensor_dev_attr_fan3_min.dev_attr.attr, &sensor_dev_attr_fan3_alarm.dev_attr.attr, &sensor_dev_attr_fan3_target.dev_attr.attr, &sensor_dev_attr_pwm1.dev_attr.attr, &sensor_dev_attr_pwm1_enable.dev_attr.attr, &sensor_dev_attr_pwm1_mode.dev_attr.attr, &sensor_dev_attr_pwm2.dev_attr.attr, &sensor_dev_attr_pwm2_enable.dev_attr.attr, &sensor_dev_attr_pwm2_mode.dev_attr.attr, &sensor_dev_attr_pwm3.dev_attr.attr, &sensor_dev_attr_pwm3_enable.dev_attr.attr, &sensor_dev_attr_pwm3_mode.dev_attr.attr, |
0e39e01c9 hwmon: Fix unchec... |
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 |
&sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr, &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, &sensor_dev_attr_temp1_type.dev_attr.attr, &sensor_dev_attr_temp2_input.dev_attr.attr, &sensor_dev_attr_temp2_max.dev_attr.attr, &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, &sensor_dev_attr_temp2_type.dev_attr.attr, &sensor_dev_attr_temp3_input.dev_attr.attr, &sensor_dev_attr_temp3_max.dev_attr.attr, &sensor_dev_attr_temp3_max_hyst.dev_attr.attr, &sensor_dev_attr_temp3_type.dev_attr.attr, |
aba5073d3 hwmon/f71805f: Ad... |
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 |
&sensor_dev_attr_pwm1_auto_point1_temp.dev_attr.attr, &sensor_dev_attr_pwm1_auto_point1_fan.dev_attr.attr, &sensor_dev_attr_pwm1_auto_point2_temp.dev_attr.attr, &sensor_dev_attr_pwm1_auto_point2_fan.dev_attr.attr, &sensor_dev_attr_pwm1_auto_point3_temp.dev_attr.attr, &sensor_dev_attr_pwm1_auto_point3_fan.dev_attr.attr, &sensor_dev_attr_pwm2_auto_point1_temp.dev_attr.attr, &sensor_dev_attr_pwm2_auto_point1_fan.dev_attr.attr, &sensor_dev_attr_pwm2_auto_point2_temp.dev_attr.attr, &sensor_dev_attr_pwm2_auto_point2_fan.dev_attr.attr, &sensor_dev_attr_pwm2_auto_point3_temp.dev_attr.attr, &sensor_dev_attr_pwm2_auto_point3_fan.dev_attr.attr, &sensor_dev_attr_pwm3_auto_point1_temp.dev_attr.attr, &sensor_dev_attr_pwm3_auto_point1_fan.dev_attr.attr, &sensor_dev_attr_pwm3_auto_point2_temp.dev_attr.attr, &sensor_dev_attr_pwm3_auto_point2_fan.dev_attr.attr, &sensor_dev_attr_pwm3_auto_point3_temp.dev_attr.attr, &sensor_dev_attr_pwm3_auto_point3_fan.dev_attr.attr, |
0e39e01c9 hwmon: Fix unchec... |
1247 1248 1249 1250 |
&sensor_dev_attr_in0_alarm.dev_attr.attr, &sensor_dev_attr_in1_alarm.dev_attr.attr, &sensor_dev_attr_in2_alarm.dev_attr.attr, &sensor_dev_attr_in3_alarm.dev_attr.attr, |
0e39e01c9 hwmon: Fix unchec... |
1251 1252 1253 |
&sensor_dev_attr_in5_alarm.dev_attr.attr, &sensor_dev_attr_in6_alarm.dev_attr.attr, &sensor_dev_attr_in7_alarm.dev_attr.attr, |
0e39e01c9 hwmon: Fix unchec... |
1254 1255 1256 1257 1258 1259 1260 1261 1262 |
&dev_attr_alarms_in.attr, &sensor_dev_attr_temp1_alarm.dev_attr.attr, &sensor_dev_attr_temp2_alarm.dev_attr.attr, &sensor_dev_attr_temp3_alarm.dev_attr.attr, &dev_attr_alarms_temp.attr, &dev_attr_alarms_fan.attr, &dev_attr_name.attr, NULL |
2488a39d2 [PATCH] hwmon: Us... |
1263 |
}; |
0e39e01c9 hwmon: Fix unchec... |
1264 1265 |
static const struct attribute_group f71805f_group = { .attrs = f71805f_attributes, |
2488a39d2 [PATCH] hwmon: Us... |
1266 |
}; |
51c997d80 hwmon/f71805f: Ad... |
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 |
static struct attribute *f71805f_attributes_optin[4][5] = { { &sensor_dev_attr_in4_input.dev_attr.attr, &sensor_dev_attr_in4_max.dev_attr.attr, &sensor_dev_attr_in4_min.dev_attr.attr, &sensor_dev_attr_in4_alarm.dev_attr.attr, NULL }, { &sensor_dev_attr_in8_input.dev_attr.attr, &sensor_dev_attr_in8_max.dev_attr.attr, &sensor_dev_attr_in8_min.dev_attr.attr, &sensor_dev_attr_in8_alarm.dev_attr.attr, NULL }, { &sensor_dev_attr_in9_input.dev_attr.attr, &sensor_dev_attr_in9_max.dev_attr.attr, &sensor_dev_attr_in9_min.dev_attr.attr, &sensor_dev_attr_in9_alarm.dev_attr.attr, NULL }, { &sensor_dev_attr_in10_input.dev_attr.attr, &sensor_dev_attr_in10_max.dev_attr.attr, &sensor_dev_attr_in10_min.dev_attr.attr, &sensor_dev_attr_in10_alarm.dev_attr.attr, NULL } }; static const struct attribute_group f71805f_group_optin[4] = { { .attrs = f71805f_attributes_optin[0] }, { .attrs = f71805f_attributes_optin[1] }, { .attrs = f71805f_attributes_optin[2] }, { .attrs = f71805f_attributes_optin[3] }, }; |
2fff0840c hwmon: (f71805f) ... |
1301 1302 1303 1304 |
/* * We don't include pwm_freq files in the arrays above, because they must be * created conditionally (only if pwm_mode is 1 == PWM) */ |
e196783d5 hwmon/f71805f: Su... |
1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 |
static struct attribute *f71805f_attributes_pwm_freq[] = { &sensor_dev_attr_pwm1_freq.dev_attr.attr, &sensor_dev_attr_pwm2_freq.dev_attr.attr, &sensor_dev_attr_pwm3_freq.dev_attr.attr, NULL }; static const struct attribute_group f71805f_group_pwm_freq = { .attrs = f71805f_attributes_pwm_freq, }; |
95e353127 hwmon/f71805f: Ad... |
1315 1316 1317 1318 1319 1320 |
/* We also need an indexed access to pwmN files to toggle writability */ static struct attribute *f71805f_attr_pwm[] = { &sensor_dev_attr_pwm1.dev_attr.attr, &sensor_dev_attr_pwm2.dev_attr.attr, &sensor_dev_attr_pwm3.dev_attr.attr, }; |
e53004e20 [PATCH] hwmon: Ne... |
1321 1322 1323 |
/* * Device registration and initialization */ |
6c931ae1c hwmon: remove use... |
1324 |
static void f71805f_init_device(struct f71805f_data *data) |
e53004e20 [PATCH] hwmon: Ne... |
1325 1326 1327 1328 1329 1330 |
{ u8 reg; int i; reg = f71805f_read8(data, F71805F_REG_START); if ((reg & 0x41) != 0x01) { |
692fe501d hwmon: checkpatch... |
1331 1332 |
pr_debug("Starting monitoring operations "); |
e53004e20 [PATCH] hwmon: Ne... |
1333 1334 |
f71805f_write8(data, F71805F_REG_START, (reg | 0x01) & ~0x40); } |
2fff0840c hwmon: (f71805f) ... |
1335 1336 1337 1338 |
/* * Fan monitoring can be disabled. If it is, we won't be polling * the register values, and won't create the related sysfs files. */ |
e53004e20 [PATCH] hwmon: Ne... |
1339 |
for (i = 0; i < 3; i++) { |
6b14a546a hwmon/f71805f: St... |
1340 1341 |
data->fan_ctrl[i] = f71805f_read8(data, F71805F_REG_FAN_CTRL(i)); |
2fff0840c hwmon: (f71805f) ... |
1342 1343 1344 1345 |
/* * Clear latch full bit, else "speed mode" fan speed control * doesn't work */ |
315c7113b hwmon/f71805f: Ad... |
1346 1347 1348 1349 1350 |
if (data->fan_ctrl[i] & FAN_CTRL_LATCH_FULL) { data->fan_ctrl[i] &= ~FAN_CTRL_LATCH_FULL; f71805f_write8(data, F71805F_REG_FAN_CTRL(i), data->fan_ctrl[i]); } |
e53004e20 [PATCH] hwmon: Ne... |
1351 1352 |
} } |
6c931ae1c hwmon: remove use... |
1353 |
static int f71805f_probe(struct platform_device *pdev) |
e53004e20 [PATCH] hwmon: Ne... |
1354 |
{ |
a8b3a3a53 hwmon: use dev_ge... |
1355 |
struct f71805f_sio_data *sio_data = dev_get_platdata(&pdev->dev); |
e53004e20 [PATCH] hwmon: Ne... |
1356 1357 |
struct f71805f_data *data; struct resource *res; |
2488a39d2 [PATCH] hwmon: Us... |
1358 |
int i, err; |
e53004e20 [PATCH] hwmon: Ne... |
1359 |
|
2fff0840c hwmon: (f71805f) ... |
1360 |
static const char * const names[] = { |
51c997d80 hwmon/f71805f: Ad... |
1361 1362 1363 |
"f71805f", "f71872f", }; |
adc141327 hwmon: (f71805f) ... |
1364 1365 |
data = devm_kzalloc(&pdev->dev, sizeof(struct f71805f_data), GFP_KERNEL); |
b83207fdd hwmon: (f71805f) ... |
1366 |
if (!data) |
adc141327 hwmon: (f71805f) ... |
1367 |
return -ENOMEM; |
e53004e20 [PATCH] hwmon: Ne... |
1368 1369 |
res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
adc141327 hwmon: (f71805f) ... |
1370 1371 |
if (!devm_request_region(&pdev->dev, res->start + ADDR_REG_OFFSET, 2, DRVNAME)) { |
ce7ee4e80 hwmon: Request th... |
1372 1373 1374 1375 |
dev_err(&pdev->dev, "Failed to request region 0x%lx-0x%lx ", (unsigned long)(res->start + ADDR_REG_OFFSET), (unsigned long)(res->start + ADDR_REG_OFFSET + 1)); |
adc141327 hwmon: (f71805f) ... |
1376 |
return -EBUSY; |
ce7ee4e80 hwmon: Request th... |
1377 |
} |
e53004e20 [PATCH] hwmon: Ne... |
1378 |
data->addr = res->start; |
51c997d80 hwmon/f71805f: Ad... |
1379 |
data->name = names[sio_data->kind]; |
f08191849 [PATCH] hwmon: f7... |
1380 |
mutex_init(&data->update_lock); |
e53004e20 [PATCH] hwmon: Ne... |
1381 1382 |
platform_set_drvdata(pdev, data); |
51c997d80 hwmon/f71805f: Ad... |
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 |
/* Some voltage inputs depend on chip model and configuration */ switch (sio_data->kind) { case f71805f: data->has_in = 0x1ff; break; case f71872f: data->has_in = 0x6ef; if (sio_data->fnsel1 & 0x01) data->has_in |= (1 << 4); /* in4 */ if (sio_data->fnsel1 & 0x02) data->has_in |= (1 << 8); /* in8 */ break; } |
e53004e20 [PATCH] hwmon: Ne... |
1396 1397 1398 1399 |
/* Initialize the F71805F chip */ f71805f_init_device(data); /* Register sysfs interface files */ |
2fff0840c hwmon: (f71805f) ... |
1400 1401 |
err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group); if (err) |
adc141327 hwmon: (f71805f) ... |
1402 |
return err; |
51c997d80 hwmon/f71805f: Ad... |
1403 |
if (data->has_in & (1 << 4)) { /* in4 */ |
2fff0840c hwmon: (f71805f) ... |
1404 1405 1406 |
err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group_optin[0]); if (err) |
51c997d80 hwmon/f71805f: Ad... |
1407 1408 1409 |
goto exit_remove_files; } if (data->has_in & (1 << 8)) { /* in8 */ |
2fff0840c hwmon: (f71805f) ... |
1410 1411 1412 |
err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group_optin[1]); if (err) |
51c997d80 hwmon/f71805f: Ad... |
1413 1414 1415 |
goto exit_remove_files; } if (data->has_in & (1 << 9)) { /* in9 (F71872F/FG only) */ |
2fff0840c hwmon: (f71805f) ... |
1416 1417 1418 |
err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group_optin[2]); if (err) |
51c997d80 hwmon/f71805f: Ad... |
1419 1420 1421 |
goto exit_remove_files; } if (data->has_in & (1 << 10)) { /* in9 (F71872F/FG only) */ |
2fff0840c hwmon: (f71805f) ... |
1422 1423 1424 |
err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group_optin[3]); if (err) |
51c997d80 hwmon/f71805f: Ad... |
1425 1426 |
goto exit_remove_files; } |
0e39e01c9 hwmon: Fix unchec... |
1427 |
for (i = 0; i < 3; i++) { |
e196783d5 hwmon/f71805f: Su... |
1428 1429 |
/* If control mode is PWM, create pwm_freq file */ if (!(data->fan_ctrl[i] & FAN_CTRL_DC_MODE)) { |
2fff0840c hwmon: (f71805f) ... |
1430 1431 1432 |
err = sysfs_create_file(&pdev->dev.kobj, f71805f_attributes_pwm_freq[i]); if (err) |
e196783d5 hwmon/f71805f: Su... |
1433 1434 |
goto exit_remove_files; } |
95e353127 hwmon/f71805f: Ad... |
1435 1436 |
/* If PWM is in manual mode, add write permission */ if (data->fan_ctrl[i] & FAN_CTRL_MODE_MANUAL) { |
2fff0840c hwmon: (f71805f) ... |
1437 1438 1439 1440 |
err = sysfs_chmod_file(&pdev->dev.kobj, f71805f_attr_pwm[i], S_IRUGO | S_IWUSR); if (err) { |
95e353127 hwmon/f71805f: Ad... |
1441 1442 1443 1444 1445 1446 |
dev_err(&pdev->dev, "chmod +w pwm%d failed ", i + 1); goto exit_remove_files; } } |
0e39e01c9 hwmon: Fix unchec... |
1447 |
} |
1beeffe43 hwmon: Convert fr... |
1448 1449 1450 |
data->hwmon_dev = hwmon_device_register(&pdev->dev); if (IS_ERR(data->hwmon_dev)) { err = PTR_ERR(data->hwmon_dev); |
0e39e01c9 hwmon: Fix unchec... |
1451 1452 1453 |
dev_err(&pdev->dev, "Class registration failed (%d) ", err); goto exit_remove_files; |
e53004e20 [PATCH] hwmon: Ne... |
1454 |
} |
e53004e20 [PATCH] hwmon: Ne... |
1455 1456 |
return 0; |
0e39e01c9 hwmon: Fix unchec... |
1457 1458 |
exit_remove_files: sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); |
51c997d80 hwmon/f71805f: Ad... |
1459 1460 |
for (i = 0; i < 4; i++) sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); |
e196783d5 hwmon/f71805f: Su... |
1461 |
sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); |
e53004e20 [PATCH] hwmon: Ne... |
1462 1463 |
return err; } |
281dfd0b6 hwmon: remove use... |
1464 |
static int f71805f_remove(struct platform_device *pdev) |
e53004e20 [PATCH] hwmon: Ne... |
1465 1466 |
{ struct f71805f_data *data = platform_get_drvdata(pdev); |
0e39e01c9 hwmon: Fix unchec... |
1467 |
int i; |
e53004e20 [PATCH] hwmon: Ne... |
1468 |
|
1beeffe43 hwmon: Convert fr... |
1469 |
hwmon_device_unregister(data->hwmon_dev); |
0e39e01c9 hwmon: Fix unchec... |
1470 |
sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); |
51c997d80 hwmon/f71805f: Ad... |
1471 1472 |
for (i = 0; i < 4; i++) sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); |
e196783d5 hwmon/f71805f: Su... |
1473 |
sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); |
ce7ee4e80 hwmon: Request th... |
1474 |
|
e53004e20 [PATCH] hwmon: Ne... |
1475 1476 1477 1478 1479 |
return 0; } static struct platform_driver f71805f_driver = { .driver = { |
e53004e20 [PATCH] hwmon: Ne... |
1480 1481 1482 |
.name = DRVNAME, }, .probe = f71805f_probe, |
9e5e9b7a9 hwmon: remove use... |
1483 |
.remove = f71805f_remove, |
e53004e20 [PATCH] hwmon: Ne... |
1484 |
}; |
51c997d80 hwmon/f71805f: Ad... |
1485 1486 |
static int __init f71805f_device_add(unsigned short address, const struct f71805f_sio_data *sio_data) |
e53004e20 [PATCH] hwmon: Ne... |
1487 |
{ |
568825c8e [PATCH] f71805f: ... |
1488 1489 1490 1491 1492 |
struct resource res = { .start = address, .end = address + REGION_LENGTH - 1, .flags = IORESOURCE_IO, }; |
e53004e20 [PATCH] hwmon: Ne... |
1493 1494 1495 1496 1497 |
int err; pdev = platform_device_alloc(DRVNAME, address); if (!pdev) { err = -ENOMEM; |
e54c5ad61 hwmon: (f71805f) ... |
1498 1499 |
pr_err("Device allocation failed "); |
e53004e20 [PATCH] hwmon: Ne... |
1500 1501 |
goto exit; } |
568825c8e [PATCH] f71805f: ... |
1502 |
res.name = pdev->name; |
b9acb64a3 hwmon: Check for ... |
1503 1504 1505 |
err = acpi_check_resource_conflict(&res); if (err) goto exit_device_put; |
568825c8e [PATCH] f71805f: ... |
1506 |
err = platform_device_add_resources(pdev, &res, 1); |
e53004e20 [PATCH] hwmon: Ne... |
1507 |
if (err) { |
e54c5ad61 hwmon: (f71805f) ... |
1508 1509 |
pr_err("Device resource addition failed (%d) ", err); |
e53004e20 [PATCH] hwmon: Ne... |
1510 1511 |
goto exit_device_put; } |
2df6d8115 hwmon: Use platfo... |
1512 1513 1514 |
err = platform_device_add_data(pdev, sio_data, sizeof(struct f71805f_sio_data)); if (err) { |
e54c5ad61 hwmon: (f71805f) ... |
1515 1516 |
pr_err("Platform data allocation failed "); |
51c997d80 hwmon/f71805f: Ad... |
1517 1518 |
goto exit_device_put; } |
51c997d80 hwmon/f71805f: Ad... |
1519 |
|
e53004e20 [PATCH] hwmon: Ne... |
1520 1521 |
err = platform_device_add(pdev); if (err) { |
e54c5ad61 hwmon: (f71805f) ... |
1522 1523 |
pr_err("Device addition failed (%d) ", err); |
a117dddf6 hwmon/f71805f: Fi... |
1524 |
goto exit_device_put; |
e53004e20 [PATCH] hwmon: Ne... |
1525 1526 1527 1528 1529 1530 1531 1532 1533 |
} return 0; exit_device_put: platform_device_put(pdev); exit: return err; } |
51c997d80 hwmon/f71805f: Ad... |
1534 1535 |
static int __init f71805f_find(int sioaddr, unsigned short *address, struct f71805f_sio_data *sio_data) |
e53004e20 [PATCH] hwmon: Ne... |
1536 1537 1538 |
{ int err = -ENODEV; u16 devid; |
2fff0840c hwmon: (f71805f) ... |
1539 |
static const char * const names[] = { |
51c997d80 hwmon/f71805f: Ad... |
1540 |
"F71805F/FG", |
9cab0217f hwmon: (f71805f) ... |
1541 |
"F71872F/FG or F71806F/FG", |
51c997d80 hwmon/f71805f: Ad... |
1542 |
}; |
e53004e20 [PATCH] hwmon: Ne... |
1543 1544 1545 1546 1547 |
superio_enter(sioaddr); devid = superio_inw(sioaddr, SIO_REG_MANID); if (devid != SIO_FINTEK_ID) goto exit; |
67b671bce hwmon: Let the us... |
1548 |
devid = force_id ? force_id : superio_inw(sioaddr, SIO_REG_DEVID); |
51c997d80 hwmon/f71805f: Ad... |
1549 1550 1551 1552 1553 1554 1555 1556 1557 |
switch (devid) { case SIO_F71805F_ID: sio_data->kind = f71805f; break; case SIO_F71872F_ID: sio_data->kind = f71872f; sio_data->fnsel1 = superio_inb(sioaddr, SIO_REG_FNSEL1); break; default: |
e54c5ad61 hwmon: (f71805f) ... |
1558 1559 |
pr_info("Unsupported Fintek device, skipping "); |
e53004e20 [PATCH] hwmon: Ne... |
1560 1561 1562 1563 1564 |
goto exit; } superio_select(sioaddr, F71805F_LD_HWM); if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) { |
e54c5ad61 hwmon: (f71805f) ... |
1565 1566 |
pr_warn("Device not activated, skipping "); |
e53004e20 [PATCH] hwmon: Ne... |
1567 1568 1569 1570 1571 |
goto exit; } *address = superio_inw(sioaddr, SIO_REG_ADDR); if (*address == 0) { |
e54c5ad61 hwmon: (f71805f) ... |
1572 1573 |
pr_warn("Base address not set, skipping "); |
e53004e20 [PATCH] hwmon: Ne... |
1574 1575 |
goto exit; } |
75c990291 hwmon/f71805f: Fi... |
1576 |
*address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */ |
e53004e20 [PATCH] hwmon: Ne... |
1577 1578 |
err = 0; |
e54c5ad61 hwmon: (f71805f) ... |
1579 1580 1581 1582 |
pr_info("Found %s chip at %#x, revision %u ", names[sio_data->kind], *address, superio_inb(sioaddr, SIO_REG_DEVREV)); |
e53004e20 [PATCH] hwmon: Ne... |
1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 |
exit: superio_exit(sioaddr); return err; } static int __init f71805f_init(void) { int err; unsigned short address; |
51c997d80 hwmon/f71805f: Ad... |
1593 |
struct f71805f_sio_data sio_data; |
e53004e20 [PATCH] hwmon: Ne... |
1594 |
|
51c997d80 hwmon/f71805f: Ad... |
1595 1596 |
if (f71805f_find(0x2e, &address, &sio_data) && f71805f_find(0x4e, &address, &sio_data)) |
e53004e20 [PATCH] hwmon: Ne... |
1597 1598 1599 1600 1601 1602 1603 |
return -ENODEV; err = platform_driver_register(&f71805f_driver); if (err) goto exit; /* Sets global pdev as a side effect */ |
51c997d80 hwmon/f71805f: Ad... |
1604 |
err = f71805f_device_add(address, &sio_data); |
e53004e20 [PATCH] hwmon: Ne... |
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 |
if (err) goto exit_driver; return 0; exit_driver: platform_driver_unregister(&f71805f_driver); exit: return err; } static void __exit f71805f_exit(void) { platform_device_unregister(pdev); platform_driver_unregister(&f71805f_driver); } |
964f945b5 hwmon: (f71805f) ... |
1621 |
MODULE_AUTHOR("Jean Delvare <jdelvare@suse.de>"); |
e53004e20 [PATCH] hwmon: Ne... |
1622 |
MODULE_LICENSE("GPL"); |
51c997d80 hwmon/f71805f: Ad... |
1623 |
MODULE_DESCRIPTION("F71805F/F71872F hardware monitoring driver"); |
e53004e20 [PATCH] hwmon: Ne... |
1624 1625 1626 |
module_init(f71805f_init); module_exit(f71805f_exit); |