Rockchip rk27xx port initial commit. This is still work in progress.
[kugel-rb.git] / firmware / target / arm / rk27xx / backlight-rk27xx.c
blob0d871924ea9421ae82f37046c29586afbfc98a88
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
21 #include <stdbool.h>
23 #include "config.h"
24 #include "backlight.h"
25 #include "backlight-target.h"
26 #include "system.h"
28 bool _backlight_init(void)
30 /* configure PD4 as output */
31 GPIO_PDCON |= (1<<4);
33 /* set PD4 low (backlight off) */
34 GPIO_PDDR &= ~(1<<4);
36 /* IOMUXB - set PWM0 pin as GPIO */
37 SCU_IOMUXB_CON &= ~(1 << 11); /* type<<11<<channel */
39 /* setup pwm */
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 */
44 PWMT0_LRC = 2500;
45 PWMT0_HRC = 1;
47 PWMT0_CNTR = 0x00;
48 PWMT0_CTRL = (0<<9) | (1<<3) | (1<<0);
50 return true;
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
62 * unknown reason
64 PWMT0_HRC = PWMT0_LRC;
66 /* pwm enable */
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);
75 /* stop pwm timer */
76 PWMT0_CTRL &= ~(1<<3) | (1<<0);
78 /* disable PWM clock */
79 SCU_CLKCFG |= (1<<29);
82 void _backlight_set_brightness(int brightness)
84 (void)brightness;
85 /* doesn't work for unknown reason */