[Sound-open-firmware] [RFC PATCH 1/6] platform: dma: consolidate dmac initialization
Keyon Jie
yang.jie at linux.intel.com
Tue Jun 5 12:42:46 CEST 2018
On 2018年06月05日 12:23, Ranjani Sridharan wrote:
> This patch proposes to create a DMAC initialization routine in
> dma.c where it can access the platform DMAC definitions.
>
> Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
> ---
> src/include/sof/dma.h | 3 +++
> src/platform/apollolake/dma.c | 9 +++++++++
> src/platform/apollolake/platform.c | 21 +--------------------
> src/platform/baytrail/dma.c | 9 +++++++++
> src/platform/baytrail/platform.c | 22 +---------------------
> src/platform/cannonlake/dma.c | 9 +++++++++
> src/platform/cannonlake/platform.c | 21 +--------------------
> src/platform/haswell/dma.c | 9 +++++++++
> src/platform/haswell/platform.c | 16 +---------------
> 9 files changed, 43 insertions(+), 76 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..001bb67 100644
> --- a/src/platform/apollolake/dma.c
> +++ b/src/platform/apollolake/dma.c
> @@ -181,3 +181,12 @@ struct dma *dma_get(int dmac_id)
>
> return NULL;
> }
> +
> +/* Initialize all platform DMAC's */
> +void dmac_init(void)
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(dma); i++)
> + dma_probe(&dma[i]);
> +}
looks this function are same for all platforms, can we move it to common
part and share it?
Thanks,
~Keyon
> 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..5a0b650 100644
> --- a/src/platform/baytrail/dma.c
> +++ b/src/platform/baytrail/dma.c
> @@ -186,3 +186,12 @@ struct dma *dma_get(int dmac_id)
>
> return NULL;
> }
> +
> +/* Initialize all platform DMAC's */
> +void dmac_init(void)
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(dma); i++)
> + dma_probe(&dma[i]);
> +}
> 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..9031c17 100644
> --- a/src/platform/cannonlake/dma.c
> +++ b/src/platform/cannonlake/dma.c
> @@ -182,3 +182,12 @@ struct dma *dma_get(int dmac_id)
>
> return NULL;
> }
> +
> +/* Initialize all platform DMAC's */
> +void dmac_init(void)
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(dma); i++)
> + dma_probe(&dma[i]);
> +}
> 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..5d1e308 100644
> --- a/src/platform/haswell/dma.c
> +++ b/src/platform/haswell/dma.c
> @@ -135,3 +135,12 @@ struct dma *dma_get(int dmac_id)
> return NULL;
> }
> }
> +
> +/* Initialize all platform DMAC's */
> +void dmac_init(void)
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(dma); i++)
> + dma_probe(&dma[i]);
> +}
> diff --git a/src/platform/haswell/platform.c b/src/platform/haswell/platform.c
> index 81ce67a..8ffb370 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,19 +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);
> + dmac_init();
>
> /* clear the masks for dsp of the dmac*/
> io_reg_update_bits(SHIM_BASE + SHIM_IMRD,
>
More information about the Sound-open-firmware
mailing list