usb: dwc_otg_310: support vbus controlled by both gpio and pmic
[firefly-linux-kernel-4.4.55.git] / drivers / usb / dwc_otg_310 / dwc_cfi_common.h
1 /* ==========================================================================
2  * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
3  * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
4  * otherwise expressly agreed to in writing between Synopsys and you.
5  *
6  * The Software IS NOT an item of Licensed Software or Licensed Product under
7  * any End User Software License Agreement or Agreement for Licensed Product
8  * with Synopsys or any supplement thereto. You are permitted to use and
9  * redistribute this Software in source and binary forms, with or without
10  * modification, provided that redistributions of source code must retain this
11  * notice. You may not view, use, disclose, copy or distribute this file or
12  * any information contained herein except pursuant to this license grant from
13  * Synopsys. If you do not agree with this notice, including the disclaimer
14  * below, then you are not authorized to use the Software.
15  *
16  * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26  * DAMAGE.
27  * ========================================================================== */
28
29 #if !defined(__DWC_CFI_COMMON_H__)
30 #define __DWC_CFI_COMMON_H__
31
32 /* #include <linux/types.h> */
33
34 /**
35  * @file
36  *
37  * This file contains the CFI specific common constants, interfaces
38  * (functions and macros) and structures for Linux. No PCD specific
39  * data structure or definition is to be included in this file.
40  *
41  */
42
43 /** This is a request for all Core Features */
44 #define VEN_CORE_GET_FEATURES           0xB1
45
46 /** This is a request to get the value of a specific Core Feature */
47 #define VEN_CORE_GET_FEATURE            0xB2
48
49 /** This command allows the host to set the value of a specific Core Feature */
50 #define VEN_CORE_SET_FEATURE            0xB3
51
52 /** This command allows the host to set the default values of
53  * either all or any specific Core Feature
54  */
55 #define VEN_CORE_RESET_FEATURES         0xB4
56
57 /** This command forces the PCD to write the deferred values of a Core Features */
58 #define VEN_CORE_ACTIVATE_FEATURES      0xB5
59
60 /** This request reads a DWORD value from a register at the specified offset */
61 #define VEN_CORE_READ_REGISTER          0xB6
62
63 /** This request writes a DWORD value into a register at the specified offset */
64 #define VEN_CORE_WRITE_REGISTER         0xB7
65
66 /** This structure is the header of the Core Features dataset returned to
67  *  the Host
68  */
69 struct cfi_all_features_header {
70 /** The features header structure length is */
71 #define CFI_ALL_FEATURES_HDR_LEN                8
72         /**
73          * The total length of the features dataset returned to the Host
74          */
75         uint16_t wTotalLen;
76
77         /**
78          * CFI version number inBinary-Coded Decimal (i.e., 1.00 is 100H).
79          * This field identifies the version of the CFI Specification with which
80          * the device is compliant.
81          */
82         uint16_t wVersion;
83
84         /** The ID of the Core */
85         uint16_t wCoreID;
86 #define CFI_CORE_ID_UDC         1
87 #define CFI_CORE_ID_OTG         2
88 #define CFI_CORE_ID_WUDEV       3
89
90         /** Number of features returned by VEN_CORE_GET_FEATURES request */
91         uint16_t wNumFeatures;
92 } UPACKED;
93
94 typedef struct cfi_all_features_header cfi_all_features_header_t;
95
96 /** This structure is a header of the Core Feature descriptor dataset returned to
97  *  the Host after the VEN_CORE_GET_FEATURES request
98  */
99 struct cfi_feature_desc_header {
100 #define CFI_FEATURE_DESC_HDR_LEN        8
101
102         /** The feature ID */
103         uint16_t wFeatureID;
104
105         /** Length of this feature descriptor in bytes - including the
106          * length of the feature name string
107          */
108         uint16_t wLength;
109
110         /** The data length of this feature in bytes */
111         uint16_t wDataLength;
112
113         /**
114          * Attributes of this features
115          * D0: Access rights
116          * 0 - Read/Write
117          * 1 - Read only
118          */
119         uint8_t bmAttributes;
120 #define CFI_FEATURE_ATTR_RO             1
121 #define CFI_FEATURE_ATTR_RW             0
122
123         /** Length of the feature name in bytes */
124         uint8_t bNameLen;
125
126         /** The feature name buffer */
127         /* uint8_t *name; */
128 } UPACKED;
129
130 typedef struct cfi_feature_desc_header cfi_feature_desc_header_t;
131
132 /**
133  * This structure describes a NULL terminated string referenced by its id field.
134  * It is very similar to usb_string structure but has the id field type set to 16-bit.
135  */
136 struct cfi_string {
137         uint16_t id;
138         const uint8_t *s;
139 };
140 typedef struct cfi_string cfi_string_t;
141
142 #endif