Lines Matching defs:pwm
3 * pwm-fan.c - Hwmon driver for fans connected to PWM lines.
17 #include <linux/pwm.h>
42 struct pwm_device *pwm;
104 /* disable pwm, keep regulator enabled */
109 /* keep pwm and regulator enabled */
115 /* disable pwm and regulator */
155 ret = pwm_apply_might_sleep(ctx->pwm, state);
185 ret = pwm_apply_might_sleep(ctx->pwm, state);
198 static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
204 if (pwm > 0) {
206 /* pwm-fan hard disabled */
210 state->duty_cycle = DIV_ROUND_UP(pwm * (period - 1), MAX_PWM);
211 ret = pwm_apply_might_sleep(ctx->pwm, state);
219 ctx->pwm_value = pwm;
224 static int set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
229 ret = __set_pwm(ctx, pwm);
235 static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
240 if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
260 /* Disable pwm-fan unconditionally */
282 pwm_apply_might_sleep(ctx->pwm, state);
410 dev_err(&cdev->device, "Cannot set pwm!\n");
493 ctx->pwm = devm_pwm_get(dev, NULL);
494 if (IS_ERR(ctx->pwm))
495 return dev_err_probe(dev, PTR_ERR(ctx->pwm), "Could not get PWM\n");
507 pwm_init_state(ctx->pwm, &ctx->pwm_state);
585 channels[0] = HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT | HWMON_PWM_ENABLE);
639 dev->of_node, "pwm-fan", ctx, &pwm_fan_cooling_ops);
643 "Failed to register pwm-fan as cooling device: %d\n",
677 { .compatible = "pwm-fan", },
686 .name = "pwm-fan",
695 MODULE_ALIAS("platform:pwm-fan");