summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233/pwm-imx233.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-01-11 16:58:30 +0100
committerGerrit Rockbox <gerrit@rockbox.org>2017-01-16 20:08:13 +0100
commitb23b7088cbba364bd37a7ec5e6572f1ecf234e7a (patch)
tree38fd3014f7f667e0893245d3069e4ee41a9f18a4 /firmware/target/arm/imx233/pwm-imx233.c
parent759a78e5dff134f2632875f61aae60815eea6f5b (diff)
downloadrockbox-b23b7088cbba364bd37a7ec5e6572f1ecf234e7a.tar.gz
rockbox-b23b7088cbba364bd37a7ec5e6572f1ecf234e7a.tar.bz2
rockbox-b23b7088cbba364bd37a7ec5e6572f1ecf234e7a.zip
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
Diffstat (limited to 'firmware/target/arm/imx233/pwm-imx233.c')
-rw-r--r--firmware/target/arm/imx233/pwm-imx233.c11
1 files changed, 9 insertions, 2 deletions
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));