xref: /haiku/src/add-ons/kernel/busses/usb/ehci_rh.cpp (revision 9ecf9d1c1d4888d341a6eac72112c72d1ae3a4cb)
1 /*
2  * Copyright 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  */
8 
9 #include "ehci.h"
10 
11 
12 static usb_device_descriptor sEHCIRootHubDevice =
13 {
14 	18,								// Descriptor length
15 	USB_DESCRIPTOR_DEVICE,			// Descriptor type
16 	0x200,							// USB 2.0
17 	0x09,							// Class (9 = Hub)
18 	0,								// Subclass
19 	0,								// Protocol
20 	64,								// Max packet size on endpoint 0
21 	0,								// Vendor ID
22 	0,								// Product ID
23 	0x200,							// Version
24 	1,								// Index of manufacturer string
25 	2,								// Index of product string
26 	0,								// Index of serial number string
27 	1								// Number of configurations
28 };
29 
30 
31 struct ehci_root_hub_configuration_s {
32 	usb_configuration_descriptor	configuration;
33 	usb_interface_descriptor		interface;
34 	usb_endpoint_descriptor			endpoint;
35 	usb_hub_descriptor				hub;
36 } _PACKED;
37 
38 
39 static ehci_root_hub_configuration_s sEHCIRootHubConfig =
40 {
41 	{ // configuration descriptor
42 		9,								// Descriptor length
43 		USB_DESCRIPTOR_CONFIGURATION,	// Descriptor type
44 		34,								// Total length of configuration (including
45 										// interface, endpoint and hub descriptors)
46 		1,								// Number of interfaces
47 		1,								// Value of this configuration
48 		0,								// Index of configuration string
49 		0x40,							// Attributes (0x40 = self powered)
50 		0								// Max power (0, since self powered)
51 	},
52 
53 	{ // interface descriptor
54 		9,								// Descriptor length
55 		USB_DESCRIPTOR_INTERFACE,		// Descriptor type
56 		0,								// Interface number
57 		0,								// Alternate setting
58 		1,								// Number of endpoints
59 		0x09,							// Interface class (9 = Hub)
60 		0,								// Interface subclass
61 		0,								// Interface protocol
62 		0,								// Index of interface string
63 	},
64 
65 	{ // endpoint descriptor
66 		7,								// Descriptor length
67 		USB_DESCRIPTOR_ENDPOINT,		// Descriptor type
68 		USB_REQTYPE_DEVICE_IN | 1,		// Endpoint address (first in IN endpoint)
69 		0x03,							// Attributes (0x03 = interrupt endpoint)
70 		8,								// Max packet size
71 		0xFF							// Interval
72 	},
73 
74 	{ // hub descriptor
75 		9,								// Descriptor length (including
76 										// deprecated power control mask)
77 		USB_DESCRIPTOR_HUB,				// Descriptor type
78 		2,								// Number of ports
79 		0x0000,							// Hub characteristics
80 		50,								// Power on to power good (in 2ms units)
81 		0,								// Maximum current (in mA)
82 		0x00,							// Both ports are removable
83 		0xff							// Depricated power control mask
84 	}
85 };
86 
87 
88 struct ehci_root_hub_string_s {
89 	uint8	length;
90 	uint8	descriptor_type;
91 	uint16	unicode_string[12];
92 } _PACKED;
93 
94 
95 static ehci_root_hub_string_s sEHCIRootHubStrings[3] = {
96 	{
97 		4,								// Descriptor length
98 		USB_DESCRIPTOR_STRING,			// Descriptor type
99 		0x0409							// Supported language IDs (English US)
100 	},
101 
102 	{
103 		12,								// Descriptor length
104 		USB_DESCRIPTOR_STRING,			// Descriptor type
105 		'H', 'A', 'I', 'K', 'U', ' ',	// Characters
106 		'I', 'n', 'c', '.'
107 	},
108 
109 	{
110 		26,								// Descriptor length
111 		USB_DESCRIPTOR_STRING,			// Descriptor type
112 		'E', 'H', 'C', 'I', ' ', 'R',	// Characters
113 		'o', 'o', 't', 'H', 'u', 'b'
114 	}
115 };
116 
117 
118 EHCIRootHub::EHCIRootHub(EHCI *ehci, int8 deviceAddress)
119 	:	Hub(ehci, NULL, sEHCIRootHubDevice, deviceAddress, false)
120 {
121 	fEHCI = ehci;
122 }
123 
124 
125 status_t
126 EHCIRootHub::SubmitTransfer(Transfer *transfer)
127 {
128 	return B_ERROR;
129 }
130 
131 
132 void
133 EHCIRootHub::UpdatePortStatus()
134 {
135 	for (int32 i = 0; i < sEHCIRootHubConfig.hub.num_ports; i++) {
136 		fPortStatus[i].status = 0;
137 		fPortStatus[i].change = 0;
138 	}
139 }
140