2 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
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.
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.
14 #ifndef __DSI_CONNECTOR_H__
15 #define __DSI_CONNECTOR_H__
17 #include <linux/of_platform.h>
18 #include <linux/platform_device.h>
20 #include <drm/drm_crtc.h>
21 #include <drm/drm_mipi_dsi.h>
22 #include <drm/drm_panel.h>
30 struct msm_dsi_phy_shared_timings
;
31 struct msm_dsi_phy_clk_request
;
33 enum msm_dsi_phy_type
{
37 MSM_DSI_PHY_28NM_8960
,
43 enum msm_dsi_phy_usecase
{
44 MSM_DSI_PHY_STANDALONE
,
49 #define DSI_DEV_REGULATOR_MAX 8
50 #define DSI_BUS_CLK_MAX 4
52 /* Regulators for DSI devices */
53 struct dsi_reg_entry
{
59 struct dsi_reg_config
{
61 struct dsi_reg_entry regs
[DSI_DEV_REGULATOR_MAX
];
65 struct drm_device
*dev
;
66 struct platform_device
*pdev
;
68 /* connector managed by us when we're connected to a drm_panel */
69 struct drm_connector
*connector
;
70 /* internal dsi bridge attached to MDP interface */
71 struct drm_bridge
*bridge
;
73 struct mipi_dsi_host
*host
;
74 struct msm_dsi_phy
*phy
;
77 * panel/external_bridge connected to dsi bridge output, only one of the
78 * two can be valid at a time
80 struct drm_panel
*panel
;
81 struct drm_bridge
*external_bridge
;
82 unsigned long device_flags
;
84 struct device
*phy_dev
;
87 /* the encoder we are hooked to (outside of dsi block) */
88 struct drm_encoder
*encoder
;
94 struct drm_bridge
*msm_dsi_manager_bridge_init(u8 id
);
95 void msm_dsi_manager_bridge_destroy(struct drm_bridge
*bridge
);
96 struct drm_connector
*msm_dsi_manager_connector_init(u8 id
);
97 struct drm_connector
*msm_dsi_manager_ext_bridge_init(u8 id
);
98 int msm_dsi_manager_cmd_xfer(int id
, const struct mipi_dsi_msg
*msg
);
99 bool msm_dsi_manager_cmd_xfer_trigger(int id
, u32 dma_base
, u32 len
);
100 void msm_dsi_manager_attach_dsi_device(int id
, u32 device_flags
);
101 int msm_dsi_manager_register(struct msm_dsi
*msm_dsi
);
102 void msm_dsi_manager_unregister(struct msm_dsi
*msm_dsi
);
103 bool msm_dsi_manager_validate_current_config(u8 id
);
106 static inline bool msm_dsi_device_connected(struct msm_dsi
*msm_dsi
)
108 return msm_dsi
->panel
|| msm_dsi
->external_bridge
;
111 struct drm_encoder
*msm_dsi_get_encoder(struct msm_dsi
*msm_dsi
);
115 #ifdef CONFIG_DRM_MSM_DSI_PLL
116 struct msm_dsi_pll
*msm_dsi_pll_init(struct platform_device
*pdev
,
117 enum msm_dsi_phy_type type
, int dsi_id
);
118 void msm_dsi_pll_destroy(struct msm_dsi_pll
*pll
);
119 int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll
*pll
,
120 struct clk
**byte_clk_provider
, struct clk
**pixel_clk_provider
);
121 void msm_dsi_pll_save_state(struct msm_dsi_pll
*pll
);
122 int msm_dsi_pll_restore_state(struct msm_dsi_pll
*pll
);
123 int msm_dsi_pll_set_usecase(struct msm_dsi_pll
*pll
,
124 enum msm_dsi_phy_usecase uc
);
126 static inline struct msm_dsi_pll
*msm_dsi_pll_init(struct platform_device
*pdev
,
127 enum msm_dsi_phy_type type
, int id
) {
128 return ERR_PTR(-ENODEV
);
130 static inline void msm_dsi_pll_destroy(struct msm_dsi_pll
*pll
)
133 static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll
*pll
,
134 struct clk
**byte_clk_provider
, struct clk
**pixel_clk_provider
)
138 static inline void msm_dsi_pll_save_state(struct msm_dsi_pll
*pll
)
141 static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll
*pll
)
145 static inline int msm_dsi_pll_set_usecase(struct msm_dsi_pll
*pll
,
146 enum msm_dsi_phy_usecase uc
)
154 int msm_dsi_host_xfer_prepare(struct mipi_dsi_host
*host
,
155 const struct mipi_dsi_msg
*msg
);
156 void msm_dsi_host_xfer_restore(struct mipi_dsi_host
*host
,
157 const struct mipi_dsi_msg
*msg
);
158 int msm_dsi_host_cmd_tx(struct mipi_dsi_host
*host
,
159 const struct mipi_dsi_msg
*msg
);
160 int msm_dsi_host_cmd_rx(struct mipi_dsi_host
*host
,
161 const struct mipi_dsi_msg
*msg
);
162 void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host
*host
,
163 u32 dma_base
, u32 len
);
164 int msm_dsi_host_enable(struct mipi_dsi_host
*host
);
165 int msm_dsi_host_disable(struct mipi_dsi_host
*host
);
166 int msm_dsi_host_power_on(struct mipi_dsi_host
*host
,
167 struct msm_dsi_phy_shared_timings
*phy_shared_timings
,
169 int msm_dsi_host_power_off(struct mipi_dsi_host
*host
);
170 int msm_dsi_host_set_display_mode(struct mipi_dsi_host
*host
,
171 const struct drm_display_mode
*mode
);
172 struct drm_panel
*msm_dsi_host_get_panel(struct mipi_dsi_host
*host
,
173 unsigned long *panel_flags
);
174 struct drm_bridge
*msm_dsi_host_get_bridge(struct mipi_dsi_host
*host
);
175 int msm_dsi_host_register(struct mipi_dsi_host
*host
, bool check_defer
);
176 void msm_dsi_host_unregister(struct mipi_dsi_host
*host
);
177 int msm_dsi_host_set_src_pll(struct mipi_dsi_host
*host
,
178 struct msm_dsi_pll
*src_pll
);
179 void msm_dsi_host_reset_phy(struct mipi_dsi_host
*host
);
180 void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host
*host
,
181 struct msm_dsi_phy_clk_request
*clk_req
,
183 void msm_dsi_host_destroy(struct mipi_dsi_host
*host
);
184 int msm_dsi_host_modeset_init(struct mipi_dsi_host
*host
,
185 struct drm_device
*dev
);
186 int msm_dsi_host_init(struct msm_dsi
*msm_dsi
);
187 int msm_dsi_runtime_suspend(struct device
*dev
);
188 int msm_dsi_runtime_resume(struct device
*dev
);
189 int dsi_link_clk_enable_6g(struct msm_dsi_host
*msm_host
);
190 int dsi_link_clk_enable_v2(struct msm_dsi_host
*msm_host
);
191 void dsi_link_clk_disable_6g(struct msm_dsi_host
*msm_host
);
192 void dsi_link_clk_disable_v2(struct msm_dsi_host
*msm_host
);
193 int dsi_tx_buf_alloc_6g(struct msm_dsi_host
*msm_host
, int size
);
194 int dsi_tx_buf_alloc_v2(struct msm_dsi_host
*msm_host
, int size
);
195 void *dsi_tx_buf_get_6g(struct msm_dsi_host
*msm_host
);
196 void *dsi_tx_buf_get_v2(struct msm_dsi_host
*msm_host
);
197 void dsi_tx_buf_put_6g(struct msm_dsi_host
*msm_host
);
198 int dsi_dma_base_get_6g(struct msm_dsi_host
*msm_host
, uint64_t *iova
);
199 int dsi_dma_base_get_v2(struct msm_dsi_host
*msm_host
, uint64_t *iova
);
200 int dsi_clk_init_v2(struct msm_dsi_host
*msm_host
);
201 int dsi_clk_init_6g_v2(struct msm_dsi_host
*msm_host
);
202 int dsi_calc_clk_rate_v2(struct msm_dsi_host
*msm_host
, bool is_dual_dsi
);
203 int dsi_calc_clk_rate_6g(struct msm_dsi_host
*msm_host
, bool is_dual_dsi
);
207 struct msm_dsi_phy_shared_timings
{
210 bool clk_pre_inc_by_2
;
213 struct msm_dsi_phy_clk_request
{
214 unsigned long bitclk_rate
;
215 unsigned long escclk_rate
;
218 void msm_dsi_phy_driver_register(void);
219 void msm_dsi_phy_driver_unregister(void);
220 int msm_dsi_phy_enable(struct msm_dsi_phy
*phy
, int src_pll_id
,
221 struct msm_dsi_phy_clk_request
*clk_req
);
222 void msm_dsi_phy_disable(struct msm_dsi_phy
*phy
);
223 void msm_dsi_phy_get_shared_timings(struct msm_dsi_phy
*phy
,
224 struct msm_dsi_phy_shared_timings
*shared_timing
);
225 struct msm_dsi_pll
*msm_dsi_phy_get_pll(struct msm_dsi_phy
*phy
);
226 void msm_dsi_phy_set_usecase(struct msm_dsi_phy
*phy
,
227 enum msm_dsi_phy_usecase uc
);
229 #endif /* __DSI_CONNECTOR_H__ */