Skip to content

Commit 1d6643e

Browse files
author
Marcin Maka
committed
dai: simple i/f to control flow between platform and lib
A mechanism similar to the one used for dma applied. Dai initialization moved to separate unit from the main platform code for cavs. Optional dynamic discovery and initialization possible before making available to other fw units via the lib hub. SSP count cleaned up for cavs (important pre-work for clock gating). Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
1 parent f574b71 commit 1d6643e

20 files changed

Lines changed: 444 additions & 68 deletions

File tree

src/arch/xtensa/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ sof_LDADD = \
9393
../../platform/$(PLATFORM)/libplatform.la \
9494
../../ipc/libsof_ipc.a \
9595
../../lib/libdma.a \
96+
../../lib/libdai.a \
9697
../../audio/libaudio.a \
9798
../../drivers/libdrivers.la \
9899
../../math/libsof_math.a \

src/include/sof/dai.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,31 @@ struct dai {
125125
uint32_t private_size;
126126
};
127127

128+
/**
129+
* \brief Array of DAIs grouped by type.
130+
*/
131+
struct dai_type_info {
132+
uint32_t type; /**< Type */
133+
struct dai *dai_array; /**< Array of DAIs */
134+
size_t num_dais; /**< Number of elements in dai_array */
135+
};
136+
137+
/**
138+
* \brief Plugs platform specific DAI array once initialized into the lib.
139+
*
140+
* Lib serves the DAIs to other FW elements with dai_get()
141+
*
142+
* \param[in] dai_type_array Array of DAI arrays grouped by type.
143+
* \param[in] num_dai_types Number of elements in the dai_type_array.
144+
*/
145+
void dai_install(struct dai_type_info *dai_type_array, size_t num_dai_types);
146+
147+
/**
148+
* \brief API to request a platform DAI.
149+
*
150+
* \param[in] type Type of requested DAI.
151+
* \param[in] index Index of requested DAI.
152+
*/
128153
struct dai *dai_get(uint32_t type, uint32_t index);
129154

130155
#define dai_set_drvdata(dai, data) \

src/lib/Makefile.am

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
noinst_LIBRARIES = libcore.a libdma.a
1+
noinst_LIBRARIES = libcore.a libdma.a libdai.a
22

33
libcore_a_SOURCES = \
44
lib.c \
@@ -28,3 +28,13 @@ libdma_a_CFLAGS = \
2828
$(ARCH_INCDIR) \
2929
$(PLATFORM_INCDIR) \
3030
$(SOF_INCDIR)
31+
32+
libdai_a_SOURCES = \
33+
dai.c
34+
35+
libdai_a_CFLAGS = \
36+
$(AM_CFLAGS) \
37+
$(ARCH_CFLAGS) \
38+
$(ARCH_INCDIR) \
39+
$(PLATFORM_INCDIR) \
40+
$(SOF_INCDIR)

