f_dfu.h 2.1 KB

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