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 | ||
9d32c498 | 30 | enum msm_dsi_phy_type { |
9d32c498 HL |
31 | MSM_DSI_PHY_28NM_HPM, |
32 | MSM_DSI_PHY_28NM_LP, | |
dcefc117 | 33 | MSM_DSI_PHY_20NM, |
225380b3 | 34 | MSM_DSI_PHY_28NM_8960, |
9d32c498 HL |
35 | MSM_DSI_PHY_MAX |
36 | }; | |
37 | ||
ec31abf6 | 38 | #define DSI_DEV_REGULATOR_MAX 8 |
6e0eb52e | 39 | #define DSI_BUS_CLK_MAX 4 |
ec31abf6 HL |
40 | |
41 | /* Regulators for DSI devices */ | |
42 | struct dsi_reg_entry { | |
43 | char name[32]; | |
44 | int min_voltage; | |
45 | int max_voltage; | |
46 | int enable_load; | |
47 | int disable_load; | |
48 | }; | |
49 | ||
50 | struct dsi_reg_config { | |
51 | int num; | |
52 | struct dsi_reg_entry regs[DSI_DEV_REGULATOR_MAX]; | |
53 | }; | |
54 | ||
a689554b HL |
55 | struct msm_dsi { |
56 | struct drm_device *dev; | |
57 | struct platform_device *pdev; | |
58 | ||
c118e290 | 59 | /* connector managed by us when we're connected to a drm_panel */ |
a689554b | 60 | struct drm_connector *connector; |
c118e290 | 61 | /* internal dsi bridge attached to MDP interface */ |
a689554b HL |
62 | struct drm_bridge *bridge; |
63 | ||
64 | struct mipi_dsi_host *host; | |
65 | struct msm_dsi_phy *phy; | |
c118e290 AT |
66 | |
67 | /* | |
68 | * panel/external_bridge connected to dsi bridge output, only one of the | |
69 | * two can be valid at a time | |
70 | */ | |
a689554b | 71 | struct drm_panel *panel; |
c118e290 | 72 | struct drm_bridge *external_bridge; |
a9ddac9c | 73 | unsigned long device_flags; |
9d32c498 | 74 | |
ec31abf6 | 75 | struct device *phy_dev; |
a689554b HL |
76 | bool phy_enabled; |
77 | ||
78 | /* the encoders we are hooked to (outside of dsi block) */ | |
79 | struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM]; | |
80 | ||
81 | int id; | |
82 | }; | |
83 | ||
84 | /* dsi manager */ | |
85 | struct drm_bridge *msm_dsi_manager_bridge_init(u8 id); | |
86 | void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge); | |
87 | struct drm_connector *msm_dsi_manager_connector_init(u8 id); | |
c118e290 | 88 | struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id); |
a689554b HL |
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); | |
97 | ||
98 | /* msm dsi */ | |
6f054ec5 AT |
99 | static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi) |
100 | { | |
c118e290 | 101 | return msm_dsi->panel || msm_dsi->external_bridge; |
6f054ec5 AT |
102 | } |
103 | ||
a689554b HL |
104 | struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi); |
105 | ||
9d32c498 HL |
106 | /* dsi pll */ |
107 | struct msm_dsi_pll; | |
108 | #ifdef CONFIG_DRM_MSM_DSI_PLL | |
109 | struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev, | |
110 | enum msm_dsi_phy_type type, int dsi_id); | |
111 | void msm_dsi_pll_destroy(struct msm_dsi_pll *pll); | |
112 | int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll, | |
113 | struct clk **byte_clk_provider, struct clk **pixel_clk_provider); | |
328e1a63 HL |
114 | void msm_dsi_pll_save_state(struct msm_dsi_pll *pll); |
115 | int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll); | |
9d32c498 HL |
116 | #else |
117 | static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev, | |
118 | enum msm_dsi_phy_type type, int id) { | |
119 | return ERR_PTR(-ENODEV); | |
120 | } | |
121 | static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll) | |
122 | { | |
123 | } | |
124 | static inline int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll, | |
125 | struct clk **byte_clk_provider, struct clk **pixel_clk_provider) | |
126 | { | |
127 | return -ENODEV; | |
128 | } | |
328e1a63 HL |
129 | static inline void msm_dsi_pll_save_state(struct msm_dsi_pll *pll) |
130 | { | |
131 | } | |
132 | static inline int msm_dsi_pll_restore_state(struct msm_dsi_pll *pll) | |
133 | { | |
134 | return 0; | |
135 | } | |
9d32c498 HL |
136 | #endif |
137 | ||
a689554b HL |
138 | /* dsi host */ |
139 | int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host, | |
140 | const struct mipi_dsi_msg *msg); | |
141 | void msm_dsi_host_xfer_restore(struct mipi_dsi_host *host, | |
142 | const struct mipi_dsi_msg *msg); | |
143 | int msm_dsi_host_cmd_tx(struct mipi_dsi_host *host, | |
144 | const struct mipi_dsi_msg *msg); | |
145 | int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host, | |
146 | const struct mipi_dsi_msg *msg); | |
147 | void msm_dsi_host_cmd_xfer_commit(struct mipi_dsi_host *host, | |
148 | u32 iova, u32 len); | |
149 | int msm_dsi_host_enable(struct mipi_dsi_host *host); | |
150 | int msm_dsi_host_disable(struct mipi_dsi_host *host); | |
151 | int msm_dsi_host_power_on(struct mipi_dsi_host *host); | |
152 | int msm_dsi_host_power_off(struct mipi_dsi_host *host); | |
153 | int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host, | |
154 | struct drm_display_mode *mode); | |
155 | struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host, | |
156 | unsigned long *panel_flags); | |
c118e290 | 157 | struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host); |
a689554b HL |
158 | int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer); |
159 | void msm_dsi_host_unregister(struct mipi_dsi_host *host); | |
9d32c498 HL |
160 | int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host, |
161 | struct msm_dsi_pll *src_pll); | |
a689554b HL |
162 | void msm_dsi_host_destroy(struct mipi_dsi_host *host); |
163 | int msm_dsi_host_modeset_init(struct mipi_dsi_host *host, | |
164 | struct drm_device *dev); | |
165 | int msm_dsi_host_init(struct msm_dsi *msm_dsi); | |
166 | ||
167 | /* dsi phy */ | |
168 | struct msm_dsi_phy; | |
ec31abf6 HL |
169 | void msm_dsi_phy_driver_register(void); |
170 | void msm_dsi_phy_driver_unregister(void); | |
13351cd1 | 171 | int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id, |
a689554b | 172 | const unsigned long bit_rate, const unsigned long esc_rate); |
29e61690 | 173 | void msm_dsi_phy_disable(struct msm_dsi_phy *phy); |
a689554b HL |
174 | void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy, |
175 | u32 *clk_pre, u32 *clk_post); | |
9d32c498 HL |
176 | struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy); |
177 | ||
a689554b HL |
178 | #endif /* __DSI_CONNECTOR_H__ */ |
179 |