blob: 8ba3fa21b73316edb5e5491d6d87fcdae06ba215 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Lukasz Majewskic5279372013-10-08 14:30:42 +02002/*
3 * f_thor.h - USB TIZEN THOR - internal gadget definitions
4 *
5 * Copyright (C) 2013 Samsung Electronics
6 * Lukasz Majewski <l.majewski@samsung.com>
Lukasz Majewskic5279372013-10-08 14:30:42 +02007 */
8
9#ifndef _USB_THOR_H_
10#define _USB_THOR_H_
11
12#include <linux/compiler.h>
Alexey Brodkin1ace4022014-02-26 17:47:58 +040013#include <linux/sizes.h>
Lukasz Majewskic5279372013-10-08 14:30:42 +020014
15/* THOR Composite Gadget */
16#define STRING_MANUFACTURER_IDX 0
17#define STRING_PRODUCT_IDX 1
18#define STRING_SERIAL_IDX 2
19
20/* ********************************************************** */
21/* THOR protocol definitions */
22/* ********************************************************** */
23
24/*
25 * Attribute Vendor descriptor - necessary to prevent ZLP transmission
26 * from Windows XP HOST PC
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
Seung-Woo Kim1fe9ae72018-05-10 10:52:15 +090037#define VER_PROTOCOL_MAJOR 5
Lukasz Majewskic5279372013-10-08 14:30:42 +020038#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 /* RQT_INFO */
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 /* RQT_CMD */
57 RQT_CMD_REBOOT = 1,
58 RQT_CMD_POWEROFF,
59 RQT_CMD_EFSCLEAR,
60
61 /* RQT_DL */
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 /* RQT_UL */
69 RQT_UL_INIT = 1,
70 RQT_UL_START,
71 RQT_UL_END,
72 RQT_UL_EXIT,
73};
74
75struct rqt_box { /* total: 256B */
76 s32 rqt; /* request id */
77 s32 rqt_data; /* request data id */
78 s32 int_data[14]; /* int data */
79 char str_data[5][32]; /* string data */
80 char md5[32]; /* md5 checksum */
81} __packed;
82
83struct rsp_box { /* total: 128B */
84 s32 rsp; /* response id (= request id) */
85 s32 rsp_data; /* response data id */
86 s32 ack; /* ack */
87 s32 int_data[5]; /* int data */
88 char str_data[3][32]; /* string data */
89} __packed;
90
91struct data_rsp_box { /* total: 8B */
92 s32 ack; /* response id (= request id) */
93 s32 count; /* response data id */
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; /* EP0 -> control responses */
104
105 /* IN/OUT EP's and correspoinding requests */
106 struct usb_ep *in_ep, *out_ep, *int_ep;
107 struct usb_request *in_req, *out_req;
108
109 /* Control flow variables */
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 /* 1 MiB */
122#define THOR_STORE_UNIT_SIZE SZ_32M /* 32 MiB */
Siva Durga Prasad Paladugu41d237d2015-04-16 10:38:34 +0200123#ifdef CONFIG_THOR_RESET_OFF
124#define RESET_DONE 0xFFFFFFFF
125#endif
Lukasz Majewskic5279372013-10-08 14:30:42 +0200126#endif /* _USB_THOR_H_ */