1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Standalone EHCI usb debug driver
4  *
5  * Originally written by:
6  *  Eric W. Biederman" <ebiederm@xmission.com> and
7  *  Yinghai Lu <yhlu.kernel@gmail.com>
8  *
9  * Changes for early/late printk and HW errata:
10  *  Jason Wessel <jason.wessel@windriver.com>
11  *  Copyright (C) 2009 Wind River Systems, Inc.
12  *
13  */
14 
15 #ifndef __LINUX_USB_EHCI_DBGP_H
16 #define __LINUX_USB_EHCI_DBGP_H
17 
18 #include <linux/console.h>
19 #include <linux/types.h>
20 
21 /* Appendix C, Debug port ... intended for use with special "debug devices"
22  * that can help if there's no serial console.  (nonstandard enumeration.)
23  */
24 struct ehci_dbg_port {
25 	u32	control;
26 #define DBGP_OWNER	(1<<30)
27 #define DBGP_ENABLED	(1<<28)
28 #define DBGP_DONE	(1<<16)
29 #define DBGP_INUSE	(1<<10)
30 #define DBGP_ERRCODE(x)	(((x)>>7)&0x07)
31 #	define DBGP_ERR_BAD	1
32 #	define DBGP_ERR_SIGNAL	2
33 #define DBGP_ERROR	(1<<6)
34 #define DBGP_GO		(1<<5)
35 #define DBGP_OUT	(1<<4)
36 #define DBGP_LEN(x)	(((x)>>0)&0x0f)
37 	u32	pids;
38 #define DBGP_PID_GET(x)		(((x)>>16)&0xff)
39 #define DBGP_PID_SET(data, tok)	(((data)<<8)|(tok))
40 	u32	data03;
41 	u32	data47;
42 	u32	address;
43 #define DBGP_EPADDR(dev, ep)	(((dev)<<8)|(ep))
44 };
45 
46 #ifdef CONFIG_EARLY_PRINTK_DBGP
47 extern int early_dbgp_init(char *s);
48 extern struct console early_dbgp_console;
49 #endif /* CONFIG_EARLY_PRINTK_DBGP */
50 
51 struct usb_hcd;
52 
53 #ifdef CONFIG_XEN_DOM0
54 extern int xen_dbgp_reset_prep(struct usb_hcd *);
55 extern int xen_dbgp_external_startup(struct usb_hcd *);
56 #else
xen_dbgp_reset_prep(struct usb_hcd * hcd)57 static inline int xen_dbgp_reset_prep(struct usb_hcd *hcd)
58 {
59 	return 1; /* Shouldn't this be 0? */
60 }
61 
xen_dbgp_external_startup(struct usb_hcd * hcd)62 static inline int xen_dbgp_external_startup(struct usb_hcd *hcd)
63 {
64 	return -1;
65 }
66 #endif
67 
68 #ifdef CONFIG_EARLY_PRINTK_DBGP
69 /* Call backs from ehci host driver to ehci debug driver */
70 extern int dbgp_external_startup(struct usb_hcd *);
71 extern int dbgp_reset_prep(struct usb_hcd *);
72 #else
dbgp_reset_prep(struct usb_hcd * hcd)73 static inline int dbgp_reset_prep(struct usb_hcd *hcd)
74 {
75 	return xen_dbgp_reset_prep(hcd);
76 }
77 
dbgp_external_startup(struct usb_hcd * hcd)78 static inline int dbgp_external_startup(struct usb_hcd *hcd)
79 {
80 	return xen_dbgp_external_startup(hcd);
81 }
82 #endif
83 
84 #endif /* __LINUX_USB_EHCI_DBGP_H */
85