linux/drivers/usb/gadget/udc/aspeed-vhub/vhub.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0+ */
   2#ifndef __ASPEED_VHUB_H
   3#define __ASPEED_VHUB_H
   4
   5/*****************************
   6 *                           *
   7 * VHUB register definitions *
   8 *                           *
   9 *****************************/
  10
  11#define AST_VHUB_CTRL           0x00    /* Root Function Control & Status Register */
  12#define AST_VHUB_CONF           0x04    /* Root Configuration Setting Register */
  13#define AST_VHUB_IER            0x08    /* Interrupt Ctrl Register */
  14#define AST_VHUB_ISR            0x0C    /* Interrupt Status Register */
  15#define AST_VHUB_EP_ACK_IER     0x10    /* Programmable Endpoint Pool ACK Interrupt Enable Register */
  16#define AST_VHUB_EP_NACK_IER    0x14    /* Programmable Endpoint Pool NACK Interrupt Enable Register  */
  17#define AST_VHUB_EP_ACK_ISR     0x18    /* Programmable Endpoint Pool ACK Interrupt Status Register  */
  18#define AST_VHUB_EP_NACK_ISR    0x1C    /* Programmable Endpoint Pool NACK Interrupt Status Register  */
  19#define AST_VHUB_SW_RESET       0x20    /* Device Controller Soft Reset Enable Register */
  20#define AST_VHUB_USBSTS         0x24    /* USB Status Register */
  21#define AST_VHUB_EP_TOGGLE      0x28    /* Programmable Endpoint Pool Data Toggle Value Set */
  22#define AST_VHUB_ISO_FAIL_ACC   0x2C    /* Isochronous Transaction Fail Accumulator */
  23#define AST_VHUB_EP0_CTRL       0x30    /* Endpoint 0 Contrl/Status Register */
  24#define AST_VHUB_EP0_DATA       0x34    /* Base Address of Endpoint 0 In/OUT Data Buffer Register */
  25#define AST_VHUB_EP1_CTRL       0x38    /* Endpoint 1 Contrl/Status Register */
  26#define AST_VHUB_EP1_STS_CHG    0x3C    /* Endpoint 1 Status Change Bitmap Data */
  27#define AST_VHUB_SETUP0         0x80    /* Root Device Setup Data Buffer0 */
  28#define AST_VHUB_SETUP1         0x84    /* Root Device Setup Data Buffer1 */
  29
  30/* Main control reg */
  31#define VHUB_CTRL_PHY_CLK                       (1 << 31)
  32#define VHUB_CTRL_PHY_LOOP_TEST                 (1 << 25)
  33#define VHUB_CTRL_DN_PWN                        (1 << 24)
  34#define VHUB_CTRL_DP_PWN                        (1 << 23)
  35#define VHUB_CTRL_LONG_DESC                     (1 << 18)
  36#define VHUB_CTRL_ISO_RSP_CTRL                  (1 << 17)
  37#define VHUB_CTRL_SPLIT_IN                      (1 << 16)
  38#define VHUB_CTRL_LOOP_T_RESULT                 (1 << 15)
  39#define VHUB_CTRL_LOOP_T_STS                    (1 << 14)
  40#define VHUB_CTRL_PHY_BIST_RESULT               (1 << 13)
  41#define VHUB_CTRL_PHY_BIST_CTRL                 (1 << 12)
  42#define VHUB_CTRL_PHY_RESET_DIS                 (1 << 11)
  43#define VHUB_CTRL_SET_TEST_MODE(x)              ((x) << 8)
  44#define VHUB_CTRL_MANUAL_REMOTE_WAKEUP          (1 << 4)
  45#define VHUB_CTRL_AUTO_REMOTE_WAKEUP            (1 << 3)
  46#define VHUB_CTRL_CLK_STOP_SUSPEND              (1 << 2)
  47#define VHUB_CTRL_FULL_SPEED_ONLY               (1 << 1)
  48#define VHUB_CTRL_UPSTREAM_CONNECT              (1 << 0)
  49
  50/* IER & ISR */
  51#define VHUB_IRQ_USB_CMD_DEADLOCK               (1 << 18)
  52#define VHUB_IRQ_EP_POOL_NAK                    (1 << 17)
  53#define VHUB_IRQ_EP_POOL_ACK_STALL              (1 << 16)
  54#define VHUB_IRQ_DEVICE5                        (1 << 13)
  55#define VHUB_IRQ_DEVICE4                        (1 << 12)
  56#define VHUB_IRQ_DEVICE3                        (1 << 11)
  57#define VHUB_IRQ_DEVICE2                        (1 << 10)
  58#define VHUB_IRQ_DEVICE1                        (1 << 9)
  59#define VHUB_IRQ_BUS_RESUME                     (1 << 8)
  60#define VHUB_IRQ_BUS_SUSPEND                    (1 << 7)
  61#define VHUB_IRQ_BUS_RESET                      (1 << 6)
  62#define VHUB_IRQ_HUB_EP1_IN_DATA_ACK            (1 << 5)
  63#define VHUB_IRQ_HUB_EP0_IN_DATA_NAK            (1 << 4)
  64#define VHUB_IRQ_HUB_EP0_IN_ACK_STALL           (1 << 3)
  65#define VHUB_IRQ_HUB_EP0_OUT_NAK                (1 << 2)
  66#define VHUB_IRQ_HUB_EP0_OUT_ACK_STALL          (1 << 1)
  67#define VHUB_IRQ_HUB_EP0_SETUP                  (1 << 0)
  68#define VHUB_IRQ_ACK_ALL                        0x1ff
  69
  70/* SW reset reg */
  71#define VHUB_SW_RESET_EP_POOL                   (1 << 9)
  72#define VHUB_SW_RESET_DMA_CONTROLLER            (1 << 8)
  73#define VHUB_SW_RESET_DEVICE5                   (1 << 5)
  74#define VHUB_SW_RESET_DEVICE4                   (1 << 4)
  75#define VHUB_SW_RESET_DEVICE3                   (1 << 3)
  76#define VHUB_SW_RESET_DEVICE2                   (1 << 2)
  77#define VHUB_SW_RESET_DEVICE1                   (1 << 1)
  78#define VHUB_SW_RESET_ROOT_HUB                  (1 << 0)
  79#define VHUB_SW_RESET_ALL                       (VHUB_SW_RESET_EP_POOL | \
  80                                                 VHUB_SW_RESET_DMA_CONTROLLER | \
  81                                                 VHUB_SW_RESET_DEVICE5 | \
  82                                                 VHUB_SW_RESET_DEVICE4 | \
  83                                                 VHUB_SW_RESET_DEVICE3 | \
  84                                                 VHUB_SW_RESET_DEVICE2 | \
  85                                                 VHUB_SW_RESET_DEVICE1 | \
  86                                                 VHUB_SW_RESET_ROOT_HUB)
  87/* EP ACK/NACK IRQ masks */
  88#define VHUB_EP_IRQ(n)                          (1 << (n))
  89#define VHUB_EP_IRQ_ALL                         0x7fff  /* 15 EPs */
  90
  91/* USB status reg */
  92#define VHUB_USBSTS_HISPEED                     (1 << 27)
  93
  94/* EP toggle */
  95#define VHUB_EP_TOGGLE_VALUE                    (1 << 8)
  96#define VHUB_EP_TOGGLE_SET_EPNUM(x)             ((x) & 0x1f)
  97
  98/* HUB EP0 control */
  99#define VHUB_EP0_CTRL_STALL                     (1 << 0)
 100#define VHUB_EP0_TX_BUFF_RDY                    (1 << 1)
 101#define VHUB_EP0_RX_BUFF_RDY                    (1 << 2)
 102#define VHUB_EP0_RX_LEN(x)                      (((x) >> 16) & 0x7f)
 103#define VHUB_EP0_SET_TX_LEN(x)                  (((x) & 0x7f) << 8)
 104
 105/* HUB EP1 control */
 106#define VHUB_EP1_CTRL_RESET_TOGGLE              (1 << 2)
 107#define VHUB_EP1_CTRL_STALL                     (1 << 1)
 108#define VHUB_EP1_CTRL_ENABLE                    (1 << 0)
 109
 110/***********************************
 111 *                                 *
 112 * per-device register definitions *
 113 *                                 *
 114 ***********************************/
 115#define AST_VHUB_DEV_EN_CTRL            0x00
 116#define AST_VHUB_DEV_ISR                0x04
 117#define AST_VHUB_DEV_EP0_CTRL           0x08
 118#define AST_VHUB_DEV_EP0_DATA           0x0c
 119
 120/* Device enable control */
 121#define VHUB_DEV_EN_SET_ADDR(x)                 ((x) << 8)
 122#define VHUB_DEV_EN_ADDR_MASK                   ((0xff) << 8)
 123#define VHUB_DEV_EN_EP0_NAK_IRQEN               (1 << 6)
 124#define VHUB_DEV_EN_EP0_IN_ACK_IRQEN            (1 << 5)
 125#define VHUB_DEV_EN_EP0_OUT_NAK_IRQEN           (1 << 4)
 126#define VHUB_DEV_EN_EP0_OUT_ACK_IRQEN           (1 << 3)
 127#define VHUB_DEV_EN_EP0_SETUP_IRQEN             (1 << 2)
 128#define VHUB_DEV_EN_SPEED_SEL_HIGH              (1 << 1)
 129#define VHUB_DEV_EN_ENABLE_PORT                 (1 << 0)
 130
 131/* Interrupt status */
 132#define VHUV_DEV_IRQ_EP0_IN_DATA_NACK           (1 << 4)
 133#define VHUV_DEV_IRQ_EP0_IN_ACK_STALL           (1 << 3)
 134#define VHUV_DEV_IRQ_EP0_OUT_DATA_NACK          (1 << 2)
 135#define VHUV_DEV_IRQ_EP0_OUT_ACK_STALL          (1 << 1)
 136#define VHUV_DEV_IRQ_EP0_SETUP                  (1 << 0)
 137
 138/* Control bits.
 139 *
 140 * Note: The driver relies on the bulk of those bits
 141 *       matching corresponding vHub EP0 control bits
 142 */
 143#define VHUB_DEV_EP0_CTRL_STALL                 VHUB_EP0_CTRL_STALL
 144#define VHUB_DEV_EP0_TX_BUFF_RDY                VHUB_EP0_TX_BUFF_RDY
 145#define VHUB_DEV_EP0_RX_BUFF_RDY                VHUB_EP0_RX_BUFF_RDY
 146#define VHUB_DEV_EP0_RX_LEN(x)                  VHUB_EP0_RX_LEN(x)
 147#define VHUB_DEV_EP0_SET_TX_LEN(x)              VHUB_EP0_SET_TX_LEN(x)
 148
 149/*************************************
 150 *                                   *
 151 * per-endpoint register definitions *
 152 *                                   *
 153 *************************************/
 154
 155#define AST_VHUB_EP_CONFIG              0x00
 156#define AST_VHUB_EP_DMA_CTLSTAT         0x04
 157#define AST_VHUB_EP_DESC_BASE           0x08
 158#define AST_VHUB_EP_DESC_STATUS         0x0C
 159
 160/* EP config reg */
 161#define VHUB_EP_CFG_SET_MAX_PKT(x)      (((x) & 0x3ff) << 16)
 162#define VHUB_EP_CFG_AUTO_DATA_DISABLE   (1 << 13)
 163#define VHUB_EP_CFG_STALL_CTRL          (1 << 12)
 164#define VHUB_EP_CFG_SET_EP_NUM(x)       (((x) & 0xf) << 8)
 165#define VHUB_EP_CFG_SET_TYPE(x)         ((x) << 5)
 166#define   EP_TYPE_OFF                   0
 167#define   EP_TYPE_BULK                  1
 168#define   EP_TYPE_INT                   2
 169#define   EP_TYPE_ISO                   3
 170#define VHUB_EP_CFG_DIR_OUT             (1 << 4)
 171#define VHUB_EP_CFG_SET_DEV(x)          ((x) << 1)
 172#define VHUB_EP_CFG_ENABLE              (1 << 0)
 173
 174/* EP DMA control */
 175#define VHUB_EP_DMA_PROC_STATUS(x)      (((x) >> 4) & 0xf)
 176#define   EP_DMA_PROC_RX_IDLE           0
 177#define   EP_DMA_PROC_TX_IDLE           8
 178#define VHUB_EP_DMA_IN_LONG_MODE        (1 << 3)
 179#define VHUB_EP_DMA_OUT_CONTIG_MODE     (1 << 3)
 180#define VHUB_EP_DMA_CTRL_RESET          (1 << 2)
 181#define VHUB_EP_DMA_SINGLE_STAGE        (1 << 1)
 182#define VHUB_EP_DMA_DESC_MODE           (1 << 0)
 183
 184/* EP DMA status */
 185#define VHUB_EP_DMA_SET_TX_SIZE(x)      ((x) << 16)
 186#define VHUB_EP_DMA_TX_SIZE(x)          (((x) >> 16) & 0x7ff)
 187#define VHUB_EP_DMA_RPTR(x)             (((x) >> 8) & 0xff)
 188#define VHUB_EP_DMA_SET_RPTR(x)         (((x) & 0xff) << 8)
 189#define VHUB_EP_DMA_SET_CPU_WPTR(x)     (x)
 190#define VHUB_EP_DMA_SINGLE_KICK         (1 << 0) /* WPTR = 1 for single mode */
 191
 192/*******************************
 193 *                             *
 194 * DMA descriptors definitions *
 195 *                             *
 196 *******************************/
 197
 198/* Desc W1 IN */
 199#define VHUB_DSC1_IN_INTERRUPT          (1 << 31)
 200#define VHUB_DSC1_IN_SPID_DATA0         (0 << 14)
 201#define VHUB_DSC1_IN_SPID_DATA2         (1 << 14)
 202#define VHUB_DSC1_IN_SPID_DATA1         (2 << 14)
 203#define VHUB_DSC1_IN_SPID_MDATA         (3 << 14)
 204#define VHUB_DSC1_IN_SET_LEN(x)         ((x) & 0xfff)
 205#define VHUB_DSC1_IN_LEN(x)             ((x) & 0xfff)
 206
 207/****************************************
 208 *                                      *
 209 * Data structures and misc definitions *
 210 *                                      *
 211 ****************************************/
 212
 213#define AST_VHUB_NUM_GEN_EPs    15      /* Generic non-0 EPs */
 214#define AST_VHUB_NUM_PORTS      5       /* vHub ports */
 215#define AST_VHUB_EP0_MAX_PACKET 64      /* EP0's max packet size */
 216#define AST_VHUB_EPn_MAX_PACKET 1024    /* Generic EPs max packet size */
 217#define AST_VHUB_DESCS_COUNT    256     /* Use 256 descriptor mode (valid
 218                                         * values are 256 and 32)
 219                                         */
 220
 221struct ast_vhub;
 222struct ast_vhub_dev;
 223
 224/*
 225 * DMA descriptor (generic EPs only, currently only used
 226 * for IN endpoints
 227 */
 228struct ast_vhub_desc {
 229        __le32  w0;
 230        __le32  w1;
 231};
 232
 233/* A transfer request, either core-originated or internal */
 234struct ast_vhub_req {
 235        struct usb_request      req;
 236        struct list_head        queue;
 237
 238        /* Actual count written to descriptors (desc mode only) */
 239        unsigned int            act_count;
 240
 241        /*
 242         * Desc number of the final packet or -1. For non-desc
 243         * mode (or ep0), any >= 0 value means "last packet"
 244         */
 245        int                     last_desc;
 246
 247        /* Request active (pending DMAs) */
 248        bool                    active  : 1;
 249
 250        /* Internal request (don't call back core) */
 251        bool                    internal : 1;
 252};
 253#define to_ast_req(__ureq) container_of(__ureq, struct ast_vhub_req, req)
 254
 255/* Current state of an EP0 */
 256enum ep0_state {
 257        ep0_state_token,
 258        ep0_state_data,
 259        ep0_state_status,
 260};
 261
 262/*
 263 * An endpoint, either generic, ep0, actual gadget EP
 264 * or internal use vhub EP0. vhub EP1 doesn't have an
 265 * associated structure as it's mostly HW managed.
 266 */
 267struct ast_vhub_ep {
 268        struct usb_ep           ep;
 269
 270        /* Request queue */
 271        struct list_head        queue;
 272
 273        /* EP index in the device, 0 means this is an EP0 */
 274        unsigned int            d_idx;
 275
 276        /* Dev pointer or NULL for vHub EP0 */
 277        struct ast_vhub_dev     *dev;
 278
 279        /* vHub itself */
 280        struct ast_vhub         *vhub;
 281
 282        /*
 283         * DMA buffer for EP0, fallback DMA buffer for misaligned
 284         * OUT transfers for generic EPs
 285         */
 286        void                    *buf;
 287        dma_addr_t              buf_dma;
 288
 289        /* The rest depends on the EP type */
 290        union {
 291                /* EP0 (either device or vhub) */
 292                struct {
 293                        /*
 294                         * EP0 registers are "similar" for
 295                         * vHub and devices but located in
 296                         * different places.
 297                         */
 298                        void __iomem            *ctlstat;
 299                        void __iomem            *setup;
 300
 301                        /* Current state & direction */
 302                        enum ep0_state          state;
 303                        bool                    dir_in;
 304
 305                        /* Internal use request */
 306                        struct ast_vhub_req     req;
 307                } ep0;
 308
 309                /* Generic endpoint (aka EPn) */
 310                struct {
 311                        /* Registers */
 312                        void __iomem            *regs;
 313
 314                        /* Index in global pool (0..14) */
 315                        unsigned int            g_idx;
 316
 317                        /* DMA Descriptors */
 318                        struct ast_vhub_desc    *descs;
 319                        dma_addr_t              descs_dma;
 320                        unsigned int            d_next;
 321                        unsigned int            d_last;
 322                        unsigned int            dma_conf;
 323
 324                        /* Max chunk size for IN EPs */
 325                        unsigned int            chunk_max;
 326
 327                        /* State flags */
 328                        bool                    is_in :  1;
 329                        bool                    is_iso : 1;
 330                        bool                    stalled : 1;
 331                        bool                    wedged : 1;
 332                        bool                    enabled : 1;
 333                        bool                    desc_mode : 1;
 334                } epn;
 335        };
 336};
 337#define to_ast_ep(__uep) container_of(__uep, struct ast_vhub_ep, ep)
 338
 339/* A device attached to a vHub port */
 340struct ast_vhub_dev {
 341        struct ast_vhub                 *vhub;
 342        void __iomem                    *regs;
 343
 344        /* Device index (0...4) and name string */
 345        unsigned int                    index;
 346        const char                      *name;
 347
 348        /* sysfs enclosure for the gadget gunk */
 349        struct device                   *port_dev;
 350
 351        /* Link to gadget core */
 352        struct usb_gadget               gadget;
 353        struct usb_gadget_driver        *driver;
 354        bool                            registered : 1;
 355        bool                            wakeup_en : 1;
 356        bool                            suspended : 1;
 357        bool                            enabled : 1;
 358
 359        /* Endpoint structures */
 360        struct ast_vhub_ep              ep0;
 361        struct ast_vhub_ep              *epns[AST_VHUB_NUM_GEN_EPs];
 362
 363};
 364#define to_ast_dev(__g) container_of(__g, struct ast_vhub_dev, gadget)
 365
 366/* Per vhub port stateinfo structure */
 367struct ast_vhub_port {
 368        /* Port status & status change registers */
 369        u16                     status;
 370        u16                     change;
 371
 372        /* Associated device slot */
 373        struct ast_vhub_dev     dev;
 374};
 375
 376/* Global vhub structure */
 377struct ast_vhub {
 378        struct platform_device          *pdev;
 379        void __iomem                    *regs;
 380        int                             irq;
 381        spinlock_t                      lock;
 382        struct work_struct              wake_work;
 383        struct clk                      *clk;
 384
 385        /* EP0 DMA buffers allocated in one chunk */
 386        void                            *ep0_bufs;
 387        dma_addr_t                      ep0_bufs_dma;
 388
 389        /* EP0 of the vhub itself */
 390        struct ast_vhub_ep              ep0;
 391
 392        /* State of vhub ep1 */
 393        bool                            ep1_stalled : 1;
 394
 395        /* Per-port info */
 396        struct ast_vhub_port            ports[AST_VHUB_NUM_PORTS];
 397
 398        /* Generic EP data structures */
 399        struct ast_vhub_ep              epns[AST_VHUB_NUM_GEN_EPs];
 400
 401        /* Upstream bus is suspended ? */
 402        bool                            suspended : 1;
 403
 404        /* Hub itself can signal remote wakeup */
 405        bool                            wakeup_en : 1;
 406
 407        /* Force full speed only */
 408        bool                            force_usb1 : 1;
 409
 410        /* Upstream bus speed captured at bus reset */
 411        unsigned int                    speed;
 412};
 413
 414/* Standard request handlers result codes */
 415enum std_req_rc {
 416        std_req_stall = -1,     /* Stall requested */
 417        std_req_complete = 0,   /* Request completed with no data */
 418        std_req_data = 1,       /* Request completed with data */
 419        std_req_driver = 2,     /* Pass to driver pls */
 420};
 421
 422#ifdef CONFIG_USB_GADGET_VERBOSE
 423#define UDCVDBG(u, fmt...)      dev_dbg(&(u)->pdev->dev, fmt)
 424
 425#define EPVDBG(ep, fmt, ...)    do {                    \
 426        dev_dbg(&(ep)->vhub->pdev->dev,                 \
 427                "%s:EP%d " fmt,                         \
 428                (ep)->dev ? (ep)->dev->name : "hub",    \
 429                (ep)->d_idx, ##__VA_ARGS__);            \
 430        } while(0)
 431
 432#define DVDBG(d, fmt, ...)      do {                    \
 433        dev_dbg(&(d)->vhub->pdev->dev,                  \
 434                "%s " fmt, (d)->name,                   \
 435                ##__VA_ARGS__);                         \
 436        } while(0)
 437
 438#else
 439#define UDCVDBG(u, fmt...)      do { } while(0)
 440#define EPVDBG(ep, fmt, ...)    do { } while(0)
 441#define DVDBG(d, fmt, ...)      do { } while(0)
 442#endif
 443
 444#ifdef CONFIG_USB_GADGET_DEBUG
 445#define UDCDBG(u, fmt...)       dev_dbg(&(u)->pdev->dev, fmt)
 446
 447#define EPDBG(ep, fmt, ...)     do {                    \
 448        dev_dbg(&(ep)->vhub->pdev->dev,                 \
 449                "%s:EP%d " fmt,                         \
 450                (ep)->dev ? (ep)->dev->name : "hub",    \
 451                (ep)->d_idx, ##__VA_ARGS__);            \
 452        } while(0)
 453
 454#define DDBG(d, fmt, ...)       do {                    \
 455        dev_dbg(&(d)->vhub->pdev->dev,                  \
 456                "%s " fmt, (d)->name,                   \
 457                ##__VA_ARGS__);                         \
 458        } while(0)
 459#else
 460#define UDCDBG(u, fmt...)       do { } while(0)
 461#define EPDBG(ep, fmt, ...)     do { } while(0)
 462#define DDBG(d, fmt, ...)       do { } while(0)
 463#endif
 464
 465static inline void vhub_dma_workaround(void *addr)
 466{
 467        /*
 468         * This works around a confirmed HW issue with the Aspeed chip.
 469         *
 470         * The core uses a different bus to memory than the AHB going to
 471         * the USB device controller. Due to the latter having a higher
 472         * priority than the core for arbitration on that bus, it's
 473         * possible for an MMIO to the device, followed by a DMA by the
 474         * device from memory to all be performed and services before
 475         * a previous store to memory gets completed.
 476         *
 477         * This the following scenario can happen:
 478         *
 479         *    - Driver writes to a DMA descriptor (Mbus)
 480         *    - Driver writes to the MMIO register to start the DMA (AHB)
 481         *    - The gadget sees the second write and sends a read of the
 482         *      descriptor to the memory controller (Mbus)
 483         *    - The gadget hits memory before the descriptor write
 484         *      causing it to read an obsolete value.
 485         *
 486         * Thankfully the problem is limited to the USB gadget device, other
 487         * masters in the SoC all have a lower priority than the core, thus
 488         * ensuring that the store by the core arrives first.
 489         *
 490         * The workaround consists of using a dummy read of the memory before
 491         * doing the MMIO writes. This will ensure that the previous writes
 492         * have been "pushed out".
 493         */
 494        mb();
 495        (void)__raw_readl((void __iomem *)addr);
 496}
 497
 498/* core.c */
 499void ast_vhub_done(struct ast_vhub_ep *ep, struct ast_vhub_req *req,
 500                   int status);
 501void ast_vhub_nuke(struct ast_vhub_ep *ep, int status);
 502struct usb_request *ast_vhub_alloc_request(struct usb_ep *u_ep,
 503                                           gfp_t gfp_flags);
 504void ast_vhub_free_request(struct usb_ep *u_ep, struct usb_request *u_req);
 505void ast_vhub_init_hw(struct ast_vhub *vhub);
 506
 507/* ep0.c */
 508void ast_vhub_ep0_handle_ack(struct ast_vhub_ep *ep, bool in_ack);
 509void ast_vhub_ep0_handle_setup(struct ast_vhub_ep *ep);
 510void ast_vhub_init_ep0(struct ast_vhub *vhub, struct ast_vhub_ep *ep,
 511                       struct ast_vhub_dev *dev);
 512int ast_vhub_reply(struct ast_vhub_ep *ep, char *ptr, int len);
 513int __ast_vhub_simple_reply(struct ast_vhub_ep *ep, int len, ...);
 514#define ast_vhub_simple_reply(udc, ...)                                        \
 515        __ast_vhub_simple_reply((udc),                                         \
 516                               sizeof((u8[]) { __VA_ARGS__ })/sizeof(u8),      \
 517                               __VA_ARGS__)
 518
 519/* hub.c */
 520void ast_vhub_init_hub(struct ast_vhub *vhub);
 521enum std_req_rc ast_vhub_std_hub_request(struct ast_vhub_ep *ep,
 522                                         struct usb_ctrlrequest *crq);
 523enum std_req_rc ast_vhub_class_hub_request(struct ast_vhub_ep *ep,
 524                                           struct usb_ctrlrequest *crq);
 525void ast_vhub_device_connect(struct ast_vhub *vhub, unsigned int port,
 526                             bool on);
 527void ast_vhub_hub_suspend(struct ast_vhub *vhub);
 528void ast_vhub_hub_resume(struct ast_vhub *vhub);
 529void ast_vhub_hub_reset(struct ast_vhub *vhub);
 530void ast_vhub_hub_wake_all(struct ast_vhub *vhub);
 531
 532/* dev.c */
 533int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx);
 534void ast_vhub_del_dev(struct ast_vhub_dev *d);
 535void ast_vhub_dev_irq(struct ast_vhub_dev *d);
 536int ast_vhub_std_dev_request(struct ast_vhub_ep *ep,
 537                             struct usb_ctrlrequest *crq);
 538
 539/* epn.c */
 540void ast_vhub_epn_ack_irq(struct ast_vhub_ep *ep);
 541void ast_vhub_update_epn_stall(struct ast_vhub_ep *ep);
 542struct ast_vhub_ep *ast_vhub_alloc_epn(struct ast_vhub_dev *d, u8 addr);
 543void ast_vhub_dev_suspend(struct ast_vhub_dev *d);
 544void ast_vhub_dev_resume(struct ast_vhub_dev *d);
 545void ast_vhub_dev_reset(struct ast_vhub_dev *d);
 546
 547#endif /* __ASPEED_VHUB_H */
 548