Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1 | #ifndef _LBS_IF_USB_H |
2 | #define _LBS_IF_USB_H | ||||
Holger Schurig | 435a1ac | 2007-05-25 12:41:52 -0400 | [diff] [blame] | 3 | |
David Woodhouse | 4f82f5c | 2007-12-11 00:07:58 -0500 | [diff] [blame] | 4 | #include <linux/wait.h> |
5 | #include <linux/timer.h> | ||||
6 | |||||
David Woodhouse | 6bc822b | 2007-12-11 12:53:43 -0500 | [diff] [blame] | 7 | struct lbs_private; |
8 | |||||
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 9 | /* |
10 | * This file contains definition for USB interface. | ||||
11 | */ | ||||
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 12 | #define CMD_TYPE_REQUEST 0xF00DFACE |
13 | #define CMD_TYPE_DATA 0xBEADC0DE | ||||
14 | #define CMD_TYPE_INDICATION 0xBEEFFACE | ||||
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 15 | |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 16 | #define IPFIELD_ALIGN_OFFSET 2 |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 17 | |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 18 | #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 Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 23 | |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 24 | struct bootcmd |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 25 | { |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 26 | __le32 magic; |
27 | uint8_t cmd; | ||||
28 | uint8_t pad[11]; | ||||
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 29 | }; |
30 | |||||
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 31 | #define BOOT_CMD_RESP_OK 0x0001 |
32 | #define BOOT_CMD_RESP_FAIL 0x0000 | ||||
Brian Cavagnolo | 1556c0f | 2008-07-21 11:02:46 -0700 | [diff] [blame] | 33 | #define BOOT_CMD_RESP_NOT_SUPPORTED 0x0002 |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 34 | |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 35 | struct bootcmdresp |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 36 | { |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 37 | __le32 magic; |
38 | uint8_t cmd; | ||||
39 | uint8_t result; | ||||
40 | uint8_t pad[2]; | ||||
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 41 | }; |
42 | |||||
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 43 | /* USB card description structure*/ |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 44 | struct if_usb_card { |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 45 | struct usb_device *udev; |
Dan Williams | 5cddea8 | 2010-08-07 21:13:57 -0500 | [diff] [blame] | 46 | uint32_t model; /* MODEL_* */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 47 | struct urb *rx_urb, *tx_urb; |
David Woodhouse | 6bc822b | 2007-12-11 12:53:43 -0500 | [diff] [blame] | 48 | struct lbs_private *priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 49 | |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 50 | struct sk_buff *rx_skb; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 51 | |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 52 | uint8_t ep_in; |
53 | uint8_t ep_out; | ||||
54 | |||||
Brian Cavagnolo | 1556c0f | 2008-07-21 11:02:46 -0700 | [diff] [blame] | 55 | /* bootcmdresp == 0 means command is pending |
56 | * bootcmdresp < 0 means error | ||||
57 | * bootcmdresp > 0 is a BOOT_CMD_RESP_* from firmware | ||||
58 | */ | ||||
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 59 | int8_t bootcmdresp; |
60 | |||||
61 | int ep_in_size; | ||||
62 | |||||
63 | void *ep_out_buf; | ||||
64 | int ep_out_size; | ||||
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 65 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 66 | const struct firmware *fw; |
David Woodhouse | 4f82f5c | 2007-12-11 00:07:58 -0500 | [diff] [blame] | 67 | struct timer_list fw_timeout; |
68 | wait_queue_head_t fw_wq; | ||||
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 69 | 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 Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 76 | |
Holger Schurig | 4365929 | 2008-01-16 15:52:58 +0100 | [diff] [blame] | 77 | __le16 boot2_version; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 78 | }; |
79 | |||||
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 80 | /* fwheader */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 81 | struct fwheader { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 82 | __le32 dnldcmd; |
83 | __le32 baseaddr; | ||||
84 | __le32 datalength; | ||||
85 | __le32 CRC; | ||||
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 86 | }; |
87 | |||||
88 | #define FW_MAX_DATA_BLK_SIZE 600 | ||||
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 89 | /* FWData */ |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 90 | struct fwdata { |
91 | struct fwheader hdr; | ||||
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 92 | __le32 seqnum; |
David Woodhouse | eae86bf | 2007-12-14 00:47:05 -0500 | [diff] [blame] | 93 | uint8_t data[0]; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 94 | }; |
95 | |||||
Randy Dunlap | 8973a6e | 2011-04-26 15:25:29 -0700 | [diff] [blame] | 96 | /* fwsyncheader */ |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 97 | struct fwsyncheader { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 98 | __le32 cmd; |
99 | __le32 seqnum; | ||||
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 100 | }; |
101 | |||||
102 | #define FW_HAS_DATA_TO_RECV 0x00000001 | ||||
103 | #define FW_HAS_LAST_BLOCK 0x00000004 | ||||
104 | |||||
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 105 | |
Holger Schurig | 435a1ac | 2007-05-25 12:41:52 -0400 | [diff] [blame] | 106 | #endif |