cpt_clap070wp03xg_lvds.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef BUILD_LK
  2. #include <linux/string.h>
  3. #endif
  4. #ifdef BUILD_LK
  5. #include <platform/mt_gpio.h>
  6. #include <platform/mt_pmic.h>
  7. #include <debug.h>
  8. #include <platform/upmu_common.h>
  9. #elif (defined BUILD_UBOOT)
  10. #include <asm/arch/mt6577_gpio.h>
  11. #else
  12. #endif
  13. #include "lcm_drv.h"
  14. #include <linux/of_gpio.h>
  15. /* ---------------------------------------------------------------------------
  16. * Local Constants
  17. * ---------------------------------------------------------------------------
  18. */
  19. #define FRAME_WIDTH (800)
  20. #define FRAME_HEIGHT (1280)
  21. #define HSYNC_PULSE_WIDTH 16
  22. #define HSYNC_BACK_PORCH 16
  23. #define HSYNC_FRONT_PORCH 32
  24. #define VSYNC_PULSE_WIDTH 2
  25. #define VSYNC_BACK_PORCH 2
  26. #define VSYNC_FRONT_PORCH 4
  27. #define UDELAY(n) (lcm_util.udelay(n))
  28. #define MDELAY(n) (lcm_util.mdelay(n))
  29. /* ---------------------------------------------------------------------------
  30. Local Variables
  31. ---------------------------------------------------------------------------
  32. */
  33. static LCM_UTIL_FUNCS lcm_util = {0};
  34. static unsigned int GPIO_LCD_PWR_EN;
  35. static bool fgisfirst = true;
  36. void lcm_get_gpio(void)
  37. {
  38. static struct device_node *node;
  39. node = of_find_compatible_node(NULL, NULL, "mediatek,lcm");
  40. GPIO_LCD_PWR_EN = of_get_named_gpio(node, "lcm_power_gpio", 0);
  41. }
  42. /* ---------------------------------------------------------------------------
  43. Local Functions
  44. ---------------------------------------------------------------------------
  45. */
  46. static void lcm_set_gpio_output(unsigned int GPIO, unsigned int output)
  47. {
  48. gpio_direction_output(GPIO, output);
  49. gpio_set_value(GPIO, output);
  50. }
  51. /* ---------------------------------------------------------------------------
  52. LCM Driver Implementations
  53. ---------------------------------------------------------------------------
  54. */
  55. static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
  56. {
  57. memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
  58. }
  59. static void lcm_get_params(LCM_PARAMS *params)
  60. {
  61. memset(params, 0, sizeof(LCM_PARAMS));
  62. params->type = LCM_TYPE_DPI;
  63. params->ctrl = LCM_CTRL_SERIAL_DBI;
  64. params->width = FRAME_WIDTH;
  65. params->height = FRAME_HEIGHT;
  66. params->io_select_mode = 0;
  67. params->dpi.PLL_CLOCK = 67;
  68. params->dpi.clk_pol = LCM_POLARITY_FALLING;
  69. params->dpi.de_pol = LCM_POLARITY_RISING;
  70. params->dpi.vsync_pol = LCM_POLARITY_FALLING;
  71. params->dpi.hsync_pol = LCM_POLARITY_FALLING;
  72. params->dpi.hsync_pulse_width = HSYNC_PULSE_WIDTH;
  73. params->dpi.hsync_back_porch = HSYNC_BACK_PORCH;
  74. params->dpi.hsync_front_porch = HSYNC_FRONT_PORCH;
  75. params->dpi.vsync_pulse_width = VSYNC_PULSE_WIDTH;
  76. params->dpi.vsync_back_porch = VSYNC_BACK_PORCH;
  77. params->dpi.vsync_front_porch = VSYNC_FRONT_PORCH;
  78. params->dpi.lvds_tx_en = 1;
  79. params->dpi.ssc_disable = 1;
  80. params->dpi.format = LCM_DPI_FORMAT_RGB888;
  81. params->dpi.rgb_order = LCM_COLOR_ORDER_RGB;
  82. params->dpi.is_serial_output = 0;
  83. params->dpi.intermediat_buffer_num = 0;
  84. }
  85. static void lcm_init(void)
  86. {
  87. }
  88. static void lcm_suspend(void)
  89. {
  90. lcm_set_gpio_output(GPIO_LCD_PWR_EN, 0);
  91. if (fgisfirst) {
  92. fgisfirst = false;
  93. lcm_vgp_supply_enable();
  94. }
  95. MDELAY(20);
  96. lcm_vgp_supply_disable();
  97. }
  98. static void lcm_resume(void)
  99. {
  100. lcm_vgp_supply_enable();
  101. MDELAY(30);
  102. lcm_set_gpio_output(GPIO_LCD_PWR_EN, 1);
  103. }
  104. LCM_DRIVER cpt_clap070wp03xg_lvds_lcm_drv = {
  105. .name = "cpt_clap070wp03xg_lvds",
  106. .set_util_funcs = lcm_set_util_funcs,
  107. .get_params = lcm_get_params,
  108. .init = lcm_init,
  109. .suspend = lcm_suspend,
  110. .resume = lcm_resume,
  111. };