Lines Matching full:pwm
4 * JZ4740 platform PWM support
20 #include <linux/pwm.h>
40 /* Enable all TCU channels for PWM use by default except channels 0/1 */ in jz4740_pwm_can_use_chn()
44 "ingenic,pwm-channels-mask", in jz4740_pwm_can_use_chn()
50 static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) in jz4740_pwm_request() argument
57 if (!jz4740_pwm_can_use_chn(jz, pwm->hwpwm)) in jz4740_pwm_request()
60 snprintf(name, sizeof(name), "timer%u", pwm->hwpwm); in jz4740_pwm_request()
73 pwm_set_chip_data(pwm, clk); in jz4740_pwm_request()
78 static void jz4740_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) in jz4740_pwm_free() argument
80 struct clk *clk = pwm_get_chip_data(pwm); in jz4740_pwm_free()
86 static int jz4740_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) in jz4740_pwm_enable() argument
90 /* Enable PWM output */ in jz4740_pwm_enable()
91 regmap_update_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm), in jz4740_pwm_enable()
95 regmap_write(jz->map, TCU_REG_TESR, BIT(pwm->hwpwm)); in jz4740_pwm_enable()
100 static void jz4740_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) in jz4740_pwm_disable() argument
108 regmap_write(jz->map, TCU_REG_TDHRc(pwm->hwpwm), 0xffff); in jz4740_pwm_disable()
109 regmap_write(jz->map, TCU_REG_TDFRc(pwm->hwpwm), 0x0); in jz4740_pwm_disable()
112 * Disable PWM output. in jz4740_pwm_disable()
116 regmap_update_bits(jz->map, TCU_REG_TCSRc(pwm->hwpwm), in jz4740_pwm_disable()
120 regmap_write(jz->map, TCU_REG_TECR, BIT(pwm->hwpwm)); in jz4740_pwm_disable()
123 static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, in jz4740_pwm_apply() argument
126 struct jz4740_pwm_chip *jz4740 = to_jz4740(pwm->chip); in jz4740_pwm_apply()
128 struct clk *clk = pwm_get_chip_data(pwm); in jz4740_pwm_apply()
169 jz4740_pwm_disable(chip, pwm); in jz4740_pwm_apply()
178 regmap_write(jz4740->map, TCU_REG_TCNTc(pwm->hwpwm), 0); in jz4740_pwm_apply()
181 regmap_write(jz4740->map, TCU_REG_TDHRc(pwm->hwpwm), duty); in jz4740_pwm_apply()
184 regmap_write(jz4740->map, TCU_REG_TDFRc(pwm->hwpwm), period); in jz4740_pwm_apply()
187 regmap_update_bits(jz4740->map, TCU_REG_TCSRc(pwm->hwpwm), in jz4740_pwm_apply()
193 * The PWM starts in inactive state until the internal timer reaches the in jz4740_pwm_apply()
196 * value, as a high duty value would otherwise result in the PWM pin in jz4740_pwm_apply()
199 * Here, we don't do that, and instead invert the polarity of the PWM in jz4740_pwm_apply()
200 * when it is active. This trick makes the PWM start with its active in jz4740_pwm_apply()
204 regmap_update_bits(jz4740->map, TCU_REG_TCSRc(pwm->hwpwm), in jz4740_pwm_apply()
207 regmap_update_bits(jz4740->map, TCU_REG_TCSRc(pwm->hwpwm), in jz4740_pwm_apply()
212 jz4740_pwm_enable(chip, pwm); in jz4740_pwm_apply()
265 { .compatible = "ingenic,jz4740-pwm", .data = &jz4740_soc_info },
266 { .compatible = "ingenic,jz4725b-pwm", .data = &jz4725b_soc_info },
267 { .compatible = "ingenic,x1000-pwm", .data = &x1000_soc_info },
275 .name = "jz4740-pwm",
283 MODULE_DESCRIPTION("Ingenic JZ4740 PWM driver");
284 MODULE_ALIAS("platform:jz4740-pwm");