1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2026-present Eclipse ThreadX contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** USBX Component */
/** */
/** OHCI Controller Driver */
/** */
/**************************************************************************/
/**************************************************************************/
/* Include necessary system files. */
#define UX_SOURCE_CODE
#include "ux_api.h"
#include "ux_hcd_ohci.h"
#include "ux_host_stack.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _ux_hcd_ohci_port_status_get PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function will return the status for each port attached to the */
/* root HUB. */
/* */
/* INPUT */
/* */
/* hcd_ohci Pointer to OHCI controller */
/* port_index Port index */
/* */
/* OUTPUT */
/* */
/* port_status */
/* */
/* Status of the root HUB port with the following format: */
/* */
/* bit 0 device connection status */
/* if 0 : no device connected */
/* if 1 : device connected to the port */
/* bit 1 port enable status */
/* if 0 : port disabled */
/* if 1 : port enabled */
/* bit 2 port suspend status */
/* if 0 : port is not suspended */
/* if 1 : port is suspended */
/* bit 3 port overcurrent status */
/* if 0 : port has no overcurrent condition */
/* if 1 : port has overcurrent condition */
/* bit 4 port reset status */
/* if 0 : port is not in reset */
/* if 1 : port is in reset */
/* bit 5 port power status */
/* if 0 : port power is off */
/* if 1 : port power is on */
/* bit 6-7 device attached speed */
/* if 00 : low speed device attached */
/* if 01 : full speed device attached */
/* if 10 : high speed device attached */
/* */
/* CALLS */
/* */
/* _ux_hcd_ohci_register_read Read OHCI register */
/* */
/* CALLED BY */
/* */
/* OHCI Controller Driver */
/* */
/**************************************************************************/
ULONG _ux_hcd_ohci_port_status_get(UX_HCD_OHCI *hcd_ohci, ULONG port_index)
{
ULONG ohci_register_port_status;
ULONG port_status;
/* Check to see if this port is valid on this controller */
if (hcd_ohci -> ux_hcd_ohci_nb_root_hubs < port_index)
{
/* Error trap. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_HCD, UX_PORT_INDEX_UNKNOWN);
/* If trace is enabled, insert this event into the trace buffer. */
UX_TRACE_IN_LINE_INSERT(UX_TRACE_ERROR, UX_PORT_INDEX_UNKNOWN, port_index, 0, 0, UX_TRACE_ERRORS, 0, 0)
return(UX_PORT_INDEX_UNKNOWN);
}
/* The port is valid, build the status mask for this port. This function
returns a controller agnostic bit field. */
port_status = 0;
ohci_register_port_status = _ux_hcd_ohci_register_read(hcd_ohci, OHCI_HC_RH_PORT_STATUS + port_index);
/* Device Connection Status. */
if (ohci_register_port_status & OHCI_HC_PS_CCS)
port_status |= UX_PS_CCS;
/* Port Enable Status */
if (ohci_register_port_status & OHCI_HC_PS_PES)
port_status |= UX_PS_PES;
/* Port Suspend Status */
if (ohci_register_port_status & OHCI_HC_PS_PSS)
port_status |= UX_PS_PSS;
/* Port Overcurrent Status */
if (ohci_register_port_status & OHCI_HC_PS_POCI)
port_status |= UX_PS_POCI;
/* Port Reset Status */
if (ohci_register_port_status & OHCI_HC_PS_PRS)
port_status |= UX_PS_PRS;
/* Port Power Status */
if (ohci_register_port_status & OHCI_HC_PS_PPS)
port_status |= UX_PS_PPS;
/* Port Device Attached speed. This field is valid only if the CCS bit is active.
On OHCI, only low speed or full speed are available. */
if (ohci_register_port_status & OHCI_HC_PS_CCS)
{
if (ohci_register_port_status & OHCI_HC_PS_LSDA)
port_status |= UX_PS_DS_LS;
else
port_status |= UX_PS_DS_FS;
}
/* Return port status. */
return(port_status);
}
|