]>
git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/pwm/pwm-imx-util.c
3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5 * Basic support for the pwm modul on imx6.
7 * Based on linux:drivers/pwm/pwm-imx.c
9 * Sascha Hauer <s.hauer@pengutronix.de>
11 * SPDX-License-Identifier: GPL-2.0
16 #include <asm/arch/imx-regs.h>
18 /* pwm_id from 0..3 */
19 struct pwm_regs
*pwm_id_to_reg(int pwm_id
)
23 return (struct pwm_regs
*)PWM1_BASE_ADDR
;
26 return (struct pwm_regs
*)PWM2_BASE_ADDR
;
29 return (struct pwm_regs
*)PWM3_BASE_ADDR
;
32 return (struct pwm_regs
*)PWM4_BASE_ADDR
;
35 printf("unknown pwm_id: %d\n", pwm_id
);
41 int pwm_imx_get_parms(int period_ns
, int duty_ns
, unsigned long *period_c
,
42 unsigned long *duty_c
, unsigned long *prescale
)
47 * we have not yet a clock framework for imx6, so add the clock
48 * value here as a define. Replace it when we have the clock
51 c
= CONFIG_IMX6_PWM_PER_CLK
;
53 do_div(c
, 1000000000);
56 *prescale
= *period_c
/ 0x10000 + 1;
58 *period_c
/= *prescale
;
59 c
= (unsigned long long)(*period_c
* duty_ns
);
64 * according to imx pwm RM, the real period value should be
65 * PERIOD value in PWMPR plus 2.