f_dfu.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. enum dfu_state {
  47. DFU_STATE_appIDLE = 0,
  48. DFU_STATE_appDETACH = 1,
  49. DFU_STATE_dfuIDLE = 2,
  50. DFU_STATE_dfuDNLOAD_SYNC = 3,
  51. DFU_STATE_dfuDNBUSY = 4,
  52. DFU_STATE_dfuDNLOAD_IDLE = 5,
  53. DFU_STATE_dfuMANIFEST_SYNC = 6,
  54. DFU_STATE_dfuMANIFEST = 7,
  55. DFU_STATE_dfuMANIFEST_WAIT_RST = 8,
  56. DFU_STATE_dfuUPLOAD_IDLE = 9,
  57. DFU_STATE_dfuERROR = 10,
  58. };
  59. struct dfu_status {
  60. __u8 bStatus;
  61. __u8 bwPollTimeout[3];
  62. __u8 bState;
  63. __u8 iString;
  64. } __packed;
  65. struct dfu_function_descriptor {
  66. __u8 bLength;
  67. __u8 bDescriptorType;
  68. __u8 bmAttributes;
  69. __le16 wDetachTimeOut;
  70. __le16 wTransferSize;
  71. __le16 bcdDFUVersion;
  72. } __packed;
  73. #define DFU_POLL_TIMEOUT_MASK (0xFFFFFFUL)
  74. #endif /* __F_DFU_H_ */