Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / build / magpie_1_1 / sboot / hif / usb / src / usb_type.h
1 #ifndef USB_TYPE_H
2 #define USB_TYPE_H
3
4 #include "dt_defs.h"
5
6 /*********************** for Faraday USB controller *******************/
7 typedef enum
8 {
9     CMD_VOID,                   // No command
10     CMD_GET_DESCRIPTOR,         // Get_Descriptor command
11     CMD_SET_DESCRIPTOR          // Set_Descriptor command
12 } CommandType;
13
14 typedef enum
15 {
16     ACT_IDLE,
17     ACT_DONE,
18     ACT_STALL
19 } Action;
20
21 typedef struct Setup_Packet
22 {
23     uint8_t Direction;          /* Data transfer direction: IN, OUT */
24     uint8_t Type;               /* Request Type: Standard, Class, Vendor */
25     uint8_t Object;             /* Recipient: Device, Interface, Endpoint,other */
26     uint16_t Request;           /* Refer to Table 9-3 */
27     uint16_t Value;
28     uint16_t Index;
29     uint16_t Length;
30 } SetupPacket;
31
32 #define mBIT(b)                 (1 << (b))
33 #define mMASK(w)                (mBIT(w) - 1)
34
35 #define mWORD_IDX(bsize)        ((bsize) >> 1)
36 #define mWORD_SIZE(bsize)       (((bsize) + 1) >> 1)
37
38 #define mTABLE_WID              mWORD_SIZE
39 #define mTABLE_IDX              mWORD_IDX
40 #define mTABLE_LEN              mLOW_BYTE
41
42 #define mLOW_MASK(u16)          ((uint8_t) ((u16) & mMASK(8)))
43 #define mHIGH_MASK(u16)         ((uint8_t) ((u16) & ~mMASK(8)))
44 #define mLOW2HIGH(u16)          (((uint8_t) (u16)) << 8)
45
46 /* (1234) -> 0034 */
47 //#define mLOW_BYTE(u16)          ((U_8)(u16))
48 #define mLOW_BYTE(u16)          mLOW_MASK(u16)
49 /* (1234) -> 0012 */
50 #define mHIGH_BYTE(u16)         ((uint8_t) (((uint16_t) (u16)) >> 8))
51
52 #define mGET_REG1(var0, reg0)       { var0 = reg0; }
53
54 /* (1234, 5678) -> 7834 */
55 #define m2BYTE(ch1L, ch2H)      (mLOW_MASK(ch1L) | mLOW2HIGH(ch2H))
56
57 #define mREAD_WORD(var0, reg0, reg1)    \
58     { var0 = reg0; var0 += mLOW2HIGH(reg1); }
59
60 #endif