mipi_chimei_wuxga.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. */
  13. /*
  14. * Chimei WUXGA LVDS Panel driver.
  15. * The panel model is N101JSF-L21.
  16. *
  17. * The panel interface includes:
  18. * 1. LVDS input for video (clock & data).
  19. * 2. few configuration pins to control 3D module: Enable, Mode (2D/3D).
  20. * 3. Backlight LED control (PWM 200 HZ).
  21. *
  22. * This panel is controled via the Toshiba DSI-to-LVDS bridge.
  23. *
  24. */
  25. /* #define DEBUG 1 */
  26. #include "msm_fb.h"
  27. #include "msm_fb_panel.h"
  28. #include "mipi_dsi.h"
  29. #include "mipi_tc358764_dsi2lvds.h"
  30. #define MHZ (1000*1000)
  31. /**
  32. * Panel info parameters.
  33. * The panel info is passed to the mipi framebuffer driver.
  34. */
  35. static struct msm_panel_info chimei_wuxga_pinfo;
  36. /**
  37. * The mipi_dsi_phy_ctrl is calculated according to the
  38. * "dsi_timing_program.xlsm" excel sheet.
  39. * Output is based on: 1200x1920, RGB565, 4 lanes , 58 frames
  40. * per second.
  41. */
  42. static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = {
  43. /* DSIPHY_REGULATOR_CTRL */
  44. .regulator = {0x03, 0x0a, 0x04, 0x00, 0x20}, /* common 8960 */
  45. /* DSIPHY_CTRL */
  46. .ctrl = {0x5f, 0x00, 0x00, 0x10}, /* common 8960 */
  47. /* DSIPHY_STRENGTH_CTRL */
  48. .strength = {0xff, 0x00, 0x06, 0x00}, /* common 8960 */
  49. /* DSIPHY_TIMING_CTRL */
  50. .timing = { 0xC9, 0x92, 0x29, /* panel specific */
  51. 0, /* DSIPHY_TIMING_CTRL_3 = 0 */
  52. 0x2D, 0x9B, 0x2B, 0x94, 0x2D, 0x03, 0x04}, /* panel specific */
  53. /* DSIPHY_PLL_CTRL */
  54. .pll = { 0x00, /* common 8960 */
  55. /* VCO */
  56. 0x30, (0x01 | 0x30) , (0x19 | 0xC0), /* panel specific */
  57. 0x00, 0x50, 0x48, 0x63,
  58. 0x77, 0x88, 0x99, /* Auto update by dsi-mipi driver */
  59. 0x00, 0x14, 0x03, 0x00, 0x02, /* common 8960 */
  60. 0x00, 0x20, 0x00, 0x01 }, /* common 8960 */
  61. };
  62. /**
  63. * Module init.
  64. *
  65. * Register the panel-info.
  66. *
  67. * Some parameters are from the panel datasheet
  68. * and other are *calculated* by the "dsi_timing_program.xlsm"
  69. * excel file
  70. *
  71. * @return int
  72. */
  73. static int __init mipi_chimei_wuxga_init(void)
  74. {
  75. int ret;
  76. struct msm_panel_info *pinfo = &chimei_wuxga_pinfo;
  77. if (msm_fb_detect_client("mipi_video_chimei_wuxga"))
  78. return 0;
  79. pr_info("mipi-dsi chimei wuxga (1200x1920) driver ver 1.0.\n");
  80. /* Portrait */
  81. pinfo->xres = 1200;
  82. pinfo->yres = 1920;
  83. pinfo->type = MIPI_VIDEO_PANEL;
  84. pinfo->pdest = DISPLAY_1; /* Primary Display */
  85. pinfo->wait_cycle = 0;
  86. pinfo->bpp = 24; /* RGB565 requires 24 bits-per-pixel :-O */
  87. pinfo->fb_num = 2; /* using two frame buffers */
  88. /*
  89. * The CMI panel requires 80 MHZ LVDS-CLK.
  90. * The D2L bridge drives the LVDS-CLK from the DSI-CLK.
  91. * The DSI-CLK = bitclk/2, 640 MHZ/2= 320 MHZ.
  92. * LVDS-CLK = DSI-CLK/4 , 320 MHZ/4= 80 MHZ.
  93. */
  94. pinfo->clk_rate = 635 * MHZ ; /* bitclk Calculated */
  95. /*
  96. * this panel is operated by DE,
  97. * vsycn and hsync are ignored
  98. */
  99. pinfo->lcdc.h_front_porch = 160-48-32; /* thfp */
  100. pinfo->lcdc.h_back_porch = 48; /* thb */
  101. pinfo->lcdc.h_pulse_width = 32; /* thpw */
  102. pinfo->lcdc.v_front_porch = 26-3-6; /* tvfp */
  103. pinfo->lcdc.v_back_porch = 3; /* tvb */
  104. pinfo->lcdc.v_pulse_width = 6; /* tvpw */
  105. pinfo->lcdc.border_clr = 0; /* black */
  106. pinfo->lcdc.underflow_clr = 0xff; /* blue */
  107. pinfo->lcdc.hsync_skew = 0;
  108. /* Backlight levels - controled via PMIC pwm gpio */
  109. pinfo->bl_max = PWM_LEVEL;
  110. pinfo->bl_min = 1;
  111. /* mipi - general */
  112. pinfo->mipi.vc = 0; /* virtual channel */
  113. pinfo->mipi.rgb_swap = DSI_RGB_SWAP_RGB;
  114. pinfo->mipi.tx_eot_append = true;
  115. pinfo->mipi.t_clk_post = 34; /* Calculated */
  116. pinfo->mipi.t_clk_pre = 69; /* Calculated */
  117. pinfo->mipi.dsi_phy_db = &dsi_video_mode_phy_db;
  118. /* Four lanes are recomended for 1920x1200 at 60 frames per second */
  119. pinfo->mipi.frame_rate = 60;
  120. pinfo->mipi.data_lane0 = true;
  121. pinfo->mipi.data_lane1 = true;
  122. pinfo->mipi.data_lane2 = true;
  123. pinfo->mipi.data_lane3 = true;
  124. pinfo->mipi.esc_byte_ratio = 6;
  125. pinfo->mipi.mode = DSI_VIDEO_MODE;
  126. /*
  127. * Note: The CMI panel input is RGB888,
  128. * thus the DSI-to-LVDS bridge output is RGB888.
  129. * This parameter selects the DSI-Core output to the bridge.
  130. */
  131. pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB565;
  132. /* mipi - video mode */
  133. pinfo->mipi.traffic_mode = DSI_NON_BURST_SYNCH_EVENT;
  134. pinfo->mipi.pulse_mode_hsa_he = false; /* sync mode */
  135. pinfo->mipi.hfp_power_stop = false;
  136. pinfo->mipi.hbp_power_stop = false;
  137. pinfo->mipi.hsa_power_stop = false;
  138. pinfo->mipi.eof_bllp_power_stop = false;
  139. pinfo->mipi.bllp_power_stop = false;
  140. /* mipi - command mode */
  141. pinfo->mipi.te_sel = 1; /* TE from vsycn gpio */
  142. pinfo->mipi.interleave_max = 1;
  143. /* The bridge supports only Generic Read/Write commands */
  144. pinfo->mipi.insert_dcs_cmd = false;
  145. pinfo->mipi.wr_mem_continue = 0;
  146. pinfo->mipi.wr_mem_start = 0;
  147. pinfo->mipi.stream = false; /* dma_p */
  148. pinfo->mipi.mdp_trigger = DSI_CMD_TRIGGER_NONE;
  149. pinfo->mipi.dma_trigger = DSI_CMD_TRIGGER_SW;
  150. /*
  151. * toshiba d2l chip does not need max_pkt_size dcs cmd
  152. * client reply len is directly configure through
  153. * RDPKTLN register (0x0404)
  154. */
  155. pinfo->mipi.no_max_pkt_size = 1;
  156. pinfo->mipi.force_clk_lane_hs = 1;
  157. pinfo->is_3d_panel = FB_TYPE_3D_PANEL;
  158. ret = mipi_tc358764_dsi2lvds_register(pinfo, MIPI_DSI_PRIM, 1);
  159. if (ret)
  160. pr_err("%s: failed to register device!\n", __func__);
  161. return ret;
  162. }
  163. module_init(mipi_chimei_wuxga_init);
  164. MODULE_LICENSE("GPL v2");
  165. MODULE_DESCRIPTION("Chimei WUXGA LVDS Panel driver");
  166. MODULE_AUTHOR("Amir Samuelov <amirs@codeaurora.org>");