blob: e4829a391eb9be7ed39688eb1cc5e04eadd14168 [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
David Woodhouse6bc822b2007-12-11 12:53:43 -05007struct lbs_private;
8
Marcelo Tosatti876c9d32007-02-10 12:25:27 -02009/**
10 * This file contains definition for USB interface.
11 */
David Woodhouseeae86bf2007-12-14 00:47:05 -050012#define CMD_TYPE_REQUEST 0xF00DFACE
13#define CMD_TYPE_DATA 0xBEADC0DE
14#define CMD_TYPE_INDICATION 0xBEEFFACE
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020015
David Woodhouseeae86bf2007-12-14 00:47:05 -050016#define IPFIELD_ALIGN_OFFSET 2
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020017
David Woodhouseeae86bf2007-12-14 00:47:05 -050018#define BOOT_CMD_FW_BY_USB 0x01
19#define BOOT_CMD_FW_IN_EEPROM 0x02
20#define BOOT_CMD_UPDATE_BOOT2 0x03
21#define BOOT_CMD_UPDATE_FW 0x04
22#define BOOT_CMD_MAGIC_NUMBER 0x4C56524D /* LVRM */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020023
David Woodhouseeae86bf2007-12-14 00:47:05 -050024struct bootcmd
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020025{
David Woodhouseeae86bf2007-12-14 00:47:05 -050026 __le32 magic;
27 uint8_t cmd;
28 uint8_t pad[11];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020029};
30
David Woodhouseeae86bf2007-12-14 00:47:05 -050031#define BOOT_CMD_RESP_OK 0x0001
32#define BOOT_CMD_RESP_FAIL 0x0000
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020033
David Woodhouseeae86bf2007-12-14 00:47:05 -050034struct bootcmdresp
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020035{
David Woodhouseeae86bf2007-12-14 00:47:05 -050036 __le32 magic;
37 uint8_t cmd;
38 uint8_t result;
39 uint8_t pad[2];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020040};
41
42/** USB card description structure*/
David Woodhouseeae86bf2007-12-14 00:47:05 -050043struct if_usb_card {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020044 struct usb_device *udev;
45 struct urb *rx_urb, *tx_urb;
David Woodhouse6bc822b2007-12-11 12:53:43 -050046 struct lbs_private *priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020047
David Woodhouseeae86bf2007-12-14 00:47:05 -050048 struct sk_buff *rx_skb;
49 uint32_t usb_event_cause;
50 uint8_t usb_int_cause;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020051
David Woodhouseeae86bf2007-12-14 00:47:05 -050052 uint8_t ep_in;
53 uint8_t ep_out;
54
55 int8_t bootcmdresp;
56
57 int ep_in_size;
58
59 void *ep_out_buf;
60 int ep_out_size;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020061
Dan Williams954ee162007-08-20 11:43:25 -040062 const struct firmware *fw;
David Woodhouse4f82f5c2007-12-11 00:07:58 -050063 struct timer_list fw_timeout;
64 wait_queue_head_t fw_wq;
David Woodhouseeae86bf2007-12-14 00:47:05 -050065 uint32_t fwseqnum;
66 uint32_t totalbytes;
67 uint32_t fwlastblksent;
68 uint8_t CRC_OK;
69 uint8_t fwdnldover;
70 uint8_t fwfinalblk;
71 uint8_t surprise_removed;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020072
Holger Schurig43659292008-01-16 15:52:58 +010073 __le16 boot2_version;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020074};
75
76/** fwheader */
77struct fwheader {
David Woodhouse981f1872007-05-25 23:36:54 -040078 __le32 dnldcmd;
79 __le32 baseaddr;
80 __le32 datalength;
81 __le32 CRC;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020082};
83
84#define FW_MAX_DATA_BLK_SIZE 600
85/** FWData */
David Woodhouseeae86bf2007-12-14 00:47:05 -050086struct fwdata {
87 struct fwheader hdr;
David Woodhouse981f1872007-05-25 23:36:54 -040088 __le32 seqnum;
David Woodhouseeae86bf2007-12-14 00:47:05 -050089 uint8_t data[0];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020090};
91
92/** fwsyncheader */
93struct fwsyncheader {
David Woodhouse981f1872007-05-25 23:36:54 -040094 __le32 cmd;
95 __le32 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020096};
97
98#define FW_HAS_DATA_TO_RECV 0x00000001
99#define FW_HAS_LAST_BLOCK 0x00000004
100
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200101
Holger Schurig435a1ac2007-05-25 12:41:52 -0400102#endif