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