Lines Matching full:pwm
19 #include <linux/pwm.h>
23 /* PWM registers and bits definitions */
44 * struct pwm_mediatek_chip - struct representing PWM chip
45 * @chip: linux PWM chip representation
46 * @regs: base address of PWM chip
48 * @clk_main: the clock used by PWM core
49 * @clk_pwms: the clock used by each PWM channel
73 struct pwm_device *pwm) in pwm_mediatek_clk_enable() argument
86 ret = clk_prepare_enable(pc->clk_pwms[pwm->hwpwm]); in pwm_mediatek_clk_enable()
101 struct pwm_device *pwm) in pwm_mediatek_clk_disable() argument
105 clk_disable_unprepare(pc->clk_pwms[pwm->hwpwm]); in pwm_mediatek_clk_disable()
117 static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm, in pwm_mediatek_config() argument
126 ret = pwm_mediatek_clk_enable(chip, pwm); in pwm_mediatek_config()
137 do_div(resolution, clk_get_rate(pc->clk_pwms[pwm->hwpwm])); in pwm_mediatek_config()
148 pwm_mediatek_clk_disable(chip, pwm); in pwm_mediatek_config()
153 if (pc->soc->pwm45_fixup && pwm->hwpwm > 2) { in pwm_mediatek_config()
155 * PWM[4,5] has distinct offset for PWMDWIDTH and PWMTHRES in pwm_mediatek_config()
163 pwm_mediatek_writel(pc, pwm->hwpwm, PWMCON, BIT(15) | clkdiv); in pwm_mediatek_config()
164 pwm_mediatek_writel(pc, pwm->hwpwm, reg_width, cnt_period); in pwm_mediatek_config()
165 pwm_mediatek_writel(pc, pwm->hwpwm, reg_thres, cnt_duty); in pwm_mediatek_config()
167 pwm_mediatek_clk_disable(chip, pwm); in pwm_mediatek_config()
172 static int pwm_mediatek_enable(struct pwm_chip *chip, struct pwm_device *pwm) in pwm_mediatek_enable() argument
178 ret = pwm_mediatek_clk_enable(chip, pwm); in pwm_mediatek_enable()
183 value |= BIT(pwm->hwpwm); in pwm_mediatek_enable()
189 static void pwm_mediatek_disable(struct pwm_chip *chip, struct pwm_device *pwm) in pwm_mediatek_disable() argument
195 value &= ~BIT(pwm->hwpwm); in pwm_mediatek_disable()
198 pwm_mediatek_clk_disable(chip, pwm); in pwm_mediatek_disable()
201 static int pwm_mediatek_apply(struct pwm_chip *chip, struct pwm_device *pwm, in pwm_mediatek_apply() argument
210 if (pwm->state.enabled) in pwm_mediatek_apply()
211 pwm_mediatek_disable(chip, pwm); in pwm_mediatek_apply()
216 err = pwm_mediatek_config(pwm->chip, pwm, state->duty_cycle, state->period); in pwm_mediatek_apply()
220 if (!pwm->state.enabled) in pwm_mediatek_apply()
221 err = pwm_mediatek_enable(chip, pwm); in pwm_mediatek_apply()
265 snprintf(name, sizeof(name), "pwm%d", i + 1); in pwm_mediatek_probe()
339 { .compatible = "mediatek,mt2712-pwm", .data = &mt2712_pwm_data },
340 { .compatible = "mediatek,mt6795-pwm", .data = &mt6795_pwm_data },
341 { .compatible = "mediatek,mt7622-pwm", .data = &mt7622_pwm_data },
342 { .compatible = "mediatek,mt7623-pwm", .data = &mt7623_pwm_data },
343 { .compatible = "mediatek,mt7628-pwm", .data = &mt7628_pwm_data },
344 { .compatible = "mediatek,mt7629-pwm", .data = &mt7629_pwm_data },
345 { .compatible = "mediatek,mt8183-pwm", .data = &mt8183_pwm_data },
346 { .compatible = "mediatek,mt8365-pwm", .data = &mt8365_pwm_data },
347 { .compatible = "mediatek,mt8516-pwm", .data = &mt8516_pwm_data },
354 .name = "pwm-mediatek",