Loading...
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * This is a simple driver for the GTM601 Voice PCM interface
4 *
5 * Copyright (C) 2015 Goldelico GmbH
6 *
7 * Author: Marek Belisko <marek@goldelico.com>
8 *
9 * Based on wm8727.c driver
10 */
11
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>
21
22static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = {
23 SND_SOC_DAPM_OUTPUT("AOUT"),
24 SND_SOC_DAPM_INPUT("AIN"),
25};
26
27static const struct snd_soc_dapm_route gtm601_dapm_routes[] = {
28 { "AOUT", NULL, "Playback" },
29 { "Capture", NULL, "AIN" },
30};
31
32static struct snd_soc_dai_driver gtm601_dai = {
33 .name = "gtm601",
34 .playback = {
35 .stream_name = "Playback",
36 .channels_min = 1,
37 .channels_max = 1,
38 .rates = SNDRV_PCM_RATE_8000,
39 .formats = SNDRV_PCM_FMTBIT_S16_LE,
40 },
41 .capture = {
42 .stream_name = "Capture",
43 .channels_min = 1,
44 .channels_max = 1,
45 .rates = SNDRV_PCM_RATE_8000,
46 .formats = SNDRV_PCM_FMTBIT_S16_LE,
47 },
48};
49
50static struct snd_soc_dai_driver bm818_dai = {
51 .name = "bm818",
52 .playback = {
53 .stream_name = "Playback",
54 .channels_min = 2,
55 .channels_max = 2,
56 .rates = SNDRV_PCM_RATE_48000,
57 .formats = SNDRV_PCM_FMTBIT_S16_LE,
58 },
59 .capture = {
60 .stream_name = "Capture",
61 .channels_min = 2,
62 .channels_max = 2,
63 .rates = SNDRV_PCM_RATE_48000,
64 .formats = SNDRV_PCM_FMTBIT_S16_LE,
65 },
66};
67
68static 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),
73 .idle_bias_on = 1,
74 .use_pmdown_time = 1,
75 .endianness = 1,
76 .non_legacy_dai_naming = 1,
77};
78
79static int gtm601_platform_probe(struct platform_device *pdev)
80{
81 const struct snd_soc_dai_driver *dai_driver;
82
83 dai_driver = of_device_get_match_data(&pdev->dev);
84
85 return devm_snd_soc_register_component(&pdev->dev,
86 &soc_component_dev_gtm601,
87 (struct snd_soc_dai_driver *)dai_driver, 1);
88}
89
90static 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 },
93 {},
94};
95MODULE_DEVICE_TABLE(of, gtm601_codec_of_match);
96
97static struct platform_driver gtm601_codec_driver = {
98 .driver = {
99 .name = "gtm601",
100 .of_match_table = of_match_ptr(gtm601_codec_of_match),
101 },
102 .probe = gtm601_platform_probe,
103};
104
105module_platform_driver(gtm601_codec_driver);
106
107MODULE_DESCRIPTION("ASoC gtm601 driver");
108MODULE_AUTHOR("Marek Belisko <marek@goldelico.com>");
109MODULE_LICENSE("GPL");
110MODULE_ALIAS("platform:gtm601");
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/ac97_codec.h>
23#include <sound/initval.h>
24#include <sound/soc.h>
25
26static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = {
27 SND_SOC_DAPM_OUTPUT("AOUT"),
28 SND_SOC_DAPM_INPUT("AIN"),
29};
30
31static const struct snd_soc_dapm_route gtm601_dapm_routes[] = {
32 { "AOUT", NULL, "Playback" },
33 { "Capture", NULL, "AIN" },
34};
35
36static struct snd_soc_dai_driver gtm601_dai = {
37 .name = "gtm601",
38 .playback = {
39 .stream_name = "Playback",
40 .channels_min = 1,
41 .channels_max = 1,
42 .rates = SNDRV_PCM_RATE_8000,
43 .formats = SNDRV_PCM_FMTBIT_S16_LE,
44 },
45 .capture = {
46 .stream_name = "Capture",
47 .channels_min = 1,
48 .channels_max = 1,
49 .rates = SNDRV_PCM_RATE_8000,
50 .formats = SNDRV_PCM_FMTBIT_S16_LE,
51 },
52};
53
54static const struct snd_soc_codec_driver soc_codec_dev_gtm601 = {
55 .dapm_widgets = gtm601_dapm_widgets,
56 .num_dapm_widgets = ARRAY_SIZE(gtm601_dapm_widgets),
57 .dapm_routes = gtm601_dapm_routes,
58 .num_dapm_routes = ARRAY_SIZE(gtm601_dapm_routes),
59};
60
61static int gtm601_platform_probe(struct platform_device *pdev)
62{
63 return snd_soc_register_codec(&pdev->dev,
64 &soc_codec_dev_gtm601, >m601_dai, 1);
65}
66
67static int gtm601_platform_remove(struct platform_device *pdev)
68{
69 snd_soc_unregister_codec(&pdev->dev);
70 return 0;
71}
72
73#if defined(CONFIG_OF)
74static const struct of_device_id gtm601_codec_of_match[] = {
75 { .compatible = "option,gtm601", },
76 {},
77};
78MODULE_DEVICE_TABLE(of, gtm601_codec_of_match);
79#endif
80
81static struct platform_driver gtm601_codec_driver = {
82 .driver = {
83 .name = "gtm601",
84 .of_match_table = of_match_ptr(gtm601_codec_of_match),
85 },
86 .probe = gtm601_platform_probe,
87 .remove = gtm601_platform_remove,
88};
89
90module_platform_driver(gtm601_codec_driver);
91
92MODULE_DESCRIPTION("ASoC gtm601 driver");
93MODULE_AUTHOR("Marek Belisko <marek@goldelico.com>");
94MODULE_LICENSE("GPL");
95MODULE_ALIAS("platform:gtm601");