This patch proposes to move the platform DMAC initialization code to the dmac_init() routine.
Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com --- src/include/sof/dma.h | 3 +++ src/platform/apollolake/dma.c | 12 ++++++++++++ src/platform/apollolake/platform.c | 21 +-------------------- src/platform/baytrail/dma.c | 12 ++++++++++++ src/platform/baytrail/platform.c | 22 +--------------------- src/platform/cannonlake/dma.c | 12 ++++++++++++ src/platform/cannonlake/platform.c | 21 +-------------------- src/platform/haswell/dma.c | 19 +++++++++++++++++++ src/platform/haswell/platform.c | 20 +------------------- 9 files changed, 62 insertions(+), 80 deletions(-)
diff --git a/src/include/sof/dma.h b/src/include/sof/dma.h index 7ba1298..80ca880 100644 --- a/src/include/sof/dma.h +++ b/src/include/sof/dma.h @@ -140,6 +140,9 @@ struct dma_int {
struct dma *dma_get(int dmac_id);
+/* initialize all platform DMAC's */ +void dmac_init(void); + #define dma_set_drvdata(dma, data) \ dma->private = data #define dma_get_drvdata(dma) \ diff --git a/src/platform/apollolake/dma.c b/src/platform/apollolake/dma.c index 90dde96..da413e3 100644 --- a/src/platform/apollolake/dma.c +++ b/src/platform/apollolake/dma.c @@ -181,3 +181,15 @@ struct dma *dma_get(int dmac_id)
return NULL; } + +/* Initialize all platform DMAC's */ +void dmac_init(void) +{ + int i, ret; + + for (i = 0; i < ARRAY_SIZE(dma); i++) { + ret = dma_probe(&dma[i]); + if (ret < 0) + trace_error_value(ret); + } +} diff --git a/src/platform/apollolake/platform.c b/src/platform/apollolake/platform.c index 0b26ae5..589c77e 100644 --- a/src/platform/apollolake/platform.c +++ b/src/platform/apollolake/platform.c @@ -186,7 +186,6 @@ static void platform_memory_windows_init(void)
int platform_init(struct sof *sof) { - struct dma *dmac; struct dai *ssp; struct dai *dmic0; int i; @@ -244,25 +243,7 @@ int platform_init(struct sof *sof)
/* init DMACs */ trace_point(TRACE_BOOT_PLATFORM_DMA); - dmac = dma_get(DMA_GP_LP_DMAC0); - if (dmac == NULL) - return -ENODEV; - dma_probe(dmac); - - dmac = dma_get(DMA_GP_LP_DMAC1); - if (dmac == NULL) - return -ENODEV; - dma_probe(dmac); - - dmac = dma_get(DMA_HOST_OUT_DMAC); - if (dmac == NULL) - return -ENODEV; - dma_probe(dmac); - - dmac = dma_get(DMA_HOST_IN_DMAC); - if (dmac == NULL) - return -ENODEV; - dma_probe(dmac); + dmac_init();
/* init SSP ports */ trace_point(TRACE_BOOT_PLATFORM_SSP); diff --git a/src/platform/baytrail/dma.c b/src/platform/baytrail/dma.c index 53602f5..142b62a 100644 --- a/src/platform/baytrail/dma.c +++ b/src/platform/baytrail/dma.c @@ -186,3 +186,15 @@ struct dma *dma_get(int dmac_id)
return NULL; } + +/* Initialize all platform DMAC's */ +void dmac_init(void) +{ + int i, ret; + + for (i = 0; i < ARRAY_SIZE(dma); i++) { + ret = dma_probe(&dma[i]); + if (ret < 0) + trace_error_value(ret); + } +} diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c index 562fabf..50acda9 100644 --- a/src/platform/baytrail/platform.c +++ b/src/platform/baytrail/platform.c @@ -290,15 +290,10 @@ void platform_interrupt_unmask(uint32_t irq, uint32_t mask) int platform_init(struct sof *sof) { #if defined CONFIG_BAYTRAIL - struct dma *dmac0; - struct dma *dmac1; struct dai *ssp0; struct dai *ssp1; struct dai *ssp2; #elif defined CONFIG_CHERRYTRAIL - struct dma *dmac0; - struct dma *dmac1; - struct dma *dmac2; struct dai *ssp0; struct dai *ssp1; struct dai *ssp2; @@ -356,22 +351,7 @@ int platform_init(struct sof *sof)
/* init DMACs */ trace_point(TRACE_BOOT_PLATFORM_DMA); - dmac0 = dma_get(DMA_ID_DMAC0); - if (dmac0 == NULL) - return -ENODEV; - dma_probe(dmac0); - - dmac1 = dma_get(DMA_ID_DMAC1); - if (dmac1 == NULL) - return -ENODEV; - dma_probe(dmac1); - -#if defined CONFIG_CHERRYTRAIL - dmac2 = dma_get(DMA_ID_DMAC1); - if (dmac2 == NULL) - return -ENODEV; - dma_probe(dmac2); -#endif + dmac_init();
/* mask SSP 0 - 2 interrupts */ shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) | 0x00000038); diff --git a/src/platform/cannonlake/dma.c b/src/platform/cannonlake/dma.c index 3f9d6cb..1d08a1f 100644 --- a/src/platform/cannonlake/dma.c +++ b/src/platform/cannonlake/dma.c @@ -182,3 +182,15 @@ struct dma *dma_get(int dmac_id)
return NULL; } + +/* Initialize all platform DMAC's */ +void dmac_init(void) +{ + int i, ret; + + for (i = 0; i < ARRAY_SIZE(dma); i++) { + ret = dma_probe(&dma[i]); + if (ret < 0) + trace_error_value(ret); + } +} diff --git a/src/platform/cannonlake/platform.c b/src/platform/cannonlake/platform.c index 2e85088..3ca48e5 100644 --- a/src/platform/cannonlake/platform.c +++ b/src/platform/cannonlake/platform.c @@ -208,7 +208,6 @@ static struct timer platform_ext_timer = {
int platform_init(struct sof *sof) { - struct dma *dmac; struct dai *ssp; struct dai *dmic0; int i; @@ -261,25 +260,7 @@ int platform_init(struct sof *sof)
/* init DMACs */ trace_point(TRACE_BOOT_PLATFORM_DMA); - dmac = dma_get(DMA_GP_LP_DMAC0); - if (!dmac) - return -ENODEV; - dma_probe(dmac); - - dmac = dma_get(DMA_GP_LP_DMAC1); - if (!dmac) - return -ENODEV; - dma_probe(dmac); - - dmac = dma_get(DMA_HOST_OUT_DMAC); - if (!dmac) - return -ENODEV; - dma_probe(dmac); - - dmac = dma_get(DMA_HOST_IN_DMAC); - if (!dmac) - return -ENODEV; - dma_probe(dmac); + dmac_init();
/* init SSP ports */ trace_point(TRACE_BOOT_PLATFORM_SSP); diff --git a/src/platform/haswell/dma.c b/src/platform/haswell/dma.c index 42df546..1bd424e 100644 --- a/src/platform/haswell/dma.c +++ b/src/platform/haswell/dma.c @@ -135,3 +135,22 @@ struct dma *dma_get(int dmac_id) return NULL; } } + +/* Initialize all platform DMAC's */ +void dmac_init(void) +{ + int i, ret; + + for (i = 0; i < ARRAY_SIZE(dma); i++) { + ret = dma_probe(&dma[i]); + if (ret < 0) + trace_error_value(ret); + } + + /* clear the masks for dsp of the dmacs */ + io_reg_update_bits(SHIM_BASE + SHIM_IMRD, + SHIM_IMRD_DMAC0, 0); + + io_reg_update_bits(SHIM_BASE + SHIM_IMRD, + SHIM_IMRD_DMAC1, 0); +} diff --git a/src/platform/haswell/platform.c b/src/platform/haswell/platform.c index 81ce67a..710400c 100644 --- a/src/platform/haswell/platform.c +++ b/src/platform/haswell/platform.c @@ -240,8 +240,6 @@ static void platform_init_shim(void)
int platform_init(struct sof *sof) { - struct dma *dmac0; - struct dma *dmac1; struct dai *ssp0; struct dai *ssp1;
@@ -280,23 +278,7 @@ int platform_init(struct sof *sof)
/* init DMACs */ trace_point(TRACE_BOOT_PLATFORM_DMA); - dmac0 = dma_get(DMA_ID_DMAC0); - if (dmac0 == NULL) - return -ENODEV; - dma_probe(dmac0); - - /* clear the masks for dsp of the dmac*/ - io_reg_update_bits(SHIM_BASE + SHIM_IMRD, - SHIM_IMRD_DMAC0, 0); - - dmac1 = dma_get(DMA_ID_DMAC1); - if (dmac1 == NULL) - return -ENODEV; - dma_probe(dmac1); - - /* clear the masks for dsp of the dmac*/ - io_reg_update_bits(SHIM_BASE + SHIM_IMRD, - SHIM_IMRD_DMAC1, 0); + dmac_init();
/* init SSP ports */ trace_point(TRACE_BOOT_PLATFORM_SSP);