1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2cdf60525SVipin Kumar /*
3cdf60525SVipin Kumar * ALSA SoC SPDIF DIR (Digital Interface Reciever) driver
4cdf60525SVipin Kumar *
5cdf60525SVipin Kumar * Based on ALSA SoC SPDIF DIT driver
6cdf60525SVipin Kumar *
7cdf60525SVipin Kumar * This driver is used by controllers which can operate in DIR (SPDI/F) where
8cdf60525SVipin Kumar * no codec is needed. This file provides stub codec that can be used
9cdf60525SVipin Kumar * in these configurations. SPEAr SPDIF IN Audio controller uses this driver.
10cdf60525SVipin Kumar *
11cdf60525SVipin Kumar * Author: Vipin Kumar, <vipin.kumar@st.com>
12cdf60525SVipin Kumar * Copyright: (C) 2012 ST Microelectronics
13cdf60525SVipin Kumar */
14cdf60525SVipin Kumar
15cdf60525SVipin Kumar #include <linux/module.h>
16cdf60525SVipin Kumar #include <linux/moduleparam.h>
17cdf60525SVipin Kumar #include <linux/slab.h>
18cdf60525SVipin Kumar #include <sound/soc.h>
19cdf60525SVipin Kumar #include <sound/pcm.h>
20cdf60525SVipin Kumar #include <sound/initval.h>
21f9c8ba89SMarek Belisko #include <linux/of.h>
22cdf60525SVipin Kumar
232f6e3ba0SMark Brown static const struct snd_soc_dapm_widget dir_widgets[] = {
242f6e3ba0SMark Brown SND_SOC_DAPM_INPUT("spdif-in"),
252f6e3ba0SMark Brown };
262f6e3ba0SMark Brown
272f6e3ba0SMark Brown static const struct snd_soc_dapm_route dir_routes[] = {
282f6e3ba0SMark Brown { "Capture", NULL, "spdif-in" },
292f6e3ba0SMark Brown };
302f6e3ba0SMark Brown
31*8055c0cdSJerome Brunet #define STUB_RATES (SNDRV_PCM_RATE_8000_768000 | \
32*8055c0cdSJerome Brunet SNDRV_PCM_RATE_128000)
33cdf60525SVipin Kumar #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
34db5ff954SNicolin Chen SNDRV_PCM_FMTBIT_S20_3LE | \
35db5ff954SNicolin Chen SNDRV_PCM_FMTBIT_S24_LE | \
36eb733366SKatsuhiro Suzuki SNDRV_PCM_FMTBIT_S32_LE | \
37cdf60525SVipin Kumar SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
38cdf60525SVipin Kumar
398c6086b8SKuninori Morimoto static struct snd_soc_component_driver soc_codec_spdif_dir = {
402f6e3ba0SMark Brown .dapm_widgets = dir_widgets,
412f6e3ba0SMark Brown .num_dapm_widgets = ARRAY_SIZE(dir_widgets),
422f6e3ba0SMark Brown .dapm_routes = dir_routes,
432f6e3ba0SMark Brown .num_dapm_routes = ARRAY_SIZE(dir_routes),
448c6086b8SKuninori Morimoto .idle_bias_on = 1,
458c6086b8SKuninori Morimoto .use_pmdown_time = 1,
468c6086b8SKuninori Morimoto .endianness = 1,
472f6e3ba0SMark Brown };
48cdf60525SVipin Kumar
49cdf60525SVipin Kumar static struct snd_soc_dai_driver dir_stub_dai = {
50cdf60525SVipin Kumar .name = "dir-hifi",
51cdf60525SVipin Kumar .capture = {
52cdf60525SVipin Kumar .stream_name = "Capture",
53cdf60525SVipin Kumar .channels_min = 1,
54cdf60525SVipin Kumar .channels_max = 384,
55cdf60525SVipin Kumar .rates = STUB_RATES,
56cdf60525SVipin Kumar .formats = STUB_FORMATS,
57cdf60525SVipin Kumar },
58cdf60525SVipin Kumar };
59cdf60525SVipin Kumar
spdif_dir_probe(struct platform_device * pdev)60cdf60525SVipin Kumar static int spdif_dir_probe(struct platform_device *pdev)
61cdf60525SVipin Kumar {
628c6086b8SKuninori Morimoto return devm_snd_soc_register_component(&pdev->dev,
638c6086b8SKuninori Morimoto &soc_codec_spdif_dir,
64cdf60525SVipin Kumar &dir_stub_dai, 1);
65cdf60525SVipin Kumar }
66cdf60525SVipin Kumar
67f9c8ba89SMarek Belisko #ifdef CONFIG_OF
68f9c8ba89SMarek Belisko static const struct of_device_id spdif_dir_dt_ids[] = {
69f9c8ba89SMarek Belisko { .compatible = "linux,spdif-dir", },
70f9c8ba89SMarek Belisko { }
71f9c8ba89SMarek Belisko };
72f9c8ba89SMarek Belisko MODULE_DEVICE_TABLE(of, spdif_dir_dt_ids);
73f9c8ba89SMarek Belisko #endif
74f9c8ba89SMarek Belisko
75cdf60525SVipin Kumar static struct platform_driver spdif_dir_driver = {
76cdf60525SVipin Kumar .probe = spdif_dir_probe,
77cdf60525SVipin Kumar .driver = {
78cdf60525SVipin Kumar .name = "spdif-dir",
79f9c8ba89SMarek Belisko .of_match_table = of_match_ptr(spdif_dir_dt_ids),
80cdf60525SVipin Kumar },
81cdf60525SVipin Kumar };
82cdf60525SVipin Kumar
83cdf60525SVipin Kumar module_platform_driver(spdif_dir_driver);
84cdf60525SVipin Kumar
85cdf60525SVipin Kumar MODULE_DESCRIPTION("ASoC SPDIF DIR driver");
86cdf60525SVipin Kumar MODULE_AUTHOR("Vipin Kumar <vipin.kumar@st.com>");
87cdf60525SVipin Kumar MODULE_LICENSE("GPL");
88