Lines Matching full:fan
20 * Minimum and maximum FAN allowed speed in percent: from 20% to 100%. Values
22 * setting FAN speed dynamic minimum. For example, if value is set to 14 (40%)
34 * FAN datasheet defines the formula for RPM calculations as RPM = 15/t-high.
116 struct mlxreg_fan *fan = dev_get_drvdata(dev); in mlxreg_fan_read() local
123 tacho = &fan->tacho[channel]; in mlxreg_fan_read()
126 err = regmap_read(fan->regmap, tacho->reg, ®val); in mlxreg_fan_read()
130 *val = MLXREG_FAN_GET_RPM(regval, fan->divider, in mlxreg_fan_read()
131 fan->samples); in mlxreg_fan_read()
135 err = regmap_read(fan->regmap, tacho->reg, ®val); in mlxreg_fan_read()
150 err = regmap_read(fan->regmap, fan->pwm.reg, ®val); in mlxreg_fan_read()
173 struct mlxreg_fan *fan = dev_get_drvdata(dev); in mlxreg_fan_write() local
182 return regmap_write(fan->regmap, fan->pwm.reg, val); in mlxreg_fan_write()
233 HWMON_CHANNEL_INFO(fan,
273 struct mlxreg_fan *fan = cdev->devdata; in mlxreg_fan_get_cur_state() local
277 err = regmap_read(fan->regmap, fan->pwm.reg, ®val); in mlxreg_fan_get_cur_state()
279 dev_err(fan->dev, "Failed to query PWM duty\n"); in mlxreg_fan_get_cur_state()
292 struct mlxreg_fan *fan = cdev->devdata; in mlxreg_fan_set_cur_state() local
299 * Verify if this request is for changing allowed FAN dynamical in mlxreg_fan_set_cur_state()
303 * changed from 4 to 6, fan->cooling_levels[0 to 5] will be changed all in mlxreg_fan_set_cur_state()
304 * from 4 to 6. And state 5 (fan->cooling_levels[4]) should be in mlxreg_fan_set_cur_state()
310 fan->cooling_levels[i] = state; in mlxreg_fan_set_cur_state()
312 fan->cooling_levels[i] = i; in mlxreg_fan_set_cur_state()
314 err = regmap_read(fan->regmap, fan->pwm.reg, ®val); in mlxreg_fan_set_cur_state()
316 dev_err(fan->dev, "Failed to query PWM duty\n"); in mlxreg_fan_set_cur_state()
331 state = fan->cooling_levels[state]; in mlxreg_fan_set_cur_state()
332 err = regmap_write(fan->regmap, fan->pwm.reg, in mlxreg_fan_set_cur_state()
335 dev_err(fan->dev, "Failed to write PWM duty\n"); in mlxreg_fan_set_cur_state()
347 static int mlxreg_fan_connect_verify(struct mlxreg_fan *fan, in mlxreg_fan_connect_verify() argument
353 err = regmap_read(fan->regmap, data->capability, ®val); in mlxreg_fan_connect_verify()
355 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_connect_verify()
363 static int mlxreg_fan_speed_divider_get(struct mlxreg_fan *fan, in mlxreg_fan_speed_divider_get() argument
369 err = regmap_read(fan->regmap, data->capability, ®val); in mlxreg_fan_speed_divider_get()
371 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_speed_divider_get()
383 fan->divider = regval * MLXREG_FAN_TACHO_DIV_MIN; in mlxreg_fan_speed_divider_get()
388 static int mlxreg_fan_config(struct mlxreg_fan *fan, in mlxreg_fan_config() argument
396 fan->samples = MLXREG_FAN_TACHO_SAMPLES_PER_PULSE_DEF; in mlxreg_fan_config()
397 fan->divider = MLXREG_FAN_TACHO_DIV_DEF; in mlxreg_fan_config()
401 dev_err(fan->dev, "too many tacho entries: %s\n", in mlxreg_fan_config()
407 err = mlxreg_fan_connect_verify(fan, data); in mlxreg_fan_config()
416 fan->tacho[tacho_num].reg = data->reg; in mlxreg_fan_config()
417 fan->tacho[tacho_num].mask = data->mask; in mlxreg_fan_config()
418 fan->tacho[tacho_num++].connected = true; in mlxreg_fan_config()
420 if (fan->pwm.connected) { in mlxreg_fan_config()
421 dev_err(fan->dev, "duplicate pwm entry: %s\n", in mlxreg_fan_config()
425 fan->pwm.reg = data->reg; in mlxreg_fan_config()
426 fan->pwm.connected = true; in mlxreg_fan_config()
429 dev_err(fan->dev, "duplicate conf entry: %s\n", in mlxreg_fan_config()
435 dev_err(fan->dev, "invalid conf entry params: %s\n", in mlxreg_fan_config()
440 err = mlxreg_fan_speed_divider_get(fan, data); in mlxreg_fan_config()
445 fan->samples = data->mask; in mlxreg_fan_config()
447 fan->divider = data->bit; in mlxreg_fan_config()
451 dev_err(fan->dev, "invalid label: %s\n", data->label); in mlxreg_fan_config()
458 fan->cooling_levels[i] = MLXREG_FAN_SPEED_MIN_LEVEL; in mlxreg_fan_config()
460 fan->cooling_levels[i] = i; in mlxreg_fan_config()
469 struct mlxreg_fan *fan; in mlxreg_fan_probe() local
479 fan = devm_kzalloc(dev, sizeof(*fan), GFP_KERNEL); in mlxreg_fan_probe()
480 if (!fan) in mlxreg_fan_probe()
483 fan->dev = dev; in mlxreg_fan_probe()
484 fan->regmap = pdata->regmap; in mlxreg_fan_probe()
486 err = mlxreg_fan_config(fan, pdata); in mlxreg_fan_probe()
491 fan, in mlxreg_fan_probe()
500 fan->cdev = devm_thermal_of_cooling_device_register(dev, in mlxreg_fan_probe()
501 NULL, "mlxreg_fan", fan, &mlxreg_fan_cooling_ops); in mlxreg_fan_probe()
502 if (IS_ERR(fan->cdev)) { in mlxreg_fan_probe()
504 return PTR_ERR(fan->cdev); in mlxreg_fan_probe()
513 .name = "mlxreg-fan",
521 MODULE_DESCRIPTION("Mellanox FAN driver");
523 MODULE_ALIAS("platform:mlxreg-fan");