blob: a2c189dd71922d0fd89ff3e78bc480a492527810 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
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) 2012
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35
36/*******************************************************************************
37 * Filename:
38 * ---------
39 * hifusb_qmu.h
40 *
41 * Project:
42 * --------
43 * TATAKA
44 *
45 * Description:
46 * ------------
47 * This is the HIF data path driver API head file for both USB2.0/USB3.0
48 *
49 * Author:
50 * -------
51 * -------
52 *
53 ****************************************************************************/
54
55
56
57#ifndef __HIFUSB_QMU_H__
58#define __HIFUSB_QMU_H__
59
60#include "qmu_bm.h"
61//#include "kal_internal_api.h"
62#include "hif_common.h"
63
64
65/*!
66 * @brief ask hif driver to set GPD buffer into QMU
67 * @param q_type the queue type
68 * @param queue_no QMU queue no
69 * @param first_gpd first GPD of a single GPD or GPD list
70 * @param last_gpd last GPD of a single GPD or GPD list
71 * @return KAL_TRUE : set gpd success,
72 KAL_FALSE : set gpd fail and upper module should re-submit or free the queue list
73 */
74kal_bool hifusbq_set_gpd(hif_queue_type_e q_type, kal_uint8 queue_no, qbm_gpd* first_gpd, qbm_gpd* last_gpd);
75
76
77/*!
78 * @brief ask hif driver to flush all GPD buffer from QMU
79 * @param q_type the queue type
80 * @param queue_no QMU queue no
81 * @param flush type the flush type wished
82 * @param pp_head the head pointer of flush list
83 * @param pp_tail the tail pointer of flush list
84 * @return return total flushed gpd number
85 */
86kal_uint32 hifusbq_flush_gpd(hif_queue_type_e q_type, kal_uint8 queue_no, hif_flush_type_e flush_type , void **pp_head, void **pp_tail);
87
88
89/*!
90 * @brief poll specified QMU queue to see if any GPD complete
91 * deq_type == HIFQ_FREEQ, (use qbmt_free_q_hwo())
92 * would free the used queue after this function and return the deq number
93 * deq_type == HIF_DEQ,
94 * would just deq and return the deq list and the deq number
95 * use use qbmt_de_q() if generic buffer type
96 * use deqmt_deq_hif_ul_type1() if QBM_TYPE_HIF_UL_TYPE1
97 * use deqmt_deq_hif_ul_type2() if QBM_TYPE_HIF_UL_TYPE2
98 * @param deq_info the que number , que type and deq type
99 * @param first_gpd first GPD of a single GPD or GPD list
100 * @param last_gpd last GPD of a single GPD or GPD list
101 * @return return the deq number
102 */
103kal_uint32 hifusbq_poll_queue(hif_deq_info_t deq_info, void **first_gpd, void **last_gpd);
104
105/*!
106 * @brief initial hif_common.c private structure and variable
107 * @return return KAL_TRUE if success , KAL_FALSE if failure
108 */
109kal_bool hifusbq_common_qmu_init(void);
110
111/*!
112 * @brief get currently que list
113 * @param is_tx, KAL_TRUE for txq , KAL_FALSE for rxq
114 * @param q_no , the queue number form 0~n
115 * @param pp_head , return the currently queue head
116 * @param pp_tail , return the currently queue tail
117 */
118void hifusbq_get_que_list(kal_bool is_tx , kal_uint8 q_no, void **pp_head, void **pp_tail);
119
120/*!
121 * @brief configure specific queue operation option with bit-map config
122 * @param is_tx, KAL_TRUE for txq , KAL_FALSE for rxq
123 * @param q_no , the queue number form 0~n
124 * @param que_cfg , the bit-map configuration , ex. HIF_QCFG_BM_TX_EMPTY_ENQ
125 * @return KAL_TRUE if success, KAL_FALSE if configure not valid
126 */
127kal_bool hifusbq_set_que_cfg(kal_bool is_tx , kal_uint8 q_no, kal_uint16 que_cfg);
128
129/*!
130 * @brief upper layer use this light weight api to query if new ul packet valid
131 * @return return bit-mask of valid ul packet exist queue number
132 */
133kal_uint32 hifusbq_check_ul_newpkt(void);
134
135/*!
136 * @brief upper layer use this light weight api to query if new dl packet valid
137 * @return return bit-mask of valid dl packet exist queue number
138 */
139kal_uint32 hifusbq_check_dl_newpkt(void);
140
141/*!
142 * @brief ask hif driver to buffer gpd when USB related pwr or clock off (SUSPEND)
143 * @param q_type the queue type
144 * @param queue_no QMU queue no
145 * @param first_gpd first GPD of a single GPD or GPD list
146 * @param last_gpd last GPD of a single GPD or GPD list
147 * @return KAL_TRUE : set gpd success,
148 KAL_FALSE : set gpd fail and upper module should re-submit or free the queue list
149 */
150kal_bool hifusbq_pwrsave_buffer_gpd(hif_queue_type_e q_type, kal_uint8 queue_no, qbm_gpd* first_gpd, qbm_gpd* last_gpd);
151
152/*!
153 * @brief ask hif driver to configure gpd which bufferred when USB related pwr or clock off (SUSPEND) after resumed
154 * @param q_type the queue type
155 * @param queue_no QMU queue no
156 * @return KAL_TRUE : set gpd success,
157 KAL_FALSE : set gpd fail and upper module should re-submit or free the queue list
158 */
159kal_bool hifusbq_pwrsave_restore_gpd(hif_queue_type_e q_type, kal_uint8 queue_no);
160
161
162/*!
163 * @brief ask hif driver to flush all GPD bufferred when USB related pwr or clock off (SUSPEND)
164 * @param q_type the queue type
165 * @param queue_no QMU queue no
166 * @param flush type the flush type wished
167 * @param pp_head the head pointer of flush list
168 * @param pp_tail the tail pointer of flush list
169 * @return return total flushed gpd number
170 */
171kal_uint32 hifusbq_pwrsave_flush_gpd(hif_queue_type_e q_type, kal_uint8 queue_no, hif_flush_type_e flush_type , void **pp_head, void **pp_tail);
172
173/*!
174 * @brief ask hif driver to get UL/DL infotmation in init stage
175 */
176void hifusbq_get_ul_xit_base (kal_uint8 q_num , void **ul_xit_start_ptr, kal_uint32* ul_xit_count);
177void hifusbq_get_dl_drb_base (kal_uint8 q_num , void **dl_drb_start_ptr, kal_uint32* dl_drb_count, kal_uint32* dl_drb_reserv_count);
178
179/*!
180 * @brief ask hif driver to set DL fix header in init stage
181 */
182kal_bool hifusbq_set_dl_fh (kal_uint8 dl_fh_num, void *dl_fh_start_ptr, kal_uint8 dl_fh_size );
183
184/*!
185 * @brief poll specified 93 ring buffer to see if any xit/drb complete
186 */
187kal_uint32 hifusbq_poll_ul_xit (kal_uint8 q_num,kal_uint16 *ul_xit_first_idx,kal_uint16 *ul_xit_last_idx,kal_uint16 *ul_xit_last_release_idx );
188kal_uint32 hifusbq_poll_dl_drb ( kal_uint8 q_num , kal_uint32 *dl_drb_first_idx, kal_uint32 *dl_drb_last_idx );
189
190/*!
191 * @brief ask hif driver to flush all XIT/DRB buffer from USB driver
192 */
193kal_bool hifusbq_flush_ul_xit (kal_uint8 q_num, kal_uint32 *ul_xit_first_idx, kal_uint32 *ul_xit_last_idx, kal_uint32 *ul_xit_flush_count);
194kal_bool hifusbq_flush_dl_drb (kal_uint8 q_num , kal_uint32* dl_drb_first_idx, kal_uint32* dl_drb_last_idx, kal_uint32 *dl_drb_flush_count);
195
196/*!
197 * @brief ask hif driver to create/set DL DRB from USB driver
198 */
199kal_bool hifusbq_create_dl_drb ( kal_uint8 q_num , kal_uint32 *dl_drb_create_start_idx, kal_uint16 *dl_drb_create_count );
200kal_bool hifusbq_set_dl_drb (kal_uint8 q_num, kal_uint32 dl_drb_start_idx, kal_uint32 dl_drb_count);
201
202/*!
203 * @brief ask hif driver to release XIT buffer from USB driver
204 */
205kal_bool hifusbq_ul_xit_release(kal_uint8 q_num,kal_uint16 ul_xit_rel_end_idx,kal_uint16 ul_xit_count );
206
207/*!
208 * @brief Corppro call back function to release PRB buffer
209 */
210kal_bool hifusbq_ul_prb_release_func(void *ul_prb_release_start, kal_uint32 size);
211kal_bool hifusbq_ul_prb_release(void *ul_prb_release_start, void *ul_prb_release_end);
212
213/*!
214 * @brief USB driver release DL DRB in polling stage
215 */
216kal_bool hifusbq_release_dl_drb (kal_uint8 q_num , kal_uint32 dl_drb_rel_first_idx , kal_uint32 dl_drb_count );
217
218/*!
219 * @brief USB driver set header generator rule
220 */
221kal_bool hifusbq_set_header_rule (usb_header_rule_enum header_rule, usb_header_rule_data_t *rule_data);
222
223void hifusbq_init_ul_prb(kal_uint8 q_num);
224void hifusbq_init_dl_fh();
225void hifusbq_init_dl_drb(kal_uint8 q_num);
226kal_uint32 hifusbq_get_dlq_xfer_num(kal_uint8 q_num , kal_uint32 dl_drb_first_idx, kal_uint32 dl_drb_last_idx);
227
228void hifusbq_common_udq_init (void);
229kal_uint32* hifusbq_get_xit_start_address(kal_uint8 q_num);
230kal_uint32* hifusbq_get_drb_start_address(kal_uint8 q_num);
231kal_uint32* hifusbq_get_sw_drb_start_address(kal_uint8 q_num);
232kal_bool hifusbq_check_que_empty(kal_bool is_tx, kal_uint8 q_num);
233kal_bool hifusbq_ulq_block_slp(void);
234
235
236#endif