Lines Matching refs:fan
86 struct mlxreg_fan *fan; member
123 struct mlxreg_fan *fan = dev_get_drvdata(dev); in mlxreg_fan_read() local
131 tacho = &fan->tacho[channel]; in mlxreg_fan_read()
138 if (tacho->prsnt && fan->tachos_per_drwr) { in mlxreg_fan_read()
139 err = regmap_read(fan->regmap, tacho->prsnt, ®val); in mlxreg_fan_read()
147 if (BIT(channel / fan->tachos_per_drwr) & regval) { in mlxreg_fan_read()
154 err = regmap_read(fan->regmap, tacho->reg, ®val); in mlxreg_fan_read()
158 *val = MLXREG_FAN_GET_RPM(regval, fan->divider, in mlxreg_fan_read()
159 fan->samples); in mlxreg_fan_read()
163 err = regmap_read(fan->regmap, tacho->reg, ®val); in mlxreg_fan_read()
176 pwm = &fan->pwm[channel]; in mlxreg_fan_read()
179 err = regmap_read(fan->regmap, pwm->reg, ®val); in mlxreg_fan_read()
202 struct mlxreg_fan *fan = dev_get_drvdata(dev); in mlxreg_fan_write() local
212 pwm = &fan->pwm[channel]; in mlxreg_fan_write()
225 return regmap_write(fan->regmap, pwm->reg, val); in mlxreg_fan_write()
283 HWMON_CHANNEL_INFO(fan,
329 struct mlxreg_fan *fan = pwm->fan; in mlxreg_fan_get_cur_state() local
333 err = regmap_read(fan->regmap, pwm->reg, ®val); in mlxreg_fan_get_cur_state()
335 dev_err(fan->dev, "Failed to query PWM duty\n"); in mlxreg_fan_get_cur_state()
349 struct mlxreg_fan *fan = pwm->fan; in mlxreg_fan_set_cur_state() local
359 err = regmap_write(fan->regmap, pwm->reg, in mlxreg_fan_set_cur_state()
362 dev_err(fan->dev, "Failed to write PWM duty\n"); in mlxreg_fan_set_cur_state()
374 static int mlxreg_fan_connect_verify(struct mlxreg_fan *fan, in mlxreg_fan_connect_verify() argument
380 err = regmap_read(fan->regmap, data->capability, ®val); in mlxreg_fan_connect_verify()
382 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_connect_verify()
390 static int mlxreg_pwm_connect_verify(struct mlxreg_fan *fan, in mlxreg_pwm_connect_verify() argument
396 err = regmap_read(fan->regmap, data->reg, ®val); in mlxreg_pwm_connect_verify()
398 dev_err(fan->dev, "Failed to query pwm register 0x%08x\n", in mlxreg_pwm_connect_verify()
406 static int mlxreg_fan_speed_divider_get(struct mlxreg_fan *fan, in mlxreg_fan_speed_divider_get() argument
412 err = regmap_read(fan->regmap, data->capability, ®val); in mlxreg_fan_speed_divider_get()
414 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_speed_divider_get()
426 fan->divider = regval * MLXREG_FAN_TACHO_DIV_MIN; in mlxreg_fan_speed_divider_get()
431 static int mlxreg_fan_config(struct mlxreg_fan *fan, in mlxreg_fan_config() argument
439 fan->samples = MLXREG_FAN_TACHO_SAMPLES_PER_PULSE_DEF; in mlxreg_fan_config()
440 fan->divider = MLXREG_FAN_TACHO_DIV_DEF; in mlxreg_fan_config()
444 dev_err(fan->dev, "too many tacho entries: %s\n", in mlxreg_fan_config()
450 err = mlxreg_fan_connect_verify(fan, data); in mlxreg_fan_config()
459 fan->tacho[tacho_num].reg = data->reg; in mlxreg_fan_config()
460 fan->tacho[tacho_num].mask = data->mask; in mlxreg_fan_config()
461 fan->tacho[tacho_num].prsnt = data->reg_prsnt; in mlxreg_fan_config()
462 fan->tacho[tacho_num++].connected = true; in mlxreg_fan_config()
466 dev_err(fan->dev, "too many pwm entries: %s\n", in mlxreg_fan_config()
473 err = mlxreg_pwm_connect_verify(fan, data); in mlxreg_fan_config()
480 fan->pwm[pwm_num].reg = data->reg; in mlxreg_fan_config()
481 fan->pwm[pwm_num].connected = true; in mlxreg_fan_config()
485 dev_err(fan->dev, "duplicate conf entry: %s\n", in mlxreg_fan_config()
491 dev_err(fan->dev, "invalid conf entry params: %s\n", in mlxreg_fan_config()
496 err = mlxreg_fan_speed_divider_get(fan, data); in mlxreg_fan_config()
501 fan->samples = data->mask; in mlxreg_fan_config()
503 fan->divider = data->bit; in mlxreg_fan_config()
507 dev_err(fan->dev, "invalid label: %s\n", data->label); in mlxreg_fan_config()
517 err = regmap_read(fan->regmap, pdata->capability, ®val); in mlxreg_fan_config()
519 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_config()
526 dev_err(fan->dev, "Configuration is invalid: drawers num %d tachos num %d\n", in mlxreg_fan_config()
532 fan->tachos_per_drwr = tacho_avail / drwr_avail; in mlxreg_fan_config()
538 static int mlxreg_fan_cooling_config(struct device *dev, struct mlxreg_fan *fan) in mlxreg_fan_cooling_config() argument
543 struct mlxreg_fan_pwm *pwm = &fan->pwm[i]; in mlxreg_fan_cooling_config()
547 pwm->fan = fan; in mlxreg_fan_cooling_config()
566 struct mlxreg_fan *fan; in mlxreg_fan_probe() local
576 fan = devm_kzalloc(dev, sizeof(*fan), GFP_KERNEL); in mlxreg_fan_probe()
577 if (!fan) in mlxreg_fan_probe()
580 fan->dev = dev; in mlxreg_fan_probe()
581 fan->regmap = pdata->regmap; in mlxreg_fan_probe()
583 err = mlxreg_fan_config(fan, pdata); in mlxreg_fan_probe()
588 fan, in mlxreg_fan_probe()
597 err = mlxreg_fan_cooling_config(dev, fan); in mlxreg_fan_probe()