Linux 4.2.1
[linux/fpc-iii.git] / drivers / gpu / drm / msm / dsi / dsi.h
blob92d697de4858360495e24b50430eddc2d38fea83
1 /*
2 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef __DSI_CONNECTOR_H__
15 #define __DSI_CONNECTOR_H__
17 #include <linux/of_platform.h>
18 #include <linux/platform_device.h>
20 #include "drm_crtc.h"
21 #include "drm_mipi_dsi.h"
22 #include "drm_panel.h"
24 #include "msm_drv.h"
26 #define DSI_0 0
27 #define DSI_1 1
28 #define DSI_MAX 2
30 #define DSI_CLOCK_MASTER DSI_0
31 #define DSI_CLOCK_SLAVE DSI_1
33 #define DSI_LEFT DSI_0
34 #define DSI_RIGHT DSI_1
36 /* According to the current drm framework sequence, take the encoder of
37 * DSI_1 as master encoder
39 #define DSI_ENCODER_MASTER DSI_1
40 #define DSI_ENCODER_SLAVE DSI_0
42 enum msm_dsi_phy_type {
43 MSM_DSI_PHY_28NM_HPM,
44 MSM_DSI_PHY_28NM_LP,
45 MSM_DSI_PHY_MAX
48 #define DSI_DEV_REGULATOR_MAX 8
50 /* Regulators for DSI devices */
51 struct dsi_reg_entry {
52 char name[32];
53 int min_voltage;
54 int max_voltage;
55 int enable_load;
56 int disable_load;
59 struct dsi_reg_config {
60 int num;
61 struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX];
64 struct msm_dsi {
65 struct drm_device *dev;
66 struct platform_device *pdev;
68 struct drm_connector *connector;
69 struct drm_bridge *bridge;
71 struct mipi_dsi_host *host;
72 struct msm_dsi_phy *phy;
73 struct drm_panel *panel;
74 unsigned long panel_flags;
76 struct device *phy_dev;
77 bool phy_enabled;
79 /* the encoders we are hooked to (outside of dsi block) */
80 struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM];
82 int id;
85 /* dsi manager */
86 struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
87 void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
88 struct drm_connector *msm_dsi_manager_connector_init(u8 id);
89 int msm_dsi_manager_phy_enable(int id,
90 const unsigned long bit_rate, const unsigned long esc_rate,
91 u32 *clk_pre, u32 *clk_post);
92 void msm_dsi_manager_phy_disable(int id);
93 int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
94 bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 iova, u32 len);
95 int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
96 void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
98 /* msm dsi */
99 struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);
101 /* dsi pll */
102 struct msm_dsi_pll;
103 #ifdef CONFIG_DRM_MSM_DSI_PLL
104 struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
105 enum msm_dsi_phy_type type, int dsi_id);
106 void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
107 int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
108 struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
109 #else
110 static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
111 enum msm_dsi_phy_type type, int id) {
112 return ERR_PTR(-ENODEV);
114 static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
117 static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
118 struct clk **byte_clk_provider, struct clk **pixel_clk_provider)
120 return -ENODEV;
122 #endif
124 /* dsi host */
125 int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
126 const struct mipi_dsi_msg *msg);
127 void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host,
128 const struct mipi_dsi_msg *msg);
129 int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host,
130 const struct mipi_dsi_msg *msg);
131 int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
132 const struct mipi_dsi_msg *msg);
133 void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host,
134 u32 iova, u32 len);
135 int msm_dsi_host_enable(struct mipi_dsi_host *host);
136 int msm_dsi_host_disable(struct mipi_dsi_host *host);
137 int msm_dsi_host_power_on(struct mipi_dsi_host *host);
138 int msm_dsi_host_power_off(struct mipi_dsi_host *host);
139 int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
140 struct drm_display_mode *mode);
141 struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host,
142 unsigned long *panel_flags);
143 int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
144 void msm_dsi_host_unregister(struct mipi_dsi_host *host);
145 int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
146 struct msm_dsi_pll *src_pll);
147 void msm_dsi_host_destroy(struct mipi_dsi_host *host);
148 int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
149 struct drm_device *dev);
150 int msm_dsi_host_init(struct msm_dsi *msm_dsi);
152 /* dsi phy */
153 struct msm_dsi_phy;
154 void msm_dsi_phy_driver_register(void);
155 void msm_dsi_phy_driver_unregister(void);
156 int msm_dsi_phy_enable(struct msm_dsi_phy *phy, bool is_dual_panel,
157 const unsigned long bit_rate, const unsigned long esc_rate);
158 int msm_dsi_phy_disable(struct msm_dsi_phy *phy);
159 void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy,
160 u32 *clk_pre, u32 *clk_post);
161 struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
163 #endif /* __DSI_CONNECTOR_H__ */