MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / usb / net / Zydas / zd1211.h
blob4713cdf5f1095032b9aeb230709e46ac9e4730e5
1 #ifndef _ZD1211_H_
2 #define _ZD1211_H_
4 #include "zd1205.h"
7 #define MAX_NUM_PORTS 8 /* The maximum number of ports one device can grab at once */
9 #define IOWAITTIME 2
11 #define EP_DATA_OUT 0x01
12 #define EP_DATA_IN 0x02
13 #define EP_INT_IN 0x03
14 #define EP_REG_OUT 0x04
16 // EP0 [request, ID] setting.
17 #define REGID_WRITE 0x21
18 #define REGID_READ 0x22
19 #define REGID_RFOFDMSET 0x23
20 #define REGID_PROG_FLSH 0x24
21 #define EEPROM_START 0x128
22 #define EEPROM_MID 0x28
23 #define EEPROM_END 0x228
25 #define FIRMWARE_DOWNLOAD 0x30
26 #define FIRMWARE_CONFIRM 0x31
27 #define FIRMWARE_READ_DATA 0x32
29 #define EPINT_IORDRsp 0x90
30 #define EPINT_RetryFial_Event 0xa0
32 // for macp->flags
33 #define ZD1211_UNPLUG 1
34 #define ZD1211_REQ_COMP 2
35 #define ZD1211_RUNNING 3
36 #define ZD1211_TX_BUSY 4
37 #define ZD1211_CMD_FINISH 5
38 #define ZD1211_SCAN_REQUEST 6
39 #define ZD1211_SCAN_COMPLETE 7
40 #define CTX_FLAG_ESSID_WAS_SET 8
42 #define KEVENT_SCAN_TIMEOUT 1
43 #define KEVENT_MGT_MON_TIMEOUT 2
44 #define KEVENT_HOUSE_KEEPING 3
45 #define KEVENT_WATCH_DOG 4
46 #define KEVENT_AUTH_TIMEOUT 5
47 #define KEVENT_ASOC_TIMEOUT 6
48 #define KEVENT_TCHAL_TIMEOUT 7
49 #define KEVENT_NON_TX_RX_INT 8
50 #define KEVENT_ZD_IOCTL 9
51 #define KEVENT_EN_PROTECTION 10
52 #define KEVENT_DIS_PROTECTION 11
53 #define KEVENT_UPDATE_SETTING 12
54 #define KEVENT_SET_MULTICAST 13
55 #define KEVENT_PROCESS_SIGNAL 14
56 #define KEVENT_EN_BARKER 15
57 #define KEVENT_DIS_BARKER 16
58 #define KEVENT_EN_SHORT_SLOT 17
59 #define KEVENT_DIS_SHORT_SLOT 18
60 #define KEVENT_DIS_CONNECT 19
61 #define KEVENT_STD_IOCTL 20
62 #define KEVENT_REGISTER_NET 21
63 #define KEVENT_ZD_WPA_IOCTL 22
64 #define KEVENT_USB_KILL_TX_URB 23
65 #define KEVENT_FALL_IN_SLEEP 24
66 //prince add begin
67 #define KEVENT_DIS_UPDATE_SETTING 25
68 #define KEVENT_MOXA_REPEAT 26
69 //prince add end
72 #define mFILL_WRITE_REGISTER(addr0, value0) \
73 { \
74 WriteAddr[WriteIndex] = addr0; \
75 WriteData[WriteIndex ++] = value0; \
79 // write 32_bit register ==> write high word first
80 #define mFILL_WRITE_REGISTER32(addr0, value32) \
81 { \
82 WriteAddr[WriteIndex] = (addr0) + 2; \
83 WriteData[WriteIndex ++] = (u16) ((value32) >> 16); \
84 WriteAddr[WriteIndex] = addr0; \
85 WriteData[WriteIndex ++] = (u16) ((value32) & 0xFFFF); \
88 #define mFILL_READ_REGISTER(addr0) (ReadAddr[ReadIndex++] = addr0)
89 #define mFILL_RF_REGISTER(value0) (WriteData[WriteIndex++] = value0)
91 /* Flash interface */
92 #define bmFLASH_A0 1
94 #define mFLASH_SET_EVEN_ADDR(orgCR203) \
95 mFILL_WRITE_REGISTER(ZD1205_CR203 + (u16) (macp->USBCSRAddress), \
96 mCLR_BIT((u16) (orgCR203), bmFLASH_A0))
98 #define mFLASH_SET_ODD_ADDR(orgCR203) \
99 mFILL_WRITE_REGISTER(ZD1205_CR203 + (u16) (macp->USBCSRAddress), \
100 mSET_BIT((u16) (orgCR203), bmFLASH_A0))
102 #define mFLASH_WRITE_EVEN_ADDR(addr0, value0, orgCR203) \
104 mFLASH_SET_EVEN_ADDR(orgCR203); \
105 mFILL_WRITE_REGISTER(((addr0) >> 1), value0); \
108 #define mFLASH_WRITE_ODD_ADDR(addr0, value0, orgCR203) \
110 mFLASH_SET_ODD_ADDR(orgCR203); \
111 mFILL_WRITE_REGISTER(((addr0) >> 1), value0); \
115 //-------------------------------------------------------------------------
116 #if !fDRV_UPDATE_EEP
117 #define WRITE_WORD_TO_EEPROM_PER_TIME 8
119 #else
120 #define WRITE_WORD_TO_EEPROM_PER_TIME 16
121 #endif
124 typedef struct _USB_EEPROM_DATA {
125 u16 RequestID;
126 u16 Data[WRITE_WORD_TO_EEPROM_PER_TIME];
127 } USB_EEPROM_DATA, * PUSB_EEPROM_DATA;
130 typedef struct _USB_REG_PACKAGE {
131 u16 Address;
132 u16 Data;
133 } USB_REG_PACKAGE, *PUSB_REG_PACKAGE;
136 typedef struct _USB_READ_REG {
137 u16 RequestID;
138 USB_REG_PACKAGE Package[cMAX_MULTI_READ_REG_NUM] __attribute__ ((__packed__));
139 } USB_READ_REG, *PUSB_READ_REG;
143 typedef struct _USB_READ_REG_REQ {
144 u16 RequestID;
145 u16 Address[cMAX_MULTI_READ_REG_NUM];
146 } USB_READ_REG_REQ, *PUSB_READ_REG_REQ;
149 typedef struct _USB_WRITE_REG_PACKAGE {
150 u16 Address;
152 u16 WriteData_low;
153 } USB_WRITE_REG_PACKAGE, * PUSB_WRITE_REG_PACKAGE;
156 typedef struct _USB_WRITE_REG {
157 u16 RequestID;
158 USB_WRITE_REG_PACKAGE WritePackage[cMAX_MULTI_WRITE_REG_NUM] __attribute__ ((__packed__));
159 } USB_WRITE_REG, * PUSB_WRITE_REG;
162 typedef struct _USB_SET_RF {
163 u16 RequestID;
164 u16 Value;
165 u16 Index;
166 u16 Data[cMAX_MULTI_RF_REG_NUM];
167 } USB_SET_RF, * PUSB_SET_RF;
170 void zd1211_StrongSignalDect(struct zd1205_private *macp);
171 void zd1211_TxCalibration(struct zd1205_private *macp);
172 void zd1211_CheckWithIPC(struct zd1205_private *macp);
173 void zd1211_unlink_all_urbs(struct zd1205_private *macp);
174 u16 zd1211_SetHighAddr(struct zd1205_private *macp, u16 high_addr);
175 u16 zd1211_SetAbsAddr(struct zd1205_private *macp, u32 abs_addr, u16 *get_cr203);
176 void zd1211_InitHighAddr(struct zd1205_private *macp);
177 void zd1211_FlashCmdWrite(struct zd1205_private *macp, u8 Cmd);
178 void zd1211_FlashSecErase(struct zd1205_private *macp, u16 Sec0);
179 void zd1211_FlashProgram(struct zd1205_private *macp, u16 addr0, u16 val0);
180 void zd1211_EraseFlash(struct zd1205_private *macp);
181 int zd1211_ProgFlash(struct zd1205_private *macp, u32 StartAddr, u32 BufLenInBytes, u8 *pDownloadBuffer);
182 u8 zd1211_InitSetup(struct net_device *dev, struct zd1205_private *macp);
183 void zd1211_SwitchAntenna(struct zd1205_private *macp);
184 int zd1211_alloc_all_urbs(struct zd1205_private *macp);
185 void zd1211_free_all_urbs(struct zd1205_private *macp);
186 int zd1211_writel(u32 Address, u32 Value, u8 bAddUSBCSRAddress);
187 int zd1211_USB_PACKAGE_WRITE_REGISTER(u16 *Address, u16 *Value, u16 RegCount, u8 bAddUSBCSRAddress);
188 u32 zd1211_readl(u32 Address, u8 bAddUSBCSRAddress);
189 int zd1211_USB_PACKAGE_READ_REGISTER(u16 *Address, u16 *pValue, u16 RegCount, u8 bAddUSBCSRAddress);
190 void zd1211_handle_non_tx_rx(struct zd1205_private *macp);
191 void ZD1211_WRITE_MULTI_REG(u16 *pAddress, u16 *pValue, u16 *pRegCount);
192 int zd1211_USB_SET_RF_REG(u16 *InputValue, int bIs3683A);
193 int zd1211_submit_rx_urb(struct zd1205_private *macp);
194 int zd1211_submit_tx_urb(struct zd1205_private *macp,BOOLEAN LastFrag);
195 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
196 void zd1211_tx_comp_cb(struct urb *urb);
197 void zd1211_rx_comp_cb(struct urb *urb);
198 void zd1211_intr_cb(struct urb *urb);
199 void zd1211_reg_cb(struct urb *urb);
200 #else
201 void zd1211_tx_comp_cb(struct urb *urb, struct pt_regs *regs);
202 void zd1211_rx_comp_cb(struct urb *urb, struct pt_regs *regs);
203 void zd1211_intr_cb(struct urb *urb, struct pt_regs *regs);
204 void zd1211_reg_cb(struct urb *urb, struct pt_regs *regs);
205 #endif
206 void zd1211_disable_net_traffic(struct zd1205_private *macp);
207 int zd1211_USB_ProgramFlash(struct zd1205_private *macp, u16 *Value, u16 RegCount);
208 int zd1211_LoadUSBSpecCode(struct zd1205_private *macp, u8 *pBuffer, u32 uImgLength, u16 uCodeOfst, u8 bReboot);
209 int zd1211_Download_IncludeFile(struct zd1205_private *macp);
210 int zd1211_GetUSBSpecData(struct zd1205_private *macp, u8 *pBuffer, u32 uImgLength, u16 uCodeOfst);
211 int zd1211_DownLoadUSBCode(struct zd1205_private *macp, u8* FileName, void *ptr, u16 uCodeOfst);
212 int zd1211_WriteMultiRegister(u16 *Address, u16 *Value, u16 RegCount, u8 bAddUSBCSRAddress);
213 void kevent(void *data);
214 void defer_kevent(struct zd1205_private *macp, int flag);
215 void zd1211_rx_isr(unsigned long parm);
216 void zd1211_tx_isr(unsigned long parm);
217 void zd1211_alloc_rx(unsigned long parm);
219 #endif