1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2016 Allwinnertech Co., Ltd.
4  * Copyright (C) 2017-2018 Bootlin
5  *
6  * Maxime Ripard <maxime.ripard@bootlin.com>
7  */
8 
9 #ifndef _SUN6I_MIPI_DSI_H_
10 #define _SUN6I_MIPI_DSI_H_
11 
12 #include <drm/drm_connector.h>
13 #include <drm/drm_encoder.h>
14 #include <drm/drm_mipi_dsi.h>
15 
16 #define SUN6I_DSI_TCON_DIV	4
17 
18 struct sun6i_dsi_variant {
19 	bool			has_mod_clk;
20 	bool			set_mod_clk;
21 };
22 
23 struct sun6i_dsi {
24 	struct drm_connector	connector;
25 	struct drm_encoder	encoder;
26 	struct mipi_dsi_host	host;
27 
28 	struct clk		*bus_clk;
29 	struct clk		*mod_clk;
30 	struct regmap		*regs;
31 	struct regulator	*regulator;
32 	struct reset_control	*reset;
33 	struct phy		*dphy;
34 
35 	struct device		*dev;
36 	struct mipi_dsi_device	*device;
37 	struct drm_device	*drm;
38 	struct drm_panel	*panel;
39 
40 	const struct sun6i_dsi_variant *variant;
41 };
42 
43 static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host)
44 {
45 	return container_of(host, struct sun6i_dsi, host);
46 };
47 
48 static inline struct sun6i_dsi *connector_to_sun6i_dsi(struct drm_connector *connector)
49 {
50 	return container_of(connector, struct sun6i_dsi, connector);
51 };
52 
53 static inline struct sun6i_dsi *encoder_to_sun6i_dsi(const struct drm_encoder *encoder)
54 {
55 	return container_of(encoder, struct sun6i_dsi, encoder);
56 };
57 
58 #endif /* _SUN6I_MIPI_DSI_H_ */
59