xref: /linux/drivers/gpu/drm/bridge/cadence/cdns-dsi-core.h (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright: 2017 Cadence Design Systems, Inc.
4  *
5  * Author: Boris Brezillon <boris.brezillon@bootlin.com>
6  */
7 
8 #ifndef __CDNS_DSI_H__
9 #define __CDNS_DSI_H__
10 
11 #include <drm/drm_bridge.h>
12 #include <drm/drm_mipi_dsi.h>
13 #include <drm/drm_panel.h>
14 
15 #include <linux/bits.h>
16 #include <linux/completion.h>
17 #include <linux/phy/phy.h>
18 
19 struct clk;
20 struct reset_control;
21 
22 struct cdns_dsi_output {
23 	struct mipi_dsi_device *dev;
24 	struct drm_panel *panel;
25 	struct drm_bridge *bridge;
26 	union phy_configure_opts phy_opts;
27 };
28 
29 enum cdns_dsi_input_id {
30 	CDNS_SDI_INPUT,
31 	CDNS_DPI_INPUT,
32 	CDNS_DSC_INPUT,
33 };
34 
35 struct cdns_dsi_cfg {
36 	unsigned int hfp;
37 	unsigned int hsa;
38 	unsigned int hbp;
39 	unsigned int hact;
40 	unsigned int htotal;
41 };
42 
43 struct cdns_dsi_input {
44 	enum cdns_dsi_input_id id;
45 	struct drm_bridge bridge;
46 };
47 
48 struct cdns_dsi;
49 
50 /**
51  * struct cdns_dsi_platform_ops - CDNS DSI Platform operations
52  * @init: Called in the CDNS DSI probe
53  * @deinit: Called in the CDNS DSI remove
54  * @enable: Called at the beginning of CDNS DSI bridge enable
55  * @disable: Called at the end of CDNS DSI bridge disable
56  */
57 struct cdns_dsi_platform_ops {
58 	int (*init)(struct cdns_dsi *dsi);
59 	void (*deinit)(struct cdns_dsi *dsi);
60 	void (*enable)(struct cdns_dsi *dsi);
61 	void (*disable)(struct cdns_dsi *dsi);
62 };
63 
64 struct cdns_dsi {
65 	struct mipi_dsi_host base;
66 	void __iomem *regs;
67 #ifdef CONFIG_DRM_CDNS_DSI_J721E
68 	void __iomem *j721e_regs;
69 #endif
70 	const struct cdns_dsi_platform_ops *platform_ops;
71 	struct cdns_dsi_input input;
72 	struct cdns_dsi_output output;
73 	unsigned int direct_cmd_fifo_depth;
74 	unsigned int rx_fifo_depth;
75 	struct completion direct_cmd_comp;
76 	struct clk *dsi_p_clk;
77 	struct reset_control *dsi_p_rst;
78 	struct clk *dsi_sys_clk;
79 	bool link_initialized;
80 	bool phy_initialized;
81 	struct phy *dphy;
82 };
83 
84 #endif /* !__CDNS_DSI_H__ */
85