Lines Matching full:pwm

12 #include <linux/pwm.h>
32 #define TWL4030_PWM_TOGGLE(pwm, x) ((x) << (pwm)) argument
46 #define TWL6030_PWM_TOGGLE(pwm, x) ((x) << (pwm * 3)) argument
59 static int twl_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, in twl_pwm_config() argument
75 * When on cycle == off cycle the PWM will be always on in twl_pwm_config()
82 base = pwm->hwpwm * 3; in twl_pwm_config()
88 dev_err(pwmchip_parent(chip), "%s: Failed to configure PWM\n", pwm->label); in twl_pwm_config()
93 static int twl4030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) in twl4030_pwm_enable() argument
102 dev_err(pwmchip_parent(chip), "%s: Failed to read GPBR1\n", pwm->label); in twl4030_pwm_enable()
106 val |= TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMXCLK_ENABLE); in twl4030_pwm_enable()
110 dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label); in twl4030_pwm_enable()
112 val |= TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMX_ENABLE); in twl4030_pwm_enable()
116 dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label); in twl4030_pwm_enable()
123 static void twl4030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) in twl4030_pwm_disable() argument
132 dev_err(pwmchip_parent(chip), "%s: Failed to read GPBR1\n", pwm->label); in twl4030_pwm_disable()
136 val &= ~TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMX_ENABLE); in twl4030_pwm_disable()
140 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label); in twl4030_pwm_disable()
142 val &= ~TWL4030_PWM_TOGGLE(pwm->hwpwm, TWL4030_PWMXCLK_ENABLE); in twl4030_pwm_disable()
146 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label); in twl4030_pwm_disable()
152 static int twl4030_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) in twl4030_pwm_request() argument
158 if (pwm->hwpwm == 1) { in twl4030_pwm_request()
169 dev_err(pwmchip_parent(chip), "%s: Failed to read PMBR1\n", pwm->label); in twl4030_pwm_request()
173 /* Save the current MUX configuration for the PWM */ in twl4030_pwm_request()
177 /* Select PWM functionality */ in twl4030_pwm_request()
183 dev_err(pwmchip_parent(chip), "%s: Failed to request PWM\n", pwm->label); in twl4030_pwm_request()
190 static void twl4030_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) in twl4030_pwm_free() argument
196 if (pwm->hwpwm == 1) in twl4030_pwm_free()
204 dev_err(pwmchip_parent(chip), "%s: Failed to read PMBR1\n", pwm->label); in twl4030_pwm_free()
208 /* Restore the MUX configuration for the PWM */ in twl4030_pwm_free()
214 dev_err(pwmchip_parent(chip), "%s: Failed to free PWM\n", pwm->label); in twl4030_pwm_free()
220 static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) in twl6030_pwm_enable() argument
228 val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXS | TWL6030_PWMXEN); in twl6030_pwm_enable()
229 val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXR); in twl6030_pwm_enable()
233 dev_err(pwmchip_parent(chip), "%s: Failed to enable PWM\n", pwm->label); in twl6030_pwm_enable()
243 static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) in twl6030_pwm_disable() argument
251 val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXR); in twl6030_pwm_disable()
252 val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXS | TWL6030_PWMXEN); in twl6030_pwm_disable()
256 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label); in twl6030_pwm_disable()
260 val |= TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXEN); in twl6030_pwm_disable()
264 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label); in twl6030_pwm_disable()
268 val &= ~TWL6030_PWM_TOGGLE(pwm->hwpwm, TWL6030_PWMXEN); in twl6030_pwm_disable()
272 dev_err(pwmchip_parent(chip), "%s: Failed to disable PWM\n", pwm->label); in twl6030_pwm_disable()
281 static int twl4030_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, in twl4030_pwm_apply() argument
290 if (pwm->state.enabled) in twl4030_pwm_apply()
291 twl4030_pwm_disable(chip, pwm); in twl4030_pwm_apply()
296 err = twl_pwm_config(chip, pwm, state->duty_cycle, state->period); in twl4030_pwm_apply()
300 if (!pwm->state.enabled) in twl4030_pwm_apply()
301 err = twl4030_pwm_enable(chip, pwm); in twl4030_pwm_apply()
306 static int twl6030_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, in twl6030_pwm_apply() argument
315 if (pwm->state.enabled) in twl6030_pwm_apply()
316 twl6030_pwm_disable(chip, pwm); in twl6030_pwm_apply()
321 err = twl_pwm_config(chip, pwm, state->duty_cycle, state->period); in twl6030_pwm_apply()
325 if (!pwm->state.enabled) in twl6030_pwm_apply()
326 err = twl6030_pwm_enable(chip, pwm); in twl6030_pwm_apply()
363 { .compatible = "ti,twl4030-pwm" },
364 { .compatible = "ti,twl6030-pwm" },
372 .name = "twl-pwm",
380 MODULE_DESCRIPTION("PWM driver for TWL4030 and TWL6030");
381 MODULE_ALIAS("platform:twl-pwm");