• Home
  • Raw
  • Download

Lines Matching +full:kona +full:- +full:pwm

23 #include <linux/pwm.h>
28 * The Kona PWM has some unusual characteristics. Here are the main points.
44 * 5) When the external clock that feeds the PWM is disabled, output is pegged
85 unsigned int value = readl(kp->base + PWM_CONTROL_OFFSET); in kona_pwmc_prepare_for_settings()
89 writel(value, kp->base + PWM_CONTROL_OFFSET); in kona_pwmc_prepare_for_settings()
93 * it. Failing to do this may result in no PWM signal. in kona_pwmc_prepare_for_settings()
100 unsigned int value = readl(kp->base + PWM_CONTROL_OFFSET); in kona_pwmc_apply_settings()
105 writel(value, kp->base + PWM_CONTROL_OFFSET); in kona_pwmc_apply_settings()
111 static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm, in kona_pwmc_config() argument
117 unsigned int value, chan = pwm->hwpwm; in kona_pwmc_config()
130 rate = clk_get_rate(kp->clk); in kona_pwmc_config()
142 return -EINVAL; in kona_pwmc_config()
150 return -EINVAL; in kona_pwmc_config()
158 if (pwm_is_enabled(pwm)) { in kona_pwmc_config()
161 value = readl(kp->base + PRESCALE_OFFSET); in kona_pwmc_config()
164 writel(value, kp->base + PRESCALE_OFFSET); in kona_pwmc_config()
166 writel(pc, kp->base + PERIOD_COUNT_OFFSET(chan)); in kona_pwmc_config()
168 writel(dc, kp->base + DUTY_CYCLE_HIGH_OFFSET(chan)); in kona_pwmc_config()
176 static int kona_pwmc_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm, in kona_pwmc_set_polarity() argument
180 unsigned int chan = pwm->hwpwm; in kona_pwmc_set_polarity()
184 ret = clk_prepare_enable(kp->clk); in kona_pwmc_set_polarity()
186 dev_err(chip->dev, "failed to enable clock: %d\n", ret); in kona_pwmc_set_polarity()
192 value = readl(kp->base + PWM_CONTROL_OFFSET); in kona_pwmc_set_polarity()
199 writel(value, kp->base + PWM_CONTROL_OFFSET); in kona_pwmc_set_polarity()
203 clk_disable_unprepare(kp->clk); in kona_pwmc_set_polarity()
208 static int kona_pwmc_enable(struct pwm_chip *chip, struct pwm_device *pwm) in kona_pwmc_enable() argument
213 ret = clk_prepare_enable(kp->clk); in kona_pwmc_enable()
215 dev_err(chip->dev, "failed to enable clock: %d\n", ret); in kona_pwmc_enable()
219 ret = kona_pwmc_config(chip, pwm, pwm_get_duty_cycle(pwm), in kona_pwmc_enable()
220 pwm_get_period(pwm)); in kona_pwmc_enable()
222 clk_disable_unprepare(kp->clk); in kona_pwmc_enable()
229 static void kona_pwmc_disable(struct pwm_chip *chip, struct pwm_device *pwm) in kona_pwmc_disable() argument
232 unsigned int chan = pwm->hwpwm; in kona_pwmc_disable()
238 writel(0, kp->base + DUTY_CYCLE_HIGH_OFFSET(chan)); in kona_pwmc_disable()
239 writel(0, kp->base + PERIOD_COUNT_OFFSET(chan)); in kona_pwmc_disable()
242 value = readl(kp->base + PRESCALE_OFFSET); in kona_pwmc_disable()
244 writel(value, kp->base + PRESCALE_OFFSET); in kona_pwmc_disable()
248 clk_disable_unprepare(kp->clk); in kona_pwmc_disable()
267 kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL); in kona_pwmc_probe()
269 return -ENOMEM; in kona_pwmc_probe()
273 kp->chip.dev = &pdev->dev; in kona_pwmc_probe()
274 kp->chip.ops = &kona_pwm_ops; in kona_pwmc_probe()
275 kp->chip.base = -1; in kona_pwmc_probe()
276 kp->chip.npwm = 6; in kona_pwmc_probe()
277 kp->chip.of_xlate = of_pwm_xlate_with_flags; in kona_pwmc_probe()
278 kp->chip.of_pwm_n_cells = 3; in kona_pwmc_probe()
281 kp->base = devm_ioremap_resource(&pdev->dev, res); in kona_pwmc_probe()
282 if (IS_ERR(kp->base)) in kona_pwmc_probe()
283 return PTR_ERR(kp->base); in kona_pwmc_probe()
285 kp->clk = devm_clk_get(&pdev->dev, NULL); in kona_pwmc_probe()
286 if (IS_ERR(kp->clk)) { in kona_pwmc_probe()
287 dev_err(&pdev->dev, "failed to get clock: %ld\n", in kona_pwmc_probe()
288 PTR_ERR(kp->clk)); in kona_pwmc_probe()
289 return PTR_ERR(kp->clk); in kona_pwmc_probe()
292 ret = clk_prepare_enable(kp->clk); in kona_pwmc_probe()
294 dev_err(&pdev->dev, "failed to enable clock: %d\n", ret); in kona_pwmc_probe()
299 for (chan = 0; chan < kp->chip.npwm; chan++) in kona_pwmc_probe()
302 writel(value, kp->base + PWM_CONTROL_OFFSET); in kona_pwmc_probe()
304 clk_disable_unprepare(kp->clk); in kona_pwmc_probe()
306 ret = pwmchip_add_with_polarity(&kp->chip, PWM_POLARITY_INVERSED); in kona_pwmc_probe()
308 dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret); in kona_pwmc_probe()
318 for (chan = 0; chan < kp->chip.npwm; chan++) in kona_pwmc_remove()
319 if (pwm_is_enabled(&kp->chip.pwms[chan])) in kona_pwmc_remove()
320 clk_disable_unprepare(kp->clk); in kona_pwmc_remove()
322 return pwmchip_remove(&kp->chip); in kona_pwmc_remove()
326 { .compatible = "brcm,kona-pwm" },
333 .name = "bcm-kona-pwm",
341 MODULE_AUTHOR("Broadcom Corporation <bcm-kernel-feedback-list@broadcom.com>");
343 MODULE_DESCRIPTION("Broadcom Kona PWM driver");