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