if_usb.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef _LBS_IF_USB_H
  2. #define _LBS_IF_USB_H
  3. #include <linux/wait.h>
  4. #include <linux/timer.h>
  5. struct lbs_private;
  6. /**
  7. * This file contains definition for USB interface.
  8. */
  9. #define CMD_TYPE_REQUEST 0xF00DFACE
  10. #define CMD_TYPE_DATA 0xBEADC0DE
  11. #define CMD_TYPE_INDICATION 0xBEEFFACE
  12. #define IPFIELD_ALIGN_OFFSET 2
  13. #define BOOT_CMD_FW_BY_USB 0x01
  14. #define BOOT_CMD_FW_IN_EEPROM 0x02
  15. #define BOOT_CMD_UPDATE_BOOT2 0x03
  16. #define BOOT_CMD_UPDATE_FW 0x04
  17. #define BOOT_CMD_MAGIC_NUMBER 0x4C56524D /* LVRM */
  18. struct bootcmd
  19. {
  20. __le32 magic;
  21. uint8_t cmd;
  22. uint8_t pad[11];
  23. };
  24. #define BOOT_CMD_RESP_OK 0x0001
  25. #define BOOT_CMD_RESP_FAIL 0x0000
  26. struct bootcmdresp
  27. {
  28. __le32 magic;
  29. uint8_t cmd;
  30. uint8_t result;
  31. uint8_t pad[2];
  32. };
  33. /** USB card description structure*/
  34. struct if_usb_card {
  35. struct usb_device *udev;
  36. struct urb *rx_urb, *tx_urb;
  37. struct lbs_private *priv;
  38. struct sk_buff *rx_skb;
  39. uint8_t ep_in;
  40. uint8_t ep_out;
  41. int8_t bootcmdresp;
  42. int ep_in_size;
  43. void *ep_out_buf;
  44. int ep_out_size;
  45. const struct firmware *fw;
  46. struct timer_list fw_timeout;
  47. wait_queue_head_t fw_wq;
  48. uint32_t fwseqnum;
  49. uint32_t totalbytes;
  50. uint32_t fwlastblksent;
  51. uint8_t CRC_OK;
  52. uint8_t fwdnldover;
  53. uint8_t fwfinalblk;
  54. uint8_t surprise_removed;
  55. __le16 boot2_version;
  56. };
  57. /** fwheader */
  58. struct fwheader {
  59. __le32 dnldcmd;
  60. __le32 baseaddr;
  61. __le32 datalength;
  62. __le32 CRC;
  63. };
  64. #define FW_MAX_DATA_BLK_SIZE 600
  65. /** FWData */
  66. struct fwdata {
  67. struct fwheader hdr;
  68. __le32 seqnum;
  69. uint8_t data[0];
  70. };
  71. /** fwsyncheader */
  72. struct fwsyncheader {
  73. __le32 cmd;
  74. __le32 seqnum;
  75. };
  76. #define FW_HAS_DATA_TO_RECV 0x00000001
  77. #define FW_HAS_LAST_BLOCK 0x00000004
  78. #endif