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 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 9 | /** |
| 10 | * This file contains definition for USB interface. |
| 11 | */ |
| 12 | #define CMD_TYPE_REQUEST 0xF00DFACE |
| 13 | #define CMD_TYPE_DATA 0xBEADC0DE |
| 14 | #define CMD_TYPE_INDICATION 0xBEEFFACE |
| 15 | |
| 16 | #define IPFIELD_ALIGN_OFFSET 2 |
| 17 | |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [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 /* M=>0x4D,R=>0x52,V=>0x56,L=>0x4C */ |
| 23 | |
| 24 | struct bootcmdstr |
| 25 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 26 | __le32 u32magicnumber; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 27 | u8 u8cmd_tag; |
| 28 | u8 au8dumy[11]; |
| 29 | }; |
| 30 | |
| 31 | #define BOOT_CMD_RESP_OK 0x0001 |
| 32 | #define BOOT_CMD_RESP_FAIL 0x0000 |
| 33 | |
| 34 | struct bootcmdrespStr |
| 35 | { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 36 | __le32 u32magicnumber; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 37 | u8 u8cmd_tag; |
| 38 | u8 u8result; |
| 39 | u8 au8dumy[2]; |
| 40 | }; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 41 | |
| 42 | /* read callback private data */ |
| 43 | struct read_cb_info { |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 44 | struct usb_card_rec *cardp; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 45 | struct sk_buff *skb; |
| 46 | }; |
| 47 | |
| 48 | /** USB card description structure*/ |
| 49 | struct usb_card_rec { |
| 50 | struct net_device *eth_dev; |
| 51 | struct usb_device *udev; |
| 52 | struct urb *rx_urb, *tx_urb; |
David Woodhouse | 6bc822b | 2007-12-11 12:53:43 -0500 | [diff] [blame] | 53 | struct lbs_private *priv; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 54 | struct read_cb_info rinfo; |
| 55 | |
| 56 | int bulk_in_size; |
| 57 | u8 bulk_in_endpointAddr; |
| 58 | |
| 59 | u8 *bulk_out_buffer; |
| 60 | int bulk_out_size; |
| 61 | u8 bulk_out_endpointAddr; |
| 62 | |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 63 | const struct firmware *fw; |
David Woodhouse | 4f82f5c | 2007-12-11 00:07:58 -0500 | [diff] [blame] | 64 | struct timer_list fw_timeout; |
| 65 | wait_queue_head_t fw_wq; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 66 | u8 CRC_OK; |
| 67 | u32 fwseqnum; |
| 68 | u32 lastseqnum; |
| 69 | u32 totalbytes; |
| 70 | u32 fwlastblksent; |
| 71 | u8 fwdnldover; |
| 72 | u8 fwfinalblk; |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 73 | u8 surprise_removed; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 74 | |
| 75 | u32 usb_event_cause; |
| 76 | u8 usb_int_cause; |
| 77 | |
| 78 | u8 rx_urb_recall; |
| 79 | |
David Woodhouse | 6d35fdf | 2007-12-08 23:49:06 +0000 | [diff] [blame] | 80 | s8 bootcmdresp; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | /** fwheader */ |
| 84 | struct fwheader { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 85 | __le32 dnldcmd; |
| 86 | __le32 baseaddr; |
| 87 | __le32 datalength; |
| 88 | __le32 CRC; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | #define FW_MAX_DATA_BLK_SIZE 600 |
| 92 | /** FWData */ |
| 93 | struct FWData { |
| 94 | struct fwheader fwheader; |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 95 | __le32 seqnum; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 96 | u8 data[FW_MAX_DATA_BLK_SIZE]; |
| 97 | }; |
| 98 | |
| 99 | /** fwsyncheader */ |
| 100 | struct fwsyncheader { |
David Woodhouse | 981f187 | 2007-05-25 23:36:54 -0400 | [diff] [blame] | 101 | __le32 cmd; |
| 102 | __le32 seqnum; |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | #define FW_HAS_DATA_TO_RECV 0x00000001 |
| 106 | #define FW_HAS_LAST_BLOCK 0x00000004 |
| 107 | |
| 108 | #define FW_DATA_XMIT_SIZE \ |
David Woodhouse | bb793e2 | 2007-05-25 23:38:14 -0400 | [diff] [blame] | 109 | sizeof(struct fwheader) + le32_to_cpu(fwdata->fwheader.datalength) + sizeof(u32) |
Marcelo Tosatti | 876c9d3 | 2007-02-10 12:25:27 -0200 | [diff] [blame] | 110 | |
Holger Schurig | 435a1ac | 2007-05-25 12:41:52 -0400 | [diff] [blame] | 111 | #endif |