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 * This program is free software; you can redistribute it and/or modify it 10 * under the terms of the GNU General Public License as published by the 11 * Free Software Foundation; either version 2 of the License, or (at your 12 * option) any later version. 13 * 14 */ 15 16 #include "bdc.h" 17 #include "bdc_dbg.h" 18 19 void bdc_dbg_regs(struct bdc *bdc) 20 { 21 u32 temp; 22 23 dev_vdbg(bdc->dev, "bdc->regs:%p\n", bdc->regs); 24 temp = bdc_readl(bdc->regs, BDC_BDCCFG0); 25 dev_vdbg(bdc->dev, "bdccfg0:0x%08x\n", temp); 26 temp = bdc_readl(bdc->regs, BDC_BDCCFG1); 27 dev_vdbg(bdc->dev, "bdccfg1:0x%08x\n", temp); 28 temp = bdc_readl(bdc->regs, BDC_BDCCAP0); 29 dev_vdbg(bdc->dev, "bdccap0:0x%08x\n", temp); 30 temp = bdc_readl(bdc->regs, BDC_BDCCAP1); 31 dev_vdbg(bdc->dev, "bdccap1:0x%08x\n", temp); 32 temp = bdc_readl(bdc->regs, BDC_USPC); 33 dev_vdbg(bdc->dev, "uspc:0x%08x\n", temp); 34 temp = bdc_readl(bdc->regs, BDC_DVCSA); 35 dev_vdbg(bdc->dev, "dvcsa:0x%08x\n", temp); 36 temp = bdc_readl(bdc->regs, BDC_DVCSB); 37 dev_vdbg(bdc->dev, "dvcsb:0x%x08\n", temp); 38 } 39 40 void bdc_dump_epsts(struct bdc *bdc) 41 { 42 u32 temp; 43 44 temp = bdc_readl(bdc->regs, BDC_EPSTS0); 45 dev_vdbg(bdc->dev, "BDC_EPSTS0:0x%08x\n", temp); 46 47 temp = bdc_readl(bdc->regs, BDC_EPSTS1); 48 dev_vdbg(bdc->dev, "BDC_EPSTS1:0x%x\n", temp); 49 50 temp = bdc_readl(bdc->regs, BDC_EPSTS2); 51 dev_vdbg(bdc->dev, "BDC_EPSTS2:0x%08x\n", temp); 52 53 temp = bdc_readl(bdc->regs, BDC_EPSTS3); 54 dev_vdbg(bdc->dev, "BDC_EPSTS3:0x%08x\n", temp); 55 56 temp = bdc_readl(bdc->regs, BDC_EPSTS4); 57 dev_vdbg(bdc->dev, "BDC_EPSTS4:0x%08x\n", temp); 58 59 temp = bdc_readl(bdc->regs, BDC_EPSTS5); 60 dev_vdbg(bdc->dev, "BDC_EPSTS5:0x%08x\n", temp); 61 62 temp = bdc_readl(bdc->regs, BDC_EPSTS6); 63 dev_vdbg(bdc->dev, "BDC_EPSTS6:0x%08x\n", temp); 64 65 temp = bdc_readl(bdc->regs, BDC_EPSTS7); 66 dev_vdbg(bdc->dev, "BDC_EPSTS7:0x%08x\n", temp); 67 } 68 69 void bdc_dbg_srr(struct bdc *bdc, u32 srr_num) 70 { 71 struct bdc_sr *sr; 72 dma_addr_t addr; 73 int i; 74 75 sr = bdc->srr.sr_bds; 76 addr = bdc->srr.dma_addr; 77 dev_vdbg(bdc->dev, "bdc_dbg_srr sr:%p dqp_index:%d\n", 78 sr, bdc->srr.dqp_index); 79 for (i = 0; i < NUM_SR_ENTRIES; i++) { 80 sr = &bdc->srr.sr_bds[i]; 81 dev_vdbg(bdc->dev, "%llx %08x %08x %08x %08x\n", 82 (unsigned long long)addr, 83 le32_to_cpu(sr->offset[0]), 84 le32_to_cpu(sr->offset[1]), 85 le32_to_cpu(sr->offset[2]), 86 le32_to_cpu(sr->offset[3])); 87 addr += sizeof(*sr); 88 } 89 } 90 91 void bdc_dbg_bd_list(struct bdc *bdc, struct bdc_ep *ep) 92 { 93 struct bd_list *bd_list = &ep->bd_list; 94 struct bd_table *bd_table; 95 struct bdc_bd *bd; 96 int tbi, bdi, gbdi; 97 dma_addr_t dma; 98 99 gbdi = 0; 100 dev_vdbg(bdc->dev, 101 "Dump bd list for %s epnum:%d\n", 102 ep->name, ep->ep_num); 103 104 dev_vdbg(bdc->dev, 105 "tabs:%d max_bdi:%d eqp_bdi:%d hwd_bdi:%d num_bds_table:%d\n", 106 bd_list->num_tabs, bd_list->max_bdi, bd_list->eqp_bdi, 107 bd_list->hwd_bdi, bd_list->num_bds_table); 108 109 for (tbi = 0; tbi < bd_list->num_tabs; tbi++) { 110 bd_table = bd_list->bd_table_array[tbi]; 111 for (bdi = 0; bdi < bd_list->num_bds_table; bdi++) { 112 bd = bd_table->start_bd + bdi; 113 dma = bd_table->dma + (sizeof(struct bdc_bd) * bdi); 114 dev_vdbg(bdc->dev, 115 "tbi:%2d bdi:%2d gbdi:%2d virt:%p phys:%llx %08x %08x %08x %08x\n", 116 tbi, bdi, gbdi++, bd, (unsigned long long)dma, 117 le32_to_cpu(bd->offset[0]), 118 le32_to_cpu(bd->offset[1]), 119 le32_to_cpu(bd->offset[2]), 120 le32_to_cpu(bd->offset[3])); 121 } 122 dev_vdbg(bdc->dev, "\n\n"); 123 } 124 } 125