blob: 6ac887755b0797668318d5f5b988d5bb3d87ca26 [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2001
8*
9*****************************************************************************/
10
11/*****************************************************************************
12 *
13 * Filename:
14 * ---------
15 * dcl_uart.h
16 *
17 * Project:
18 * --------
19 * Maui
20 *
21 * Description:
22 * ------------
23 * Header file of DCL (Driver Common Layer) for UART.
24 *
25 * Author:
26 * -------
27 * -------
28 *
29 *============================================================================
30 * HISTORY
31 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
32 *------------------------------------------------------------------------------
33 * removed!
34 * removed!
35 * removed!
36 *
37 * removed!
38 * removed!
39 * removed!
40 * removed!
41 *
42 * removed!
43 * removed!
44 * removed!
45 * removed!
46 *
47 * removed!
48 * removed!
49 * removed!
50 * removed!
51 *
52 * removed!
53 * removed!
54 * removed!
55 *
56 * removed!
57 * removed!
58 * removed!
59 *
60 * removed!
61 * removed!
62 * removed!
63 *
64 * removed!
65 * removed!
66 * removed!
67 *
68 * removed!
69 * removed!
70 * removed!
71 *
72 * removed!
73 * removed!
74 * removed!
75 *
76 * removed!
77 * removed!
78 * removed!
79 *
80 * removed!
81 * removed!
82 * removed!
83 *
84 * removed!
85 * removed!
86 * removed!
87 *
88 * removed!
89 * removed!
90 * removed!
91 *
92 * removed!
93 * removed!
94 * removed!
95 *
96 * removed!
97 * removed!
98 * removed!
99 *
100 * removed!
101 * removed!
102 * removed!
103 *
104 * removed!
105 * removed!
106 * removed!
107 *
108 * removed!
109 * removed!
110 * removed!
111 *
112 * removed!
113 * removed!
114 * removed!
115 *
116 *
117 * removed!
118 * removed!
119 * removed!
120 *
121 * removed!
122 * removed!
123 * removed!
124 *
125 * removed!
126 * removed!
127 * removed!
128 *
129 * removed!
130 * removed!
131 * removed!
132 *
133 * removed!
134 * removed!
135 * removed!
136 * removed!
137 *
138 * removed!
139 * removed!
140 * removed!
141 *
142 * removed!
143 * removed!
144 * removed!
145 *
146 * removed!
147 * removed!
148 * removed!
149 * removed!
150 *
151 * removed!
152 * removed!
153 * removed!
154 *
155 * removed!
156 * removed!
157 * removed!
158 *
159 * removed!
160 * removed!
161 * removed!
162 *
163 * removed!
164 * removed!
165 * removed!
166 *
167 * removed!
168 * removed!
169 * removed!
170 *
171 * removed!
172 * removed!
173 * removed!
174 *
175 * removed!
176 * removed!
177 * removed!
178 *
179 * removed!
180 * removed!
181 *
182 * removed!
183 * removed!
184 * removed!
185 *
186 * removed!
187 * removed!
188 * removed!
189 *
190 * removed!
191 * removed!
192 * removed!
193 *
194 * removed!
195 * removed!
196 * removed!
197 * removed!
198 * removed!
199 *
200 * removed!
201 * removed!
202 * removed!
203 *
204 * removed!
205 * removed!
206 * removed!
207 *
208 * removed!
209 * removed!
210 * removed!
211 * removed!
212 * removed!
213 * removed!
214 * removed!
215 * removed!
216 * removed!
217 *
218 * removed!
219 * removed!
220 * removed!
221 *
222 * removed!
223 * removed!
224 * removed!
225 *
226 * removed!
227 * removed!
228 * removed!
229 *
230 * removed!
231 * removed!
232 * removed!
233 *
234 * removed!
235 * removed!
236 * removed!
237 *
238 * removed!
239 * removed!
240 * removed!
241 * removed!
242 *
243 * removed!
244 * removed!
245 * removed!
246 *
247 * removed!
248 * removed!
249 * removed!
250 *
251 * removed!
252 * removed!
253 * removed!
254 *
255 * removed!
256 * removed!
257 * removed!
258 *
259 * removed!
260 * removed!
261 * removed!
262 *
263 * removed!
264 * removed!
265 * removed!
266 *
267 * removed!
268 * removed!
269 * removed!
270 *
271 * removed!
272 * removed!
273 * removed!
274 *
275 * removed!
276 * removed!
277 * removed!
278 *
279 * removed!
280 * removed!
281 * removed!
282 *
283 * removed!
284 * removed!
285 * removed!
286 *
287 * removed!
288 * removed!
289 * removed!
290 *
291 * removed!
292 * removed!
293 * removed!
294 *
295 * removed!
296 * removed!
297 * removed!
298 *
299 * removed!
300 * removed!
301 * removed!
302 *
303 * removed!
304 * removed!
305 * removed!
306 *
307 * removed!
308 * removed!
309 * removed!
310 *
311 * removed!
312 * removed!
313 * removed!
314 *
315 * removed!
316 * removed!
317 * removed!
318 *
319 * removed!
320 * removed!
321 * removed!
322 *
323 * removed!
324 * removed!
325 * removed!
326 *
327 * removed!
328 * removed!
329 * removed!
330 *
331 * removed!
332 * removed!
333 * removed!
334 *
335 * removed!
336 * removed!
337 * removed!
338 *
339 * removed!
340 * removed!
341 * removed!
342 *
343 * removed!
344 * removed!
345 * removed!
346 *
347 * removed!
348 * removed!
349 * removed!
350 *
351 * removed!
352 * removed!
353 * removed!
354 *
355 * removed!
356 * removed!
357 * removed!
358 *
359 * removed!
360 * removed!
361 * removed!
362 *
363 * removed!
364 * removed!
365 * removed!
366 *
367 * removed!
368 * removed!
369 * removed!
370 *
371 *------------------------------------------------------------------------------
372 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
373 *============================================================================
374 ****************************************************************************/
375#ifdef DCL_DEFINITION_STRUCT
376#ifndef __DCL_UART_STRUCT__
377#define __DCL_UART_STRUCT__
378
379#if defined(__CMUX_SUPPORT__)
380#include "cmux_vp_num.h"
381#define VIRTUAL_PORT_NUM CMUX_VP_NUM
382#else // #if defined(__CMUX_SUPPORT__)
383#define VIRTUAL_PORT_NUM 0
384#endif // #if defined(__CMUX_SUPPORT__)
385
386/*!
387 * @brief it defines DCL UART Device port enumeration
388 */
389#define DCL_UART_DEV \
390 uart_port1=0x00, \
391 uart_port2, \
392 uart_port3, \
393 /*uart_port_irda,*/\
394 uart_port_usb,\
395 uart_port_usb2,\
396 uart_port_usb3,\
397 uart_port_usb4,\
398 uart_port_usb5,\
399 uart_port_usb6,\
400 uart_port_usb7,\
401 uart_port_usb8,\
402 uart_port_usb_sp_direct,\
403 /*uart_port_bluetooth,*/\
404 /*uart_port_swdbg,*/\
405 uart_port_dhl_sp_expt,\
406 uart_port_dhl_eap_expt = uart_port_dhl_sp_expt,\
407 uart_port_dhl_ctrl_sp_expt,\
408 uart_port_meta_eap_expt = uart_port_dhl_ctrl_sp_expt,\
409 uart_port_dhl_sp,\
410 uart_port_dhl_ccci = uart_port_dhl_sp,\
411 uart_port_ccci_start = uart_port_dhl_ccci,\
412 uart_port_dhl_ctrl_sp,\
413 uart_port_tst_ccci = uart_port_dhl_ctrl_sp,\
414 uart_port_at_ccci,\
415 uart_port_gps_ccci,\
416 uart_port_sim_ccci,\
417 uart_port_dhl2_ccci,\
418 uart_port_atcp_ccci,\
419 uart_port_c2k_ppp_ccci,\
420 uart_port_c2k_agps_ccci,\
421 uart_port_cellinfo_ccci,\
422 uart_port_imsm_ccci,\
423 uart_port_woa_ccci,\
424 uart_port_xui_ccci,\
425 uart_port_bip_ccci,\
426 uart_port_udc_ccci,\
427 uart_port_nlopt_ccci,\
428 uart_port_nlopp_ccci,\
429 uart_port_sar_ccci,\
430 uart_port_ciq_ccci,\
431 uart_port_ikeraw_ccci,\
432 uart_port_ril_ipc0_ccci,\
433 uart_port_ril_ipc1_ccci,\
434 uart_port_vt_ccci,\
435 uart_port_cc_state_ccci,\
436 uart_port_mipi_ccci,\
437 uart_port_mipc_ap0_ccci,\
438 uart_port_mipc_ap1_ccci,\
439 uart_port_mipc_ap2_ccci,\
440 uart_port_mipc_ap3_ccci,\
441 uart_port_mipc_ap4_ccci,\
442 uart_port_mipc_ap5_ccci,\
443 uart_port_mipc_ap6_ccci,\
444 uart_port_mipc_ap7_ccci,\
445 uart_port_mipc_ap8_ccci,\
446 uart_port_mipc_ap9_ccci,\
447 uart_port_mipc_eap0_ccci,\
448 uart_port_mbim_eap0_ccci,\
449 uart_port_log_eap_ccci, uart_port_dhl_eap = uart_port_log_eap_ccci,\
450 uart_port_meta_eap_ccci, uart_port_meta_eap = uart_port_meta_eap_ccci,\
451 uart_port_epdg_ccci,\
452 uart_port_epdg2_ccci,\
453 uart_port_epdg3_ccci,\
454 uart_port_epdg4_ccci,\
455 uart_port_mbim_eap_dss0_ccci,\
456 uart_port_mbim_eap_dss1_ccci,\
457 uart_port_mbim_eap_dss2_ccci,\
458 uart_port_mbim_eap_dss3_ccci,\
459 uart_port_mbim_eap_dss4_ccci,\
460 uart_port_mbim_eap_dss5_ccci,\
461 uart_port_mbim_eap_dss6_ccci,\
462 uart_port_mbim_eap_dss7_ccci,\
463 uart_port_mipc_ap10_ccci,\
464 uart_port_mipc_ap11_ccci,\
465 uart_port_mipc_ap12_ccci,\
466 uart_port_mipc_ap13_ccci,\
467 uart_port_mipc_ap14_ccci,\
468 uart_port_ccci_end = uart_port_mipc_ap14_ccci,\
469 start_of_virtual_port,\
470 end_of_virtual_port = (VIRTUAL_PORT_NUM + start_of_virtual_port),\
471 /*uart_port_dcc,*/\
472 /*uart_port_lga1,*/\
473 /*uart_port_lga2,*/\
474 /*uart_port_lmu,*/\
475 /*uart_port_sp_usb,*/\
476 /*uart_port_sp_usb_dsp,*/\
477 uart_port_mini_log,\
478 uart_port_dual_talk,\
479 uart_port_modis,/*only for modis*/\
480 uart_port_mtad,\
481 uart_max_port,\
482 uart_port_null = 99,
483
484
485/*******************************************************************************
486 * DCL_CTRL_CMD for UART
487 *******************************************************************************/
488/*!
489 * @brief it defines DCL UART commands, including SIO/UART/USB/TTY commands
490 * Since TTY architecture has been modified and enhanced, there are some summaries for UART commands:
491 * - Data related SIO commands, such as
492 * SIO_CMD_PUT_BYTES
493 * SIO_CMD_PUT_ISR_BYTES,
494 * SIO_CMD_PUT_UART_BYTE
495 * SIO_CMD_PUT_UART_BYTES
496 * SIO_CMD_GET_TX_AVAIL
497 * SIO_CMD_GET_ISR_TX_AVAIL
498 * -> only support for conventional Tx Path.
499 * SIO_CMD_GET_BYTES
500 * SIO_CMD_GET_UART_BYTE
501 * SIO_CMD_GET_RX_AVAIL
502 * -> only support for conventional Rx Path.
503 * SIO_CMD_SEND_ISR_DATA
504 * SIO_CMD_SEND_DATA
505 * -> not support for all path.
506 * are not supported for new upper layer modules which use NEW TTY architecture.
507 * - TTY commands are added for new TTY architecture.
508 * among these commands, TTY_CMD_PUT_BYTES_IOR is to put bytes with ior format.
509 * But the upper layer modules don't need to take care TTY_CMD_PUT_BYTES_IOR commands. They only use DclSerialPort_UpModuleTransmit API to put data.
510 * - Driver must implement the following commands:
511 * SIO_CMD_INIT
512 * SIO_CMD_OPEN
513 * SIO_CMD_CLOSE
514 * SIO_CMD_PURGE
515 * SIO_CMD_SET_OWNER
516 * SIO_CMD_CLR_RX_BUF
517 * SIO_CMD_CLR_TX_BUF
518 * SIO_CMD_GET_OWNER_ID
519 * TTY_CMD_PUT_BYTES_IOR
520 * TTY_CMD_GET_CHUNK_SIZE
521 * TTY_CMD_ASSIGN_RX_IOR
522 * TTY_CMD_NEED_TX_DONE_CB
523 * , other commands
524 * - UART commands UART_CMD_BOOT_PUTBYTES & UART_CMD_BMT_PUT_BYTES still use buffer/length instead of ior as parameter.
525 *
526 * Notes of some commands:
527 * - SIO_CMD_CLR_TX_BUF : it would block and sleep before the command returns in conventional Tx mode.
528 * - SIO_CMD_CLR_RX_BUF : it would block and sleep before the command returns in conventional Rx mode.
529 * - SIO_CMD_SET_OWNER : it would block and sleep before the command returns in conventional Tx or Rx mode.
530 * - SIO_CMD_CLOSE : it would block and sleep before the command returns in conventional Tx or Rx mode.
531 * - SIO_CMD_PUT_ISR_BYTES : This command doesn't guarantee that all data can be sent successfully in conventional Tx mode since it won't send ReadyToWrite ilm.
532 */
533#define UART_CMDS \
534 SIO_CMD_INIT = 0x00,\
535 SIO_CMD_OPEN,\
536 SIO_CMD_CLOSE,\
537 SIO_CMD_GET_BYTES,\
538 SIO_CMD_PUT_BYTES,\
539 SIO_CMD_GET_RX_AVAIL,\
540 SIO_CMD_GET_TX_AVAIL,\
541 SIO_CMD_PUT_ISR_BYTES,\
542 SIO_CMD_GET_ISR_TX_AVAIL,\
543 SIO_CMD_PURGE,\
544 SIO_CMD_SET_OWNER,\
545 SIO_CMD_SET_FLOW_CTRL,\
546 SIO_CMD_CONFIG_ESCAPE,\
547 SIO_CMD_SET_DCB_CONFIG,\
548 SIO_CMD_CTRL_DCD,\
549 SIO_CMD_CTRL_BREAK, \
550 SIO_CMD_CLR_RX_BUF,\
551 SIO_CMD_CLR_TX_BUF, \
552 SIO_CMD_SET_BAUDRATE, \
553 SIO_CMD_SEND_ISR_DATA, \
554 SIO_CMD_SEND_DATA, \
555 SIO_CMD_GET_OWNER_ID, \
556 SIO_CMD_SET_AUTOBAUD_DIV, \
557 SIO_CMD_REG_TX_CB,\
558 SIO_CMD_REG_RX_CB,\
559 SIO_CMD_GET_UART_BYTE,\
560 SIO_CMD_PUT_UART_BYTE,\
561 SIO_CMD_PUT_UART_BYTES,\
562 SIO_CMD_READ_DCB_CONFIG,\
563 SIO_CMD_CTRL_RI,\
564 SIO_CMD_GET_ESCAPE_INFO,\
565 SIO_CMD_CTRL_DTR,\
566 SIO_CMD_READ_HW_STATUS,\
567 SIO_CMD_GET_UART_BYTE_WITH_TIMEOUT,\
568 UART_CMD_UART_START = 0x100,\
569 UART_CMD_SET_FIFO_TRIGGER,\
570 UART_CMD_POWER_ON,\
571 UART_CMD_CHECK_TX_BUF_EMPTY,\
572 UART_CMD_CHECK_TX_SEND_OUT,\
573 UART_CMD_GET_TX_BUF_SIZE,\
574 UART_CMD_SLEEP_TX_ENABLE,\
575 UART_CMD_CTRL_SLEEP_MODE,\
576 UART_CMD_SWITCH_PORT,\
577 UART_CMD_BOOTUP_INIT,\
578 UART_CMD_BOOT_PUTBYTES,\
579 UART_CMD_LOOPBACK,\
580 UART_CMD_ASSERT_WAIT_SEND_OUT,\
581 UART_CMD_CTRL_USE_VFIFO,\
582 UART_CMD_GET_FLOW_CONTROL,\
583 UART_CMD_REG_DEF_CB,\
584 UART_CMD_BMT_PUT_BYTES,\
585 UART_CMD_RECHANDLER_VFIFO,\
586 UART_CMD_TRXHANDLER_VFIFO,\
587 UART_CMD_RECTIMEOUTHANDLE,\
588 UART_CMD_CTRL_TX_DMA,\
589 UART_CMD_GET_MAX_BAUDRATE,\
590 UART_CMD_UART_END,\
591 USB_CMD_UART_START = 0x200,\
592 USB_CMD_IS_CDCACM,\
593 USB_CMD_HIGH_SPEED_IF_ENABLE, \
594 USB_CMD_REG_TX_CB, \
595 USB_CMD_TX_DATA_STATUS, \
596 USB_CMD_SEND_DATA, \
597 USB_CMD_GET_DATA, \
598 USB_CMD_SEND_ISR_DATA, \
599 USB_CMD_CTRL_SEND_DATA, \
600 USB_CMD_CTRL_GET_DATA, \
601 USB_CMD_HALT, \
602 USB_CMD_FT_PORT, \
603 USB_CMD_ACM_RING_BUFF_THRESHOLD_EN, \
604 USB_CMD_USB2UART_TX_DMA_CBK, \
605 USB_CMD_BOOT_PUTBYTES, \
606 USB_CMD_IS_CDCACM_ACTIVE,\
607 USB_CMD_UART_END, \
608 TTY_CMD_UART_START = 0x300,\
609 TTY_CMD_GET_CHUNK_SIZE,\
610 TTY_CMD_ASSIGN_RX_IOR,\
611 TTY_CMD_NEED_TX_DONE_CB,\
612 TTY_CMD_GET_DRV_STATE,\
613 TTY_CMD_PUT_BYTES_IOR,\
614 TTY_CMD_PUT_BYTES_IOR_LIGHT,\
615 TTY_CMD_GET_MTU_SIZE,\
616 TTY_CMD_SET_INDICATION,\
617 TTY_CMD_UART_END,\
618 TTY_CMD_EXCEPTION_START = 0x400,\
619 TTY_CMD_EXCEPTION_RESET,\
620 TTY_CMD_EXCEPTION_HIF_INIT,\
621 TTY_CMD_EXCEPTION_CLEAR_CHANNEL,\
622 TTY_CMD_EXCEPTION_TX_GPD,\
623 TTY_CMD_EXCEPTION_TX_DONE_INFO,\
624 TTY_CMD_EXCEPTION_HIF_STATE,\
625 TTY_CMD_EXCEPTION_ASSIGN_RX_GPD,\
626 TTY_CMD_EXCEPTION_GET_RX_GPD,\
627 TTY_CMD_EXCEPTION_HIF_POLL,\
628 TTY_CMD_EXCEPTION_HIF_RESET_LINK,\
629 TTY_CMD_EXCEPTION_FLUSH_TX,\
630 TTY_CMD_EXCEPTION_FLUSH_RX,\
631 TTY_CMD_EXCEPTION_END,
632
633//
634typedef enum
635{
636 DCL_UART_TYPE = 0x00,
637 DCL_UART_USB_TYPE,
638 DCL_UART_BLUETOOTH_TYPE,
639 DCL_UART_CMUX_TYPE,
640 DCL_UART_SPPA_TYPE,
641 DCL_UART_CCCI_TYPE,
642 DCL_UART_CCIF_TYPE,
643 DCL_UART_DCC_TYPE,
644 DCL_UART_LOGACC_TYPE,
645 DCL_UART_LMU_TYPE,
646 DCL_UART_SP_USB_TYPE,
647 DCL_UART_MINI_LOG_TYPE,
648 DCL_UART_MTAD_TYPE,
649 DCL_UART_DEV_TYPE_MAX
650}SIO_TYPE_T;
651
652typedef DCL_UINT32 UART_BAUDRATE_T;
653typedef UART_BAUDRATE_T UART_baudrate;
654typedef DCL_UINT16 UART_PORT;
655
656#define UART_BAUD_AUTO 0
657#define UART_BAUD_75 75
658#define UART_BAUD_150 150
659#define UART_BAUD_300 300
660#define UART_BAUD_600 600
661#define UART_BAUD_1200 1200
662#define UART_BAUD_2400 2400
663#define UART_BAUD_4800 4800
664#define UART_BAUD_7200 7200
665#define UART_BAUD_9600 9600
666#define UART_BAUD_14400 14400
667#define UART_BAUD_19200 19200
668#define UART_BAUD_28800 28800
669#define UART_BAUD_33900 33900
670#define UART_BAUD_38400 38400
671#define UART_BAUD_57600 57600
672#define UART_BAUD_115200 115200
673#define UART_BAUD_230400 230400
674#define UART_BAUD_460800 460800
675#define UART_BAUD_921600 921600
676#define UART_BAUD_1500000 1500000
677
678#define UART_TO_ELT_BAUD 1500000
679
680typedef enum {
681 LEN_5=5,
682 LEN_6,
683 LEN_7,
684 LEN_8
685} UART_BITS_PER_CHAR_T;
686
687typedef enum {
688 SB_1=1,
689 SB_2,
690 SB_1_5
691} UART_STOP_BITS_T;
692
693typedef enum {
694 PA_NONE=0,
695 PA_ODD,
696 PA_EVEN,
697 PA_SPACE
698} UART_PARITY_T;
699
700/*
701#if defined(FC_NONE)
702#undef FC_NONE
703#endif
704*/
705
706typedef enum {
707 FC_NONE=1,
708 FC_HW,
709 FC_SW
710} UART_FLOW_CTRL_MODE_T;
711
712typedef enum {
713 DCL_NONE_VFIFO,
714 DCL_RX_VFIFO,
715 DCL_TX_VFIFO,
716 DCL_TXRX_VFIFO
717} UART_VFIFO_T;
718
719typedef enum {
720 uart_sleep_on_tx_allow = 0,
721 uart_sleep_on_tx_forbid
722} UART_SLEEP_ON_TX;
723
724
725
726typedef struct
727{
728 UART_BAUDRATE_T u4Baud;
729 DCL_UINT8 u1DataBits; //UART_BITS_PER_CHAR_T
730 DCL_UINT8 u1StopBits; //UART_STOP_BITS_T
731 DCL_UINT8 u1Parity; //UART_PARITY_T
732 DCL_UINT8 u1FlowControl; //UART_FLOW_CTRL_MODE_T
733 DCL_UCHAR ucXonChar;
734 DCL_UCHAR ucXoffChar;
735 DCL_BOOLEAN fgDSRCheck;
736} UART_CONFIG_T;
737
738typedef enum
739{
740 DCL_IO_Low=0,
741 DCL_IO_High
742} IO_LEVEL_T;
743
744
745typedef enum {
746 DCL_RX_BUF,
747 DCL_TX_BUF
748} UART_BUFFER_T;
749
750typedef enum {
751 DCL_UART_SLEEP_ON_TX_ALLOW = 0,
752 DCL_UART_SLEEP_ON_TX_FORBID,
753} UART_SLEEP_ON_TX_T;
754
755typedef enum {
756 DCL_UART_BY_VFIFO,
757 DCL_UART_BY_DMA,
758 DCL_UART_BY_MCU,
759 DCL_UART_BY_UNKNOWN
760} UART_WORK_MODE;
761
762
763/*!
764 * @brief tty_io_request_t is a typedef of struct _tty_io_request
765 */
766typedef struct _tty_io_request_t tty_io_request_t;
767
768/*!
769 * @brief struct _tty_io_request_t describe io request used to communicate
770 * between ap module & tty
771 */
772struct _tty_io_request_t{
773 /*!
774 * @brief next io request
775 */
776 tty_io_request_t *next_request;
777 /*!
778 * @brief pointer to current gpd of this io request
779 */
780 void *first_gpd;
781 /*!
782 * @brief pointer to last gpd of this io request
783 */
784 void *last_gpd;
785};
786
787//UART_CMD_INIT
788typedef struct
789{
790 DCL_UINT32 u4Flag;
791}UART_CTRL_INIT_T;
792
793//UART_CMD_OPEN
794typedef struct
795{
796 DCL_UINT32 u4OwenrId;
797}UART_CTRL_OPEN_T;
798
799//UART_CMD_CLOSE
800typedef struct
801{
802 DCL_UINT32 u4OwenrId;
803}UART_CTRL_CLOSE_T;
804
805//UART_CMD_GET_BYTES
806typedef struct
807{
808 DCL_UINT16 u2Length;
809 DCL_UINT32 u4OwenrId;
810 DCL_UINT16 u2RetSize;
811 DCL_UINT8* puBuffaddr;
812 DCL_UINT8* pustatus;
813
814}UART_CTRL_GET_BYTES_T;
815
816//UART_CMD_PUT_BTYES
817//UART_CMD_PUT_ISR_BYTES
818typedef struct
819{
820 DCL_UINT16 u2Length;
821 DCL_UINT32 u4OwenrId;
822 DCL_UINT16 u2RetSize;
823 DCL_UINT8* puBuffaddr;
824}UART_CTRL_PUT_BYTES_T;
825
826typedef struct
827{
828 DCL_UINT32 u4OwnerId;
829 void *putIor;
830}UART_CTRL_PUT_BYTES_IOR_T;
831
832//UART_CMD_GET_RX_AVAIL
833typedef struct
834{
835 DCL_UINT16 u2RetSize;
836}UART_CTRL_RX_AVAIL_T;
837
838//UART_CMD_GET_TX_AVAIL
839//UART_CMD_GET_ISR_TX_AVAIL
840typedef struct
841{
842 DCL_UINT16 u2RetSize;
843}UART_CTRL_TX_AVAIL_T;
844
845//UART_CMD_PURGE
846typedef struct
847{
848 DCL_UINT32 u4OwenrId;
849 UART_BUFFER_T dir;
850}UART_CTRL_PURGE_T;
851
852//UART_CMD_SET_OWNER
853//UART_CMD_GET_OWNER_ID
854typedef struct
855{
856 DCL_UINT32 u4OwenrId;
857}UART_CTRL_OWNER_T;
858
859//UART_CMD_SET_FLOW_CTRL
860typedef struct
861{
862 DCL_UINT32 u4OwenrId;
863 DCL_BOOL bXON;
864}UART_CTRL_FLOW_CTRL_T;
865
866//UART_CMD_CONFIG_ESCAPE
867typedef struct
868{
869 DCL_UINT32 u4OwenrId;
870 DCL_UINT8 uEscChar;
871 DCL_UINT16 u2ESCGuardtime;
872} UART_CTRL_CONFIG_ESP_T;
873
874//UART_CMD_SET_DCB_COFIG
875//UART_CMD_READ_DCB_CONFIG
876
877typedef struct
878{
879 DCL_UINT32 u4OwenrId;
880 UART_CONFIG_T rUARTConfig;
881} UART_CTRL_DCB_T;
882
883//UART_CMD_CTRL_DCD
884
885typedef struct
886{
887 DCL_UINT32 u4OwenrId;
888 IO_LEVEL_T rIOLevelDCD;
889} UART_CTRL_DCD_T;
890
891//UART_CMD_GET_FLOW_CONTROL
892typedef struct
893{
894 DCL_UINT32 u4OwenrId;
895 UART_FLOW_CTRL_MODE_T FlowCtrlMode;
896}UART_CTRL_GET_FC_T;
897
898//TTY_CMD_GET_CHUNK_SIZE
899typedef struct
900{
901 DCL_UINT32 chunkSize;
902} UART_CTRL_GET_CHUNK_SIZE_T;
903
904//TTY_CMD_NEED_TX_DONE_CB
905typedef struct
906{
907 DCL_UINT32 u4OwnerId;
908 DCL_BOOL needTxDoneCb;
909} UART_CTRL_NEED_TX_DONE_CB_T;
910
911//TTY_CMD_GET_MTU_SIZE
912typedef struct
913{
914 DCL_UINT32 ulmtu_sz;
915 DCL_UINT32 dlmtu_sz;
916} UART_CTRL_GET_MTU_SIZE_T;
917
918//TTY_CMD_SET_INDICATION
919typedef struct
920{
921 DCL_BOOL need_indication;
922} UART_CTRL_SET_INDICATION_T;
923
924/*!
925 * @brief TTY driver state
926 */
927typedef enum _tty_drv_state {
928 /*!
929 * @brief driver detached state
930 */
931 DRV_ST_DETACHED = 0,
932 /*!
933 * @brief driver attached state
934 */
935 DRV_ST_ATTACHED
936} tty_drv_state_e;
937
938//TTY_CMD_GET_DRV_STATE
939typedef struct
940{
941 DCL_UINT32 u4OwnerId;
942 tty_drv_state_e drv_state;
943} UART_CTRL_GET_DRV_STATE_T;
944
945//TTY_CMD_ASSIGN_RX_IOR
946typedef struct
947{
948 DCL_UINT32 u4OwnerId;
949 void *ior;
950} UART_CTRL_ASSIGN_RX_IOR_T;
951
952//UART_CMD_CTRL_BREAK
953typedef struct
954{
955 DCL_UINT32 u4OwenrId;
956 IO_LEVEL_T rIOLevelBRK;
957} UART_CTRL_BREAK_T;
958
959//UART_CMD_CLR_RX_BUF
960//UART_CMD_CLR_TX_BUF
961typedef struct
962{
963 DCL_UINT32 u4OwenrId;
964} UART_CTRL_CLR_BUFFER_T;
965
966//UART_CMD_SET_BAUDRATE
967typedef struct
968{
969 DCL_UINT32 u4OwenrId;
970 UART_BAUDRATE_T baudrate;
971} UART_CTRL_BAUDRATE_T;
972
973//UART_CMD_SEND_ISR_DATA
974//UART_CMD_SEND_DATA
975typedef struct
976{
977 DCL_UINT32 u4OwenrId;
978 DCL_UINT8* puBuffaddr;
979 DCL_UINT16 u2Length;
980 DCL_UINT8 umode;
981 DCL_UINT8 uescape_char;
982 DCL_UINT16 u2RetSize;
983}UART_CTRL_SEND_DATA_T;
984
985//UART_CMD_SET_AUTOBAUD_DIV
986typedef struct
987{
988 DCL_UINT32 u4OwenrId;
989} UART_CTRL_AUTO_BAUDDIV_T;
990
991typedef void (*DCL_UART_TX_FUNC)(DCL_UINT32 u4Port);
992typedef void (*DCL_UART_RX_FUNC)(DCL_UINT32 u4Port) ;
993
994
995//UART_CMD_REG_TX_CB
996typedef struct
997{
998 DCL_UINT32 u4OwenrId;
999 DCL_UART_TX_FUNC func;
1000} UART_CTRL_REG_TX_CB_T;
1001
1002
1003//UART_CMD_REG_RX_CB
1004typedef struct
1005{
1006 DCL_UINT32 u4OwenrId;
1007
1008 DCL_UART_RX_FUNC func;
1009} UART_CTRL_REG_RX_CB_T;
1010
1011typedef enum
1012{
1013 UART_TX = 0,
1014 UART_RX,
1015 DSP_TX,
1016 DSP_RX
1017}UART_IO_DIR;
1018
1019//UART_CMD_REG_DEF_CB
1020typedef struct
1021{
1022 UART_IO_DIR dir;
1023}UART_CTRL_REG_DEF_CB_T;
1024
1025//UART_CMD_GET_UART_BYTE
1026typedef struct
1027{
1028 DCL_UINT8 uByte;
1029}UART_CTRL_GET_UART_BYTE_T;
1030
1031//SIO_CMD_GET_UART_BYTE_WITH_TIMEOUT
1032typedef struct
1033{
1034 DCL_UINT8 u1retByte;
1035 DCL_UINT8 uByte;
1036 DCL_UINT32 u4timeout_value;
1037}UART_CTRL_GET_UART_BYTE_WITH_TIMEOUT_T;
1038
1039//UART_CMD_PUT_UART_BYTE
1040typedef struct
1041{
1042 DCL_UINT8 uData;
1043}UART_CTRL_PUT_UART_BYTE_T;
1044
1045//UART_CMD_PUT_UART_BYTES
1046typedef struct
1047{
1048 DCL_UINT8* puBuffaddr;
1049 DCL_UINT16 u2Length;
1050
1051}UART_CTRL_PUT_UART_BYTES_T;
1052
1053//UART_CMD_CTRL_RI
1054typedef struct
1055{
1056 DCL_UINT32 u4OwenrId;
1057 IO_LEVEL_T rIOLevelSRI;
1058
1059}UART_CTRL_RI_T;
1060
1061//UART_CMD_CTRL_DTR
1062typedef struct
1063{
1064 DCL_UINT32 u4OwenrId;
1065 IO_LEVEL_T rIOLevelDTR;
1066}UART_CTRL_DTR_T;
1067
1068//UART_CMD_READ_HW_STATUS
1069typedef struct
1070{
1071 IO_LEVEL_T rIOLevelDSR;
1072 IO_LEVEL_T rIOLevelCTS;
1073}UART_CTRL_RHS_T;
1074
1075//UART_CMD_SET_FIFO_TRIGGER
1076typedef struct
1077{
1078 DCL_UINT16 tx_level;
1079 DCL_UINT16 rx_level;
1080}UART_CTRL_SFT_T;
1081
1082//UART_CMD_POWER_ON
1083typedef struct
1084{
1085 DCL_BOOL bFlag_Poweron;
1086}UART_CTRL_POWERON_T;
1087
1088//UART_CMD_CHECK_TX_BUF_EMPTY
1089typedef struct
1090{
1091 DCL_BOOL bFlag;
1092}UART_CTRL_CHECK_TBE_T;
1093
1094// UART_CMD_CHECK_TX_SEND_OUT
1095typedef struct
1096{
1097 DCL_BOOL bFlag;
1098}UART_CTRL_CHECK_TSO_T;
1099
1100//UART_CMD_GET_TX_BUF_SIZE
1101typedef struct
1102{
1103 DCL_UINT32* ptotal_size;
1104 DCL_UINT32* preturn_size;
1105}UART_CTRL_GET_TBS_T;
1106
1107
1108//UART_CMD_SLEEP_TX_ENABLE
1109typedef struct
1110{
1111 UART_SLEEP_ON_TX_T bFlag;
1112}UART_CTRL_SLEEP_ON_TX_ENABLE_T;
1113
1114//UART_CMD_CTRL_SLEEP_MODE
1115typedef struct
1116{
1117 DCL_BOOL bFlag;
1118}UART_CTRL_SLEEP_ENABLE_T;
1119
1120
1121//UART_CMD_BOOT_PUTBYTES
1122typedef struct
1123{
1124 DCL_UINT8* puBuffaddr;
1125 DCL_UINT16 u2Length;
1126}UART_CTRL_BOOT_PUTBYTES_T;
1127
1128
1129//UART_CMD_CTRL_USE_VFIFO
1130typedef struct
1131{
1132 DCL_BOOL bUseVFifo;
1133}UART_CTRL_USE_VFIFO_T;
1134
1135//UART_CMD_GET_MAX_BAUDRATE
1136typedef struct
1137{
1138 kal_uint32 max_baudrate;
1139}UART_CTRL_GET_MAXBAUDRATE_T;
1140
1141//TTY_CMD_EXCEPTION_TX_GPD
1142typedef struct
1143{
1144 void *first_gpd;
1145 void *last_gpd;
1146}TTY_CTRL_EXCP_TX_GPD_T;
1147
1148//TTY_CMD_EXCEPTION_TX_DONE_INFO
1149typedef struct
1150{
1151 void *first_gpd;
1152 void *last_gpd;
1153 DCL_UINT32 num;
1154}TTY_CTRL_EXCP_TX_DONE_INFO_T;
1155
1156//TTY_CMD_EXCEPTION_HIF_STATE
1157typedef enum _tty_excp_hif_state {
1158 HIF_STATE_NORMAL = 0,
1159 HIF_STATE_TXERROR
1160} tty_excp_hif_state;
1161typedef struct
1162{
1163 tty_excp_hif_state hif_state;
1164}TTY_CTRL_EXCP_HIF_STATE_T;
1165
1166//TTY_CMD_EXCEPTION_ASSIGN_RX_GPD
1167typedef struct
1168{
1169 void *first_gpd;
1170 void *last_gpd;
1171}TTY_CTRL_EXCP_ASSIGN_RX_GPD_T;
1172
1173//TTY_CMD_EXCEPTION_GET_RX_GPD
1174typedef struct
1175{
1176 void *first_gpd;
1177 void *last_gpd;
1178 DCL_UINT32 num;
1179}TTY_CTRL_EXCP_GET_RX_GPD_T;
1180
1181//TTY_CMD_EXCEPTION_FLUSH_TX
1182typedef struct
1183{
1184 void *first_gpd;
1185 void *last_gpd;
1186 DCL_UINT32 num;
1187}TTY_CTRL_EXCP_FLUSH_TX_T;
1188
1189//TTY_CMD_EXCEPTION_FLUSH_RX
1190typedef struct
1191{
1192 void *first_gpd;
1193 void *last_gpd;
1194 DCL_UINT32 num;
1195}TTY_CTRL_EXCP_FLUSH_RX_T;
1196
1197//TTY_CMD_EXCEPTION_HIF_POLL
1198typedef struct
1199{
1200 DCL_BOOL reset_event;
1201}TTY_CTRL_EXCP_HIF_POLL_T;
1202
1203typedef enum {
1204 NONE_VFIFO,
1205 RX_VFIFO,
1206 TX_VFIFO,
1207 TXRX_VFIFO
1208} UART_TxRx_VFIFO_support;
1209
1210typedef enum {
1211 RX_BUF,
1212 TX_BUF
1213} UART_buffer;
1214
1215typedef enum {
1216 Compensate_None = 0,
1217 Compensate_Wait,
1218 Compensate_AT,
1219 Compensate_at
1220}UART_Compensate_enum;
1221
1222
1223typedef enum {
1224 len_5=5,
1225 len_6,
1226 len_7,
1227 len_8
1228} UART_bitsPerCharacter;
1229
1230typedef enum {
1231 sb_1=1,
1232 sb_2,
1233 sb_1_5
1234} UART_stopBits;
1235
1236typedef enum {
1237 pa_none=0,
1238 pa_odd,
1239 pa_even,
1240 pa_mark, //k2 md2 6589, add for solving driver/peripheral uart module build error
1241 pa_space
1242} UART_parity;
1243
1244typedef enum {
1245 fc_none=1,
1246 fc_hw,
1247 fc_sw
1248} UART_flowCtrlMode;
1249
1250typedef struct
1251{
1252 UART_baudrate baud;
1253 UART_bitsPerCharacter dataBits;
1254 UART_stopBits stopBits;
1255 UART_parity parity;
1256 UART_flowCtrlMode flowControl;
1257 kal_uint8 xonChar;
1258 kal_uint8 xoffChar;
1259 kal_bool DSRCheck;
1260} UARTDCBStruct;
1261
1262typedef struct
1263{
1264 kal_uint8 EscChar;
1265 kal_uint16 GuardTime;
1266} UART_ESCDetectStruct;
1267
1268typedef struct
1269{
1270 kal_uint8 *rx_buffer; /* data buffer */
1271 kal_uint8 *tx_buffer; /* data buffer */
1272 kal_uint8 *txISR_buffer; /* data buffer */
1273} UART_RingBufferStruct;
1274
1275
1276 typedef enum {
1277 uart_null_buffer=0,
1278 uart_isr_buffer,
1279 uart_normal_buffer
1280 } UART_RingBuffer_Type;
1281
1282 typedef struct
1283 {
1284 UART_RingBuffer_Type type;
1285 kal_uint16 index;
1286 } UART_RingBuffer_SaveIndex;
1287
1288
1289typedef struct
1290{
1291 kal_uint16 tst_port_ps;
1292 kal_uint16 ps_port;
1293 UART_baudrate tst_baudrate_ps;
1294 UART_baudrate ps_baudrate;
1295 kal_bool High_Speed_SIM_Enabled;
1296 kal_uint8 swdbg;
1297 kal_uint8 uart_power_setting; /* For DCM, Start [Set UART POWER], CTI */
1298 kal_uint8 cti_uart_port;
1299 UART_baudrate cti_baudrate;
1300 kal_uint8 tst_port_l1;
1301 UART_baudrate tst_baudrate_l1;
1302 kal_uint8 tst_output_mode;
1303 kal_uint8 usb_logging_mode;
1304 kal_uint16 tst_port_dsp;
1305 UART_baudrate tst_baud_rate_dsp;
1306 kal_uint8 usb_cdrom_config;
1307 kal_uint16 speech_port;
1308 kal_uint16 ndis_port;
1309 kal_uint16 epdg_cmd_port;
1310 kal_uint16 epdg_urc_port;
1311 kal_uint16 epdg_cmd_port_2;
1312 kal_uint16 epdg_urc_port_2;
1313} port_setting_struct;
1314
1315/*start of local parameter struct */
1316
1317typedef struct
1318{
1319 LOCAL_PARA_HDR /* LOCAL_PARA_HDR */
1320 DCL_UINT16 port;
1321}uart_ready_to_read_ind_struct;
1322
1323typedef struct
1324{
1325 LOCAL_PARA_HDR /* LOCAL_PARA_HDR */
1326 DCL_UINT16 port;
1327}uart_ready_to_write_ind_struct;
1328
1329 typedef struct
1330{
1331 LOCAL_PARA_HDR /* LOCAL_PARA_HDR */
1332 DCL_UINT16 port;
1333}uart_dsr_change_ind_struct;
1334
1335 typedef struct
1336{
1337 LOCAL_PARA_HDR /* LOCAL_PARA_HDR */
1338 DCL_UINT16 port;
1339}uart_escape_detected_ind_struct;
1340
1341 typedef struct
1342{
1343 LOCAL_PARA_HDR /* LOCAL_PARA_HDR */
1344 DCL_UINT16 port;
1345}uart_plugin_ind_struct;
1346
1347 typedef struct
1348{
1349 LOCAL_PARA_HDR /* LOCAL_PARA_HDR */
1350 DCL_UINT16 port;
1351}uart_plugout_ind_struct;
1352
1353
1354#define UART_CTRLS \
1355 UART_CTRL_INIT_T rUARTCtrlInit;\
1356 UART_CTRL_OPEN_T rUARTCtrlOPEN; \
1357 UART_CTRL_CLOSE_T rUARTCtrlCLOSE; \
1358 UART_CTRL_GET_BYTES_T rUARTCtrlGETBYTES; \
1359 UART_CTRL_PUT_BYTES_T rUARTCtrlPUTBYTES; \
1360 UART_CTRL_RX_AVAIL_T rUARTCtrlRXAVAIL; \
1361 UART_CTRL_TX_AVAIL_T rUARTCtrlTXAVAIL; \
1362 UART_CTRL_PURGE_T rUARTCtrlPURGE; \
1363 UART_CTRL_OWNER_T rUARTCtrlOWNER; \
1364 UART_CTRL_FLOW_CTRL_T rUARTCtrlFLOWCTRL; \
1365 UART_CTRL_CONFIG_ESP_T rUARTCtrlCONFIGESP; \
1366 UART_CTRL_DCB_T rUARTCtrlDCB; \
1367 UART_CTRL_DCD_T rUARTCtrlDCD;\
1368 UART_CTRL_BREAK_T rUARTCtrlBREAK;\
1369 UART_CTRL_CLR_BUFFER_T rUARTCtrlCLRBUFFER;\
1370 UART_CTRL_BAUDRATE_T rUARTCtrlBAUDRATE;\
1371 UART_CTRL_SEND_DATA_T rUARTCtrlSENDDATA;\
1372 UART_CTRL_AUTO_BAUDDIV_T rUARTCtrlAUTOBAUDDIV;\
1373 UART_CTRL_REG_TX_CB_T rUARTCtrlREGTXCB;\
1374 UART_CTRL_REG_RX_CB_T rUARTCtrlREGRXCB;\
1375 UART_CTRL_GET_UART_BYTE_T rUARTCtrlGETUARTBYTE;\
1376 UART_CTRL_GET_UART_BYTE_WITH_TIMEOUT_T rUARTCtrlGETUARTBYTEWithTimeOut;\
1377 UART_CTRL_PUT_UART_BYTE_T rUARTCtrlPUTUARTBYTE;\
1378 UART_CTRL_PUT_UART_BYTES_T rUARTCtrlPUTUARTBYTES;\
1379 UART_CTRL_RI_T rUARTCtrlRI;\
1380 UART_CTRL_DTR_T rUARTCtrlDTR;\
1381 UART_CTRL_RHS_T rUARTCtrlRHS;\
1382 UART_CTRL_SFT_T rUARTCtrlSFT;\
1383 UART_CTRL_POWERON_T rUARTCtrlPoweron;\
1384 UART_CTRL_CHECK_TBE_T rUARTCtrlCheckBUFEMP;\
1385 UART_CTRL_CHECK_TSO_T rUARTCtrlCheckTXSendOut;\
1386 UART_CTRL_GET_TBS_T rUARTCtrlGetTxBufSize;\
1387 UART_CTRL_SLEEP_ON_TX_ENABLE_T rUARTCtrlSleepOnTxEnable;\
1388 UART_CTRL_SLEEP_ENABLE_T rUARTCtrlSleepEnable;\
1389 UART_CTRL_BOOT_PUTBYTES_T rUARTCtrlBootPutBytes;\
1390 UART_CTRL_USE_VFIFO_T rUARTCtrlUseVFifo;\
1391 UART_CTRL_REG_DEF_CB_T rUARTCtrlRegDefCB;\
1392 UART_CTRL_GET_MAXBAUDRATE_T rUARTCtrlGetMaxBaudrate;\
1393 UART_CTRL_GET_FC_T rUARTCtrlGetFC;\
1394 UART_CTRL_NEED_TX_DONE_CB_T rUARTCtrlNeedTxDoneCb; /*new*/\
1395 UART_CTRL_GET_DRV_STATE_T rUARTCtrlGetDrvState; /*new*/\
1396 UART_CTRL_ASSIGN_RX_IOR_T rUARTCtrlAssignRxIor; /*new*/ \
1397 UART_CTRL_PUT_BYTES_IOR_T rUARTCtrlPUTBYTESIOR; /*new*/ \
1398 UART_CTRL_GET_CHUNK_SIZE_T rUARTCtrlGETCHUNKSIZE; /*new*/\
1399 UART_CTRL_GET_MTU_SIZE_T rUARTCtrlGETMTUSIZE; /*new*/\
1400 UART_CTRL_SET_INDICATION_T rUARTCtrlSETINDICATION; /*new*/\
1401 TTY_CTRL_EXCP_TX_GPD_T rTTYCtrlExcpTxGPD; /*new*/\
1402 TTY_CTRL_EXCP_TX_DONE_INFO_T rTTYCtrlExcpTxDoneInfo; /*new*/\
1403 TTY_CTRL_EXCP_HIF_STATE_T rTTYCtrlExcpHifState; /*new*/\
1404 TTY_CTRL_EXCP_ASSIGN_RX_GPD_T rTTYCtrlExcpAssignRxGPD; /*new*/\
1405 TTY_CTRL_EXCP_GET_RX_GPD_T rTTYCtrlExcpGetRxGPD; /*new*/\
1406 TTY_CTRL_EXCP_FLUSH_TX_T rTTYCtrlExcpFlushTx; /*new*/\
1407 TTY_CTRL_EXCP_FLUSH_RX_T rTTYCtrlExcpFlushRx; /*new*/\
1408 TTY_CTRL_EXCP_HIF_POLL_T rTTYCtrlExcpHifPoll; /*new*/
1409
1410#endif
1411#endif
1412
1413
1414#ifdef DCL_DEFINITION_PROTOTYPE
1415#ifndef __DCL_UART_H_PROTOTYPE__
1416#define __DCL_UART_H_PROTOTYPE__
1417
1418typedef DCL_STATUS(*SeriPort_HANLDER_CB)(DCL_DEV dev, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
1419typedef struct
1420{
1421 SIO_TYPE_T DevType;
1422 SeriPort_HANLDER_CB SeriportHandlerCb;
1423}Seriport_HANDLER_T;
1424
1425/*!
1426 * @brief TTY flag
1427 */
1428typedef enum _tty_flag {
1429 /*!
1430 * @brief use new TTY Tx path
1431 */
1432 TTY_FLAG_NEW_TX = (1 << 0),
1433 /*!
1434 * @brief use new TTY Rx path
1435 */
1436 TTY_FLAG_NEW_RX = (1 << 1),
1437} tty_flag_e;
1438
1439typedef DCL_STATUS(*tty_txdone_cb)(DCL_HANDLE handle, module_type source_id, tty_io_request_t *tx_ior);
1440typedef DCL_STATUS(*tty_rx_cb)(DCL_HANDLE handle, module_type source_id, tty_io_request_t *rx_ior);
1441typedef DCL_STATUS(*tty_drv_state_change_cb)(DCL_HANDLE handle, tty_drv_state_e state);
1442
1443
1444
1445/*!
1446* @function DclSerialPort_Open
1447* @brief This function is to open the UART module and get a handle.
1448* @param dev Port number. it can take DCL_UART_DEV as reference
1449* @param flags module_type | FLAGS_UART_USE_VFIFO
1450* module_type: KAL module type enum value
1451* FLAGS_UART_USE_VFIFO: flags that specifies to use Virtual FIFO or not for UART device. Note that it's only valide for eDev with DCL_UART1, DCL_UART2, DCL_UART3(if exists)
1452* [Note] Currently TTY doesn't handle flags!! This parameter is kept for backward compatible.
1453* @result STATUS_FAIL Open failed.
1454* @result STATUS_ALREADY_OPENED This device has already been opened.
1455* @result STATUS_INVALID_DEVICE The device is not valid.
1456* @result STATUS_SET_VFIFO_FAIL Fail to use Vitual FIFO for the UART port.
1457* @result other value a valid handle
1458*
1459*/
1460extern DCL_HANDLE DclSerialPort_Open(DCL_DEV dev, DCL_FLAGS flags);
1461
1462/*!
1463* @function DclSerialPort_Configure
1464* @brief This function is to configure for the UART module. [Note] Currenlty this function is not used.
1465* @param handle a valid handle return by DclSerialPort_Open()
1466* @param configure a ponter to UART_CONFIG_T structure which is a member of union DCL_CONFIGURE_T
1467* @result STATUS_OK successfully configure.
1468* @result STATUS_INVALID_HANDLE It's a invalid handle.
1469* @result STATUS_NOT_OPENED The module has not been opened.
1470* @result STATUS_INVALID_CONFIGURATION the configuration is not valid.
1471*/
1472extern DCL_STATUS DclSerialPort_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure);
1473
1474/*!
1475* @function DclSerialPort_Control
1476* @brief This function is support UART module commands. It is called to send command to control the UART module.
1477* @param handle a valid handle return by DclSerialPort_Open()
1478* @param cmd dcl uart commands
1479* @param data pointer to the corresponding data structure of command
1480* @result STATUS_OK command is executed successfully.
1481* @result STATUS_INVALID_CMD It's a invalid command.
1482* @result STATUS_INVALID_HANDLE It's a invalid handle.
1483*/
1484extern DCL_STATUS DclSerialPort_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
1485
1486/*!
1487* @function DclSerialPort_Close
1488* @brief This function is to close the UART module.
1489* @param handle hanlde previous got from DclSerialPort_Open()
1490* @result STATUS_OK Successfully close the UART module.
1491* @result STATUS_INVALID_HANDLE It's invalid handle.
1492* @result STATUS_NOT_OPENED The UART module hasn't been opened yet.
1493*/
1494extern DCL_STATUS DclSerialPort_Close(DCL_HANDLE handle);
1495
1496/* ---------------------------------------- General --------------------------------------------- */
1497/*!
1498* @function DclSerialPort_Initialize
1499* @brief This function is to initialize TTY module..
1500* @param none
1501* @result STATUS_OK successfully initialize TTY module.
1502* @result STATUS_FAIL initialized failed..
1503*/
1504extern DCL_STATUS DclSerialPort_Initialize(void);
1505
1506/* ----------------------------------- Export to upper layer --------------------------------------- */
1507/*!
1508* @function [New TTY API] DclSerialPort_UpModuleInit
1509* @brief This function is to initialize/start designated COM Port for upper module.
1510* @param handle a valid handle return by DclSerialPort_Open()
1511* @param module_id upper module id
1512* @param flag TTY COM Port attribute. Currently they are TTY_FLAG_NEW_TX or TTY_FLAG_NEW_RX.
1513* Upper module can initialize flag with new Tx/Rx flow (gpd based) or conventional Tx/Rx (buffer/length based) flow.
1514* ex. New Tx and Conventional Rx - DclSerialPort_UpModuleReinit(handle, module_id, TTY_FLAG_NEW_TX);
1515* @result STATUS_OK Init COM Port device successfully.
1516* @result STATUS_INVALID_HANDLE It's a invalid handle.
1517* @result STATUS_ALREADY_OPENED The COM Port has been initialized by other module.
1518* @result STATUS_DEVICE_NOT_EXIST The corresponding device driver of COM Port has not been initialized.
1519*/
1520extern DCL_STATUS DclSerialPort_UpModuleInit(DCL_HANDLE handle, module_type module_id, int flag);
1521
1522/*!
1523* @function [New TTY API] DclSerialPort_UpModuleReinit
1524* @brief This function is to re-init TTY COM Port setting. This function is called when owner is changed.
1525* @param handle a valid handle return by DclSerialPort_Open()
1526* @param module_id upper module id
1527* @param flag TTY COM Port attribute. Currently they are TTY_FLAG_NEW_TX or TTY_FLAG_NEW_RX.
1528* Upper module can re-init flag with new Tx/Rx flow (gpd based) or conventional Tx/Rx (buffer/length based) flow.
1529* ex. Reinit to New Tx and Conventional Rx - DclSerialPort_UpModuleReinit(handle, module_id, TTY_FLAG_NEW_TX);
1530* @result STATUS_OK Re-Init COM Port device successfully.
1531* @result STATUS_INVALID_HANDLE It's a invalid handle.
1532* @result STATUS_NOT_OPENED The COM Port has not been initialized.
1533* @result STATUS_DEVICE_NOT_EXIST The corresponding device driver of COM Port has not been initialized.
1534*/
1535extern DCL_STATUS DclSerialPort_UpModuleReinit(DCL_HANDLE handle, module_type module_id, int flag);
1536
1537/*!
1538* @function [New TTY API] DclSerialPort_UpModuleDeinit
1539* @brief This function is to de-init/de-register COM Port.
1540* @param handle a valid handle return by DclSerialPort_Open()
1541* @result STATUS_OK Deinit COM Port device successfully.
1542* @result STATUS_INVALID_HANDLE It's a invalid handle.
1543* @result STATUS_NOT_OPENED The COM Port has not been initialized.
1544* @result STATUS_DEVICE_NOT_EXIST The corresponding device driver of COM Port has not been initialized.
1545*/
1546extern DCL_STATUS DclSerialPort_UpModuleDeinit(DCL_HANDLE handle);
1547
1548/*!
1549* @function [New TTY API] DclSerialPort_UpModuleRegisterCb
1550* @brief This function is for upper layer module to register callback function.
1551* @param handle a valid handle return by DclSerialPort_Open()
1552* @param rx_cb rx callback function, driver send receiving data to upper layer through this rx callback function
1553* @param tx_done_cb tx done callback function, this callback function will be called when data has been sent
1554* @param drv_state_change_cb driver state change callback function, it notify the upper layer module when driver state is changed, ex. USB disconnect
1555* @result STATUS_OK Register callback function successfully.
1556* @result STATUS_INVALID_HANDLE It's a invalid handle.
1557* @result STATUS_NOT_OPENED The COM Port has not been initialized.
1558* @result STATUS_DEVICE_NOT_EXIST The corresponding device driver of COM Port has not been initialized.
1559* @result STATUS_FAIL Failed for other reasons.
1560*/
1561extern DCL_STATUS DclSerialPort_UpModuleRegisterCb(DCL_HANDLE handle, tty_rx_cb rx_cb, tty_txdone_cb tx_done_cb, tty_drv_state_change_cb drv_state_change_cb);
1562
1563/*!
1564* @function [New TTY API] DclSerialPort_UpModuleTransmit
1565* @brief This function is to transmit data to COM Port in ior format.
1566* @param handle a valid handle return by DclSerialPort_Open()
1567* @param ior pointer to tx io request which is sent to COM Port driver
1568* @result STATUS_OK Transmit ior successfully.
1569* @result STATUS_INVALID_HANDLE It's a invalid handle.
1570* @result STATUS_FAIL Failed for other reasons.
1571*/
1572extern DCL_STATUS DclSerialPort_UpModuleTransmit(DCL_HANDLE handle, tty_io_request_t *ior);
1573
1574/*!
1575* @function [New TTY API] DclSerialPort_UpModuleTransmitLight
1576* @brief This function is to transmit data to COM Port in ior format and light-weight.
1577* Before user use this Tx function, it must calculate tx checksum and flush GPD in advance.
1578* @param handle a valid handle return by DclSerialPort_Open()
1579* @param ior pointer to tx io request which is sent to COM Port driver
1580* @result STATUS_OK Transmit ior successfully.
1581* @result STATUS_INVALID_HANDLE It's a invalid handle.
1582* @result STATUS_FAIL Failed for other reasons.
1583*/
1584extern DCL_STATUS DclSerialPort_UpModuleTransmitLight(DCL_HANDLE handle, tty_io_request_t *ior);
1585
1586/*!
1587* @function [New TTY API] DclSerialPort_UpModuleAssignRxIor
1588* @brief This function is to assign empty Rx ior to driver for data receiving.
1589* @param handle a valid handle return by DclSerialPort_Open()
1590* @param rx_ior pointer to rx io request for data receiving
1591* @result STATUS_OK Assign Rx ior successfully.
1592* @result STATUS_INVALID_HANDLE It's a invalid handle.
1593* @result STATUS_FAIL Failed for other reasons.
1594*/
1595extern DCL_STATUS DclSerialPort_UpModuleAssignRxIor(DCL_HANDLE handle, tty_io_request_t *rx_ior);
1596
1597/* ------------------------------------ Export to driver ------------------------------------------- */
1598/*!
1599* @function DclSerialPort_DrvRegisterCb
1600* @brief This function is to register callback funtion for the UART module or COM Port class driver.
1601* @param handle a valid handle return by DclSerialPort_Open()
1602* @param seriport_handler the structure contains callback function and device type.
1603 TTY would send commands (SIO/UART/USB/TTY/...) to driver through this callback function when the corresponding event happens.
1604* @result STATUS_OK successful.
1605* @result STATUS_INVALID_HANDLE It's a invalid handle.
1606* @result STATUS_ALREADY_OPENED This device has already been opened.
1607* @result STATUS_INVALID_ARGUMENT The parameter is invalid, ex. uart_handler_cb is NULL.
1608*/
1609extern DCL_STATUS DclSerialPort_DrvRegisterCb(DCL_HANDLE handle, Seriport_HANDLER_T* seriport_handler);
1610
1611/*!
1612* @function DclSerialPort_DrvDeRegisterCb
1613* @brief This function is to De-register callback funtion for the UART module or COM Port class driver.
1614* @param handle a valid handle return by DclSerialPort_Open()
1615*
1616* @result STATUS_OK successful.
1617* @result STATUS_INVALID_HANDLE It's a invalid handle.
1618* @result STATUS_INVALID_OPERATION This device has already been de-registered or driver state is attached.
1619*/
1620extern DCL_STATUS DclSerialPort_DrvDeRegisterCb(DCL_HANDLE handle);
1621
1622/*!
1623* @function [New TTY API] DclSerialPort_DrvAttach
1624* @brief This function is for driver to inform TTY that the device is attached/connected.
1625* @param handle a valid handle return by DclSerialPort_Open()
1626* @result STATUS_OK successful.
1627* @result STATUS_INVALID_HANDLE It's a invalid handle.
1628* @result STATUS_DEVICE_NOT_EXIST The corresponding device driver of COM Port has not been initialized.
1629*/
1630extern DCL_STATUS DclSerialPort_DrvAttach(DCL_HANDLE handle);
1631
1632/*!
1633* @function [New TTY API] DclSerialPort_DrvDetach
1634* @brief This function is for driver to inform TTY that the device is detached/disconnected.
1635* @param handle a valid handle return by DclSerialPort_Open()
1636* @result STATUS_OK successful.
1637* @result STATUS_INVALID_HANDLE It's a invalid handle.
1638* @result STATUS_DEVICE_NOT_EXIST The corresponding device driver of COM Port has not been initialized.
1639*/
1640extern DCL_STATUS DclSerialPort_DrvDetach(DCL_HANDLE handle);
1641
1642/*!
1643* @function [New TTY API] DclSerialPort_DrvRx
1644* @brief This function is for driver to send back the received data to TTY/upper layer.
1645* @param handle a valid handle return by DclSerialPort_Open()
1646* @param source_id driver module id
1647* @param rx_ior received data with ior format
1648* @result STATUS_OK successfully register the callback function.
1649* @result STATUS_INVALID_HANDLE It's a invalid handle.
1650* @result STATUS_NOT_OPENED The COM Port is not opened by upper layer.
1651*/
1652extern DCL_STATUS DclSerialPort_DrvRx(DCL_HANDLE handle, module_type source_id, void *rx_ior);
1653
1654/*!
1655* @function [New TTY API] DclSerialPort_DrvTxDone
1656* @brief This function is for driver to send back the transmitted (tx done) data to TTY/upper layer.
1657* This function is called if "need tx done callback" is configured YES.
1658* @param handle a valid handle return by DclSerialPort_Open()
1659* @param source_id driver module id
1660* @param tx_ior transmitted data with ior format
1661* @result STATUS_OK successful.
1662* @result STATUS_INVALID_HANDLE It's a invalid handle.
1663* @result STATUS_NOT_OPENED The COM Port is not opened by upper layer.
1664*/
1665extern DCL_STATUS DclSerialPort_DrvTxDone(DCL_HANDLE handle, module_type source_id, void *tx_ior);
1666
1667
1668#endif // #ifndef __DCL_UART_H_PROTOTYPE__
1669#endif // #ifdef DCL_DEFINITION_PROTOTYPE
1670