blob: 224c957e292d0fa2aa11e2dc17e600ab5a1cbb98 [file] [log] [blame]
Holger Schurig10078322007-11-15 18:05:47 -05001#ifndef _LBS_IF_USB_H
2#define _LBS_IF_USB_H
Holger Schurig435a1ac2007-05-25 12:41:52 -04003
David Woodhouse4f82f5c2007-12-11 00:07:58 -05004#include <linux/wait.h>
5#include <linux/timer.h>
6
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02007/**
8 * This file contains definition for USB interface.
9 */
10#define CMD_TYPE_REQUEST 0xF00DFACE
11#define CMD_TYPE_DATA 0xBEADC0DE
12#define CMD_TYPE_INDICATION 0xBEEFFACE
13
14#define IPFIELD_ALIGN_OFFSET 2
15
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020016#define BOOT_CMD_FW_BY_USB 0x01
17#define BOOT_CMD_FW_IN_EEPROM 0x02
18#define BOOT_CMD_UPDATE_BOOT2 0x03
19#define BOOT_CMD_UPDATE_FW 0x04
20#define BOOT_CMD_MAGIC_NUMBER 0x4C56524D /* M=>0x4D,R=>0x52,V=>0x56,L=>0x4C */
21
22struct bootcmdstr
23{
David Woodhouse981f1872007-05-25 23:36:54 -040024 __le32 u32magicnumber;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020025 u8 u8cmd_tag;
26 u8 au8dumy[11];
27};
28
29#define BOOT_CMD_RESP_OK 0x0001
30#define BOOT_CMD_RESP_FAIL 0x0000
31
32struct bootcmdrespStr
33{
David Woodhouse981f1872007-05-25 23:36:54 -040034 __le32 u32magicnumber;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020035 u8 u8cmd_tag;
36 u8 u8result;
37 u8 au8dumy[2];
38};
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020039
40/* read callback private data */
41struct read_cb_info {
Dan Williams954ee162007-08-20 11:43:25 -040042 struct usb_card_rec *cardp;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020043 struct sk_buff *skb;
44};
45
46/** USB card description structure*/
47struct usb_card_rec {
48 struct net_device *eth_dev;
49 struct usb_device *udev;
50 struct urb *rx_urb, *tx_urb;
51 void *priv;
52 struct read_cb_info rinfo;
53
54 int bulk_in_size;
55 u8 bulk_in_endpointAddr;
56
57 u8 *bulk_out_buffer;
58 int bulk_out_size;
59 u8 bulk_out_endpointAddr;
60
Dan Williams954ee162007-08-20 11:43:25 -040061 const struct firmware *fw;
David Woodhouse4f82f5c2007-12-11 00:07:58 -050062 struct timer_list fw_timeout;
63 wait_queue_head_t fw_wq;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020064 u8 CRC_OK;
65 u32 fwseqnum;
66 u32 lastseqnum;
67 u32 totalbytes;
68 u32 fwlastblksent;
69 u8 fwdnldover;
70 u8 fwfinalblk;
Dan Williams954ee162007-08-20 11:43:25 -040071 u8 surprise_removed;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020072
73 u32 usb_event_cause;
74 u8 usb_int_cause;
75
76 u8 rx_urb_recall;
77
David Woodhouse6d35fdf2007-12-08 23:49:06 +000078 s8 bootcmdresp;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020079};
80
81/** fwheader */
82struct fwheader {
David Woodhouse981f1872007-05-25 23:36:54 -040083 __le32 dnldcmd;
84 __le32 baseaddr;
85 __le32 datalength;
86 __le32 CRC;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020087};
88
89#define FW_MAX_DATA_BLK_SIZE 600
90/** FWData */
91struct FWData {
92 struct fwheader fwheader;
David Woodhouse981f1872007-05-25 23:36:54 -040093 __le32 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020094 u8 data[FW_MAX_DATA_BLK_SIZE];
95};
96
97/** fwsyncheader */
98struct fwsyncheader {
David Woodhouse981f1872007-05-25 23:36:54 -040099 __le32 cmd;
100 __le32 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200101};
102
103#define FW_HAS_DATA_TO_RECV 0x00000001
104#define FW_HAS_LAST_BLOCK 0x00000004
105
106#define FW_DATA_XMIT_SIZE \
David Woodhousebb793e22007-05-25 23:38:14 -0400107 sizeof(struct fwheader) + le32_to_cpu(fwdata->fwheader.datalength) + sizeof(u32)
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200108
Holger Schurig435a1ac2007-05-25 12:41:52 -0400109#endif