mb/amb/birman*/gpio: remove configuration for VDD_MEM_VID[0,1]
[coreboot2.git] / payloads / libpayload / drivers / usb / xhci_debug.c
blobc9fef44ae77f2e21df4dc2155090145df7f2fb62
1 /*
3 * Copyright (C) 2013 secunet Security Networks AG
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
29 #include <inttypes.h>
30 #include "xhci_private.h"
32 #ifdef XHCI_DUMPS
34 void
35 xhci_dump_slotctx(const slotctx_t *const sc)
37 xhci_debug("Slot Context (@%p):\n", sc);
38 usb_debug(" FIELD1\t0x%08"PRIx32"\n", sc->f1);
39 usb_debug(" FIELD2\t0x%08"PRIx32"\n", sc->f2);
40 usb_debug(" FIELD3\t0x%08"PRIx32"\n", sc->f3);
41 usb_debug(" FIELD4\t0x%08"PRIx32"\n", sc->f4);
42 SC_DUMP(ROUTE, sc);
43 SC_DUMP(SPEED1, sc);
44 SC_DUMP(MTT, sc);
45 SC_DUMP(HUB, sc);
46 SC_DUMP(CTXENT, sc);
47 SC_DUMP(RHPORT, sc);
48 SC_DUMP(NPORTS, sc);
49 SC_DUMP(TTID, sc);
50 SC_DUMP(TTPORT, sc);
51 SC_DUMP(TTT, sc);
52 SC_DUMP(UADDR, sc);
53 SC_DUMP(STATE, sc);
56 void
57 xhci_dump_epctx(const epctx_t *const ec)
59 xhci_debug("Endpoint Context (@%p):\n", ec);
60 usb_debug(" FIELD1\t0x%08"PRIx32"\n", ec->f1);
61 usb_debug(" FIELD2\t0x%08"PRIx32"\n", ec->f2);
62 usb_debug(" TRDQ_L\t0x%08"PRIx32"\n", ec->tr_dq_low);
63 usb_debug(" TRDQ_H\t0x%08"PRIx32"\n", ec->tr_dq_high);
64 usb_debug(" FIELD5\t0x%08"PRIx32"\n", ec->f5);
65 EC_DUMP(STATE, ec);
66 EC_DUMP(INTVAL, ec);
67 EC_DUMP(CERR, ec);
68 EC_DUMP(TYPE, ec);
69 EC_DUMP(MBS, ec);
70 EC_DUMP(MPS, ec);
71 EC_DUMP(DCS, ec);
72 EC_DUMP(AVRTRB, ec);
73 EC_DUMP(MXESIT, ec);
76 void
77 xhci_dump_devctx(const devctx_t *const dc, const u32 ctx_mask)
79 int i;
80 if (ctx_mask & 1)
81 xhci_dump_slotctx(dc->slot);
82 for (i = 1; i <= SC_GET(CTXENT, dc->slot); ++i) {
83 if (ctx_mask & (1 << i))
84 xhci_dump_epctx(dc->ep[i]);
88 void
89 xhci_dump_inputctx(const inputctx_t *const ic)
91 xhci_debug("Input Control add: 0x%08"PRIx32"\n", *ic->add);
92 xhci_debug("Input Control drop: 0x%08"PRIx32"\n", *ic->drop);
93 xhci_dump_devctx(&ic->dev, *ic->add);
96 void
97 xhci_dump_transfer_trb(const trb_t *const cur)
99 xhci_debug("Transfer TRB (@%p):\n", cur);
100 usb_debug(" PTR_L\t0x%08"PRIx32"\n", cur->ptr_low);
101 usb_debug(" PTR_H\t0x%08"PRIx32"\n", cur->ptr_high);
102 usb_debug(" STATUS\t0x%08"PRIx32"\n", cur->status);
103 usb_debug(" CNTRL\t0x%08"PRIx32"\n", cur->control);
104 TRB_DUMP(TL, cur);
105 TRB_DUMP(TDS, cur);
106 TRB_DUMP(C, cur);
107 TRB_DUMP(ISP, cur);
108 TRB_DUMP(CH, cur);
109 TRB_DUMP(IOC, cur);
110 TRB_DUMP(IDT, cur);
111 TRB_DUMP(TT, cur);
112 TRB_DUMP(DIR, cur);
115 static const trb_t *
116 xhci_next_trb(const trb_t *const cur)
118 if (TRB_GET(TT, cur) == TRB_LINK)
119 return (!cur->ptr_low) ? NULL : phys_to_virt(cur->ptr_low);
120 else
121 return cur + 1;
124 void
125 xhci_dump_transfer_trbs(const trb_t *const first, const trb_t *const last)
127 const trb_t *cur;
128 for (cur = first; cur; cur = xhci_next_trb(cur)) {
129 xhci_dump_transfer_trb(cur);
130 if (cur == last)
131 break;
135 #endif