1012771d8Swdenk /* 2012771d8Swdenk * (C) Copyright 2001 3012771d8Swdenk * Denis Peter, MPL AG Switzerland 4012771d8Swdenk * 51a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 6012771d8Swdenk * Note: Part of this code has been derived from linux 7012771d8Swdenk * 8012771d8Swdenk */ 9012771d8Swdenk #ifndef _USB_H_ 10012771d8Swdenk #define _USB_H_ 11012771d8Swdenk 12012771d8Swdenk #include <usb_defs.h> 13c60795f4SIlya Yanok #include <linux/usb/ch9.h> 14012771d8Swdenk 1571c5de4fSTom Rini /* 1671c5de4fSTom Rini * The EHCI spec says that we must align to at least 32 bytes. However, 1771c5de4fSTom Rini * some platforms require larger alignment. 1871c5de4fSTom Rini */ 1971c5de4fSTom Rini #if ARCH_DMA_MINALIGN > 32 2071c5de4fSTom Rini #define USB_DMA_MINALIGN ARCH_DMA_MINALIGN 2171c5de4fSTom Rini #else 2271c5de4fSTom Rini #define USB_DMA_MINALIGN 32 2371c5de4fSTom Rini #endif 2471c5de4fSTom Rini 25012771d8Swdenk /* Everything is aribtrary */ 26012771d8Swdenk #define USB_ALTSETTINGALLOC 4 27012771d8Swdenk #define USB_MAXALTSETTING 128 /* Hard limit */ 28012771d8Swdenk 29012771d8Swdenk #define USB_MAX_DEVICE 32 30012771d8Swdenk #define USB_MAXCONFIG 8 31012771d8Swdenk #define USB_MAXINTERFACES 8 32012771d8Swdenk #define USB_MAXENDPOINTS 16 33012771d8Swdenk #define USB_MAXCHILDREN 8 /* This is arbitrary */ 34012771d8Swdenk #define USB_MAX_HUB 16 35012771d8Swdenk 36012771d8Swdenk #define USB_CNTL_TIMEOUT 100 /* 100ms timeout */ 37012771d8Swdenk 3896820a35SSimon Glass /* 3996820a35SSimon Glass * This is the timeout to allow for submitting an urb in ms. We allow more 4096820a35SSimon Glass * time for a BULK device to react - some are slow. 4196820a35SSimon Glass */ 4280b350a7SJason Cooper #define USB_TIMEOUT_MS(pipe) (usb_pipebulk(pipe) ? 5000 : 1000) 4396820a35SSimon Glass 44012771d8Swdenk /* device request (setup) */ 45012771d8Swdenk struct devrequest { 46012771d8Swdenk unsigned char requesttype; 47012771d8Swdenk unsigned char request; 48012771d8Swdenk unsigned short value; 49012771d8Swdenk unsigned short index; 50012771d8Swdenk unsigned short length; 51012771d8Swdenk } __attribute__ ((packed)); 52012771d8Swdenk 538f8bd565STom Rix /* Interface */ 548f8bd565STom Rix struct usb_interface { 558f8bd565STom Rix struct usb_interface_descriptor desc; 56012771d8Swdenk 57012771d8Swdenk unsigned char no_of_ep; 587455af41SBartlomiej Sieka unsigned char num_altsetting; 59012771d8Swdenk unsigned char act_altsetting; 60de39f8c1SMichael Trimarchi 61012771d8Swdenk struct usb_endpoint_descriptor ep_desc[USB_MAXENDPOINTS]; 626497c667SVivek Gautam /* 636497c667SVivek Gautam * Super Speed Device will have Super Speed Endpoint 646497c667SVivek Gautam * Companion Descriptor (section 9.6.7 of usb 3.0 spec) 656497c667SVivek Gautam * Revision 1.0 June 6th 2011 666497c667SVivek Gautam */ 676497c667SVivek Gautam struct usb_ss_ep_comp_descriptor ss_ep_comp_desc[USB_MAXENDPOINTS]; 68012771d8Swdenk } __attribute__ ((packed)); 69012771d8Swdenk 708f8bd565STom Rix /* Configuration information.. */ 718f8bd565STom Rix struct usb_config { 72c60795f4SIlya Yanok struct usb_config_descriptor desc; 73012771d8Swdenk 74012771d8Swdenk unsigned char no_of_if; /* number of interfaces */ 758f8bd565STom Rix struct usb_interface if_desc[USB_MAXINTERFACES]; 76012771d8Swdenk } __attribute__ ((packed)); 77012771d8Swdenk 7848867208SRemy Bohmer enum { 7948867208SRemy Bohmer /* Maximum packet size; encoded as 0,1,2,3 = 8,16,32,64 */ 8048867208SRemy Bohmer PACKET_SIZE_8 = 0, 8148867208SRemy Bohmer PACKET_SIZE_16 = 1, 8248867208SRemy Bohmer PACKET_SIZE_32 = 2, 8348867208SRemy Bohmer PACKET_SIZE_64 = 3, 8448867208SRemy Bohmer }; 85012771d8Swdenk 86012771d8Swdenk struct usb_device { 87012771d8Swdenk int devnum; /* Device number on USB bus */ 883e126484SMichael Trimarchi int speed; /* full/low/high */ 89012771d8Swdenk char mf[32]; /* manufacturer */ 90012771d8Swdenk char prod[32]; /* product */ 91012771d8Swdenk char serial[32]; /* serial number */ 92012771d8Swdenk 9348867208SRemy Bohmer /* Maximum packet size; one of: PACKET_SIZE_* */ 9448867208SRemy Bohmer int maxpacketsize; 9548867208SRemy Bohmer /* one bit for each endpoint ([0] = IN, [1] = OUT) */ 9648867208SRemy Bohmer unsigned int toggle[2]; 97de39f8c1SMichael Trimarchi /* endpoint halts; one bit per endpoint # & direction; 98de39f8c1SMichael Trimarchi * [0] = IN, [1] = OUT 99de39f8c1SMichael Trimarchi */ 10048867208SRemy Bohmer unsigned int halted[2]; 101012771d8Swdenk int epmaxpacketin[16]; /* INput endpoint specific maximums */ 102012771d8Swdenk int epmaxpacketout[16]; /* OUTput endpoint specific maximums */ 103012771d8Swdenk 104012771d8Swdenk int configno; /* selected config number */ 105f5766139SPuneet Saxena /* Device Descriptor */ 106f5766139SPuneet Saxena struct usb_device_descriptor descriptor 107f5766139SPuneet Saxena __attribute__((aligned(ARCH_DMA_MINALIGN))); 1088f8bd565STom Rix struct usb_config config; /* config descriptor */ 109012771d8Swdenk 110012771d8Swdenk int have_langid; /* whether string_langid is valid yet */ 111012771d8Swdenk int string_langid; /* language ID for strings */ 112012771d8Swdenk int (*irq_handle)(struct usb_device *dev); 113012771d8Swdenk unsigned long irq_status; 114012771d8Swdenk int irq_act_len; /* transfered bytes */ 115012771d8Swdenk void *privptr; 116012771d8Swdenk /* 117012771d8Swdenk * Child devices - if this is a hub device 118012771d8Swdenk * Each instance needs its own set of data structures. 119012771d8Swdenk */ 120012771d8Swdenk unsigned long status; 121012771d8Swdenk int act_len; /* transfered bytes */ 122012771d8Swdenk int maxchild; /* Number of ports if hub */ 1233e126484SMichael Trimarchi int portnr; 124012771d8Swdenk struct usb_device *parent; 125012771d8Swdenk struct usb_device *children[USB_MAXCHILDREN]; 126c7e3b2b5SLucas Stach 127c7e3b2b5SLucas Stach void *controller; /* hardware controller private data */ 128*5853e133SVivek Gautam /* slot_id - for xHCI enabled devices */ 129*5853e133SVivek Gautam unsigned int slot_id; 130012771d8Swdenk }; 131012771d8Swdenk 132012771d8Swdenk /********************************************************************** 133012771d8Swdenk * this is how the lowlevel part communicate with the outer world 134012771d8Swdenk */ 135012771d8Swdenk 136822af351SRodolfo Giometti #if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || \ 13751ab142bSmichael defined(CONFIG_USB_EHCI) || defined(CONFIG_USB_OHCI_NEW) || \ 1383e126484SMichael Trimarchi defined(CONFIG_USB_SL811HS) || defined(CONFIG_USB_ISP116X_HCD) || \ 139f298e4b6STom Rix defined(CONFIG_USB_R8A66597_HCD) || defined(CONFIG_USB_DAVINCI) || \ 140e608f221SBryan Wu defined(CONFIG_USB_OMAP3) || defined(CONFIG_USB_DA8XX) || \ 14137931f02SIlya Yanok defined(CONFIG_USB_BLACKFIN) || defined(CONFIG_USB_AM35X) || \ 142673a524bSIlya Yanok defined(CONFIG_USB_MUSB_DSPS) || defined(CONFIG_USB_MUSB_AM35X) || \ 143*5853e133SVivek Gautam defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined(CONFIG_USB_XHCI) 144822af351SRodolfo Giometti 145c7e3b2b5SLucas Stach int usb_lowlevel_init(int index, void **controller); 146c7e3b2b5SLucas Stach int usb_lowlevel_stop(int index); 147c7e3b2b5SLucas Stach 148de39f8c1SMichael Trimarchi int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, 149de39f8c1SMichael Trimarchi void *buffer, int transfer_len); 150012771d8Swdenk int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, 151012771d8Swdenk int transfer_len, struct devrequest *setup); 152012771d8Swdenk int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, 153012771d8Swdenk int transfer_len, int interval); 154012771d8Swdenk 155012771d8Swdenk /* Defines */ 156012771d8Swdenk #define USB_UHCI_VEND_ID 0x8086 157012771d8Swdenk #define USB_UHCI_DEV_ID 0x7112 158012771d8Swdenk 159e5f24753SLukasz Dalek /* 160e5f24753SLukasz Dalek * PXA25x can only act as USB device. There are drivers 161e5f24753SLukasz Dalek * which works with USB CDC gadgets implementations. 162e5f24753SLukasz Dalek * Some of them have common routines which can be used 163e5f24753SLukasz Dalek * in boards init functions e.g. udc_disconnect() used for 164e5f24753SLukasz Dalek * forced device disconnection from host. 165e5f24753SLukasz Dalek */ 166e5f24753SLukasz Dalek #elif defined(CONFIG_USB_GADGET_PXA2XX) 167e5f24753SLukasz Dalek 168e5f24753SLukasz Dalek extern void udc_disconnect(void); 169e5f24753SLukasz Dalek 170012771d8Swdenk #else 171012771d8Swdenk #error USB Lowlevel not defined 172012771d8Swdenk #endif 173012771d8Swdenk 174012771d8Swdenk #ifdef CONFIG_USB_STORAGE 175012771d8Swdenk 176012771d8Swdenk #define USB_MAX_STOR_DEV 5 177012771d8Swdenk block_dev_desc_t *usb_stor_get_dev(int index); 178012771d8Swdenk int usb_stor_scan(int mode); 179e813eae3SAnatolij Gustschin int usb_stor_info(void); 180012771d8Swdenk 181012771d8Swdenk #endif 182012771d8Swdenk 18389d48367SSimon Glass #ifdef CONFIG_USB_HOST_ETHER 18489d48367SSimon Glass 18589d48367SSimon Glass #define USB_MAX_ETH_DEV 5 18689d48367SSimon Glass int usb_host_eth_scan(int mode); 18789d48367SSimon Glass 18889d48367SSimon Glass #endif 18989d48367SSimon Glass 190012771d8Swdenk #ifdef CONFIG_USB_KEYBOARD 191012771d8Swdenk 192012771d8Swdenk int drv_usb_kbd_init(void); 193012771d8Swdenk int usb_kbd_deregister(void); 194012771d8Swdenk 195012771d8Swdenk #endif 196012771d8Swdenk /* routines */ 197012771d8Swdenk int usb_init(void); /* initialize the USB Controller */ 198012771d8Swdenk int usb_stop(void); /* stop the USB Controller */ 199012771d8Swdenk 200012771d8Swdenk 201012771d8Swdenk int usb_set_protocol(struct usb_device *dev, int ifnum, int protocol); 202de39f8c1SMichael Trimarchi int usb_set_idle(struct usb_device *dev, int ifnum, int duration, 203de39f8c1SMichael Trimarchi int report_id); 204012771d8Swdenk struct usb_device *usb_get_dev_index(int index); 205012771d8Swdenk int usb_control_msg(struct usb_device *dev, unsigned int pipe, 206012771d8Swdenk unsigned char request, unsigned char requesttype, 207012771d8Swdenk unsigned short value, unsigned short index, 208012771d8Swdenk void *data, unsigned short size, int timeout); 209012771d8Swdenk int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, 210012771d8Swdenk void *data, int len, int *actual_length, int timeout); 211012771d8Swdenk int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe, 212012771d8Swdenk void *buffer, int transfer_len, int interval); 21389d48367SSimon Glass int usb_disable_asynch(int disable); 214012771d8Swdenk int usb_maxpacket(struct usb_device *dev, unsigned long pipe); 215de39f8c1SMichael Trimarchi int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer, 216de39f8c1SMichael Trimarchi int cfgno); 217de39f8c1SMichael Trimarchi int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type, 218de39f8c1SMichael Trimarchi unsigned char id, void *buf, int size); 219012771d8Swdenk int usb_get_class_descriptor(struct usb_device *dev, int ifnum, 220de39f8c1SMichael Trimarchi unsigned char type, unsigned char id, void *buf, 221de39f8c1SMichael Trimarchi int size); 222012771d8Swdenk int usb_clear_halt(struct usb_device *dev, int pipe); 223012771d8Swdenk int usb_string(struct usb_device *dev, int index, char *buf, size_t size); 224012771d8Swdenk int usb_set_interface(struct usb_device *dev, int interface, int alternate); 225012771d8Swdenk 226012771d8Swdenk /* big endian -> little endian conversion */ 227149dded2Swdenk /* some CPUs are already little endian e.g. the ARM920T */ 228ae3b770eSMarkus Klotzbuecher #define __swap_16(x) \ 2293f85ce27Swdenk ({ unsigned short x_ = (unsigned short)x; \ 2303f85ce27Swdenk (unsigned short)( \ 2313f85ce27Swdenk ((x_ & 0x00FFU) << 8) | ((x_ & 0xFF00U) >> 8)); \ 2323f85ce27Swdenk }) 233ae3b770eSMarkus Klotzbuecher #define __swap_32(x) \ 2343f85ce27Swdenk ({ unsigned long x_ = (unsigned long)x; \ 2353f85ce27Swdenk (unsigned long)( \ 2363f85ce27Swdenk ((x_ & 0x000000FFUL) << 24) | \ 2373f85ce27Swdenk ((x_ & 0x0000FF00UL) << 8) | \ 2383f85ce27Swdenk ((x_ & 0x00FF0000UL) >> 8) | \ 2393f85ce27Swdenk ((x_ & 0xFF000000UL) >> 24)); \ 2403f85ce27Swdenk }) 241ae3b770eSMarkus Klotzbuecher 242c7d703f3SMike Frysinger #ifdef __LITTLE_ENDIAN 243ae3b770eSMarkus Klotzbuecher # define swap_16(x) (x) 244ae3b770eSMarkus Klotzbuecher # define swap_32(x) (x) 245ae3b770eSMarkus Klotzbuecher #else 246ae3b770eSMarkus Klotzbuecher # define swap_16(x) __swap_16(x) 247ae3b770eSMarkus Klotzbuecher # define swap_32(x) __swap_32(x) 248c7d703f3SMike Frysinger #endif 249012771d8Swdenk 250012771d8Swdenk /* 251012771d8Swdenk * Calling this entity a "pipe" is glorifying it. A USB pipe 252012771d8Swdenk * is something embarrassingly simple: it basically consists 253012771d8Swdenk * of the following information: 254012771d8Swdenk * - device number (7 bits) 255012771d8Swdenk * - endpoint number (4 bits) 256012771d8Swdenk * - current Data0/1 state (1 bit) 257012771d8Swdenk * - direction (1 bit) 2583e126484SMichael Trimarchi * - speed (2 bits) 259012771d8Swdenk * - max packet size (2 bits: 8, 16, 32 or 64) 260012771d8Swdenk * - pipe type (2 bits: control, interrupt, bulk, isochronous) 261012771d8Swdenk * 262012771d8Swdenk * That's 18 bits. Really. Nothing more. And the USB people have 263012771d8Swdenk * documented these eighteen bits as some kind of glorious 264012771d8Swdenk * virtual data structure. 265012771d8Swdenk * 266012771d8Swdenk * Let's not fall in that trap. We'll just encode it as a simple 267012771d8Swdenk * unsigned int. The encoding is: 268012771d8Swdenk * 269012771d8Swdenk * - max size: bits 0-1 (00 = 8, 01 = 16, 10 = 32, 11 = 64) 270de39f8c1SMichael Trimarchi * - direction: bit 7 (0 = Host-to-Device [Out], 271de39f8c1SMichael Trimarchi * (1 = Device-to-Host [In]) 272012771d8Swdenk * - device: bits 8-14 273012771d8Swdenk * - endpoint: bits 15-18 274012771d8Swdenk * - Data0/1: bit 19 275de39f8c1SMichael Trimarchi * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt, 276de39f8c1SMichael Trimarchi * 10 = control, 11 = bulk) 277012771d8Swdenk * 278012771d8Swdenk * Why? Because it's arbitrary, and whatever encoding we select is really 279012771d8Swdenk * up to us. This one happens to share a lot of bit positions with the UHCI 280012771d8Swdenk * specification, so that much of the uhci driver can just mask the bits 281012771d8Swdenk * appropriately. 282012771d8Swdenk */ 283012771d8Swdenk /* Create various pipes... */ 284012771d8Swdenk #define create_pipe(dev,endpoint) \ 285d0fe1128SSergei Shtylyov (((dev)->devnum << 8) | ((endpoint) << 15) | \ 286c60795f4SIlya Yanok (dev)->maxpacketsize) 2873e126484SMichael Trimarchi #define default_pipe(dev) ((dev)->speed << 26) 288012771d8Swdenk 289de39f8c1SMichael Trimarchi #define usb_sndctrlpipe(dev, endpoint) ((PIPE_CONTROL << 30) | \ 290de39f8c1SMichael Trimarchi create_pipe(dev, endpoint)) 291de39f8c1SMichael Trimarchi #define usb_rcvctrlpipe(dev, endpoint) ((PIPE_CONTROL << 30) | \ 292de39f8c1SMichael Trimarchi create_pipe(dev, endpoint) | \ 293de39f8c1SMichael Trimarchi USB_DIR_IN) 294de39f8c1SMichael Trimarchi #define usb_sndisocpipe(dev, endpoint) ((PIPE_ISOCHRONOUS << 30) | \ 295de39f8c1SMichael Trimarchi create_pipe(dev, endpoint)) 296de39f8c1SMichael Trimarchi #define usb_rcvisocpipe(dev, endpoint) ((PIPE_ISOCHRONOUS << 30) | \ 297de39f8c1SMichael Trimarchi create_pipe(dev, endpoint) | \ 298de39f8c1SMichael Trimarchi USB_DIR_IN) 299de39f8c1SMichael Trimarchi #define usb_sndbulkpipe(dev, endpoint) ((PIPE_BULK << 30) | \ 300de39f8c1SMichael Trimarchi create_pipe(dev, endpoint)) 301de39f8c1SMichael Trimarchi #define usb_rcvbulkpipe(dev, endpoint) ((PIPE_BULK << 30) | \ 302de39f8c1SMichael Trimarchi create_pipe(dev, endpoint) | \ 303de39f8c1SMichael Trimarchi USB_DIR_IN) 304de39f8c1SMichael Trimarchi #define usb_sndintpipe(dev, endpoint) ((PIPE_INTERRUPT << 30) | \ 305de39f8c1SMichael Trimarchi create_pipe(dev, endpoint)) 306de39f8c1SMichael Trimarchi #define usb_rcvintpipe(dev, endpoint) ((PIPE_INTERRUPT << 30) | \ 307de39f8c1SMichael Trimarchi create_pipe(dev, endpoint) | \ 308de39f8c1SMichael Trimarchi USB_DIR_IN) 309de39f8c1SMichael Trimarchi #define usb_snddefctrl(dev) ((PIPE_CONTROL << 30) | \ 310de39f8c1SMichael Trimarchi default_pipe(dev)) 311de39f8c1SMichael Trimarchi #define usb_rcvdefctrl(dev) ((PIPE_CONTROL << 30) | \ 312de39f8c1SMichael Trimarchi default_pipe(dev) | \ 313de39f8c1SMichael Trimarchi USB_DIR_IN) 314012771d8Swdenk 315012771d8Swdenk /* The D0/D1 toggle bits */ 316012771d8Swdenk #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> ep) & 1) 317012771d8Swdenk #define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << ep)) 318de39f8c1SMichael Trimarchi #define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = \ 319de39f8c1SMichael Trimarchi ((dev)->toggle[out] & \ 320de39f8c1SMichael Trimarchi ~(1 << ep)) | ((bit) << ep)) 321012771d8Swdenk 322012771d8Swdenk /* Endpoint halt control/status */ 323012771d8Swdenk #define usb_endpoint_out(ep_dir) (((ep_dir >> 7) & 1) ^ 1) 324012771d8Swdenk #define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep))) 325012771d8Swdenk #define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep))) 326012771d8Swdenk #define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep))) 327012771d8Swdenk 328de39f8c1SMichael Trimarchi #define usb_packetid(pipe) (((pipe) & USB_DIR_IN) ? USB_PID_IN : \ 329de39f8c1SMichael Trimarchi USB_PID_OUT) 330012771d8Swdenk 331012771d8Swdenk #define usb_pipeout(pipe) ((((pipe) >> 7) & 1) ^ 1) 332012771d8Swdenk #define usb_pipein(pipe) (((pipe) >> 7) & 1) 333012771d8Swdenk #define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f) 334012771d8Swdenk #define usb_pipe_endpdev(pipe) (((pipe) >> 8) & 0x7ff) 335012771d8Swdenk #define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf) 336012771d8Swdenk #define usb_pipedata(pipe) (((pipe) >> 19) & 1) 337012771d8Swdenk #define usb_pipetype(pipe) (((pipe) >> 30) & 3) 338012771d8Swdenk #define usb_pipeisoc(pipe) (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS) 339012771d8Swdenk #define usb_pipeint(pipe) (usb_pipetype((pipe)) == PIPE_INTERRUPT) 340012771d8Swdenk #define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL) 341012771d8Swdenk #define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK) 342012771d8Swdenk 343*5853e133SVivek Gautam #define usb_pipe_ep_index(pipe) \ 344*5853e133SVivek Gautam usb_pipecontrol(pipe) ? (usb_pipeendpoint(pipe) * 2) : \ 345*5853e133SVivek Gautam ((usb_pipeendpoint(pipe) * 2) - \ 346*5853e133SVivek Gautam (usb_pipein(pipe) ? 0 : 1)) 347012771d8Swdenk 348012771d8Swdenk /************************************************************************* 349012771d8Swdenk * Hub Stuff 350012771d8Swdenk */ 351012771d8Swdenk struct usb_port_status { 352012771d8Swdenk unsigned short wPortStatus; 353012771d8Swdenk unsigned short wPortChange; 354012771d8Swdenk } __attribute__ ((packed)); 355012771d8Swdenk 356012771d8Swdenk struct usb_hub_status { 357012771d8Swdenk unsigned short wHubStatus; 358012771d8Swdenk unsigned short wHubChange; 359012771d8Swdenk } __attribute__ ((packed)); 360012771d8Swdenk 361012771d8Swdenk 362012771d8Swdenk /* Hub descriptor */ 363012771d8Swdenk struct usb_hub_descriptor { 364012771d8Swdenk unsigned char bLength; 365012771d8Swdenk unsigned char bDescriptorType; 366012771d8Swdenk unsigned char bNbrPorts; 367012771d8Swdenk unsigned short wHubCharacteristics; 368012771d8Swdenk unsigned char bPwrOn2PwrGood; 369012771d8Swdenk unsigned char bHubContrCurrent; 370012771d8Swdenk unsigned char DeviceRemovable[(USB_MAXCHILDREN+1+7)/8]; 371012771d8Swdenk unsigned char PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8]; 372012771d8Swdenk /* DeviceRemovable and PortPwrCtrlMask want to be variable-length 373012771d8Swdenk bitmaps that hold max 255 entries. (bit0 is ignored) */ 374012771d8Swdenk } __attribute__ ((packed)); 375012771d8Swdenk 376012771d8Swdenk 377012771d8Swdenk struct usb_hub_device { 378012771d8Swdenk struct usb_device *pusb_dev; 379012771d8Swdenk struct usb_hub_descriptor desc; 380012771d8Swdenk }; 381012771d8Swdenk 38223faf2bcSMarek Vasut int usb_hub_probe(struct usb_device *dev, int ifnum); 38323faf2bcSMarek Vasut void usb_hub_reset(void); 38423faf2bcSMarek Vasut int hub_port_reset(struct usb_device *dev, int port, 38523faf2bcSMarek Vasut unsigned short *portstat); 38623faf2bcSMarek Vasut 387c7e3b2b5SLucas Stach struct usb_device *usb_alloc_new_device(void *controller); 388c7e3b2b5SLucas Stach 38923faf2bcSMarek Vasut int usb_new_device(struct usb_device *dev); 390359439d2SMilind Choudhary void usb_free_device(void); 391*5853e133SVivek Gautam int usb_alloc_device(struct usb_device *dev); 39223faf2bcSMarek Vasut 393012771d8Swdenk #endif /*_USB_H_ */ 394