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