3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5 * Basic support for the pwm modul on imx6.
7 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/arch/imx-regs.h>
15 #include "pwm-imx-util.h"
17 int pwm_init(int pwm_id, int div, int invert)
19 struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id);
25 int pwm_config(int pwm_id, int duty_ns, int period_ns)
27 struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id);
28 unsigned long period_cycles, duty_cycles, prescale;
31 pwm_imx_get_parms(period_ns, duty_ns, &period_cycles, &duty_cycles,
34 cr = PWMCR_PRESCALER(prescale) |
35 PWMCR_DOZEEN | PWMCR_WAITEN |
36 PWMCR_DBGEN | PWMCR_CLKSRC_IPG_HIGH;
40 writel(duty_cycles, &pwm->sar);
41 /* set period cycles */
42 writel(period_cycles, &pwm->pr);
46 int pwm_enable(int pwm_id)
48 struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id);
50 setbits_le32(&pwm->cr, PWMCR_EN);
54 void pwm_disable(int pwm_id)
56 struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id);
58 clrbits_le32(&pwm->cr, PWMCR_EN);