Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LBS_IF_USB_H
0003 #define _LBS_IF_USB_H
0004 
0005 #include <linux/wait.h>
0006 #include <linux/timer.h>
0007 
0008 struct lbs_private;
0009 
0010 /*
0011  * This file contains definition for USB interface.
0012  */
0013 #define CMD_TYPE_REQUEST        0xF00DFACE
0014 #define CMD_TYPE_DATA           0xBEADC0DE
0015 #define CMD_TYPE_INDICATION     0xBEEFFACE
0016 
0017 #define IPFIELD_ALIGN_OFFSET        2
0018 
0019 #define BOOT_CMD_FW_BY_USB      0x01
0020 #define BOOT_CMD_FW_IN_EEPROM       0x02
0021 #define BOOT_CMD_UPDATE_BOOT2       0x03
0022 #define BOOT_CMD_UPDATE_FW      0x04
0023 #define BOOT_CMD_MAGIC_NUMBER       0x4C56524D   /* LVRM */
0024 
0025 struct bootcmd
0026 {
0027     __le32  magic;
0028     uint8_t cmd;
0029     uint8_t pad[11];
0030 };
0031 
0032 #define BOOT_CMD_RESP_OK        0x0001
0033 #define BOOT_CMD_RESP_FAIL      0x0000
0034 #define BOOT_CMD_RESP_NOT_SUPPORTED 0x0002
0035 
0036 struct bootcmdresp
0037 {
0038     __le32  magic;
0039     uint8_t cmd;
0040     uint8_t result;
0041     uint8_t pad[2];
0042 };
0043 
0044 /* USB card description structure*/
0045 struct if_usb_card {
0046     struct usb_device *udev;
0047     uint32_t model;  /* MODEL_* */
0048     struct urb *rx_urb, *tx_urb;
0049     struct lbs_private *priv;
0050 
0051     struct sk_buff *rx_skb;
0052 
0053     uint8_t ep_in;
0054     uint8_t ep_out;
0055 
0056     /* bootcmdresp == 0 means command is pending
0057      * bootcmdresp < 0 means error
0058      * bootcmdresp > 0 is a BOOT_CMD_RESP_* from firmware
0059      */
0060     int8_t bootcmdresp;
0061 
0062     int ep_in_size;
0063 
0064     void *ep_out_buf;
0065     int ep_out_size;
0066 
0067     const struct firmware *fw;
0068     struct timer_list fw_timeout;
0069     wait_queue_head_t fw_wq;
0070     uint32_t fwseqnum;
0071     uint32_t totalbytes;
0072     uint32_t fwlastblksent;
0073     uint8_t CRC_OK;
0074     uint8_t fwdnldover;
0075     uint8_t fwfinalblk;
0076     uint8_t surprise_removed;
0077 
0078     __le16 boot2_version;
0079 };
0080 
0081 /* fwheader */
0082 struct fwheader {
0083     __le32 dnldcmd;
0084     __le32 baseaddr;
0085     __le32 datalength;
0086     __le32 CRC;
0087 };
0088 
0089 #define FW_MAX_DATA_BLK_SIZE    600
0090 /* FWData */
0091 struct fwdata {
0092     struct fwheader hdr;
0093     __le32 seqnum;
0094     uint8_t data[];
0095 };
0096 
0097 /* fwsyncheader */
0098 struct fwsyncheader {
0099     __le32 cmd;
0100     __le32 seqnum;
0101 };
0102 
0103 #define FW_HAS_DATA_TO_RECV     0x00000001
0104 #define FW_HAS_LAST_BLOCK       0x00000004
0105 
0106 
0107 #endif