18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * bdc_dbg.c - BRCM BDC USB3.0 device controller debug functions 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2014 Broadcom Corporation 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Author: Ashwini Pahuja 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include "bdc.h" 118c2ecf20Sopenharmony_ci#include "bdc_dbg.h" 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_civoid bdc_dbg_regs(struct bdc *bdc) 148c2ecf20Sopenharmony_ci{ 158c2ecf20Sopenharmony_ci u32 temp; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "bdc->regs:%p\n", bdc->regs); 188c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_BDCCFG0); 198c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "bdccfg0:0x%08x\n", temp); 208c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_BDCCFG1); 218c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "bdccfg1:0x%08x\n", temp); 228c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_BDCCAP0); 238c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "bdccap0:0x%08x\n", temp); 248c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_BDCCAP1); 258c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "bdccap1:0x%08x\n", temp); 268c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_USPC); 278c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "uspc:0x%08x\n", temp); 288c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_DVCSA); 298c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "dvcsa:0x%08x\n", temp); 308c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_DVCSB); 318c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "dvcsb:0x%x08\n", temp); 328c2ecf20Sopenharmony_ci} 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_civoid bdc_dump_epsts(struct bdc *bdc) 358c2ecf20Sopenharmony_ci{ 368c2ecf20Sopenharmony_ci u32 temp; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_EPSTS0); 398c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "BDC_EPSTS0:0x%08x\n", temp); 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_EPSTS1); 428c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "BDC_EPSTS1:0x%x\n", temp); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_EPSTS2); 458c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "BDC_EPSTS2:0x%08x\n", temp); 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_EPSTS3); 488c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "BDC_EPSTS3:0x%08x\n", temp); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_EPSTS4); 518c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "BDC_EPSTS4:0x%08x\n", temp); 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_EPSTS5); 548c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "BDC_EPSTS5:0x%08x\n", temp); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_EPSTS6); 578c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "BDC_EPSTS6:0x%08x\n", temp); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci temp = bdc_readl(bdc->regs, BDC_EPSTS7); 608c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "BDC_EPSTS7:0x%08x\n", temp); 618c2ecf20Sopenharmony_ci} 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_civoid bdc_dbg_srr(struct bdc *bdc, u32 srr_num) 648c2ecf20Sopenharmony_ci{ 658c2ecf20Sopenharmony_ci struct bdc_sr *sr; 668c2ecf20Sopenharmony_ci dma_addr_t addr; 678c2ecf20Sopenharmony_ci int i; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci sr = bdc->srr.sr_bds; 708c2ecf20Sopenharmony_ci addr = bdc->srr.dma_addr; 718c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "bdc_dbg_srr sr:%p dqp_index:%d\n", 728c2ecf20Sopenharmony_ci sr, bdc->srr.dqp_index); 738c2ecf20Sopenharmony_ci for (i = 0; i < NUM_SR_ENTRIES; i++) { 748c2ecf20Sopenharmony_ci sr = &bdc->srr.sr_bds[i]; 758c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "%llx %08x %08x %08x %08x\n", 768c2ecf20Sopenharmony_ci (unsigned long long)addr, 778c2ecf20Sopenharmony_ci le32_to_cpu(sr->offset[0]), 788c2ecf20Sopenharmony_ci le32_to_cpu(sr->offset[1]), 798c2ecf20Sopenharmony_ci le32_to_cpu(sr->offset[2]), 808c2ecf20Sopenharmony_ci le32_to_cpu(sr->offset[3])); 818c2ecf20Sopenharmony_ci addr += sizeof(*sr); 828c2ecf20Sopenharmony_ci } 838c2ecf20Sopenharmony_ci} 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_civoid bdc_dbg_bd_list(struct bdc *bdc, struct bdc_ep *ep) 868c2ecf20Sopenharmony_ci{ 878c2ecf20Sopenharmony_ci struct bd_list *bd_list = &ep->bd_list; 888c2ecf20Sopenharmony_ci struct bd_table *bd_table; 898c2ecf20Sopenharmony_ci struct bdc_bd *bd; 908c2ecf20Sopenharmony_ci int tbi, bdi, gbdi; 918c2ecf20Sopenharmony_ci dma_addr_t dma; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci gbdi = 0; 948c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, 958c2ecf20Sopenharmony_ci "Dump bd list for %s epnum:%d\n", 968c2ecf20Sopenharmony_ci ep->name, ep->ep_num); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, 998c2ecf20Sopenharmony_ci "tabs:%d max_bdi:%d eqp_bdi:%d hwd_bdi:%d num_bds_table:%d\n", 1008c2ecf20Sopenharmony_ci bd_list->num_tabs, bd_list->max_bdi, bd_list->eqp_bdi, 1018c2ecf20Sopenharmony_ci bd_list->hwd_bdi, bd_list->num_bds_table); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci for (tbi = 0; tbi < bd_list->num_tabs; tbi++) { 1048c2ecf20Sopenharmony_ci bd_table = bd_list->bd_table_array[tbi]; 1058c2ecf20Sopenharmony_ci for (bdi = 0; bdi < bd_list->num_bds_table; bdi++) { 1068c2ecf20Sopenharmony_ci bd = bd_table->start_bd + bdi; 1078c2ecf20Sopenharmony_ci dma = bd_table->dma + (sizeof(struct bdc_bd) * bdi); 1088c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, 1098c2ecf20Sopenharmony_ci "tbi:%2d bdi:%2d gbdi:%2d virt:%p phys:%llx %08x %08x %08x %08x\n", 1108c2ecf20Sopenharmony_ci tbi, bdi, gbdi++, bd, (unsigned long long)dma, 1118c2ecf20Sopenharmony_ci le32_to_cpu(bd->offset[0]), 1128c2ecf20Sopenharmony_ci le32_to_cpu(bd->offset[1]), 1138c2ecf20Sopenharmony_ci le32_to_cpu(bd->offset[2]), 1148c2ecf20Sopenharmony_ci le32_to_cpu(bd->offset[3])); 1158c2ecf20Sopenharmony_ci } 1168c2ecf20Sopenharmony_ci dev_vdbg(bdc->dev, "\n\n"); 1178c2ecf20Sopenharmony_ci } 1188c2ecf20Sopenharmony_ci} 119