M471M/R1/S BSP V3.01.000
The Board Support Package for M4521
hub.h
Go to the documentation of this file.
1/**************************************************************************/
9#ifndef _USBH_HUB_H_
10#define _USBH_HUB_H_
11
12
14
15
16/*--------------------------------------------------------------------------*/
17/* Hub class feature selectors (Table 11-17) */
18/*--------------------------------------------------------------------------*/
19#define FS_C_HUB_LOCAL_POWER 0
20#define FS_C_HUB_OVER_CURRENT 1
21
22#define FS_PORT_CONNECTION 0
23#define FS_PORT_ENABLE 1
24#define FS_PORT_SUSPEND 2
25#define FS_PORT_OVER_CURRENT 3
26#define FS_PORT_RESET 4
27#define FS_PORT_POWER 8
28#define FS_C_PORT_CONNECTION 16
29#define FS_C_PORT_ENABLE 17
30#define FS_C_PORT_SUSPEND 18
31#define FS_C_PORT_OVER_CURRENT 19
32#define FS_C_PORT_RESET 20
33
34/*--------------------------------------------------------------------------*/
35/* Hub/Port staus and change bits */
36/*--------------------------------------------------------------------------*/
37#define HUB_S_LOCAL_POWER (1UL << 0)
38#define HUB_S_OVERCURRENT (1UL << 1)
39
40#define HUB_C_LOCAL_POWER (1UL << 0)
41#define HUB_C_OVERCURRENT (1UL << 1)
42
43#define PORT_S_CONNECTION (1UL << 0)
44#define PORT_S_ENABLE (1UL << 1)
45#define PORT_S_SUSPEND (1UL << 2)
46#define PORT_S_OVERCURRENT (1UL << 3)
47#define PORT_S_RESET (1UL << 4)
48#define PORT_S_PORT_POWER (1UL << 8)
49#define PORT_S_LOW_SPEED (1UL << 9)
50#define PORT_S_HIGH_SPEED (1UL << 10)
51#define PORT_S_TEST (1UL << 11)
52#define PORT_S_INDICATOR (1UL << 12)
53
54#define PORT_C_CONNECTION (1UL << 0)
55#define PORT_C_ENABLE (1UL << 1)
56#define PORT_C_SUSPEND (1UL << 2)
57#define PORT_C_OVERCURRENT (1UL << 3)
58#define PORT_C_RESET (1UL << 4)
59
60
61/*--------------------------------------------------------------------------*/
62/* Hub descriptor */
63/*--------------------------------------------------------------------------*/
64#ifdef __ICCARM__
65typedef struct {
66 __packed uint8_t bDescLength;
67 __packed uint8_t bDescriptorType;
68 __packed uint8_t bNbrPorts;
69 __packed uint16_t wHubCharacteristics;
70 __packed uint8_t bPwrOn2PwrGood;
71 __packed uint8_t bHubContrCurrent;
72 __packed uint8_t bDeviceRemovble;
73 __packed uint8_t PortPwrCtrlMask[16];
74} DESC_HUB_T;
75#else
76typedef struct __attribute__((__packed__)) {
77 uint8_t bDescLength;
78 uint8_t bDescriptorType;
79 uint8_t bNbrPorts;
80 uint16_t wHubCharacteristics;
81 uint8_t bPwrOn2PwrGood;
82 uint8_t bHubContrCurrent;
83 uint8_t bDeviceRemovble;
84 uint8_t PortPwrCtrlMask[16];
85} DESC_HUB_T;
86#endif
87
88/*
89 * wHubCharacteristics bit field mask
90 */
91#define HUB_CHAR_LPSM 0x0003 /* 00b: global port power, 01b: per port power, 1x: reserved */
92#define HUB_CHAR_COMPOUND 0x0004 /* 1: is part of a compond device, 0: is not. */
93#define HUB_CHAR_OCPM 0x0018 /* 00b: global over-current protection, 01b: per port, 1x: reserved */
94#define HUB_CHAR_TTTT 0x0060 /* TT think time. 00b: 8FS, 01b: 16FS, 10b: 24FS, 11b: 32FS */
95#define HUB_CHAR_PORTIND 0x0080 /* 1: port indicator (LED) supported, 0: not */
96
97/* port indicator status selectors */
98#define HUB_LED_AUTO 0
99#define HUB_LED_AMBER 1
100#define HUB_LED_GREEN 2
101#define HUB_LED_OFF 3
102
103
104/*--------------------------------------------------------------------------*/
105/* Port reset retry and time-out settings */
106/*--------------------------------------------------------------------------*/
107#define PORT_RESET_RETRY 3 /* port reset retry times */
108#define PORT_RESET_TIME_MS 50 /* port reset time (ms) */
109#define PORT_RESET_RETRY_INC_MS 250 /* increased reset time (ms) after reset failed */
110
111
112#define HUB_STATUS_MAX_BYTE 2 /* maximum number of interrupt-in status bytes */
113/* 2 can support up to 16 port hubs */
114/* 4 can support up to 32 port hubs */
115/* Note!! If modeifed to 4, "uint16_t sc_bitmap" */
116/* MUST be changed as "uint32_t sc_bitmap" */
117typedef struct hub_dev_t {
118 IFACE_T *iface;
119 UTR_T *utr;
120 uint8_t buff[HUB_STATUS_MAX_BYTE];
121 uint16_t sc_bitmap;
122 uint8_t bNbrPorts;
123 uint8_t bPwrOn2PwrGood;
124 char pos_id[MAX_HUB_DEVICE+1];
125 int (*port_reset)(struct hub_dev_t *hub, int port);
126 UDEV_T *children;
127} HUB_DEV_T;
128
129
131
132#endif /* _USBH_HUB_H_ */
void *__dso_handle __attribute__((weak))
Definition: _syscalls.c:35