f_thor.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * f_thor.h - USB TIZEN THOR - internal gadget definitions
  4. *
  5. * Copyright (C) 2013 Samsung Electronics
  6. * Lukasz Majewski <l.majewski@samsung.com>
  7. */
  8. #ifndef _USB_THOR_H_
  9. #define _USB_THOR_H_
  10. #include <linux/compiler.h>
  11. #include <linux/sizes.h>
  12. /* THOR Composite Gadget */
  13. #define STRING_MANUFACTURER_IDX 0
  14. #define STRING_PRODUCT_IDX 1
  15. #define STRING_SERIAL_IDX 2
  16. /* ********************************************************** */
  17. /* THOR protocol definitions */
  18. /* ********************************************************** */
  19. /*
  20. * Attribute Vendor descriptor - necessary to prevent ZLP transmission
  21. * from Windows XP HOST PC
  22. */
  23. struct usb_cdc_attribute_vendor_descriptor {
  24. __u8 bLength;
  25. __u8 bDescriptorType;
  26. __u8 bDescriptorSubType;
  27. __u16 DAUType;
  28. __u16 DAULength;
  29. __u8 DAUValue;
  30. } __packed;
  31. #define VER_PROTOCOL_MAJOR 5
  32. #define VER_PROTOCOL_MINOR 0
  33. enum rqt {
  34. RQT_INFO = 200,
  35. RQT_CMD,
  36. RQT_DL,
  37. RQT_UL,
  38. };
  39. enum rqt_data {
  40. /* RQT_INFO */
  41. RQT_INFO_VER_PROTOCOL = 1,
  42. RQT_INIT_VER_HW,
  43. RQT_INIT_VER_BOOT,
  44. RQT_INIT_VER_KERNEL,
  45. RQT_INIT_VER_PLATFORM,
  46. RQT_INIT_VER_CSC,
  47. /* RQT_CMD */
  48. RQT_CMD_REBOOT = 1,
  49. RQT_CMD_POWEROFF,
  50. RQT_CMD_EFSCLEAR,
  51. /* RQT_DL */
  52. RQT_DL_INIT = 1,
  53. RQT_DL_FILE_INFO,
  54. RQT_DL_FILE_START,
  55. RQT_DL_FILE_END,
  56. RQT_DL_EXIT,
  57. /* RQT_UL */
  58. RQT_UL_INIT = 1,
  59. RQT_UL_START,
  60. RQT_UL_END,
  61. RQT_UL_EXIT,
  62. };
  63. struct rqt_box { /* total: 256B */
  64. s32 rqt; /* request id */
  65. s32 rqt_data; /* request data id */
  66. s32 int_data[14]; /* int data */
  67. char str_data[5][32]; /* string data */
  68. char md5[32]; /* md5 checksum */
  69. } __packed;
  70. struct rsp_box { /* total: 128B */
  71. s32 rsp; /* response id (= request id) */
  72. s32 rsp_data; /* response data id */
  73. s32 ack; /* ack */
  74. s32 int_data[5]; /* int data */
  75. char str_data[3][32]; /* string data */
  76. } __packed;
  77. struct data_rsp_box { /* total: 8B */
  78. s32 ack; /* response id (= request id) */
  79. s32 count; /* response data id */
  80. } __packed;
  81. enum {
  82. FILE_TYPE_NORMAL,
  83. FILE_TYPE_PIT,
  84. };
  85. struct thor_dev {
  86. struct usb_gadget *gadget;
  87. struct usb_request *req; /* EP0 -> control responses */
  88. /* IN/OUT EP's and correspoinding requests */
  89. struct usb_ep *in_ep, *out_ep, *int_ep;
  90. struct usb_request *in_req, *out_req;
  91. /* Control flow variables */
  92. unsigned char configuration_done;
  93. unsigned char rxdata;
  94. unsigned char txdata;
  95. };
  96. struct f_thor {
  97. struct usb_function usb_function;
  98. struct thor_dev *dev;
  99. };
  100. #define F_NAME_BUF_SIZE 32
  101. #define THOR_PACKET_SIZE SZ_1M /* 1 MiB */
  102. #define THOR_STORE_UNIT_SIZE SZ_32M /* 32 MiB */
  103. #ifdef CONFIG_THOR_RESET_OFF
  104. #define RESET_DONE 0xFFFFFFFF
  105. #endif
  106. #endif /* _USB_THOR_H_ */