Lines Matching refs:pwm
31 #define REG_CTRL(pwm) (((pwm) << 4) + 0x00) argument
32 #define REG_SCALAR(pwm) (((pwm) << 4) + 0x04) argument
33 #define REG_PERIOD(pwm) (((pwm) << 4) + 0x08) argument
34 #define REG_DUTY(pwm) (((pwm) << 4) + 0x0C) argument
72 static int vt8500_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, in vt8500_pwm_config() argument
108 writel(prescale, vt8500->base + REG_SCALAR(pwm->hwpwm)); in vt8500_pwm_config()
109 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_SCALAR_UPDATE); in vt8500_pwm_config()
111 writel(pv, vt8500->base + REG_PERIOD(pwm->hwpwm)); in vt8500_pwm_config()
112 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_PERIOD_UPDATE); in vt8500_pwm_config()
114 writel(dc, vt8500->base + REG_DUTY(pwm->hwpwm)); in vt8500_pwm_config()
115 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_DUTY_UPDATE); in vt8500_pwm_config()
117 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_config()
119 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_config()
120 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); in vt8500_pwm_config()
126 static int vt8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) in vt8500_pwm_enable() argument
138 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_enable()
140 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_enable()
141 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); in vt8500_pwm_enable()
146 static void vt8500_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) in vt8500_pwm_disable() argument
151 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_disable()
153 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_disable()
154 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); in vt8500_pwm_disable()
160 struct pwm_device *pwm, in vt8500_pwm_set_polarity() argument
166 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_set_polarity()
173 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_set_polarity()
174 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); in vt8500_pwm_set_polarity()
179 static int vt8500_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, in vt8500_pwm_apply() argument
183 bool enabled = pwm->state.enabled; in vt8500_pwm_apply()
185 if (state->polarity != pwm->state.polarity) { in vt8500_pwm_apply()
191 vt8500_pwm_disable(chip, pwm); in vt8500_pwm_apply()
196 err = vt8500_pwm_set_polarity(chip, pwm, state->polarity); in vt8500_pwm_apply()
203 vt8500_pwm_disable(chip, pwm); in vt8500_pwm_apply()
215 err = vt8500_pwm_config(pwm->chip, pwm, state->duty_cycle, state->period); in vt8500_pwm_apply()
220 err = vt8500_pwm_enable(chip, pwm); in vt8500_pwm_apply()