xref: /haiku/src/add-ons/kernel/bus_managers/usb/usbspec_private.h (revision 21258e2674226d6aa732321b6f8494841895af5f)
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 
43 struct usb_request_data {
44 	uint8   RequestType;
45 	uint8   Request;
46 	uint16  Value;
47 	uint16  Index;
48 	uint16  Length;
49 } _PACKED;
50 
51 
52 struct 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 
60 struct 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 
74 struct usb_endpoint_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_COMPANION 0x30
83 
84 
85 // USB Spec 1.1 page 273
86 struct usb_port_status
87 {
88 	uint16 status;
89 	uint16 change;
90 };
91 
92 
93 //The bits in the usb_port_status struct
94 // USB 1.1 spec page 274
95 // USB2_LinkPowerMangement_ECN[final].pdf page 25
96 #define PORT_STATUS_CONNECTION		0x0001
97 #define PORT_STATUS_ENABLE			0x0002
98 #define PORT_STATUS_SUSPEND			0x0004
99 #define PORT_STATUS_OVER_CURRENT	0x0008
100 #define PORT_STATUS_RESET			0x0010
101 #define PORT_STATUS_L1				0x0020
102 #define PORT_STATUS_POWER			0x0100
103 #define PORT_STATUS_LOW_SPEED		0x0200
104 #define PORT_STATUS_HIGH_SPEED		0x0400
105 #define PORT_STATUS_TEST			0x0800
106 #define PORT_STATUS_INDICATOR		0x1000
107 // USB 3.0 spec table 10-10
108 #define PORT_STATUS_SS_LINK_STATE	0x01e0
109 #define PORT_STATUS_SS_POWER		0x0200
110 #define PORT_STATUS_SS_SPEED		0x1c00
111 
112 
113 
114 //The feature requests with ports
115 // USB 1.1 spec page 268
116 #define PORT_CONNECTION				0
117 #define PORT_ENABLE					1
118 #define PORT_SUSPEND				2
119 #define PORT_OVER_CURRENT			3
120 #define PORT_RESET					4
121 #define PORT_POWER					8
122 #define PORT_LOW_SPEED				9
123 #define C_PORT_CONNECTION			16
124 #define C_PORT_ENABLE				17
125 #define C_PORT_SUSPEND				18
126 #define C_PORT_OVER_CURRENT			19
127 #define C_PORT_RESET				20
128 
129 // USB 3.0 spec table 10-8
130 #define PORT_LINK_STATE				5
131 #define PORT_U1_TIMEOUT				23
132 #define PORT_U2_TIMEOUT				24
133 #define C_PORT_LINK_STATE			25
134 #define C_PORT_CONFIG_ERROR			26
135 #define C_PORT_REMOTE_WAKE_MASK		27
136 #define PORT_BH_PORT_RESET			28
137 #define C_PORT_BH_PORT_RESET		29
138 #define PORT_FORCE_LINKPM_STATE		30
139 
140 // USB 3.0 spec table 10-11
141 #define PORT_CHANGE_BH_PORT_RESET	0x0020
142 #define PORT_CHANGE_LINK_STATE		0x0040
143 
144 #endif // _USBSPEC_PRIVATE_H
145