[Sound-open-firmware] [PATCH v4 1/5] platform: dma: move dmac initialization
Ranjani Sridharan
ranjani.sridharan at linux.intel.com
Tue Jun 12 05:37:11 CEST 2018
This patch proposes to move the platform DMAC initialization
code to the dmac_init() routine.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
src/include/sof/dma.h | 3 +++
src/platform/apollolake/dma.c | 19 +++++++++++++++++++
src/platform/apollolake/platform.c | 22 +++-------------------
src/platform/baytrail/dma.c | 19 +++++++++++++++++++
src/platform/baytrail/platform.c | 23 +++--------------------
src/platform/cannonlake/dma.c | 19 +++++++++++++++++++
src/platform/cannonlake/platform.c | 23 +++--------------------
src/platform/haswell/dma.c | 26 ++++++++++++++++++++++++++
src/platform/haswell/platform.c | 21 +++------------------
9 files changed, 98 insertions(+), 77 deletions(-)
diff --git a/src/include/sof/dma.h b/src/include/sof/dma.h
index 7ba1298..af15d14 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 */
+int 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..00d19d5 100644
--- a/src/platform/apollolake/dma.c
+++ b/src/platform/apollolake/dma.c
@@ -181,3 +181,22 @@ struct dma *dma_get(int dmac_id)
return NULL;
}
+
+/* Initialize all platform DMAC's */
+int dmac_init(void)
+{
+ int i, ret;
+
+ for (i = 0; i < ARRAY_SIZE(dma); i++) {
+ ret = dma_probe(&dma[i]);
+ if (ret < 0) {
+
+ /* trace failed DMAC ID */
+ trace_error(TRACE_CLASS_DMA, "edi");
+ trace_error_value(dma[i].plat_data.id);
+ return ret;
+ }
+ }
+
+ return 0;
+}
diff --git a/src/platform/apollolake/platform.c b/src/platform/apollolake/platform.c
index 0b26ae5..a523b46 100644
--- a/src/platform/apollolake/platform.c
+++ b/src/platform/apollolake/platform.c
@@ -186,10 +186,9 @@ static void platform_memory_windows_init(void)
int platform_init(struct sof *sof)
{
- struct dma *dmac;
struct dai *ssp;
struct dai *dmic0;
- int i;
+ int i, ret;
platform_interrupt_init();
@@ -244,25 +243,10 @@ int platform_init(struct sof *sof)
/* init DMACs */
trace_point(TRACE_BOOT_PLATFORM_DMA);
- dmac = dma_get(DMA_GP_LP_DMAC0);
- if (dmac == NULL)
+ ret = dmac_init();
+ if (ret < 0)
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);
/* 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..78fbf14 100644
--- a/src/platform/baytrail/dma.c
+++ b/src/platform/baytrail/dma.c
@@ -186,3 +186,22 @@ struct dma *dma_get(int dmac_id)
return NULL;
}
+
+/* Initialize all platform DMAC's */
+int dmac_init(void)
+{
+ int i, ret;
+
+ for (i = 0; i < ARRAY_SIZE(dma); i++) {
+ ret = dma_probe(&dma[i]);
+ if (ret < 0) {
+
+ /* trace failed DMAC ID */
+ trace_error(TRACE_CLASS_DMA, "edi");
+ trace_error_value(dma[i].plat_data.id);
+ return ret;
+ }
+ }
+
+ return 0;
+}
diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c
index 562fabf..3b0d381 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;
@@ -308,6 +303,7 @@ int platform_init(struct sof *sof)
#else
#error Undefined platform
#endif
+ int ret;
trace_point(TRACE_BOOT_PLATFORM_MBOX);
@@ -356,22 +352,9 @@ int platform_init(struct sof *sof)
/* init DMACs */
trace_point(TRACE_BOOT_PLATFORM_DMA);
- dmac0 = dma_get(DMA_ID_DMAC0);
- if (dmac0 == NULL)
+ ret = dmac_init();
+ if (ret < 0)
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
/* 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..c560b86 100644
--- a/src/platform/cannonlake/dma.c
+++ b/src/platform/cannonlake/dma.c
@@ -182,3 +182,22 @@ struct dma *dma_get(int dmac_id)
return NULL;
}
+
+/* Initialize all platform DMAC's */
+int dmac_init(void)
+{
+ int i, ret;
+
+ for (i = 0; i < ARRAY_SIZE(dma); i++) {
+ ret = dma_probe(&dma[i]);
+ if (ret < 0) {
+
+ /* trace failed DMAC ID */
+ trace_error(TRACE_CLASS_DMA, "edi");
+ trace_error_value(dma[i].plat_data.id);
+ return ret;
+ }
+ }
+
+ return 0;
+}
diff --git a/src/platform/cannonlake/platform.c b/src/platform/cannonlake/platform.c
index 2e85088..54c146c 100644
--- a/src/platform/cannonlake/platform.c
+++ b/src/platform/cannonlake/platform.c
@@ -208,10 +208,9 @@ static struct timer platform_ext_timer = {
int platform_init(struct sof *sof)
{
- struct dma *dmac;
struct dai *ssp;
struct dai *dmic0;
- int i;
+ int i, ret;
trace_point(TRACE_BOOT_PLATFORM_ENTRY);
platform_init_hw();
@@ -261,25 +260,9 @@ int platform_init(struct sof *sof)
/* init DMACs */
trace_point(TRACE_BOOT_PLATFORM_DMA);
- dmac = dma_get(DMA_GP_LP_DMAC0);
- if (!dmac)
+ ret = dmac_init();
+ if (ret < 0)
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);
/* 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..0ae935d 100644
--- a/src/platform/haswell/dma.c
+++ b/src/platform/haswell/dma.c
@@ -135,3 +135,29 @@ struct dma *dma_get(int dmac_id)
return NULL;
}
}
+
+/* Initialize all platform DMAC's */
+int dmac_init(void)
+{
+ int i, ret;
+
+ for (i = 0; i < ARRAY_SIZE(dma); i++) {
+ ret = dma_probe(&dma[i]);
+ if (ret < 0) {
+
+ /* trace failed DMAC ID */
+ trace_error(TRACE_CLASS_DMA, "edi");
+ trace_error_value(dma[i].plat_data.id);
+ return 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);
+
+ return 0;
+}
diff --git a/src/platform/haswell/platform.c b/src/platform/haswell/platform.c
index 81ce67a..0c0bf06 100644
--- a/src/platform/haswell/platform.c
+++ b/src/platform/haswell/platform.c
@@ -240,10 +240,9 @@ static void platform_init_shim(void)
int platform_init(struct sof *sof)
{
- struct dma *dmac0;
- struct dma *dmac1;
struct dai *ssp0;
struct dai *ssp1;
+ int ret;
trace_point(TRACE_BOOT_PLATFORM_MBOX);
@@ -280,23 +279,9 @@ int platform_init(struct sof *sof)
/* init DMACs */
trace_point(TRACE_BOOT_PLATFORM_DMA);
- dmac0 = dma_get(DMA_ID_DMAC0);
- if (dmac0 == NULL)
+ ret = dmac_init();
+ if (ret < 0)
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);
/* init SSP ports */
trace_point(TRACE_BOOT_PLATFORM_SSP);
--
2.17.1
More information about the Sound-open-firmware
mailing list