lvds_frc_fhd.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /* Copyright (c) 2012, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <mach/gpio.h>
  13. #include "msm_fb.h"
  14. static struct lvds_panel_platform_data *frc_pdata;
  15. static struct platform_device *frc_fbpdev;
  16. static int gpio_update; /* 268 */
  17. static int gpio_reset; /* 269 */
  18. static int gpio_pwr; /* 270 */
  19. static int lvds_frc_panel_on(struct platform_device *pdev)
  20. {
  21. int ret;
  22. ret = gpio_request(gpio_pwr, "frc_pwr");
  23. if (ret) {
  24. pr_err("%s: gpio_pwr=%d, gpio_request failed\n",
  25. __func__, gpio_pwr);
  26. goto panel_on_exit;
  27. }
  28. ret = gpio_request(gpio_update, "frc_update");
  29. if (ret) {
  30. pr_err("%s: gpio_update=%d, gpio_request failed\n",
  31. __func__, gpio_update);
  32. goto panel_on_exit1;
  33. }
  34. ret = gpio_request(gpio_reset, "frc_reset");
  35. if (ret) {
  36. pr_err("%s: gpio_reset=%d, gpio_request failed\n",
  37. __func__, gpio_reset);
  38. goto panel_on_exit2;
  39. }
  40. gpio_direction_output(gpio_reset, 1);
  41. gpio_direction_output(gpio_pwr, 0);
  42. gpio_direction_output(gpio_update, 0);
  43. usleep(1000);
  44. gpio_direction_output(gpio_reset, 0);
  45. usleep(1000);
  46. gpio_direction_output(gpio_pwr, 1);
  47. usleep(1000);
  48. gpio_direction_output(gpio_update, 1);
  49. usleep(1000);
  50. gpio_direction_output(gpio_reset, 1);
  51. usleep(1000);
  52. gpio_free(gpio_reset);
  53. panel_on_exit2:
  54. gpio_free(gpio_update);
  55. panel_on_exit1:
  56. gpio_free(gpio_pwr);
  57. panel_on_exit:
  58. return ret;
  59. }
  60. static int lvds_frc_panel_off(struct platform_device *pdev)
  61. {
  62. int ret;
  63. ret = gpio_request(gpio_pwr, "frc_pwr");
  64. if (ret) {
  65. pr_err("%s: gpio_pwr=%d, gpio_request failed\n",
  66. __func__, gpio_pwr);
  67. goto panel_off_exit;
  68. }
  69. ret = gpio_request(gpio_update, "frc_update");
  70. if (ret) {
  71. pr_err("%s: gpio_update=%d, gpio_request failed\n",
  72. __func__, gpio_update);
  73. goto panel_off_exit1;
  74. }
  75. ret = gpio_request(gpio_reset, "frc_reset");
  76. if (ret) {
  77. pr_err("%s: gpio_reset=%d, gpio_request failed\n",
  78. __func__, gpio_reset);
  79. goto panel_off_exit2;
  80. }
  81. gpio_direction_output(gpio_reset, 0);
  82. usleep(1000);
  83. gpio_direction_output(gpio_update, 0);
  84. usleep(1000);
  85. gpio_direction_output(gpio_pwr, 0);
  86. usleep(1000);
  87. gpio_free(gpio_reset);
  88. panel_off_exit2:
  89. gpio_free(gpio_update);
  90. panel_off_exit1:
  91. gpio_free(gpio_pwr);
  92. panel_off_exit:
  93. return ret;
  94. }
  95. static int __devinit lvds_frc_probe(struct platform_device *pdev)
  96. {
  97. int rc = 0;
  98. if (pdev->id == 0) {
  99. frc_pdata = pdev->dev.platform_data;
  100. if (frc_pdata != NULL) {
  101. gpio_update = frc_pdata->gpio[0];
  102. gpio_reset = frc_pdata->gpio[1];
  103. gpio_pwr = frc_pdata->gpio[2];
  104. pr_info("%s: power=%d update=%d reset=%d\n",
  105. __func__, gpio_pwr, gpio_update, gpio_reset);
  106. }
  107. return 0;
  108. }
  109. frc_fbpdev = msm_fb_add_device(pdev);
  110. if (!frc_fbpdev) {
  111. dev_err(&pdev->dev, "failed to add msm_fb device\n");
  112. rc = -ENODEV;
  113. goto probe_exit;
  114. }
  115. probe_exit:
  116. return rc;
  117. }
  118. static struct platform_driver this_driver = {
  119. .probe = lvds_frc_probe,
  120. .driver = {
  121. .name = "lvds_frc_fhd",
  122. },
  123. };
  124. static struct msm_fb_panel_data lvds_frc_panel_data = {
  125. .on = lvds_frc_panel_on,
  126. .off = lvds_frc_panel_off,
  127. };
  128. static struct platform_device this_device = {
  129. .name = "lvds_frc_fhd",
  130. .id = 1,
  131. .dev = {
  132. .platform_data = &lvds_frc_panel_data,
  133. }
  134. };
  135. static int __init lvds_frc_fhd_init(void)
  136. {
  137. int ret;
  138. struct msm_panel_info *pinfo;
  139. if (msm_fb_detect_client("lvds_frc_fhd"))
  140. return 0;
  141. ret = platform_driver_register(&this_driver);
  142. if (ret)
  143. return ret;
  144. pinfo = &lvds_frc_panel_data.panel_info;
  145. pinfo->xres = 1920;
  146. pinfo->yres = 1080;
  147. MSM_FB_SINGLE_MODE_PANEL(pinfo);
  148. pinfo->type = LVDS_PANEL;
  149. pinfo->pdest = DISPLAY_1;
  150. pinfo->wait_cycle = 0;
  151. pinfo->bpp = 24;
  152. pinfo->fb_num = 2;
  153. pinfo->clk_rate = 74250000;
  154. pinfo->bl_max = 255;
  155. pinfo->bl_min = 1;
  156. /*
  157. * use hdmi 1080p60 setting, for dual channel mode,
  158. * horizontal length is half.
  159. */
  160. pinfo->lcdc.h_back_porch = 148/2;
  161. pinfo->lcdc.h_front_porch = 88/2;
  162. pinfo->lcdc.h_pulse_width = 44/2;
  163. pinfo->lcdc.v_back_porch = 36;
  164. pinfo->lcdc.v_front_porch = 4;
  165. pinfo->lcdc.v_pulse_width = 5;
  166. pinfo->lcdc.underflow_clr = 0xff;
  167. pinfo->lcdc.hsync_skew = 0;
  168. pinfo->lvds.channel_mode = LVDS_DUAL_CHANNEL_MODE;
  169. pinfo->lcdc.is_sync_active_high = TRUE;
  170. /* Set border color, padding only for reducing active display region */
  171. pinfo->lcdc.border_clr = 0x0;
  172. pinfo->lcdc.xres_pad = 0;
  173. pinfo->lcdc.yres_pad = 0;
  174. ret = platform_device_register(&this_device);
  175. if (ret)
  176. platform_driver_unregister(&this_driver);
  177. return ret;
  178. }
  179. module_init(lvds_frc_fhd_init);