Moi Seppo, maybe split this patch in two? see below.
On 4/30/18 11:04 AM, Seppo Ingalsuo wrote:
Signed-off-by: Seppo Ingalsuo seppo.ingalsuo@linux.intel.com
src/platform/apollolake/dai.c | 67 ++++++++++++++++++++++- src/platform/apollolake/include/platform/memory.h | 5 ++ src/platform/apollolake/include/platform/shim.h | 2 +- src/platform/apollolake/platform.c | 12 ++++ src/platform/cannonlake/dai.c | 65 +++++++++++++++++++++- src/platform/cannonlake/include/platform/memory.h | 8 ++- src/platform/cannonlake/platform.c | 11 ++++ 7 files changed, 161 insertions(+), 9 deletions(-)
diff --git a/src/platform/apollolake/dai.c b/src/platform/apollolake/dai.c index 7e5da44..fea9faf 100644 --- a/src/platform/apollolake/dai.c +++ b/src/platform/apollolake/dai.c @@ -32,6 +32,7 @@ #include <sof/sof.h> #include <sof/dai.h> #include <sof/ssp.h> +#include <sof/dmic.h> #include <sof/stream.h> #include <sof/audio/component.h> #include <platform/platform.h> @@ -146,14 +147,74 @@ static struct dai ssp[PLATFORM_NUM_SSP] = { .ops = &ssp_ops, },};
+#if defined CONFIG_DMIC
+static struct dai dmic[2] = {
- /* Testing idea if DMIC FIFOs A and B to access the same microphones
* with two different sample rate and PCM format could be presented
* similarly as SSP0..N. The difference however is that the DMIC
* programming is global and not per FIFO.
*/
- /* Primary FIFO A */
- {
.type = SOF_DAI_INTEL_DMIC,
.index = 0,
.plat_data = {
.base = DMIC_BASE,
.irq = IRQ_EXT_DMIC_LVL5(0),
.fifo[SOF_IPC_STREAM_PLAYBACK] = {
.offset = 0, /* No playback */
.handshake = 0,
},
.fifo[SOF_IPC_STREAM_CAPTURE] = {
.offset = DMIC_BASE + OUTDATA0,
.handshake = DMA_HANDSHAKE_DMIC_CH0,
}
},
.ops = &dmic_ops,
- },
- /* Secondary FIFO B */
- {
.type = SOF_DAI_INTEL_DMIC,
.index = 1,
.plat_data = {
.base = DMIC_BASE,
.irq = IRQ_EXT_DMIC_LVL5(0),
.fifo[SOF_IPC_STREAM_PLAYBACK] = {
.offset = 0, /* No playback */
.handshake = 0,
},
.fifo[SOF_IPC_STREAM_CAPTURE] = {
.offset = DMIC_BASE + OUTDATA1,
.handshake = DMA_HANDSHAKE_DMIC_CH1,
}
},
.ops = &dmic_ops,
- }
+};
+#endif
- struct dai *dai_get(uint32_t type, uint32_t index) { int i;
- for (i = 0; i < ARRAY_SIZE(ssp); i++) {
if (ssp[i].type == type && ssp[i].index == index)
return &ssp[i];
- if (type == SOF_DAI_INTEL_SSP) {
for (i = 0; i < ARRAY_SIZE(ssp); i++) {
if (ssp[i].type == type && ssp[i].index == index)
return &ssp[i];
}
- }
this is unrelated to DMICs and would be good as a separate patch added first.
+#if defined CONFIG_DMIC
- if (type == SOF_DAI_INTEL_DMIC) {
for (i = 0; i < ARRAY_SIZE(dmic); i++) {
if (dmic[i].type == type && dmic[i].index == index)
return &dmic[i];
}}
+#endif
return NULL; } diff --git a/src/platform/apollolake/include/platform/memory.h b/src/platform/apollolake/include/platform/memory.h index c71d8c6..8a78892 100644 --- a/src/platform/apollolake/include/platform/memory.h +++ b/src/platform/apollolake/include/platform/memory.h @@ -1,3 +1,4 @@
- /*
- Copyright (c) 2016, Intel Corporation
- All rights reserved.
@@ -171,7 +172,11 @@ #define SOF_TEXT_SIZE 0x19000
/* initialized data */ +#if defined CONFIG_DMIC +#define SOF_DATA_SIZE 0x1a000 +#else #define SOF_DATA_SIZE 0x18000 +#endif
/* bss data */ #define SOF_BSS_DATA_SIZE 0x2800 diff --git a/src/platform/apollolake/include/platform/shim.h b/src/platform/apollolake/include/platform/shim.h index c7fcc8f..daff826 100644 --- a/src/platform/apollolake/include/platform/shim.h +++ b/src/platform/apollolake/include/platform/shim.h @@ -123,7 +123,7 @@
/* LP GPDMA Force Dynamic Clock Gating bits, 0--enable */ #define SHIM_CLKCTL_LPGPDMAFDCGB(x) (0x1 << (26 + x)) -#define SHIM_CLKCTL_DMICFDCGB(x) (0x1 << 24) +#define SHIM_CLKCTL_DMICFDCGB (0x1 << 24)
same here, this is not DMIC-specific
#define SHIM_CLKCTL_I2SFDCGB(x) (0x1 << (20 + x)) #define SHIM_CLKCTL_I2SEFDCGB(x) (0x1 << (18 + x)) #define SHIM_CLKCTL_TCPLCG(x) (0x1 << (16 + x)) diff --git a/src/platform/apollolake/platform.c b/src/platform/apollolake/platform.c index d24a440..25c880d 100644 --- a/src/platform/apollolake/platform.c +++ b/src/platform/apollolake/platform.c @@ -188,6 +188,7 @@ int platform_init(struct sof *sof) { struct dma *dmac; struct dai *ssp;
struct dai *dmic0; int i;
platform_interrupt_init();
@@ -230,6 +231,7 @@ int platform_init(struct sof *sof) SHIM_CLKCTL_I2SFDCGB(2) | SHIM_CLKCTL_I2SFDCGB(1) | SHIM_CLKCTL_I2SFDCGB(0) |
SHIM_CLKCTL_DMICFDCGB |
same here
SHIM_CLKCTL_I2SEFDCGB(1) | SHIM_CLKCTL_I2SEFDCGB(0) | SHIM_CLKCTL_TCPAPLLS |
@@ -271,6 +273,16 @@ int platform_init(struct sof *sof) dai_probe(ssp); }
- /* Init DMIC. Note that the two PDM controllers and four microphones
* supported max. those are available in platform are handled by dmic0.
*/
- trace_point(TRACE_BOOT_PLATFORM_DMIC);
- dmic0 = dai_get(SOF_DAI_INTEL_DMIC, 0);
- if (dmic0 == NULL)
return -ENODEV;
- dai_probe(dmic0);
- /* Initialize DMA for Trace*/ dma_trace_init_complete(sof->dmat);
diff --git a/src/platform/cannonlake/dai.c b/src/platform/cannonlake/dai.c index 6b2db36..f195eca 100644 --- a/src/platform/cannonlake/dai.c +++ b/src/platform/cannonlake/dai.c @@ -33,6 +33,7 @@ #include <sof/sof.h> #include <sof/dai.h> #include <sof/ssp.h> +#include <sof/dmic.h> #include <sof/stream.h> #include <sof/audio/component.h> #include <platform/memory.h> @@ -95,14 +96,72 @@ static struct dai ssp[] = { .ops = &ssp_ops, },};
+#if defined CONFIG_DMIC +static struct dai dmic[2] = {
- /* Testing idea if DMIC FIFOs A and B to access the same microphones
* with two different sample rate and PCM format could be presented
* similarly as SSP0..N. The difference however is that the DMIC
* programming is global and not per FIFO.
*/
- /* Primary FIFO A */
- {
.type = SOF_DAI_INTEL_DMIC,
.index = 0,
.plat_data = {
.base = DMIC_BASE,
.irq = IRQ_EXT_DMIC_LVL5(0),
.fifo[SOF_IPC_STREAM_PLAYBACK] = {
.offset = 0, /* No playback */
.handshake = 0,
},
.fifo[SOF_IPC_STREAM_CAPTURE] = {
.offset = DMIC_BASE + OUTDATA0,
.handshake = DMA_HANDSHAKE_DMIC_CH0,
}
},
.ops = &dmic_ops,
- },
- /* Secondary FIFO B */
- {
.type = SOF_DAI_INTEL_DMIC,
.index = 1,
.plat_data = {
.base = DMIC_BASE,
.irq = IRQ_EXT_DMIC_LVL5(0),
.fifo[SOF_IPC_STREAM_PLAYBACK] = {
.offset = 0, /* No playback */
.handshake = 0,
},
.fifo[SOF_IPC_STREAM_CAPTURE] = {
.offset = DMIC_BASE + OUTDATA1,
.handshake = DMA_HANDSHAKE_DMIC_CH1,
}
},
.ops = &dmic_ops,
- }
+}; +#endif
- struct dai *dai_get(uint32_t type, uint32_t index) { int i;
- for (i = 0; i < ARRAY_SIZE(ssp); i++) {
if (ssp[i].type == type && ssp[i].index == index)
return &ssp[i];
- if (type == SOF_DAI_INTEL_SSP) {
for (i = 0; i < ARRAY_SIZE(ssp); i++) {
if (ssp[i].type == type && ssp[i].index == index)
return &ssp[i];
}
- }
and here
+#if defined CONFIG_DMIC
- if (type == SOF_DAI_INTEL_DMIC) {
for (i = 0; i < ARRAY_SIZE(dmic); i++) {
if (dmic[i].type == type && dmic[i].index == index)
return &dmic[i];
}}
+#endif
return NULL; } diff --git a/src/platform/cannonlake/include/platform/memory.h b/src/platform/cannonlake/include/platform/memory.h index c7f4750..08cbf28 100644 --- a/src/platform/cannonlake/include/platform/memory.h +++ b/src/platform/cannonlake/include/platform/memory.h @@ -108,8 +108,8 @@ #define L2_HP_SRAM_TLB_BASE 0x00003000
/* DMICs */ -#define DMIC_BASE 0x00004000 -#define DMIC_SIZE 0x00004000 +#define DMIC_BASE 0x00010000 +#define DMIC_SIZE 0x00008000
/* SSP */ #define SSP_BASE(x) (0x00077000 + x * SSP_SIZE) @@ -240,7 +240,11 @@ #define SOF_TEXT_SIZE 0x18000
/* initialized data */ +#if defined CONFIG_DMIC +#define SOF_DATA_SIZE 0x1a000 +#else #define SOF_DATA_SIZE 0x18000 +#endif
/* bss data */ #define SOF_BSS_DATA_SIZE 0x8000 diff --git a/src/platform/cannonlake/platform.c b/src/platform/cannonlake/platform.c index 9c56047..d801a0e 100644 --- a/src/platform/cannonlake/platform.c +++ b/src/platform/cannonlake/platform.c @@ -210,6 +210,7 @@ int platform_init(struct sof *sof) { struct dma *dmac; struct dai *ssp;
struct dai *dmic0; int i;
trace_point(TRACE_BOOT_PLATFORM_ENTRY);
@@ -289,6 +290,16 @@ int platform_init(struct sof *sof) dai_probe(ssp); }
- /* Init DMIC. Note that the two PDM controllers and four microphones
* supported max. those are available in platform are handled by dmic0.
*/
- trace_point(TRACE_BOOT_PLATFORM_DMIC);
- dmic0 = dai_get(SOF_DAI_INTEL_DMIC, 0);
- if (dmic0 == NULL)
return -ENODEV;
- dai_probe(dmic0);
- /* Initialize DMA for Trace*/ dma_trace_init_complete(sof->dmat);