1012771d8Swdenk /* 2012771d8Swdenk * (C) Copyright 2001 3012771d8Swdenk * Denis Peter, MPL AG Switzerland 4012771d8Swdenk * 5012771d8Swdenk * See file CREDITS for list of people who contributed to this 6012771d8Swdenk * project. 7012771d8Swdenk * 8012771d8Swdenk * This program is free software; you can redistribute it and/or 9012771d8Swdenk * modify it under the terms of the GNU General Public License as 10012771d8Swdenk * published by the Free Software Foundation; either version 2 of 11012771d8Swdenk * the License, or (at your option) any later version. 12012771d8Swdenk * 13012771d8Swdenk * This program is distributed in the hope that it will be useful, 14012771d8Swdenk * but WITHOUT ANY WARRANTY; without even the implied warranty of 15012771d8Swdenk * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16012771d8Swdenk * GNU General Public License for more details. 17012771d8Swdenk * 18012771d8Swdenk * You should have received a copy of the GNU General Public License 19012771d8Swdenk * along with this program; if not, write to the Free Software 20012771d8Swdenk * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21012771d8Swdenk * MA 02111-1307 USA 22012771d8Swdenk * 23012771d8Swdenk * Note: Part of this code has been derived from linux 24012771d8Swdenk * 25012771d8Swdenk */ 26012771d8Swdenk #ifndef _USB_H_ 27012771d8Swdenk #define _USB_H_ 28012771d8Swdenk 29012771d8Swdenk #include <usb_defs.h> 30c60795f4SIlya Yanok #include <linux/usb/ch9.h> 31012771d8Swdenk 3271c5de4fSTom Rini /* 3371c5de4fSTom Rini * The EHCI spec says that we must align to at least 32 bytes. However, 3471c5de4fSTom Rini * some platforms require larger alignment. 3571c5de4fSTom Rini */ 3671c5de4fSTom Rini #if ARCH_DMA_MINALIGN > 32 3771c5de4fSTom Rini #define USB_DMA_MINALIGN ARCH_DMA_MINALIGN 3871c5de4fSTom Rini #else 3971c5de4fSTom Rini #define USB_DMA_MINALIGN 32 4071c5de4fSTom Rini #endif 4171c5de4fSTom Rini 42012771d8Swdenk /* Everything is aribtrary */ 43012771d8Swdenk #define USB_ALTSETTINGALLOC 4 44012771d8Swdenk #define USB_MAXALTSETTING 128 /* Hard limit */ 45012771d8Swdenk 46012771d8Swdenk #define USB_MAX_DEVICE 32 47012771d8Swdenk #define USB_MAXCONFIG 8 48012771d8Swdenk #define USB_MAXINTERFACES 8 49012771d8Swdenk #define USB_MAXENDPOINTS 16 50012771d8Swdenk #define USB_MAXCHILDREN 8 /* This is arbitrary */ 51012771d8Swdenk #define USB_MAX_HUB 16 52012771d8Swdenk 53012771d8Swdenk #define USB_CNTL_TIMEOUT 100 /* 100ms timeout */ 54012771d8Swdenk 5596820a35SSimon Glass /* 5696820a35SSimon Glass * This is the timeout to allow for submitting an urb in ms. We allow more 5796820a35SSimon Glass * time for a BULK device to react - some are slow. 5896820a35SSimon Glass */ 5980b350a7SJason Cooper #define USB_TIMEOUT_MS(pipe) (usb_pipebulk(pipe) ? 5000 : 1000) 6096820a35SSimon Glass 61012771d8Swdenk /* device request (setup) */ 62012771d8Swdenk struct devrequest { 63012771d8Swdenk unsigned char requesttype; 64012771d8Swdenk unsigned char request; 65012771d8Swdenk unsigned short value; 66012771d8Swdenk unsigned short index; 67012771d8Swdenk unsigned short length; 68012771d8Swdenk } __attribute__ ((packed)); 69012771d8Swdenk 708f8bd565STom Rix /* Interface */ 718f8bd565STom Rix struct usb_interface { 728f8bd565STom Rix struct usb_interface_descriptor desc; 73012771d8Swdenk 74012771d8Swdenk unsigned char no_of_ep; 757455af41SBartlomiej Sieka unsigned char num_altsetting; 76012771d8Swdenk unsigned char act_altsetting; 77de39f8c1SMichael Trimarchi 78012771d8Swdenk struct usb_endpoint_descriptor ep_desc[USB_MAXENDPOINTS]; 79012771d8Swdenk } __attribute__ ((packed)); 80012771d8Swdenk 818f8bd565STom Rix /* Configuration information.. */ 828f8bd565STom Rix struct usb_config { 83c60795f4SIlya Yanok struct usb_config_descriptor desc; 84012771d8Swdenk 85012771d8Swdenk unsigned char no_of_if; /* number of interfaces */ 868f8bd565STom Rix struct usb_interface if_desc[USB_MAXINTERFACES]; 87012771d8Swdenk } __attribute__ ((packed)); 88012771d8Swdenk 8948867208SRemy Bohmer enum { 9048867208SRemy Bohmer /* Maximum packet size; encoded as 0,1,2,3 = 8,16,32,64 */ 9148867208SRemy Bohmer PACKET_SIZE_8 = 0, 9248867208SRemy Bohmer PACKET_SIZE_16 = 1, 9348867208SRemy Bohmer PACKET_SIZE_32 = 2, 9448867208SRemy Bohmer PACKET_SIZE_64 = 3, 9548867208SRemy Bohmer }; 96012771d8Swdenk 97012771d8Swdenk struct usb_device { 98012771d8Swdenk int devnum; /* Device number on USB bus */ 993e126484SMichael Trimarchi int speed; /* full/low/high */ 100012771d8Swdenk char mf[32]; /* manufacturer */ 101012771d8Swdenk char prod[32]; /* product */ 102012771d8Swdenk char serial[32]; /* serial number */ 103012771d8Swdenk 10448867208SRemy Bohmer /* Maximum packet size; one of: PACKET_SIZE_* */ 10548867208SRemy Bohmer int maxpacketsize; 10648867208SRemy Bohmer /* one bit for each endpoint ([0] = IN, [1] = OUT) */ 10748867208SRemy Bohmer unsigned int toggle[2]; 108de39f8c1SMichael Trimarchi /* endpoint halts; one bit per endpoint # & direction; 109de39f8c1SMichael Trimarchi * [0] = IN, [1] = OUT 110de39f8c1SMichael Trimarchi */ 11148867208SRemy Bohmer unsigned int halted[2]; 112012771d8Swdenk int epmaxpacketin[16]; /* INput endpoint specific maximums */ 113012771d8Swdenk int epmaxpacketout[16]; /* OUTput endpoint specific maximums */ 114012771d8Swdenk 115012771d8Swdenk int configno; /* selected config number */ 116f5766139SPuneet Saxena /* Device Descriptor */ 117f5766139SPuneet Saxena struct usb_device_descriptor descriptor 118f5766139SPuneet Saxena __attribute__((aligned(ARCH_DMA_MINALIGN))); 1198f8bd565STom Rix struct usb_config config; /* config descriptor */ 120012771d8Swdenk 121012771d8Swdenk int have_langid; /* whether string_langid is valid yet */ 122012771d8Swdenk int string_langid; /* language ID for strings */ 123012771d8Swdenk int (*irq_handle)(struct usb_device *dev); 124012771d8Swdenk unsigned long irq_status; 125012771d8Swdenk int irq_act_len; /* transfered bytes */ 126012771d8Swdenk void *privptr; 127012771d8Swdenk /* 128012771d8Swdenk * Child devices - if this is a hub device 129012771d8Swdenk * Each instance needs its own set of data structures. 130012771d8Swdenk */ 131012771d8Swdenk unsigned long status; 132012771d8Swdenk int act_len; /* transfered bytes */ 133012771d8Swdenk int maxchild; /* Number of ports if hub */ 1343e126484SMichael Trimarchi int portnr; 135012771d8Swdenk struct usb_device *parent; 136012771d8Swdenk struct usb_device *children[USB_MAXCHILDREN]; 137c7e3b2b5SLucas Stach 138c7e3b2b5SLucas Stach void *controller; /* hardware controller private data */ 139012771d8Swdenk }; 140012771d8Swdenk 141012771d8Swdenk /********************************************************************** 142012771d8Swdenk * this is how the lowlevel part communicate with the outer world 143012771d8Swdenk */ 144012771d8Swdenk 145822af351SRodolfo Giometti #if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || \ 14651ab142bSmichael defined(CONFIG_USB_EHCI) || defined(CONFIG_USB_OHCI_NEW) || \ 1473e126484SMichael Trimarchi defined(CONFIG_USB_SL811HS) || defined(CONFIG_USB_ISP116X_HCD) || \ 148f298e4b6STom Rix defined(CONFIG_USB_R8A66597_HCD) || defined(CONFIG_USB_DAVINCI) || \ 149e608f221SBryan Wu defined(CONFIG_USB_OMAP3) || defined(CONFIG_USB_DA8XX) || \ 15037931f02SIlya Yanok defined(CONFIG_USB_BLACKFIN) || defined(CONFIG_USB_AM35X) || \ 151*673a524bSIlya Yanok defined(CONFIG_USB_MUSB_DSPS) || defined(CONFIG_USB_MUSB_AM35X) || \ 152*673a524bSIlya Yanok defined(CONFIG_USB_MUSB_OMAP2PLUS) 153822af351SRodolfo Giometti 154c7e3b2b5SLucas Stach int usb_lowlevel_init(int index, void **controller); 155c7e3b2b5SLucas Stach int usb_lowlevel_stop(int index); 156c7e3b2b5SLucas Stach 157de39f8c1SMichael Trimarchi int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, 158de39f8c1SMichael Trimarchi void *buffer, int transfer_len); 159012771d8Swdenk int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, 160012771d8Swdenk int transfer_len, struct devrequest *setup); 161012771d8Swdenk int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, 162012771d8Swdenk int transfer_len, int interval); 163012771d8Swdenk 164012771d8Swdenk /* Defines */ 165012771d8Swdenk #define USB_UHCI_VEND_ID 0x8086 166012771d8Swdenk #define USB_UHCI_DEV_ID 0x7112 167012771d8Swdenk 168e5f24753SLukasz Dalek /* 169e5f24753SLukasz Dalek * PXA25x can only act as USB device. There are drivers 170e5f24753SLukasz Dalek * which works with USB CDC gadgets implementations. 171e5f24753SLukasz Dalek * Some of them have common routines which can be used 172e5f24753SLukasz Dalek * in boards init functions e.g. udc_disconnect() used for 173e5f24753SLukasz Dalek * forced device disconnection from host. 174e5f24753SLukasz Dalek */ 175e5f24753SLukasz Dalek #elif defined(CONFIG_USB_GADGET_PXA2XX) 176e5f24753SLukasz Dalek 177e5f24753SLukasz Dalek extern void udc_disconnect(void); 178e5f24753SLukasz Dalek 179012771d8Swdenk #else 180012771d8Swdenk #error USB Lowlevel not defined 181012771d8Swdenk #endif 182012771d8Swdenk 183012771d8Swdenk #ifdef CONFIG_USB_STORAGE 184012771d8Swdenk 185012771d8Swdenk #define USB_MAX_STOR_DEV 5 186012771d8Swdenk block_dev_desc_t *usb_stor_get_dev(int index); 187012771d8Swdenk int usb_stor_scan(int mode); 188e813eae3SAnatolij Gustschin int usb_stor_info(void); 189012771d8Swdenk 190012771d8Swdenk #endif 191012771d8Swdenk 19289d48367SSimon Glass #ifdef CONFIG_USB_HOST_ETHER 19389d48367SSimon Glass 19489d48367SSimon Glass #define USB_MAX_ETH_DEV 5 19589d48367SSimon Glass int usb_host_eth_scan(int mode); 19689d48367SSimon Glass 19789d48367SSimon Glass #endif 19889d48367SSimon Glass 199012771d8Swdenk #ifdef CONFIG_USB_KEYBOARD 200012771d8Swdenk 201012771d8Swdenk int drv_usb_kbd_init(void); 202012771d8Swdenk int usb_kbd_deregister(void); 203012771d8Swdenk 204012771d8Swdenk #endif 205012771d8Swdenk /* routines */ 206012771d8Swdenk int usb_init(void); /* initialize the USB Controller */ 207012771d8Swdenk int usb_stop(void); /* stop the USB Controller */ 208012771d8Swdenk 209012771d8Swdenk 210012771d8Swdenk int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol); 211de39f8c1SMichael Trimarchi int usb_set_idle(struct usb_device *dev, int ifnum, int duration, 212de39f8c1SMichael Trimarchi int report_id); 213012771d8Swdenk struct usb_device *usb_get_dev_index(int index); 214012771d8Swdenk int usb_control_msg(struct usb_device *dev, unsigned int pipe, 215012771d8Swdenk unsigned char request, unsigned char requesttype, 216012771d8Swdenk unsigned short value, unsigned short index, 217012771d8Swdenk void *data, unsigned short size, int timeout); 218012771d8Swdenk int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, 219012771d8Swdenk void *data, int len, int *actual_length, int timeout); 220012771d8Swdenk int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe, 221012771d8Swdenk void *buffer, int transfer_len, int interval); 22289d48367SSimon Glass int usb_disable_asynch(int disable); 223012771d8Swdenk int usb_maxpacket(struct usb_device *dev, unsigned long pipe); 224de39f8c1SMichael Trimarchi int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, 225de39f8c1SMichael Trimarchi int cfgno); 226de39f8c1SMichael Trimarchi int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type, 227de39f8c1SMichael Trimarchi unsigned char id, void *buf, int size); 228012771d8Swdenk int usb_get_class_descriptor(struct usb_device *dev, int ifnum, 229de39f8c1SMichael Trimarchi unsigned char type, unsigned char id, void *buf, 230de39f8c1SMichael Trimarchi int size); 231012771d8Swdenk int usb_clear_halt(struct usb_device *dev, int pipe); 232012771d8Swdenk int usb_string(struct usb_device *dev, int index, char *buf, size_t size); 233012771d8Swdenk int usb_set_interface(struct usb_device *dev, int interface, int alternate); 234012771d8Swdenk 235012771d8Swdenk /* big endian -> little endian conversion */ 236149dded2Swdenk /* some CPUs are already little endian e.g. the ARM920T */ 237ae3b770eSMarkus Klotzbuecher #define __swap_16(x) \ 2383f85ce27Swdenk ({ unsigned short x_ = (unsigned short)x; \ 2393f85ce27Swdenk (unsigned short)( \ 2403f85ce27Swdenk ((x_ & 0x00FFU) << 8) | ((x_ & 0xFF00U) >> 8)); \ 2413f85ce27Swdenk }) 242ae3b770eSMarkus Klotzbuecher #define __swap_32(x) \ 2433f85ce27Swdenk ({ unsigned long x_ = (unsigned long)x; \ 2443f85ce27Swdenk (unsigned long)( \ 2453f85ce27Swdenk ((x_ & 0x000000FFUL) << 24) | \ 2463f85ce27Swdenk ((x_ & 0x0000FF00UL) << 8) | \ 2473f85ce27Swdenk ((x_ & 0x00FF0000UL) >> 8) | \ 2483f85ce27Swdenk ((x_ & 0xFF000000UL) >> 24)); \ 2493f85ce27Swdenk }) 250ae3b770eSMarkus Klotzbuecher 251c7d703f3SMike Frysinger #ifdef __LITTLE_ENDIAN 252ae3b770eSMarkus Klotzbuecher # define swap_16(x) (x) 253ae3b770eSMarkus Klotzbuecher # define swap_32(x) (x) 254ae3b770eSMarkus Klotzbuecher #else 255ae3b770eSMarkus Klotzbuecher # define swap_16(x) __swap_16(x) 256ae3b770eSMarkus Klotzbuecher # define swap_32(x) __swap_32(x) 257c7d703f3SMike Frysinger #endif 258012771d8Swdenk 259012771d8Swdenk /* 260012771d8Swdenk * Calling this entity a "pipe" is glorifying it. A USB pipe 261012771d8Swdenk * is something embarrassingly simple: it basically consists 262012771d8Swdenk * of the following information: 263012771d8Swdenk * - device number (7 bits) 264012771d8Swdenk * - endpoint number (4 bits) 265012771d8Swdenk * - current Data0/1 state (1 bit) 266012771d8Swdenk * - direction (1 bit) 2673e126484SMichael Trimarchi * - speed (2 bits) 268012771d8Swdenk * - max packet size (2 bits: 8, 16, 32 or 64) 269012771d8Swdenk * - pipe type (2 bits: control, interrupt, bulk, isochronous) 270012771d8Swdenk * 271012771d8Swdenk * That's 18 bits. Really. Nothing more. And the USB people have 272012771d8Swdenk * documented these eighteen bits as some kind of glorious 273012771d8Swdenk * virtual data structure. 274012771d8Swdenk * 275012771d8Swdenk * Let's not fall in that trap. We'll just encode it as a simple 276012771d8Swdenk * unsigned int. The encoding is: 277012771d8Swdenk * 278012771d8Swdenk * - max size: bits 0-1 (00 = 8, 01 = 16, 10 = 32, 11 = 64) 279de39f8c1SMichael Trimarchi * - direction: bit 7 (0 = Host-to-Device [Out], 280de39f8c1SMichael Trimarchi * (1 = Device-to-Host [In]) 281012771d8Swdenk * - device: bits 8-14 282012771d8Swdenk * - endpoint: bits 15-18 283012771d8Swdenk * - Data0/1: bit 19 284de39f8c1SMichael Trimarchi * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt, 285de39f8c1SMichael Trimarchi * 10 = control, 11 = bulk) 286012771d8Swdenk * 287012771d8Swdenk * Why? Because it's arbitrary, and whatever encoding we select is really 288012771d8Swdenk * up to us. This one happens to share a lot of bit positions with the UHCI 289012771d8Swdenk * specification, so that much of the uhci driver can just mask the bits 290012771d8Swdenk * appropriately. 291012771d8Swdenk */ 292012771d8Swdenk /* Create various pipes... */ 293012771d8Swdenk #define create_pipe(dev,endpoint) \ 294d0fe1128SSergei Shtylyov (((dev)->devnum << 8) | ((endpoint) << 15) | \ 295c60795f4SIlya Yanok (dev)->maxpacketsize) 2963e126484SMichael Trimarchi #define default_pipe(dev) ((dev)->speed << 26) 297012771d8Swdenk 298de39f8c1SMichael Trimarchi #define usb_sndctrlpipe(dev, endpoint) ((PIPE_CONTROL << 30) | \ 299de39f8c1SMichael Trimarchi create_pipe(dev, endpoint)) 300de39f8c1SMichael Trimarchi #define usb_rcvctrlpipe(dev, endpoint) ((PIPE_CONTROL << 30) | \ 301de39f8c1SMichael Trimarchi create_pipe(dev, endpoint) | \ 302de39f8c1SMichael Trimarchi USB_DIR_IN) 303de39f8c1SMichael Trimarchi #define usb_sndisocpipe(dev, endpoint) ((PIPE_ISOCHRONOUS << 30) | \ 304de39f8c1SMichael Trimarchi create_pipe(dev, endpoint)) 305de39f8c1SMichael Trimarchi #define usb_rcvisocpipe(dev, endpoint) ((PIPE_ISOCHRONOUS << 30) | \ 306de39f8c1SMichael Trimarchi create_pipe(dev, endpoint) | \ 307de39f8c1SMichael Trimarchi USB_DIR_IN) 308de39f8c1SMichael Trimarchi #define usb_sndbulkpipe(dev, endpoint) ((PIPE_BULK << 30) | \ 309de39f8c1SMichael Trimarchi create_pipe(dev, endpoint)) 310de39f8c1SMichael Trimarchi #define usb_rcvbulkpipe(dev, endpoint) ((PIPE_BULK << 30) | \ 311de39f8c1SMichael Trimarchi create_pipe(dev, endpoint) | \ 312de39f8c1SMichael Trimarchi USB_DIR_IN) 313de39f8c1SMichael Trimarchi #define usb_sndintpipe(dev, endpoint) ((PIPE_INTERRUPT << 30) | \ 314de39f8c1SMichael Trimarchi create_pipe(dev, endpoint)) 315de39f8c1SMichael Trimarchi #define usb_rcvintpipe(dev, endpoint) ((PIPE_INTERRUPT << 30) | \ 316de39f8c1SMichael Trimarchi create_pipe(dev, endpoint) | \ 317de39f8c1SMichael Trimarchi USB_DIR_IN) 318de39f8c1SMichael Trimarchi #define usb_snddefctrl(dev) ((PIPE_CONTROL << 30) | \ 319de39f8c1SMichael Trimarchi default_pipe(dev)) 320de39f8c1SMichael Trimarchi #define usb_rcvdefctrl(dev) ((PIPE_CONTROL << 30) | \ 321de39f8c1SMichael Trimarchi default_pipe(dev) | \ 322de39f8c1SMichael Trimarchi USB_DIR_IN) 323012771d8Swdenk 324012771d8Swdenk /* The D0/D1 toggle bits */ 325012771d8Swdenk #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> ep) & 1) 326012771d8Swdenk #define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << ep)) 327de39f8c1SMichael Trimarchi #define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = \ 328de39f8c1SMichael Trimarchi ((dev)->toggle[out] & \ 329de39f8c1SMichael Trimarchi ~(1 << ep)) | ((bit) << ep)) 330012771d8Swdenk 331012771d8Swdenk /* Endpoint halt control/status */ 332012771d8Swdenk #define usb_endpoint_out(ep_dir) (((ep_dir >> 7) & 1) ^ 1) 333012771d8Swdenk #define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep))) 334012771d8Swdenk #define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep))) 335012771d8Swdenk #define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep))) 336012771d8Swdenk 337de39f8c1SMichael Trimarchi #define usb_packetid(pipe) (((pipe) & USB_DIR_IN) ? USB_PID_IN : \ 338de39f8c1SMichael Trimarchi USB_PID_OUT) 339012771d8Swdenk 340012771d8Swdenk #define usb_pipeout(pipe) ((((pipe) >> 7) & 1) ^ 1) 341012771d8Swdenk #define usb_pipein(pipe) (((pipe) >> 7) & 1) 342012771d8Swdenk #define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f) 343012771d8Swdenk #define usb_pipe_endpdev(pipe) (((pipe) >> 8) & 0x7ff) 344012771d8Swdenk #define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf) 345012771d8Swdenk #define usb_pipedata(pipe) (((pipe) >> 19) & 1) 346012771d8Swdenk #define usb_pipetype(pipe) (((pipe) >> 30) & 3) 347012771d8Swdenk #define usb_pipeisoc(pipe) (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS) 348012771d8Swdenk #define usb_pipeint(pipe) (usb_pipetype((pipe)) == PIPE_INTERRUPT) 349012771d8Swdenk #define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL) 350012771d8Swdenk #define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK) 351012771d8Swdenk 352012771d8Swdenk 353012771d8Swdenk /************************************************************************* 354012771d8Swdenk * Hub Stuff 355012771d8Swdenk */ 356012771d8Swdenk struct usb_port_status { 357012771d8Swdenk unsigned short wPortStatus; 358012771d8Swdenk unsigned short wPortChange; 359012771d8Swdenk } __attribute__ ((packed)); 360012771d8Swdenk 361012771d8Swdenk struct usb_hub_status { 362012771d8Swdenk unsigned short wHubStatus; 363012771d8Swdenk unsigned short wHubChange; 364012771d8Swdenk } __attribute__ ((packed)); 365012771d8Swdenk 366012771d8Swdenk 367012771d8Swdenk /* Hub descriptor */ 368012771d8Swdenk struct usb_hub_descriptor { 369012771d8Swdenk unsigned char bLength; 370012771d8Swdenk unsigned char bDescriptorType; 371012771d8Swdenk unsigned char bNbrPorts; 372012771d8Swdenk unsigned short wHubCharacteristics; 373012771d8Swdenk unsigned char bPwrOn2PwrGood; 374012771d8Swdenk unsigned char bHubContrCurrent; 375012771d8Swdenk unsigned char DeviceRemovable[(USB_MAXCHILDREN+1+7)/8]; 376012771d8Swdenk unsigned char PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8]; 377012771d8Swdenk /* DeviceRemovable and PortPwrCtrlMask want to be variable-length 378012771d8Swdenk bitmaps that hold max 255 entries. (bit0 is ignored) */ 379012771d8Swdenk } __attribute__ ((packed)); 380012771d8Swdenk 381012771d8Swdenk 382012771d8Swdenk struct usb_hub_device { 383012771d8Swdenk struct usb_device *pusb_dev; 384012771d8Swdenk struct usb_hub_descriptor desc; 385012771d8Swdenk }; 386012771d8Swdenk 38723faf2bcSMarek Vasut int usb_hub_probe(struct usb_device *dev, int ifnum); 38823faf2bcSMarek Vasut void usb_hub_reset(void); 38923faf2bcSMarek Vasut int hub_port_reset(struct usb_device *dev, int port, 39023faf2bcSMarek Vasut unsigned short *portstat); 39123faf2bcSMarek Vasut 392c7e3b2b5SLucas Stach struct usb_device *usb_alloc_new_device(void *controller); 393c7e3b2b5SLucas Stach 39423faf2bcSMarek Vasut int usb_new_device(struct usb_device *dev); 39523faf2bcSMarek Vasut 396012771d8Swdenk #endif /*_USB_H_ */ 397