blob: c11ed60ccefb6cab880c9c12760176e6eae30f24 [file] [log] [blame]
Marek Beliskoefc47202015-06-20 22:47:01 +02001/*
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>
Marek Beliskoefc47202015-06-20 22:47:01 +020022#include <sound/initval.h>
23#include <sound/soc.h>
24
25static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = {
26 SND_SOC_DAPM_OUTPUT("AOUT"),
27 SND_SOC_DAPM_INPUT("AIN"),
28};
29
30static const struct snd_soc_dapm_route gtm601_dapm_routes[] = {
31 { "AOUT", NULL, "Playback" },
32 { "Capture", NULL, "AIN" },
33};
34
kbuild test robotbeb5f862015-06-22 23:48:25 +080035static struct snd_soc_dai_driver gtm601_dai = {
Marek Beliskoefc47202015-06-20 22:47:01 +020036 .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
Kuninori Morimoto993709b2018-01-29 04:41:22 +000053static 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,
Marek Beliskoefc47202015-06-20 22:47:01 +020062};
63
64static int gtm601_platform_probe(struct platform_device *pdev)
65{
Kuninori Morimoto993709b2018-01-29 04:41:22 +000066 return devm_snd_soc_register_component(&pdev->dev,
67 &soc_component_dev_gtm601, &gtm601_dai, 1);
Marek Beliskoefc47202015-06-20 22:47:01 +020068}
69
Marek Beliskoefc47202015-06-20 22:47:01 +020070#if defined(CONFIG_OF)
71static const struct of_device_id gtm601_codec_of_match[] = {
72 { .compatible = "option,gtm601", },
73 {},
74};
75MODULE_DEVICE_TABLE(of, gtm601_codec_of_match);
76#endif
77
78static struct platform_driver gtm601_codec_driver = {
79 .driver = {
Axel Lin02a95472015-07-07 12:57:19 +080080 .name = "gtm601",
81 .of_match_table = of_match_ptr(gtm601_codec_of_match),
Marek Beliskoefc47202015-06-20 22:47:01 +020082 },
Marek Beliskoefc47202015-06-20 22:47:01 +020083 .probe = gtm601_platform_probe,
Marek Beliskoefc47202015-06-20 22:47:01 +020084};
85
86module_platform_driver(gtm601_codec_driver);
87
88MODULE_DESCRIPTION("ASoC gtm601 driver");
89MODULE_AUTHOR("Marek Belisko <marek@goldelico.com>");
90MODULE_LICENSE("GPL");
Axel Lind4979632015-06-24 10:55:24 +080091MODULE_ALIAS("platform:gtm601");