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 17ec31abf6SHai Li #include <linux/of_platform.h> 18a689554bSHai Li #include <linux/platform_device.h> 19a689554bSHai Li 20a689554bSHai Li #include "drm_crtc.h" 21a689554bSHai Li #include "drm_mipi_dsi.h" 22a689554bSHai Li #include "drm_panel.h" 23a689554bSHai Li 24a689554bSHai Li #include "msm_drv.h" 25a689554bSHai Li 26a689554bSHai Li #define DSI_0 0 27a689554bSHai Li #define DSI_1 1 28a689554bSHai Li #define DSI_MAX 2 29a689554bSHai Li 309d32c498SHai Li enum msm_dsi_phy_type { 319d32c498SHai Li MSM_DSI_PHY_28NM_HPM, 329d32c498SHai Li MSM_DSI_PHY_28NM_LP, 33dcefc117SHai Li MSM_DSI_PHY_20NM, 349d32c498SHai Li MSM_DSI_PHY_MAX 359d32c498SHai Li }; 369d32c498SHai Li 37ec31abf6SHai Li #define DSI_DEV_REGULATOR_MAX 8 38ec31abf6SHai Li 39ec31abf6SHai Li /* Regulators for DSI devices */ 40ec31abf6SHai Li struct dsi_reg_entry { 41ec31abf6SHai Li char name[32]; 42ec31abf6SHai Li int min_voltage; 43ec31abf6SHai Li int max_voltage; 44ec31abf6SHai Li int enable_load; 45ec31abf6SHai Li int disable_load; 46ec31abf6SHai Li }; 47ec31abf6SHai Li 48ec31abf6SHai Li struct dsi_reg_config { 49ec31abf6SHai Li int num; 50ec31abf6SHai Li struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX]; 51ec31abf6SHai Li }; 52ec31abf6SHai Li 53a689554bSHai Li struct msm_dsi { 54a689554bSHai Li struct drm_device *dev; 55a689554bSHai Li struct platform_device *pdev; 56a689554bSHai Li 57a689554bSHai Li struct drm_connector *connector; 58a689554bSHai Li struct drm_bridge *bridge; 59a689554bSHai Li 60a689554bSHai Li struct mipi_dsi_host *host; 61a689554bSHai Li struct msm_dsi_phy *phy; 62a689554bSHai Li struct drm_panel *panel; 63*a9ddac9cSArchit Taneja unsigned long device_flags; 649d32c498SHai Li 65ec31abf6SHai Li struct device *phy_dev; 66a689554bSHai Li bool phy_enabled; 67a689554bSHai Li 68a689554bSHai Li /* the encoders we are hooked to (outside of dsi block) */ 69a689554bSHai Li struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM]; 70a689554bSHai Li 71a689554bSHai Li int id; 72a689554bSHai Li }; 73a689554bSHai Li 74a689554bSHai Li /* dsi manager */ 75a689554bSHai Li struct drm_bridge *msm_dsi_manager_bridge_init(u8 id); 76a689554bSHai Li void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge); 77a689554bSHai Li struct drm_connector *msm_dsi_manager_connector_init(u8 id); 78a689554bSHai Li int msm_dsi_manager_phy_enable(int id, 79a689554bSHai Li const unsigned long bit_rate, const unsigned long esc_rate, 80a689554bSHai Li u32 *clk_pre, u32 *clk_post); 81a689554bSHai Li void msm_dsi_manager_phy_disable(int id); 82a689554bSHai Li int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg); 83a689554bSHai Li bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 iova, u32 len); 84a689554bSHai Li int msm_dsi_manager_register(struct msm_dsi *msm_dsi); 85a689554bSHai Li void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi); 86a689554bSHai Li 87a689554bSHai Li /* msm dsi */ 88a689554bSHai Li struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi); 89a689554bSHai Li 909d32c498SHai Li /* dsi pll */ 919d32c498SHai Li struct msm_dsi_pll; 929d32c498SHai Li #ifdef CONFIG_DRM_MSM_DSI_PLL 939d32c498SHai Li struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev, 949d32c498SHai Li enum msm_dsi_phy_type type, int dsi_id); 959d32c498SHai Li void msm_dsi_pll_destroy(struct msm_dsi_pll *pll); 969d32c498SHai Li int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll, 979d32c498SHai Li struct clk **byte_clk_provider, struct clk **pixel_clk_provider); 98328e1a63SHai Li void msm_dsi_pll_save_state(struct msm_dsi_pll *pll); 99328e1a63SHai Li int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll); 1009d32c498SHai Li #else 1019d32c498SHai Li static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev, 1029d32c498SHai Li enum msm_dsi_phy_type type, int id) { 1039d32c498SHai Li return ERR_PTR(-ENODEV); 1049d32c498SHai Li } 1059d32c498SHai Li static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll) 1069d32c498SHai Li { 1079d32c498SHai Li } 1089d32c498SHai Li static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll, 1099d32c498SHai Li struct clk **byte_clk_provider, struct clk **pixel_clk_provider) 1109d32c498SHai Li { 1119d32c498SHai Li return -ENODEV; 1129d32c498SHai Li } 113328e1a63SHai Li static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll) 114328e1a63SHai Li { 115328e1a63SHai Li } 116328e1a63SHai Li static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll) 117328e1a63SHai Li { 118328e1a63SHai Li return 0; 119328e1a63SHai Li } 1209d32c498SHai Li #endif 1219d32c498SHai Li 122a689554bSHai Li /* dsi host */ 123a689554bSHai Li int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host, 124a689554bSHai Li const struct mipi_dsi_msg *msg); 125a689554bSHai Li void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host, 126a689554bSHai Li const struct mipi_dsi_msg *msg); 127a689554bSHai Li int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host, 128a689554bSHai Li const struct mipi_dsi_msg *msg); 129a689554bSHai Li int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host, 130a689554bSHai Li const struct mipi_dsi_msg *msg); 131a689554bSHai Li void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host, 132a689554bSHai Li u32 iova, u32 len); 133a689554bSHai Li int msm_dsi_host_enable(struct mipi_dsi_host *host); 134a689554bSHai Li int msm_dsi_host_disable(struct mipi_dsi_host *host); 135a689554bSHai Li int msm_dsi_host_power_on(struct mipi_dsi_host *host); 136a689554bSHai Li int msm_dsi_host_power_off(struct mipi_dsi_host *host); 137a689554bSHai Li int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host, 138a689554bSHai Li struct drm_display_mode *mode); 139a689554bSHai Li struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host, 140a689554bSHai Li unsigned long *panel_flags); 141a689554bSHai Li int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer); 142a689554bSHai Li void msm_dsi_host_unregister(struct mipi_dsi_host *host); 1439d32c498SHai Li int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host, 1449d32c498SHai Li struct msm_dsi_pll *src_pll); 145a689554bSHai Li void msm_dsi_host_destroy(struct mipi_dsi_host *host); 146a689554bSHai Li int msm_dsi_host_modeset_init(struct mipi_dsi_host *host, 147a689554bSHai Li struct drm_device *dev); 148a689554bSHai Li int msm_dsi_host_init(struct msm_dsi *msm_dsi); 149a689554bSHai Li 150a689554bSHai Li /* dsi phy */ 151a689554bSHai Li struct msm_dsi_phy; 152ec31abf6SHai Li void msm_dsi_phy_driver_register(void); 153ec31abf6SHai Li void msm_dsi_phy_driver_unregister(void); 15413351cd1SHai Li int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id, 155a689554bSHai Li const unsigned long bit_rate, const unsigned long esc_rate); 156a689554bSHai Li int msm_dsi_phy_disable(struct msm_dsi_phy *phy); 157a689554bSHai Li void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy, 158a689554bSHai Li u32 *clk_pre, u32 *clk_post); 1599d32c498SHai Li struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy); 1609d32c498SHai Li 161a689554bSHai Li #endif /* __DSI_CONNECTOR_H__ */ 162a689554bSHai Li 163