if_usb.h 1.9 KB

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