1/* 2 * Copyright (C) 2008, cozybit Inc. 3 * Copyright (C) 2003-2006, Marvell International Ltd. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or (at 8 * your option) any later version. 9 */ 10#include <linux/wait.h> 11#include <linux/timer.h> 12 13struct lbtf_private; 14 15/** 16 * This file contains definition for USB interface. 17 */ 18#define CMD_TYPE_REQUEST 0xF00DFACE 19#define CMD_TYPE_DATA 0xBEADC0DE 20#define CMD_TYPE_INDICATION 0xBEEFFACE 21 22#define BOOT_CMD_FW_BY_USB 0x01 23#define BOOT_CMD_FW_IN_EEPROM 0x02 24#define BOOT_CMD_UPDATE_BOOT2 0x03 25#define BOOT_CMD_UPDATE_FW 0x04 26#define BOOT_CMD_MAGIC_NUMBER 0x4C56524D /* LVRM */ 27 28struct bootcmd { 29 __le32 magic; 30 uint8_t cmd; 31 uint8_t pad[11]; 32}; 33 34#define BOOT_CMD_RESP_OK 0x0001 35#define BOOT_CMD_RESP_FAIL 0x0000 36 37struct bootcmdresp { 38 __le32 magic; 39 uint8_t cmd; 40 uint8_t result; 41 uint8_t pad[2]; 42}; 43 44/** USB card description structure*/ 45struct if_usb_card { 46 struct usb_device *udev; 47 struct urb *rx_urb, *tx_urb, *cmd_urb; 48 struct lbtf_private *priv; 49 50 struct sk_buff *rx_skb; 51 52 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; 61 62 const struct firmware *fw; 63 struct timer_list fw_timeout; 64 wait_queue_head_t fw_wq; 65 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 72 __le16 boot2_version; 73}; 74 75/** fwheader */ 76struct fwheader { 77 __le32 dnldcmd; 78 __le32 baseaddr; 79 __le32 datalength; 80 __le32 CRC; 81}; 82 83#define FW_MAX_DATA_BLK_SIZE 600 84/** FWData */ 85struct fwdata { 86 struct fwheader hdr; 87 __le32 seqnum; 88 uint8_t data[0]; 89}; 90 91/** fwsyncheader */ 92struct fwsyncheader { 93 __le32 cmd; 94 __le32 seqnum; 95}; 96 97#define FW_HAS_DATA_TO_RECV 0x00000001 98#define FW_HAS_LAST_BLOCK 0x00000004 99