xref: /linux/drivers/net/wireless/marvell/libertas_tf/if_usb.h (revision 24bce201d79807b668bf9d9e0aca801c5c0d5f78)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *  Copyright (C) 2008, cozybit Inc.
4  *  Copyright (C) 2003-2006, Marvell International Ltd.
5  */
6 #include <linux/wait.h>
7 #include <linux/timer.h>
8 
9 struct lbtf_private;
10 
11 /**
12   * This file contains definition for USB interface.
13   */
14 #define CMD_TYPE_REQUEST		0xF00DFACE
15 #define CMD_TYPE_DATA			0xBEADC0DE
16 #define CMD_TYPE_INDICATION		0xBEEFFACE
17 
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 */
23 
24 struct bootcmd {
25 	__le32	magic;
26 	uint8_t	cmd;
27 	uint8_t	pad[11];
28 };
29 
30 #define BOOT_CMD_RESP_OK		0x0001
31 #define BOOT_CMD_RESP_FAIL		0x0000
32 
33 struct bootcmdresp {
34 	__le32	magic;
35 	uint8_t	cmd;
36 	uint8_t	result;
37 	uint8_t	pad[2];
38 };
39 
40 /** USB card description structure*/
41 struct if_usb_card {
42 	struct usb_device *udev;
43 	struct urb *rx_urb, *tx_urb, *cmd_urb;
44 	struct lbtf_private *priv;
45 
46 	struct sk_buff *rx_skb;
47 
48 	uint8_t ep_in;
49 	uint8_t ep_out;
50 
51 	int8_t bootcmdresp;
52 
53 	int ep_in_size;
54 
55 	void *ep_out_buf;
56 	int ep_out_size;
57 
58 	const struct firmware *fw;
59 	struct timer_list fw_timeout;
60 	wait_queue_head_t fw_wq;
61 	uint32_t fwseqnum;
62 	uint32_t totalbytes;
63 	uint32_t fwlastblksent;
64 	uint8_t CRC_OK;
65 	uint8_t fwdnldover;
66 	uint8_t fwfinalblk;
67 
68 	__le16 boot2_version;
69 };
70 
71 /** fwheader */
72 struct fwheader {
73 	__le32 dnldcmd;
74 	__le32 baseaddr;
75 	__le32 datalength;
76 	__le32 CRC;
77 };
78 
79 #define FW_MAX_DATA_BLK_SIZE	600
80 /** FWData */
81 struct fwdata {
82 	struct fwheader hdr;
83 	__le32 seqnum;
84 	uint8_t data[];
85 };
86 
87 /** fwsyncheader */
88 struct fwsyncheader {
89 	__le32 cmd;
90 	__le32 seqnum;
91 };
92 
93 #define FW_HAS_DATA_TO_RECV		0x00000001
94 #define FW_HAS_LAST_BLOCK		0x00000004
95