1 // SPDX-License-Identifier: GPL-2.0-only
3 * This is a simple driver for the GTM601 Voice PCM interface
5 * Copyright (C) 2015 Goldelico GmbH
9 * Based on wm8727.c driver
12 #include <linux/init.h>
13 #include <linux/slab.h>
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/of_device.h>
17 #include <sound/core.h>
18 #include <sound/pcm.h>
19 #include <sound/initval.h>
20 #include <sound/soc.h>
22 static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = {
23 SND_SOC_DAPM_OUTPUT("AOUT"),
24 SND_SOC_DAPM_INPUT("AIN"),
27 static const struct snd_soc_dapm_route gtm601_dapm_routes[] = {
28 { "AOUT", NULL, "Playback" },
29 { "Capture", NULL, "AIN" },
32 static struct snd_soc_dai_driver gtm601_dai = {
35 .stream_name = "Playback",
38 .rates = SNDRV_PCM_RATE_8000,
39 .formats = SNDRV_PCM_FMTBIT_S16_LE,
42 .stream_name = "Capture",
45 .rates = SNDRV_PCM_RATE_8000,
46 .formats = SNDRV_PCM_FMTBIT_S16_LE,
50 static struct snd_soc_dai_driver bm818_dai = {
53 .stream_name = "Playback",
56 .rates = SNDRV_PCM_RATE_48000,
57 .formats = SNDRV_PCM_FMTBIT_S16_LE,
60 .stream_name = "Capture",
63 .rates = SNDRV_PCM_RATE_48000,
64 .formats = SNDRV_PCM_FMTBIT_S16_LE,
68 static const struct snd_soc_component_driver soc_component_dev_gtm601 = {
69 .dapm_widgets = gtm601_dapm_widgets,
70 .num_dapm_widgets = ARRAY_SIZE(gtm601_dapm_widgets),
71 .dapm_routes = gtm601_dapm_routes,
72 .num_dapm_routes = ARRAY_SIZE(gtm601_dapm_routes),
76 .non_legacy_dai_naming = 1,
79 static int gtm601_platform_probe(struct platform_device *pdev)
81 const struct snd_soc_dai_driver *dai_driver;
83 dai_driver = of_device_get_match_data(&pdev->dev);
85 return devm_snd_soc_register_component(&pdev->dev,
86 &soc_component_dev_gtm601,
87 (struct snd_soc_dai_driver *)dai_driver, 1);
90 static const struct of_device_id gtm601_codec_of_match[] __maybe_unused = {
91 { .compatible = "option,gtm601", .data = (void *)>m601_dai },
92 { .compatible = "broadmobi,bm818", .data = (void *)&bm818_dai },
95 MODULE_DEVICE_TABLE(of, gtm601_codec_of_match);
97 static struct platform_driver gtm601_codec_driver = {
100 .of_match_table = of_match_ptr(gtm601_codec_of_match),
102 .probe = gtm601_platform_probe,
105 module_platform_driver(gtm601_codec_driver);
107 MODULE_DESCRIPTION("ASoC gtm601 driver");
109 MODULE_LICENSE("GPL");
110 MODULE_ALIAS("platform:gtm601");