XenevaOS
Loading...
Searching...
No Matches
usbhub.h
Go to the documentation of this file.
1//
2// usbhub.h
3//
4// Definitions for USB hubs
5//
6// USPi - An USB driver for Raspberry Pi written in C
7// Copyright (C) 2014 R. Stange <rsta2@o2online.de>
8//
9// This program is free software: you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 3 of the License, or
12// (at your option) any later version.
13//
14// This program is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with this program. If not, see <http://www.gnu.org/licenses/>.
21//
22#ifndef _uspi_usbhub_h
23#define _uspi_usbhub_h
24
25#include "uspi/macros.h"
26
27// Configuration
28#define USB_HUB_MAX_PORTS 8 // TODO
29
30// Device Class
31#define USB_DEVICE_CLASS_HUB 9
32
33// Class-specific Requests
34#define RESET_TT 9
35
36// Descriptor Type
37#define DESCRIPTOR_HUB 0x29
38
39// Feature Selectors
40#define PORT_RESET 4
41#define PORT_POWER 8
42
43#pragma pack(push,1)
44// Hub Descriptor
45typedef struct TUSBHubDescriptor
46{
47 unsigned char bDescLength;
48 unsigned char bDescriptorType;
49 unsigned char bNbrPorts;
50 unsigned short wHubCharacteristics;
51 #define HUB_POWER_MODE(reg) ((reg) & 3)
52 #define HUB_POWER_MODE_GANGED 0
53 #define HUB_POWER_MODE_INDIVIDUAL 1
54 #define HUB_TT_THINK_TIME(reg) (((reg) >> 5) & 3)
55 unsigned char bPwrOn2PwrGood;
56 unsigned char bHubContrCurrent;
57 unsigned char DeviceRemoveable[1]; // max. 8 ports
58 unsigned char PortPwrCtrlMask[1]; // max. 8 ports
60#pragma pack(pop)
61//PACKED TUSBHubDescriptor;
62
63#pragma pack(push,1)
64typedef struct TUSBHubStatus
65{
66 unsigned short wHubStatus;
67 #define HUB_LOCAL_POWER_LOST__MASK (1 << 0)
68 #define HUB_OVER_CURRENT__MASK (1 << 1)
69 unsigned short wHubChange;
70 #define C_HUB_LOCAL_POWER_LOST__MASK (1 << 0)
71 #define C_HUB_OVER_CURRENT__MASK (1 << 1)
73#pragma pack(pop)
74//PACKED TUSBHubStatus;
75
76#pragma pack(push,1)
77typedef struct TUSBPortStatus
78{
79 unsigned short wPortStatus;
80 #define PORT_CONNECTION__MASK (1 << 0)
81 #define PORT_ENABLE__MASK (1 << 1)
82 #define PORT_OVER_CURRENT__MASK (1 << 3)
83 #define PORT_RESET__MASK (1 << 4)
84 #define PORT_POWER__MASK (1 << 8)
85 #define PORT_LOW_SPEED__MASK (1 << 9)
86 #define PORT_HIGH_SPEED__MASK (1 << 10)
87 unsigned short wChangeStatus;
89#pragma pack(pop)
90//PACKED TUSBPortStatus;
91
92#endif
Definition usbhub.h:46
unsigned char bPwrOn2PwrGood
Definition usbhub.h:55
unsigned char DeviceRemoveable[1]
Definition usbhub.h:57
unsigned char bHubContrCurrent
Definition usbhub.h:56
unsigned char bDescriptorType
Definition usbhub.h:48
unsigned char bNbrPorts
Definition usbhub.h:49
unsigned char PortPwrCtrlMask[1]
Definition usbhub.h:58
unsigned short wHubCharacteristics
Definition usbhub.h:50
unsigned char bDescLength
Definition usbhub.h:47
Definition usbhub.h:65
unsigned short wHubStatus
Definition usbhub.h:66
unsigned short wHubChange
Definition usbhub.h:69
Definition usbhub.h:78
unsigned short wChangeStatus
Definition usbhub.h:87
unsigned short wPortStatus
Definition usbhub.h:79