Lines Matching full:pwm
3 * PWM Controller Driver for HiSilicon BVT SoCs
15 #include <linux/pwm.h>
82 static void hibvt_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) in hibvt_pwm_enable() argument
86 hibvt_pwm_set_bits(hi_pwm_chip->base, PWM_CTRL_ADDR(pwm->hwpwm), in hibvt_pwm_enable()
90 static void hibvt_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) in hibvt_pwm_disable() argument
94 hibvt_pwm_set_bits(hi_pwm_chip->base, PWM_CTRL_ADDR(pwm->hwpwm), in hibvt_pwm_disable()
98 static void hibvt_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, in hibvt_pwm_config() argument
109 hibvt_pwm_set_bits(hi_pwm_chip->base, PWM_CFG0_ADDR(pwm->hwpwm), in hibvt_pwm_config()
112 hibvt_pwm_set_bits(hi_pwm_chip->base, PWM_CFG1_ADDR(pwm->hwpwm), in hibvt_pwm_config()
117 struct pwm_device *pwm, in hibvt_pwm_set_polarity() argument
123 hibvt_pwm_set_bits(hi_pwm_chip->base, PWM_CTRL_ADDR(pwm->hwpwm), in hibvt_pwm_set_polarity()
126 hibvt_pwm_set_bits(hi_pwm_chip->base, PWM_CTRL_ADDR(pwm->hwpwm), in hibvt_pwm_set_polarity()
130 static int hibvt_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, in hibvt_pwm_get_state() argument
140 value = readl(base + PWM_CFG0_ADDR(pwm->hwpwm)); in hibvt_pwm_get_state()
143 value = readl(base + PWM_CFG1_ADDR(pwm->hwpwm)); in hibvt_pwm_get_state()
146 value = readl(base + PWM_CTRL_ADDR(pwm->hwpwm)); in hibvt_pwm_get_state()
153 static int hibvt_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, in hibvt_pwm_apply() argument
158 if (state->polarity != pwm->state.polarity) in hibvt_pwm_apply()
159 hibvt_pwm_set_polarity(chip, pwm, state->polarity); in hibvt_pwm_apply()
161 if (state->period != pwm->state.period || in hibvt_pwm_apply()
162 state->duty_cycle != pwm->state.duty_cycle) { in hibvt_pwm_apply()
163 hibvt_pwm_config(chip, pwm, state->duty_cycle, state->period); in hibvt_pwm_apply()
166 * Some implementations require the PWM to be enabled twice in hibvt_pwm_apply()
170 hibvt_pwm_enable(chip, pwm); in hibvt_pwm_apply()
173 if (state->enabled != pwm->state.enabled) { in hibvt_pwm_apply()
175 hibvt_pwm_enable(chip, pwm); in hibvt_pwm_apply()
177 hibvt_pwm_disable(chip, pwm); in hibvt_pwm_apply()
261 { .compatible = "hisilicon,hi3516cv300-pwm",
263 { .compatible = "hisilicon,hi3519v100-pwm",
265 { .compatible = "hisilicon,hi3559v100-shub-pwm",
267 { .compatible = "hisilicon,hi3559v100-pwm",
275 .name = "hibvt-pwm",
284 MODULE_DESCRIPTION("HiSilicon BVT SoCs PWM driver");