mipi_orise.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. #include "msm_fb.h"
  14. #include "mipi_dsi.h"
  15. #include "mipi_orise.h"
  16. #include "mdp4.h"
  17. static struct mipi_dsi_panel_platform_data *mipi_orise_pdata;
  18. static struct dsi_buf orise_tx_buf;
  19. static struct dsi_buf orise_rx_buf;
  20. static char enter_sleep[2] = {0x10, 0x00}; /* DTYPE_DCS_WRITE */
  21. static char exit_sleep[2] = {0x11, 0x00}; /* DTYPE_DCS_WRITE */
  22. static char display_off[2] = {0x28, 0x00}; /* DTYPE_DCS_WRITE */
  23. static char display_on[2] = {0x29, 0x00}; /* DTYPE_DCS_WRITE */
  24. static struct dsi_cmd_desc orise_video_on_cmds[] = {
  25. {DTYPE_DCS_WRITE, 1, 0, 0, 10,
  26. sizeof(exit_sleep), exit_sleep},
  27. {DTYPE_DCS_WRITE, 1, 0, 0, 10,
  28. sizeof(display_on), display_on},
  29. };
  30. static struct dsi_cmd_desc orise_cmd_on_cmds[] = {
  31. {DTYPE_DCS_WRITE, 1, 0, 0, 10,
  32. sizeof(exit_sleep), exit_sleep},
  33. {DTYPE_DCS_WRITE, 1, 0, 0, 10,
  34. sizeof(display_on), display_on},
  35. };
  36. static struct dsi_cmd_desc orise_display_off_cmds[] = {
  37. {DTYPE_DCS_WRITE, 1, 0, 0, 10,
  38. sizeof(display_off), display_off},
  39. {DTYPE_DCS_WRITE, 1, 0, 0, 120,
  40. sizeof(enter_sleep), enter_sleep}
  41. };
  42. static int mipi_orise_lcd_on(struct platform_device *pdev)
  43. {
  44. struct msm_fb_data_type *mfd;
  45. struct mipi_panel_info *mipi;
  46. struct msm_panel_info *pinfo;
  47. struct dcs_cmd_req cmdreq;
  48. mfd = platform_get_drvdata(pdev);
  49. if (!mfd)
  50. return -ENODEV;
  51. if (mfd->key != MFD_KEY)
  52. return -EINVAL;
  53. pinfo = &mfd->panel_info;
  54. mipi = &mfd->panel_info.mipi;
  55. memset(&cmdreq, 0, sizeof(cmdreq));
  56. if (mipi->mode == DSI_VIDEO_MODE) {
  57. cmdreq.cmds = orise_video_on_cmds;
  58. cmdreq.cmds_cnt = ARRAY_SIZE(orise_video_on_cmds);
  59. cmdreq.flags = CMD_REQ_COMMIT;
  60. cmdreq.rlen = 0;
  61. cmdreq.cb = NULL;
  62. mipi_dsi_cmdlist_put(&cmdreq);
  63. } else {
  64. cmdreq.cmds = orise_cmd_on_cmds;
  65. cmdreq.cmds_cnt = ARRAY_SIZE(orise_cmd_on_cmds);
  66. cmdreq.flags = CMD_REQ_COMMIT;
  67. cmdreq.rlen = 0;
  68. cmdreq.cb = NULL;
  69. mipi_dsi_cmdlist_put(&cmdreq);
  70. mipi_dsi_cmd_bta_sw_trigger(); /* clean up ack_err_status */
  71. }
  72. return 0;
  73. }
  74. static int mipi_orise_lcd_off(struct platform_device *pdev)
  75. {
  76. struct msm_fb_data_type *mfd;
  77. struct dcs_cmd_req cmdreq;
  78. mfd = platform_get_drvdata(pdev);
  79. if (!mfd)
  80. return -ENODEV;
  81. if (mfd->key != MFD_KEY)
  82. return -EINVAL;
  83. memset(&cmdreq, 0, sizeof(cmdreq));
  84. cmdreq.cmds = orise_display_off_cmds;
  85. cmdreq.cmds_cnt = ARRAY_SIZE(orise_display_off_cmds);
  86. cmdreq.flags = CMD_REQ_COMMIT;
  87. cmdreq.rlen = 0;
  88. cmdreq.cb = NULL;
  89. mipi_dsi_cmdlist_put(&cmdreq);
  90. return 0;
  91. }
  92. static int __devinit mipi_orise_lcd_probe(struct platform_device *pdev)
  93. {
  94. struct msm_fb_data_type *mfd;
  95. struct mipi_panel_info *mipi;
  96. struct platform_device *current_pdev;
  97. static struct mipi_dsi_phy_ctrl *phy_settings;
  98. if (pdev->id == 0) {
  99. mipi_orise_pdata = pdev->dev.platform_data;
  100. if (mipi_orise_pdata
  101. && mipi_orise_pdata->phy_ctrl_settings) {
  102. phy_settings = (mipi_orise_pdata->phy_ctrl_settings);
  103. }
  104. return 0;
  105. }
  106. current_pdev = msm_fb_add_device(pdev);
  107. if (current_pdev) {
  108. mfd = platform_get_drvdata(current_pdev);
  109. if (!mfd)
  110. return -ENODEV;
  111. if (mfd->key != MFD_KEY)
  112. return -EINVAL;
  113. mipi = &mfd->panel_info.mipi;
  114. if (phy_settings != NULL)
  115. mipi->dsi_phy_db = phy_settings;
  116. }
  117. return 0;
  118. }
  119. static struct platform_driver this_driver = {
  120. .probe = mipi_orise_lcd_probe,
  121. .driver = {
  122. .name = "mipi_orise",
  123. },
  124. };
  125. static struct msm_fb_panel_data orise_panel_data = {
  126. .on = mipi_orise_lcd_on,
  127. .off = mipi_orise_lcd_off,
  128. };
  129. static int ch_used[3];
  130. int mipi_orise_device_register(struct msm_panel_info *pinfo,
  131. u32 channel, u32 panel)
  132. {
  133. struct platform_device *pdev = NULL;
  134. int ret;
  135. if ((channel >= 3) || ch_used[channel])
  136. return -ENODEV;
  137. ch_used[channel] = TRUE;
  138. pdev = platform_device_alloc("mipi_orise", (panel << 8)|channel);
  139. if (!pdev)
  140. return -ENOMEM;
  141. orise_panel_data.panel_info = *pinfo;
  142. ret = platform_device_add_data(pdev, &orise_panel_data,
  143. sizeof(orise_panel_data));
  144. if (ret) {
  145. printk(KERN_ERR
  146. "%s: platform_device_add_data failed!\n", __func__);
  147. goto err_device_put;
  148. }
  149. ret = platform_device_add(pdev);
  150. if (ret) {
  151. printk(KERN_ERR
  152. "%s: platform_device_register failed!\n", __func__);
  153. goto err_device_put;
  154. }
  155. return 0;
  156. err_device_put:
  157. platform_device_put(pdev);
  158. return ret;
  159. }
  160. static int __init mipi_orise_lcd_init(void)
  161. {
  162. mipi_dsi_buf_alloc(&orise_tx_buf, DSI_BUF_SIZE);
  163. mipi_dsi_buf_alloc(&orise_rx_buf, DSI_BUF_SIZE);
  164. return platform_driver_register(&this_driver);
  165. }
  166. module_init(mipi_orise_lcd_init);