Lines Matching +full:activate +full:- +full:to +full:- +full:activate
2 smsc47m1.c - Part of lm_sensors, Linux kernel modules
7 Super-I/O chips.
10 Copyright (C) 2004-2007 Jean Delvare <khali@linux-fr.org>
11 Ported to Linux 2.6 by Gabriele Gorla <gorlik@yahoo.com>
25 along with this program; if not, write to the Free Software
37 #include <linux/hwmon-sysfs.h>
54 /* Super-I/0 registers and commands */
56 #define REG 0x2e /* The register to read/write */
57 #define VAL 0x2f /* The value to read/write */
99 #define SMSC47M1_REG_TPIN(nr) (0x34 - (nr))
100 #define SMSC47M1_REG_PPIN(nr) (0x36 - (nr))
115 983040/((192-(reg))*(div)))
117 983040/(((reg)-(preload))*(div)))
141 u8 activate; /* Remember initial device state */ member
151 return inb_p(data->addr + reg); in smsc47m1_read_value()
157 outb_p(value, data->addr + reg); in smsc47m1_write_value()
173 int nr = attr->index; in get_fan()
178 int rpm = (data->pwm[nr] & 0x7F) == 0x00 ? 0 : in get_fan()
179 FAN_FROM_REG(data->fan[nr], in get_fan()
180 DIV_FROM_REG(data->fan_div[nr]), in get_fan()
181 data->fan_preload[nr]); in get_fan()
190 int nr = attr->index; in get_fan_min()
191 int rpm = MIN_FROM_REG(data->fan_preload[nr], in get_fan_min()
192 DIV_FROM_REG(data->fan_div[nr])); in get_fan_min()
201 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[attr->index])); in get_fan_div()
207 int bitnr = to_sensor_dev_attr(devattr)->index; in get_fan_alarm()
209 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); in get_fan_alarm()
217 return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[attr->index])); in get_pwm()
225 return sprintf(buf, "%d\n", PWM_EN_FROM_REG(data->pwm[attr->index])); in get_pwm_en()
232 return sprintf(buf, "%d\n", data->alarms); in get_alarms()
240 int nr = attr->index; in set_fan_min()
243 mutex_lock(&data->update_lock); in set_fan_min()
244 rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]); in set_fan_min()
247 mutex_unlock(&data->update_lock); in set_fan_min()
248 return -EINVAL; in set_fan_min()
251 data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv); in set_fan_min()
253 data->fan_preload[nr]); in set_fan_min()
254 mutex_unlock(&data->update_lock); in set_fan_min()
261 of least surprise; the user doesn't expect the fan minimum to change just
268 int nr = attr->index; in set_fan_div()
270 u8 old_div = DIV_FROM_REG(data->fan_div[nr]); in set_fan_div()
275 mutex_lock(&data->update_lock); in set_fan_div()
277 case 1: data->fan_div[nr] = 0; break; in set_fan_div()
278 case 2: data->fan_div[nr] = 1; break; in set_fan_div()
279 case 4: data->fan_div[nr] = 2; break; in set_fan_div()
280 case 8: data->fan_div[nr] = 3; break; in set_fan_div()
282 mutex_unlock(&data->update_lock); in set_fan_div()
283 return -EINVAL; in set_fan_div()
291 tmp |= data->fan_div[nr] << (4 + 2 * nr); in set_fan_div()
296 tmp |= data->fan_div[2] << 4; in set_fan_div()
302 tmp = 192 - (old_div * (192 - data->fan_preload[nr]) in set_fan_div()
304 data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191); in set_fan_div()
306 data->fan_preload[nr]); in set_fan_div()
307 mutex_unlock(&data->update_lock); in set_fan_div()
317 int nr = attr->index; in set_pwm()
321 return -EINVAL; in set_pwm()
323 mutex_lock(&data->update_lock); in set_pwm()
324 data->pwm[nr] &= 0x81; /* Preserve additional bits */ in set_pwm()
325 data->pwm[nr] |= PWM_TO_REG(val); in set_pwm()
327 data->pwm[nr]); in set_pwm()
328 mutex_unlock(&data->update_lock); in set_pwm()
338 int nr = attr->index; in set_pwm_en()
342 return -EINVAL; in set_pwm_en()
344 mutex_lock(&data->update_lock); in set_pwm_en()
345 data->pwm[nr] &= 0xFE; /* preserve the other bits */ in set_pwm_en()
346 data->pwm[nr] |= !val; in set_pwm_en()
348 data->pwm[nr]); in set_pwm_en()
349 mutex_unlock(&data->update_lock); in set_pwm_en()
356 NULL, offset - 1); \
358 get_fan_min, set_fan_min, offset - 1); \
360 get_fan_div, set_fan_div, offset - 1); \
362 NULL, offset - 1); \
364 get_pwm, set_pwm, offset - 1); \
366 get_pwm_en, set_pwm_en, offset - 1)
379 return sprintf(buf, "%s\n", data->name); in show_name()
384 setup so we create them individually. It is still convenient to define a
385 group to remove them all at once. */
429 * The LPC47M997 is undocumented, but seems to be compatible with in smsc47m1_find()
435 * We check the high bit of the device revision register to in smsc47m1_find()
441 sio_data->type = smsc47m1; in smsc47m1_find()
445 sio_data->type = smsc47m1; in smsc47m1_find()
449 sio_data->type = smsc47m1; in smsc47m1_find()
453 sio_data->type = smsc47m1; in smsc47m1_find()
459 return -ENODEV; in smsc47m1_find()
463 sio_data->type = smsc47m2; in smsc47m1_find()
467 return -ENODEV; in smsc47m1_find()
476 return -ENODEV; in smsc47m1_find()
481 sio_data->activate = superio_inb(SUPERIO_REG_ACT); in smsc47m1_find()
482 if ((sio_data->activate & 0x01) == 0) { in smsc47m1_find()
484 superio_outb(SUPERIO_REG_ACT, sio_data->activate | 0x01); in smsc47m1_find()
491 /* Restore device to its initial state */
494 if ((sio_data->activate & 0x01) == 0) { in smsc47m1_restore()
499 superio_outb(SUPERIO_REG_ACT, sio_data->activate); in smsc47m1_restore()
510 * This function can be used to:
511 * - test for resource conflicts with ACPI
512 * - request the resources
513 * - release the resources
514 * We only allocate the I/O ports we really need, to minimize the risk of
566 dev_err(dev, "Region 0x%hx-0x%hx already in " in smsc47m1_handle_resources()
570 for (i -= 2; i >= 0; i -= 2) in smsc47m1_handle_resources()
573 return -EBUSY; in smsc47m1_handle_resources()
588 struct device *dev = &pdev->dev; in smsc47m1_probe()
589 struct smsc47m1_sio_data *sio_data = dev->platform_data; in smsc47m1_probe()
601 err = smsc47m1_handle_resources(res->start, sio_data->type, in smsc47m1_probe()
607 err = -ENOMEM; in smsc47m1_probe()
611 data->addr = res->start; in smsc47m1_probe()
612 data->type = sio_data->type; in smsc47m1_probe()
613 data->name = names[sio_data->type]; in smsc47m1_probe()
614 mutex_init(&data->update_lock); in smsc47m1_probe()
623 if (data->type == smsc47m2) { in smsc47m1_probe()
642 err = -ENODEV; in smsc47m1_probe()
691 } else if (data->type == smsc47m2) in smsc47m1_probe()
718 } else if (data->type == smsc47m2) in smsc47m1_probe()
726 data->hwmon_dev = hwmon_device_register(dev); in smsc47m1_probe()
727 if (IS_ERR(data->hwmon_dev)) { in smsc47m1_probe()
728 err = PTR_ERR(data->hwmon_dev); in smsc47m1_probe()
735 sysfs_remove_group(&dev->kobj, &smsc47m1_group); in smsc47m1_probe()
740 smsc47m1_handle_resources(res->start, sio_data->type, RELEASE, dev); in smsc47m1_probe()
749 hwmon_device_unregister(data->hwmon_dev); in smsc47m1_remove()
750 sysfs_remove_group(&pdev->dev.kobj, &smsc47m1_group); in smsc47m1_remove()
753 smsc47m1_handle_resources(res->start, data->type, RELEASE, &pdev->dev); in smsc47m1_remove()
765 mutex_lock(&data->update_lock); in smsc47m1_update_device()
767 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { in smsc47m1_update_device()
769 fan_nr = data->type == smsc47m2 ? 3 : 2; in smsc47m1_update_device()
772 data->fan[i] = smsc47m1_read_value(data, in smsc47m1_update_device()
774 data->fan_preload[i] = smsc47m1_read_value(data, in smsc47m1_update_device()
776 data->pwm[i] = smsc47m1_read_value(data, in smsc47m1_update_device()
781 data->fan_div[0] = (i >> 4) & 0x03; in smsc47m1_update_device()
782 data->fan_div[1] = i >> 6; in smsc47m1_update_device()
784 data->alarms = smsc47m1_read_value(data, in smsc47m1_update_device()
787 if (data->alarms) in smsc47m1_update_device()
791 data->fan_div[2] = (smsc47m1_read_value(data, in smsc47m1_update_device()
793 data->alarms |= (smsc47m1_read_value(data, in smsc47m1_update_device()
796 if (data->alarms & 0x04) in smsc47m1_update_device()
802 data->last_updated = jiffies; in smsc47m1_update_device()
805 mutex_unlock(&data->update_lock); in smsc47m1_update_device()
814 .end = address + SMSC_EXTENT - 1, in smsc47m1_device_add()
820 err = smsc47m1_handle_resources(address, sio_data->type, CHECK, NULL); in smsc47m1_device_add()
826 err = -ENOMEM; in smsc47m1_device_add()
865 return -ENODEV; in sm_smsc47m1_init()
888 smsc47m1_restore(pdev->dev.platform_data); in sm_smsc47m1_exit()