• Home
  • Raw
  • Download

Lines Matching refs:fan

120 	struct mlxreg_fan *fan = dev_get_drvdata(dev);  in mlxreg_fan_read()  local
127 tacho = &fan->tacho[channel]; in mlxreg_fan_read()
134 if (tacho->prsnt && fan->tachos_per_drwr) { in mlxreg_fan_read()
135 err = regmap_read(fan->regmap, tacho->prsnt, &regval); in mlxreg_fan_read()
143 if (BIT(channel / fan->tachos_per_drwr) & regval) { in mlxreg_fan_read()
150 err = regmap_read(fan->regmap, tacho->reg, &regval); in mlxreg_fan_read()
160 *val = MLXREG_FAN_GET_RPM(regval, fan->divider, in mlxreg_fan_read()
161 fan->samples); in mlxreg_fan_read()
165 err = regmap_read(fan->regmap, tacho->reg, &regval); in mlxreg_fan_read()
180 err = regmap_read(fan->regmap, fan->pwm.reg, &regval); in mlxreg_fan_read()
203 struct mlxreg_fan *fan = dev_get_drvdata(dev); in mlxreg_fan_write() local
212 return regmap_write(fan->regmap, fan->pwm.reg, val); in mlxreg_fan_write()
263 HWMON_CHANNEL_INFO(fan,
303 struct mlxreg_fan *fan = cdev->devdata; in mlxreg_fan_get_cur_state() local
307 err = regmap_read(fan->regmap, fan->pwm.reg, &regval); in mlxreg_fan_get_cur_state()
309 dev_err(fan->dev, "Failed to query PWM duty\n"); in mlxreg_fan_get_cur_state()
322 struct mlxreg_fan *fan = cdev->devdata; in mlxreg_fan_set_cur_state() local
346 fan->cooling_levels[i] = state; in mlxreg_fan_set_cur_state()
348 fan->cooling_levels[i] = i; in mlxreg_fan_set_cur_state()
350 err = regmap_read(fan->regmap, fan->pwm.reg, &regval); in mlxreg_fan_set_cur_state()
352 dev_err(fan->dev, "Failed to query PWM duty\n"); in mlxreg_fan_set_cur_state()
367 state = fan->cooling_levels[state]; in mlxreg_fan_set_cur_state()
368 err = regmap_write(fan->regmap, fan->pwm.reg, in mlxreg_fan_set_cur_state()
371 dev_err(fan->dev, "Failed to write PWM duty\n"); in mlxreg_fan_set_cur_state()
383 static int mlxreg_fan_connect_verify(struct mlxreg_fan *fan, in mlxreg_fan_connect_verify() argument
389 err = regmap_read(fan->regmap, data->capability, &regval); in mlxreg_fan_connect_verify()
391 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_connect_verify()
399 static int mlxreg_fan_speed_divider_get(struct mlxreg_fan *fan, in mlxreg_fan_speed_divider_get() argument
405 err = regmap_read(fan->regmap, data->capability, &regval); in mlxreg_fan_speed_divider_get()
407 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_speed_divider_get()
419 fan->divider = regval * MLXREG_FAN_TACHO_DIV_MIN; in mlxreg_fan_speed_divider_get()
424 static int mlxreg_fan_config(struct mlxreg_fan *fan, in mlxreg_fan_config() argument
432 fan->samples = MLXREG_FAN_TACHO_SAMPLES_PER_PULSE_DEF; in mlxreg_fan_config()
433 fan->divider = MLXREG_FAN_TACHO_DIV_DEF; in mlxreg_fan_config()
437 dev_err(fan->dev, "too many tacho entries: %s\n", in mlxreg_fan_config()
443 err = mlxreg_fan_connect_verify(fan, data); in mlxreg_fan_config()
452 fan->tacho[tacho_num].reg = data->reg; in mlxreg_fan_config()
453 fan->tacho[tacho_num].mask = data->mask; in mlxreg_fan_config()
454 fan->tacho[tacho_num].prsnt = data->reg_prsnt; in mlxreg_fan_config()
455 fan->tacho[tacho_num++].connected = true; in mlxreg_fan_config()
458 if (fan->pwm.connected) { in mlxreg_fan_config()
459 dev_err(fan->dev, "duplicate pwm entry: %s\n", in mlxreg_fan_config()
463 fan->pwm.reg = data->reg; in mlxreg_fan_config()
464 fan->pwm.connected = true; in mlxreg_fan_config()
467 dev_err(fan->dev, "duplicate conf entry: %s\n", in mlxreg_fan_config()
473 dev_err(fan->dev, "invalid conf entry params: %s\n", in mlxreg_fan_config()
478 err = mlxreg_fan_speed_divider_get(fan, data); in mlxreg_fan_config()
483 fan->samples = data->mask; in mlxreg_fan_config()
485 fan->divider = data->bit; in mlxreg_fan_config()
489 dev_err(fan->dev, "invalid label: %s\n", data->label); in mlxreg_fan_config()
499 err = regmap_read(fan->regmap, pdata->capability, &regval); in mlxreg_fan_config()
501 dev_err(fan->dev, "Failed to query capability register 0x%08x\n", in mlxreg_fan_config()
508 dev_err(fan->dev, "Configuration is invalid: drawers num %d tachos num %d\n", in mlxreg_fan_config()
514 fan->tachos_per_drwr = tacho_avail / drwr_avail; in mlxreg_fan_config()
519 fan->cooling_levels[i] = MLXREG_FAN_SPEED_MIN_LEVEL; in mlxreg_fan_config()
521 fan->cooling_levels[i] = i; in mlxreg_fan_config()
530 struct mlxreg_fan *fan; in mlxreg_fan_probe() local
540 fan = devm_kzalloc(dev, sizeof(*fan), GFP_KERNEL); in mlxreg_fan_probe()
541 if (!fan) in mlxreg_fan_probe()
544 fan->dev = dev; in mlxreg_fan_probe()
545 fan->regmap = pdata->regmap; in mlxreg_fan_probe()
547 err = mlxreg_fan_config(fan, pdata); in mlxreg_fan_probe()
552 fan, in mlxreg_fan_probe()
561 fan->cdev = devm_thermal_of_cooling_device_register(dev, in mlxreg_fan_probe()
562 NULL, "mlxreg_fan", fan, &mlxreg_fan_cooling_ops); in mlxreg_fan_probe()
563 if (IS_ERR(fan->cdev)) { in mlxreg_fan_probe()
565 return PTR_ERR(fan->cdev); in mlxreg_fan_probe()