Lines Matching full:pwm

15 #include <linux/pwm.h>
39 static int stmpe_24xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) in stmpe_24xx_pwm_enable() argument
47 dev_err(chip->dev, "error reading PWM#%u control\n", in stmpe_24xx_pwm_enable()
48 pwm->hwpwm); in stmpe_24xx_pwm_enable()
52 value = ret | BIT(pwm->hwpwm); in stmpe_24xx_pwm_enable()
56 dev_err(chip->dev, "error writing PWM#%u control\n", in stmpe_24xx_pwm_enable()
57 pwm->hwpwm); in stmpe_24xx_pwm_enable()
65 struct pwm_device *pwm) in stmpe_24xx_pwm_disable() argument
73 dev_err(chip->dev, "error reading PWM#%u control\n", in stmpe_24xx_pwm_disable()
74 pwm->hwpwm); in stmpe_24xx_pwm_disable()
78 value = ret & ~BIT(pwm->hwpwm); in stmpe_24xx_pwm_disable()
82 dev_err(chip->dev, "error writing PWM#%u control\n", in stmpe_24xx_pwm_disable()
83 pwm->hwpwm); in stmpe_24xx_pwm_disable()
88 /* STMPE 24xx PWM instructions */
99 static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, in stmpe_24xx_pwm_config() argument
113 if (pwm_is_enabled(pwm)) { in stmpe_24xx_pwm_config()
114 stmpe_24xx_pwm_disable(chip, pwm); in stmpe_24xx_pwm_config()
116 /* Connect the PWM to the pin */ in stmpe_24xx_pwm_config()
117 pin = pwm->hwpwm; in stmpe_24xx_pwm_config()
127 dev_err(chip->dev, "unable to connect PWM#%u to pin\n", in stmpe_24xx_pwm_config()
128 pwm->hwpwm); in stmpe_24xx_pwm_config()
134 switch (pwm->hwpwm) { in stmpe_24xx_pwm_config()
152 dev_dbg(chip->dev, "PWM#%u: config duty %d ns, period %d ns\n", in stmpe_24xx_pwm_config()
153 pwm->hwpwm, duty_ns, period_ns); in stmpe_24xx_pwm_config()
178 * counter from the ramp, if this is >= PWM counter the output in stmpe_24xx_pwm_config()
192 if (pwm_is_enabled(pwm)) in stmpe_24xx_pwm_config()
193 stmpe_24xx_pwm_enable(chip, pwm); in stmpe_24xx_pwm_config()
197 /* STMPE2403 can simply set the right PWM value */ in stmpe_24xx_pwm_config()
219 "PWM#%u: value = %02x, last_duty = %02x, program=%04x,%04x,%04x\n", in stmpe_24xx_pwm_config()
220 pwm->hwpwm, value, last, program[0], program[1], in stmpe_24xx_pwm_config()
250 /* If we were enabled, re-enable this PWM */ in stmpe_24xx_pwm_config()
251 if (pwm_is_enabled(pwm)) in stmpe_24xx_pwm_config()
252 stmpe_24xx_pwm_enable(chip, pwm); in stmpe_24xx_pwm_config()
257 dev_dbg(chip->dev, "programmed PWM#%u, %u bytes\n", pwm->hwpwm, i); in stmpe_24xx_pwm_config()
262 static int stmpe_24xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, in stmpe_24xx_pwm_apply() argument
271 if (pwm->state.enabled) in stmpe_24xx_pwm_apply()
272 stmpe_24xx_pwm_disable(chip, pwm); in stmpe_24xx_pwm_apply()
277 err = stmpe_24xx_pwm_config(pwm->chip, pwm, state->duty_cycle, state->period); in stmpe_24xx_pwm_apply()
281 if (!pwm->state.enabled) in stmpe_24xx_pwm_apply()
282 err = stmpe_24xx_pwm_enable(chip, pwm); in stmpe_24xx_pwm_apply()
312 dev_err(&pdev->dev, "Unknown STMPE PWM\n"); in stmpe_pwm_probe()
332 .name = "stmpe-pwm",