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 14 #ifndef __DSI_CONNECTOR_H__ 15 #define __DSI_CONNECTOR_H__ 16 17 #include <linux/platform_device.h> 18 19 #include "drm_crtc.h" 20 #include "drm_mipi_dsi.h" 21 #include "drm_panel.h" 22 23 #include "msm_drv.h" 24 25 #define DSI_0 0 26 #define DSI_1 1 27 #define DSI_MAX 2 28 29 #define DSI_CLOCK_MASTER DSI_0 30 #define DSI_CLOCK_SLAVE DSI_1 31 32 #define DSI_LEFT DSI_0 33 #define DSI_RIGHT DSI_1 34 35 /* According to the current drm framework sequence, take the encoder of 36 * DSI_1 as master encoder 37 */ 38 #define DSI_ENCODER_MASTER DSI_1 39 #define DSI_ENCODER_SLAVE DSI_0 40 41 struct msm_dsi { 42 struct drm_device *dev; 43 struct platform_device *pdev; 44 45 struct drm_connector *connector; 46 struct drm_bridge *bridge; 47 48 struct mipi_dsi_host *host; 49 struct msm_dsi_phy *phy; 50 struct drm_panel *panel; 51 unsigned long panel_flags; 52 bool phy_enabled; 53 54 /* the encoders we are hooked to (outside of dsi block) */ 55 struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM]; 56 57 int id; 58 }; 59 60 /* dsi manager */ 61 struct drm_bridge *msm_dsi_manager_bridge_init(u8 id); 62 void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge); 63 struct drm_connector *msm_dsi_manager_connector_init(u8 id); 64 int msm_dsi_manager_phy_enable(int id, 65 const unsigned long bit_rate, const unsigned long esc_rate, 66 u32 *clk_pre, u32 *clk_post); 67 void msm_dsi_manager_phy_disable(int id); 68 int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg); 69 bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 iova, u32 len); 70 int msm_dsi_manager_register(struct msm_dsi *msm_dsi); 71 void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi); 72 73 /* msm dsi */ 74 struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi); 75 76 /* dsi host */ 77 int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host, 78 const struct mipi_dsi_msg *msg); 79 void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host, 80 const struct mipi_dsi_msg *msg); 81 int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host, 82 const struct mipi_dsi_msg *msg); 83 int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host, 84 const struct mipi_dsi_msg *msg); 85 void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host, 86 u32 iova, u32 len); 87 int msm_dsi_host_enable(struct mipi_dsi_host *host); 88 int msm_dsi_host_disable(struct mipi_dsi_host *host); 89 int msm_dsi_host_power_on(struct mipi_dsi_host *host); 90 int msm_dsi_host_power_off(struct mipi_dsi_host *host); 91 int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host, 92 struct drm_display_mode *mode); 93 struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host, 94 unsigned long *panel_flags); 95 int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer); 96 void msm_dsi_host_unregister(struct mipi_dsi_host *host); 97 void msm_dsi_host_destroy(struct mipi_dsi_host *host); 98 int msm_dsi_host_modeset_init(struct mipi_dsi_host *host, 99 struct drm_device *dev); 100 int msm_dsi_host_init(struct msm_dsi *msm_dsi); 101 102 /* dsi phy */ 103 struct msm_dsi_phy; 104 enum msm_dsi_phy_type { 105 MSM_DSI_PHY_UNKNOWN, 106 MSM_DSI_PHY_28NM, 107 MSM_DSI_PHY_MAX 108 }; 109 struct msm_dsi_phy *msm_dsi_phy_init(struct platform_device *pdev, 110 enum msm_dsi_phy_type type, int id); 111 int msm_dsi_phy_enable(struct msm_dsi_phy *phy, bool is_dual_panel, 112 const unsigned long bit_rate, const unsigned long esc_rate); 113 int msm_dsi_phy_disable(struct msm_dsi_phy *phy); 114 void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy, 115 u32 *clk_pre, u32 *clk_post); 116 #endif /* __DSI_CONNECTOR_H__ */ 117 118