Lines Matching full:fan
27 * FAN datasheet defines the formula for RPM calculations as RPM = 15/t-high.
77 * @fan: private data;
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()
135 * Check FAN presence: FAN related bit in presence register is one, in mlxreg_fan_read()
136 * if FAN is physically connected, zero - otherwise. 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()
148 /* FAN is not connected - return zero for FAN speed. */ in mlxreg_fan_read()
154 err = regmap_read(fan->regmap, tacho->reg, ®val); in mlxreg_fan_read()
159 /* FAN is broken - return zero for FAN speed. */ in mlxreg_fan_read()
164 *val = MLXREG_FAN_GET_RPM(regval, fan->divider, in mlxreg_fan_read()
165 fan->samples); in mlxreg_fan_read()
169 err = regmap_read(fan->regmap, tacho->reg, ®val); in mlxreg_fan_read()
182 pwm = &fan->pwm[channel]; in mlxreg_fan_read()
185 err = regmap_read(fan->regmap, pwm->reg, ®val); in mlxreg_fan_read()
208 struct mlxreg_fan *fan = dev_get_drvdata(dev); in mlxreg_fan_write() local
218 pwm = &fan->pwm[channel]; in mlxreg_fan_write()
231 return regmap_write(fan->regmap, pwm->reg, val); in mlxreg_fan_write()
289 HWMON_CHANNEL_INFO(fan,
345 struct mlxreg_fan *fan = pwm->fan; in mlxreg_fan_get_cur_state() local
349 err = regmap_read(fan->regmap, pwm->reg, ®val); in mlxreg_fan_get_cur_state()
351 dev_err(fan->dev, "Failed to query PWM duty\n"); in mlxreg_fan_get_cur_state()
365 struct mlxreg_fan *fan = pwm->fan; in mlxreg_fan_set_cur_state() local
375 err = regmap_write(fan->regmap, pwm->reg, in mlxreg_fan_set_cur_state()
378 dev_err(fan->dev, "Failed to write PWM duty\n"); in mlxreg_fan_set_cur_state()
390 static int mlxreg_fan_connect_verify(struct mlxreg_fan *fan, in mlxreg_fan_connect_verify() argument
396 err = regmap_read(fan->regmap, data->capability, ®val); in mlxreg_fan_connect_verify()
398 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_connect_verify()
406 static int mlxreg_pwm_connect_verify(struct mlxreg_fan *fan, in mlxreg_pwm_connect_verify() argument
412 err = regmap_read(fan->regmap, data->reg, ®val); in mlxreg_pwm_connect_verify()
414 dev_err(fan->dev, "Failed to query pwm register 0x%08x\n", in mlxreg_pwm_connect_verify()
422 static int mlxreg_fan_speed_divider_get(struct mlxreg_fan *fan, in mlxreg_fan_speed_divider_get() argument
428 err = regmap_read(fan->regmap, data->capability, ®val); in mlxreg_fan_speed_divider_get()
430 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_speed_divider_get()
442 fan->divider = regval * MLXREG_FAN_TACHO_DIV_MIN; in mlxreg_fan_speed_divider_get()
447 static int mlxreg_fan_config(struct mlxreg_fan *fan, in mlxreg_fan_config() argument
455 fan->samples = MLXREG_FAN_TACHO_SAMPLES_PER_PULSE_DEF; in mlxreg_fan_config()
456 fan->divider = MLXREG_FAN_TACHO_DIV_DEF; in mlxreg_fan_config()
460 dev_err(fan->dev, "too many tacho entries: %s\n", in mlxreg_fan_config()
466 err = mlxreg_fan_connect_verify(fan, data); in mlxreg_fan_config()
475 fan->tacho[tacho_num].reg = data->reg; in mlxreg_fan_config()
476 fan->tacho[tacho_num].mask = data->mask; in mlxreg_fan_config()
477 fan->tacho[tacho_num].prsnt = data->reg_prsnt; in mlxreg_fan_config()
478 fan->tacho[tacho_num++].connected = true; in mlxreg_fan_config()
482 dev_err(fan->dev, "too many pwm entries: %s\n", in mlxreg_fan_config()
489 err = mlxreg_pwm_connect_verify(fan, data); in mlxreg_fan_config()
496 fan->pwm[pwm_num].reg = data->reg; in mlxreg_fan_config()
497 fan->pwm[pwm_num].connected = true; in mlxreg_fan_config()
501 dev_err(fan->dev, "duplicate conf entry: %s\n", in mlxreg_fan_config()
507 dev_err(fan->dev, "invalid conf entry params: %s\n", in mlxreg_fan_config()
512 err = mlxreg_fan_speed_divider_get(fan, data); in mlxreg_fan_config()
517 fan->samples = data->mask; in mlxreg_fan_config()
519 fan->divider = data->bit; in mlxreg_fan_config()
523 dev_err(fan->dev, "invalid label: %s\n", data->label); in mlxreg_fan_config()
532 /* Obtain the number of FAN drawers, supported by system. */ in mlxreg_fan_config()
533 err = regmap_read(fan->regmap, pdata->capability, ®val); in mlxreg_fan_config()
535 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_config()
542 dev_err(fan->dev, "Configuration is invalid: drawers num %d tachos num %d\n", in mlxreg_fan_config()
548 fan->tachos_per_drwr = tacho_avail / drwr_avail; in mlxreg_fan_config()
554 static int mlxreg_fan_cooling_config(struct device *dev, struct mlxreg_fan *fan) in mlxreg_fan_cooling_config() argument
559 struct mlxreg_fan_pwm *pwm = &fan->pwm[i]; in mlxreg_fan_cooling_config()
563 pwm->fan = fan; in mlxreg_fan_cooling_config()
582 struct mlxreg_fan *fan; in mlxreg_fan_probe() local
592 fan = devm_kzalloc(dev, sizeof(*fan), GFP_KERNEL); in mlxreg_fan_probe()
593 if (!fan) in mlxreg_fan_probe()
596 fan->dev = dev; in mlxreg_fan_probe()
597 fan->regmap = pdata->regmap; in mlxreg_fan_probe()
599 err = mlxreg_fan_config(fan, pdata); in mlxreg_fan_probe()
604 fan, in mlxreg_fan_probe()
613 err = mlxreg_fan_cooling_config(dev, fan); in mlxreg_fan_probe()
620 .name = "mlxreg-fan",
628 MODULE_DESCRIPTION("Mellanox FAN driver");
630 MODULE_ALIAS("platform:mlxreg-fan");