• Home
  • Raw
  • Download

Lines Matching +full:pulses +full:- +full:per +full:- +full:revolution

2  * max6639.c - Support for Maxim MAX6639
4 * 2-Channel Temperature Monitor with Dual PWM Fan-Speed Controller
32 #include <linux/hwmon-sysfs.h>
96 u8 temp_therm[2]; /* THERM Temperature, 0..255 C (->_max) */
97 u8 temp_alert[2]; /* ALERT Temperature, 0..255 C (->_crit) */
98 u8 temp_ot[2]; /* OT Temperature, 0..255 C (->_emergency) */
101 u8 ppr; /* Pulses per rotation 0..3 for 1..4 ppr */
108 struct i2c_client *client = data->client; in max6639_update_device()
113 mutex_lock(&data->update_lock); in max6639_update_device()
115 if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) { in max6639_update_device()
118 dev_dbg(&client->dev, "Starting max6639 update\n"); in max6639_update_device()
127 data->status = status_reg; in max6639_update_device()
136 data->fan[i] = res; in max6639_update_device()
144 data->temp[i] = res >> 5; in max6639_update_device()
145 data->temp_fault[i] = res & 0x01; in max6639_update_device()
153 data->temp[i] |= res << 3; in max6639_update_device()
156 data->last_updated = jiffies; in max6639_update_device()
157 data->valid = 1; in max6639_update_device()
160 mutex_unlock(&data->update_lock); in max6639_update_device()
175 temp = data->temp[attr->index] * 125; in show_temp_input()
188 return sprintf(buf, "%d\n", data->temp_fault[attr->index]); in show_temp_fault()
197 return sprintf(buf, "%d\n", (data->temp_therm[attr->index] * 1000)); in show_temp_max()
206 struct i2c_client *client = data->client; in set_temp_max()
214 mutex_lock(&data->update_lock); in set_temp_max()
215 data->temp_therm[attr->index] = TEMP_LIMIT_TO_REG(val); in set_temp_max()
217 MAX6639_REG_THERM_LIMIT(attr->index), in set_temp_max()
218 data->temp_therm[attr->index]); in set_temp_max()
219 mutex_unlock(&data->update_lock); in set_temp_max()
229 return sprintf(buf, "%d\n", (data->temp_alert[attr->index] * 1000)); in show_temp_crit()
238 struct i2c_client *client = data->client; in set_temp_crit()
246 mutex_lock(&data->update_lock); in set_temp_crit()
247 data->temp_alert[attr->index] = TEMP_LIMIT_TO_REG(val); in set_temp_crit()
249 MAX6639_REG_ALERT_LIMIT(attr->index), in set_temp_crit()
250 data->temp_alert[attr->index]); in set_temp_crit()
251 mutex_unlock(&data->update_lock); in set_temp_crit()
262 return sprintf(buf, "%d\n", (data->temp_ot[attr->index] * 1000)); in show_temp_emergency()
271 struct i2c_client *client = data->client; in set_temp_emergency()
279 mutex_lock(&data->update_lock); in set_temp_emergency()
280 data->temp_ot[attr->index] = TEMP_LIMIT_TO_REG(val); in set_temp_emergency()
282 MAX6639_REG_OT_LIMIT(attr->index), in set_temp_emergency()
283 data->temp_ot[attr->index]); in set_temp_emergency()
284 mutex_unlock(&data->update_lock); in set_temp_emergency()
294 return sprintf(buf, "%d\n", data->pwm[attr->index] * 255 / 120); in show_pwm()
303 struct i2c_client *client = data->client; in set_pwm()
313 mutex_lock(&data->update_lock); in set_pwm()
314 data->pwm[attr->index] = (u8)(val * 120 / 255); in set_pwm()
316 MAX6639_REG_TARGTDUTY(attr->index), in set_pwm()
317 data->pwm[attr->index]); in set_pwm()
318 mutex_unlock(&data->update_lock); in set_pwm()
331 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], in show_fan_input()
332 data->rpm_range)); in show_fan_input()
344 return sprintf(buf, "%d\n", !!(data->status & (1 << attr->index))); in show_alarm()
424 dev_get_platdata(&client->dev); in max6639_init_client()
435 /* Fans pulse per revolution is 2 by default */ in max6639_init_client()
436 if (max6639_info && max6639_info->ppr > 0 && in max6639_init_client()
437 max6639_info->ppr < 5) in max6639_init_client()
438 data->ppr = max6639_info->ppr; in max6639_init_client()
440 data->ppr = 2; in max6639_init_client()
441 data->ppr -= 1; in max6639_init_client()
444 rpm_range = rpm_range_to_reg(max6639_info->rpm_range); in max6639_init_client()
445 data->rpm_range = rpm_range; in max6639_init_client()
449 /* Set Fan pulse per revolution */ in max6639_init_client()
452 data->ppr << 6); in max6639_init_client()
464 if (max6639_info && max6639_info->pwm_polarity == 0) in max6639_init_client()
484 data->temp_therm[i] = 80; in max6639_init_client()
485 data->temp_alert[i] = 90; in max6639_init_client()
486 data->temp_ot[i] = 100; in max6639_init_client()
489 data->temp_therm[i]); in max6639_init_client()
494 data->temp_alert[i]); in max6639_init_client()
498 MAX6639_REG_OT_LIMIT(i), data->temp_ot[i]); in max6639_init_client()
503 data->pwm[i] = 120; in max6639_init_client()
505 MAX6639_REG_TARGTDUTY(i), data->pwm[i]); in max6639_init_client()
517 /* Return 0 if detection is successful, -ENODEV otherwise */
521 struct i2c_adapter *adapter = client->adapter; in max6639_detect()
525 return -ENODEV; in max6639_detect()
531 return -ENODEV; in max6639_detect()
533 strlcpy(info->type, "max6639", I2C_NAME_SIZE); in max6639_detect()
541 struct device *dev = &client->dev; in max6639_probe()
548 return -ENOMEM; in max6639_probe()
550 data->client = client; in max6639_probe()
551 mutex_init(&data->update_lock); in max6639_probe()
558 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, in max6639_probe()