blob: 2a1629df40afbee738b0b636aab0494ab98815b0 [file] [log] [blame]
Kyösti Mälkkicb141bc2014-02-07 19:24:23 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007 AMD
5 * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Kyösti Mälkkicb141bc2014-02-07 19:24:23 +020015 */
16
17#ifndef _EHCI_DEBUG_H_
18#define _EHCI_DEBUG_H_
19
Kyösti Mälkkiea6736a2014-02-10 00:00:44 +020020#include <types.h>
21
Kyösti Mälkkicb141bc2014-02-07 19:24:23 +020022void usbdebug_re_enable(unsigned ehci_base);
23void usbdebug_disable(void);
24
Kyösti Mälkki6f6a2492014-02-09 19:21:30 +020025/* Returns 0 on success and sets MMIO base and dbg_offset if EHCI debug
26 * capability was found and enabled. Returns non-zero on error.
27 */
28int ehci_debug_hw_enable(unsigned *base, unsigned *dbg_offset);
Kyösti Mälkkicb141bc2014-02-07 19:24:23 +020029void ehci_debug_select_port(unsigned int port);
30
Kyösti Mälkki8cde8522014-02-09 23:35:39 +020031#define DBGP_EP_VALID (1<<0)
32#define DBGP_EP_ENABLED (1<<1)
33#define DBGP_EP_BUSY (1<<2)
34#define DBGP_EP_STATMASK (DBGP_EP_VALID | DBGP_EP_ENABLED)
35
Kyösti Mälkki46249be22014-10-27 14:07:28 +020036#define DBGP_MAX_ENDPOINTS 4
37#define DBGP_SETUP_EP0 0 /* Compulsory endpoint 0. */
38#define DBGP_CONSOLE_EPOUT 1
39#define DBGP_CONSOLE_EPIN 2
40
Kyösti Mälkki83fe6d72014-02-25 20:11:52 +020041struct ehci_dbg_port;
42
Kyösti Mälkki8cde8522014-02-09 23:35:39 +020043struct dbgp_pipe
44{
45 u8 devnum;
46 u8 endpoint;
47 u8 pid;
48 u8 status;
49 int timeout;
50
51 u8 bufidx;
52 u8 buflen;
53 char buf[8];
54};
55
56void dbgp_put(struct dbgp_pipe *pipe);
57int dbgp_try_get(struct dbgp_pipe *pipe);
58
Kyösti Mälkkiea6736a2014-02-10 00:00:44 +020059struct dbgp_pipe *dbgp_console_output(void);
60struct dbgp_pipe *dbgp_console_input(void);
61int dbgp_ep_is_active(struct dbgp_pipe *pipe);
62int dbgp_bulk_write_x(struct dbgp_pipe *pipe, const char *bytes, int size);
63int dbgp_bulk_read_x(struct dbgp_pipe *pipe, void *data, int size);
64
Kyösti Mälkki83fe6d72014-02-25 20:11:52 +020065int dbgp_control_msg(struct ehci_dbg_port *ehci_debug, unsigned devnum,
66 int requesttype, int request, int value, int index, void *data, int size);
67void dbgp_mdelay(int ms);
68
69int dbgp_probe_gadget(struct ehci_dbg_port *ehci_debug, struct dbgp_pipe *pipe);
70
Kyösti Mälkkicb141bc2014-02-07 19:24:23 +020071#endif /* _EHCI_DEBUG_H_ */