src/lib/dai.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the Intel Corporation nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
* Author: Marcin Maka <marcin.maka@linux.intel.com>
29+
*/
30+
31+
#include <sof/dai.h>
32+
33+
struct dai_info {
34+
struct dai_type_info *dai_type_array;
35+
size_t num_dai_types;
36+
};
37+
38+
static struct dai_info lib_dai = {
39+
.dai_type_array = NULL,
40+
.num_dai_types = 0
41+
};
42+
43+
void dai_install(struct dai_type_info *dai_type_array, size_t num_dai_types)
44+
{
45+
lib_dai.dai_type_array = dai_type_array;
46+
lib_dai.num_dai_types = num_dai_types;
47+
}
48+
49+
struct dai *dai_get(uint32_t type, uint32_t index)
50+
{
51+
int i;
52+
struct dai_type_info *dti;
53+
54+
for (dti = lib_dai.dai_type_array;
55+
dti < lib_dai.dai_type_array + lib_dai.num_dai_types; dti++) {
56+
if (dti->type == type) {
57+
for (i = 0; i < dti->num_dais; i++) {
58+
if (dti->dai_array[i].index == index)
59+
return dti->dai_array + i;
60+
}
61+
}
62+
}
63+
return NULL;
64+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the Intel Corporation nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
* Author: Marcin Maka <marcin.maka@linux.intel.com>
29+
*/
30+
31+
#ifndef __PLATFORM_DAI_H__
32+
#define __PLATFORM_DAI_H__
33+
34+
/* SSP */
35+
36+
/*
37+
* Number of base and extended SSP ports must be defined separately
38+
* since some HW registers are in two groups, one for base and one
39+
* for extended.
40+
*/
41+
42+
/** \brief Number of 'base' SSP ports available */
43+
#define DAI_NUM_SSP_BASE 4
44+
45+
/** \brief Number of 'extended' SSP ports available */
46+
#define DAI_NUM_SSP_EXT 2
47+
48+
int dai_init(void);
49+
50+
#endif

src/platform/apollolake/include/platform/platform.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ struct sof;
130130
/* platform has low power memory type */
131131
#define PLATFORM_MEM_HAS_LP_RAM
132132

133-
/* number of SSP ports in platform */
134-
#define PLATFORM_NUM_SSP 6
135-
136133
/* DSP default delay in cycles */
137134
#define PLATFORM_DEFAULT_DELAY 12
138135

src/platform/baytrail/dai.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <platform/memory.h>
3737
#include <platform/interrupt.h>
3838
#include <platform/dma.h>
39+
#include <platform/dai.h>
3940
#include <uapi/ipc.h>
4041
#include <stdint.h>
4142
#include <string.h>
@@ -148,14 +149,16 @@ static struct dai ssp[] = {
148149
#endif
149150
};
150151

151-
struct dai *dai_get(enum sof_ipc_dai_type type, uint32_t index)
152-
{
153-
int i;
154-
155-
for (i = 0; i < ARRAY_SIZE(ssp); i++) {
156-
if (ssp[i].type == type && ssp[i].index == index)
157-
return &ssp[i];
152+
static struct dai_type_info dti[] = {
153+
{
154+
.type = SOF_DAI_INTEL_SSP,
155+
.dai_array = ssp,
156+
.num_dais = ARRAY_SIZE(ssp)
158157
}
158+
};
159159

160-
return NULL;
160+
int dai_init(void)
161+
{
162+
dai_install(dti, ARRAY_SIZE(dti));
163+
return 0;
161164
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the Intel Corporation nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
* Author: Marcin Maka <marcin.maka@linux.intel.com>
29+
*/
30+
31+
#ifndef __PLATFORM_DAI_H__
32+
#define __PLATFORM_DAI_H__
33+
34+
int dai_init(void);
35+
36+
#endif

src/platform/baytrail/platform.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <platform/mailbox.h>
3434
#include <platform/shim.h>
3535
#include <platform/dma.h>
36+
#include <platform/dai.h>
3637
#include <platform/clk.h>
3738
#include <platform/timer.h>
3839
#include <platform/pmc.h>
@@ -234,6 +235,10 @@ int platform_init(struct sof *sof)
234235
if (ret < 0)
235236
return -ENODEV;
236237

238+
ret = dai_init();
239+
if (ret < 0)
240+
return -ENODEV;
241+
237242
/* mask SSP 0 - 2 interrupts */
238243
shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) | 0x00000038);
239244

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the Intel Corporation nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
* Author: Marcin Maka <marcin.maka@linux.intel.com>
29+
*/
30+
31+
#ifndef __PLATFORM_DAI_H__
32+
#define __PLATFORM_DAI_H__
33+
34+
/* SSP */
35+
36+
/*
37+
* Number of base and extended SSP ports must be defined separately
38+
* since some HW registers are in two groups, one for base and one
39+
* for extended.
40+
*/
41+
42+
/** \brief Number of 'base' SSP ports available */
43+
#define DAI_NUM_SSP_BASE 3
44+
45+
/** \brief Number of 'extended' SSP ports available */
46+
#define DAI_NUM_SSP_EXT 0
47+
48+
int dai_init(void);
49+
50+
#endif

0 commit comments

Comments
 (0)