From b23b7088cbba364bd37a7ec5e6572f1ecf234e7a Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Wed, 11 Jan 2017 16:58:30 +0100 Subject: imx233: add small framework for LED It handles GPIO and PWM based LEDs, possibly with several channels (red-green LED for example). The debug allows one to play with the setting. Currently the code supports the ZEN, ZEN X-Fi, and ZEN Mozaic. Change-Id: I8c3b66e6ba21778acdb123daabb724280a7d1a4f --- firmware/target/arm/imx233/pwm-imx233.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'firmware/target/arm/imx233/pwm-imx233.c') diff --git a/firmware/target/arm/imx233/pwm-imx233.c b/firmware/target/arm/imx233/pwm-imx233.c index 5e1cc1daa5..3704b60ff2 100644 --- a/firmware/target/arm/imx233/pwm-imx233.c +++ b/firmware/target/arm/imx233/pwm-imx233.c @@ -54,9 +54,18 @@ bool imx233_pwm_is_enabled(int channel) void imx233_pwm_enable(int channel, bool enable) { if(enable) + { + /* claim pin */ + imx233_pinctrl_setup_vpin(VPIN_PWM(channel), "pwm", PINCTRL_DRIVE_4mA, false); BF_SET(PWM_CTRL, PWMx_ENABLE(channel)); + } else + { BF_CLR(PWM_CTRL, PWMx_ENABLE(channel)); + /* stop claiming the pin */ + imx233_pinctrl_release(VPIN_UNPACK_BANK(VPIN_PWM(channel)), + VPIN_UNPACK_PIN(VPIN_PWM(channel)), "pwm"); + } } void imx233_pwm_setup(int channel, int period, int cdiv, int active, @@ -66,8 +75,6 @@ void imx233_pwm_setup(int channel, int period, int cdiv, int active, bool enable = imx233_pwm_is_enabled(channel); if(enable) imx233_pwm_enable(channel, false); - /* setup pin */ - imx233_pinctrl_setup_vpin(VPIN_PWM(channel), "pwm", PINCTRL_DRIVE_4mA, false); /* watch the order ! active THEN period * NOTE: the register value is period-1 */ BF_WR_ALL(PWM_ACTIVEn(channel), ACTIVE(active), INACTIVE(inactive)); -- cgit v1.2.3