blob: 27fb0b5e7ea1fe32d93eb797542e08be978ac6bc [file] [log] [blame]
Donghwa Lee6fff52b2012-07-02 01:16:13 +00001/*
2 * PWM BACKLIGHT driver for Board based on EXYNOS.
3 *
4 * Author: Donghwa Lee <dh09.lee@samsung.com>
5 *
6 * Derived from linux/drivers/video/backlight/pwm_backlight.c
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23#include <common.h>
24#include <pwm.h>
25#include <linux/types.h>
26#include <asm/io.h>
27#include <asm/arch/cpu.h>
28#include <asm/arch/gpio.h>
29#include <asm/arch/pwm.h>
30#include <asm/arch/pwm_backlight.h>
31
32static struct pwm_backlight_data *pwm;
33
34static int exynos_pwm_backlight_update_status(void)
35{
36 int brightness = pwm->brightness;
37 int max = pwm->max_brightness;
38
39 if (brightness == 0) {
40 pwm_config(pwm->pwm_id, 0, pwm->period);
41 pwm_disable(pwm->pwm_id);
42 } else {
43 pwm_config(pwm->pwm_id,
44 brightness * pwm->period / max, pwm->period);
45 pwm_enable(pwm->pwm_id);
46 }
47 return 0;
48}
49
50int exynos_pwm_backlight_init(struct pwm_backlight_data *pd)
51{
52 pwm = pd;
53
54 exynos_pwm_backlight_update_status();
55
56 return 0;
57}