Donghwa Lee | c8a3178 | 2012-07-02 01:16:13 +0000 | [diff] [blame] | 1 | /* |
| 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 Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
Donghwa Lee | c8a3178 | 2012-07-02 01:16:13 +0000 | [diff] [blame] | 9 | */ |
| 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 | |
| 20 | static struct pwm_backlight_data *pwm; |
| 21 | |
| 22 | static 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 | |
| 38 | int 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 | } |