f_dfu.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * f_dfu.h -- Device Firmware Update gadget
  3. *
  4. * Copyright (C) 2011-2012 Samsung Electronics
  5. * author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #ifndef __F_DFU_H_
  10. #define __F_DFU_H_
  11. #include <linux/compiler.h>
  12. #include <linux/usb/composite.h>
  13. #define DFU_CONFIG_VAL 1
  14. #define DFU_DT_FUNC 0x21
  15. #define DFU_BIT_WILL_DETACH (0x1 << 3)
  16. #define DFU_BIT_MANIFESTATION_TOLERANT (0x1 << 2)
  17. #define DFU_BIT_CAN_UPLOAD (0x1 << 1)
  18. #define DFU_BIT_CAN_DNLOAD 0x1
  19. /* big enough to hold our biggest descriptor */
  20. #define DFU_USB_BUFSIZ 4096
  21. #define USB_REQ_DFU_DETACH 0x00
  22. #define USB_REQ_DFU_DNLOAD 0x01
  23. #define USB_REQ_DFU_UPLOAD 0x02
  24. #define USB_REQ_DFU_GETSTATUS 0x03
  25. #define USB_REQ_DFU_CLRSTATUS 0x04
  26. #define USB_REQ_DFU_GETSTATE 0x05
  27. #define USB_REQ_DFU_ABORT 0x06
  28. #define DFU_STATUS_OK 0x00
  29. #define DFU_STATUS_errTARGET 0x01
  30. #define DFU_STATUS_errFILE 0x02
  31. #define DFU_STATUS_errWRITE 0x03
  32. #define DFU_STATUS_errERASE 0x04
  33. #define DFU_STATUS_errCHECK_ERASED 0x05
  34. #define DFU_STATUS_errPROG 0x06
  35. #define DFU_STATUS_errVERIFY 0x07
  36. #define DFU_STATUS_errADDRESS 0x08
  37. #define DFU_STATUS_errNOTDONE 0x09
  38. #define DFU_STATUS_errFIRMWARE 0x0a
  39. #define DFU_STATUS_errVENDOR 0x0b
  40. #define DFU_STATUS_errUSBR 0x0c
  41. #define DFU_STATUS_errPOR 0x0d
  42. #define DFU_STATUS_errUNKNOWN 0x0e
  43. #define DFU_STATUS_errSTALLEDPKT 0x0f
  44. #define RET_STALL -1
  45. #define RET_ZLP 0
  46. #define RET_STAT_LEN 6
  47. enum dfu_state {
  48. DFU_STATE_appIDLE = 0,
  49. DFU_STATE_appDETACH = 1,
  50. DFU_STATE_dfuIDLE = 2,
  51. DFU_STATE_dfuDNLOAD_SYNC = 3,
  52. DFU_STATE_dfuDNBUSY = 4,
  53. DFU_STATE_dfuDNLOAD_IDLE = 5,
  54. DFU_STATE_dfuMANIFEST_SYNC = 6,
  55. DFU_STATE_dfuMANIFEST = 7,
  56. DFU_STATE_dfuMANIFEST_WAIT_RST = 8,
  57. DFU_STATE_dfuUPLOAD_IDLE = 9,
  58. DFU_STATE_dfuERROR = 10,
  59. };
  60. struct dfu_status {
  61. __u8 bStatus;
  62. __u8 bwPollTimeout[3];
  63. __u8 bState;
  64. __u8 iString;
  65. } __packed;
  66. struct dfu_function_descriptor {
  67. __u8 bLength;
  68. __u8 bDescriptorType;
  69. __u8 bmAttributes;
  70. __le16 wDetachTimeOut;
  71. __le16 wTransferSize;
  72. __le16 bcdDFUVersion;
  73. } __packed;
  74. #define DFU_POLL_TIMEOUT_MASK (0xFFFFFFUL)
  75. #endif /* __F_DFU_H_ */