1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * bdc_dbg.c - BRCM BDC USB3.0 device controller debug functions
4 *
5 * Copyright (C) 2014 Broadcom Corporation
6 *
7 * Author: Ashwini Pahuja
8 */
9
10 #include "bdc.h"
11 #include "bdc_dbg.h"
12
bdc_dbg_regs(struct bdc * bdc)13 void bdc_dbg_regs(struct bdc *bdc)
14 {
15 u32 temp;
16
17 dev_vdbg(bdc->dev, "bdc->regs:%p\n", bdc->regs);
18 temp = bdc_readl(bdc->regs, BDC_BDCCFG0);
19 dev_vdbg(bdc->dev, "bdccfg0:0x%08x\n", temp);
20 temp = bdc_readl(bdc->regs, BDC_BDCCFG1);
21 dev_vdbg(bdc->dev, "bdccfg1:0x%08x\n", temp);
22 temp = bdc_readl(bdc->regs, BDC_BDCCAP0);
23 dev_vdbg(bdc->dev, "bdccap0:0x%08x\n", temp);
24 temp = bdc_readl(bdc->regs, BDC_BDCCAP1);
25 dev_vdbg(bdc->dev, "bdccap1:0x%08x\n", temp);
26 temp = bdc_readl(bdc->regs, BDC_USPC);
27 dev_vdbg(bdc->dev, "uspc:0x%08x\n", temp);
28 temp = bdc_readl(bdc->regs, BDC_DVCSA);
29 dev_vdbg(bdc->dev, "dvcsa:0x%08x\n", temp);
30 temp = bdc_readl(bdc->regs, BDC_DVCSB);
31 dev_vdbg(bdc->dev, "dvcsb:0x%x08\n", temp);
32 }
33
bdc_dump_epsts(struct bdc * bdc)34 void bdc_dump_epsts(struct bdc *bdc)
35 {
36 u32 temp;
37
38 temp = bdc_readl(bdc->regs, BDC_EPSTS0);
39 dev_vdbg(bdc->dev, "BDC_EPSTS0:0x%08x\n", temp);
40
41 temp = bdc_readl(bdc->regs, BDC_EPSTS1);
42 dev_vdbg(bdc->dev, "BDC_EPSTS1:0x%x\n", temp);
43
44 temp = bdc_readl(bdc->regs, BDC_EPSTS2);
45 dev_vdbg(bdc->dev, "BDC_EPSTS2:0x%08x\n", temp);
46
47 temp = bdc_readl(bdc->regs, BDC_EPSTS3);
48 dev_vdbg(bdc->dev, "BDC_EPSTS3:0x%08x\n", temp);
49
50 temp = bdc_readl(bdc->regs, BDC_EPSTS4);
51 dev_vdbg(bdc->dev, "BDC_EPSTS4:0x%08x\n", temp);
52
53 temp = bdc_readl(bdc->regs, BDC_EPSTS5);
54 dev_vdbg(bdc->dev, "BDC_EPSTS5:0x%08x\n", temp);
55
56 temp = bdc_readl(bdc->regs, BDC_EPSTS6);
57 dev_vdbg(bdc->dev, "BDC_EPSTS6:0x%08x\n", temp);
58
59 temp = bdc_readl(bdc->regs, BDC_EPSTS7);
60 dev_vdbg(bdc->dev, "BDC_EPSTS7:0x%08x\n", temp);
61 }
62
bdc_dbg_srr(struct bdc * bdc,u32 srr_num)63 void bdc_dbg_srr(struct bdc *bdc, u32 srr_num)
64 {
65 struct bdc_sr *sr;
66 dma_addr_t addr;
67 int i;
68
69 sr = bdc->srr.sr_bds;
70 addr = bdc->srr.dma_addr;
71 dev_vdbg(bdc->dev, "%s sr:%p dqp_index:%d\n", __func__,
72 sr, bdc->srr.dqp_index);
73 for (i = 0; i < NUM_SR_ENTRIES; i++) {
74 sr = &bdc->srr.sr_bds[i];
75 dev_vdbg(bdc->dev, "%llx %08x %08x %08x %08x\n",
76 (unsigned long long)addr,
77 le32_to_cpu(sr->offset[0]),
78 le32_to_cpu(sr->offset[1]),
79 le32_to_cpu(sr->offset[2]),
80 le32_to_cpu(sr->offset[3]));
81 addr += sizeof(*sr);
82 }
83 }
84
bdc_dbg_bd_list(struct bdc * bdc,struct bdc_ep * ep)85 void bdc_dbg_bd_list(struct bdc *bdc, struct bdc_ep *ep)
86 {
87 struct bd_list *bd_list = &ep->bd_list;
88 struct bd_table *bd_table;
89 struct bdc_bd *bd;
90 int tbi, bdi, gbdi;
91 dma_addr_t dma;
92
93 gbdi = 0;
94 dev_vdbg(bdc->dev,
95 "Dump bd list for %s epnum:%d\n",
96 ep->name, ep->ep_num);
97
98 dev_vdbg(bdc->dev,
99 "tabs:%d max_bdi:%d eqp_bdi:%d hwd_bdi:%d num_bds_table:%d\n",
100 bd_list->num_tabs, bd_list->max_bdi, bd_list->eqp_bdi,
101 bd_list->hwd_bdi, bd_list->num_bds_table);
102
103 for (tbi = 0; tbi < bd_list->num_tabs; tbi++) {
104 bd_table = bd_list->bd_table_array[tbi];
105 for (bdi = 0; bdi < bd_list->num_bds_table; bdi++) {
106 bd = bd_table->start_bd + bdi;
107 dma = bd_table->dma + (sizeof(struct bdc_bd) * bdi);
108 dev_vdbg(bdc->dev,
109 "tbi:%2d bdi:%2d gbdi:%2d virt:%p phys:%llx %08x %08x %08x %08x\n",
110 tbi, bdi, gbdi++, bd, (unsigned long long)dma,
111 le32_to_cpu(bd->offset[0]),
112 le32_to_cpu(bd->offset[1]),
113 le32_to_cpu(bd->offset[2]),
114 le32_to_cpu(bd->offset[3]));
115 }
116 dev_vdbg(bdc->dev, "\n\n");
117 }
118 }
119