blob: 5ba0aee0eb2f7e6eac289583a990f51fc1daf2f6 [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
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
43/** 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;
46 struct urb *rx_urb, *tx_urb;
David Woodhouse6bc822b2007-12-11 12:53:43 -050047 struct lbs_private *priv;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020048
David Woodhouseeae86bf2007-12-14 00:47:05 -050049 struct sk_buff *rx_skb;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020050
David Woodhouseeae86bf2007-12-14 00:47:05 -050051 uint8_t ep_in;
52 uint8_t ep_out;
53
Brian Cavagnolo1556c0f2008-07-21 11:02:46 -070054 /* bootcmdresp == 0 means command is pending
55 * bootcmdresp < 0 means error
56 * bootcmdresp > 0 is a BOOT_CMD_RESP_* from firmware
57 */
David Woodhouseeae86bf2007-12-14 00:47:05 -050058 int8_t bootcmdresp;
59
60 int ep_in_size;
61
62 void *ep_out_buf;
63 int ep_out_size;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020064
Dan Williams954ee162007-08-20 11:43:25 -040065 const struct firmware *fw;
David Woodhouse4f82f5c2007-12-11 00:07:58 -050066 struct timer_list fw_timeout;
67 wait_queue_head_t fw_wq;
David Woodhouseeae86bf2007-12-14 00:47:05 -050068 uint32_t fwseqnum;
69 uint32_t totalbytes;
70 uint32_t fwlastblksent;
71 uint8_t CRC_OK;
72 uint8_t fwdnldover;
73 uint8_t fwfinalblk;
74 uint8_t surprise_removed;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020075
Holger Schurig43659292008-01-16 15:52:58 +010076 __le16 boot2_version;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020077};
78
79/** fwheader */
80struct fwheader {
David Woodhouse981f1872007-05-25 23:36:54 -040081 __le32 dnldcmd;
82 __le32 baseaddr;
83 __le32 datalength;
84 __le32 CRC;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020085};
86
87#define FW_MAX_DATA_BLK_SIZE 600
88/** FWData */
David Woodhouseeae86bf2007-12-14 00:47:05 -050089struct fwdata {
90 struct fwheader hdr;
David Woodhouse981f1872007-05-25 23:36:54 -040091 __le32 seqnum;
David Woodhouseeae86bf2007-12-14 00:47:05 -050092 uint8_t data[0];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020093};
94
95/** fwsyncheader */
96struct fwsyncheader {
David Woodhouse981f1872007-05-25 23:36:54 -040097 __le32 cmd;
98 __le32 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020099};
100
101#define FW_HAS_DATA_TO_RECV 0x00000001
102#define FW_HAS_LAST_BLOCK 0x00000004
103
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200104
Holger Schurig435a1ac2007-05-25 12:41:52 -0400105#endif