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("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
192 return color_depth;
\r
195 * Get DPI video pixel configuration
\r
196 * @param instance pointer to structure holding the DSI Host core information
\r
197 * @return pixel configuration
\r
199 uint8_t mipi_dsih_hal_dpi_get_color_config(dsih_ctrl_t * instance)
\r
201 uint8_t color_config = 0;
\r
202 switch (mipi_dsih_read_part(instance, R_DSI_HOST_DPI_COLOR_CODE, 0, 4))
\r
223 return color_config;
\r
226 * Set DPI loosely packetisation video (used only when color depth = 18
\r
227 * @param instance pointer to structure holding the DSI Host core information
\r
230 void mipi_dsih_hal_dpi_18_loosely_packet_en(dsih_ctrl_t * instance, int enable)
\r
232 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_COLOR_CODE, enable, 8, 1);
\r
235 * Set DPI color mode pin polarity
\r
236 * @param instance pointer to structure holding the DSI Host core information
\r
237 * @param active_low (1) or active high (0)
\r
239 void mipi_dsih_hal_dpi_color_mode_pol(dsih_ctrl_t * instance, int active_low)
\r
241 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_CFG_POL, active_low, 4, 1);
\r
244 * Set DPI shut down pin polarity
\r
245 * @param instance pointer to structure holding the DSI Host core information
\r
246 * @param active_low (1) or active high (0)
\r
248 void mipi_dsih_hal_dpi_shut_down_pol(dsih_ctrl_t * instance, int active_low)
\r
250 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_CFG_POL, active_low, 3, 1);
\r
253 * Set DPI horizontal sync pin polarity
\r
254 * @param instance pointer to structure holding the DSI Host core information
\r
255 * @param active_low (1) or active high (0)
\r
257 void mipi_dsih_hal_dpi_hsync_pol(dsih_ctrl_t * instance, int active_low)
\r
259 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_CFG_POL, active_low, 2, 1);
\r
262 * Set DPI vertical sync pin polarity
\r
263 * @param instance pointer to structure holding the DSI Host core information
\r
264 * @param active_low (1) or active high (0)
\r
266 void mipi_dsih_hal_dpi_vsync_pol(dsih_ctrl_t * instance, int active_low)
\r
268 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_CFG_POL, active_low, 1, 1);
\r
271 * Set DPI data enable pin polarity
\r
272 * @param instance pointer to structure holding the DSI Host core information
\r
273 * @param active_low (1) or active high (0)
\r
275 void mipi_dsih_hal_dpi_dataen_pol(dsih_ctrl_t * instance, int active_low)
\r
277 mipi_dsih_write_part(instance, R_DSI_HOST_DPI_CFG_POL, active_low, 0, 1);
\r
280 * Enable FRAME BTA ACK
\r
281 * @param instance pointer to structure holding the DSI Host core information
\r
282 * @param enable (1) - disable (0)
\r
284 void mipi_dsih_hal_dpi_frame_ack_en(dsih_ctrl_t * instance, int enable)
\r
286 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 14, 1);
\r
289 * Enable null packets (value in null packet size will be taken in calculations)
\r
290 * @param instance pointer to structure holding the DSI Host core information
\r
291 * @param enable (1) - disable (0)
\r
292 * @note function retained for backward compatibility (not used from 1.20a on)
\r
294 void mipi_dsih_hal_dpi_null_packet_en(dsih_ctrl_t * instance, int enable)
\r
298 * Enable multi packets (value in no of chunks will be taken in calculations)
\r
299 * @param instance pointer to structure holding the DSI Host core information
\r
300 * @param enable (1) - disable (0)
\r
302 void mipi_dsih_hal_dpi_multi_packet_en(dsih_ctrl_t * instance, int enable)
\r
306 * Enable return to low power mode inside horizontal front porch periods when
\r
308 * @param instance pointer to structure holding the DSI Host core information
\r
309 * @param enable (1) - disable (0)
\r
311 void mipi_dsih_hal_dpi_lp_during_hfp(dsih_ctrl_t * instance, int enable)
\r
313 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 13, 1);
\r
316 * Enable return to low power mode inside horizontal back porch periods when
\r
318 * @param instance pointer to structure holding the DSI Host core information
\r
319 * @param enable (1) - disable (0)
\r
321 void mipi_dsih_hal_dpi_lp_during_hbp(dsih_ctrl_t * instance, int enable)
\r
323 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 12, 1);
\r
326 * Enable return to low power mode inside vertical active lines periods when
\r
328 * @param instance pointer to structure holding the DSI Host core information
\r
329 * @param enable (1) - disable (0)
\r
331 void mipi_dsih_hal_dpi_lp_during_vactive(dsih_ctrl_t * instance, int enable)
\r
333 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 11, 1);
\r
336 * Enable return to low power mode inside vertical front porch periods when
\r
338 * @param instance pointer to structure holding the DSI Host core information
\r
339 * @param enable (1) - disable (0)
\r
341 void mipi_dsih_hal_dpi_lp_during_vfp(dsih_ctrl_t * instance, int enable)
\r
343 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 10, 1);
\r
346 * Enable return to low power mode inside vertical back porch periods when
\r
348 * @param instance pointer to structure holding the DSI Host core information
\r
349 * @param enable (1) - disable (0)
\r
351 void mipi_dsih_hal_dpi_lp_during_vbp(dsih_ctrl_t * instance, int enable)
\r
353 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 9, 1);
\r
356 * Enable return to low power mode inside vertical sync periods when
\r
358 * @param instance pointer to structure holding the DSI Host core information
\r
359 * @param enable (1) - disable (0)
\r
361 void mipi_dsih_hal_dpi_lp_during_vsync(dsih_ctrl_t * instance, int enable)
\r
363 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, enable, 8, 1);
\r
366 * Set DPI video mode type (burst/non-burst - with sync pulses or events)
\r
367 * @param instance pointer to structure holding the DSI Host core information
\r
369 * @return error code
\r
371 dsih_error_t mipi_dsih_hal_dpi_video_mode_type(dsih_ctrl_t * instance, dsih_video_mode_t type)
\r
375 mipi_dsih_write_part(instance, R_DSI_HOST_VID_MODE_CFG, type, 0, 2);
\r
380 if (instance->log_error != 0)
\r
382 instance->log_error("undefined type");
\r
384 return ERR_DSI_OUT_OF_BOUND;
\r
388 * Enable/disable DPI video mode
\r
389 * @param instance pointer to structure holding the DSI Host core information
\r
390 * @param enable (1) - disable (0)
\r
392 void mipi_dsih_hal_dpi_video_mode_en(dsih_ctrl_t * instance, int enable)
\r
394 mipi_dsih_write_part(instance, R_DSI_HOST_MODE_CFG, enable? 0: 1, 0, 1);
\r
397 * Get the status of video mode, whether enabled or not in core
\r
398 * @param instance pointer to structure holding the DSI Host core information
\r
401 int mipi_dsih_hal_dpi_is_video_mode(dsih_ctrl_t * instance)
\r
403 return (mipi_dsih_read_part(instance, R_DSI_HOST_MODE_CFG, 0, 1) == 0);
\r
406 * Write the null packet size - will only be taken into account when null
\r
407 * packets are enabled.
\r
408 * @param instance pointer to structure holding the DSI Host core information
\r
409 * @param size of null packet
\r
410 * @return error code
\r
412 dsih_error_t mipi_dsih_hal_dpi_null_packet_size(dsih_ctrl_t * instance, uint16_t size)
\r
414 if (size < (1 << 13)) /* 13-bit field */
\r
416 mipi_dsih_write_part(instance, R_DSI_HOST_VID_NULL_SIZE, size, 0, 13);
\r
421 return ERR_DSI_OUT_OF_BOUND;
\r
425 * Write no of chunks to core - taken into consideration only when multi packet
\r
427 * @param instance pointer to structure holding the DSI Host core information
\r
428 * @param no of chunks
\r
430 dsih_error_t mipi_dsih_hal_dpi_chunks_no(dsih_ctrl_t * instance, uint16_t no)
\r
432 if (no < (1 << 13))
\r
434 mipi_dsih_write_part(instance, R_DSI_HOST_VID_NUM_CHUNKS, no, 0, 13);
\r
439 return ERR_DSI_OUT_OF_BOUND;
\r
443 * Write video packet size. obligatory for sending video
\r
444 * @param instance pointer to structure holding the DSI Host core information
\r
445 * @param size of video packet - containing information
\r
446 * @return error code
\r
448 dsih_error_t mipi_dsih_hal_dpi_video_packet_size(dsih_ctrl_t * instance, uint16_t size)
\r
450 if (size < (1 << 14)) /* 14-bit field */
\r
452 mipi_dsih_write_part(instance, R_DSI_HOST_VID_PKT_SIZE, size, 0, 14);
\r
457 return ERR_DSI_OUT_OF_BOUND;
\r
461 * function retained for backward compatibility (not used from 1.20a on)
\r
462 * @param instance pointer to structure holding the DSI Host core information
\r
463 * @param enable (1) - disable (0)
\r
465 void mipi_dsih_hal_edpi_enable(dsih_ctrl_t * instance, int enable)
\r
469 * Specifiy the size of the packet memory write start/continue
\r
470 * @param instance pointer to structure holding the DSI Host core information
\r
471 * @ size of the packet
\r
472 * @note when different than zero (0) eDPI is enabled
\r
474 void mipi_dsih_hal_edpi_max_allowed_size(dsih_ctrl_t * instance, uint16_t size)
\r
476 mipi_dsih_write_part(instance, R_DSI_HOST_EDPI_CMD_SIZE, size, 0, 16);
\r
479 * Enable tear effect acknowledge
\r
480 * @param instance pointer to structure holding the DSI Host core information
\r
481 * @param enable (1) - disable (0)
\r
483 void mipi_dsih_hal_tear_effect_ack_en(dsih_ctrl_t * instance, int enable)
\r
485 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, enable, 0, 1);
\r
488 * Enable packets acknowledge request after each packet transmission
\r
489 * @param instance pointer to structure holding the DSI Host core information
\r
490 * @param enable (1) - disable (0)
\r
492 void mipi_dsih_hal_cmd_ack_en(dsih_ctrl_t * instance, int enable)
\r
494 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, enable, 1, 1);
\r
497 * Set DCS command packet transmission to transmission type
\r
498 * @param instance pointer to structure holding the DSI Host core information
\r
499 * @param no_of_param of command
\r
500 * @param lp transmit in low power
\r
501 * @return error code
\r
503 dsih_error_t mipi_dsih_hal_dcs_wr_tx_type(dsih_ctrl_t * instance, unsigned no_of_param, int lp)
\r
505 switch (no_of_param)
\r
508 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 16, 1);
\r
511 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 17, 1);
\r
514 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 19, 1);
\r
520 * Set DCS read command packet transmission to transmission type
\r
521 * @param instance pointer to structure holding the DSI Host core information
\r
522 * @param no_of_param of command
\r
523 * @param lp transmit in low power
\r
524 * @return error code
\r
526 dsih_error_t mipi_dsih_hal_dcs_rd_tx_type(dsih_ctrl_t * instance, unsigned no_of_param, int lp)
\r
528 dsih_error_t err = OK;
\r
529 switch (no_of_param)
\r
532 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 18, 1);
\r
535 if (instance->log_error != 0)
\r
537 instance->log_error("undefined DCS Read packet type");
\r
539 err = ERR_DSI_OUT_OF_BOUND;
\r
545 /*Jessica add begin: to support max read packet size command */
\r
546 dsih_error_t mipi_dsih_hal_max_rd_packet_size_type(dsih_ctrl_t * instance, int lp)
\r
548 dsih_error_t err = OK;
\r
550 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 24, 1);
\r
552 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 10, 1);
\r
556 /*Jessica add end*/
\r
559 * Set generic write command packet transmission to transmission type
\r
560 * @param instance pointer to structure holding the DSI Host core information
\r
561 * @param no_of_param of command
\r
562 * @param lp transmit in low power
\r
563 * @return error code
\r
565 dsih_error_t mipi_dsih_hal_gen_wr_tx_type(dsih_ctrl_t * instance, unsigned no_of_param, int lp)
\r
567 switch (no_of_param)
\r
570 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 8, 1);
\r
573 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 9, 1);
\r
576 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 10, 1);
\r
579 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 14, 1);
\r
585 * Set generic command packet transmission to transmission type
\r
586 * @param instance pointer to structure holding the DSI Host core information
\r
587 * @param no_of_param of command
\r
588 * @param lp transmit in low power
\r
589 * @return error code
\r
591 dsih_error_t mipi_dsih_hal_gen_rd_tx_type(dsih_ctrl_t * instance, unsigned no_of_param, int lp)
\r
593 dsih_error_t err = OK;
\r
594 switch (no_of_param)
\r
597 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 11, 1);
\r
600 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 12, 1);
\r
603 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 13, 1);
\r
606 if (instance->log_error != 0)
\r
608 instance->log_error("undefined Generic Read packet type");
\r
610 err = ERR_DSI_OUT_OF_BOUND;
\r
616 * Configure maximum read packet size command transmission type
\r
617 * @param instance pointer to structure holding the DSI Host core information
\r
618 * @param lp set to low power
\r
620 void mipi_dsih_hal_max_rd_size_tx_type(dsih_ctrl_t * instance, int lp)
\r
622 mipi_dsih_write_part(instance, R_DSI_HOST_CMD_MODE_CFG, lp, 24, 1);
\r
625 * Enable command mode (Generic interface)
\r
626 * @param instance pointer to structure holding the DSI Host core information
\r
629 void mipi_dsih_hal_gen_cmd_mode_en(dsih_ctrl_t * instance, int enable)
\r
631 mipi_dsih_write_part(instance, R_DSI_HOST_MODE_CFG, enable? 1: 0, 0, 1);
\r
634 * Retrieve the controller's status of whether command mode is ON or not
\r
635 * @param instance pointer to structure holding the DSI Host core information
\r
636 * @return whether command mode is ON
\r
638 int mipi_dsih_hal_gen_is_cmd_mode(dsih_ctrl_t * instance)
\r
640 return (mipi_dsih_read_part(instance, R_DSI_HOST_MODE_CFG, 0, 1) == 1);
\r
643 * Configure the Horizontal Line time
\r
644 * @param instance pointer to structure holding the DSI Host core information
\r
645 * @param time taken to transmit the total of the horizontal line
\r
647 void mipi_dsih_hal_dpi_hline(dsih_ctrl_t * instance, uint16_t time)
\r
649 mipi_dsih_write_part(instance, R_DSI_HOST_VID_HLINE_TIME, time, 0, 15);
\r
652 * Configure the Horizontal back porch time
\r
653 * @param instance pointer to structure holding the DSI Host core information
\r
654 * @param time taken to transmit the horizontal back porch
\r
656 void mipi_dsih_hal_dpi_hbp(dsih_ctrl_t * instance, uint16_t time)
\r
658 mipi_dsih_write_part(instance, R_DSI_HOST_VID_HBP_TIME, time, 0, 12);
\r
661 * Configure the Horizontal sync time
\r
662 * @param instance pointer to structure holding the DSI Host core information
\r
663 * @param time taken to transmit the horizontal sync
\r
665 void mipi_dsih_hal_dpi_hsa(dsih_ctrl_t * instance, uint16_t time)
\r
667 mipi_dsih_write_part(instance, R_DSI_HOST_VID_HSA_TIME, time, 0, 12);
\r
670 * Configure the vertical active lines of the video stream
\r
671 * @param instance pointer to structure holding the DSI Host core information
\r
674 void mipi_dsih_hal_dpi_vactive(dsih_ctrl_t * instance, uint16_t lines)
\r
676 mipi_dsih_write_part(instance, R_DSI_HOST_VID_VACTIVE_LINES, lines, 0, 14);
\r
679 * Configure the vertical front porch lines of the video stream
\r
680 * @param instance pointer to structure holding the DSI Host core information
\r
683 void mipi_dsih_hal_dpi_vfp(dsih_ctrl_t * instance, uint16_t lines)
\r
685 mipi_dsih_write_part(instance, R_DSI_HOST_VID_VFP_LINES, lines, 0, 10);
\r
688 * Configure the vertical back porch lines of the video stream
\r
689 * @param instance pointer to structure holding the DSI Host core information
\r
692 void mipi_dsih_hal_dpi_vbp(dsih_ctrl_t * instance, uint16_t lines)
\r
694 mipi_dsih_write_part(instance, R_DSI_HOST_VID_VBP_LINES, lines, 0, 10);
\r
697 * Configure the vertical sync lines of the video stream
\r
698 * @param instance pointer to structure holding the DSI Host core information
\r
701 void mipi_dsih_hal_dpi_vsync(dsih_ctrl_t * instance, uint16_t lines)
\r
703 mipi_dsih_write_part(instance, R_DSI_HOST_VID_VSA_LINES, lines, 0, 10);
\r
706 * configure timeout divisions (so they would have more clock ticks)
\r
707 * @param instance pointer to structure holding the DSI Host core information
\r
708 * @param byte_clk_division_factor no of hs cycles before transiting back to LP in
\r
709 * (lane_clk / byte_clk_division_factor)
\r
711 void mipi_dsih_hal_timeout_clock_division(dsih_ctrl_t * instance, uint8_t byte_clk_division_factor)
\r
713 mipi_dsih_write_part(instance, R_DSI_HOST_CLK_MGR, byte_clk_division_factor, 8, 8);
\r
716 * Configure the Low power receive time out
\r
717 * @param instance pointer to structure holding the DSI Host core information
\r
718 * @param count (of byte cycles)
\r
720 void mipi_dsih_hal_lp_rx_timeout(dsih_ctrl_t * instance, uint16_t count)
\r
722 mipi_dsih_write_part(instance, R_DSI_HOST_TO_CNT_CFG, count, 0, 16);
\r
725 * Configure a high speed transmission time out7
\r
726 * @param instance pointer to structure holding the DSI Host core information
\r
727 * @param count (byte cycles)
\r
729 void mipi_dsih_hal_hs_tx_timeout(dsih_ctrl_t * instance, uint16_t count)
\r
731 mipi_dsih_write_part(instance, R_DSI_HOST_TO_CNT_CFG, count, 16, 16);
\r
734 * Get the error 0 interrupt register status
\r
735 * @param instance pointer to structure holding the DSI Host core information
\r
736 * @param mask the mask to be read from the register
\r
737 * @return error status 0 value
\r
739 uint32_t mipi_dsih_hal_int_status_0(dsih_ctrl_t * instance, uint32_t mask)
\r
741 return (mipi_dsih_read_word(instance, R_DSI_HOST_INT_ST0) & mask);
\r
744 * Get the error 1 interrupt register status
\r
745 * @param instance pointer to structure holding the DSI Host core information
\r
746 * @param mask the mask to be read from the register
\r
747 * @return error status 1 value
\r
749 uint32_t mipi_dsih_hal_int_status_1(dsih_ctrl_t * instance, uint32_t mask)
\r
751 return (mipi_dsih_read_word(instance, R_DSI_HOST_INT_ST1) & mask);
\r
754 * Configure MASK (hiding) of interrupts coming from error 0 source
\r
755 * @param instance pointer to structure holding the DSI Host core information
\r
756 * @param mask to be written to the register
\r
758 void mipi_dsih_hal_int_mask_0(dsih_ctrl_t * instance, uint32_t mask)
\r
760 mipi_dsih_write_word(instance, R_DSI_HOST_INT_MSK0, mask);
\r
763 * Get the ERROR MASK 0 register status
\r
764 * @param instance pointer to structure holding the DSI Host core information
\r
765 * @param mask the bits to read from the mask register
\r
767 uint32_t mipi_dsih_hal_int_get_mask_0(dsih_ctrl_t * instance, uint32_t mask)
\r
769 return (mipi_dsih_read_word(instance, R_DSI_HOST_INT_MSK0) & mask);
\r
772 * Configure MASK (hiding) of interrupts coming from error 0 source
\r
773 * @param instance pointer to structure holding the DSI Host core information
\r
774 * @param mask the mask to be written to the register
\r
776 void mipi_dsih_hal_int_mask_1(dsih_ctrl_t * instance, uint32_t mask)
\r
778 mipi_dsih_write_word(instance, R_DSI_HOST_INT_MSK1, mask);
\r
781 * Get the ERROR MASK 1 register status
\r
782 * @param instance pointer to structure holding the DSI Host core information
\r
783 * @param mask the bits to read from the mask register
\r
785 uint32_t mipi_dsih_hal_int_get_mask_1(dsih_ctrl_t * instance, uint32_t mask)
\r
787 return (mipi_dsih_read_word(instance, R_DSI_HOST_INT_MSK1) & mask);
\r
789 /* DBI NOT IMPLEMENTED */
\r
790 void mipi_dsih_hal_dbi_out_color_coding(dsih_ctrl_t * instance, uint8_t color_depth, uint8_t option);
\r
791 void mipi_dsih_hal_dbi_in_color_coding(dsih_ctrl_t * instance, uint8_t color_depth, uint8_t option);
\r
792 void mipi_dsih_hal_dbi_lut_size(dsih_ctrl_t * instance, uint8_t size);
\r
793 void mipi_dsih_hal_dbi_partitioning_en(dsih_ctrl_t * instance, int enable);
\r
794 void mipi_dsih_hal_dbi_dcs_vc(dsih_ctrl_t * instance, uint8_t vc);
\r
795 void mipi_dsih_hal_dbi_max_cmd_size(dsih_ctrl_t * instance, uint16_t size);
\r
796 void mipi_dsih_hal_dbi_cmd_size(dsih_ctrl_t * instance, uint16_t size);
\r
797 int mipi_dsih_hal_dbi_rd_cmd_busy(dsih_ctrl_t * instance);
\r
798 int mipi_dsih_hal_dbi_read_fifo_full(dsih_ctrl_t * instance);
\r
799 int mipi_dsih_hal_dbi_read_fifo_empty(dsih_ctrl_t * instance);
\r
800 int mipi_dsih_hal_dbi_write_fifo_full(dsih_ctrl_t * instance);
\r
801 int mipi_dsih_hal_dbi_write_fifo_empty(dsih_ctrl_t * instance);
\r
802 int mipi_dsih_hal_dbi_cmd_fifo_full(dsih_ctrl_t * instance);
\r
803 int mipi_dsih_hal_dbi_cmd_fifo_empty(dsih_ctrl_t * instance);
\r
806 * Write command header in the generic interface
\r
807 * (which also sends DCS commands) as a subset
\r
808 * @param instance pointer to structure holding the DSI Host core information
\r
809 * @param vc of destination
\r
810 * @param packet_type (or type of DCS command)
\r
811 * @param ls_byte (if DCS, it is the DCS command)
\r
812 * @param ms_byte (only parameter of short DCS packet)
\r
813 * @return error code
\r
815 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
819 mipi_dsih_write_part(instance, R_DSI_HOST_GEN_HDR, (ms_byte << 16) | (ls_byte << 8 ) | ((vc << 6) | packet_type), 0, 24);
\r
822 return ERR_DSI_OVERFLOW;
\r
825 * Write the payload of the long packet commands
\r
826 * @param instance pointer to structure holding the DSI Host core information
\r
827 * @param payload array of bytes of payload
\r
828 * @return error code
\r
830 dsih_error_t mipi_dsih_hal_gen_packet_payload(dsih_ctrl_t * instance, uint32_t payload)
\r
832 if (mipi_dsih_hal_gen_write_fifo_full(instance))
\r
834 return ERR_DSI_OVERFLOW;
\r
836 mipi_dsih_write_word(instance, R_DSI_HOST_GEN_PLD_DATA, payload);
\r
841 * Write the payload of the long packet commands
\r
842 * @param instance pointer to structure holding the DSI Host core information
\r
843 * @param payload pointer to 32-bit array to hold read information
\r
844 * @return error code
\r
846 dsih_error_t mipi_dsih_hal_gen_read_payload(dsih_ctrl_t * instance, uint32_t* payload)
\r
848 *payload = mipi_dsih_read_word(instance, R_DSI_HOST_GEN_PLD_DATA);
\r
853 * Configure the read back virtual channel for the generic interface
\r
854 * @param instance pointer to structure holding the DSI Host core information
\r
855 * @param vc to listen to on the line
\r
857 void mipi_dsih_hal_gen_rd_vc(dsih_ctrl_t * instance, uint8_t vc)
\r
859 mipi_dsih_write_part(instance, R_DSI_HOST_GEN_VCID, vc, 0, 2);
\r
862 * Enable EOTp reception
\r
863 * @param instance pointer to structure holding the DSI Host core information
\r
866 void mipi_dsih_hal_gen_eotp_rx_en(dsih_ctrl_t * instance, int enable)
\r
868 mipi_dsih_write_part(instance, R_DSI_HOST_PCKHDL_CFG, enable, 1, 1);
\r
871 * Enable EOTp transmission
\r
872 * @param instance pointer to structure holding the DSI Host core information
\r
875 void mipi_dsih_hal_gen_eotp_tx_en(dsih_ctrl_t * instance, int enable)
\r
877 mipi_dsih_write_part(instance, R_DSI_HOST_PCKHDL_CFG, enable, 0, 1);
\r
880 * Enable Bus Turn-around request
\r
881 * @param instance pointer to structure holding the DSI Host core information
\r
884 void mipi_dsih_hal_bta_en(dsih_ctrl_t * instance, int enable)
\r
886 mipi_dsih_write_part(instance, R_DSI_HOST_PCKHDL_CFG, enable, 2, 1);
\r
889 * Enable ECC reception, error correction and reporting
\r
890 * @param instance pointer to structure holding the DSI Host core information
\r
893 void mipi_dsih_hal_gen_ecc_rx_en(dsih_ctrl_t * instance, int enable)
\r
895 mipi_dsih_write_part(instance, R_DSI_HOST_PCKHDL_CFG, enable, 3, 1);
\r
898 * Enable CRC reception, error reporting
\r
899 * @param instance pointer to structure holding the DSI Host core information
\r
902 void mipi_dsih_hal_gen_crc_rx_en(dsih_ctrl_t * instance, int enable)
\r
904 mipi_dsih_write_part(instance, R_DSI_HOST_PCKHDL_CFG, enable, 4, 1);
\r
907 * Get status of read command
\r
908 * @param instance pointer to structure holding the DSI Host core information
\r
909 * @return 1 if busy
\r
911 int mipi_dsih_hal_gen_rd_cmd_busy(dsih_ctrl_t * instance)
\r
913 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 6, 1);
\r
916 * Get the FULL status of generic read payload fifo
\r
917 * @param instance pointer to structure holding the DSI Host core information
\r
918 * @return 1 if fifo full
\r
920 int mipi_dsih_hal_gen_read_fifo_full(dsih_ctrl_t * instance)
\r
922 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 5, 1);
\r
925 * Get the EMPTY status of generic read payload fifo
\r
926 * @param instance pointer to structure holding the DSI Host core information
\r
927 * @return 1 if fifo empty
\r
929 int mipi_dsih_hal_gen_read_fifo_empty(dsih_ctrl_t * instance)
\r
931 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 4, 1);
\r
934 * Get the FULL status of generic write payload fifo
\r
935 * @param instance pointer to structure holding the DSI Host core information
\r
936 * @return 1 if fifo full
\r
938 int mipi_dsih_hal_gen_write_fifo_full(dsih_ctrl_t * instance)
\r
940 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 3, 1);
\r
943 * Get the EMPTY status of generic write payload fifo
\r
944 * @param instance pointer to structure holding the DSI Host core information
\r
945 * @return 1 if fifo empty
\r
947 int mipi_dsih_hal_gen_write_fifo_empty(dsih_ctrl_t * instance)
\r
949 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 2, 1);
\r
952 * Get the FULL status of generic command fifo
\r
953 * @param instance pointer to structure holding the DSI Host core information
\r
954 * @return 1 if fifo full
\r
956 int mipi_dsih_hal_gen_cmd_fifo_full(dsih_ctrl_t * instance)
\r
958 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 1, 1);
\r
961 * Get the EMPTY status of generic command fifo
\r
962 * @param instance pointer to structure holding the DSI Host core information
\r
963 * @return 1 if fifo empty
\r
965 int mipi_dsih_hal_gen_cmd_fifo_empty(dsih_ctrl_t * instance)
\r
967 return mipi_dsih_read_part(instance, R_DSI_HOST_CMD_PKT_STATUS, 0, 1);
\r
971 * Configure how many cycles of byte clock would the PHY module take
\r
972 * to switch data lane from high speed to low power
\r
973 * @param instance pointer to structure holding the DSI Host core information
\r
974 * @param no_of_byte_cycles
\r
975 * @return error code
\r
977 dsih_error_t mipi_dsih_phy_hs2lp_config(dsih_ctrl_t * instance, uint8_t no_of_byte_cycles)
\r
979 mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_CFG, no_of_byte_cycles, 24, 8);
\r
983 * Configure how many cycles of byte clock would the PHY module take
\r
984 * to switch the data lane from to low power high speed
\r
985 * @param instance pointer to structure holding the DSI Host core information
\r
986 * @param no_of_byte_cycles
\r
987 * @return error code
\r
989 dsih_error_t mipi_dsih_phy_lp2hs_config(dsih_ctrl_t * instance, uint8_t no_of_byte_cycles)
\r
991 mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_CFG, no_of_byte_cycles, 16, 8);
\r
995 * Configure how many cycles of byte clock would the PHY module take
\r
996 * to switch clock lane from high speed to low power
\r
997 * @param instance pointer to structure holding the DSI Host core information
\r
998 * @param no_of_byte_cycles
\r
999 * @return error code
\r
1001 dsih_error_t mipi_dsih_phy_clk_hs2lp_config(dsih_ctrl_t * instance, uint8_t no_of_byte_cycles)
\r
1003 mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_LPCLK_CFG, no_of_byte_cycles, 16, 10);
\r
1007 * Configure how many cycles of byte clock would the PHY module take
\r
1008 * to switch clock lane from to low power high speed
\r
1009 * @param instance pointer to structure holding the DSI Host core information
\r
1010 * @param no_of_byte_cycles
\r
1011 * @return error code
\r
1013 dsih_error_t mipi_dsih_phy_clk_lp2hs_config(dsih_ctrl_t * instance, uint8_t no_of_byte_cycles)
\r
1015 mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_LPCLK_CFG, no_of_byte_cycles, 0, 10);
\r
1019 * Configure how many cycles of byte clock would the PHY module take
\r
1020 * to turn the bus around to start receiving
\r
1021 * @param instance pointer to structure holding the DSI Host core information
\r
1022 * @param no_of_byte_cycles
\r
1023 * @return error code
\r
1025 dsih_error_t mipi_dsih_phy_bta_time(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1027 /*Jessica modified: From ASIC, the second table in spec is correct, this 15 bits are max rd time*/
\r
1028 if (no_of_byte_cycles < 0x8000) /* 15-bit field */
\r
1030 //mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_CFG, no_of_byte_cycles, 0, 12);
\r
1031 mipi_dsih_write_part(instance, R_DSI_HOST_PHY_TMR_CFG, no_of_byte_cycles, 0, 15);
\r
1035 return ERR_DSI_OVERFLOW;
\r
1040 * Enable the automatic mechanism to stop providing clock in the clock
\r
1041 * lane when time allows
\r
1042 * @param instance pointer to structure holding the DSI Host core information
\r
1044 * @return error code
\r
1046 void mipi_dsih_non_continuous_clock(dsih_ctrl_t * instance, int enable)
\r
1048 mipi_dsih_write_part(instance, R_DSI_HOST_LPCLK_CTRL, enable, 1, 1);
\r
1051 * Get the status of the automatic mechanism to stop providing clock in the
\r
1052 * clock lane when time allows
\r
1053 * @param instance pointer to structure holding the DSI Host core information
\r
1054 * @return status 1 (enabled) 0 (disabled)
\r
1056 int mipi_dsih_non_continuous_clock_status(dsih_ctrl_t * instance)
\r
1058 return mipi_dsih_read_part(instance, R_DSI_HOST_LPCLK_CTRL, 1, 1);
\r
1060 /* PRESP Time outs */
\r
1062 * Timeout for peripheral (for controller to stay still) after LP data
\r
1063 * transmission write requests
\r
1064 * @param instance pointer to structure holding the DSI Host core information
\r
1065 * @param no_of_byte_cycles period for which the DWC_mipi_dsi_host keeps the
\r
1066 * link still, after sending a low power write operation. This period is
\r
1067 * measured in cycles of lanebyteclk
\r
1069 void mipi_dsih_hal_presp_timeout_low_power_write(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1071 mipi_dsih_write_part(instance, R_DSI_HOST_LP_WR_TO_CNT, no_of_byte_cycles, 0, 16);
\r
1074 * Timeout for peripheral (for controller to stay still) after LP data
\r
1075 * transmission read requests
\r
1076 * @param instance pointer to structure holding the DSI Host core information
\r
1077 * @param no_of_byte_cycles period for which the DWC_mipi_dsi_host keeps the
\r
1078 * link still, after sending a low power read operation. This period is
\r
1079 * measured in cycles of lanebyteclk
\r
1081 void mipi_dsih_hal_presp_timeout_low_power_read(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1083 mipi_dsih_write_part(instance, R_DSI_HOST_LP_RD_TO_CNT, no_of_byte_cycles, 0, 16);
\r
1086 * Timeout for peripheral (for controller to stay still) after HS data
\r
1087 * transmission write requests
\r
1088 * @param instance pointer to structure holding the DSI Host core information
\r
1089 * @param no_of_byte_cycles period for which the DWC_mipi_dsi_host keeps the
\r
1090 * link still, after sending a high-speed write operation. This period is
\r
1091 * measured in cycles of lanebyteclk
\r
1093 void mipi_dsih_hal_presp_timeout_high_speed_write(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1095 mipi_dsih_write_part(instance, R_DSI_HOST_HS_WR_TO_CNT, no_of_byte_cycles, 0, 16);
\r
1098 * Timeout for peripheral between HS data transmission read requests
\r
1099 * @param instance pointer to structure holding the DSI Host core information
\r
1100 * @param no_of_byte_cycles period for which the DWC_mipi_dsi_host keeps the
\r
1101 * link still, after sending a high-speed read operation. This period is
\r
1102 * measured in cycles of lanebyteclk
\r
1104 void mipi_dsih_hal_presp_timeout_high_speed_read(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1106 mipi_dsih_write_part(instance, R_DSI_HOST_HS_RD_TO_CNT, no_of_byte_cycles, 0, 16);
\r
1109 * Timeout for peripheral (for controller to stay still) after bus turn around
\r
1110 * @param instance pointer to structure holding the DSI Host core information
\r
1111 * @param no_of_byte_cycles period for which the DWC_mipi_dsi_host keeps the
\r
1112 * link still, after sending a BTA operation. This period is
\r
1113 * measured in cycles of lanebyteclk
\r
1115 void mipi_dsih_hal_presp_timeout_bta(dsih_ctrl_t * instance, uint16_t no_of_byte_cycles)
\r
1117 mipi_dsih_write_part(instance, R_DSI_HOST_BTA_TO_CNT, no_of_byte_cycles, 0, 16);
\r