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