1 // SPDX-License-Identifier: GPL-2.0 2 /* 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 */ 41 enum { 42 WA_EXEC_RC_CMD = 40, /* Radio Control command Request */ 43 }; 44 45 /* Wireless Adapter Requests ([WUSB] table 8-51) */ 46 enum { 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, 55 WUSB_REQ_CHAN_STOP = 28, 56 }; 57 58 59 /* Wireless Adapter WUSB Channel Time types ([WUSB] table 8-52) */ 60 enum { 61 WUSB_TIME_ADJ = 0, 62 WUSB_TIME_BPST = 1, 63 WUSB_TIME_WUSB = 2, 64 }; 65 66 enum { 67 WA_ENABLE = 0x01, 68 WA_RESET = 0x02, 69 RPIPE_PAUSE = 0x1, 70 RPIPE_STALL = 0x2, 71 }; 72 73 /* Responses from Get Status request ([WUSB] section 8.3.1.6) */ 74 enum { 75 WA_STATUS_ENABLED = 0x01, 76 WA_STATUS_RESETTING = 0x02 77 }; 78 79 enum 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 */ 91 struct usb_rpipe_descriptor { 92 u8 bLength; 93 u8 bDescriptorType; 94 __le16 wRPipeIndex; 95 __le16 wRequests; 96 __le16 wBlocks; /* rw if 0 */ 97 __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 }; 106 u8 bSpeed; /* rw: xfer rate 'enum uwb_phy_rate' */ 107 union { 108 u8 dwa_bDeviceAddress; /* rw: DWA Target device address. */ 109 u8 hwa_reserved; /* rw: HWA. */ 110 }; 111 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 */ 129 enum 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 */ 143 struct wa_notif_hdr { 144 u8 bLength; 145 u8 bNotifyType; /* enum wa_notif_type */ 146 } __packed; 147 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 */ 157 struct 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[]; 162 } __packed; 163 164 /* [WUSB] section 8.3.3 */ 165 enum 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, 171 WA_XFER_ISO_PACKET_INFO = 0xA0, 172 WA_XFER_ISO_PACKET_STATUS = 0xA1, 173 }; 174 175 /* [WUSB] section 8.3.3 */ 176 struct 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; 183 } __packed; 184 185 struct wa_xfer_ctl { 186 struct wa_xfer_hdr hdr; 187 u8 bmAttribute; 188 __le16 wReserved; 189 struct usb_ctrlrequest baSetupData; 190 } __packed; 191 192 struct wa_xfer_bi { 193 struct wa_xfer_hdr hdr; 194 u8 bReserved; 195 __le16 wReserved; 196 } __packed; 197 198 /* [WUSB] section 8.5.5 */ 199 struct wa_xfer_hwaiso { 200 struct wa_xfer_hdr hdr; 201 u8 bReserved; 202 __le16 wPresentationTime; 203 __le32 dwNumOfPackets; 204 } __packed; 205 206 struct wa_xfer_packet_info_hwaiso { 207 __le16 wLength; 208 u8 bPacketType; 209 u8 bReserved; 210 __le16 PacketLength[0]; 211 } __packed; 212 213 struct wa_xfer_packet_status_len_hwaiso { 214 __le16 PacketLength; 215 __le16 PacketStatus; 216 } __packed; 217 218 struct 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; 224 225 /* [WUSB] section 8.3.3.5 */ 226 struct wa_xfer_abort { 227 u8 bLength; 228 u8 bRequestType; 229 __le16 wRPipe; /* RPipe index */ 230 __le32 dwTransferID; /* Host-assigned ID */ 231 } __packed; 232 233 /** 234 * WA Transfer Complete notification ([WUSB] section 8.3.3.3) 235 * 236 */ 237 struct wa_notif_xfer { 238 struct wa_notif_hdr hdr; 239 u8 bEndpoint; 240 u8 Reserved; 241 } __packed; 242 243 /** Transfer result basic codes [WUSB] table 8-15 */ 244 enum { 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 */ 261 struct wa_xfer_result { 262 struct wa_notif_hdr hdr; 263 __le32 dwTransferID; 264 __le32 dwTransferLength; 265 u8 bTransferSegment; 266 u8 bTransferStatus; 267 __le32 dwNumOfPackets; 268 } __packed; 269 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 */ 280 struct usb_wa_descriptor { 281 u8 bLength; 282 u8 bDescriptorType; 283 __le16 bcdWAVersion; 284 u8 bNumPorts; /* don't use!! */ 285 u8 bmAttributes; /* Reserved == 0 */ 286 __le16 wNumRPipes; 287 __le16 wRPipeMaxBlock; 288 u8 bRPipeBlockSize; 289 u8 bPwrOn2PwrGood; 290 u8 bNumMMCIEs; 291 u8 DeviceRemovable; /* FIXME: in DWA this is up to 16 bytes */ 292 } __packed; 293 294 /** 295 * HWA Device Information Buffer (WUSB1.0[T8.54]) 296 */ 297 struct hwa_dev_info { 298 u8 bmDeviceAvailability[32]; /* FIXME: ignored for now */ 299 u8 bDeviceAddress; 300 __le16 wPHYRates; 301 u8 bmDeviceAttribute; 302 } __packed; 303 304 #endif /* #ifndef __LINUX_USB_WUSB_WA_H */ 305