exynos_pwm_bl.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. * 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. #include <common.h>
  23. #include <pwm.h>
  24. #include <linux/types.h>
  25. #include <asm/io.h>
  26. #include <asm/arch/cpu.h>
  27. #include <asm/arch/gpio.h>
  28. #include <asm/arch/pwm.h>
  29. #include <asm/arch/pwm_backlight.h>
  30. static struct pwm_backlight_data *pwm;
  31. static int exynos_pwm_backlight_update_status(void)
  32. {
  33. int brightness = pwm->brightness;
  34. int max = pwm->max_brightness;
  35. if (brightness == 0) {
  36. pwm_config(pwm->pwm_id, 0, pwm->period);
  37. pwm_disable(pwm->pwm_id);
  38. } else {
  39. pwm_config(pwm->pwm_id,
  40. brightness * pwm->period / max, pwm->period);
  41. pwm_enable(pwm->pwm_id);
  42. }
  43. return 0;
  44. }
  45. int exynos_pwm_backlight_init(struct pwm_backlight_data *pd)
  46. {
  47. pwm = pd;
  48. exynos_pwm_backlight_update_status();
  49. return 0;
  50. }