f_thor.h 2.6 KB

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