if_usb.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #define BOOT_CMD_RESP_NOT_SUPPORTED 0x0002
  27. struct bootcmdresp
  28. {
  29. __le32 magic;
  30. uint8_t cmd;
  31. uint8_t result;
  32. uint8_t pad[2];
  33. };
  34. /* USB card description structure*/
  35. struct if_usb_card {
  36. struct usb_device *udev;
  37. uint32_t model; /* MODEL_* */
  38. struct urb *rx_urb, *tx_urb;
  39. struct lbs_private *priv;
  40. struct sk_buff *rx_skb;
  41. uint8_t ep_in;
  42. uint8_t ep_out;
  43. /* bootcmdresp == 0 means command is pending
  44. * bootcmdresp < 0 means error
  45. * bootcmdresp > 0 is a BOOT_CMD_RESP_* from firmware
  46. */
  47. int8_t bootcmdresp;
  48. int ep_in_size;
  49. void *ep_out_buf;
  50. int ep_out_size;
  51. const struct firmware *fw;
  52. struct timer_list fw_timeout;
  53. wait_queue_head_t fw_wq;
  54. uint32_t fwseqnum;
  55. uint32_t totalbytes;
  56. uint32_t fwlastblksent;
  57. uint8_t CRC_OK;
  58. uint8_t fwdnldover;
  59. uint8_t fwfinalblk;
  60. uint8_t surprise_removed;
  61. __le16 boot2_version;
  62. };
  63. /* fwheader */
  64. struct fwheader {
  65. __le32 dnldcmd;
  66. __le32 baseaddr;
  67. __le32 datalength;
  68. __le32 CRC;
  69. };
  70. #define FW_MAX_DATA_BLK_SIZE 600
  71. /* FWData */
  72. struct fwdata {
  73. struct fwheader hdr;
  74. __le32 seqnum;
  75. uint8_t data[0];
  76. };
  77. /* fwsyncheader */
  78. struct fwsyncheader {
  79. __le32 cmd;
  80. __le32 seqnum;
  81. };
  82. #define FW_HAS_DATA_TO_RECV 0x00000001
  83. #define FW_HAS_LAST_BLOCK 0x00000004
  84. #endif