2 * @file mipi_dsih_hal.c
\r
3 * @brief Hardware Abstraction Level of DWC MIPI DSI HOST controller
\r
8 #include "mipi_dsih_hal.h"
\r
11 * Write a 32-bit word to the DSI Host core
\r
12 * @param instance pointer to structure holding the DSI Host core information
\r
13 * @param reg_address register offset in core
\r
14 * @param data 32-bit word to be written to register
\r
16 void mipi_dsih_write_word(dsih_ctrl_t * instance, uint32_t reg_address, uint32_t data)
\r
19 instance->core_write_function(instance->address, reg_address, data);
\r
22 * Write a bit field o a 32-bit word to the DSI Host core
\r
23 * @param instance pointer to structure holding the DSI Host core information
\r
24 * @param reg_address register offset in core
\r
25 * @param data to be written to register
\r
26 * @param shift bit shift from the left (system is BIG ENDIAN)
\r
27 * @param width of bit field
\r
29 void mipi_dsih_write_part(dsih_ctrl_t * instance, uint32_t reg_address, uint32_t data, uint8_t shift, uint8_t width)
\r
31 uint32_t mask = (1 << width) - 1;
\r
32 uint32_t temp = mipi_dsih_read_word(instance, reg_address);
\r
34 temp &= ~(mask << shift);
\r
35 temp |= (data & mask) << shift;
\r
36 mipi_dsih_write_word(instance, reg_address, temp);
\r
39 * Write a 32-bit word to the DSI Host core
\r
40 * @param instance pointer to structure holding the DSI Host core information
\r
41 * @param reg_address offset of register
\r
42 * @return 32-bit word value stored in register
\r
44 uint32_t mipi_dsih_read_word(dsih_ctrl_t * instance, uint32_t reg_address)
\r
46 return instance->core_read_function(instance->address, reg_address);
\r
49 * Write a 32-bit word to the DSI Host core
\r
50 * @param instance pointer to structure holding the DSI Host core information
\r
51 * @param reg_address offset of register in core
\r
52 * @param shift bit shift from the left (system is BIG ENDIAN)
\r
53 * @param width of bit field
\r
54 * @return bit field read from register
\r
56 uint32_t mipi_dsih_read_part(dsih_ctrl_t * instance, uint32_t reg_address, uint8_t shift, uint8_t width)
\r
58 return (mipi_dsih_read_word(instance, reg_address) >> shift) & ((1 << width) - 1);
\r
61 * Get DSI Host core version
\r
62 * @param instance pointer to structure holding the DSI Host core information
\r
63 * @return ascii number of the version
\r
65 uint32_t mipi_dsih_hal_get_version(dsih_ctrl_t * instance)
\r
67 return mipi_dsih_read_word(instance, R_DSI_HOST_VERSION);
\r
70 * Modify power status of DSI Host core
\r
71 * @param instance pointer to structure holding the DSI Host core information
\r
72 * @param on (1) or off (0)
\r
74 void mipi_dsih_hal_power(dsih_ctrl_t * instance, int on)
\r
76 mipi_dsih_write_part(instance, R_DSI_HOST_PWR_UP, on, 0, 1);
\r
79 * Get the power status of the DSI Host core
\r
80 * @param instance pointer to structure holding the DSI Host core information
\r
81 * @return power status
\r
83 int mipi_dsih_hal_get_power(dsih_ctrl_t * instance)
\r
85 return (int)(mipi_dsih_read_part(instance, R_DSI_HOST_PWR_UP, 0, 1));
\r
88 * Write transmission escape timeout
\r
89 * a safe guard so that the state machine would reset if transmission
\r
91 * @param instance pointer to structure holding the DSI Host core information
\r
92 * @param tx_escape_division
\r
94 void mipi_dsih_hal_tx_escape_division(dsih_ctrl_t * instance, uint8_t tx_escape_division)
\r
96 mipi_dsih_write_part(instance, R_DSI_HOST_CLK_MGR, tx_escape_division, 0, 8);
\r
99 * Write the DPI video virtual channel destination
\r
100 * @param instance pointer to structure holding the DSI Host core information
\r
101 * @param vc virtual channel
\r
103 void mipi_dsih_hal_dpi_video_vc(dsih_ctrl_t * instance, uint8_t vc)
\r
105 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_VCID, (uint32_t)(vc), 0, 2);
\r
108 * Get the DPI video virtual channel destination
\r
109 * @param instance pointer to structure holding the DSI Host core information
\r
110 * @return virtual channel
\r
112 uint8_t mipi_dsih_hal_dpi_get_video_vc(dsih_ctrl_t * instance)
\r
114 return mipi_dsih_read_part(instance, R_DSI_HOST_DPI_VCID, 0, 2);
\r
117 * Set DPI video color coding
\r
118 * @param instance pointer to structure holding the DSI Host core information
\r
119 * @param color_coding enum (configuration and color depth)
\r
120 * @return error code
\r
122 dsih_error_t mipi_dsih_hal_dpi_color_coding(dsih_ctrl_t * instance, dsih_color_coding_t color_coding)
\r
124 dsih_error_t err = OK;
\r
125 if (color_coding > COLOR_CODE_MAX)
\r
127 if (instance->log_error != 0)
\r
129 instance->log_error("sprdfb: invalid colour configuration");
\r
131 err = ERR_DSI_COLOR_CODING;
\r
135 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_COLOR_CODE, color_coding, 0, 4);
\r
140 * Get DPI video color coding
\r
141 * @param instance pointer to structure holding the DSI Host core information
\r
142 * @return color coding enum (configuration and color depth)
\r
144 dsih_color_coding_t mipi_dsih_hal_dpi_get_color_coding(dsih_ctrl_t * instance)
\r
146 return (dsih_color_coding_t)(mipi_dsih_read_part(instance, R_DSI_HOST_DPI_COLOR_CODE, 0, 4));
\r
149 * Get DPI video color depth
\r
150 * @param instance pointer to structure holding the DSI Host core information
\r
151 * @return number of bits per pixel
\r
153 uint8_t mipi_dsih_hal_dpi_get_color_depth(dsih_ctrl_t * instance)
\r
155 uint8_t color_depth = 0;
\r
156 switch (mipi_dsih_read_part(instance, R_DSI_HOST_DPI_COLOR_CODE, 0, 4))
\r
191 return color_depth;
\r
194 * Get DPI video pixel configuration
\r
195 * @param instance pointer to structure holding the DSI Host core information
\r
196 * @return pixel configuration
\r
198 uint8_t mipi_dsih_hal_dpi_get_color_config(dsih_ctrl_t * instance)
\r
200 uint8_t color_config = 0;
\r
201 switch (mipi_dsih_read_part(instance, R_DSI_HOST_DPI_COLOR_CODE, 0, 4))
\r
222 return color_config;
\r
225 * Set DPI loosely packetisation video (used only when color depth = 18
\r
226 * @param instance pointer to structure holding the DSI Host core information
\r
229 void mipi_dsih_hal_dpi_18_loosely_packet_en(dsih_ctrl_t * instance, int enable)
\r
231 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_COLOR_CODE, enable, 8, 1);
\r
234 * Set DPI color mode pin polarity
\r
235 * @param instance pointer to structure holding the DSI Host core information
\r
236 * @param active_low (1) or active high (0)
\r
238 void mipi_dsih_hal_dpi_color_mode_pol(dsih_ctrl_t * instance, int active_low)
\r
240 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_CFG_POL, active_low, 4, 1);
\r
243 * Set DPI shut down pin polarity
\r
244 * @param instance pointer to structure holding the DSI Host core information
\r
245 * @param active_low (1) or active high (0)
\r
247 void mipi_dsih_hal_dpi_shut_down_pol(dsih_ctrl_t * instance, int active_low)
\r
249 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_CFG_POL, active_low, 3, 1);
\r
252 * Set DPI horizontal sync pin polarity
\r
253 * @param instance pointer to structure holding the DSI Host core information
\r
254 * @param active_low (1) or active high (0)
\r
256 void mipi_dsih_hal_dpi_hsync_pol(dsih_ctrl_t * instance, int active_low)
\r
258 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_CFG_POL, active_low, 2, 1);
\r
261 * Set DPI vertical sync pin polarity
\r
262 * @param instance pointer to structure holding the DSI Host core information
\r
263 * @param active_low (1) or active high (0)
\r
265 void mipi_dsih_hal_dpi_vsync_pol(dsih_ctrl_t * instance, int active_low)
\r
267 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_CFG_POL, active_low, 1, 1);
\r
270 * Set DPI data enable pin polarity
\r
271 * @param instance pointer to structure holding the DSI Host core information
\r
272 * @param active_low (1) or active high (0)
\r
274 void mipi_dsih_hal_dpi_dataen_pol(dsih_ctrl_t * instance, int active_low)
\r
276 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_CFG_POL, active_low, 0, 1);
\r
279 * Enable FRAME BTA ACK
\r
280 * @param instance pointer to structure holding the DSI Host core information
\r
281 * @param enable (1) - disable (0)
\r
283 void mipi_dsih_hal_dpi_frame_ack_en(dsih_ctrl_t * instance, int enable)
\r
285 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 14, 1);
\r
288 * Enable null packets (value in null packet size will be taken in calculations)
\r
289 * @param instance pointer to structure holding the DSI Host core information
\r
290 * @param enable (1) - disable (0)
\r
291 * @note function retained for backward compatibility (not used from 1.20a on)
\r
293 void mipi_dsih_hal_dpi_null_packet_en(dsih_ctrl_t * instance, int enable)
\r
297 * Enable multi packets (value in no of chunks will be taken in calculations)
\r
298 * @param instance pointer to structure holding the DSI Host core information
\r
299 * @param enable (1) - disable (0)
\r
301 void mipi_dsih_hal_dpi_multi_packet_en(dsih_ctrl_t * instance, int enable)
\r
305 * Enable return to low power mode inside horizontal front porch periods when
\r
307 * @param instance pointer to structure holding the DSI Host core information
\r
308 * @param enable (1) - disable (0)
\r
310 void mipi_dsih_hal_dpi_lp_during_hfp(dsih_ctrl_t * instance, int enable)
\r
312 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 13, 1);
\r
315 * Enable return to low power mode inside horizontal back porch periods when
\r
317 * @param instance pointer to structure holding the DSI Host core information
\r
318 * @param enable (1) - disable (0)
\r
320 void mipi_dsih_hal_dpi_lp_during_hbp(dsih_ctrl_t * instance, int enable)
\r
322 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 12, 1);
\r
325 * Enable return to low power mode inside vertical active lines periods when
\r
327 * @param instance pointer to structure holding the DSI Host core information
\r
328 * @param enable (1) - disable (0)
\r
330 void mipi_dsih_hal_dpi_lp_during_vactive(dsih_ctrl_t * instance, int enable)
\r
332 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 11, 1);
\r
335 * Enable return to low power mode inside vertical front porch periods when
\r
337 * @param instance pointer to structure holding the DSI Host core information
\r
338 * @param enable (1) - disable (0)
\r
340 void mipi_dsih_hal_dpi_lp_during_vfp(dsih_ctrl_t * instance, int enable)
\r
342 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 10, 1);
\r
345 * Enable return to low power mode inside vertical back porch periods when
\r
347 * @param instance pointer to structure holding the DSI Host core information
\r
348 * @param enable (1) - disable (0)
\r
350 void mipi_dsih_hal_dpi_lp_during_vbp(dsih_ctrl_t * instance, int enable)
\r
352 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 9, 1);
\r
355 * Enable return to low power mode inside vertical sync periods when
\r
357 * @param instance pointer to structure holding the DSI Host core information
\r
358 * @param enable (1) - disable (0)
\r
360 void mipi_dsih_hal_dpi_lp_during_vsync(dsih_ctrl_t * instance, int enable)
\r
362 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 8, 1);
\r
365 * Set DPI video mode type (burst/non-burst - with sync pulses or events)
\r
366 * @param instance pointer to structure holding the DSI Host core information
\r
368 * @return error code
\r
370 dsih_error_t mipi_dsih_hal_dpi_video_mode_type(dsih_ctrl_t * instance, dsih_video_mode_t type)
\r
374 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, type, 0, 2);
\r
379 if (instance->log_error != 0)
\r
381 instance->log_error("sprdfb: undefined type");
\r
383 return ERR_DSI_OUT_OF_BOUND;
\r
387 * Enable/disable DPI video mode
\r
388 * @param instance pointer to structure holding the DSI Host core information
\r
389 * @param enable (1) - disable (0)
\r
391 void mipi_dsih_hal_dpi_video_mode_en(dsih_ctrl_t * instance, int enable)
\r
393 mipi_dsih_write_part(instance, R_DSI_HOST_MODE_CFG, enable? 0: 1, 0, 1);
\r
396 * Get the status of video mode, whether enabled or not in core
\r
397 * @param instance pointer to structure holding the DSI Host core information
\r
400 int mipi_dsih_hal_dpi_is_video_mode(dsih_ctrl_t * instance)
\r
402 return (mipi_dsih_read_part(instance, R_DSI_HOST_MODE_CFG, 0, 1) == 0);
\r
405 * Write the null packet size - will only be taken into account when null
\r
406 * packets are enabled.
\r
407 * @param instance pointer to structure holding the DSI Host core information
\r
408 * @param size of null packet
\r
409 * @return error code
\r
411 dsih_error_t mipi_dsih_hal_dpi_null_packet_size(dsih_ctrl_t * instance, uint16_t size)
\r
413 if (size < (1 << 13)) /* 13-bit field */
\r
415 mipi_dsih_write_part(instance, R_DSI_HOST_VID_NULL_SIZE, size, 0, 13);
\r
420 return ERR_DSI_OUT_OF_BOUND;
\r
424 * Write no of chunks to core - taken into consideration only when multi packet
\r
426 * @param instance pointer to structure holding the DSI Host core information
\r
427 * @param no of chunks
\r
429 dsih_error_t mipi_dsih_hal_dpi_chunks_no(dsih_ctrl_t * instance, uint16_t no)
\r
431 if (no < (1 << 13))
\r
433 mipi_dsih_write_part(instance, R_DSI_HOST_VID_NUM_CHUNKS, no, 0, 13);
\r
438 return ERR_DSI_OUT_OF_BOUND;
\r
442 * Write video packet size. obligatory for sending video
\r
443 * @param instance pointer to structure holding the DSI Host core information
\r
444 * @param size of video packet - containing information
\r
445 * @return error code
\r
447 dsih_error_t mipi_dsih_hal_dpi_video_packet_size(dsih_ctrl_t * instance, uint16_t size)
\r
449 if (size < (1 << 14)) /* 14-bit field */
\r
451 mipi_dsih_write_part(instance, R_DSI_HOST_VID_PKT_SIZE, size, 0, 14);
\r
456 return ERR_DSI_OUT_OF_BOUND;
\r
460 * function retained for backward compatibility (not used from 1.20a on)
\r
461 * @param instance pointer to structure holding the DSI Host core information
\r
462 * @param enable (1) - disable (0)
\r
464 void mipi_dsih_hal_edpi_enable(dsih_ctrl_t * instance, int enable)
\r
468 * Specifiy the size of the packet memory write start/continue
\r
469 * @param instance pointer to structure holding the DSI Host core information
\r
470 * @ size of the packet
\r
471 * @note when different than zero (0) eDPI is enabled
\r
473 void mipi_dsih_hal_edpi_max_allowed_size(dsih_ctrl_t * instance, uint16_t size)
\r
475 mipi_dsih_write_part(instance, R_DSI_HOST_EDPI_CMD_SIZE, size, 0, 16);
\r
478 * Enable tear effect acknowledge
\r
479 * @param instance pointer to structure holding the DSI Host core information
\r
480 * @param enable (1) - disable (0)
\r
482 void mipi_dsih_hal_tear_effect_ack_en(dsih_ctrl_t * instance, int enable)
\r
484 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, enable, 0, 1);
\r
487 * Enable packets acknowledge request after each packet transmission
\r
488 * @param instance pointer to structure holding the DSI Host core information
\r
489 * @param enable (1) - disable (0)
\r
491 void mipi_dsih_hal_cmd_ack_en(dsih_ctrl_t * instance, int enable)
\r
493 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, enable, 1, 1);
\r
496 * Set DCS command packet transmission to transmission type
\r
497 * @param instance pointer to structure holding the DSI Host core information
\r
498 * @param no_of_param of command
\r
499 * @param lp transmit in low power
\r
500 * @return error code
\r
502 dsih_error_t mipi_dsih_hal_dcs_wr_tx_type(dsih_ctrl_t * instance, unsigned no_of_param, int lp)
\r
504 switch (no_of_param)
\r
507 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 16, 1);
\r
510 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 17, 1);
\r
513 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 19, 1);
\r
519 * Set DCS read command packet transmission to transmission type
\r
520 * @param instance pointer to structure holding the DSI Host core information
\r
521 * @param no_of_param of command
\r
522 * @param lp transmit in low power
\r
523 * @return error code
\r
525 dsih_error_t mipi_dsih_hal_dcs_rd_tx_type(dsih_ctrl_t * instance, unsigned no_of_param, int lp)
\r
527 dsih_error_t err = OK;
\r
528 switch (no_of_param)
\r
531 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 18, 1);
\r
534 if (instance->log_error != 0)
\r
536 instance->log_error("sprdfb: undefined DCS Read packet type");
\r
538 err = ERR_DSI_OUT_OF_BOUND;
\r
544 /*Jessica add begin: to support max read packet size command */
\r
545 dsih_error_t mipi_dsih_hal_max_rd_packet_size_type(dsih_ctrl_t * instance, int lp)
\r
547 dsih_error_t err = OK;
\r
548 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 10, 1);
\r
551 /*Jessica add end*/
\r
554 * Set generic write command packet transmission to transmission type
\r
555 * @param instance pointer to structure holding the DSI Host core information
\r
556 * @param no_of_param of command
\r
557 * @param lp transmit in low power
\r
558 * @return error code
\r
560 dsih_error_t mipi_dsih_hal_gen_wr_tx_type(dsih_ctrl_t * instance, unsigned no_of_param, int lp)
\r
562 switch (no_of_param)
\r
565 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 8, 1);
\r
568 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 9, 1);
\r
571 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 10, 1);
\r
574 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 14, 1);
\r
580 * Set generic command packet transmission to transmission type
\r
581 * @param instance pointer to structure holding the DSI Host core information
\r
582 * @param no_of_param of command
\r
583 * @param lp transmit in low power
\r
584 * @return error code
\r
586 dsih_error_t mipi_dsih_hal_gen_rd_tx_type(dsih_ctrl_t * instance, unsigned no_of_param, int lp)
\r
588 dsih_error_t err = OK;
\r
589 switch (no_of_param)
\r
592 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 11, 1);
\r
595 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 12, 1);
\r
598 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 13, 1);
\r
601 if (instance->log_error != 0)
\r
603 instance->log_error("sprdfb: undefined Generic Read packet type");
\r
605 err = ERR_DSI_OUT_OF_BOUND;
\r
611 * Configure maximum read packet size command transmission type
\r
612 * @param instance pointer to structure holding the DSI Host core information
\r
613 * @param lp set to low power
\r
615 void mipi_dsih_hal_max_rd_size_tx_type(dsih_ctrl_t * instance, int lp)
\r
617 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 24, 1);
\r
620 * Enable command mode (Generic interface)
\r
621 * @param instance pointer to structure holding the DSI Host core information
\r
624 void mipi_dsih_hal_gen_cmd_mode_en(dsih_ctrl_t * instance, int enable)
\r
626 mipi_dsih_write_part(instance, R_DSI_HOST_MODE_CFG, enable? 1: 0, 0, 1);
\r
629 * Retrieve the controller's status of whether command mode is ON or not
\r
630 * @param instance pointer to structure holding the DSI Host core information
\r
631 * @return whether command mode is ON
\r
633 int mipi_dsih_hal_gen_is_cmd_mode(dsih_ctrl_t * instance)
\r
635 return (mipi_dsih_read_part(instance, R_DSI_HOST_MODE_CFG, 0, 1) == 1);
\r
638 * Configure the Horizontal Line time
\r
639 * @param instance pointer to structure holding the DSI Host core information
\r
640 * @param time taken to transmit the total of the horizontal line
\r
642 void mipi_dsih_hal_dpi_hline(dsih_ctrl_t * instance, uint16_t time)
\r
644 mipi_dsih_write_part(instance, R_DSI_HOST_VID_HLINE_TIME, time, 0, 15);
\r
647 * Configure the Horizontal back porch time
\r
648 * @param instance pointer to structure holding the DSI Host core information
\r
649 * @param time taken to transmit the horizontal back porch
\r
651 void mipi_dsih_hal_dpi_hbp(dsih_ctrl_t * instance, uint16_t time)
\r
653 mipi_dsih_write_part(instance, R_DSI_HOST_VID_HBP_TIME, time, 0, 12);
\r
656 * Configure the Horizontal sync time
\r
657 * @param instance pointer to structure holding the DSI Host core information
\r
658 * @param time taken to transmit the horizontal sync
\r
660 void mipi_dsih_hal_dpi_hsa(dsih_ctrl_t * instance, uint16_t time)
\r
662 mipi_dsih_write_part(instance, R_DSI_HOST_VID_HSA_TIME, time, 0, 12);
\r
665 * Configure the vertical active lines of the video stream
\r
666 * @param instance pointer to structure holding the DSI Host core information
\r
669 void mipi_dsih_hal_dpi_vactive(dsih_ctrl_t * instance, uint16_t lines)
\r
671 mipi_dsih_write_part(instance, R_DSI_HOST_VID_VACTIVE_LINES, lines, 0, 14);
\r
674 * Configure the vertical front porch lines of the video stream
\r
675 * @param instance pointer to structure holding the DSI Host core information
\r
678 void mipi_dsih_hal_dpi_vfp(dsih_ctrl_t * instance, uint16_t lines)
\r
680 mipi_dsih_write_part(instance, R_DSI_HOST_VID_VFP_LINES, lines, 0, 10);
\r
683 * Configure the vertical back porch lines of the video stream
\r
684 * @param instance pointer to structure holding the DSI Host core information
\r
687 void mipi_dsih_hal_dpi_vbp(dsih_ctrl_t * instance, uint16_t lines)
\r
689 mipi_dsih_write_part(instance, R_DSI_HOST_VID_VBP_LINES, lines, 0, 10);
\r
692 * Configure the vertical sync lines of the video stream
\r
693 * @param instance pointer to structure holding the DSI Host core information
\r
696 void mipi_dsih_hal_dpi_vsync(dsih_ctrl_t * instance, uint16_t lines)
\r
698 mipi_dsih_write_part(instance, R_DSI_HOST_VID_VSA_LINES, lines, 0, 10);
\r
701 * configure timeout divisions (so they would have more clock ticks)
\r
702 * @param instance pointer to structure holding the DSI Host core information
\r
703 * @param byte_clk_division_factor no of hs cycles before transiting back to LP in
\r
704 * (lane_clk / byte_clk_division_factor)
\r
706 void mipi_dsih_hal_timeout_clock_division(dsih_ctrl_t * instance, uint8_t byte_clk_division_factor)
\r
708 mipi_dsih_write_part(instance, R_DSI_HOST_CLK_MGR, byte_clk_division_factor, 8, 8);
\r
711 * Configure the Low power receive time out
\r
712 * @param instance pointer to structure holding the DSI Host core information
\r
713 * @param count (of byte cycles)
\r
715 void mipi_dsih_hal_lp_rx_timeout(dsih_ctrl_t * instance, uint16_t count)
\r
717 mipi_dsih_write_part(instance, R_DSI_HOST_TO_CNT_CFG, count, 0, 16);
\r
720 * Configure a high speed transmission time out7
\r
721 * @param instance pointer to structure holding the DSI Host core information
\r
722 * @param count (byte cycles)
\r
724 void mipi_dsih_hal_hs_tx_timeout(dsih_ctrl_t * instance, uint16_t count)
\r
726 mipi_dsih_write_part(instance, R_DSI_HOST_TO_CNT_CFG, count, 16, 16);
\r
729 * Get the error 0 interrupt register status
\r
730 * @param instance pointer to structure holding the DSI Host core information
\r
731 * @param mask the mask to be read from the register
\r
732 * @return error status 0 value
\r
734 uint32_t mipi_dsih_hal_int_status_0(dsih_ctrl_t * instance, uint32_t mask)
\r
736 return (mipi_dsih_read_word(instance, R_DSI_HOST_INT_ST0) & mask);
\r
739 * Get the error 1 interrupt register status
\r
740 * @param instance pointer to structure holding the DSI Host core information
\r
741 * @param mask the mask to be read from the register
\r
742 * @return error status 1 value
\r
744 uint32_t mipi_dsih_hal_int_status_1(dsih_ctrl_t * instance, uint32_t mask)
\r
746 return (mipi_dsih_read_word(instance, R_DSI_HOST_INT_ST1) & mask);
\r
749 * Configure MASK (hiding) of interrupts coming from error 0 source
\r
750 * @param instance pointer to structure holding the DSI Host core information
\r
751 * @param mask to be written to the register
\r
753 void mipi_dsih_hal_int_mask_0(dsih_ctrl_t * instance, uint32_t mask)
\r
755 mipi_dsih_write_word(instance, R_DSI_HOST_INT_MSK0, mask);
\r
758 * Get the ERROR MASK 0 register status
\r
759 * @param instance pointer to structure holding the DSI Host core information
\r
760 * @param mask the bits to read from the mask register
\r
762 uint32_t mipi_dsih_hal_int_get_mask_0(dsih_ctrl_t * instance, uint32_t mask)
\r
764 return (mipi_dsih_read_word(instance, R_DSI_HOST_INT_MSK0) & mask);
\r
767 * Configure MASK (hiding) of interrupts coming from error 0 source
\r
768 * @param instance pointer to structure holding the DSI Host core information
\r
769 * @param mask the mask to be written to the register
\r
771 void mipi_dsih_hal_int_mask_1(dsih_ctrl_t * instance, uint32_t mask)
\r
773 mipi_dsih_write_word(instance, R_DSI_HOST_INT_MSK1, mask);
\r
776 * Get the ERROR MASK 1 register status
\r
777 * @param instance pointer to structure holding the DSI Host core information
\r
778 * @param mask the bits to read from the mask register
\r
780 uint32_t mipi_dsih_hal_int_get_mask_1(dsih_ctrl_t * instance, uint32_t mask)
\r
782 return (mipi_dsih_read_word(instance, R_DSI_HOST_INT_MSK1) & mask);
\r
784 /* DBI NOT IMPLEMENTED */
\r
785 void mipi_dsih_hal_dbi_out_color_coding(dsih_ctrl_t * instance, uint8_t color_depth, uint8_t option);
\r
786 void mipi_dsih_hal_dbi_in_color_coding(dsih_ctrl_t * instance, uint8_t color_depth, uint8_t option);
\r
787 void mipi_dsih_hal_dbi_lut_size(dsih_ctrl_t * instance, uint8_t size);
\r
788 void mipi_dsih_hal_dbi_partitioning_en(dsih_ctrl_t * instance, int enable);
\r
789 void mipi_dsih_hal_dbi_dcs_vc(dsih_ctrl_t * instance, uint8_t vc);
\r
790 void mipi_dsih_hal_dbi_max_cmd_size(dsih_ctrl_t * instance, uint16_t size);
\r
791 void mipi_dsih_hal_dbi_cmd_size(dsih_ctrl_t * instance, uint16_t size);
\r
792 void mipi_dsih_hal_dbi_max_cmd_size(dsih_ctrl_t * instance, uint16_t size);
\r
793 int mipi_dsih_hal_dbi_rd_cmd_busy(dsih_ctrl_t * instance);
\r
794 int mipi_dsih_hal_dbi_read_fifo_full(dsih_ctrl_t * instance);
\r
795 int mipi_dsih_hal_dbi_read_fifo_empty(dsih_ctrl_t * instance);
\r
796 int mipi_dsih_hal_dbi_write_fifo_full(dsih_ctrl_t * instance);
\r
797 int mipi_dsih_hal_dbi_write_fifo_empty(dsih_ctrl_t * instance);
\r
798 int mipi_dsih_hal_dbi_cmd_fifo_full(dsih_ctrl_t * instance);
\r
799 int mipi_dsih_hal_dbi_cmd_fifo_empty(dsih_ctrl_t * instance);
\r
802 * Write command header in the generic interface
\r
803 * (which also sends DCS commands) as a subset
\r
804 * @param instance pointer to structure holding the DSI Host core information
\r
805 * @param vc of destination
\r
806 * @param packet_type (or type of DCS command)
\r
807 * @param ls_byte (if DCS, it is the DCS command)
\r
808 * @param ms_byte (only parameter of short DCS packet)
\r
809 * @return error code
\r
811 dsih_error_t mipi_dsih_hal_gen_packet_header(dsih_ctrl_t * instance, uint8_t vc, uint8_t packet_type, uint8_t ms_byte, uint8_t ls_byte)
\r
815 mipi_dsih_write_part(instance, R_DSI_HOST_GEN_HDR, (ms_byte << 16) | (ls_byte << 8 ) | ((vc << 6) | packet_type), 0, 24);
\r
818 return ERR_DSI_OVERFLOW;
\r
821 * Write the payload of the long packet commands
\r
822 * @param instance pointer to structure holding the DSI Host core information
\r
823 * @param payload array of bytes of payload
\r
824 * @return error code
\r
826 dsih_error_t mipi_dsih_hal_gen_packet_payload(dsih_ctrl_t * instance, uint32_t payload)
\r
828 if (mipi_dsih_hal_gen_write_fifo_full(instance))
\r
830 return ERR_DSI_OVERFLOW;
\r
832 mipi_dsih_write_word(instance, R_DSI_HOST_GEN_PLD_DATA, payload);
\r
837 * Write the payload of the long packet commands
\r
838 * @param instance pointer to structure holding the DSI Host core information
\r
839 * @param payload pointer to 32-bit array to hold read information
\r
840 * @return error code
\r
842 dsih_error_t mipi_dsih_hal_gen_read_payload(dsih_ctrl_t * instance, uint32_t* payload)
\r
844 *payload = mipi_dsih_read_word(instance, R_DSI_HOST_GEN_PLD_DATA);
\r
849 * Configure the read back virtual channel for the generic interface
\r
850 * @param instance pointer to structure holding the DSI Host core information
\r
851 * @param vc to listen to on the line
\r
853 void mipi_dsih_hal_gen_rd_vc(dsih_ctrl_t * instance, uint8_t vc)
\r
855 mipi_dsih_write_part(instance, R_DSI_HOST_GEN_VCID, vc, 0, 2);
\r
858 * Enable EOTp reception
\r
859 * @param instance pointer to structure holding the DSI Host core information
\r
862 void mipi_dsih_hal_gen_eotp_rx_en(dsih_ctrl_t * instance, int enable)
\r
864 mipi_dsih_write_part(instance, R_DSI_HOST_PCKHDL_CFG, enable, 1, 1);
\r
867 * Enable EOTp transmission
\r
868 * @param instance pointer to structure holding the DSI Host core information
\r
871 void mipi_dsih_hal_gen_eotp_tx_en(dsih_ctrl_t * instance, int enable)
\r
873 mipi_dsih_write_part(instance, R_DSI_HOST_PCKHDL_CFG, enable, 0, 1);
\r
876 * Enable Bus Turn-around request
\r
877 * @param instance pointer to structure holding the DSI Host core information
\r
880 void mipi_dsih_hal_bta_en(dsih_ctrl_t * instance, int enable)
\r
882 mipi_dsih_write_part(instance, R_DSI_HOST_PCKHDL_CFG, enable, 2, 1);
\r
885 * Enable ECC reception, error correction and reporting
\r
886 * @param instance pointer to structure holding the DSI Host core information
\r
889 void mipi_dsih_hal_gen_ecc_rx_en(dsih_ctrl_t * instance, int enable)
\r
891 mipi_dsih_write_part(instance, R_DSI_HOST_PCKHDL_CFG, enable, 3, 1);
\r
894 * Enable CRC reception, error reporting
\r
895 * @param instance pointer to structure holding the DSI Host core information
\r
898 void mipi_dsih_hal_gen_crc_rx_en(dsih_ctrl_t * instance, int enable)
\r
900 mipi_dsih_write_part(instance, R_DSI_HOST_PCKHDL_CFG, enable, 4, 1);
\r
903 * Get status of read command
\r
904 * @param instance pointer to structure holding the DSI Host core information
\r
905 * @return 1 if busy
\r
907 int mipi_dsih_hal_gen_rd_cmd_busy(dsih_ctrl_t * instance)
\r
909 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 6, 1);
\r
912 * Get the FULL status of generic read payload fifo
\r
913 * @param instance pointer to structure holding the DSI Host core information
\r
914 * @return 1 if fifo full
\r
916 int mipi_dsih_hal_gen_read_fifo_full(dsih_ctrl_t * instance)
\r
918 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 5, 1);
\r
921 * Get the EMPTY status of generic read payload fifo
\r
922 * @param instance pointer to structure holding the DSI Host core information
\r
923 * @return 1 if fifo empty
\r
925 int mipi_dsih_hal_gen_read_fifo_empty(dsih_ctrl_t * instance)
\r
927 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 4, 1);
\r
930 * Get the FULL status of generic write payload fifo
\r
931 * @param instance pointer to structure holding the DSI Host core information
\r
932 * @return 1 if fifo full
\r
934 int mipi_dsih_hal_gen_write_fifo_full(dsih_ctrl_t * instance)
\r
936 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 3, 1);
\r
939 * Get the EMPTY status of generic write payload fifo
\r
940 * @param instance pointer to structure holding the DSI Host core information
\r
941 * @return 1 if fifo empty
\r
943 int mipi_dsih_hal_gen_write_fifo_empty(dsih_ctrl_t * instance)
\r
945 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 2, 1);
\r
948 * Get the FULL status of generic command fifo
\r
949 * @param instance pointer to structure holding the DSI Host core information
\r
950 * @return 1 if fifo full
\r
952 int mipi_dsih_hal_gen_cmd_fifo_full(dsih_ctrl_t * instance)
\r
954 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 1, 1);
\r
957 * Get the EMPTY status of generic command fifo
\r
958 * @param instance pointer to structure holding the DSI Host core information
\r
959 * @return 1 if fifo empty
\r
961 int mipi_dsih_hal_gen_cmd_fifo_empty(dsih_ctrl_t * instance)
\r
963 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 0, 1);
\r
967 * Configure how many cycles of byte clock would the PHY module take
\r
968 * to switch data lane from high speed to low power
\r
969 * @param instance pointer to structure holding the DSI Host core information
\r
970 * @param no_of_byte_cycles
\r
971 * @return error code
\r
973 dsih_error_t mipi_dsih_phy_hs2lp_config(dsih_ctrl_t * instance, uint8_t no_of_byte_cycles)
\r
975 mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_CFG, no_of_byte_cycles, 24, 8);
\r
979 * Configure how many cycles of byte clock would the PHY module take
\r
980 * to switch the data lane from to low power high speed
\r
981 * @param instance pointer to structure holding the DSI Host core information
\r
982 * @param no_of_byte_cycles
\r
983 * @return error code
\r
985 dsih_error_t mipi_dsih_phy_lp2hs_config(dsih_ctrl_t * instance, uint8_t no_of_byte_cycles)
\r
987 mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_CFG, no_of_byte_cycles, 16, 8);
\r
991 * Configure how many cycles of byte clock would the PHY module take
\r
992 * to switch clock lane from high speed to low power
\r
993 * @param instance pointer to structure holding the DSI Host core information
\r
994 * @param no_of_byte_cycles
\r
995 * @return error code
\r
997 dsih_error_t mipi_dsih_phy_clk_hs2lp_config(dsih_ctrl_t * instance, uint8_t no_of_byte_cycles)
\r
999 mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_LPCLK_CFG, no_of_byte_cycles, 16, 10);
\r
1003 * Configure how many cycles of byte clock would the PHY module take
\r
1004 * to switch clock lane from to low power high speed
\r
1005 * @param instance pointer to structure holding the DSI Host core information
\r
1006 * @param no_of_byte_cycles
\r
1007 * @return error code
\r
1009 dsih_error_t mipi_dsih_phy_clk_lp2hs_config(dsih_ctrl_t * instance, uint8_t no_of_byte_cycles)
\r
1011 mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_LPCLK_CFG, no_of_byte_cycles, 0, 10);
\r
1015 * Configure how many cycles of byte clock would the PHY module take
\r
1016 * to turn the bus around to start receiving
\r
1017 * @param instance pointer to structure holding the DSI Host core information
\r
1018 * @param no_of_byte_cycles
\r
1019 * @return error code
\r
1021 dsih_error_t mipi_dsih_phy_bta_time(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1023 /*Jessica modified: From ASIC, the second table in spec is correct, this 15 bits are max rd time*/
\r
1024 if (no_of_byte_cycles < 0x8000) /* 15-bit field */
\r
1026 //mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_CFG, no_of_byte_cycles, 0, 12);
\r
1027 mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_CFG, no_of_byte_cycles, 0, 15);
\r
1031 return ERR_DSI_OVERFLOW;
\r
1036 * Enable the automatic mechanism to stop providing clock in the clock
\r
1037 * lane when time allows
\r
1038 * @param instance pointer to structure holding the DSI Host core information
\r
1040 * @return error code
\r
1042 void mipi_dsih_non_continuous_clock(dsih_ctrl_t * instance, int enable)
\r
1044 mipi_dsih_write_part(instance, R_DSI_HOST_LPCLK_CTRL, enable, 1, 1);
\r
1047 * Get the status of the automatic mechanism to stop providing clock in the
\r
1048 * clock lane when time allows
\r
1049 * @param instance pointer to structure holding the DSI Host core information
\r
1050 * @return status 1 (enabled) 0 (disabled)
\r
1052 int mipi_dsih_non_continuous_clock_status(dsih_ctrl_t * instance)
\r
1054 return mipi_dsih_read_part(instance, R_DSI_HOST_LPCLK_CTRL, 1, 1);
\r
1056 /* PRESP Time outs */
\r
1058 * Timeout for peripheral (for controller to stay still) after LP data
\r
1059 * transmission write requests
\r
1060 * @param instance pointer to structure holding the DSI Host core information
\r
1061 * @param no_of_byte_cycles period for which the DWC_mipi_dsi_host keeps the
\r
1062 * link still, after sending a low power write operation. This period is
\r
1063 * measured in cycles of lanebyteclk
\r
1065 void mipi_dsih_hal_presp_timeout_low_power_write(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1067 mipi_dsih_write_part(instance, R_DSI_HOST_LP_WR_TO_CNT, no_of_byte_cycles, 0, 16);
\r
1070 * Timeout for peripheral (for controller to stay still) after LP data
\r
1071 * transmission read requests
\r
1072 * @param instance pointer to structure holding the DSI Host core information
\r
1073 * @param no_of_byte_cycles period for which the DWC_mipi_dsi_host keeps the
\r
1074 * link still, after sending a low power read operation. This period is
\r
1075 * measured in cycles of lanebyteclk
\r
1077 void mipi_dsih_hal_presp_timeout_low_power_read(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1079 mipi_dsih_write_part(instance, R_DSI_HOST_LP_RD_TO_CNT, no_of_byte_cycles, 0, 16);
\r
1082 * Timeout for peripheral (for controller to stay still) after HS data
\r
1083 * transmission write requests
\r
1084 * @param instance pointer to structure holding the DSI Host core information
\r
1085 * @param no_of_byte_cycles period for which the DWC_mipi_dsi_host keeps the
\r
1086 * link still, after sending a high-speed write operation. This period is
\r
1087 * measured in cycles of lanebyteclk
\r
1089 void mipi_dsih_hal_presp_timeout_high_speed_write(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1091 mipi_dsih_write_part(instance, R_DSI_HOST_HS_WR_TO_CNT, no_of_byte_cycles, 0, 16);
\r
1094 * Timeout for peripheral between HS data transmission read requests
\r
1095 * @param instance pointer to structure holding the DSI Host core information
\r
1096 * @param no_of_byte_cycles period for which the DWC_mipi_dsi_host keeps the
\r
1097 * link still, after sending a high-speed read operation. This period is
\r
1098 * measured in cycles of lanebyteclk
\r
1100 void mipi_dsih_hal_presp_timeout_high_speed_read(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1102 mipi_dsih_write_part(instance, R_DSI_HOST_HS_RD_TO_CNT, no_of_byte_cycles, 0, 16);
\r
1105 * Timeout for peripheral (for controller to stay still) after bus turn around
\r
1106 * @param instance pointer to structure holding the DSI Host core information
\r
1107 * @param no_of_byte_cycles period for which the DWC_mipi_dsi_host keeps the
\r
1108 * link still, after sending a BTA operation. This period is
\r
1109 * measured in cycles of lanebyteclk
\r
1111 void mipi_dsih_hal_presp_timeout_bta(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1113 mipi_dsih_write_part(instance, R_DSI_HOST_BTA_TO_CNT, no_of_byte_cycles, 0, 16);
\r