blob: a6890daf202f52a0566af5f5d72308701d2183e4 [file] [log] [blame]
Donghwa Leec8a31782012-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 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
Donghwa Leec8a31782012-07-02 01:16:13 +00009 */
10
11#include <common.h>
12#include <pwm.h>
13#include <linux/types.h>
14#include <asm/io.h>
15#include <asm/arch/cpu.h>
16#include <asm/arch/gpio.h>
17#include <asm/arch/pwm.h>
18#include <asm/arch/pwm_backlight.h>
19
20static struct pwm_backlight_data *pwm;
21
22static int exynos_pwm_backlight_update_status(void)
23{
24 int brightness = pwm->brightness;
25 int max = pwm->max_brightness;
26
27 if (brightness == 0) {
28 pwm_config(pwm->pwm_id, 0, pwm->period);
29 pwm_disable(pwm->pwm_id);
30 } else {
31 pwm_config(pwm->pwm_id,
32 brightness * pwm->period / max, pwm->period);
33 pwm_enable(pwm->pwm_id);
34 }
35 return 0;
36}
37
38int exynos_pwm_backlight_init(struct pwm_backlight_data *pd)
39{
40 pwm = pd;
41
42 exynos_pwm_backlight_update_status();
43
44 return 0;
45}