1 // SPDX-License-Identifier: GPL-2.0-or-later
3 // Author: Kevin Wells <kevin.wells@nxp.com>
5 // Copyright (C) 2008 NXP Semiconductors
6 // Copyright 2023 Timesys Corporation <piotr.wojtaszczyk@timesys.com>
8 #include <linux/module.h>
9 #include <linux/init.h>
10 #include <linux/platform_device.h>
11 #include <linux/slab.h>
12 #include <linux/dma-mapping.h>
13 #include <linux/amba/pl08x.h>
15 #include <sound/core.h>
16 #include <sound/pcm.h>
17 #include <sound/pcm_params.h>
18 #include <sound/dmaengine_pcm.h>
19 #include <sound/soc.h>
21 #include "lpc3xxx-i2s.h"
23 #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
24 SNDRV_PCM_FMTBIT_U8 | \
25 SNDRV_PCM_FMTBIT_S16_LE | \
26 SNDRV_PCM_FMTBIT_U16_LE | \
27 SNDRV_PCM_FMTBIT_S24_LE | \
28 SNDRV_PCM_FMTBIT_U24_LE | \
29 SNDRV_PCM_FMTBIT_S32_LE | \
30 SNDRV_PCM_FMTBIT_U32_LE | \
31 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
33 static const struct snd_pcm_hardware lpc3xxx_pcm_hardware
= {
34 .info
= (SNDRV_PCM_INFO_MMAP
|
35 SNDRV_PCM_INFO_MMAP_VALID
|
36 SNDRV_PCM_INFO_INTERLEAVED
|
37 SNDRV_PCM_INFO_BLOCK_TRANSFER
|
38 SNDRV_PCM_INFO_PAUSE
|
39 SNDRV_PCM_INFO_RESUME
),
40 .formats
= STUB_FORMATS
,
41 .period_bytes_min
= 128,
42 .period_bytes_max
= 2048,
45 .buffer_bytes_max
= 128 * 1024
48 static const struct snd_dmaengine_pcm_config lpc3xxx_dmaengine_pcm_config
= {
49 .pcm_hardware
= &lpc3xxx_pcm_hardware
,
50 .prepare_slave_config
= snd_dmaengine_pcm_prepare_slave_config
,
51 .compat_filter_fn
= pl08x_filter_id
,
52 .prealloc_buffer_size
= 128 * 1024,
55 static const struct snd_soc_component_driver lpc3xxx_soc_platform_driver
= {
56 .name
= "lpc32xx-pcm",
59 int lpc3xxx_pcm_register(struct platform_device
*pdev
)
63 ret
= devm_snd_dmaengine_pcm_register(&pdev
->dev
, &lpc3xxx_dmaengine_pcm_config
, 0);
65 dev_err(&pdev
->dev
, "failed to register dmaengine: %d\n", ret
);
69 return devm_snd_soc_register_component(&pdev
->dev
, &lpc3xxx_soc_platform_driver
,
72 EXPORT_SYMBOL(lpc3xxx_pcm_register
);