blob: a3d467aa23b5cb79b914ec152030d03da0f89573 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Donghwa Leec8a31782012-07-02 01:16:13 +00002/*
3 * PWM BACKLIGHT driver for Board based on EXYNOS.
4 *
5 * Author: Donghwa Lee <dh09.lee@samsung.com>
6 *
7 * Derived from linux/drivers/video/backlight/pwm_backlight.c
Donghwa Leec8a31782012-07-02 01:16:13 +00008 */
9
10#include <common.h>
11#include <pwm.h>
12#include <linux/types.h>
13#include <asm/io.h>
14#include <asm/arch/cpu.h>
15#include <asm/arch/gpio.h>
16#include <asm/arch/pwm.h>
17#include <asm/arch/pwm_backlight.h>
18
19static struct pwm_backlight_data *pwm;
20
21static int exynos_pwm_backlight_update_status(void)
22{
23 int brightness = pwm->brightness;
24 int max = pwm->max_brightness;
25
26 if (brightness == 0) {
27 pwm_config(pwm->pwm_id, 0, pwm->period);
28 pwm_disable(pwm->pwm_id);
29 } else {
30 pwm_config(pwm->pwm_id,
31 brightness * pwm->period / max, pwm->period);
32 pwm_enable(pwm->pwm_id);
33 }
34 return 0;
35}
36
37int exynos_pwm_backlight_init(struct pwm_backlight_data *pd)
38{
39 pwm = pd;
40
41 exynos_pwm_backlight_update_status();
42
43 return 0;
44}