xref: /haiku/src/add-ons/kernel/bus_managers/usb/usbspec_private.h (revision a3e794ae459fec76826407f8ba8c94cd3535f128)
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				16
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 (not interesting for drivers)
41 */
42 
43 struct memory_chunk
44 {
45 	uint32 next_item;
46 	uint32 physical;
47 };
48 
49 
50 struct usb_request_data
51 {
52 	uint8   RequestType;
53 	uint8   Request;
54 	uint16  Value;
55 	uint16  Index;
56 	uint16  Length;
57 };
58 
59 
60 struct usb_isochronous_data {
61 	usb_iso_packet_descriptor *packet_descriptors;
62 	uint32 packet_count;
63 	uint32 *starting_frame_number;
64 	uint32 flags;
65 };
66 
67 
68 struct usb_hub_descriptor
69 {
70 	uint8 length;
71 	uint8 descriptor_type;
72 	uint8 num_ports;
73 	uint16 characteristics;
74 	uint8 power_on_to_power_good;
75 	uint8 max_power;
76 	uint8 device_removeable;	//Should be variable!!!
77 	uint8 power_control_mask;	//Deprecated
78 } _PACKED;
79 
80 #define USB_DESCRIPTOR_HUB 0x29
81 
82 
83 // USB Spec 1.1 page 273
84 struct usb_port_status
85 {
86 	uint16 status;
87 	uint16 change;
88 };
89 
90 
91 //The bits in the usb_port_status struct
92 // USB 1.1 spec page 274
93 // USB2_LinkPowerMangement_ECN[final].pdf page 25
94 #define PORT_STATUS_CONNECTION		0x0001
95 #define PORT_STATUS_ENABLE			0x0002
96 #define PORT_STATUS_SUSPEND			0x0004
97 #define PORT_STATUS_OVER_CURRENT	0x0008
98 #define PORT_STATUS_RESET			0x0010
99 #define PORT_STATUS_L1				0x0020
100 #define PORT_STATUS_POWER			0x0100
101 #define PORT_STATUS_LOW_SPEED		0x0200
102 #define PORT_STATUS_HIGH_SPEED		0x0400
103 #define PORT_STATUS_TEST			0x0800
104 #define PORT_STATUS_INDICATOR		0x1000
105 // USB 3.0 spec table 10-11
106 #define PORT_STATUS_SS_LINK_STATE	0x01e0
107 #define PORT_STATUS_SS_POWER		0x0200
108 #define PORT_STATUS_SS_SPEED		0x1c00
109 
110 
111 
112 //The feature requests with ports
113 // USB 1.1 spec page 268
114 #define PORT_CONNECTION				0
115 #define PORT_ENABLE					1
116 #define PORT_SUSPEND				2
117 #define PORT_OVER_CURRENT			3
118 #define PORT_RESET					4
119 #define PORT_POWER					8
120 #define PORT_LOW_SPEED				9
121 #define C_PORT_CONNECTION			16
122 #define C_PORT_ENABLE				17
123 #define C_PORT_SUSPEND				18
124 #define C_PORT_OVER_CURRENT			19
125 #define C_PORT_RESET				20
126 
127 // USB 3.0 spec table 10-8
128 #define PORT_LINK_STATE				5
129 #define PORT_U1_TIMEOUT				23
130 #define PORT_U2_TIMEOUT				24
131 #define C_PORT_LINK_STATE			25
132 #define C_PORT_CONFIG_ERROR			26
133 #define C_PORT_REMOTE_WAKE_MASK		27
134 #define PORT_BH_PORT_RESET			28
135 #define C_PORT_BH_PORT_RESET		29
136 #define PORT_FORCE_LINKPM_STATE		30
137 
138 
139 #endif // _USBSPEC_PRIVATE_H
140