1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #ifndef _EHCI_DEBUG_H_ 4 #define _EHCI_DEBUG_H_ 5 6 #include <types.h> 7 8 void usbdebug_re_enable(uintptr_t ehci_base); 9 void usbdebug_disable(void); 10 11 /* Returns 0 on success and sets MMIO base and dbg_offset if EHCI debug 12 * capability was found and enabled. Returns non-zero on error. 13 */ 14 int ehci_debug_hw_enable(unsigned int *base, unsigned int *dbg_offset); 15 void ehci_debug_select_port(unsigned int port); 16 17 #define DBGP_EP_VALID (1<<0) 18 #define DBGP_EP_ENABLED (1<<1) 19 #define DBGP_EP_BUSY (1<<2) 20 #define DBGP_EP_NOT_PRESENT (1<<3) 21 #define DBGP_EP_STATMASK (DBGP_EP_VALID | DBGP_EP_ENABLED) 22 23 #define DBGP_MAX_ENDPOINTS 4 24 #define DBGP_SETUP_EP0 0 /* Compulsory endpoint 0. */ 25 #define DBGP_CONSOLE_EPOUT 1 26 #define DBGP_CONSOLE_EPIN 2 27 28 struct ehci_dbg_port; 29 30 struct dbgp_pipe 31 { 32 u8 devnum; 33 u8 endpoint; 34 u8 pid; 35 u8 status; 36 u16 timeout; 37 38 u8 bufidx; 39 u8 buflen; 40 char buf[8]; 41 } __packed; 42 43 void dbgp_put(struct dbgp_pipe *pipe); 44 int dbgp_try_get(struct dbgp_pipe *pipe); 45 46 struct dbgp_pipe *dbgp_console_output(void); 47 struct dbgp_pipe *dbgp_console_input(void); 48 int dbgp_ep_is_active(struct dbgp_pipe *pipe); 49 int dbgp_bulk_write_x(struct dbgp_pipe *pipe, const char *bytes, int size); 50 int dbgp_bulk_read_x(struct dbgp_pipe *pipe, void *data, int size); 51 52 int dbgp_control_msg(struct ehci_dbg_port *ehci_debug, unsigned int devnum, 53 int requesttype, int request, int value, int index, void *data, int size); 54 void dbgp_mdelay(int ms); 55 56 int dbgp_probe_gadget(struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe); 57 58 #endif /* _EHCI_DEBUG_H_ */ 59