blob: 56d5ee3bd5d43614183748fbcabc5c6bbd993e18 [file] [log] [blame]
Ajay Singh Parmar67f31322016-06-22 17:37:56 -07001/*
Aravind Venkateswaranb3fc3a02018-03-05 16:09:05 -08002 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
Ajay Singh Parmar67f31322016-06-22 17:37:56 -07003 *
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_PHY_H_
15#define _DSI_PHY_H_
16
17#include "dsi_defs.h"
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +053018#include "dsi_clk.h"
19#include "dsi_pwr.h"
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070020#include "dsi_phy_hw.h"
21
22struct dsi_ver_spec_info {
23 enum dsi_phy_version version;
24 u32 lane_cfg_count;
25 u32 strength_cfg_count;
26 u32 regulator_cfg_count;
27 u32 timing_cfg_count;
28};
29
30/**
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070031 * struct dsi_phy_power_info - digital and analog power supplies for DSI PHY
32 * @digital: Digital power supply for DSI PHY.
33 * @phy_pwr: Analog power supplies for DSI PHY to work.
34 */
35struct dsi_phy_power_info {
36 struct dsi_regulator_info digital;
37 struct dsi_regulator_info phy_pwr;
38};
39
40/**
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +053041 * enum phy_engine_state - define engine status for dsi phy.
42 * @DSI_PHY_ENGINE_OFF: Engine is turned off.
43 * @DSI_PHY_ENGINE_ON: Engine is turned on.
44 * @DSI_PHY_ENGINE_MAX: Maximum value.
45 */
46enum phy_engine_state {
47 DSI_PHY_ENGINE_OFF = 0,
48 DSI_PHY_ENGINE_ON,
49 DSI_PHY_ENGINE_MAX,
50};
51
52
53/**
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070054 * struct msm_dsi_phy - DSI PHY object
55 * @pdev: Pointer to platform device.
56 * @index: Instance id.
57 * @name: Name of the PHY instance.
58 * @refcount: Reference count.
59 * @phy_lock: Mutex for hardware and object access.
60 * @ver_info: Version specific phy parameters.
61 * @hw: DSI PHY hardware object.
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +053062 * @pwr_info: Power information.
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070063 * @cfg: DSI phy configuration.
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +053064 * @clk_cb: structure containing call backs for clock control
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070065 * @power_state: True if PHY is powered on.
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +053066 * @dsi_phy_state: PHY state information.
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070067 * @mode: Current mode.
68 * @data_lanes: Number of data lanes used.
69 * @dst_format: Destination format.
Alan Kwong797e0892017-10-17 09:37:24 -040070 * @allow_phy_power_off: True if PHY is allowed to power off when idle
Alan Kwong60cc3552017-11-01 22:08:48 -040071 * @regulator_min_datarate_bps: Minimum per lane data rate to turn on regulator
72 * @regulator_required: True if phy regulator is required
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070073 */
74struct msm_dsi_phy {
75 struct platform_device *pdev;
76 int index;
77 const char *name;
78 u32 refcount;
79 struct mutex phy_lock;
80
81 const struct dsi_ver_spec_info *ver_info;
82 struct dsi_phy_hw hw;
83
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070084 struct dsi_phy_power_info pwr_info;
85
86 struct dsi_phy_cfg cfg;
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +053087 struct clk_ctrl_cb clk_cb;
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070088
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +053089 enum phy_engine_state dsi_phy_state;
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070090 bool power_state;
91 struct dsi_mode_info mode;
92 enum dsi_data_lanes data_lanes;
93 enum dsi_pixel_format dst_format;
Alan Kwong797e0892017-10-17 09:37:24 -040094
95 bool allow_phy_power_off;
Alan Kwong60cc3552017-11-01 22:08:48 -040096 u32 regulator_min_datarate_bps;
97 bool regulator_required;
Ajay Singh Parmar67f31322016-06-22 17:37:56 -070098};
99
100/**
101 * dsi_phy_get() - get a dsi phy handle from device node
102 * @of_node: device node for dsi phy controller
103 *
104 * Gets the DSI PHY handle for the corresponding of_node. The ref count is
105 * incremented to one all subsequents get will fail until the original client
106 * calls a put.
107 *
108 * Return: DSI PHY handle or an error code.
109 */
110struct msm_dsi_phy *dsi_phy_get(struct device_node *of_node);
111
112/**
113 * dsi_phy_put() - release dsi phy handle
114 * @dsi_phy: DSI PHY handle.
115 *
116 * Release the DSI PHY hardware. Driver will clean up all resources and puts
117 * back the DSI PHY into reset state.
118 */
119void dsi_phy_put(struct msm_dsi_phy *dsi_phy);
120
121/**
122 * dsi_phy_drv_init() - initialize dsi phy driver
123 * @dsi_phy: DSI PHY handle.
124 *
125 * Initializes DSI PHY driver. Should be called after dsi_phy_get().
126 *
127 * Return: error code.
128 */
129int dsi_phy_drv_init(struct msm_dsi_phy *dsi_phy);
130
131/**
132 * dsi_phy_drv_deinit() - de-initialize dsi phy driver
133 * @dsi_phy: DSI PHY handle.
134 *
135 * Release all resources acquired by dsi_phy_drv_init().
136 *
137 * Return: error code.
138 */
139int dsi_phy_drv_deinit(struct msm_dsi_phy *dsi_phy);
140
141/**
142 * dsi_phy_validate_mode() - validate a display mode
143 * @dsi_phy: DSI PHY handle.
144 * @mode: Mode information.
145 *
146 * Validation will fail if the mode cannot be supported by the PHY driver or
147 * hardware.
148 *
149 * Return: error code.
150 */
151int dsi_phy_validate_mode(struct msm_dsi_phy *dsi_phy,
152 struct dsi_mode_info *mode);
153
154/**
155 * dsi_phy_set_power_state() - enable/disable dsi phy power supplies
156 * @dsi_phy: DSI PHY handle.
157 * @enable: Boolean flag to enable/disable.
158 *
159 * Return: error code.
160 */
161int dsi_phy_set_power_state(struct msm_dsi_phy *dsi_phy, bool enable);
162
163/**
164 * dsi_phy_enable() - enable DSI PHY hardware
165 * @dsi_phy: DSI PHY handle.
166 * @config: DSI host configuration.
167 * @pll_source: Source PLL for PHY clock.
168 * @skip_validation: Validation will not be performed on parameters.
Shashank Babu Chinta Venkata7d608732017-05-31 14:10:26 -0700169 * @is_cont_splash_enabled: check whether continuous splash enabled.
Ajay Singh Parmar67f31322016-06-22 17:37:56 -0700170 *
171 * Validates and enables DSI PHY.
172 *
173 * Return: error code.
174 */
175int dsi_phy_enable(struct msm_dsi_phy *dsi_phy,
176 struct dsi_host_config *config,
177 enum dsi_phy_pll_source pll_source,
Shashank Babu Chinta Venkata7d608732017-05-31 14:10:26 -0700178 bool skip_validation,
179 bool is_cont_splash_enabled);
Ajay Singh Parmar67f31322016-06-22 17:37:56 -0700180
181/**
182 * dsi_phy_disable() - disable DSI PHY hardware.
183 * @phy: DSI PHY handle.
184 *
185 * Return: error code.
186 */
187int dsi_phy_disable(struct msm_dsi_phy *phy);
188
189/**
Padmanabhan Komanduru56611ef2016-12-19 12:21:11 +0530190 * dsi_phy_set_ulps() - set ulps state for DSI pHY
191 * @phy: DSI PHY handle
192 * @config: DSi host configuration information.
193 * @enable: Enable/Disable
Veera Sundaram Sankaranbb3680f2017-04-21 13:20:46 -0700194 * @clamp_enabled: mmss_clamp enabled/disabled
Padmanabhan Komanduru56611ef2016-12-19 12:21:11 +0530195 *
196 * Return: error code.
197 */
198int dsi_phy_set_ulps(struct msm_dsi_phy *phy, struct dsi_host_config *config,
Veera Sundaram Sankaranbb3680f2017-04-21 13:20:46 -0700199 bool enable, bool clamp_enabled);
Padmanabhan Komanduru56611ef2016-12-19 12:21:11 +0530200
201/**
Padmanabhan Komandurudbd2fb02016-12-02 15:18:49 +0530202 * dsi_phy_clk_cb_register() - Register PHY clock control callback
203 * @phy: DSI PHY handle
204 * @clk_cb: Structure containing call back for clock control
205 *
206 * Return: error code.
207 */
208int dsi_phy_clk_cb_register(struct msm_dsi_phy *phy,
209 struct clk_ctrl_cb *clk_cb);
210
211/**
212 * dsi_phy_idle_ctrl() - enable/disable DSI PHY during idle screen
213 * @phy: DSI PHY handle
214 * @enable: boolean to specify PHY enable/disable.
215 *
216 * Return: error code.
217 */
218int dsi_phy_idle_ctrl(struct msm_dsi_phy *phy, bool enable);
219
220/**
Alan Kwong60cc3552017-11-01 22:08:48 -0400221 * dsi_phy_set_clk_freq() - set DSI PHY clock frequency setting
222 * @phy: DSI PHY handle
223 * @clk_freq: link clock frequency
224 *
225 * Return: error code.
226 */
227int dsi_phy_set_clk_freq(struct msm_dsi_phy *phy,
228 struct link_clk_freq *clk_freq);
229
230/**
Ajay Singh Parmar67f31322016-06-22 17:37:56 -0700231 * dsi_phy_set_timing_params() - timing parameters for the panel
232 * @phy: DSI PHY handle
233 * @timing: array holding timing params.
234 * @size: size of the array.
235 *
236 * When PHY timing calculator is not implemented, this array will be used to
237 * pass PHY timing information.
238 *
239 * Return: error code.
240 */
241int dsi_phy_set_timing_params(struct msm_dsi_phy *phy,
Padmanabhan Komanduruee89d212016-12-19 12:51:31 +0530242 u32 *timing, u32 size);
Ajay Singh Parmar67f31322016-06-22 17:37:56 -0700243
244/**
Sandeep Panda11b20d82017-06-19 12:57:27 +0530245 * dsi_phy_lane_reset() - Reset DSI PHY lanes in case of error
246 * @phy: DSI PHY handle
247 *
248 * Return: error code.
249 */
250int dsi_phy_lane_reset(struct msm_dsi_phy *phy);
251
252/**
Aravind Venkateswaranb3fc3a02018-03-05 16:09:05 -0800253 * dsi_phy_toggle_resync_fifo() - toggle resync retime FIFO
254 * @phy: DSI PHY handle
255 *
256 * Toggle the resync retime FIFO to synchronize the data paths.
257 * This should be done everytime there is a change in the link clock
258 * rate
259 */
260void dsi_phy_toggle_resync_fifo(struct msm_dsi_phy *phy);
261
262/**
Ajay Singh Parmar67f31322016-06-22 17:37:56 -0700263 * dsi_phy_drv_register() - register platform driver for dsi phy
264 */
265void dsi_phy_drv_register(void);
266
267/**
268 * dsi_phy_drv_unregister() - unregister platform driver
269 */
270void dsi_phy_drv_unregister(void);
271
272#endif /* _DSI_PHY_H_ */