]>
git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/pwm/pwm-imx.c
3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5 * Basic support for the pwm module 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
);
28 int pwm_config(int pwm_id
, int duty_ns
, int period_ns
)
30 struct pwm_regs
*pwm
= (struct pwm_regs
*)pwm_id_to_reg(pwm_id
);
31 unsigned long period_cycles
, duty_cycles
, prescale
;
37 pwm_imx_get_parms(period_ns
, duty_ns
, &period_cycles
, &duty_cycles
,
40 cr
= PWMCR_PRESCALER(prescale
) |
41 PWMCR_DOZEEN
| PWMCR_WAITEN
|
42 PWMCR_DBGEN
| PWMCR_CLKSRC_IPG_HIGH
;
46 writel(duty_cycles
, &pwm
->sar
);
47 /* set period cycles */
48 writel(period_cycles
, &pwm
->pr
);
52 int pwm_enable(int pwm_id
)
54 struct pwm_regs
*pwm
= (struct pwm_regs
*)pwm_id_to_reg(pwm_id
);
59 setbits_le32(&pwm
->cr
, PWMCR_EN
);
63 void pwm_disable(int pwm_id
)
65 struct pwm_regs
*pwm
= (struct pwm_regs
*)pwm_id_to_reg(pwm_id
);
70 clrbits_le32(&pwm
->cr
, PWMCR_EN
);