summaryrefslogtreecommitdiff
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.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)
54void imx233_pwm_enable(int channel, bool enable) 54void imx233_pwm_enable(int channel, bool enable)
55{ 55{
56 if(enable) 56 if(enable)
57 {
58 /* claim pin */
59 imx233_pinctrl_setup_vpin(VPIN_PWM(channel), "pwm", PINCTRL_DRIVE_4mA, false);
57 BF_SET(PWM_CTRL, PWMx_ENABLE(channel)); 60 BF_SET(PWM_CTRL, PWMx_ENABLE(channel));
61 }
58 else 62 else
63 {
59 BF_CLR(PWM_CTRL, PWMx_ENABLE(channel)); 64 BF_CLR(PWM_CTRL, PWMx_ENABLE(channel));
65 /* stop claiming the pin */
66 imx233_pinctrl_release(VPIN_UNPACK_BANK(VPIN_PWM(channel)),
67 VPIN_UNPACK_PIN(VPIN_PWM(channel)), "pwm");
68 }
60} 69}
61 70
62void imx233_pwm_setup(int channel, int period, int cdiv, int active, 71void 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,
66 bool enable = imx233_pwm_is_enabled(channel); 75 bool enable = imx233_pwm_is_enabled(channel);
67 if(enable) 76 if(enable)
68 imx233_pwm_enable(channel, false); 77 imx233_pwm_enable(channel, false);
69 /* setup pin */
70 imx233_pinctrl_setup_vpin(VPIN_PWM(channel), "pwm", PINCTRL_DRIVE_4mA, false);
71 /* watch the order ! active THEN period 78 /* watch the order ! active THEN period
72 * NOTE: the register value is period-1 */ 79 * NOTE: the register value is period-1 */
73 BF_WR_ALL(PWM_ACTIVEn(channel), ACTIVE(active), INACTIVE(inactive)); 80 BF_WR_ALL(PWM_ACTIVEn(channel), ACTIVE(active), INACTIVE(inactive));