if_usb.h 1.9 KB

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