Add README.
[gps-watch.git] / src / common / usb.h
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2015, Freescale Semiconductor, Inc.
4  * Copyright 2016 NXP
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  *   of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  *   list of conditions and the following disclaimer in the documentation and/or
16  *   other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  *   contributors may be used to endorse or promote products derived from this
20  *   software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 #ifndef __USB_H__
36 #define __USB_H__
37
38 #include <stdint.h>
39 #include <stdio.h>
40 #include "fsl_common.h"
41 #include "usb_osa.h"
42 #include "usb_misc.h"
43 #include "usb_spec.h"
44
45 /*!
46  * @addtogroup usb_drv
47  * @{
48  */
49
50 /*******************************************************************************
51  * Definitions
52  ******************************************************************************/
53 /*! @brief Defines USB stack major version */
54 #define USB_STACK_VERSION_MAJOR (2U)
55 /*! @brief Defines USB stack minor version */
56 #define USB_STACK_VERSION_MINOR (0U)
57 /*! @brief Defines USB stack bugfix version */
58 #define USB_STACK_VERSION_BUGFIX (1U)
59
60 /*! @brief USB stack version definition */
61 #define USB_MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))
62
63 /*! @brief USB error code */
64 typedef enum _usb_status
65 {
66     kStatus_USB_Success = 0x00U, /*!< Success */
67     kStatus_USB_Error,           /*!< Failed */
68
69     kStatus_USB_Busy,                       /*!< Busy */
70     kStatus_USB_InvalidHandle,              /*!< Invalid handle */
71     kStatus_USB_InvalidParameter,           /*!< Invalid parameter */
72     kStatus_USB_InvalidRequest,             /*!< Invalid request */
73     kStatus_USB_ControllerNotFound,         /*!< Controller cannot be found */
74     kStatus_USB_InvalidControllerInterface, /*!< Invalid controller interface */
75
76     kStatus_USB_NotSupported,   /*!< Configuration is not supported */
77     kStatus_USB_Retry,          /*!< Enumeration get configuration retry */
78     kStatus_USB_TransferStall,  /*!< Transfer stalled */
79     kStatus_USB_TransferFailed, /*!< Transfer failed */
80     kStatus_USB_AllocFail,      /*!< Allocation failed */
81     kStatus_USB_LackSwapBuffer, /*!< Insufficient swap buffer for KHCI */
82     kStatus_USB_TransferCancel, /*!< The transfer cancelled */
83     kStatus_USB_BandwidthFail,  /*!< Allocate bandwidth failed */
84     kStatus_USB_MSDStatusFail,  /*!< For MSD, the CSW status means fail */
85     kStatus_USB_EHCIAttached,
86     kStatus_USB_EHCIDetached,
87 } usb_status_t;
88
89 /*! @brief USB host handle type define */
90 typedef void *usb_host_handle;
91
92 /*! @brief USB device handle type define. For device stack it is the whole device handle; for host stack it is the
93  * attached device instance handle*/
94 typedef void *usb_device_handle;
95
96 /*! @brief USB OTG handle type define */
97 typedef void *usb_otg_handle;
98
99 /*! @brief USB controller ID */
100 typedef enum _usb_controller_index
101 {
102     kUSB_ControllerKhci0 = 0U, /*!< KHCI 0U */
103     kUSB_ControllerKhci1 = 1U, /*!< KHCI 1U, Currently, there are no platforms which have two KHCI IPs, this is reserved
104                                   to be used in the future. */
105     kUSB_ControllerEhci0 = 2U, /*!< EHCI 0U */
106     kUSB_ControllerEhci1 = 3U, /*!< EHCI 1U, Currently, there are no platforms which have two EHCI IPs, this is reserved
107                                   to be used in the future. */
108
109     kUSB_ControllerLpcIp3511Fs0 = 4U, /*!< LPC USB IP3511 FS controller 0 */
110     kUSB_ControllerLpcIp3511Fs1 =
111         5U, /*!< LPC USB IP3511 FS controller 1, there are no platforms which have two IP3511 IPs, this is reserved
112               to be used in the future. */
113
114     kUSB_ControllerLpcIp3511Hs0 = 6U, /*!< LPC USB IP3511 HS controller 0 */
115     kUSB_ControllerLpcIp3511Hs1 =
116         7U, /*!< LPC USB IP3511 HS controller 1, there are no platforms which have two IP3511 IPs, this is reserved
117               to be used in the future. */
118
119     kUSB_ControllerOhci0 = 8U, /*!< OHCI 0U */
120     kUSB_ControllerOhci1 = 9U, /*!< OHCI 1U, Currently, there are no platforms which have two OHCI IPs, this is reserved
121                                   to be used in the future. */
122
123     kUSB_ControllerIp3516Hs0 = 10U, /*!< IP3516HS 0U */
124     kUSB_ControllerIp3516Hs1 =
125         11U, /*!< IP3516HS 1U, Currently, there are no platforms which have two IP3516HS IPs, this is reserved
126            to be used in the future. */
127 } usb_controller_index_t;
128
129 /**
130 * @brief USB stack version fields
131 */
132 typedef struct _usb_version
133 {
134     uint8_t major;  /*!< Major */
135     uint8_t minor;  /*!< Minor */
136     uint8_t bugfix; /*!< Bug fix */
137 } usb_version_t;
138
139 /*******************************************************************************
140  * API
141  ******************************************************************************/
142
143 /*! @} */
144
145 #endif /* __USB_H__ */