Lines Matching refs:pwm

12 #include <linux/pwm.h>
32 #define TWL4030_PWM_TOGGLE(pwm, x) ((x) << (pwm))
46 #define TWL6030_PWM_TOGGLE(pwm, x) ((x) << (pwm * 3))
60 static int twl_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
83 base = pwm->hwpwm * 3;
89 dev_err(chip->dev, "%s: Failed to configure PWM\n", pwm->label);
94 static int twl4030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
103 dev_err(chip->dev, "%s: Failed to read GPBR1\n", pwm->label);
107 val |= TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMXCLK_ENABLE);
111 dev_err(chip->dev, "%s: Failed to enable PWM\n", pwm->label);
113 val |= TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMX_ENABLE);
117 dev_err(chip->dev, "%s: Failed to enable PWM\n", pwm->label);
124 static void twl4030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
133 dev_err(chip->dev, "%s: Failed to read GPBR1\n", pwm->label);
137 val &= ~TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMX_ENABLE);
141 dev_err(chip->dev, "%s: Failed to disable PWM\n", pwm->label);
143 val &= ~TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMXCLK_ENABLE);
147 dev_err(chip->dev, "%s: Failed to disable PWM\n", pwm->label);
153 static int twl4030_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
159 if (pwm->hwpwm == 1) {
170 dev_err(chip->dev, "%s: Failed to read PMBR1\n", pwm->label);
184 dev_err(chip->dev, "%s: Failed to request PWM\n", pwm->label);
191 static void twl4030_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
197 if (pwm->hwpwm == 1)
205 dev_err(chip->dev, "%s: Failed to read PMBR1\n", pwm->label);
215 dev_err(chip->dev, "%s: Failed to free PWM\n", pwm->label);
221 static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
229 val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXS | TWL6030_PWMXEN);
230 val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXR);
234 dev_err(chip->dev, "%s: Failed to enable PWM\n", pwm->label);
244 static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
252 val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXR);
253 val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXS | TWL6030_PWMXEN);
257 dev_err(chip->dev, "%s: Failed to disable PWM\n", pwm->label);
261 val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXEN);
265 dev_err(chip->dev, "%s: Failed to disable PWM\n", pwm->label);
269 val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXEN);
273 dev_err(chip->dev, "%s: Failed to disable PWM\n", pwm->label);
282 static int twl4030_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
291 if (pwm->state.enabled)
292 twl4030_pwm_disable(chip, pwm);
297 err = twl_pwm_config(pwm->chip, pwm, state->duty_cycle, state->period);
301 if (!pwm->state.enabled)
302 err = twl4030_pwm_enable(chip, pwm);
307 static int twl6030_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
316 if (pwm->state.enabled)
317 twl6030_pwm_disable(chip, pwm);
322 err = twl_pwm_config(pwm->chip, pwm, state->duty_cycle, state->period);
326 if (!pwm->state.enabled)
327 err = twl6030_pwm_enable(chip, pwm);
367 { .compatible = "ti,twl4030-pwm" },
368 { .compatible = "ti,twl6030-pwm" },
376 .name = "twl-pwm",
385 MODULE_ALIAS("platform:twl-pwm");