1
2
3
4
5
6
7
8
9#ifndef _USB_THOR_H_
10#define _USB_THOR_H_
11
12#include <linux/compiler.h>
13#include <linux/sizes.h>
14
15
16#define STRING_MANUFACTURER_IDX 0
17#define STRING_PRODUCT_IDX 1
18#define STRING_SERIAL_IDX 2
19
20
21
22
23
24
25
26
27
28struct usb_cdc_attribute_vendor_descriptor {
29 __u8 bLength;
30 __u8 bDescriptorType;
31 __u8 bDescriptorSubType;
32 __u16 DAUType;
33 __u16 DAULength;
34 __u8 DAUValue;
35} __packed;
36
37#define VER_PROTOCOL_MAJOR 5
38#define VER_PROTOCOL_MINOR 0
39
40enum rqt {
41 RQT_INFO = 200,
42 RQT_CMD,
43 RQT_DL,
44 RQT_UL,
45};
46
47enum rqt_data {
48
49 RQT_INFO_VER_PROTOCOL = 1,
50 RQT_INIT_VER_HW,
51 RQT_INIT_VER_BOOT,
52 RQT_INIT_VER_KERNEL,
53 RQT_INIT_VER_PLATFORM,
54 RQT_INIT_VER_CSC,
55
56
57 RQT_CMD_REBOOT = 1,
58 RQT_CMD_POWEROFF,
59 RQT_CMD_EFSCLEAR,
60
61
62 RQT_DL_INIT = 1,
63 RQT_DL_FILE_INFO,
64 RQT_DL_FILE_START,
65 RQT_DL_FILE_END,
66 RQT_DL_EXIT,
67
68
69 RQT_UL_INIT = 1,
70 RQT_UL_START,
71 RQT_UL_END,
72 RQT_UL_EXIT,
73};
74
75struct rqt_box {
76 s32 rqt;
77 s32 rqt_data;
78 s32 int_data[14];
79 char str_data[5][32];
80 char md5[32];
81} __packed;
82
83struct rsp_box {
84 s32 rsp;
85 s32 rsp_data;
86 s32 ack;
87 s32 int_data[5];
88 char str_data[3][32];
89} __packed;
90
91struct data_rsp_box {
92 s32 ack;
93 s32 count;
94} __packed;
95
96enum {
97 FILE_TYPE_NORMAL,
98 FILE_TYPE_PIT,
99};
100
101struct thor_dev {
102 struct usb_gadget *gadget;
103 struct usb_request *req;
104
105
106 struct usb_ep *in_ep, *out_ep, *int_ep;
107 struct usb_request *in_req, *out_req;
108
109
110 unsigned char configuration_done;
111 unsigned char rxdata;
112 unsigned char txdata;
113};
114
115struct f_thor {
116 struct usb_function usb_function;
117 struct thor_dev *dev;
118};
119
120#define F_NAME_BUF_SIZE 32
121#define THOR_PACKET_SIZE SZ_1M
122#define THOR_STORE_UNIT_SIZE SZ_32M
123#ifdef CONFIG_THOR_RESET_OFF
124#define RESET_DONE 0xFFFFFFFF
125#endif
126#endif
127