23 #if CONFIG(DEBUG_CONSOLE_INIT)
28 # define dprintk(LEVEL, args...) \
29 do { if (!dbgp_enabled()) printk(LEVEL, ##args); } while (0)
31 # define dprintk(LEVEL, args...) do {} while (0)
34 #define DBGP_LEN_UPDATE(x, len) (((x) & ~0x0f) | ((len) & 0x0f))
36 #define DBGP_CLAIM (DBGP_OWNER | DBGP_ENABLED | DBGP_INUSE)
38 #define HUB_ROOT_RESET_TIME 50
39 #define HUB_SHORT_RESET_TIME 10
40 #define HUB_LONG_RESET_TIME 200
41 #define HUB_RESET_TIMEOUT 500
43 #define DBGP_MICROFRAME_TIMEOUT_LOOPS 1000
44 #define DBGP_MICROFRAME_RETRIES 10
45 #define DBGP_MAX_PACKET 8
60 die(
"BUG: Increase ehci_dbg_info reserve in CAR");
100 unsigned int ctrl,
const int timeout)
102 u32 rd_ctrl, rd_pids;
103 u32 ctrl_prev = 0, pids_prev = 0;
105 int ret, host_retries;
111 if (loop++ >= timeout)
117 if (loop == 1 || host_retries > 1)
119 loop, host_retries, ctrl |
DBGP_GO);
125 if (rd_ctrl != ctrl_prev || rd_pids != pids_prev || (ret<0)) {
129 loop, host_retries, rd_ctrl, rd_pids, ret);
173 const unsigned char *bytes =
buf;
178 for (i = 0; i < 4 && i < size; i++)
179 lo |= bytes[i] << (8*i);
180 for (; i < 8 && i < size; i++)
181 hi |= bytes[i] << (8*(i - 4));
188 unsigned char *bytes =
buf;
194 for (i = 0; i < 4 && i < size; i++)
195 bytes[i] = (lo >> (8*i)) & 0xff;
196 for (; i < 8 && i < size; i++)
197 bytes[i] = (hi >> (8*(i - 4))) & 0xff;
216 for (i = 0; i < 4 && i < len; i++)
218 for (; i < 8 && i < len; i++)
225 const char *bytes,
int size)
258 void *data,
int size)
298 for (i = 0; i < 1000; i++)
304 int request,
int value,
int index,
void *data,
int size)
321 req.
wIndex = cpu_to_le16(index);
322 req.
wLength = cpu_to_le16(size);
324 pipe->devnum = devnum;
327 pipe->timeout = 1000;
346 else if (!read && size)
390 }
while ((portsc &
PORT_RESET) && (--loop > 0));
412 for (reps = 0; reps < 3; reps++) {
429 u32 cmd, ctrl,
status, portsc, hcs_params;
430 u32 debug_port, new_debug_port = 0, n_ports;
438 info->ehci_base = ehci_bar;
450 if (CONFIG_USBDEBUG_DEFAULT_PORT > 0)
466 for (i = 1; i <= n_ports; i++) {
471 if (port_map_tried && (new_debug_port != debug_port)) {
489 }
while (!(status &
STS_HALT) && (--loop > 0));
504 }
while ((cmd &
CMD_RESET) && (--loop > 0));
534 }
while ((status &
STS_HALT) && (--loop > 0));
546 goto next_debug_port;
584 if (CONFIG_USBDEBUG_DEFAULT_PORT == 0) {
585 port_map_tried |= (1 << (debug_port - 1));
586 new_debug_port = ((debug_port-1 + 1) % n_ports) + 1;
587 if (port_map_tried != ((1 << n_ports) - 1)) {
689 if (dbg_info_cbmem ==
NULL)
691 memcpy(dbg_info_cbmem, dbg_info,
sizeof(*dbg_info));
696 if (
CONFIG(USBDEBUG_IN_PRE_RAM)) {
735 if (
CONFIG(USBDEBUG_IN_PRE_RAM)
static void write32(void *addr, uint32_t val)
static uint32_t read32(const void *addr)
#define _car_ehci_dbg_info_size
char _car_ehci_dbg_info[]
void * memcpy(void *dest, const void *src, size_t n)
void * memset(void *dstpp, int c, size_t len)
void * cbmem_add(u32 id, u64 size)
void * cbmem_find(u32 id)
#define CBMEM_ID_EHCI_DEBUG
#define printk(level,...)
void __noreturn die(const char *fmt,...)
static struct smmstore_params_info info
#define DBGP_EPADDR(dev, ep)
#define HCS_DEBUG_PORT(p)
#define DBGP_PID_SET(data, tok)
struct ehci_debug_info __packed
static struct ehci_debug_info * glob_dbg_info_p
void dbgp_put(struct dbgp_pipe *pipe)
static struct ehci_debug_info glob_dbg_info
static void migrate_ehci_debug(int is_recovery)
static int usbdebug_init_(uintptr_t ehci_bar, unsigned int offset, struct ehci_debug_info *info)
static int dbgp_enabled(void)
struct dbgp_pipe * dbgp_console_output(void)
static int dbgp_bulk_read(struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe, void *data, int size)
static void dbgp_print_data(struct ehci_dbg_port *ehci_debug)
ROMSTAGE_CBMEM_INIT_HOOK(migrate_ehci_debug)
POSTCAR_CBMEM_INIT_HOOK(migrate_ehci_debug)
struct dbgp_pipe * dbgp_console_input(void)
#define DBGP_MICROFRAME_RETRIES
#define HUB_ROOT_RESET_TIME
static void dbgp_breath(void)
int dbgp_bulk_read_x(struct dbgp_pipe *pipe, void *data, int size)
static int dbgp_bulk_write(struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe, const char *bytes, int size)
int dbgp_ep_is_active(struct dbgp_pipe *pipe)
static void dbgp_set_data(struct ehci_dbg_port *ehci_debug, const void *buf, int size)
int usbdebug_hw_init(bool force)
static int ehci_reset_port(struct ehci_regs *ehci_regs, int port)
static int ehci_wait_for_port(struct ehci_regs *ehci_regs, int port)
static int dbgp_wait_until_complete(struct ehci_dbg_port *ehci_debug)
int dbgp_control_msg(struct ehci_dbg_port *ehci_debug, unsigned int devnum, int requesttype, int request, int value, int index, void *data, int size)
int dbgp_try_get(struct dbgp_pipe *pipe)
#define dprintk(LEVEL, args...)
RAMSTAGE_CBMEM_INIT_HOOK(migrate_ehci_debug)
int dbgp_bulk_write_x(struct dbgp_pipe *pipe, const char *bytes, int size)
#define DBGP_MICROFRAME_TIMEOUT_LOOPS
static struct ehci_debug_info * dbgp_ehci_info(void)
static int dbgp_not_present(void)
#define DBGP_LEN_UPDATE(x, len)
static void dbgp_get_data(struct ehci_dbg_port *ehci_debug, void *buf, int size)
static int dbgp_wait_until_done(struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe, unsigned int ctrl, const int timeout)
int dbgp_probe_gadget(struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe)
#define DBGP_EP_NOT_PRESENT
void usbdebug_disable(void)
int ehci_debug_hw_enable(unsigned int *base, unsigned int *dbg_offset)
#define DBGP_CONSOLE_EPOUT
void usbdebug_re_enable(uintptr_t ehci_base)
#define DBGP_CONSOLE_EPIN
#define DBGP_MAX_ENDPOINTS
void ehci_debug_select_port(unsigned int port)
#define BIOS_INFO
BIOS_INFO - Expected events.
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define BIOS_SPEW
BIOS_SPEW - Excessively verbose output.
#define ENV_SEPARATE_VERSTAGE
struct dbgp_pipe ep_pipe[DBGP_MAX_ENDPOINTS]
#define USB_PID_DATA_TOGGLE