blob: 329b9eb8ed837e5b0a352d4edd70de1102e3d4f9 [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) 2005
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 *
38 * Filename:
39 * ---------
40 * usb.h
41 *
42 * Project:
43 * --------
44 * Maui_Software
45 *
46 * Description:
47 * ------------
48 * This file intends for usb1.1 definitions.
49 *
50 * Author:
51 * -------
52 * -------
53 * -------
54 *
55 *============================================================================
56 * HISTORY
57 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
58 *------------------------------------------------------------------------------
59 * removed!
60 * removed!
61 * removed!
62 * removed!
63 * removed!
64 * removed!
65 * removed!
66 * removed!
67 * removed!
68 * removed!
69 * removed!
70 * removed!
71 * removed!
72 * removed!
73 * removed!
74 * removed!
75 * removed!
76 * removed!
77 * removed!
78 *
79 * removed!
80 * removed!
81 * removed!
82 *
83 * removed!
84 * removed!
85 * removed!
86 *
87 * removed!
88 * removed!
89 * removed!
90 *
91 * removed!
92 * removed!
93 * removed!
94 *
95 * removed!
96 * removed!
97 * removed!
98 *
99 * removed!
100 * removed!
101 * removed!
102 *
103 * removed!
104 * removed!
105 * removed!
106 *
107 * removed!
108 * removed!
109 * removed!
110 *
111 * removed!
112 * removed!
113 * removed!
114 *
115 * removed!
116 * removed!
117 * removed!
118 *
119 * removed!
120 * removed!
121 * removed!
122 *
123 * removed!
124 * removed!
125 * removed!
126 *
127 * removed!
128 * removed!
129 * removed!
130 *
131 * removed!
132 * removed!
133 * removed!
134 *
135 * removed!
136 * removed!
137 * removed!
138 *
139 * removed!
140 * removed!
141 * removed!
142 *
143 * removed!
144 * removed!
145 * removed!
146 *
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 * removed!
182 *
183 * removed!
184 * removed!
185 * removed!
186 *
187 * removed!
188 * removed!
189 * removed!
190 *
191 * removed!
192 * removed!
193 * removed!
194 *
195 * removed!
196 * removed!
197 * removed!
198 *
199 * removed!
200 * removed!
201 * removed!
202 *
203 * removed!
204 * removed!
205 * removed!
206 *
207 * removed!
208 * removed!
209 * removed!
210 *
211 * removed!
212 * removed!
213 * removed!
214 *
215 * removed!
216 * removed!
217 * removed!
218 *
219 * removed!
220 * removed!
221 * removed!
222 *
223 * removed!
224 * removed!
225 * removed!
226 *
227 * removed!
228 * removed!
229 * removed!
230 *
231 * removed!
232 * removed!
233 * removed!
234 *
235 * removed!
236 * removed!
237 * removed!
238 *
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 * removed!
323 * removed!
324 * removed!
325 * removed!
326 * removed!
327 * removed!
328 * removed!
329 * removed!
330 * removed!
331 * removed!
332 * removed!
333 * removed!
334 * removed!
335 * removed!
336 * removed!
337 * removed!
338 * removed!
339 * removed!
340 * removed!
341 * removed!
342 * removed!
343 * removed!
344 * removed!
345 * removed!
346 * removed!
347 * removed!
348 * removed!
349 * removed!
350 * removed!
351 * removed!
352 * removed!
353 * removed!
354 * removed!
355 * removed!
356 *------------------------------------------------------------------------------
357 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
358 *============================================================================
359 ****************************************************************************/
360
361#ifndef USB_H
362#define USB_H
363
364
365#include "usb_custom.h"
366#include "usb_custom_def.h"
367//#include "usb_drv.h"
368#include "dcl.h"
369#include "usb_comm.h"
370#include "kal_general_types.h"
371
372
373/* Remove dependence.
374 * It should be releated to MMI behavior. Thus, add it on makefile if request is incoming.
375 */
376//#ifdef __TC01__
377//#define __USB_BOOT_NOT_CHECK_NVRAM_SETTING__
378//#endif
379
380/***********************************************
381 standard command definition
382************************************************/
383
384/* Standard Request Codes */
385#define USB_GET_STATUS 0x00
386#define USB_CLEAR_FEATURE 0x01
387#define USB_SET_FEATURE 0x03
388#define USB_SET_ADDRESS 0x05
389#define USB_GET_DESCRIPTOR 0x06
390#define USB_SET_DESCRIPTOR 0x07
391#define USB_GET_CONFIGURATION 0x08
392#define USB_SET_CONFIGURATION 0x09
393#define USB_GET_INTERFACE 0x0A
394#define USB_SET_INTERFACE 0x0B
395#define USB_SYNCH_FRAME 0x0C
396
397/* Vendor Request Codes */
398#define USB_GET_MS_DESCRIPTOR 0xCC
399
400/* Command bit fields */
401#define USB_CMD_DATADIR 0x80
402
403/* Request Type Field */
404#define USB_CMD_TYPEMASK 0x60
405#define USB_CMD_STDREQ 0x00
406#define USB_CMD_CLASSREQ 0x20
407#define USB_CMD_VENDREQ 0x40
408#define USB_CMD_STDDEVIN 0x80
409#define USB_CMD_STDDEVOUT 0x00
410#define USB_CMD_STDIFIN 0x81
411#define USB_CMD_STDIFOUT 0x01
412#define USB_CMD_STDEPIN 0x82
413#define USB_CMD_STDEPOUT 0x02
414#define USB_CMD_CLASSIFIN 0xA1
415#define USB_CMD_CLASSIFOUT 0x21
416#define USB_CMD_VENDDEVIN 0xC0
417#define USB_CMD_VENDDEVOUT 0x40
418
419
420/* Standard command descriptor type*/
421#define USB_DEVICE 0x01
422#define USB_CONFIG 0x02
423#define USB_STRING 0x03
424#define USB_INTERFACE 0x04
425#define USB_ENDPOINT 0x05
426#define USB_DEVICE_QUALIFIER 0x06
427#define USB_OTHER_SPEED 0x07
428#define USB_INTERFACE_POWER 0x08
429#define USB_OTG_DESC 0x09
430#define USB_INTERFACE_ASSOCIATION 0x0B
431
432#define USB_CMD_DESCMASK 0xFF00
433#define USB_CMD_DEVICE (USB_DEVICE<<8)
434#define USB_CMD_CONFIG (USB_CONFIG<<8)
435#define USB_CMD_STRING (USB_STRING<<8)
436#define USB_CMD_INTERFACE (USB_INTERFACE<<8)
437#define USB_CMD_ENDPOINT (USB_ENDPOINT<<8)
438#define USB_CMD_DEVICE_QUALIFIER (USB_DEVICE_QUALIFIER<<8)
439#define USB_CMD_OTHER_SPEED (USB_OTHER_SPEED<<8)
440#define USB_CMD_INTERFACE_POWER (USB_INTERFACE_POWER<<8)
441
442/* Standard Device Feature Selectors */
443#define USB_FTR_DEVREMWAKE 0x0001
444#define USB_FTR_EPHALT 0x0000
445#define USB_FTR_B_HNP_ENB 0x0003
446#define USB_FTR_A_HNP_SUPPORT 0x0004
447#define USB_FTR_A_ALT_HNP_SUPPORT 0x0005
448#define USB_FTR_TEST_MODE 0x0002
449
450/* Vendor OS feature descriptor, feature index */
451#define USB_FTR_GENRE 0x0001
452#define USB_FTR_EXT_COMPAT_ID 0x0004
453#define USB_FTR_EXT_PROPERTIES 0x0005
454
455
456/* USB test mode */
457#define USB_TEST_J 0x01
458#define USB_TEST_K 0x02
459#define USB_TEST_SE0_NAK 0x03
460#define USB_TEST_PACKET 0x04
461
462/***********************************************
463 standard descriptor definition
464************************************************/
465/* Scriptor length */
466#define USB_DEVDSC_LENGTH 18
467#define USB_CFGDSC_LENGTH 9
468#define USB_IFDSC_LENGTH 9
469#define USB_MAX_IFDSC_LENGTH 258 /* this will change depend on different class interface */
470 /*descriptor requirment*/
471 /* 258 is for video streaming class interface */
472#define USB_EPDSC_LENGTH 7
473#define USB_OTGDSC_LENGTH 3
474#define USB_MAX_CLASS_EPDESC_LENGTH 12 /* this will change depend on different class interface */
475 /*descriptor requirment*/
476 /* 12 is for video control interrupt ep */
477#define USB_IAD_LENGTH 8
478#define USB_DEV_QUA_DSC_LENGTH 10
479#define USB_OTHER_CFGDSC_LENGTH 9
480#define USB_MAX_OS_STRING_LENGTH 18
481#define USB_MAX_OS_FEATURE_DESC_LENGTH 40
482
483
484/* Endpoint direction */
485#define USB_EP_DIR 0x80
486#define USB_EP_DIR_IN 0x80
487#define USB_EP_DIR_OUT 0x00
488
489/* Endpoint transfer types */
490#define USB_EP_TFMASK 0x03
491#define USB_EP_CONTROL 0x00
492#define USB_EP_ISO 0x01
493#define USB_EP_BULK 0x02
494#define USB_EP_INTR 0x03
495
496/* ISO Synchronization types */
497#define USB_ISO_NO_SYNCHRONIZATION 0x00
498#define USB_ISO_ASYNCHRONOUS 0x01
499#define USB_ISO_ADAPTIVE 0x02
500#define USB_ISO_SYNCHRONOUS 0x03
501
502/* ISO Usage types */
503#define USB_ISO_DATA 0x00
504#define USB_ISO_FEEDBACK 0x01
505#define USB_ISO_IMPLICIT_FEEDBACK 0x02
506
507/*****Descriptor Element*****/
508/* Define values for Standard Device Descriptor */
509/* For Device descriptor */
510
511/* bcdDevice value */
512#define USB_DEVDSC_BCDDEVICE_PHONE 0x0100 /* Release number of USB device */
513#define USB_DEVDSC_BCDDEVICE_MODEM_CARD 0x0200 /* Release number of USB modem card device for ECMT */
514#define USB_DEVDSC_BCDDEVICE_MODEM_CARD_FOR_NDIS 0x0300 /* Release number of USB modem card device for NDIS*/
515
516/* Device class code for composite device */
517#define USB_COMPOSITE_DEVICE_CODE 0xEF
518#define USB_COMPOSITE_SUBCLASS_CODE 0x02
519#define USB_COMPOSITE_PROTOCOL_CODE 0x01
520
521/* Device class code for without IAD composite device */
522#define USB_COMPOSITE_NO_IAD_DEVICE_CODE 0x00
523#define USB_COMPOSITE_NO_IAD_SUBCLASS_CODE 0x00
524#define USB_COMPOSITE_NO_IAD_PROTOCOL_CODE 0x00
525
526
527#define USB_DEVDSC_CONFIGS USB_MAX_CONFIG // USB_DEVDSC_CONFIGS --> USB_GetChargeCurrentTableSize()
528
529
530/*For Configuration descriptor*/
531#define USB_CFGDSC_ATTR_NATURE 0x80
532#define USB_CFGDSC_ATTR_SELFPOWER 0x40
533#define USB_CFGDSC_ATTR_REMOTEWAKEUP 0x20
534#define USB_CFGDSC_MAXPOWER (500/2)
535
536#define USB_OTG_HNP_SUPPORT 0x02
537#define USB_OTG_SRP_SUPPORT 0x01
538
539
540/***********************************************
541 Hub class code definition
542************************************************/
543#define USB_HUB_DEVICE_CLASS_CODE 0x09
544#define USB_HUB_DEVICE_SUBCLASS_CODE 0x00
545//#define USB_HUB_DEVICE_PROTOCOL_CODE 0x00
546#define USB_HUB_INTERFACE_CLASS_CODE 0x09
547#define USB_HUB_INTERFACE_SUBCLASS_CODE 0x00
548//#define USB_HUB_INTERFACE_PROTOCOL_CODE 0x00
549
550
551/***********************************************
552 Implement definition
553************************************************/
554
555/* Define configuration, interface, ep number */
556#define USB_MAX_CONFIG 6 /* configuration number */
557#define USB_MAX_IAD 1
558
559#define USB_MAX_INTERFACE 2 /* interface number */
560
561#define USB_MAX_INTERFACE_ALTERNATE_NUM 1 /* interface alternate seting number */
562
563#if defined(__USB_EP_TEST__)
564#define USB_MAX_EP_BULK_TX 4 /* max bulk in ep number */
565#define USB_MAX_EP_BULK_RX 3 /* max bulk in ep number */
566#define USB_MAX_EP_ISO_TX 4 /* max interrupt ep number */
567#define USB_MAX_EP_INTR_TX 4 /* max interrupt ep number */
568#else
569#define USB_MAX_EP_BULK_TX 1 /* max bulk in ep number */
570#define USB_MAX_EP_BULK_RX 1 /* max bulk in ep number */
571#define USB_MAX_EP_INTR_TX 1 /* max interrupt ep number */
572#define USB_MAX_EP_ISO_TX 1 /* max interrupt ep number */
573#endif
574
575#define USB_MAX_STRING 12 /* string number */
576
577#define USB_MAX_EP_PER_IF 3 /* 3 is for image class */
578
579/* serial string array size for that unique Serial number*/
580#define USB_SERIAL_STRING_LEN 16
581
582/* define endpoint data parameters */
583#define USB_EP_NODATA -1 /* no more data for endpoint to send */
584
585
586/***********************************************
587 standard command structure
588************************************************/
589
590/* usb standard command structure */
591typedef struct
592{
593 kal_uint8 bmRequestType;
594 kal_uint8 bRequest;
595 kal_uint16 wValue;
596 kal_uint16 wIndex;
597 kal_uint16 wLength;
598}Usb_Command;
599
600
601
602/***********************************************
603 Standard descriptor structure
604************************************************/
605
606/* standard device descriptor */
607typedef struct
608{
609 kal_uint8 bLength;
610 kal_uint8 bDescriptorType;
611 kal_uint16 bcdUSB;
612 kal_uint8 bDeviceClass;
613 kal_uint8 bDeviceSubClass;
614 kal_uint8 bDeviceProtocol;
615 kal_uint8 bMaxPacketSize0;
616 kal_uint16 idVendor;
617 kal_uint16 idProduct;
618 kal_uint16 bcdDevice;
619 kal_uint8 iManufacturer;
620 kal_uint8 iProduct;
621 kal_uint8 iSerialNumber;
622 kal_uint8 bNumConfigurations;
623}Usb_Dev_Dscr;
624
625
626/* standard configuration descriptor */
627typedef struct
628{
629 kal_uint8 bLength;
630 kal_uint8 bDescriptorType;
631 kal_uint16 wTotalLength;
632 kal_uint8 bNumInterfaces;
633 kal_uint8 bConfigurationValue;
634 kal_uint8 iConfiguration;
635 kal_uint8 bmAttributes;
636 kal_uint8 bMaxPower;
637}Usb_Cfg_Dscr;
638
639
640/* standard IAD descriptor */
641typedef struct
642{
643 kal_uint8 bLength;
644 kal_uint8 bDescriptorType;
645 kal_uint8 bFirstInterface;
646 kal_uint8 bInterfaceCount;
647 kal_uint8 bFunctionClass;
648 kal_uint8 bFunctionSubClass;
649 kal_uint8 bFunctionProtocol;
650 kal_uint8 iFunction;
651}Usb_IAD_Dscr;
652
653
654/* standard interface descriptor */
655typedef struct
656{
657 kal_uint8 bLength;
658 kal_uint8 bDescriptorType;
659 kal_uint8 bInterfaceNumber;
660 kal_uint8 bAlternateSetting;
661 kal_uint8 bNumEndpoints;
662 kal_uint8 bInterfaceClass;
663 kal_uint8 bInterfaceSubClass;
664 kal_uint8 bInterfaceProtocol;
665 kal_uint8 iInterface;
666}Usb_If_Dscr;
667
668
669/* standard endpoint descriptor */
670typedef struct
671{
672 kal_uint8 bLength;
673 kal_uint8 bDescriptorType;
674 kal_uint8 bEndpointAddress;
675 kal_uint8 bmAttributes;
676 kal_uint8 wMaxPacketSize[2];
677 kal_uint8 bInterval;
678}Usb_Ep_Dscr;
679
680
681/* standard string descriptor */
682typedef struct
683{
684 kal_uint8 bLength;
685 kal_uint8 bDescriptorType;
686 kal_uint16 wData[1];
687}Usb_String_Dscr;
688
689
690/* standard string descriptor */
691typedef struct
692{
693 kal_uint8 bLength;
694 kal_uint8 bDescriptorType;
695 kal_uint8 bAttribute;
696}Usb_Otg_Dscr;
697
698
699typedef struct
700{
701 kal_uint8 bLength;
702 kal_uint8 bDescriptorType;
703 kal_uint16 bcdUSB;
704 kal_uint8 bDeviceClass;
705 kal_uint8 bDeviceSubClass;
706 kal_uint8 bDeviceProtocol;
707 kal_uint8 bMaxPacketSize0;
708 kal_uint8 bNumConfigurations;
709 kal_uint8 bReserved;
710}Usb_Dev_Qual_Dscr;
711
712
713typedef struct
714{
715 kal_uint8 bLength;
716 kal_uint8 bDescriptorType;
717 kal_uint16 wTotalLength;
718 kal_uint8 bNumInterfaces;
719 kal_uint8 bConfigurationValue;
720 kal_uint8 iConfiguration;
721 kal_uint8 bmAttributes;
722 kal_uint8 MaxPower;
723}Usb_Other_Speed_Cfg_Dscr;
724
725
726typedef struct
727{
728 kal_uint8 bLength;
729 kal_uint8 bDescriptorType;
730 kal_uint8 qwSignature[14];
731 kal_uint8 bMS_VendorCode;
732 kal_uint8 bPad;
733}Usb_OS_String_Dscr;
734
735
736typedef struct
737{
738 kal_uint32 dwLength;
739 kal_uint16 bcdVersion;
740 kal_uint16 wIndex;
741 kal_uint8 bCount;
742 kal_uint8 bPads_1[7];
743 kal_uint8 bFirstInterfaceNumber;
744 kal_uint8 bPads_2;
745 kal_uint8 compatibleID[8];
746 kal_uint8 subcompatibleID[8];
747 kal_uint8 bPads_3[6];
748}Usb_Ext_Compat_ID_OS_Feature_Dscr;
749
750
751/***********************************************
752 implement enum and structure
753************************************************/
754
755/* device states */
756typedef enum
757{
758 DEVSTATE_DEFAULT = 0,
759 DEVSTATE_SET_ADDRESS,
760 DEVSTATE_ADDRESS,
761 DEVSTATE_CONFIG
762}USB_DEVICE_STATE;
763
764
765/* Endpoint 0 state */
766typedef enum
767{
768 USB_EP0_IDLE=0,
769 USB_EP0_RX,
770 USB_EP0_TX,
771 USB_EP0_RX_STATUS
772}USB_EP0_STATE;
773
774
775/* EP0 status */
776typedef struct
777{
778 kal_int32 nBytesLeft; /* number of bytes left to send in TX mode */
779 void *pData; /* pointer to data to transmit/receive */
780 kal_int32 nBytesRecv; /* number of bytes received in RX mode */
781 kal_uint8 byFAddr; /* new function address */
782 kal_bool no_ZLP; /* No need ZLP when wLength == transfer size */
783}Usb_Ep0_Status;
784
785
786/* Bulk IN endpoint status */
787typedef struct
788{
789 void *pData; /* pointer to data buffer */
790 kal_int32 nBytesLeft; /* number of bytes left to send */
791 kal_uint8 byEP; /* endpoint number */
792}Usb_EpBIn_Status;
793
794
795/* Bulk OUT endpoint status */
796typedef struct
797{
798 void *pData; /* pointer to data buffer */
799 kal_int32 nBuffLen; /* length of data buffer */
800 kal_int32 nBytesRecv; /* number of bytes received */
801 kal_uint8 byEP; /* endpoint number */
802}Usb_EpBOut_Status;
803
804
805typedef enum
806{
807 USB_NORMAL_BOOT = 0,
808 USB_BOOT_ONE_PORT,
809 USB_BOOT_TWO_PORT,
810 USB_BOOT_THREE_PORT,
811 USB_BOOT_FOUR_PORT,
812 USB_BOOT_FIVE_PORT
813// USB_RNDIS_ONE_PORT
814}USB_Comport_Boot_Status;
815
816typedef enum
817{
818 USB_COMPORT_WIN = 0,
819 USB_COMPORT_WIN_SINGLE_INTERFACE,
820 USB_COMPORT_MAC,
821 USB_COMPORT_LINUX,
822 USB_COMPORT_MBIM,
823}USB_Comport_OS_Driver_Status;
824
825typedef enum
826{
827 USB_MASK_OWNER_COM_1 = 0,
828 USB_MASK_OWNER_COM_2,
829 USB_MASK_OWNER_COM_3,
830 USB_MASK_OWNER_COM_4,
831 USB_MASK_OWNER_COM_5,
832 USB_MASK_OWNER_MS = 10,
833 USB_MASK_OWNER_ALL,
834 USB_MASK_OWNER_MAX
835}USB_MASK_OWNER;
836
837
838/* interface create function pointer */
839typedef void (*usb_create_if_func_ptr)(void *);
840/* interface speed reset function pointer */
841typedef void (* usb_speed_if_func_ptr)(kal_bool bset);
842/* EP0 rx interrupt handler */
843typedef void (*usb_ep0_rx_ptr)(void *);
844/* class specific command interrupt handler */
845typedef void (*usb_class_specific_handler_ptr)(Usb_Ep0_Status *, Usb_Command*);
846/* endpoint interrupt handler */
847typedef void (*usb_ep_handler_ptr)(void);
848/* EP0 command interrupt handler */
849typedef void (*usb_ep0_cmd_ptr)(Usb_Command *pcmd);
850
851typedef void (*usb_void_func)(void);
852
853/* endpoint information, including endpoint status */
854typedef struct
855{
856 union
857 {
858 Usb_Ep_Dscr stdep; /* ep descriptor */
859 kal_uint8 classep[USB_MAX_CLASS_EPDESC_LENGTH];
860 }epdesc;
861
862 union
863 {
864 Usb_EpBIn_Status epin_status;
865 Usb_EpBOut_Status epout_status;
866 }ep_status; /* ep status */
867
868 usb_ep_handler_ptr ep_reset; /* ep reset handler */
869 kal_uint16 epdscr_size; /* descriptor length */
870}Usb_Ep_Info;
871
872
873typedef struct
874{
875 Usb_Ep_Info *ep_info[USB_MAX_EP_PER_IF];/* endpoint attach to the interface info */
876 kal_uint16 ifdscr_size; /* descriptor length */
877 Usb_If_Dscr stdif;
878}Usb_Alternate_Interface_Info;
879
880
881/* interface information, including endpoint information and interface information*/
882typedef struct
883{
884 kal_char *interface_name_ptr; /* interface name */
885 usb_class_specific_handler_ptr if_class_specific_hdlr; /* interface specific handler, handle ep0 class specific request */
886 kal_uint16 ifdscr_size; /* descriptor length */
887 union
888 {
889 Usb_If_Dscr stdif;
890 kal_uint8 classif[USB_MAX_IFDSC_LENGTH];
891 }ifdscr;
892
893 Usb_Ep_Info *ep_info[USB_MAX_EP_PER_IF];/* endpoint attach to the interface info */
894
895#if defined(__USB_SUPPORT_ISO_PIPE__)
896 Usb_Alternate_Interface_Info alternate_if_info[USB_MAX_INTERFACE_ALTERNATE_NUM];
897 kal_uint8 alternate_setting; /* alternate setting number */
898#endif
899
900}Usb_Interface_Info;
901
902
903/* configuration information */
904typedef struct
905{
906 Usb_Cfg_Dscr stdcfg; /* config descriptor */
907}Usb_Config_Info;
908
909
910typedef struct
911{
912 kal_bool b_enable;
913 kal_uint8 cmd;
914 usb_ep0_cmd_ptr ep0_cmd_hdlr;
915}Usb_EP0_Cmd_Hdler;
916
917/* device information, used for usb level */
918typedef struct
919{
920 USB_DEVICE_TYPE device_type;
921 USB_DEVICE_STATE nDevState; /*DEVSTATE_CONFIG,DEVSTATE_ADDRESS,DEVSTATE_DEFAULT*/
922 kal_bool remoteWk;
923#if defined(__DUAL_TALK_MODEM_SUPPORT__)
924 kal_bool isRemoteWking;
925#endif
926
927 kal_uint32 memory_addr;// allocate memory buffer address
928 kal_uint32 reserved_memory_size;//memory left size
929
930 kal_bool self_powered;
931 kal_bool ep0_send_one_pkt; /* the variable to record ep0 will send only one packet */
932 kal_bool usb_send_config_result; /* to send configure may be fail */
933
934 kal_uint8 config_num;
935 kal_uint8 interface_num[USB_MAX_INTERFACE];
936 USB_EP0_STATE ep0_state;
937
938
939 /* Add for multi-configurations*/
940 PMU_CTRL_CHR_GET_CHR_CURRENT_LIST get_chr_current_list;
941 kal_uint8 multi_Max_Power[USB_MAX_CONFIG];
942 kal_uint8 current_table_index;
943
944
945 /* used for resource management*/
946// optimize code size : cannot change order
947 kal_uint8 resource_ep_bulk_tx_number;
948 kal_uint8 resource_ep_bulk_rx_number;
949 kal_uint8 resource_ep_intr_tx_number;
950 kal_uint8 resource_interface_number;
951 kal_uint8 resource_string_number;
952#ifdef __USB_SUPPORT_ISO_PIPE__
953 kal_uint8 resource_ep_iso_tx_number;
954#endif
955#if defined(__USB_SUPPORT_ISO_PIPE__)
956 kal_uint8 resource_interface_alternate_number[USB_MAX_INTERFACE];
957#endif
958 kal_uint8 resource_iad_number;
959// resource_iad_number : must be the end of resource parameter
960
961
962
963 /* the configuration only one for saving memory */
964// optimize code size : cannot change order
965 Usb_Dev_Dscr devdscr;
966 Usb_Cfg_Dscr cfgdscr;
967 Usb_Ep_Info ep_bulk_tx_info[USB_MAX_EP_BULK_TX];
968 Usb_Ep_Info ep_bulk_rx_info[USB_MAX_EP_BULK_RX];
969 Usb_Ep_Info ep_intr_tx_info[USB_MAX_EP_INTR_TX];
970 Usb_Interface_Info if_info[USB_MAX_INTERFACE];
971#ifdef __USB_SUPPORT_ISO_PIPE__
972 Usb_Ep_Info ep_iso_tx_info[USB_MAX_EP_ISO_TX];
973#endif
974 Usb_String_Dscr *resource_string[USB_MAX_STRING];
975 Usb_IAD_Dscr iad_desc[USB_MAX_IAD];
976#ifdef __OTG_ENABLE__
977 Usb_Otg_Dscr otgdscr;
978#endif
979#ifdef __USB_IMAGE_CLASS__
980 Usb_OS_String_Dscr os_string_desc;
981 Usb_Ext_Compat_ID_OS_Feature_Dscr os_feature_desc;
982#endif
983
984 kal_uint8 *conf; /*just for descriptor transfer*/
985// conf : : must be the end of descriptor parameter
986
987 Usb_Command cmd; /*USB_COMMAND*/
988
989 Usb_Ep0_Status ep0info;
990 usb_ep0_rx_ptr ep0_rx_handler;
991 Usb_EP0_Cmd_Hdler ep0_class_cmd_handler; /* class specific ep0 cmd */
992
993 /* serial string unique for each phone*/
994 kal_uint16 serial_string[USB_SERIAL_STRING_LEN];
995
996 /* customizable variables*/
997 const USB_DEVICE_PARAM *device_param;
998} Usb_Device;
999
1000
1001/***********************************************
1002 function and global variable
1003************************************************/
1004extern Usb_Device gUsbDevice;
1005
1006void USB_EP0_Command_Hdlr(kal_bool bError);
1007
1008
1009#ifdef __RTL_SIMULATION_FOR_60QBIT__
1010extern void usb_irq_disable_duration_test2(void);
1011#endif
1012
1013extern void USB_Send_Msg_Ext_Queue(module_type dstid,msg_type msg_id,void *data);
1014
1015extern kal_uint32 USB_Get_Memory (kal_uint32 len);
1016extern void USB_Free_Memory(void);
1017
1018#endif /* USB_H */
1019