1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2efc4720dSMarek Belisko /*
3efc4720dSMarek Belisko * This is a simple driver for the GTM601 Voice PCM interface
4efc4720dSMarek Belisko *
5efc4720dSMarek Belisko * Copyright (C) 2015 Goldelico GmbH
6efc4720dSMarek Belisko *
7efc4720dSMarek Belisko * Author: Marek Belisko <marek@goldelico.com>
8efc4720dSMarek Belisko *
9efc4720dSMarek Belisko * Based on wm8727.c driver
10efc4720dSMarek Belisko */
11efc4720dSMarek Belisko
12efc4720dSMarek Belisko #include <linux/init.h>
13efc4720dSMarek Belisko #include <linux/slab.h>
14efc4720dSMarek Belisko #include <linux/module.h>
15efc4720dSMarek Belisko #include <linux/kernel.h>
16057a317aSAngus Ainslie (Purism) #include <linux/of_device.h>
17efc4720dSMarek Belisko #include <sound/core.h>
18efc4720dSMarek Belisko #include <sound/pcm.h>
19efc4720dSMarek Belisko #include <sound/initval.h>
20efc4720dSMarek Belisko #include <sound/soc.h>
21efc4720dSMarek Belisko
22efc4720dSMarek Belisko static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = {
23efc4720dSMarek Belisko SND_SOC_DAPM_OUTPUT("AOUT"),
24efc4720dSMarek Belisko SND_SOC_DAPM_INPUT("AIN"),
25efc4720dSMarek Belisko };
26efc4720dSMarek Belisko
27efc4720dSMarek Belisko static const struct snd_soc_dapm_route gtm601_dapm_routes[] = {
28efc4720dSMarek Belisko { "AOUT", NULL, "Playback" },
29efc4720dSMarek Belisko { "Capture", NULL, "AIN" },
30efc4720dSMarek Belisko };
31efc4720dSMarek Belisko
32beb5f865Skbuild test robot static struct snd_soc_dai_driver gtm601_dai = {
33efc4720dSMarek Belisko .name = "gtm601",
34efc4720dSMarek Belisko .playback = {
35efc4720dSMarek Belisko .stream_name = "Playback",
36efc4720dSMarek Belisko .channels_min = 1,
37efc4720dSMarek Belisko .channels_max = 1,
38efc4720dSMarek Belisko .rates = SNDRV_PCM_RATE_8000,
39efc4720dSMarek Belisko .formats = SNDRV_PCM_FMTBIT_S16_LE,
40efc4720dSMarek Belisko },
41efc4720dSMarek Belisko .capture = {
42efc4720dSMarek Belisko .stream_name = "Capture",
43efc4720dSMarek Belisko .channels_min = 1,
44efc4720dSMarek Belisko .channels_max = 1,
45efc4720dSMarek Belisko .rates = SNDRV_PCM_RATE_8000,
46efc4720dSMarek Belisko .formats = SNDRV_PCM_FMTBIT_S16_LE,
47efc4720dSMarek Belisko },
48efc4720dSMarek Belisko };
49efc4720dSMarek Belisko
50057a317aSAngus Ainslie (Purism) static struct snd_soc_dai_driver bm818_dai = {
51057a317aSAngus Ainslie (Purism) .name = "bm818",
52057a317aSAngus Ainslie (Purism) .playback = {
53057a317aSAngus Ainslie (Purism) .stream_name = "Playback",
54057a317aSAngus Ainslie (Purism) .channels_min = 2,
55057a317aSAngus Ainslie (Purism) .channels_max = 2,
56057a317aSAngus Ainslie (Purism) .rates = SNDRV_PCM_RATE_48000,
57057a317aSAngus Ainslie (Purism) .formats = SNDRV_PCM_FMTBIT_S16_LE,
58057a317aSAngus Ainslie (Purism) },
59057a317aSAngus Ainslie (Purism) .capture = {
60057a317aSAngus Ainslie (Purism) .stream_name = "Capture",
61057a317aSAngus Ainslie (Purism) .channels_min = 2,
62057a317aSAngus Ainslie (Purism) .channels_max = 2,
63057a317aSAngus Ainslie (Purism) .rates = SNDRV_PCM_RATE_48000,
64057a317aSAngus Ainslie (Purism) .formats = SNDRV_PCM_FMTBIT_S16_LE,
65057a317aSAngus Ainslie (Purism) },
66057a317aSAngus Ainslie (Purism) };
67057a317aSAngus Ainslie (Purism)
68993709b8SKuninori Morimoto static const struct snd_soc_component_driver soc_component_dev_gtm601 = {
69efc4720dSMarek Belisko .dapm_widgets = gtm601_dapm_widgets,
70efc4720dSMarek Belisko .num_dapm_widgets = ARRAY_SIZE(gtm601_dapm_widgets),
71efc4720dSMarek Belisko .dapm_routes = gtm601_dapm_routes,
72efc4720dSMarek Belisko .num_dapm_routes = ARRAY_SIZE(gtm601_dapm_routes),
73993709b8SKuninori Morimoto .idle_bias_on = 1,
74993709b8SKuninori Morimoto .use_pmdown_time = 1,
75993709b8SKuninori Morimoto .endianness = 1,
76efc4720dSMarek Belisko };
77efc4720dSMarek Belisko
gtm601_platform_probe(struct platform_device * pdev)78efc4720dSMarek Belisko static int gtm601_platform_probe(struct platform_device *pdev)
79efc4720dSMarek Belisko {
80057a317aSAngus Ainslie (Purism) const struct snd_soc_dai_driver *dai_driver;
81057a317aSAngus Ainslie (Purism)
82057a317aSAngus Ainslie (Purism) dai_driver = of_device_get_match_data(&pdev->dev);
83057a317aSAngus Ainslie (Purism)
84993709b8SKuninori Morimoto return devm_snd_soc_register_component(&pdev->dev,
85057a317aSAngus Ainslie (Purism) &soc_component_dev_gtm601,
86057a317aSAngus Ainslie (Purism) (struct snd_soc_dai_driver *)dai_driver, 1);
87efc4720dSMarek Belisko }
88efc4720dSMarek Belisko
89*03219fafSKrzysztof Kozlowski static const struct of_device_id gtm601_codec_of_match[] __maybe_unused = {
90057a317aSAngus Ainslie (Purism) { .compatible = "option,gtm601", .data = (void *)>m601_dai },
91057a317aSAngus Ainslie (Purism) { .compatible = "broadmobi,bm818", .data = (void *)&bm818_dai },
92efc4720dSMarek Belisko {},
93efc4720dSMarek Belisko };
94efc4720dSMarek Belisko MODULE_DEVICE_TABLE(of, gtm601_codec_of_match);
95efc4720dSMarek Belisko
96efc4720dSMarek Belisko static struct platform_driver gtm601_codec_driver = {
97efc4720dSMarek Belisko .driver = {
98efc4720dSMarek Belisko .name = "gtm601",
99efc4720dSMarek Belisko .of_match_table = of_match_ptr(gtm601_codec_of_match),
100efc4720dSMarek Belisko },
101efc4720dSMarek Belisko .probe = gtm601_platform_probe,
102efc4720dSMarek Belisko };
103efc4720dSMarek Belisko
104efc4720dSMarek Belisko module_platform_driver(gtm601_codec_driver);
105efc4720dSMarek Belisko
106efc4720dSMarek Belisko MODULE_DESCRIPTION("ASoC gtm601 driver");
107efc4720dSMarek Belisko MODULE_AUTHOR("Marek Belisko <marek@goldelico.com>");
108efc4720dSMarek Belisko MODULE_LICENSE("GPL");
109d4979631SAxel Lin MODULE_ALIAS("platform:gtm601");
110