NetBurner 3.5.7
PDF Version
usb_host_ehci.h
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016,2019 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _USB_HOST_CONTROLLER_EHCI_H_
10#define _USB_HOST_CONTROLLER_EHCI_H_
11
12/*******************************************************************************
13 * KHCI private public structures, enumerations, macros, functions
14 ******************************************************************************/
15
16/*******************************************************************************
17 * Definitions
18 ******************************************************************************/
19/* EHCI host macros */
20#define EHCI_HOST_T_INVALID_VALUE (1U)
21#define EHCI_HOST_POINTER_TYPE_ITD (0x00U)
22#define EHCI_HOST_POINTER_TYPE_QH (0x00000002U)
23#define EHCI_HOST_POINTER_TYPE_SITD (0x00000004U)
24#define EHCI_HOST_POINTER_TYPE_FSTN (0x00000006U)
25#define EHCI_HOST_POINTER_TYPE_MASK (0x00000006U)
26#define EHCI_HOST_POINTER_ADDRESS_MASK (0xFFFFFFE0U)
27#define EHCI_HOST_PID_OUT (0UL)
28#define EHCI_HOST_PID_IN (1UL)
29#define EHCI_HOST_PID_SETUP (2UL)
30
31#define EHCI_HOST_QH_RL_SHIFT (28U)
32#define EHCI_HOST_QH_RL_MASK (0xF0000000U)
33#define EHCI_HOST_QH_C_SHIFT (27U)
34#define EHCI_HOST_QH_MAX_PACKET_LENGTH_SHIFT (16U)
35#define EHCI_HOST_QH_MAX_PACKET_LENGTH_MASK (0x07FF0000U)
36#define EHCI_HOST_QH_H_SHIFT (15U)
37#define EHCI_HOST_QH_DTC_SHIFT (14U)
38#define EHCI_HOST_QH_EPS_SHIFT (12U)
39#define EHCI_HOST_QH_ENDPT_SHIFT (8U)
40#define EHCI_HOST_QH_I_SHIFT (7U)
41#define EHCI_HOST_QH_DEVICE_ADDRESS_SHIFT (0U)
42#define EHCI_HOST_QH_MULT_SHIFT (30U)
43#define EHCI_HOST_QH_PORT_NUMBER_SHIFT (23U)
44#define EHCI_HOST_QH_HUB_ADDR_SHIFT (16U)
45#define EHCI_HOST_QH_UFRAME_CMASK_SHIFT (8U)
46#define EHCI_HOST_QH_UFRAME_SMASK_SHIFT (0U)
47#define EHCI_HOST_QH_STATUS_ERROR_MASK (0x0000007EU)
48#define EHCI_HOST_QH_STATUS_NOSTALL_ERROR_MASK (0x0000003EU)
49
50#define EHCI_HOST_QTD_DT_SHIFT (31U)
51#define EHCI_HOST_QTD_DT_MASK (0x80000000U)
52#define EHCI_HOST_QTD_TOTAL_BYTES_SHIFT (16U)
53#define EHCI_HOST_QTD_TOTAL_BYTES_MASK (0x7FFF0000U)
54#define EHCI_HOST_QTD_IOC_MASK (0x00008000U)
55#define EHCI_HOST_QTD_C_PAGE_SHIFT (12U)
56#define EHCI_HOST_QTD_CERR_SHIFT (10U)
57#define EHCI_HOST_QTD_CERR_MAX_VALUE (0x00000003UL)
58#define EHCI_HOST_QTD_PID_CODE_SHIFT (8U)
59#define EHCI_HOST_QTD_STATUS_SHIFT (0U)
60#define EHCI_HOST_QTD_CURRENT_OFFSET_MASK (0x00000FFFU)
61#define EHCI_HOST_QTD_BUFFER_POINTER_SHIFT (12U)
62#define EHCI_HOST_QTD_STATUS_ACTIVE_MASK (0x00000080U)
63#define EHCI_HOST_QTD_STATUS_MASK (0x000000ffU)
64#define EHCI_HOST_QTD_STATUS_ERROR_MASK (0x0000007EU)
65#define EHCI_HOST_QTD_STATUS_STALL_ERROR_MASK (0x00000040U)
66
67#define EHCI_HOST_ITD_STATUS_ACTIVE_MASK (0x80000000U)
68#define EHCI_HOST_ITD_TRANSACTION_LEN_SHIFT (16U)
69#define EHCI_HOST_ITD_TRANSACTION_LEN_MASK (0x0FFF0000U)
70#define EHCI_HOST_ITD_IOC_SHIFT (15U)
71#define EHCI_HOST_ITD_PG_SHIFT (12U)
72#define EHCI_HOST_ITD_TRANSACTION_OFFSET_SHIFT (0U)
73#define EHCI_HOST_ITD_TRANSACTION_OFFSET_MASK (0x00000FFFU)
74#define EHCI_HOST_ITD_BUFFER_POINTER_SHIFT (12U)
75#define EHCI_HOST_ITD_ENDPT_SHIFT (8U)
76#define EHCI_HOST_ITD_DEVICE_ADDRESS_SHIFT (0U)
77#define EHCI_HOST_ITD_MAX_PACKET_SIZE_SHIFT (0U)
78#define EHCI_HOST_ITD_MULT_SHIFT (0U)
79#define EHCI_HOST_ITD_DIRECTION_SHIFT (11U)
80
81#define EHCI_HOST_SITD_STATUS_ACTIVE_MASK (0x00000080U)
82#define EHCI_HOST_SITD_DIRECTION_SHIFT (31U)
83#define EHCI_HOST_SITD_PORT_NUMBER_SHIFT (24U)
84#define EHCI_HOST_SITD_HUB_ADDR_SHIFT (16U)
85#define EHCI_HOST_SITD_ENDPT_SHIFT (8U)
86#define EHCI_HOST_SITD_DEVICE_ADDRESS_SHIFT (0U)
87#define EHCI_HOST_SITD_CMASK_SHIFT (8U)
88#define EHCI_HOST_SITD_SMASK_SHIFT (0U)
89#define EHCI_HOST_SITD_TOTAL_BYTES_SHIFT (16U)
90#define EHCI_HOST_SITD_TOTAL_BYTES_MASK (0x03FF0000U)
91#define EHCI_HOST_SITD_TP_SHIFT (3U)
92#define EHCI_HOST_SITD_TCOUNT_SHIFT (0U)
93#define EHCI_HOST_SITD_IOC_SHIFT (31U)
94
95/* register related MACROs */
96#define EHCI_PORTSC1_W1_BITS (0x0000002AU)
97#define EHCI_MAX_UFRAME_VALUE (0x00003FFFU)
98
99/* task event */
100#define EHCI_TASK_EVENT_DEVICE_ATTACH (0x01U)
101#define EHCI_TASK_EVENT_TRANSACTION_DONE (0x02U)
102#define EHCI_TASK_EVENT_DEVICE_DETACH (0x04U)
103#define EHCI_TASK_EVENT_PORT_CHANGE (0x08U)
104#define EHCI_TASK_EVENT_TIMER0 (0x10U)
105#define EHCI_TASK_EVENT_TIMER1 (0x20U)
106#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
107#if ((defined(USB_HOST_CONFIG_LPM_L1)) && (USB_HOST_CONFIG_LPM_L1 > 0U))
108#define EHCI_TASK_EVENT_HOST_COMPLETED_LPM (0x40U)
109#endif
110#endif
111
112#define USB_HostEhciLock() (void)OSA_MutexLock(ehciInstance->ehciMutex, USB_OSA_WAIT_TIMEOUT)
113#define USB_HostEhciUnlock() (void)OSA_MutexUnlock(ehciInstance->ehciMutex)
114
115/*******************************************************************************
116 * KHCI driver public structures, enumerations, macros, functions
117 ******************************************************************************/
118
125#define USB_HOST_EHCI_ISO_NUMBER USB_HOST_CONFIG_EHCI_MAX_ITD
127#define USB_HOST_EHCI_PORT_CONNECT_DEBOUNCE_DELAY (101U)
129#define USB_HOST_EHCI_PORT_RESET_DELAY (11U)
131#define USB_HOST_EHCI_ISO_MAX_CONTINUOUS_TRANSFER (8U)
144#define USB_HOST_EHCI_ISO_BOUNCE_FRAME_NUMBER (2U)
157#define USB_HOST_EHCI_ISO_BOUNCE_UFRAME_NUMBER (16U)
159#define USB_HOST_EHCI_CONTROL_BULK_TIME_OUT_VALUE (50U)
160
161#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
162typedef enum _bus_ehci_suspend_request_state
163{
164 kBus_EhciIdle = 0U,
165 kBus_EhciStartSuspend,
166 kBus_EhciSuspended,
167 kBus_EhciStartResume,
168 kBus_EhciL1StartSleep,
169 kBus_EhciL1Sleeped,
170 kBus_EhciL1StartResume,
171 kBus_EhciHsError,
172} bus_ehci_suspend_request_state_t;
173#endif
174
182
225
246
255
257typedef struct _usb_host_ehci_itd
258{
260 uint32_t transactions[8];
261 uint32_t bufferPointers[7];
263 /* add space */
266 uint32_t reserved[6];
268
271{
273 uint32_t endpointStates[2];
274 uint32_t transferResults[3];
275 uint32_t backPointer;
277 /* reserved space */
281 uint8_t reserved;
283
296
299{
301 uint32_t *ehciUnitBase;
302 uint8_t *ehciFrameList;
310 USBHS_Type *ehciIpBase;
315 osa_mutex_handle_t ehciMutex;
316 uint32_t mutexBuffer[(OSA_MUTEX_HANDLE_SIZE + 3) / 4];
317 osa_event_handle_t taskEventHandle;
318 uint32_t taskEventHandleBuffer[(OSA_EVENT_HANDLE_SIZE + 3) / 4];
319#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
320 uint64_t matchTick;
321#if ((defined FSL_FEATURE_SOC_USBPHY_COUNT) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U))
322 USBPHY_Type *registerPhyBase;
323#endif
324#if (defined(FSL_FEATURE_SOC_USBNC_COUNT) && (FSL_FEATURE_SOC_USBNC_COUNT > 0U))
325 USBNC_Type *registerNcBase;
326#endif
327
328#endif
329 uint8_t controllerId;
335#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
336#if ((defined(USB_HOST_CONFIG_LPM_L1)) && (USB_HOST_CONFIG_LPM_L1 > 0U))
337 uint8_t hirdValue;
338 uint8_t L1remoteWakeupEnable;
339#endif
340 bus_ehci_suspend_request_state_t busSuspendStatus;
341#endif
343
346{
347#if ((defined(USB_HOST_CONFIG_EHCI_MAX_QH)) && (USB_HOST_CONFIG_EHCI_MAX_QH > 0U))
348 usb_host_ehci_qh_t ehciQh[USB_HOST_CONFIG_EHCI_MAX_QH];
349#endif
350#if ((defined(USB_HOST_CONFIG_EHCI_MAX_QTD)) && (USB_HOST_CONFIG_EHCI_MAX_QTD > 0U))
351 usb_host_ehci_qtd_t ehciQtd[USB_HOST_CONFIG_EHCI_MAX_QTD];
352#endif
353#if ((defined(USB_HOST_CONFIG_EHCI_MAX_ITD)) && (USB_HOST_CONFIG_EHCI_MAX_ITD > 0U))
354 usb_host_ehci_itd_t ehciItd[USB_HOST_CONFIG_EHCI_MAX_ITD];
355 /* add additional 32bytes because the itd cannot cross over 4K boundary,
356 * If one ITD cross over 4K boundary, the code will move 32 bytes for ITD.
357 */
358 uint32_t reserved[8];
359#endif
360#if ((defined(USB_HOST_CONFIG_EHCI_MAX_SITD)) && (USB_HOST_CONFIG_EHCI_MAX_SITD > 0U))
361 usb_host_ehci_sitd_t ehciSitd[USB_HOST_CONFIG_EHCI_MAX_SITD];
362#endif
363#if ((defined(USB_HOST_EHCI_ISO_NUMBER)) && (USB_HOST_EHCI_ISO_NUMBER > 0U))
365#endif
366#if ((defined(USB_HOST_CONFIG_MAX_PIPES)) && (USB_HOST_CONFIG_MAX_PIPES > 0U))
367 usb_host_ehci_pipe_t ehciPipe[USB_HOST_CONFIG_MAX_PIPES];
368#endif
370
371/*******************************************************************************
372 * API
373 ******************************************************************************/
374
375#ifdef __cplusplus
376extern "C" {
377#endif
397extern usb_status_t USB_HostEhciCreate(uint8_t controllerId,
398 usb_host_handle upperLayerHandle,
399 usb_host_controller_handle *controllerHandle);
400
411
427 usb_host_pipe_handle *pipeHandle,
428 usb_host_pipe_init_t *pipeInit);
429
441
456 usb_host_pipe_handle pipeHandle,
457 usb_host_transfer_t *transfer);
458
473 usb_host_pipe_handle pipeHandle,
474 usb_host_transfer_t *transfer);
475
489 uint32_t ioctlEvent,
490 void *ioctlParam);
491
494#ifdef __cplusplus
495}
496#endif
497
500#endif /* _USB_HOST_CONTROLLER_EHCI_H_ */
enum _usb_status usb_status_t
USB error code.
void * usb_host_handle
USB host handle type define.
Definition nxp_usb.h:70
struct _usb_host_ehci_itd usb_host_ehci_itd_t
EHCI ITD structure. See the USB EHCI specification.
struct _usb_host_ehci_pipe usb_host_ehci_pipe_t
EHCI pipe structure.
usb_status_t USB_HostEhciIoctl(usb_host_controller_handle controllerHandle, uint32_t ioctlEvent, void *ioctlParam)
Controls the EHCI.
#define USB_HOST_EHCI_ISO_NUMBER
The maximum supported ISO pipe number.
Definition usb_host_ehci.h:125
_host_ehci_device_state_
EHCI state for device attachment/detachment.
Definition usb_host_ehci.h:177
usb_status_t USB_HostEhciCreate(uint8_t controllerId, usb_host_handle upperLayerHandle, usb_host_controller_handle *controllerHandle)
Creates the USB host EHCI instance.
struct _usb_host_ehci_sitd usb_host_ehci_sitd_t
EHCI SITD structure. See the USB EHCI specification.
struct _usb_host_ehci_instance usb_host_ehci_instance_t
EHCI instance structure.
usb_status_t USB_HostEhciDestory(usb_host_controller_handle controllerHandle)
Destroys the USB host EHCI instance.
struct _usb_host_ehci_data usb_host_ehci_data_t
EHCI data structure.
enum _host_ehci_device_state_ host_ehci_device_state_t
EHCI state for device attachment/detachment.
usb_status_t USB_HostEhciReadpipe(usb_host_controller_handle controllerHandle, usb_host_pipe_handle pipeHandle, usb_host_transfer_t *transfer)
Receives data from the pipe.
usb_status_t USB_HostEhciWritePipe(usb_host_controller_handle controllerHandle, usb_host_pipe_handle pipeHandle, usb_host_transfer_t *transfer)
Sends data to the pipe.
struct _usb_host_ehci_qtd usb_host_ehci_qtd_t
EHCI QTD structure. See the USB EHCI specification.
usb_status_t USB_HostEhciOpenPipe(usb_host_controller_handle controllerHandle, usb_host_pipe_handle *pipeHandle, usb_host_pipe_init_t *pipeInit)
Opens the USB host pipe.
struct _usb_host_ehci_qh usb_host_ehci_qh_t
EHCI QH structure. See the USB EHCI specification.
usb_status_t USB_HostEhciClosePipe(usb_host_controller_handle controllerHandle, usb_host_pipe_handle pipeHandle)
Closes the USB host pipe.
struct _usb_host_ehci_iso usb_host_ehci_iso_t
EHCI ISO structure; An ISO pipe has an instance of this structure to keep the ISO pipe-specific infor...
@ kEHCIDevicePhyAttached
Definition usb_host_ehci.h:178
@ kEHCIDeviceAttached
Definition usb_host_ehci.h:179
@ kEHCIDeviceDetached
Definition usb_host_ehci.h:180
void * usb_host_controller_handle
USB host controller handle type define.
Definition usb_host.h:31
void * usb_host_pipe_handle
USB host pipe handle type define.
Definition usb_host.h:40
EHCI data structure.
Definition usb_host_ehci.h:346
EHCI instance structure.
Definition usb_host_ehci.h:299
usb_host_ehci_qtd_t * ehciQtdHead
Definition usb_host_ehci.h:304
uint32_t mutexBuffer[(OSA_MUTEX_HANDLE_SIZE+3)/4]
Definition usb_host_ehci.h:316
uint8_t ehciSitdNumber
Definition usb_host_ehci.h:333
uint8_t deviceAttached
Definition usb_host_ehci.h:330
usb_host_ehci_qtd_t * ehciQtdTail
Definition usb_host_ehci.h:305
uint8_t * ehciFrameList
Definition usb_host_ehci.h:302
osa_event_handle_t taskEventHandle
Definition usb_host_ehci.h:317
osa_mutex_handle_t ehciMutex
Definition usb_host_ehci.h:315
usb_host_ehci_pipe_t * ehciPipeList
Definition usb_host_ehci.h:313
uint32_t taskEventHandleBuffer[(OSA_EVENT_HANDLE_SIZE+3)/4]
Definition usb_host_ehci.h:318
usb_host_ehci_sitd_t * ehciSitdList
Definition usb_host_ehci.h:308
usb_host_handle hostHandle
Definition usb_host_ehci.h:300
usb_host_ehci_qh_t * shedFirstQh
Definition usb_host_ehci.h:311
usb_host_ehci_iso_t * ehciIsoList
Definition usb_host_ehci.h:309
usb_host_ehci_qh_t * ehciQhList
Definition usb_host_ehci.h:303
usb_host_ehci_pipe_t * ehciPipeIndexBase
Definition usb_host_ehci.h:312
usb_host_ehci_sitd_t * ehciSitdIndexBase
Definition usb_host_ehci.h:307
USBHS_Type * ehciIpBase
Definition usb_host_ehci.h:310
uint8_t ehciQtdNumber
Definition usb_host_ehci.h:334
uint8_t controllerId
Definition usb_host_ehci.h:329
uint8_t firstDeviceSpeed
Definition usb_host_ehci.h:331
usb_host_ehci_itd_t * ehciItdList
Definition usb_host_ehci.h:306
uint8_t ehciItdNumber
Definition usb_host_ehci.h:332
uint32_t * ehciUnitBase
Definition usb_host_ehci.h:301
usb_host_ehci_pipe_t * ehciRunningPipeList
Definition usb_host_ehci.h:314
EHCI ISO structure; An ISO pipe has an instance of this structure to keep the ISO pipe-specific infor...
Definition usb_host_ehci.h:287
usb_host_pipe_t * ehciPipePointer
Definition usb_host_ehci.h:289
usb_host_transfer_t * ehciTransferHead
Definition usb_host_ehci.h:290
usb_host_transfer_t * ehciTransferTail
Definition usb_host_ehci.h:291
uint16_t lastLinkFrame
Definition usb_host_ehci.h:293
struct _usb_host_ehci_iso * next
Definition usb_host_ehci.h:288
EHCI ITD structure. See the USB EHCI specification.
Definition usb_host_ehci.h:258
uint32_t transactions[8]
Definition usb_host_ehci.h:260
uint32_t reserved[6]
Definition usb_host_ehci.h:266
struct _usb_host_ehci_itd * nextItdPointer
Definition usb_host_ehci.h:264
uint32_t frameEntryIndex
Definition usb_host_ehci.h:265
uint32_t nextLinkPointer
Definition usb_host_ehci.h:259
uint32_t bufferPointers[7]
Definition usb_host_ehci.h:261
EHCI pipe structure.
Definition usb_host_ehci.h:185
usb_host_pipe_t pipeCommon
Definition usb_host_ehci.h:186
uint8_t uframeCmask
Definition usb_host_ehci.h:219
void * ehciQh
Definition usb_host_ehci.h:187
uint16_t completeSplitTime
Definition usb_host_ehci.h:205
uint8_t uframeSmask
Definition usb_host_ehci.h:212
uint8_t startUframe
Definition usb_host_ehci.h:209
uint16_t dataTime
Definition usb_host_ehci.h:194
uint16_t startFrame
Definition usb_host_ehci.h:191
uint16_t startSplitTime
Definition usb_host_ehci.h:201
uint16_t uframeInterval
Definition usb_host_ehci.h:190
EHCI QH structure. See the USB EHCI specification.
Definition usb_host_ehci.h:228
usb_host_ehci_pipe_t * ehciPipePointer
Definition usb_host_ehci.h:239
uint32_t nextQtdPointer
Definition usb_host_ehci.h:233
uint32_t horizontalLinkPointer
Definition usb_host_ehci.h:229
uint32_t currentQtdPointer
Definition usb_host_ehci.h:232
uint16_t timeOutValue
Definition usb_host_ehci.h:242
usb_host_transfer_t * ehciTransferHead
Definition usb_host_ehci.h:240
uint32_t transferOverlayResults[6]
Definition usb_host_ehci.h:236
uint32_t staticEndpointStates[2]
Definition usb_host_ehci.h:231
uint32_t alternateNextQtdPointer
Definition usb_host_ehci.h:234
usb_host_transfer_t * ehciTransferTail
Definition usb_host_ehci.h:241
uint16_t timeOutLabel
Definition usb_host_ehci.h:244
EHCI QTD structure. See the USB EHCI specification.
Definition usb_host_ehci.h:249
uint32_t alternateNextQtdPointer
Definition usb_host_ehci.h:251
uint32_t bufferPointers[4]
Definition usb_host_ehci.h:253
uint32_t transferResults[2]
Definition usb_host_ehci.h:252
uint32_t nextQtdPointer
Definition usb_host_ehci.h:250
EHCI SITD structure. See the USB EHCI specification.
Definition usb_host_ehci.h:271
uint16_t frameEntryIndex
Definition usb_host_ehci.h:278
uint32_t endpointStates[2]
Definition usb_host_ehci.h:273
uint8_t nextSitdIndex
Definition usb_host_ehci.h:279
uint8_t reserved
Definition usb_host_ehci.h:281
uint32_t nextLinkPointer
Definition usb_host_ehci.h:272
uint32_t backPointer
Definition usb_host_ehci.h:275
uint32_t transferResults[3]
Definition usb_host_ehci.h:274
USB host pipe information structure for opening pipe.
Definition usb_host.h:272
USB host pipe common structure.
Definition usb_host.h:224
USB host transfer structure.
Definition usb_host.h:241