xref: /openbmc/linux/sound/soc/codecs/gtm601.c (revision d2574c33)
1 /*
2  * This is a simple driver for the GTM601 Voice PCM interface
3  *
4  * Copyright (C) 2015 Goldelico GmbH
5  *
6  * Author: Marek Belisko <marek@goldelico.com>
7  *
8  * Based on wm8727.c driver
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14 
15 #include <linux/init.h>
16 #include <linux/slab.h>
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/device.h>
20 #include <sound/core.h>
21 #include <sound/pcm.h>
22 #include <sound/initval.h>
23 #include <sound/soc.h>
24 
25 static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = {
26 	SND_SOC_DAPM_OUTPUT("AOUT"),
27 	SND_SOC_DAPM_INPUT("AIN"),
28 };
29 
30 static const struct snd_soc_dapm_route gtm601_dapm_routes[] = {
31 	{ "AOUT", NULL, "Playback" },
32 	{ "Capture", NULL, "AIN" },
33 };
34 
35 static struct snd_soc_dai_driver gtm601_dai = {
36 	.name = "gtm601",
37 	.playback = {
38 		.stream_name = "Playback",
39 		.channels_min = 1,
40 		.channels_max = 1,
41 		.rates = SNDRV_PCM_RATE_8000,
42 		.formats = SNDRV_PCM_FMTBIT_S16_LE,
43 		},
44 	.capture = {
45 		.stream_name = "Capture",
46 		.channels_min = 1,
47 		.channels_max = 1,
48 		.rates = SNDRV_PCM_RATE_8000,
49 		.formats = SNDRV_PCM_FMTBIT_S16_LE,
50 	},
51 };
52 
53 static const struct snd_soc_component_driver soc_component_dev_gtm601 = {
54 	.dapm_widgets		= gtm601_dapm_widgets,
55 	.num_dapm_widgets	= ARRAY_SIZE(gtm601_dapm_widgets),
56 	.dapm_routes		= gtm601_dapm_routes,
57 	.num_dapm_routes	= ARRAY_SIZE(gtm601_dapm_routes),
58 	.idle_bias_on		= 1,
59 	.use_pmdown_time	= 1,
60 	.endianness		= 1,
61 	.non_legacy_dai_naming	= 1,
62 };
63 
64 static int gtm601_platform_probe(struct platform_device *pdev)
65 {
66 	return devm_snd_soc_register_component(&pdev->dev,
67 			&soc_component_dev_gtm601, &gtm601_dai, 1);
68 }
69 
70 #if defined(CONFIG_OF)
71 static const struct of_device_id gtm601_codec_of_match[] = {
72 	{ .compatible = "option,gtm601", },
73 	{},
74 };
75 MODULE_DEVICE_TABLE(of, gtm601_codec_of_match);
76 #endif
77 
78 static struct platform_driver gtm601_codec_driver = {
79 	.driver = {
80 		.name = "gtm601",
81 		.of_match_table = of_match_ptr(gtm601_codec_of_match),
82 	},
83 	.probe = gtm601_platform_probe,
84 };
85 
86 module_platform_driver(gtm601_codec_driver);
87 
88 MODULE_DESCRIPTION("ASoC gtm601 driver");
89 MODULE_AUTHOR("Marek Belisko <marek@goldelico.com>");
90 MODULE_LICENSE("GPL");
91 MODULE_ALIAS("platform:gtm601");
92