change source file mode to 0644 instead of 0755
[profile/mobile/platform/kernel/u-boot-tm1.git] / drivers / video / sprdfb / dsi_1_21a / mipi_dsih_local.h
1 /**\r
2  * @file mipi_dsih_local.h\r
3  * @brief instance context structure and enumerator definitions:\r
4  * errors, events, color coding, video modes and driver state\r
5  *\r
6  *  Synopsys Inc.\r
7  *  SG DWC PT02\r
8  */\r
9 /*\r
10         The Synopsys Software Driver and documentation (hereinafter "Software")\r
11         is an unsupported proprietary work of Synopsys, Inc. unless otherwise\r
12         expressly agreed to in writing between  Synopsys and you.\r
13 \r
14         The Software IS NOT an item of Licensed Software or Licensed Product under\r
15         any End User Software License Agreement or Agreement for Licensed Product\r
16         with Synopsys or any supplement thereto.  Permission is hereby granted,\r
17         free of charge, to any person obtaining a copy of this software annotated\r
18         with this license and the Software, to deal in the Software without\r
19         restriction, including without limitation the rights to use, copy, modify,\r
20         merge, publish, distribute, sublicense, and/or sell copies of the Software,\r
21         and to permit persons to whom the Software is furnished to do so, subject\r
22         to the following conditions:\r
23 \r
24         The above copyright notice and this permission notice shall be included in\r
25         all copies or substantial portions of the Software.\r
26 \r
27         THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS\r
28         AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
29         IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
30         ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,\r
31         INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
32         (INCLUDING, BUT NOT     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
33         SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
34         CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
35         LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
36         OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\r
37         DAMAGE.\r
38  */\r
39 \r
40 #ifndef MIPI_DSIH_LOCAL_H_\r
41 #define MIPI_DSIH_LOCAL_H_\r
42 \r
43 //#include <stdint.h>\r
44 #include <common.h>\r
45 #include "../sprdfb_chip_common.h"\r
46 \r
47 //typedef unsigned char   uint8_t;\r
48 //typedef unsigned short  uint16_t;\r
49 //typedef unsigned int    uint32_t;\r
50 \r
51 #define DSIH_PIXEL_TOLERANCE  2\r
52 #define DSIH_FIFO_ACTIVE_WAIT 500    /* no of tries to access the fifo*/\r
53 #define DSIH_PHY_ACTIVE_WAIT  (50000)\r
54 #define ONE_MS_ACTIVE_WAIT    (50000) /* 50MHz processor */\r
55 #define DEFAULT_BYTE_CLOCK        (432000) /* a value to start PHY PLL - random */\r
56 #define MAX_NULL_SIZE             (1023)\r
57 #define FIFO_DEPTH            (1096)\r
58 #define WORD_LENGTH           (4) /* bytes (32bit registers) */\r
59 /** Define D-PHY type */\r
60 #ifdef SPRD_MIPI_DPHY_GEN1\r
61 /** DWC_MIPI_DPHY_BIDIR_TSMC40LP 4 Lanes Gen 1 1GHz */\r
62  #define DWC_MIPI_DPHY_BIDIR_TSMC40LP\r
63 #endif\r
64 #ifdef SPRD_MIPI_DPHY_GEN2\r
65 /** DWC_MIPI_DPHY_BIDIR_TSMC40LP / GF28LP 4 Lanes Gen 2 1.5GHz */\r
66 #define GEN_2\r
67 #endif\r
68 /** 4 Lanes Gen 2 1.5GHz testchips */\r
69 //#define TESTCHIP\r
70 /** TQL 2 Lane test chip */\r
71 /* #define DPHY2Btql */\r
72 \r
73 /**\r
74  * Errors generated by the DSI Host controller driver\r
75  */\r
76 typedef enum\r
77 {\r
78         OK = 0,\r
79         ERR_DSI_COLOR_CODING,\r
80         ERR_DSI_OUT_OF_BOUND,\r
81         ERR_DSI_OVERFLOW,\r
82         ERR_DSI_INVALID_INSTANCE,\r
83         ERR_DSI_INVALID_IO,\r
84         ERR_DSI_CORE_INCOMPATIBLE,\r
85         ERR_DSI_VIDEO_MODE,\r
86         ERR_DSI_INVALID_COMMAND,\r
87         ERR_DSI_INVALID_EVENT,\r
88         ERR_DSI_INVALID_HANDLE,\r
89         ERR_DSI_PHY_POWERUP,\r
90         ERR_DSI_PHY_INVALID,\r
91         ERR_DSI_PHY_FREQ_OUT_OF_BOUND,\r
92 #ifdef GEN_2\r
93     ERR_DSI_PHY_PLL_NOT_LOCKED,\r
94 #endif\r
95     ERR_DSI_TIMEOUT\r
96 }\r
97 dsih_error_t;\r
98 /**\r
99  * Video stream type\r
100  */\r
101 typedef enum\r
102 {\r
103         VIDEO_NON_BURST_WITH_SYNC_PULSES = 0,\r
104         VIDEO_NON_BURST_WITH_SYNC_EVENTS,\r
105         VIDEO_BURST_WITH_SYNC_PULSES\r
106 }\r
107 dsih_video_mode_t;\r
108 /**\r
109  * Color coding type (depth and pixel configuration)\r
110  */\r
111 typedef enum\r
112 {\r
113         COLOR_CODE_16BIT_CONFIG1                =  0,\r
114         COLOR_CODE_16BIT_CONFIG2                =  1,\r
115         COLOR_CODE_16BIT_CONFIG3                =  2,\r
116         COLOR_CODE_18BIT_CONFIG1                =  3,\r
117         COLOR_CODE_18BIT_CONFIG2                =  4,\r
118         COLOR_CODE_24BIT                                =  5,\r
119         COLOR_CODE_20BIT_YCC422_LOOSELY =  6,\r
120         COLOR_CODE_24BIT_YCC422                 =  7,\r
121         COLOR_CODE_16BIT_YCC422                 =  8,\r
122         COLOR_CODE_30BIT                                =  9,\r
123         COLOR_CODE_36BIT                                = 10,\r
124         COLOR_CODE_12BIT_YCC420                 = 11,\r
125         COLOR_CODE_MAX\r
126 }\r
127 dsih_color_coding_t;\r
128 /**\r
129  * Events generated by the DSI Host controller\r
130  */\r
131 typedef enum\r
132 {\r
133         ACK_SOT_ERR = 0,\r
134         ACK_SOT_SYNC,\r
135         ACK_EOT_SYNC,\r
136         ACK_ESCAPE_CMD_ERR,\r
137         ACK_LP_TX_SYNC_ERR,\r
138         ACK_HS_RX_TIMEOUT_ERR,\r
139         ACK_FALSE_CONTROL_ERR,\r
140         ACK_RSVD_DEVICE_ERR_7,\r
141         ACK_ECC_SINGLE_BIT_ERR,\r
142         ACK_ECC_MULTI_BIT_ERR,\r
143         ACK_CHECKSUM_ERR,\r
144         ACK_DSI_TYPE_NOT_RECOGNIZED_ERR,\r
145         ACK_VC_ID_INVALID_ERR,\r
146         ACK_INVALID_TX_LENGTH_ERR,\r
147         ACK_RSVD_DEVICE_ERR_14,\r
148         ACK_DSI_PROTOCOL_ERR,\r
149 \r
150         DPHY_ESC_ENTRY_ERR,\r
151         DPHY_SYNC_ESC_LP_ERR,\r
152         DPHY_CONTROL_LANE0_ERR,\r
153         DPHY_CONTENTION_LP0_ERR,\r
154         DPHY_CONTENTION_LP1_ERR,\r
155         /* start of st1 */\r
156         HS_CONTENTION,\r
157         LP_CONTENTION,\r
158         RX_ECC_SINGLE_ERR,\r
159         RX_ECC_MULTI_ERR,\r
160         RX_CRC_ERR,\r
161         RX_PKT_SIZE_ERR,\r
162         RX_EOTP_ERR,\r
163         DPI_PLD_FIFO_FULL_ERR,\r
164         GEN_TX_CMD_FIFO_FULL_ERR,\r
165         GEN_TX_PLD_FIFO_FULL_ERR,\r
166         GEN_TX_PLD_FIFO_EMPTY_ERR,\r
167         GEN_RX_PLD_FIFO_EMPTY_ERR,\r
168         GEN_RX_PLD_FIFO_FULL_ERR,\r
169 \r
170         DBI_TX_CMD_FIFO_FULL_ERR,\r
171         DBI_TX_PLD_FIFO_FULL_ERR,\r
172         DBI_RX_PLD_FIFO_EMPTY_ERR,\r
173         DBI_RX_PLD_FIFO_FULL_ERR,\r
174         DBI_ILLEGAL_CMD_ERR,\r
175         DSI_MAX_EVENT\r
176 }\r
177 dsih_event_t;\r
178 /**\r
179  * DSI Host state machine states\r
180  * Holds the mapping of D-PHY to the OS, logging I/O, and hardware access layer.\r
181  */\r
182 typedef enum\r
183 {\r
184         NOT_INITIALIZED = 0,\r
185         INITIALIZED,\r
186         ON,\r
187         OFF\r
188 }\r
189 dsih_state_t;\r
190 \r
191 /**\r
192  * MIPI D-PHY\r
193  * Holds the mapping of API to the OS, logging I/O, and hardware access layer\r
194  * and HW module information.\r
195  */\r
196 typedef struct dphy_t\r
197 {\r
198         /** Physical base address of PHY module - REQUIRED */\r
199         uint32_t address;\r
200         /** Reference frequency provided to PHY module [KHz] - REQUIRED */\r
201         uint32_t reference_freq;\r
202         /** D-PHY driver state - used internally by driver */\r
203         dsih_state_t status;\r
204         /** Function handle of any board function that needs to be called\r
205          * in order to set up the environment for the D-PHY before it is\r
206          * configured. */\r
207         void (*bsp_pre_config)(struct dphy_t *instance, void* param);\r
208         /** Register read access function handle - REQUIRED */\r
209         uint32_t (*core_read_function)(uint32_t addr, uint32_t offset);\r
210         /** Register write access function handle - REQUIRED */\r
211         void (*core_write_function)(uint32_t addr, uint32_t offset, uint32_t data);\r
212         /** Log errors function handle */\r
213         void (*log_error)(const char * string);\r
214         /** Log information function handle */\r
215         void (*log_info)(const char *fmt, ...);\r
216 }\r
217 dphy_t;\r
218 \r
219 /**\r
220  * MIPI DSI Host Controller\r
221  * Holds important information for the functioning of the DSI Host Controller API\r
222  * Holds the mapping of API to the OS, logging I/O, and hardware access layer.\r
223  * It also holds important information set by the user about the HW considerations\r
224  * and internal state variables.\r
225  */\r
226 typedef struct dsih_ctrl_t\r
227 {\r
228         /** Physical base address of controller - REQUIRED */\r
229         uint32_t address;\r
230         /** D-PHY instance associated with the DSI host controller - REQUIRED */\r
231         dphy_t phy_instance;\r
232         /**D-PHY frequency*/\r
233         uint32_t phy_feq;\r
234         /** Number of lanes physically connected to controller - REQUIRED */\r
235         uint8_t max_lanes;\r
236         /** Maximum number of byte clock cycles needed by the PHY to perform\r
237          * the Bus Turn Around operation - REQUIRED */\r
238         uint16_t max_bta_cycles;\r
239         /** Describe the color mode pin (dpicolorm) whether it is active high or low - REQUIRED */\r
240         int color_mode_polarity;\r
241         /** Describe the shut down pin (dpishutdn) whether it is active high or low - REQUIRED */\r
242         int shut_down_polarity;\r
243         /** initialised or not */\r
244         dsih_state_t status;\r
245         /** Register read access function handle - REQUIRED */\r
246         uint32_t (*core_read_function)(uint32_t addr, uint32_t offset);\r
247         /** Register write access function handle - REQUIRED */\r
248         void (*core_write_function)(uint32_t addr, uint32_t offset, uint32_t data);\r
249         /** Log errors function handle */\r
250         void (*log_error)(const char * string);\r
251         /** Log information function handle */\r
252         void (*log_info)(const char *fmt, ...);\r
253         /** Event registry holds handlers of the callbacks of registered events */\r
254         void (*event_registry[DSI_MAX_EVENT])(struct dsih_ctrl_t *instance, void *handler);\r
255 }\r
256 dsih_ctrl_t;\r
257 /**\r
258  * Video configurations\r
259  * Holds information about the video stream to be sent through the DPI interface.\r
260  */\r
261 typedef struct\r
262 {\r
263         /** Number of lanes used to send current video */\r
264         uint8_t  no_of_lanes;\r
265         /** Virtual channel number to send this video stream */\r
266         uint8_t  virtual_channel;\r
267         /** Video mode, whether burst with sync pulses, or packets with either sync pulses or events */\r
268         dsih_video_mode_t video_mode;\r
269         /** Maximum number of byte clock cycles needed by the PHY to transition\r
270          * the data lanes from high speed to low power - REQUIRED */\r
271         uint8_t max_hs_to_lp_cycles;\r
272         /** Maximum number of byte clock cycles needed by the PHY to transition\r
273          * the data lanes from low power to high speed - REQUIRED */\r
274         uint8_t max_lp_to_hs_cycles;\r
275         /** Maximum number of byte clock cycles needed by the PHY to transition\r
276          * the clock lane from high speed to low power - REQUIRED */\r
277         uint8_t max_clk_hs_to_lp_cycles;\r
278         /** Maximum number of byte clock cycles needed by the PHY to transition\r
279          * the clock lane from low power to high speed - REQUIRED */\r
280         uint8_t max_clk_lp_to_hs_cycles;\r
281         /** Enable non coninuous clock for energy saving\r
282          * - Clock lane will go to LS while not transmitting video */\r
283         int non_continuous_clock;\r
284         /** Enable receiving of ack packets */\r
285         int      receive_ack_packets;\r
286         /** Byte (lane) clock [KHz] */\r
287         uint32_t byte_clock;\r
288         /** Pixel (DPI) Clock [KHz]*/\r
289         uint32_t pixel_clock;\r
290         /** Colour coding - BPP and Pixel configuration */\r
291         dsih_color_coding_t color_coding;\r
292         /** Is 18-bit loosely packets (valid only when BPP == 18) */\r
293         int      is_18_loosely;\r
294         /** Data enable signal (dpidaten) whether it is active high or low */\r
295         int      data_en_polarity;\r
296         /** Horizontal synchronisation signal (dpihsync) whether it is active high or low */\r
297         int      h_polarity;\r
298         /** Horizontal resolution or Active Pixels */\r
299         uint16_t h_active_pixels; /* hadr */\r
300         /** Horizontal Sync Pixels - min 4 for best performance */\r
301         uint16_t h_sync_pixels;\r
302         /** Horizontal back porch pixels */\r
303         uint16_t h_back_porch_pixels;   /* hbp */\r
304         /** Total Horizontal pixels */\r
305         uint16_t h_total_pixels;  /* h_total */\r
306         /** Vertical synchronisation signal (dpivsync) whether it is active high or low */\r
307         int      v_polarity;\r
308         /** Vertical active lines (resolution) */\r
309         uint16_t v_active_lines; /* vadr */\r
310         /** Vertical sync lines */\r
311         uint16_t v_sync_lines;\r
312         /** Vertical back porch lines */\r
313         uint16_t v_back_porch_lines;   /* vbp */\r
314         /** Total no of vertical lines */\r
315         uint16_t v_total_lines;  /* v_total */\r
316 }\r
317 dsih_dpi_video_t;\r
318 \r
319 typedef struct\r
320 {\r
321         /** virtual channel */\r
322         uint8_t                         virtual_channel;\r
323         /** Commands to be sent in high speed or low power */\r
324         int                             lp;\r
325         /** Colour coding - BPP and Pixel configuration */\r
326         dsih_color_coding_t color_coding;\r
327         /** Top horizontal pixel position in the display */\r
328         uint16_t                        h_start;\r
329         /** Horizontal resolution or Active Pixels */\r
330         uint16_t                        h_active_pixels; /* hadr */\r
331         /** Left most line position in the display */\r
332         uint16_t                        v_start;\r
333         /** Vertical active lines (resolution) */\r
334         uint16_t                        v_active_lines; /* vadr */\r
335         /** Whether Tearing effect should be requested */\r
336         int                             te;\r
337         /** packet size of write memory command -\r
338          * 0 is default (optimum usage of RAM) */\r
339         uint16_t                        packet_size;\r
340 }\r
341 dsih_cmd_mode_video_t;\r
342 /**\r
343  * Register configurations\r
344  */\r
345 typedef struct\r
346 {\r
347         /** Register offset */\r
348         uint32_t addr;\r
349         /** Register data [in or out] */\r
350         uint32_t data;\r
351 }\r
352 register_config_t;\r
353 \r
354 #endif /* MIPI_DSIH_LOCAL_H_ */\r