GNU Linux-libre 4.19.281-gnu1
[releases.git] / drivers / gpu / drm / sun4i / sun6i_mipi_dsi.h
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 struct sun6i_dphy {
17         struct clk              *bus_clk;
18         struct clk              *mod_clk;
19         struct regmap           *regs;
20         struct reset_control    *reset;
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 reset_control    *reset;
32         struct sun6i_dphy       *dphy;
33
34         struct device           *dev;
35         struct sun4i_drv        *drv;
36         struct mipi_dsi_device  *device;
37         struct drm_panel        *panel;
38 };
39
40 static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host)
41 {
42         return container_of(host, struct sun6i_dsi, host);
43 };
44
45 static inline struct sun6i_dsi *connector_to_sun6i_dsi(struct drm_connector *connector)
46 {
47         return container_of(connector, struct sun6i_dsi, connector);
48 };
49
50 static inline struct sun6i_dsi *encoder_to_sun6i_dsi(const struct drm_encoder *encoder)
51 {
52         return container_of(encoder, struct sun6i_dsi, encoder);
53 };
54
55 int sun6i_dphy_probe(struct sun6i_dsi *dsi, struct device_node *node);
56 int sun6i_dphy_remove(struct sun6i_dsi *dsi);
57
58 int sun6i_dphy_init(struct sun6i_dphy *dphy, unsigned int lanes);
59 int sun6i_dphy_power_on(struct sun6i_dphy *dphy, unsigned int lanes);
60 int sun6i_dphy_power_off(struct sun6i_dphy *dphy);
61 int sun6i_dphy_exit(struct sun6i_dphy *dphy);
62
63 #endif /* _SUN6I_MIPI_DSI_H_ */