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 9#ifndef _USB_THOR_H_ 10#define _USB_THOR_H_ 11 12#include <linux/compiler.h> 13#include <linux/sizes.h> 14 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 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 /* 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 */ 123#ifdef CONFIG_THOR_RESET_OFF 124#define RESET_DONE 0xFFFFFFFF 125#endif 126#endif /* _USB_THOR_H_ */ 127