blob: 64a840b5106e51d7c3a3490b21a32cc3239cdff5 [file] [log] [blame]
Greg Kroah-Hartman5fd54ac2017-11-03 11:28:30 +01001// SPDX-License-Identifier: GPL-2.0
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +01002/*
3 * Wireless USB Wire Adapter constants and structures.
4 *
5 * Copyright (C) 2005-2006 Intel Corporation.
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * FIXME: docs
24 * FIXME: organize properly, group logically
25 *
26 * All the event structures are defined in uwb/spec.h, as they are
27 * common to the WHCI and WUSB radio control interfaces.
28 *
29 * References:
30 * [WUSB] Wireless Universal Serial Bus Specification, revision 1.0, ch8
31 */
32#ifndef __LINUX_USB_WUSB_WA_H
33#define __LINUX_USB_WUSB_WA_H
34
35/**
36 * Radio Command Request for the Radio Control Interface
37 *
38 * Radio Control Interface command and event codes are the same as
39 * WHCI, and listed in include/linux/uwb.h:UWB_RC_{CMD,EVT}_*
40 */
41enum {
42 WA_EXEC_RC_CMD = 40, /* Radio Control command Request */
43};
44
45/* Wireless Adapter Requests ([WUSB] table 8-51) */
46enum {
47 WUSB_REQ_ADD_MMC_IE = 20,
48 WUSB_REQ_REMOVE_MMC_IE = 21,
49 WUSB_REQ_SET_NUM_DNTS = 22,
50 WUSB_REQ_SET_CLUSTER_ID = 23,
51 WUSB_REQ_SET_DEV_INFO = 24,
52 WUSB_REQ_GET_TIME = 25,
53 WUSB_REQ_SET_STREAM_IDX = 26,
54 WUSB_REQ_SET_WUSB_MAS = 27,
David Vrabel4d2bea42008-10-27 15:42:31 +000055 WUSB_REQ_CHAN_STOP = 28,
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +010056};
57
58
59/* Wireless Adapter WUSB Channel Time types ([WUSB] table 8-52) */
60enum {
61 WUSB_TIME_ADJ = 0,
62 WUSB_TIME_BPST = 1,
63 WUSB_TIME_WUSB = 2,
64};
65
66enum {
67 WA_ENABLE = 0x01,
68 WA_RESET = 0x02,
69 RPIPE_PAUSE = 0x1,
Thomas Pugliese6d33f7b2013-08-15 12:21:30 -050070 RPIPE_STALL = 0x2,
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +010071};
72
73/* Responses from Get Status request ([WUSB] section 8.3.1.6) */
74enum {
75 WA_STATUS_ENABLED = 0x01,
76 WA_STATUS_RESETTING = 0x02
77};
78
79enum rpipe_crs {
80 RPIPE_CRS_CTL = 0x01,
81 RPIPE_CRS_ISO = 0x02,
82 RPIPE_CRS_BULK = 0x04,
83 RPIPE_CRS_INTR = 0x08
84};
85
86/**
87 * RPipe descriptor ([WUSB] section 8.5.2.11)
88 *
89 * FIXME: explain rpipes
90 */
91struct usb_rpipe_descriptor {
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070092 u8 bLength;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +010093 u8 bDescriptorType;
94 __le16 wRPipeIndex;
95 __le16 wRequests;
96 __le16 wBlocks; /* rw if 0 */
Thomas Puglieseee0218f2013-06-06 14:06:01 -050097 __le16 wMaxPacketSize; /* rw */
98 union {
99 u8 dwa_bHSHubAddress; /* rw: DWA. */
100 u8 hwa_bMaxBurst; /* rw: HWA. */
101 };
102 union {
103 u8 dwa_bHSHubPort; /* rw: DWA. */
104 u8 hwa_bDeviceInfoIndex; /* rw: HWA. */
105 };
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100106 u8 bSpeed; /* rw: xfer rate 'enum uwb_phy_rate' */
Thomas Puglieseee0218f2013-06-06 14:06:01 -0500107 union {
108 u8 dwa_bDeviceAddress; /* rw: DWA Target device address. */
109 u8 hwa_reserved; /* rw: HWA. */
110 };
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100111 u8 bEndpointAddress; /* rw: Target EP address */
112 u8 bDataSequence; /* ro: Current Data sequence */
113 __le32 dwCurrentWindow; /* ro */
114 u8 bMaxDataSequence; /* ro?: max supported seq */
115 u8 bInterval; /* rw: */
116 u8 bOverTheAirInterval; /* rw: */
117 u8 bmAttribute; /* ro? */
118 u8 bmCharacteristics; /* ro? enum rpipe_attr, supported xsactions */
119 u8 bmRetryOptions; /* rw? */
120 __le16 wNumTransactionErrors; /* rw */
121} __attribute__ ((packed));
122
123/**
124 * Wire Adapter Notification types ([WUSB] sections 8.4.5 & 8.5.4)
125 *
126 * These are the notifications coming on the notification endpoint of
127 * an HWA and a DWA.
128 */
129enum wa_notif_type {
130 DWA_NOTIF_RWAKE = 0x91,
131 DWA_NOTIF_PORTSTATUS = 0x92,
132 WA_NOTIF_TRANSFER = 0x93,
133 HWA_NOTIF_BPST_ADJ = 0x94,
134 HWA_NOTIF_DN = 0x95,
135};
136
137/**
138 * Wire Adapter notification header
139 *
140 * Notifications coming from a wire adapter use a common header
141 * defined in [WUSB] sections 8.4.5 & 8.5.4.
142 */
143struct wa_notif_hdr {
144 u8 bLength;
145 u8 bNotifyType; /* enum wa_notif_type */
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500146} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100147
148/**
149 * HWA DN Received notification [(WUSB] section 8.5.4.2)
150 *
151 * The DNData is specified in WUSB1.0[7.6]. For each device
152 * notification we received, we just need to dispatch it.
153 *
154 * @dndata: this is really an array of notifications, but all start
155 * with the same header.
156 */
157struct hwa_notif_dn {
158 struct wa_notif_hdr hdr;
159 u8 bSourceDeviceAddr; /* from errata 2005/07 */
160 u8 bmAttributes;
161 struct wusb_dn_hdr dndata[];
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500162} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100163
164/* [WUSB] section 8.3.3 */
165enum wa_xfer_type {
166 WA_XFER_TYPE_CTL = 0x80,
167 WA_XFER_TYPE_BI = 0x81, /* bulk/interrupt */
168 WA_XFER_TYPE_ISO = 0x82,
169 WA_XFER_RESULT = 0x83,
170 WA_XFER_ABORT = 0x84,
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500171 WA_XFER_ISO_PACKET_INFO = 0xA0,
172 WA_XFER_ISO_PACKET_STATUS = 0xA1,
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100173};
174
175/* [WUSB] section 8.3.3 */
176struct wa_xfer_hdr {
177 u8 bLength; /* 0x18 */
178 u8 bRequestType; /* 0x80 WA_REQUEST_TYPE_CTL */
179 __le16 wRPipe; /* RPipe index */
180 __le32 dwTransferID; /* Host-assigned ID */
181 __le32 dwTransferLength; /* Length of data to xfer */
182 u8 bTransferSegment;
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500183} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100184
185struct wa_xfer_ctl {
186 struct wa_xfer_hdr hdr;
187 u8 bmAttribute;
188 __le16 wReserved;
189 struct usb_ctrlrequest baSetupData;
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500190} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100191
192struct wa_xfer_bi {
193 struct wa_xfer_hdr hdr;
194 u8 bReserved;
195 __le16 wReserved;
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500196} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100197
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500198/* [WUSB] section 8.5.5 */
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100199struct wa_xfer_hwaiso {
200 struct wa_xfer_hdr hdr;
201 u8 bReserved;
202 __le16 wPresentationTime;
203 __le32 dwNumOfPackets;
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500204} __packed;
205
206struct wa_xfer_packet_info_hwaiso {
207 __le16 wLength;
208 u8 bPacketType;
209 u8 bReserved;
210 __le16 PacketLength[0];
211} __packed;
212
213struct wa_xfer_packet_status_len_hwaiso {
214 __le16 PacketLength;
215 __le16 PacketStatus;
216} __packed;
217
218struct wa_xfer_packet_status_hwaiso {
219 __le16 wLength;
220 u8 bPacketType;
221 u8 bReserved;
222 struct wa_xfer_packet_status_len_hwaiso PacketStatus[0];
223} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100224
225/* [WUSB] section 8.3.3.5 */
226struct wa_xfer_abort {
227 u8 bLength;
228 u8 bRequestType;
229 __le16 wRPipe; /* RPipe index */
230 __le32 dwTransferID; /* Host-assigned ID */
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500231} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100232
233/**
234 * WA Transfer Complete notification ([WUSB] section 8.3.3.3)
235 *
236 */
237struct wa_notif_xfer {
238 struct wa_notif_hdr hdr;
239 u8 bEndpoint;
240 u8 Reserved;
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500241} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100242
243/** Transfer result basic codes [WUSB] table 8-15 */
244enum {
245 WA_XFER_STATUS_SUCCESS,
246 WA_XFER_STATUS_HALTED,
247 WA_XFER_STATUS_DATA_BUFFER_ERROR,
248 WA_XFER_STATUS_BABBLE,
249 WA_XFER_RESERVED,
250 WA_XFER_STATUS_NOT_FOUND,
251 WA_XFER_STATUS_INSUFFICIENT_RESOURCE,
252 WA_XFER_STATUS_TRANSACTION_ERROR,
253 WA_XFER_STATUS_ABORTED,
254 WA_XFER_STATUS_RPIPE_NOT_READY,
255 WA_XFER_INVALID_FORMAT,
256 WA_XFER_UNEXPECTED_SEGMENT_NUMBER,
257 WA_XFER_STATUS_RPIPE_TYPE_MISMATCH,
258};
259
260/** [WUSB] section 8.3.3.4 */
261struct wa_xfer_result {
262 struct wa_notif_hdr hdr;
263 __le32 dwTransferID;
264 __le32 dwTransferLength;
265 u8 bTransferSegment;
266 u8 bTransferStatus;
267 __le32 dwNumOfPackets;
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500268} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100269
270/**
271 * Wire Adapter Class Descriptor ([WUSB] section 8.5.2.7).
272 *
273 * NOTE: u16 fields are read Little Endian from the hardware.
274 *
275 * @bNumPorts is the original max number of devices that the host can
276 * connect; we might chop this so the stack can handle
277 * it. In case you need to access it, use wusbhc->ports_max
278 * if it is a Wireless USB WA.
279 */
280struct usb_wa_descriptor {
281 u8 bLength;
282 u8 bDescriptorType;
Thomas Pugliese1653d2f2013-10-07 10:07:51 -0500283 __le16 bcdWAVersion;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100284 u8 bNumPorts; /* don't use!! */
285 u8 bmAttributes; /* Reserved == 0 */
Thomas Pugliese1653d2f2013-10-07 10:07:51 -0500286 __le16 wNumRPipes;
287 __le16 wRPipeMaxBlock;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100288 u8 bRPipeBlockSize;
289 u8 bPwrOn2PwrGood;
290 u8 bNumMMCIEs;
291 u8 DeviceRemovable; /* FIXME: in DWA this is up to 16 bytes */
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500292} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100293
294/**
295 * HWA Device Information Buffer (WUSB1.0[T8.54])
296 */
297struct hwa_dev_info {
298 u8 bmDeviceAvailability[32]; /* FIXME: ignored for now */
299 u8 bDeviceAddress;
300 __le16 wPHYRates;
301 u8 bmDeviceAttribute;
Thomas Pugliese4ae1a5b2013-10-01 14:04:35 -0500302} __packed;
Inaky Perez-Gonzalezc7f73642008-09-17 16:34:22 +0100303
304#endif /* #ifndef __LINUX_USB_WUSB_WA_H */