blob: 6e42eac331deb502bbb4a9fd943c0cac82ef6870 [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
Randy Dunlap8973a6e2011-04-26 15:25:29 -07009/*
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
Brian Cavagnolo1556c0f2008-07-21 11:02:46 -070033#define BOOT_CMD_RESP_NOT_SUPPORTED 0x0002
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020034
David Woodhouseeae86bf2007-12-14 00:47:05 -050035struct bootcmdresp
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020036{
David Woodhouseeae86bf2007-12-14 00:47:05 -050037 __le32 magic;
38 uint8_t cmd;
39 uint8_t result;
40 uint8_t pad[2];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020041};
42
Randy Dunlap8973a6e2011-04-26 15:25:29 -070043/* USB card description structure*/
David Woodhouseeae86bf2007-12-14 00:47:05 -050044struct if_usb_card {
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020045 struct usb_device *udev;
Dan Williams5cddea82010-08-07 21:13:57 -050046 uint32_t model; /* MODEL_* */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020047 struct urb *rx_urb, *tx_urb;
David Woodhouse6bc822b2007-12-11 12:53:43 -050048 struct lbs_private *priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020049
David Woodhouseeae86bf2007-12-14 00:47:05 -050050 struct sk_buff *rx_skb;
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
Brian Cavagnolo1556c0f2008-07-21 11:02:46 -070055 /* bootcmdresp == 0 means command is pending
56 * bootcmdresp < 0 means error
57 * bootcmdresp > 0 is a BOOT_CMD_RESP_* from firmware
58 */
David Woodhouseeae86bf2007-12-14 00:47:05 -050059 int8_t bootcmdresp;
60
61 int ep_in_size;
62
63 void *ep_out_buf;
64 int ep_out_size;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020065
Dan Williams954ee162007-08-20 11:43:25 -040066 const struct firmware *fw;
David Woodhouse4f82f5c2007-12-11 00:07:58 -050067 struct timer_list fw_timeout;
68 wait_queue_head_t fw_wq;
David Woodhouseeae86bf2007-12-14 00:47:05 -050069 uint32_t fwseqnum;
70 uint32_t totalbytes;
71 uint32_t fwlastblksent;
72 uint8_t CRC_OK;
73 uint8_t fwdnldover;
74 uint8_t fwfinalblk;
75 uint8_t surprise_removed;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020076
Holger Schurig43659292008-01-16 15:52:58 +010077 __le16 boot2_version;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020078};
79
Randy Dunlap8973a6e2011-04-26 15:25:29 -070080/* fwheader */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020081struct fwheader {
David Woodhouse981f1872007-05-25 23:36:54 -040082 __le32 dnldcmd;
83 __le32 baseaddr;
84 __le32 datalength;
85 __le32 CRC;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020086};
87
88#define FW_MAX_DATA_BLK_SIZE 600
Randy Dunlap8973a6e2011-04-26 15:25:29 -070089/* FWData */
David Woodhouseeae86bf2007-12-14 00:47:05 -050090struct fwdata {
91 struct fwheader hdr;
David Woodhouse981f1872007-05-25 23:36:54 -040092 __le32 seqnum;
David Woodhouseeae86bf2007-12-14 00:47:05 -050093 uint8_t data[0];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020094};
95
Randy Dunlap8973a6e2011-04-26 15:25:29 -070096/* fwsyncheader */
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020097struct fwsyncheader {
David Woodhouse981f1872007-05-25 23:36:54 -040098 __le32 cmd;
99 __le32 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200100};
101
102#define FW_HAS_DATA_TO_RECV 0x00000001
103#define FW_HAS_LAST_BLOCK 0x00000004
104
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200105
Holger Schurig435a1ac2007-05-25 12:41:52 -0400106#endif