1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
6 #ifndef __DSI_CONNECTOR_H__
7 #define __DSI_CONNECTOR_H__
9 #include <linux/of_platform.h>
10 #include <linux/platform_device.h>
12 #include <drm/drm_crtc.h>
13 #include <drm/drm_mipi_dsi.h>
14 #include <drm/drm_panel.h>
22 struct msm_dsi_phy_shared_timings;
23 struct msm_dsi_phy_clk_request;
25 enum msm_dsi_phy_type {
29 MSM_DSI_PHY_28NM_8960,
35 enum msm_dsi_phy_usecase {
36 MSM_DSI_PHY_STANDALONE,
41 #define DSI_DEV_REGULATOR_MAX 8
42 #define DSI_BUS_CLK_MAX 4
44 /* Regulators for DSI devices */
45 struct dsi_reg_entry {
51 struct dsi_reg_config {
53 struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
57 struct drm_device *dev;
58 struct platform_device *pdev;
60 /* connector managed by us when we're connected to a drm_panel */
61 struct drm_connector *connector;
62 /* internal dsi bridge attached to MDP interface */
63 struct drm_bridge *bridge;
65 struct mipi_dsi_host *host;
66 struct msm_dsi_phy *phy;
69 * panel/external_bridge connected to dsi bridge output, only one of the
70 * two can be valid at a time
72 struct drm_panel *panel;
73 struct drm_bridge *external_bridge;
75 struct device *phy_dev;
78 /* the encoder we are hooked to (outside of dsi block) */
79 struct drm_encoder *encoder;
85 struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
86 void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
87 struct drm_connector *msm_dsi_manager_connector_init(u8 id);
88 struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
89 int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
90 bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
91 void msm_dsi_manager_setup_encoder(int id);
92 int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
93 void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
94 bool msm_dsi_manager_validate_current_config(u8 id);
97 static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
99 return msm_dsi->panel || msm_dsi->external_bridge;
102 struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
106 #ifdef CONFIG_DRM_MSM_DSI_PLL
107 struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
108 enum msm_dsi_phy_type type, int dsi_id);
109 void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
110 int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
111 struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
112 void msm_dsi_pll_save_state(struct msm_dsi_pll *pll);
113 int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll);
114 int msm_dsi_pll_set_usecase(struct msm_dsi_pll *pll,
115 enum msm_dsi_phy_usecase uc);
117 static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
118 enum msm_dsi_phy_type type, int id) {
119 return ERR_PTR(-ENODEV);
121 static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
124 static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
125 struct clk **byte_clk_provider, struct clk **pixel_clk_provider)
129 static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll)
132 static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll)
136 static inline int msm_dsi_pll_set_usecase(struct msm_dsi_pll *pll,
137 enum msm_dsi_phy_usecase uc)
145 int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
146 const struct mipi_dsi_msg *msg);
147 void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
148 const struct mipi_dsi_msg *msg);
149 int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
150 const struct mipi_dsi_msg *msg);
151 int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
152 const struct mipi_dsi_msg *msg);
153 void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
154 u32 dma_base, u32 len);
155 int msm_dsi_host_enable(struct mipi_dsi_host *host);
156 int msm_dsi_host_disable(struct mipi_dsi_host *host);
157 int msm_dsi_host_power_on(struct mipi_dsi_host *host,
158 struct msm_dsi_phy_shared_timings *phy_shared_timings,
160 int msm_dsi_host_power_off(struct mipi_dsi_host *host);
161 int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
162 const struct drm_display_mode *mode);
163 struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host);
164 unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
165 struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
166 int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
167 void msm_dsi_host_unregister(struct mipi_dsi_host *host);
168 int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
169 struct msm_dsi_pll *src_pll);
170 void msm_dsi_host_reset_phy(struct mipi_dsi_host *host);
171 void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host,
172 struct msm_dsi_phy_clk_request *clk_req,
174 void msm_dsi_host_destroy(struct mipi_dsi_host *host);
175 int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
176 struct drm_device *dev);
177 int msm_dsi_host_init(struct msm_dsi *msm_dsi);
178 int msm_dsi_runtime_suspend(struct device *dev);
179 int msm_dsi_runtime_resume(struct device *dev);
180 int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host);
181 int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host);
182 void dsi_link_clk_disable_6g(struct msm_dsi_host *msm_host);
183 void dsi_link_clk_disable_v2(struct msm_dsi_host *msm_host);
184 int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size);
185 int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size);
186 void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host);
187 void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host);
188 void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host);
189 int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *iova);
190 int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *iova);
191 int dsi_clk_init_v2(struct msm_dsi_host *msm_host);
192 int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host);
193 int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_dual_dsi);
194 int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_dual_dsi);
198 struct msm_dsi_phy_shared_timings {
201 bool clk_pre_inc_by_2;
204 struct msm_dsi_phy_clk_request {
205 unsigned long bitclk_rate;
206 unsigned long escclk_rate;
209 void msm_dsi_phy_driver_register(void);
210 void msm_dsi_phy_driver_unregister(void);
211 int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id,
212 struct msm_dsi_phy_clk_request *clk_req);
213 void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
214 void msm_dsi_phy_get_shared_timings(struct msm_dsi_phy *phy,
215 struct msm_dsi_phy_shared_timings *shared_timing);
216 struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
217 void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy,
218 enum msm_dsi_phy_usecase uc);
220 #endif /* __DSI_CONNECTOR_H__ */