1/*
2 * Copyright 2003-2006, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Michael Lotz <mmlr@mlotz.ch>
7 *		Niels S. Reedijk
8 */
9#ifndef _USBSPEC_PRIVATE_H
10#define _USBSPEC_PRIVATE_H
11
12
13#include <KernelExport.h>
14#include <USB3.h>
15
16
17#define USB_MAX_AREAS					8
18#define USB_MAX_FRAGMENT_SIZE			B_PAGE_SIZE * 96
19#define USB_MAX_PORT_COUNT				255
20
21#define USB_DELAY_BUS_RESET				100000
22#define USB_DELAY_HUB_POWER_UP			200000
23#define USB_DELAY_PORT_RESET			50000
24#define USB_DELAY_PORT_RESET_RECOVERY	50000
25#define USB_DELAY_SET_ADDRESS_RETRY		200000
26#define USB_DELAY_SET_ADDRESS			10000
27#define USB_DELAY_SET_CONFIGURATION		50000
28#define USB_DELAY_HUB_EXPLORE			1000000
29
30#define USB_DEBOUNCE_TIMEOUT			1500000
31#define USB_DEBOUNCE_CHECK_INTERVAL		25000
32#define USB_DEBOUNCE_STABLE_TIME		100000
33
34// For bandwidth calculation
35#define	USB_BW_HOST_DELAY					1000
36#define	USB_BW_SETUP_LOW_SPEED_PORT_DELAY	333
37
38
39/*
40 * Important data from the USB spec.
41 */
42
43struct usb_request_data {
44	uint8   RequestType;
45	uint8   Request;
46	uint16  Value;
47	uint16  Index;
48	uint16  Length;
49} _PACKED;
50
51
52struct usb_isochronous_data {
53	usb_iso_packet_descriptor *packet_descriptors;
54	uint32 packet_count;
55	uint32 *starting_frame_number;
56	uint32 flags;
57};
58
59
60struct usb_hub_descriptor {
61	uint8 length;
62	uint8 descriptor_type;
63	uint8 num_ports;
64	uint16 characteristics;
65	uint8 power_on_to_power_good;
66	uint8 max_power;
67	uint8 device_removeable;	//Should be variable!!!
68	uint8 power_control_mask;	//Deprecated
69} _PACKED;
70
71#define USB_DESCRIPTOR_HUB 0x29
72
73
74struct usb_endpoint_ss_companion_descriptor {
75	uint8	length;
76	uint8	descriptor_type;
77	uint8	max_burst;
78	uint8	attributes;
79	uint16	bytes_per_interval;
80} _PACKED;
81
82#define USB_DESCRIPTOR_ENDPOINT_SS_COMPANION 0x30
83
84
85// USB Spec 1.1 page 273
86struct usb_port_status {
87	uint16 status;
88	uint16 change;
89};
90
91
92//The bits in the usb_port_status struct
93// USB 1.1 spec page 274
94// USB2_LinkPowerMangement_ECN[final].pdf page 25
95#define PORT_STATUS_CONNECTION		0x0001
96#define PORT_STATUS_ENABLE			0x0002
97#define PORT_STATUS_SUSPEND			0x0004
98#define PORT_STATUS_OVER_CURRENT	0x0008
99#define PORT_STATUS_RESET			0x0010
100#define PORT_STATUS_L1				0x0020
101#define PORT_STATUS_POWER			0x0100
102#define PORT_STATUS_LOW_SPEED		0x0200
103#define PORT_STATUS_HIGH_SPEED		0x0400
104#define PORT_STATUS_TEST			0x0800
105#define PORT_STATUS_INDICATOR		0x1000
106// USB 3.0 spec table 10-10
107#define PORT_STATUS_SS_LINK_STATE	0x01e0
108#define PORT_STATUS_SS_POWER		0x0200
109#define PORT_STATUS_SS_SPEED		0x1c00
110
111
112
113//The feature requests with ports
114// USB 1.1 spec page 268
115#define PORT_CONNECTION				0
116#define PORT_ENABLE					1
117#define PORT_SUSPEND				2
118#define PORT_OVER_CURRENT			3
119#define PORT_RESET					4
120#define PORT_POWER					8
121#define PORT_LOW_SPEED				9
122#define C_PORT_CONNECTION			16
123#define C_PORT_ENABLE				17
124#define C_PORT_SUSPEND				18
125#define C_PORT_OVER_CURRENT			19
126#define C_PORT_RESET				20
127
128// USB 3.0 spec table 10-8
129#define PORT_LINK_STATE				5
130#define PORT_U1_TIMEOUT				23
131#define PORT_U2_TIMEOUT				24
132#define C_PORT_LINK_STATE			25
133#define C_PORT_CONFIG_ERROR			26
134#define C_PORT_REMOTE_WAKE_MASK		27
135#define PORT_BH_PORT_RESET			28
136#define C_PORT_BH_PORT_RESET		29
137#define PORT_FORCE_LINKPM_STATE		30
138
139// USB 3.0 spec table 10-11
140#define PORT_CHANGE_BH_PORT_RESET	0x0020
141#define PORT_CHANGE_LINK_STATE		0x0040
142
143#endif // _USBSPEC_PRIVATE_H
144