1#ifndef _FT1000_USB_H_
2#define _FT1000_USB_H_
3
4
5#include "../ft1000.h"
6#include "ft1000_ioctl.h"
7#define FT1000_DRV_VER 0x01010403
8
9#define MAX_NUM_APP 6
10#define MAX_MSG_LIMIT 200
11#define NUM_OF_FREE_BUFFERS 1500
12
13#define PSEUDOSZ 16
14
15#define SUCCESS 0x00
16
17struct app_info_block {
18 u32 nTxMsg;
19 u32 nRxMsg;
20 u32 nTxMsgReject;
21 u32 nRxMsgMiss;
22 struct fown_struct *fileobject;
23 u16 app_id;
24 int DspBCMsgFlag;
25 int NumOfMsg;
26 wait_queue_head_t wait_dpram_msg;
27 struct list_head app_sqlist;
28} __attribute__((packed));
29
30
31#define DEBUG(args...) printk(KERN_INFO args)
32
33#define FALSE 0
34#define TRUE 1
35
36#define STATUS_SUCCESS 0
37#define STATUS_FAILURE 0x1001
38
39#define FT1000_STATUS_CLOSING 0x01
40
41#define LARGE_TIMEOUT 5000
42
43#define DSPBCMSGID 0x10
44
45
46
47#undef FT1000_DPRAM_RX_BASE
48#define FT1000_DPRAM_RX_BASE 0x1800
49
50
51
52#undef FT1000_MAG_DSP_LED_INDX
53#define FT1000_MAG_DSP_LED_INDX 0x1
54#undef FT1000_MAG_DSP_CON_STATE_INDX
55#define FT1000_MAG_DSP_CON_STATE_INDX 0x0
56
57
58#define MAX_ASIC_RESET_CNT 20
59
60#define MAX_BUF_SIZE 4096
61
62struct ft1000_device
63{
64 struct usb_device *dev;
65 struct net_device *net;
66
67 u32 status;
68
69 struct urb *rx_urb;
70 struct urb *tx_urb;
71
72 u8 tx_buf[MAX_BUF_SIZE];
73 u8 rx_buf[MAX_BUF_SIZE];
74
75 u8 bulk_in_endpointAddr;
76 u8 bulk_out_endpointAddr;
77
78
79
80
81} __attribute__ ((packed));
82
83struct ft1000_debug_dirs {
84 struct list_head list;
85 struct dentry *dent;
86 struct dentry *file;
87 int int_number;
88};
89
90struct ft1000_info {
91 struct ft1000_device *pFt1000Dev;
92 struct net_device_stats stats;
93
94 struct task_struct *pPollThread;
95
96 unsigned char fcodeldr;
97 unsigned char bootmode;
98 unsigned char usbboot;
99 unsigned short dspalive;
100 u16 ASIC_ID;
101 bool fProvComplete;
102 bool fCondResetPend;
103 bool fAppMsgPend;
104 u16 DrvErrNum;
105 u16 AsicID;
106 int DspAsicReset;
107 int DeviceCreated;
108 int CardReady;
109 int NetDevRegDone;
110 u8 CardNumber;
111 u8 DeviceName[15];
112 struct ft1000_debug_dirs nodes;
113 int registered;
114 int mediastate;
115 u8 squeseqnum;
116 spinlock_t dpram_lock;
117 spinlock_t fifo_lock;
118 u16 fifo_cnt;
119 u8 DspVer[DSPVERSZ];
120 u8 HwSerNum[HWSERNUMSZ];
121 u8 Sku[SKUSZ];
122 u8 eui64[EUISZ];
123 time_t ConTm;
124 u8 ProductMode[MODESZ];
125 u8 RfCalVer[CALVERSZ];
126 u8 RfCalDate[CALDATESZ];
127 u16 DSP_TIME[4];
128 u16 LedStat;
129 u16 ConStat;
130 u16 ProgConStat;
131 struct list_head prov_list;
132 int appcnt;
133 struct app_info_block app_info[MAX_NUM_APP];
134 u16 DSPInfoBlklen;
135 u16 DrvMsgPend;
136 int (*ft1000_reset)(struct net_device *dev);
137 u16 DSPInfoBlk[MAX_DSP_SESS_REC];
138 union {
139 u16 Rec[MAX_DSP_SESS_REC];
140 u32 MagRec[MAX_DSP_SESS_REC/2];
141 } DSPSess;
142 unsigned short tempbuf[32];
143 char netdevname[IFNAMSIZ];
144 struct proc_dir_entry *ft1000_proc_dir;
145};
146
147
148struct dpram_blk {
149 struct list_head list;
150 u16 *pbuffer;
151} __attribute__ ((packed));
152
153int ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data, u16 nRegIndx);
154int ft1000_write_register(struct ft1000_device *ft1000dev, u16 value, u16 nRegIndx);
155int ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, u16 cnt);
156int ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, u16 cnt);
157int ft1000_read_dpram16(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, u8 highlow);
158int ft1000_write_dpram16(struct ft1000_device *ft1000dev, u16 indx, u16 value, u8 highlow);
159int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer);
160int fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer);
161
162extern void *pFileStart;
163extern size_t FileLength;
164extern int numofmsgbuf;
165
166int ft1000_close (struct net_device *dev);
167u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLength);
168
169extern struct list_head freercvpool;
170extern spinlock_t free_buff_lock;
171
172int ft1000_create_dev(struct ft1000_device *dev);
173void ft1000_destroy_dev(struct net_device *dev);
174extern void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer, int size);
175
176struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist);
177void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist);
178
179int dsp_reload(struct ft1000_device *ft1000dev);
180int init_ft1000_netdev(struct ft1000_device *ft1000dev);
181struct usb_interface;
182int reg_ft1000_netdev(struct ft1000_device *ft1000dev, struct usb_interface *intf);
183int ft1000_poll(void* dev_id);
184
185int ft1000_init_proc(struct net_device *dev);
186void ft1000_cleanup_proc(struct ft1000_info *info);
187
188
189
190#endif
191