summaryrefslogtreecommitdiff
path: root/firmware/target/arm/rk27xx/backlight-rk27xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/rk27xx/backlight-rk27xx.c')
-rw-r--r--firmware/target/arm/rk27xx/backlight-rk27xx.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/firmware/target/arm/rk27xx/backlight-rk27xx.c b/firmware/target/arm/rk27xx/backlight-rk27xx.c
new file mode 100644
index 0000000000..0d871924ea
--- /dev/null
+++ b/firmware/target/arm/rk27xx/backlight-rk27xx.c
@@ -0,0 +1,86 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 by Marcin Bukat
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <stdbool.h>
22
23#include "config.h"
24#include "backlight.h"
25#include "backlight-target.h"
26#include "system.h"
27
28bool _backlight_init(void)
29{
30 /* configure PD4 as output */
31 GPIO_PDCON |= (1<<4);
32
33 /* set PD4 low (backlight off) */
34 GPIO_PDDR &= ~(1<<4);
35
36 /* IOMUXB - set PWM0 pin as GPIO */
37 SCU_IOMUXB_CON &= ~(1 << 11); /* type<<11<<channel */
38
39 /* setup pwm */
40 PWMT0_CTRL = (0<<9) | (1<<7);
41
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;
46
47 PWMT0_CNTR = 0x00;
48 PWMT0_CTRL = (0<<9) | (1<<3) | (1<<0);
49
50 return true;
51}
52
53void _backlight_on(void)
54{
55 /* enable PWM clock */
56 SCU_CLKCFG &= ~(1<<29);
57
58 /* set output pin as PWM pin */
59 SCU_IOMUXB_CON |= (1<<11); /* type<<11<<channel */
60
61 /* 100% duty cycle. Other settings doesn't work for
62 * unknown reason
63 */
64 PWMT0_HRC = PWMT0_LRC;
65
66 /* pwm enable */
67 PWMT0_CTRL |= (1<<3) | (1<<0);
68}
69
70void _backlight_off(void)
71{
72 /* setup PWM0 pin as GPIO which is pulled low */
73 SCU_IOMUXB_CON &= ~(1<<11);
74
75 /* stop pwm timer */
76 PWMT0_CTRL &= ~(1<<3) | (1<<0);
77
78 /* disable PWM clock */
79 SCU_CLKCFG |= (1<<29);
80}
81
82void _backlight_set_brightness(int brightness)
83{
84 (void)brightness;
85 /* doesn't work for unknown reason */
86}