Skip to content

Commit

Permalink
dma: dw: Add a debug utility function
Browse files Browse the repository at this point in the history
Add a helper function to dump the GPDMA SHIM and channel registers for
debug along with a config option to enable it.

Co-developed-by: Tom Burdick <thomas.burdick@intel.com>
Singed-off-by: Tom Burdick <thomas.burdick@intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
  • Loading branch information
ranj063 authored and carlescufi committed Mar 17, 2023
1 parent 8ba2796 commit 045c686
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/dma/Kconfig.intel_adsp_gpdma
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ config DMA_INTEL_ADSP_GPDMA_HAS_LLP
Intel ADSP GPDMA may optionally have a linear link position
feature.

config DMA_INTEL_ADSP_GPDMA_DEBUG
bool "Debug dump for IP registers"
help
Dump Intel ADSP GPDMA registers for debug

source "drivers/dma/Kconfig.dw_common"

endif # DMA_INTEL_ADSP_GPDMA
4 changes: 4 additions & 0 deletions drivers/dma/dma_dw_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ extern "C" {
/* min number of elems for config with irq disabled */
#define DW_DMA_CFG_NO_IRQ_MIN_ELEMS 3

#define DW_DMA_CHANNEL_REGISTER_OFFSET_END 0x50
#define DW_DMA_IP_REGISTER_OFFSET_END 0x418
#define DW_DMA_IP_REGISTER_OFFSET_START 0x2C0

/* linked list item address */
#define DW_DMA_LLI_ADDRESS(lli, dir) \
(((dir) == MEMORY_TO_PERIPHERAL) ? ((lli)->sar) : ((lli)->dar))
Expand Down
32 changes: 32 additions & 0 deletions drivers/dma/dma_intel_adsp_gpdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,38 @@ struct intel_adsp_gpdma_cfg {
uint32_t shim;
};

#ifdef DMA_INTEL_ADSP_GPDMA_DEBUG
static void intel_adsp_gpdma_dump_registers(const struct device *dev, uint32_t channel)
{
const struct intel_adsp_gpdma_cfg *const dev_cfg = dev->config;
const struct dw_dma_dev_cfg *const dw_cfg = &dev_cfg->dw_cfg;
uint32_t cap, ctl, ipptr, llpc, llpl, llpu;
int i;

/* Shims */
cap = dw_read(dev_cfg->shim, 0x0);
ctl = dw_read(dev_cfg->shim, 0x4);
ipptr = dw_read(dev_cfg->shim, 0x8);
llpc = dw_read(dev_cfg->shim, GPDMA_CHLLPC_OFFSET(channel));
llpl = dw_read(dev_cfg->shim, GPDMA_CHLLPL(channel));
llpu = dw_read(dev_cfg->shim, GPDMA_CHLLPU(channel));

LOG_INF("channel: %d cap %x, ctl %x, ipptr %x, llpc %x, llpl %x, llpu %x",
channel, cap, ctl, ipptr, llpc, llpl, llpu);

/* Channel Register Dump */
for (i = 0; i <= DW_DMA_CHANNEL_REGISTER_OFFSET_END; i += 0x8)
LOG_INF(" channel register offset: %#x value: %#x\n", chan_reg_offs[i],
dw_read(dw_cfg->base, DW_CHAN_OFFSET(channel) + chan_reg_offs[i]));

/* IP Register Dump */
for (i = DW_DMA_CHANNEL_REGISTER_OFFSET_START; i <= DW_DMA_CHANNEL_REGISTER_OFFSET_END;
i += 0x8)
LOG_INF(" ip register offset: %#x value: %#x\n", ip_reg_offs[i],
dw_read(dw_cfg->base, ip_reg_offs[i]));
}
#endif

static void intel_adsp_gpdma_llp_config(const struct device *dev,
uint32_t channel, uint32_t dma_slot)
{
Expand Down

0 comments on commit 045c686

Please sign in to comment.