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 {
19 	struct drm_connector	connector;
20 	struct drm_encoder	encoder;
21 	struct mipi_dsi_host	host;
22 
23 	struct clk		*bus_clk;
24 	struct clk		*mod_clk;
25 	struct regmap		*regs;
26 	struct regulator	*regulator;
27 	struct reset_control	*reset;
28 	struct phy		*dphy;
29 
30 	struct device		*dev;
31 	struct mipi_dsi_device	*device;
32 	struct drm_device	*drm;
33 	struct drm_panel	*panel;
34 };
35 
host_to_sun6i_dsi(struct mipi_dsi_host * host)36 static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host)
37 {
38 	return container_of(host, struct sun6i_dsi, host);
39 };
40 
connector_to_sun6i_dsi(struct drm_connector * connector)41 static inline struct sun6i_dsi *connector_to_sun6i_dsi(struct drm_connector *connector)
42 {
43 	return container_of(connector, struct sun6i_dsi, connector);
44 };
45 
encoder_to_sun6i_dsi(const struct drm_encoder * encoder)46 static inline struct sun6i_dsi *encoder_to_sun6i_dsi(const struct drm_encoder *encoder)
47 {
48 	return container_of(encoder, struct sun6i_dsi, encoder);
49 };
50 
51 #endif /* _SUN6I_MIPI_DSI_H_ */
52