1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Amaury Pouly 2017-01-11 16:58:30 +01:00 committed by Gerrit Rockbox
parent 759a78e5df
commit b23b7088cb
6 changed files with 312 additions and 5 deletions

View file

@ -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));