dsi.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. enum msm_dsi_phy_type {
  25. MSM_DSI_PHY_28NM_HPM,
  26. MSM_DSI_PHY_28NM_LP,
  27. MSM_DSI_PHY_20NM,
  28. MSM_DSI_PHY_MAX
  29. };
  30. #define DSI_DEV_REGULATOR_MAX 8
  31. /* Regulators for DSI devices */
  32. struct dsi_reg_entry {
  33. char name[32];
  34. int min_voltage;
  35. int max_voltage;
  36. int enable_load;
  37. int disable_load;
  38. };
  39. struct dsi_reg_config {
  40. int num;
  41. struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
  42. };
  43. struct msm_dsi {
  44. struct drm_device *dev;
  45. struct platform_device *pdev;
  46. /* connector managed by us when we're connected to a drm_panel */
  47. struct drm_connector *connector;
  48. /* internal dsi bridge attached to MDP interface */
  49. struct drm_bridge *bridge;
  50. struct mipi_dsi_host *host;
  51. struct msm_dsi_phy *phy;
  52. /*
  53. * panel/external_bridge connected to dsi bridge output, only one of the
  54. * two can be valid at a time
  55. */
  56. struct drm_panel *panel;
  57. struct drm_bridge *external_bridge;
  58. unsigned long device_flags;
  59. struct device *phy_dev;
  60. bool phy_enabled;
  61. /* the encoders we are hooked to (outside of dsi block) */
  62. struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM];
  63. int id;
  64. };
  65. /* dsi manager */
  66. struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
  67. void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
  68. struct drm_connector *msm_dsi_manager_connector_init(u8 id);
  69. struct drm_connector *msm_dsi_manager_ext_bridge_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. static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
  80. {
  81. return msm_dsi->panel || msm_dsi->external_bridge;
  82. }
  83. struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
  84. /* dsi pll */
  85. struct msm_dsi_pll;
  86. #ifdef CONFIG_DRM_MSM_DSI_PLL
  87. struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
  88. enum msm_dsi_phy_type type, int dsi_id);
  89. void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
  90. int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
  91. struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
  92. void msm_dsi_pll_save_state(struct msm_dsi_pll *pll);
  93. int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll);
  94. #else
  95. static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
  96. enum msm_dsi_phy_type type, int id) {
  97. return ERR_PTR(-ENODEV);
  98. }
  99. static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
  100. {
  101. }
  102. static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
  103. struct clk **byte_clk_provider, struct clk **pixel_clk_provider)
  104. {
  105. return -ENODEV;
  106. }
  107. static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll)
  108. {
  109. }
  110. static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll)
  111. {
  112. return 0;
  113. }
  114. #endif
  115. /* dsi host */
  116. int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
  117. const struct mipi_dsi_msg *msg);
  118. void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
  119. const struct mipi_dsi_msg *msg);
  120. int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
  121. const struct mipi_dsi_msg *msg);
  122. int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
  123. const struct mipi_dsi_msg *msg);
  124. void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
  125. u32 iova, u32 len);
  126. int msm_dsi_host_enable(struct mipi_dsi_host *host);
  127. int msm_dsi_host_disable(struct mipi_dsi_host *host);
  128. int msm_dsi_host_power_on(struct mipi_dsi_host *host);
  129. int msm_dsi_host_power_off(struct mipi_dsi_host *host);
  130. int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
  131. struct drm_display_mode *mode);
  132. struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host,
  133. unsigned long *panel_flags);
  134. struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
  135. int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
  136. void msm_dsi_host_unregister(struct mipi_dsi_host *host);
  137. int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
  138. struct msm_dsi_pll *src_pll);
  139. void msm_dsi_host_destroy(struct mipi_dsi_host *host);
  140. int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
  141. struct drm_device *dev);
  142. int msm_dsi_host_init(struct msm_dsi *msm_dsi);
  143. /* dsi phy */
  144. struct msm_dsi_phy;
  145. void msm_dsi_phy_driver_register(void);
  146. void msm_dsi_phy_driver_unregister(void);
  147. int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id,
  148. const unsigned long bit_rate, const unsigned long esc_rate);
  149. void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
  150. void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy,
  151. u32 *clk_pre, u32 *clk_post);
  152. struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
  153. #endif /* __DSI_CONNECTOR_H__ */