xref: /linux/include/drm/bridge/dw_mipi_dsi.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) STMicroelectronics SA 2017
4  *
5  * Authors: Philippe Cornu <philippe.cornu@st.com>
6  *          Yannick Fertre <yannick.fertre@st.com>
7  */
8 
9 #ifndef __DW_MIPI_DSI__
10 #define __DW_MIPI_DSI__
11 
12 #include <linux/types.h>
13 
14 #include <drm/drm_atomic.h>
15 #include <drm/drm_bridge.h>
16 #include <drm/drm_connector.h>
17 #include <drm/drm_crtc.h>
18 #include <drm/drm_modes.h>
19 
20 struct drm_display_mode;
21 struct drm_encoder;
22 struct dw_mipi_dsi;
23 struct mipi_dsi_device;
24 struct platform_device;
25 
26 struct dw_mipi_dsi_dphy_timing {
27 	u16 data_hs2lp;
28 	u16 data_lp2hs;
29 	u16 clk_hs2lp;
30 	u16 clk_lp2hs;
31 };
32 
33 struct dw_mipi_dsi_phy_ops {
34 	int (*init)(void *priv_data);
35 	void (*power_on)(void *priv_data);
36 	void (*power_off)(void *priv_data);
37 	int (*get_lane_mbps)(void *priv_data,
38 			     const struct drm_display_mode *mode,
39 			     unsigned long mode_flags, u32 lanes, u32 format,
40 			     unsigned int *lane_mbps);
41 	int (*get_timing)(void *priv_data, unsigned int lane_mbps,
42 			  struct dw_mipi_dsi_dphy_timing *timing);
43 	int (*get_esc_clk_rate)(void *priv_data, unsigned int *esc_clk_rate);
44 };
45 
46 struct dw_mipi_dsi_host_ops {
47 	int (*attach)(void *priv_data,
48 		      struct mipi_dsi_device *dsi);
49 	int (*detach)(void *priv_data,
50 		      struct mipi_dsi_device *dsi);
51 };
52 
53 struct dw_mipi_dsi_plat_data {
54 	void __iomem *base;
55 	unsigned int max_data_lanes;
56 
57 	enum drm_mode_status (*mode_valid)(void *priv_data,
58 					   const struct drm_display_mode *mode,
59 					   unsigned long mode_flags,
60 					   u32 lanes, u32 format);
61 
62 	bool (*mode_fixup)(void *priv_data, const struct drm_display_mode *mode,
63 			   struct drm_display_mode *adjusted_mode);
64 
65 	u32 *(*get_input_bus_fmts)(void *priv_data,
66 				   struct drm_bridge *bridge,
67 				   struct drm_bridge_state *bridge_state,
68 				   struct drm_crtc_state *crtc_state,
69 				   struct drm_connector_state *conn_state,
70 				   u32 output_fmt,
71 				   unsigned int *num_input_fmts);
72 
73 	const struct dw_mipi_dsi_phy_ops *phy_ops;
74 	const struct dw_mipi_dsi_host_ops *host_ops;
75 
76 	void *priv_data;
77 };
78 
79 struct dw_mipi_dsi *dw_mipi_dsi_probe(struct platform_device *pdev,
80 				      const struct dw_mipi_dsi_plat_data
81 				      *plat_data);
82 void dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi);
83 int dw_mipi_dsi_bind(struct dw_mipi_dsi *dsi, struct drm_encoder *encoder);
84 void dw_mipi_dsi_unbind(struct dw_mipi_dsi *dsi);
85 void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave);
86 struct drm_bridge *dw_mipi_dsi_get_bridge(struct dw_mipi_dsi *dsi);
87 
88 #endif /* __DW_MIPI_DSI__ */
89