summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_thor.h
blob: 83412851dd17f6100f7c2eda67b0e30e8b69958d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * f_thor.h - USB TIZEN THOR - internal gadget definitions
 *
 * Copyright (C) 2013 Samsung Electronics
 * Lukasz Majewski  <l.majewski@samsung.com>
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */

#ifndef _USB_THOR_H_
#define _USB_THOR_H_

#include <linux/compiler.h>
#include <linux/sizes.h>

/* THOR Composite Gadget */
#define STRING_MANUFACTURER_IDX	0
#define STRING_PRODUCT_IDX		1
#define STRING_SERIAL_IDX		2

/* ********************************************************** */
/*                   THOR protocol definitions		      */
/* ********************************************************** */

/*
 * Attribute Vendor descriptor - necessary to prevent ZLP transmission
 * from Windows XP HOST PC
 */
struct usb_cdc_attribute_vendor_descriptor {
	__u8 bLength;
	__u8 bDescriptorType;
	__u8 bDescriptorSubType;
	__u16 DAUType;
	__u16 DAULength;
	__u8 DAUValue;
} __packed;

#define VER_PROTOCOL_MAJOR	4
#define VER_PROTOCOL_MINOR	0

enum rqt {
	RQT_INFO = 200,
	RQT_CMD,
	RQT_DL,
	RQT_UL,
};

enum rqt_data {
	/* RQT_INFO */
	RQT_INFO_VER_PROTOCOL = 1,
	RQT_INIT_VER_HW,
	RQT_INIT_VER_BOOT,
	RQT_INIT_VER_KERNEL,
	RQT_INIT_VER_PLATFORM,
	RQT_INIT_VER_CSC,

	/* RQT_CMD */
	RQT_CMD_REBOOT = 1,
	RQT_CMD_POWEROFF,
	RQT_CMD_EFSCLEAR,

	/* RQT_DL */
	RQT_DL_INIT = 1,
	RQT_DL_FILE_INFO,
	RQT_DL_FILE_START,
	RQT_DL_FILE_END,
	RQT_DL_EXIT,

	/* RQT_UL */
	RQT_UL_INIT = 1,
	RQT_UL_START,
	RQT_UL_END,
	RQT_UL_EXIT,
};

struct rqt_box {		/* total: 256B */
	s32 rqt;		/* request id */
	s32 rqt_data;		/* request data id */
	s32 int_data[14];	/* int data */
	char str_data[5][32];	/* string data */
	char md5[32];		/* md5 checksum */
} __packed;

struct rsp_box {		/* total: 128B */
	s32 rsp;		/* response id (= request id) */
	s32 rsp_data;		/* response data id */
	s32 ack;		/* ack */
	s32 int_data[5];	/* int data */
	char str_data[3][32];	/* string data */
} __packed;

struct data_rsp_box {		/* total: 8B */
	s32 ack;		/* response id (= request id) */
	s32 count;		/* response data id */
} __packed;

enum {
	FILE_TYPE_NORMAL,
	FILE_TYPE_PIT,
};

struct thor_dev {
	struct usb_gadget *gadget;
	struct usb_request *req; /* EP0 -> control responses */

	/* IN/OUT EP's and correspoinding requests */
	struct usb_ep *in_ep, *out_ep, *int_ep;
	struct usb_request *in_req, *out_req;

	/* Control flow variables */
	unsigned char configuration_done;
	unsigned char rxdata;
	unsigned char txdata;
};

struct f_thor {
	struct usb_function usb_function;
	struct thor_dev *dev;
};

#define F_NAME_BUF_SIZE 32
#define THOR_PACKET_SIZE SZ_1M      /* 1 MiB */
#define THOR_STORE_UNIT_SIZE SZ_32M /* 32 MiB */
#ifdef CONFIG_THOR_RESET_OFF
#define RESET_DONE 0xFFFFFFFF
#endif
#endif /* _USB_THOR_H_ */
OpenPOWER on IntegriCloud