dsi.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright (c) 2015, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __DSI_CONNECTOR_H__
  14. #define __DSI_CONNECTOR_H__
  15. #include <linux/of_platform.h>
  16. #include <linux/platform_device.h>
  17. #include "drm_crtc.h"
  18. #include "drm_mipi_dsi.h"
  19. #include "drm_panel.h"
  20. #include "msm_drv.h"
  21. #define DSI_0 0
  22. #define DSI_1 1
  23. #define DSI_MAX 2
  24. #define DSI_CLOCK_MASTER DSI_0
  25. #define DSI_CLOCK_SLAVE DSI_1
  26. #define DSI_LEFT DSI_0
  27. #define DSI_RIGHT DSI_1
  28. /* According to the current drm framework sequence, take the encoder of
  29. * DSI_1 as master encoder
  30. */
  31. #define DSI_ENCODER_MASTER DSI_1
  32. #define DSI_ENCODER_SLAVE DSI_0
  33. enum msm_dsi_phy_type {
  34. MSM_DSI_PHY_28NM_HPM,
  35. MSM_DSI_PHY_28NM_LP,
  36. MSM_DSI_PHY_MAX
  37. };
  38. #define DSI_DEV_REGULATOR_MAX 8
  39. /* Regulators for DSI devices */
  40. struct dsi_reg_entry {
  41. char name[32];
  42. int min_voltage;
  43. int max_voltage;
  44. int enable_load;
  45. int disable_load;
  46. };
  47. struct dsi_reg_config {
  48. int num;
  49. struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
  50. };
  51. struct msm_dsi {
  52. struct drm_device *dev;
  53. struct platform_device *pdev;
  54. struct drm_connector *connector;
  55. struct drm_bridge *bridge;
  56. struct mipi_dsi_host *host;
  57. struct msm_dsi_phy *phy;
  58. struct drm_panel *panel;
  59. unsigned long panel_flags;
  60. struct device *phy_dev;
  61. bool phy_enabled;
  62. /* the encoders we are hooked to (outside of dsi block) */
  63. struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM];
  64. int id;
  65. };
  66. /* dsi manager */
  67. struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
  68. void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
  69. struct drm_connector *msm_dsi_manager_connector_init(u8 id);
  70. int msm_dsi_manager_phy_enable(int id,
  71. const unsigned long bit_rate, const unsigned long esc_rate,
  72. u32 *clk_pre, u32 *clk_post);
  73. void msm_dsi_manager_phy_disable(int id);
  74. int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
  75. bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 iova, u32 len);
  76. int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
  77. void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
  78. /* msm dsi */
  79. struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
  80. /* dsi pll */
  81. struct msm_dsi_pll;
  82. #ifdef CONFIG_DRM_MSM_DSI_PLL
  83. struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
  84. enum msm_dsi_phy_type type, int dsi_id);
  85. void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
  86. int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
  87. struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
  88. #else
  89. static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
  90. enum msm_dsi_phy_type type, int id) {
  91. return ERR_PTR(-ENODEV);
  92. }
  93. static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
  94. {
  95. }
  96. static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
  97. struct clk **byte_clk_provider, struct clk **pixel_clk_provider)
  98. {
  99. return -ENODEV;
  100. }
  101. #endif
  102. /* dsi host */
  103. int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
  104. const struct mipi_dsi_msg *msg);
  105. void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
  106. const struct mipi_dsi_msg *msg);
  107. int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
  108. const struct mipi_dsi_msg *msg);
  109. int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
  110. const struct mipi_dsi_msg *msg);
  111. void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
  112. u32 iova, u32 len);
  113. int msm_dsi_host_enable(struct mipi_dsi_host *host);
  114. int msm_dsi_host_disable(struct mipi_dsi_host *host);
  115. int msm_dsi_host_power_on(struct mipi_dsi_host *host);
  116. int msm_dsi_host_power_off(struct mipi_dsi_host *host);
  117. int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
  118. struct drm_display_mode *mode);
  119. struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host,
  120. unsigned long *panel_flags);
  121. int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
  122. void msm_dsi_host_unregister(struct mipi_dsi_host *host);
  123. int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
  124. struct msm_dsi_pll *src_pll);
  125. void msm_dsi_host_destroy(struct mipi_dsi_host *host);
  126. int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
  127. struct drm_device *dev);
  128. int msm_dsi_host_init(struct msm_dsi *msm_dsi);
  129. /* dsi phy */
  130. struct msm_dsi_phy;
  131. void msm_dsi_phy_driver_register(void);
  132. void msm_dsi_phy_driver_unregister(void);
  133. int msm_dsi_phy_enable(struct msm_dsi_phy *phy, bool is_dual_panel,
  134. const unsigned long bit_rate, const unsigned long esc_rate);
  135. int msm_dsi_phy_disable(struct msm_dsi_phy *phy);
  136. void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy,
  137. u32 *clk_pre, u32 *clk_post);
  138. struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
  139. #endif /* __DSI_CONNECTOR_H__ */