blob: be066de74aaad451cf05ac6077c15b4050a539d9 [file] [log] [blame]
Rongjun Yinga731e212014-03-05 16:34:35 +08001/*
2 * SiRF Audio port driver
3 *
4 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
5 *
6 * Licensed under GPLv2 or later.
7 */
8#include <linux/module.h>
Rongjun Yinga731e212014-03-05 16:34:35 +08009#include <sound/soc.h>
10#include <sound/dmaengine_pcm.h>
11
Rongjun Yinga731e212014-03-05 16:34:35 +080012struct sirf_audio_port {
13 struct regmap *regmap;
14 struct snd_dmaengine_dai_dma_data playback_dma_data;
15 struct snd_dmaengine_dai_dma_data capture_dma_data;
16};
17
Rongjun Yinga731e212014-03-05 16:34:35 +080018
19static int sirf_audio_port_dai_probe(struct snd_soc_dai *dai)
20{
21 struct sirf_audio_port *port = snd_soc_dai_get_drvdata(dai);
Codrut Grosuadbdba32017-02-25 21:59:33 +020022
Rongjun Yinga731e212014-03-05 16:34:35 +080023 snd_soc_dai_init_dma_data(dai, &port->playback_dma_data,
24 &port->capture_dma_data);
25 return 0;
26}
27
Rongjun Yinga731e212014-03-05 16:34:35 +080028static struct snd_soc_dai_driver sirf_audio_port_dai = {
29 .probe = sirf_audio_port_dai_probe,
30 .name = "sirf-audio-port",
31 .id = 0,
32 .playback = {
33 .channels_min = 2,
34 .channels_max = 2,
35 .rates = SNDRV_PCM_RATE_48000,
36 .formats = SNDRV_PCM_FMTBIT_S16_LE,
37 },
38 .capture = {
39 .channels_min = 1,
40 .channels_max = 2,
41 .rates = SNDRV_PCM_RATE_48000,
42 .formats = SNDRV_PCM_FMTBIT_S16_LE,
43 },
Rongjun Yinga731e212014-03-05 16:34:35 +080044};
45
46static const struct snd_soc_component_driver sirf_audio_port_component = {
47 .name = "sirf-audio-port",
48};
49
Rongjun Yinga731e212014-03-05 16:34:35 +080050static int sirf_audio_port_probe(struct platform_device *pdev)
51{
52 int ret;
53 struct sirf_audio_port *port;
Rongjun Yinga731e212014-03-05 16:34:35 +080054
55 port = devm_kzalloc(&pdev->dev,
56 sizeof(struct sirf_audio_port), GFP_KERNEL);
57 if (!port)
58 return -ENOMEM;
59
Rongjun Yinga731e212014-03-05 16:34:35 +080060 ret = devm_snd_soc_register_component(&pdev->dev,
61 &sirf_audio_port_component, &sirf_audio_port_dai, 1);
62 if (ret)
63 return ret;
64
65 platform_set_drvdata(pdev, port);
66 return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
67}
68
69static const struct of_device_id sirf_audio_port_of_match[] = {
70 { .compatible = "sirf,audio-port", },
71 {}
72};
73MODULE_DEVICE_TABLE(of, sirf_audio_port_of_match);
74
75static struct platform_driver sirf_audio_port_driver = {
76 .driver = {
77 .name = "sirf-audio-port",
Rongjun Yinga731e212014-03-05 16:34:35 +080078 .of_match_table = sirf_audio_port_of_match,
79 },
80 .probe = sirf_audio_port_probe,
81};
82
83module_platform_driver(sirf_audio_port_driver);
84
85MODULE_DESCRIPTION("SiRF Audio Port driver");
86MODULE_AUTHOR("RongJun Ying <Rongjun.Ying@csr.com>");
87MODULE_LICENSE("GPL v2");