Lines Matching refs:pwm
27 struct pwm_device *pwm; member
72 static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm) in __set_pwm() argument
79 if (ctx->pwm_value == pwm) in __set_pwm()
82 pwm_init_state(ctx->pwm, &state); in __set_pwm()
83 period = ctx->pwm->args.period; in __set_pwm()
84 state.duty_cycle = DIV_ROUND_UP(pwm * (period - 1), MAX_PWM); in __set_pwm()
85 state.enabled = pwm ? true : false; in __set_pwm()
87 ret = pwm_apply_state(ctx->pwm, &state); in __set_pwm()
89 ctx->pwm_value = pwm; in __set_pwm()
95 static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm) in pwm_fan_update_state() argument
100 if (pwm < ctx->pwm_fan_cooling_levels[i + 1]) in pwm_fan_update_state()
110 unsigned long pwm; in pwm_store() local
113 if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM) in pwm_store()
116 ret = __set_pwm(ctx, pwm); in pwm_store()
120 pwm_fan_update_state(ctx, pwm); in pwm_store()
140 static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0);
277 pwm_disable(ctx->pwm); in pwm_fan_pwm_disable()
297 ctx->pwm = devm_of_pwm_get(dev, dev->of_node, NULL); in pwm_fan_probe()
298 if (IS_ERR(ctx->pwm)) in pwm_fan_probe()
299 return dev_err_probe(dev, PTR_ERR(ctx->pwm), "Could not get PWM\n"); in pwm_fan_probe()
327 pwm_init_state(ctx->pwm, &state); in pwm_fan_probe()
339 state.duty_cycle = ctx->pwm->args.period - 1; in pwm_fan_probe()
342 ret = pwm_apply_state(ctx->pwm, &state); in pwm_fan_probe()
405 pwm_get_args(ctx->pwm, &args); in pwm_fan_disable()
408 ret = pwm_config(ctx->pwm, 0, args.period); in pwm_fan_disable()
412 pwm_disable(ctx->pwm); in pwm_fan_disable()
455 pwm_get_args(ctx->pwm, &pargs); in pwm_fan_resume()
457 ret = pwm_config(ctx->pwm, duty, pargs.period); in pwm_fan_resume()
460 return pwm_enable(ctx->pwm); in pwm_fan_resume()