Commit | Line | Data |
---|---|---|
a689554b HL |
1 | /* |
2 | * Copyright (c) 2015, The Linux Foundation. All rights reserved. | |
3 | * | |
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. | |
7 | * | |
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. | |
12 | */ | |
13 | ||
14 | #ifndef __DSI_CONNECTOR_H__ | |
15 | #define __DSI_CONNECTOR_H__ | |
16 | ||
ec31abf6 | 17 | #include <linux/of_platform.h> |
a689554b HL |
18 | #include <linux/platform_device.h> |
19 | ||
20 | #include "drm_crtc.h" | |
21 | #include "drm_mipi_dsi.h" | |
22 | #include "drm_panel.h" | |
23 | ||
24 | #include "msm_drv.h" | |
25 | ||
26 | #define DSI_0 0 | |
27 | #define DSI_1 1 | |
28 | #define DSI_MAX 2 | |
29 | ||
dceac340 | 30 | struct msm_dsi_phy_shared_timings; |
b62aa70a | 31 | struct msm_dsi_phy_clk_request; |
dceac340 | 32 | |
9d32c498 | 33 | enum msm_dsi_phy_type { |
9d32c498 HL |
34 | MSM_DSI_PHY_28NM_HPM, |
35 | MSM_DSI_PHY_28NM_LP, | |
dcefc117 | 36 | MSM_DSI_PHY_20NM, |
225380b3 | 37 | MSM_DSI_PHY_28NM_8960, |
9d32c498 HL |
38 | MSM_DSI_PHY_MAX |
39 | }; | |
40 | ||
57bf4338 HL |
41 | enum msm_dsi_phy_usecase { |
42 | MSM_DSI_PHY_STANDALONE, | |
43 | MSM_DSI_PHY_MASTER, | |
44 | MSM_DSI_PHY_SLAVE, | |
45 | }; | |
46 | ||
ec31abf6 | 47 | #define DSI_DEV_REGULATOR_MAX 8 |
6e0eb52e | 48 | #define DSI_BUS_CLK_MAX 4 |
ec31abf6 HL |
49 | |
50 | /* Regulators for DSI devices */ | |
51 | struct dsi_reg_entry { | |
52 | char name[32]; | |
ec31abf6 HL |
53 | int enable_load; |
54 | int disable_load; | |
55 | }; | |
56 | ||
57 | struct dsi_reg_config { | |
58 | int num; | |
59 | struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX]; | |
60 | }; | |
61 | ||
a689554b HL |
62 | struct msm_dsi { |
63 | struct drm_device *dev; | |
64 | struct platform_device *pdev; | |
65 | ||
c118e290 | 66 | /* connector managed by us when we're connected to a drm_panel */ |
a689554b | 67 | struct drm_connector *connector; |
c118e290 | 68 | /* internal dsi bridge attached to MDP interface */ |
a689554b HL |
69 | struct drm_bridge *bridge; |
70 | ||
71 | struct mipi_dsi_host *host; | |
72 | struct msm_dsi_phy *phy; | |
c118e290 AT |
73 | |
74 | /* | |
75 | * panel/external_bridge connected to dsi bridge output, only one of the | |
76 | * two can be valid at a time | |
77 | */ | |
a689554b | 78 | struct drm_panel *panel; |
c118e290 | 79 | struct drm_bridge *external_bridge; |
a9ddac9c | 80 | unsigned long device_flags; |
9d32c498 | 81 | |
ec31abf6 | 82 | struct device *phy_dev; |
a689554b HL |
83 | bool phy_enabled; |
84 | ||
97e00119 AT |
85 | /* the encoder we are hooked to (outside of dsi block) */ |
86 | struct drm_encoder *encoder; | |
a689554b HL |
87 | |
88 | int id; | |
89 | }; | |
90 | ||
91 | /* dsi manager */ | |
92 | struct drm_bridge *msm_dsi_manager_bridge_init(u8 id); | |
93 | void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge); | |
94 | struct drm_connector *msm_dsi_manager_connector_init(u8 id); | |
c118e290 | 95 | struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id); |
a689554b | 96 | int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg); |
4ff9d4cb | 97 | bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len); |
9c9f6f8d | 98 | void msm_dsi_manager_attach_dsi_device(int id, u32 device_flags); |
a689554b HL |
99 | int msm_dsi_manager_register(struct msm_dsi *msm_dsi); |
100 | void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi); | |
101 | ||
102 | /* msm dsi */ | |
6f054ec5 AT |
103 | static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi) |
104 | { | |
c118e290 | 105 | return msm_dsi->panel || msm_dsi->external_bridge; |
6f054ec5 AT |
106 | } |
107 | ||
a689554b HL |
108 | struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi); |
109 | ||
9d32c498 HL |
110 | /* dsi pll */ |
111 | struct msm_dsi_pll; | |
112 | #ifdef CONFIG_DRM_MSM_DSI_PLL | |
113 | struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev, | |
114 | enum msm_dsi_phy_type type, int dsi_id); | |
115 | void msm_dsi_pll_destroy(struct msm_dsi_pll *pll); | |
116 | int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll, | |
117 | struct clk **byte_clk_provider, struct clk **pixel_clk_provider); | |
328e1a63 HL |
118 | void msm_dsi_pll_save_state(struct msm_dsi_pll *pll); |
119 | int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll); | |
9d32c498 HL |
120 | #else |
121 | static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev, | |
122 | enum msm_dsi_phy_type type, int id) { | |
123 | return ERR_PTR(-ENODEV); | |
124 | } | |
125 | static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll) | |
126 | { | |
127 | } | |
128 | static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll, | |
129 | struct clk **byte_clk_provider, struct clk **pixel_clk_provider) | |
130 | { | |
131 | return -ENODEV; | |
132 | } | |
328e1a63 HL |
133 | static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll) |
134 | { | |
135 | } | |
136 | static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll) | |
137 | { | |
138 | return 0; | |
139 | } | |
9d32c498 HL |
140 | #endif |
141 | ||
a689554b HL |
142 | /* dsi host */ |
143 | int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host, | |
144 | const struct mipi_dsi_msg *msg); | |
145 | void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host, | |
146 | const struct mipi_dsi_msg *msg); | |
147 | int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host, | |
148 | const struct mipi_dsi_msg *msg); | |
149 | int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host, | |
150 | const struct mipi_dsi_msg *msg); | |
151 | void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host, | |
4ff9d4cb | 152 | u32 dma_base, u32 len); |
a689554b HL |
153 | int msm_dsi_host_enable(struct mipi_dsi_host *host); |
154 | int msm_dsi_host_disable(struct mipi_dsi_host *host); | |
b62aa70a HL |
155 | int msm_dsi_host_power_on(struct mipi_dsi_host *host, |
156 | struct msm_dsi_phy_shared_timings *phy_shared_timings); | |
a689554b HL |
157 | int msm_dsi_host_power_off(struct mipi_dsi_host *host); |
158 | int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host, | |
159 | struct drm_display_mode *mode); | |
160 | struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host, | |
161 | unsigned long *panel_flags); | |
c118e290 | 162 | struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host); |
a689554b HL |
163 | int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer); |
164 | void msm_dsi_host_unregister(struct mipi_dsi_host *host); | |
9d32c498 HL |
165 | int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host, |
166 | struct msm_dsi_pll *src_pll); | |
34d9545b | 167 | void msm_dsi_host_reset_phy(struct mipi_dsi_host *host); |
b62aa70a HL |
168 | void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host *host, |
169 | struct msm_dsi_phy_clk_request *clk_req); | |
a689554b HL |
170 | void msm_dsi_host_destroy(struct mipi_dsi_host *host); |
171 | int msm_dsi_host_modeset_init(struct mipi_dsi_host *host, | |
172 | struct drm_device *dev); | |
173 | int msm_dsi_host_init(struct msm_dsi *msm_dsi); | |
174 | ||
175 | /* dsi phy */ | |
176 | struct msm_dsi_phy; | |
dceac340 HL |
177 | struct msm_dsi_phy_shared_timings { |
178 | u32 clk_post; | |
179 | u32 clk_pre; | |
180 | bool clk_pre_inc_by_2; | |
181 | }; | |
b62aa70a HL |
182 | |
183 | struct msm_dsi_phy_clk_request { | |
184 | unsigned long bitclk_rate; | |
185 | unsigned long escclk_rate; | |
186 | }; | |
187 | ||
ec31abf6 HL |
188 | void msm_dsi_phy_driver_register(void); |
189 | void msm_dsi_phy_driver_unregister(void); | |
13351cd1 | 190 | int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id, |
b62aa70a | 191 | struct msm_dsi_phy_clk_request *clk_req); |
29e61690 | 192 | void msm_dsi_phy_disable(struct msm_dsi_phy *phy); |
dceac340 HL |
193 | void msm_dsi_phy_get_shared_timings(struct msm_dsi_phy *phy, |
194 | struct msm_dsi_phy_shared_timings *shared_timing); | |
9d32c498 | 195 | struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy); |
57bf4338 HL |
196 | void msm_dsi_phy_set_usecase(struct msm_dsi_phy *phy, |
197 | enum msm_dsi_phy_usecase uc); | |
9d32c498 | 198 | |
a689554b HL |
199 | #endif /* __DSI_CONNECTOR_H__ */ |
200 |