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))
59 static int twl_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
82 base = pwm->hwpwm * 3;
88 dev_err(pwmchip_parent(chip), "%s: Failed to configure PWM\n", pwm->label);
93 static int twl4030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
102 dev_err(pwmchip_parent(chip), "%s: Failed to read GPBR1\n", pwm->label);
106 val |= TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMXCLK_ENABLE);
110 dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label);
112 val |= TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMX_ENABLE);
116 dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label);
123 static void twl4030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
132 dev_err(pwmchip_parent(chip), "%s: Failed to read GPBR1\n", pwm->label);
136 val &= ~TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMX_ENABLE);
140 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label);
142 val &= ~TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMXCLK_ENABLE);
146 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label);
152 static int twl4030_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
158 if (pwm->hwpwm == 1) {
169 dev_err(pwmchip_parent(chip), "%s: Failed to read PMBR1\n", pwm->label);
183 dev_err(pwmchip_parent(chip), "%s: Failed to request PWM\n", pwm->label);
190 static void twl4030_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
196 if (pwm->hwpwm == 1)
204 dev_err(pwmchip_parent(chip), "%s: Failed to read PMBR1\n", pwm->label);
214 dev_err(pwmchip_parent(chip), "%s: Failed to free PWM\n", pwm->label);
220 static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
228 val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXS | TWL6030_PWMXEN);
229 val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXR);
233 dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label);
243 static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
251 val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXR);
252 val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXS | TWL6030_PWMXEN);
256 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label);
260 val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXEN);
264 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label);
268 val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXEN);
272 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label);
281 static int twl4030_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
290 if (pwm->state.enabled)
291 twl4030_pwm_disable(chip, pwm);
296 err = twl_pwm_config(chip, pwm, state->duty_cycle, state->period);
300 if (!pwm->state.enabled)
301 err = twl4030_pwm_enable(chip, pwm);
306 static int twl6030_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
315 if (pwm->state.enabled)
316 twl6030_pwm_disable(chip, pwm);
321 err = twl_pwm_config(chip, pwm, state->duty_cycle, state->period);
325 if (!pwm->state.enabled)
326 err = twl6030_pwm_enable(chip, pwm);
363 { .compatible = "ti,twl4030-pwm" },
364 { .compatible = "ti,twl6030-pwm" },
372 .name = "twl-pwm",
381 MODULE_ALIAS("platform:twl-pwm");