1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** USBX Component */
17 /** */
18 /** OHCI Controller Driver */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29 #include "ux_hcd_ohci.h"
30 #include "ux_host_stack.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_hcd_ohci_entry PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function dispatches the HCD function internally to the OHCI */
46 /* controller driver routines. */
47 /* */
48 /* INPUT */
49 /* */
50 /* HCD Pointer to HCD */
51 /* function Function for driver to perform*/
52 /* parameter Pointer to parameter(s) */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* Completion Status */
57 /* */
58 /* CALLS */
59 /* */
60 /* _ux_hcd_ohci_asynchronous_endpoint_create Create async endpoint */
61 /* _ux_hcd_ohci_asynchronous_endpoint_destroy Destroy async endpoint */
62 /* _ux_hcd_ohci_controller_disable Disable controller */
63 /* _ux_hcd_ohci_done_queue_process Process done queue */
64 /* _ux_hcd_ohci_endpoint_reset Reset endpoint */
65 /* _ux_hcd_ohci_frame_number_get Get frame number */
66 /* _ux_hcd_ohci_frame_number_set Set frame number */
67 /* _ux_hcd_ohci_interrupt_endpoint_create Create interrupt endpoint*/
68 /* _ux_hcd_ohci_isochronous_endpoint_create Create isoch endpoint */
69 /* _ux_hcd_ohci_periodic_endpoint_destroy Destroy periodic endpoint*/
70 /* _ux_hcd_ohci_port_enable Enable port */
71 /* _ux_hcd_ohci_port_disable Disable port */
72 /* _ux_hcd_ohci_port_reset Reset port */
73 /* _ux_hcd_ohci_port_resume Resume port */
74 /* _ux_hcd_ohci_port_status_get Get port status */
75 /* _ux_hcd_ohci_port_suspend Suspend port */
76 /* _ux_hcd_ohci_power_down_port Power down port */
77 /* _ux_hcd_ohci_power_on_port Power on port */
78 /* _ux_hcd_ohci_request_transfer Request transfer */
79 /* _ux_hcd_ohci_transfer_abort Abort transfer */
80 /* */
81 /* CALLED BY */
82 /* */
83 /* Host Stack */
84 /* */
85 /* RELEASE HISTORY */
86 /* */
87 /* DATE NAME DESCRIPTION */
88 /* */
89 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
90 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
91 /* resulting in version 6.1 */
92 /* */
93 /**************************************************************************/
_ux_hcd_ohci_entry(UX_HCD * hcd,UINT function,VOID * parameter)94 UINT _ux_hcd_ohci_entry(UX_HCD *hcd, UINT function, VOID *parameter)
95 {
96
97 UINT status;
98 UX_HCD_OHCI *hcd_ohci;
99
100
101 /* Check the status of the controller. */
102 if (hcd -> ux_hcd_status == UX_UNUSED)
103 {
104
105 /* Error trap. */
106 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_HCD, UX_CONTROLLER_UNKNOWN);
107
108 /* If trace is enabled, insert this event into the trace buffer. */
109 UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_CONTROLLER_UNKNOWN, 0, 0, 0, UX_TRACE_ERRORS, 0, 0)
110
111 return(UX_CONTROLLER_UNKNOWN);
112 }
113
114 /* Get the pointer to the OHCI HCD. */
115 hcd_ohci = (UX_HCD_OHCI *) hcd -> ux_hcd_controller_hardware;
116
117 /* look at the function and route it. */
118 switch(function)
119 {
120
121 case UX_HCD_DISABLE_CONTROLLER:
122
123 status = _ux_hcd_ohci_controller_disable(hcd_ohci);
124 break;
125
126
127 case UX_HCD_GET_PORT_STATUS:
128
129 status = _ux_hcd_ohci_port_status_get(hcd_ohci, (ULONG) parameter);
130 break;
131
132
133 case UX_HCD_ENABLE_PORT:
134
135 status = _ux_hcd_ohci_port_enable(hcd_ohci, (ULONG) parameter);
136 break;
137
138
139 case UX_HCD_DISABLE_PORT:
140
141 status = _ux_hcd_ohci_port_disable(hcd_ohci, (ULONG) parameter);
142 break;
143
144
145 case UX_HCD_POWER_ON_PORT:
146
147 status = _ux_hcd_ohci_power_on_port(hcd_ohci, (ULONG) parameter);
148 break;
149
150
151 case UX_HCD_POWER_DOWN_PORT:
152
153 status = _ux_hcd_ohci_power_down_port(hcd_ohci, (ULONG) parameter);
154 break;
155
156
157 case UX_HCD_SUSPEND_PORT:
158
159 status = _ux_hcd_ohci_port_suspend(hcd_ohci, (ULONG) parameter);
160 break;
161
162
163 case UX_HCD_RESUME_PORT:
164
165 status = _ux_hcd_ohci_port_resume(hcd_ohci, (UINT) parameter);
166 break;
167
168
169 case UX_HCD_RESET_PORT:
170
171 status = _ux_hcd_ohci_port_reset(hcd_ohci, (ULONG) parameter);
172 break;
173
174
175 case UX_HCD_GET_FRAME_NUMBER:
176
177 status = _ux_hcd_ohci_frame_number_get(hcd_ohci, (ULONG *) parameter);
178 break;
179
180
181 case UX_HCD_SET_FRAME_NUMBER:
182
183 _ux_hcd_ohci_frame_number_set(hcd_ohci, (ULONG) parameter);
184 status = UX_SUCCESS;
185 break;
186
187
188 case UX_HCD_TRANSFER_REQUEST:
189
190 status = _ux_hcd_ohci_request_transfer(hcd_ohci, (UX_TRANSFER *) parameter);
191 break;
192
193
194 case UX_HCD_TRANSFER_ABORT:
195
196 status = _ux_hcd_ohci_transfer_abort(hcd_ohci, (UX_TRANSFER *) parameter);
197 break;
198
199
200 case UX_HCD_CREATE_ENDPOINT:
201
202 switch ((((UX_ENDPOINT*) parameter) -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE)
203 {
204
205 case UX_CONTROL_ENDPOINT:
206 case UX_BULK_ENDPOINT:
207
208 status = _ux_hcd_ohci_asynchronous_endpoint_create(hcd_ohci, (UX_ENDPOINT*) parameter);
209 break;
210
211
212 case UX_INTERRUPT_ENDPOINT:
213
214 status = _ux_hcd_ohci_interrupt_endpoint_create(hcd_ohci, (UX_ENDPOINT*) parameter);
215 break;
216
217
218 case UX_ISOCHRONOUS_ENDPOINT:
219
220 status = _ux_hcd_ohci_isochronous_endpoint_create(hcd_ohci, (UX_ENDPOINT*) parameter);
221 break;
222
223 }
224 break;
225
226
227 case UX_HCD_DESTROY_ENDPOINT:
228
229 switch ((((UX_ENDPOINT*) parameter) -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE)
230 {
231
232 case UX_CONTROL_ENDPOINT:
233 case UX_BULK_ENDPOINT:
234
235 status = _ux_hcd_ohci_asynchronous_endpoint_destroy(hcd_ohci, (UX_ENDPOINT*) parameter);
236 break;
237
238 case UX_INTERRUPT_ENDPOINT:
239 case UX_ISOCHRONOUS_ENDPOINT:
240
241 status = _ux_hcd_ohci_periodic_endpoint_destroy(hcd_ohci, (UX_ENDPOINT*) parameter);
242 break;
243
244 }
245 break;
246
247
248 case UX_HCD_RESET_ENDPOINT:
249
250 status = _ux_hcd_ohci_endpoint_reset(hcd_ohci, (UX_ENDPOINT*) parameter);
251 break;
252
253
254 case UX_HCD_PROCESS_DONE_QUEUE:
255
256 _ux_hcd_ohci_done_queue_process(hcd_ohci);
257 status = UX_SUCCESS;
258 break;
259
260
261 default:
262
263 /* Error trap. */
264 _ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_HCD, UX_FUNCTION_NOT_SUPPORTED);
265
266 /* If trace is enabled, insert this event into the trace buffer. */
267 UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_FUNCTION_NOT_SUPPORTED, 0, 0, 0, UX_TRACE_ERRORS, 0, 0)
268
269 /* Set status to not supported. */
270 status = UX_FUNCTION_NOT_SUPPORTED;
271 }
272
273 /* Return completion status. */
274 return(status);
275 }
276
277