1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2011 by Marcin Bukat
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 #include "backlight.h"
25 #include "backlight-target.h"
28 bool _backlight_init(void)
30 /* configure PD4 as output */
33 /* set PD4 low (backlight off) */
36 /* IOMUXB - set PWM0 pin as GPIO */
37 SCU_IOMUXB_CON
&= ~(1 << 11); /* type<<11<<channel */
40 PWMT0_CTRL
= (0<<9) | (1<<7);
42 /* set pwm frequency ~10kHz */
43 /* (apb_freq/pwm_freq)/pwm_div = (50 000 000/10 000)/2 */
48 PWMT0_CTRL
= (0<<9) | (1<<3) | (1<<0);
53 void _backlight_on(void)
55 /* enable PWM clock */
56 SCU_CLKCFG
&= ~(1<<29);
58 /* set output pin as PWM pin */
59 SCU_IOMUXB_CON
|= (1<<11); /* type<<11<<channel */
61 /* 100% duty cycle. Other settings doesn't work for
64 PWMT0_HRC
= PWMT0_LRC
;
67 PWMT0_CTRL
|= (1<<3) | (1<<0);
70 void _backlight_off(void)
72 /* setup PWM0 pin as GPIO which is pulled low */
73 SCU_IOMUXB_CON
&= ~(1<<11);
76 PWMT0_CTRL
&= ~(1<<3) | (1<<0);
78 /* disable PWM clock */
79 SCU_CLKCFG
|= (1<<29);
82 void _backlight_set_brightness(int brightness
)
85 /* doesn't work for unknown reason */