exynos_pwm_bl.c 926 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. *
  8. * SPDX-License-Identifier: GPL-2.0+
  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. static struct pwm_backlight_data *pwm;
  19. static int exynos_pwm_backlight_update_status(void)
  20. {
  21. int brightness = pwm->brightness;
  22. int max = pwm->max_brightness;
  23. if (brightness == 0) {
  24. pwm_config(pwm->pwm_id, 0, pwm->period);
  25. pwm_disable(pwm->pwm_id);
  26. } else {
  27. pwm_config(pwm->pwm_id,
  28. brightness * pwm->period / max, pwm->period);
  29. pwm_enable(pwm->pwm_id);
  30. }
  31. return 0;
  32. }
  33. int exynos_pwm_backlight_init(struct pwm_backlight_data *pd)
  34. {
  35. pwm = pd;
  36. exynos_pwm_backlight_update_status();
  37. return 0;
  38. }