Chinaunix首页 | 论坛 | 博客

Go

  • 博客访问: 226513
  • 博文数量: 67
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 783
  • 用 户 组: 普通用户
  • 注册时间: 2013-10-12 16:29
文章分类

全部博文(67)

文章存档

2015年(1)

2014年(47)

2013年(19)

我的朋友

分类: LINUX

2014-10-10 11:45:09

原创:kylin_zeng  http://blog.chinaunix.net/uid/23795897.html

lcd 背光灯 pwm  board配置。

点击(此处)折叠或打开

  1. #ifdef CONFIG_BACKLIGHT_RK29_BL
  2. #define PWM_ID 3
  3. #define PWM_MODE     PWM3
  4. #define PWM_EFFECT_VALUE 1

  5. static struct platform_device rk29_device_backlight = {
  6.     .name    = "rk29_backlight",
  7.     .id     = -1,
  8.     .dev    = {
  9.         .platform_data = &rk29_bl_info,
  10.     }
  11. };


  12. static struct rk29_bl_info rk29_bl_info = {
  13.         .min_brightness = 120,//65, //value must between 0~255
  14.         .max_brightness = 255,//150, //value must between 0~255
  15.         .brightness_mode =BRIGHTNESS_MODE_CONIC,
  16.     .pre_div = 30 * 1000, // pwm output clk: 30k;
  17.     .pwm_id = PWM_ID, //3
  18.     .bl_ref = PWM_EFFECT_VALUE, //1
  19.     .io_init = rk29_backlight_io_init,
  20.     .io_deinit = rk29_backlight_io_deinit,
  21.     .pwm_suspend = rk29_backlight_pwm_suspend,
  22.     .pwm_resume = rk29_backlight_pwm_resume,
  23. };


  24. static int rk29_backlight_io_init(void)
  25. {
  26.     int ret = 0;
  27.     iomux_set(PWM_MODE);
  28.     return ret;
  29. }

  30. static int rk29_backlight_io_deinit(void)
  31. {
  32.     int ret = 0, pwm_gpio;
  33.     pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
  34.     gpio_request(pwm_gpio, NULL);
  35.     gpio_direction_output(pwm_gpio, GPIO_LOW);
  36.     return ret;
  37. }


  38. static int rk29_backlight_pwm_suspend(void)
  39. {
  40.     int ret = 0, pwm_gpio;
  41.     pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
  42.     if (gpio_request(pwm_gpio, NULL)) {
  43.         printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
  44.         return -1;
  45.     }
  46.     gpio_direction_output(pwm_gpio, GPIO_LOW);
  47.     return ret;
  48. }

  49. static int rk29_backlight_pwm_resume(void)
  50. {
  51.     int pwm_gpio = iomux_mode_to_gpio(PWM_MODE);
  52.     gpio_free(pwm_gpio);
  53.     iomux_set(PWM_MODE);
  54.     return 0;
  55. }

  56. int iomux_mode_to_gpio(unsigned int mode)
  57. {
  58.         struct union_mode m;

  59.     if(!mode_is_valid(mode)){
  60.         INFO("<%s> mode(0x%x) is invalid\n", __func__, mode);
  61.         return INVALID_GPIO;
  62.     }

  63.         m.mode = mode;
  64.         return PIN_BASE + m.mux.bank * 32 + (m.mux.goff - 0x0A) * 8 + m.mux.off;
  65. }

阅读(1548) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~