if_usb.h 1.8 KB

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