blob: 77066911230b88280bb459211480ae1b7397b239 [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
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020073};
74
75/** fwheader */
76struct fwheader {
David Woodhouse981f1872007-05-25 23:36:54 -040077 __le32 dnldcmd;
78 __le32 baseaddr;
79 __le32 datalength;
80 __le32 CRC;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020081};
82
83#define FW_MAX_DATA_BLK_SIZE 600
84/** FWData */
David Woodhouseeae86bf2007-12-14 00:47:05 -050085struct fwdata {
86 struct fwheader hdr;
David Woodhouse981f1872007-05-25 23:36:54 -040087 __le32 seqnum;
David Woodhouseeae86bf2007-12-14 00:47:05 -050088 uint8_t data[0];
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020089};
90
91/** fwsyncheader */
92struct fwsyncheader {
David Woodhouse981f1872007-05-25 23:36:54 -040093 __le32 cmd;
94 __le32 seqnum;
Marcelo Tosatti876c9d32007-02-10 12:25:27 -020095};
96
97#define FW_HAS_DATA_TO_RECV 0x00000001
98#define FW_HAS_LAST_BLOCK 0x00000004
99
Marcelo Tosatti876c9d32007-02-10 12:25:27 -0200100
Holger Schurig435a1ac2007-05-25 12:41:52 -0400101#endif