Lines Matching +full:tach +full:- +full:ch

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * max31790.c - Part of lm_sensors, Linux kernel modules for hardware
19 #define MAX31790_REG_FAN_CONFIG(ch) (0x02 + (ch)) argument
20 #define MAX31790_REG_FAN_DYNAMICS(ch) (0x08 + (ch)) argument
23 #define MAX31790_REG_TACH_COUNT(ch) (0x18 + (ch) * 2) argument
24 #define MAX31790_REG_PWM_DUTY_CYCLE(ch) (0x30 + (ch) * 2) argument
25 #define MAX31790_REG_PWMOUT(ch) (0x40 + (ch) * 2) argument
26 #define MAX31790_REG_TARGET_COUNT(ch) (0x50 + (ch) * 2) argument
68 u16 tach[NR_CHANNEL * 2]; member
76 struct i2c_client *client = data->client; in max31790_update_device()
81 mutex_lock(&data->update_lock); in max31790_update_device()
83 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { in max31790_update_device()
88 data->fault_status |= rv & 0x3F; in max31790_update_device()
94 data->fault_status |= (rv & 0x3F) << 6; in max31790_update_device()
101 data->tach[i] = rv; in max31790_update_device()
103 if (data->fan_config[i] in max31790_update_device()
110 data->tach[NR_CHANNEL + i] = rv; in max31790_update_device()
116 data->pwm[i] = rv; in max31790_update_device()
122 data->target_count[i] = rv; in max31790_update_device()
126 data->last_updated = jiffies; in max31790_update_device()
127 data->valid = true; in max31790_update_device()
132 data->valid = false; in max31790_update_device()
136 mutex_unlock(&data->update_lock); in max31790_update_device()
179 sr = get_tach_period(data->fan_dynamics[channel % NR_CHANNEL]); in max31790_read_fan()
180 if (data->tach[channel] == FAN_COUNT_REG_MAX) in max31790_read_fan()
183 rpm = RPM_FROM_REG(data->tach[channel], sr); in max31790_read_fan()
187 sr = get_tach_period(data->fan_dynamics[channel]); in max31790_read_fan()
188 rpm = RPM_FROM_REG(data->target_count[channel], sr); in max31790_read_fan()
192 mutex_lock(&data->update_lock); in max31790_read_fan()
193 *val = !!(data->fault_status & (1 << channel)); in max31790_read_fan()
194 data->fault_status &= ~(1 << channel); in max31790_read_fan()
203 i2c_smbus_write_byte_data(data->client, reg, in max31790_read_fan()
204 data->target_count[channel % NR_CHANNEL] >> 8); in max31790_read_fan()
206 mutex_unlock(&data->update_lock); in max31790_read_fan()
209 *val = !!(data->fan_config[channel] & MAX31790_FAN_CFG_TACH_INPUT_EN); in max31790_read_fan()
212 return -EOPNOTSUPP; in max31790_read_fan()
220 struct i2c_client *client = data->client; in max31790_write_fan()
226 mutex_lock(&data->update_lock); in max31790_write_fan()
232 data->fan_dynamics[channel] = in max31790_write_fan()
233 ((data->fan_dynamics[channel] & in max31790_write_fan()
238 data->fan_dynamics[channel]); in max31790_write_fan()
242 sr = get_tach_period(data->fan_dynamics[channel]); in max31790_write_fan()
246 data->target_count[channel] = target_count << 5; in max31790_write_fan()
250 data->target_count[channel]); in max31790_write_fan()
253 fan_config = data->fan_config[channel]; in max31790_write_fan()
259 err = -EINVAL; in max31790_write_fan()
262 if (fan_config != data->fan_config[channel]) { in max31790_write_fan()
266 data->fan_config[channel] = fan_config; in max31790_write_fan()
270 err = -EOPNOTSUPP; in max31790_write_fan()
274 mutex_unlock(&data->update_lock); in max31790_write_fan()
282 u8 fan_config = data->fan_config[channel % NR_CHANNEL]; in max31790_fan_is_visible()
314 fan_config = data->fan_config[channel]; in max31790_read_pwm()
318 *val = data->pwm[channel] >> 8; in max31790_read_pwm()
329 return -EOPNOTSUPP; in max31790_read_pwm()
337 struct i2c_client *client = data->client; in max31790_write_pwm()
341 mutex_lock(&data->update_lock); in max31790_write_pwm()
346 err = -EINVAL; in max31790_write_pwm()
352 data->valid = false; in max31790_write_pwm()
358 fan_config = data->fan_config[channel]; in max31790_write_pwm()
378 err = -EINVAL; in max31790_write_pwm()
381 if (fan_config != data->fan_config[channel]) { in max31790_write_pwm()
385 data->fan_config[channel] = fan_config; in max31790_write_pwm()
389 err = -EOPNOTSUPP; in max31790_write_pwm()
393 mutex_unlock(&data->update_lock); in max31790_write_pwm()
401 u8 fan_config = data->fan_config[channel]; in max31790_pwm_is_visible()
423 return -EOPNOTSUPP; in max31790_read()
436 return -EOPNOTSUPP; in max31790_write()
499 data->fan_config[i] = rv; in max31790_init_client()
505 data->fan_dynamics[i] = rv; in max31790_init_client()
513 struct i2c_adapter *adapter = client->adapter; in max31790_probe()
514 struct device *dev = &client->dev; in max31790_probe()
521 return -ENODEV; in max31790_probe()
525 return -ENOMEM; in max31790_probe()
527 data->client = client; in max31790_probe()
528 mutex_init(&data->update_lock); in max31790_probe()
537 hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, in max31790_probe()