Lines Matching refs:fan

93 	struct mlxreg_fan *fan;  member
126 struct mlxreg_fan *fan = dev_get_drvdata(dev); in mlxreg_fan_read() local
134 tacho = &fan->tacho[channel]; in mlxreg_fan_read()
141 if (tacho->prsnt && fan->tachos_per_drwr) { in mlxreg_fan_read()
142 err = regmap_read(fan->regmap, tacho->prsnt, &regval); in mlxreg_fan_read()
150 if (BIT(channel / fan->tachos_per_drwr) & regval) { in mlxreg_fan_read()
157 err = regmap_read(fan->regmap, tacho->reg, &regval); in mlxreg_fan_read()
161 *val = MLXREG_FAN_GET_RPM(regval, fan->divider, in mlxreg_fan_read()
162 fan->samples); in mlxreg_fan_read()
166 err = regmap_read(fan->regmap, tacho->reg, &regval); in mlxreg_fan_read()
179 pwm = &fan->pwm[channel]; in mlxreg_fan_read()
182 err = regmap_read(fan->regmap, pwm->reg, &regval); in mlxreg_fan_read()
205 struct mlxreg_fan *fan = dev_get_drvdata(dev); in mlxreg_fan_write() local
215 pwm = &fan->pwm[channel]; in mlxreg_fan_write()
216 return regmap_write(fan->regmap, pwm->reg, val); in mlxreg_fan_write()
274 HWMON_CHANNEL_INFO(fan,
320 struct mlxreg_fan *fan = pwm->fan; in mlxreg_fan_get_cur_state() local
324 err = regmap_read(fan->regmap, pwm->reg, &regval); in mlxreg_fan_get_cur_state()
326 dev_err(fan->dev, "Failed to query PWM duty\n"); in mlxreg_fan_get_cur_state()
340 struct mlxreg_fan *fan = pwm->fan; in mlxreg_fan_set_cur_state() local
368 err = regmap_read(fan->regmap, pwm->reg, &regval); in mlxreg_fan_set_cur_state()
370 dev_err(fan->dev, "Failed to query PWM duty\n"); in mlxreg_fan_set_cur_state()
386 err = regmap_write(fan->regmap, pwm->reg, in mlxreg_fan_set_cur_state()
389 dev_err(fan->dev, "Failed to write PWM duty\n"); in mlxreg_fan_set_cur_state()
401 static int mlxreg_fan_connect_verify(struct mlxreg_fan *fan, in mlxreg_fan_connect_verify() argument
407 err = regmap_read(fan->regmap, data->capability, &regval); in mlxreg_fan_connect_verify()
409 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_connect_verify()
417 static int mlxreg_pwm_connect_verify(struct mlxreg_fan *fan, in mlxreg_pwm_connect_verify() argument
423 err = regmap_read(fan->regmap, data->reg, &regval); in mlxreg_pwm_connect_verify()
425 dev_err(fan->dev, "Failed to query pwm register 0x%08x\n", in mlxreg_pwm_connect_verify()
433 static int mlxreg_fan_speed_divider_get(struct mlxreg_fan *fan, in mlxreg_fan_speed_divider_get() argument
439 err = regmap_read(fan->regmap, data->capability, &regval); in mlxreg_fan_speed_divider_get()
441 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_speed_divider_get()
453 fan->divider = regval * MLXREG_FAN_TACHO_DIV_MIN; in mlxreg_fan_speed_divider_get()
458 static int mlxreg_fan_config(struct mlxreg_fan *fan, in mlxreg_fan_config() argument
466 fan->samples = MLXREG_FAN_TACHO_SAMPLES_PER_PULSE_DEF; in mlxreg_fan_config()
467 fan->divider = MLXREG_FAN_TACHO_DIV_DEF; in mlxreg_fan_config()
471 dev_err(fan->dev, "too many tacho entries: %s\n", in mlxreg_fan_config()
477 err = mlxreg_fan_connect_verify(fan, data); in mlxreg_fan_config()
486 fan->tacho[tacho_num].reg = data->reg; in mlxreg_fan_config()
487 fan->tacho[tacho_num].mask = data->mask; in mlxreg_fan_config()
488 fan->tacho[tacho_num].prsnt = data->reg_prsnt; in mlxreg_fan_config()
489 fan->tacho[tacho_num++].connected = true; in mlxreg_fan_config()
493 dev_err(fan->dev, "too many pwm entries: %s\n", in mlxreg_fan_config()
500 err = mlxreg_pwm_connect_verify(fan, data); in mlxreg_fan_config()
507 fan->pwm[pwm_num].reg = data->reg; in mlxreg_fan_config()
508 fan->pwm[pwm_num].connected = true; in mlxreg_fan_config()
512 dev_err(fan->dev, "duplicate conf entry: %s\n", in mlxreg_fan_config()
518 dev_err(fan->dev, "invalid conf entry params: %s\n", in mlxreg_fan_config()
523 err = mlxreg_fan_speed_divider_get(fan, data); in mlxreg_fan_config()
528 fan->samples = data->mask; in mlxreg_fan_config()
530 fan->divider = data->bit; in mlxreg_fan_config()
534 dev_err(fan->dev, "invalid label: %s\n", data->label); in mlxreg_fan_config()
544 err = regmap_read(fan->regmap, pdata->capability, &regval); in mlxreg_fan_config()
546 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_config()
553 dev_err(fan->dev, "Configuration is invalid: drawers num %d tachos num %d\n", in mlxreg_fan_config()
559 fan->tachos_per_drwr = tacho_avail / drwr_avail; in mlxreg_fan_config()
565 static int mlxreg_fan_cooling_config(struct device *dev, struct mlxreg_fan *fan) in mlxreg_fan_cooling_config() argument
570 struct mlxreg_fan_pwm *pwm = &fan->pwm[i]; in mlxreg_fan_cooling_config()
574 pwm->fan = fan; in mlxreg_fan_cooling_config()
596 struct mlxreg_fan *fan; in mlxreg_fan_probe() local
606 fan = devm_kzalloc(dev, sizeof(*fan), GFP_KERNEL); in mlxreg_fan_probe()
607 if (!fan) in mlxreg_fan_probe()
610 fan->dev = dev; in mlxreg_fan_probe()
611 fan->regmap = pdata->regmap; in mlxreg_fan_probe()
613 err = mlxreg_fan_config(fan, pdata); in mlxreg_fan_probe()
618 fan, in mlxreg_fan_probe()
627 err = mlxreg_fan_cooling_config(dev, fan); in mlxreg_fan_probe()