Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * This is a simple driver for the GTM601 Voice PCM interface
0004  *
0005  * Copyright (C) 2015 Goldelico GmbH
0006  *
0007  * Author: Marek Belisko <marek@goldelico.com>
0008  *
0009  * Based on wm8727.c driver
0010  */
0011 
0012 #include <linux/init.h>
0013 #include <linux/slab.h>
0014 #include <linux/module.h>
0015 #include <linux/kernel.h>
0016 #include <linux/of_device.h>
0017 #include <sound/core.h>
0018 #include <sound/pcm.h>
0019 #include <sound/initval.h>
0020 #include <sound/soc.h>
0021 
0022 static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = {
0023     SND_SOC_DAPM_OUTPUT("AOUT"),
0024     SND_SOC_DAPM_INPUT("AIN"),
0025 };
0026 
0027 static const struct snd_soc_dapm_route gtm601_dapm_routes[] = {
0028     { "AOUT", NULL, "Playback" },
0029     { "Capture", NULL, "AIN" },
0030 };
0031 
0032 static struct snd_soc_dai_driver gtm601_dai = {
0033     .name = "gtm601",
0034     .playback = {
0035         .stream_name = "Playback",
0036         .channels_min = 1,
0037         .channels_max = 1,
0038         .rates = SNDRV_PCM_RATE_8000,
0039         .formats = SNDRV_PCM_FMTBIT_S16_LE,
0040         },
0041     .capture = {
0042         .stream_name = "Capture",
0043         .channels_min = 1,
0044         .channels_max = 1,
0045         .rates = SNDRV_PCM_RATE_8000,
0046         .formats = SNDRV_PCM_FMTBIT_S16_LE,
0047     },
0048 };
0049 
0050 static struct snd_soc_dai_driver bm818_dai = {
0051     .name = "bm818",
0052     .playback = {
0053         .stream_name = "Playback",
0054         .channels_min = 2,
0055         .channels_max = 2,
0056         .rates = SNDRV_PCM_RATE_48000,
0057         .formats = SNDRV_PCM_FMTBIT_S16_LE,
0058     },
0059     .capture = {
0060         .stream_name = "Capture",
0061         .channels_min = 2,
0062         .channels_max = 2,
0063         .rates = SNDRV_PCM_RATE_48000,
0064         .formats = SNDRV_PCM_FMTBIT_S16_LE,
0065     },
0066 };
0067 
0068 static const struct snd_soc_component_driver soc_component_dev_gtm601 = {
0069     .dapm_widgets       = gtm601_dapm_widgets,
0070     .num_dapm_widgets   = ARRAY_SIZE(gtm601_dapm_widgets),
0071     .dapm_routes        = gtm601_dapm_routes,
0072     .num_dapm_routes    = ARRAY_SIZE(gtm601_dapm_routes),
0073     .idle_bias_on       = 1,
0074     .use_pmdown_time    = 1,
0075     .endianness     = 1,
0076 };
0077 
0078 static int gtm601_platform_probe(struct platform_device *pdev)
0079 {
0080     const struct snd_soc_dai_driver *dai_driver;
0081 
0082     dai_driver = of_device_get_match_data(&pdev->dev);
0083 
0084     return devm_snd_soc_register_component(&pdev->dev,
0085             &soc_component_dev_gtm601,
0086             (struct snd_soc_dai_driver *)dai_driver, 1);
0087 }
0088 
0089 static const struct of_device_id gtm601_codec_of_match[] __maybe_unused = {
0090     { .compatible = "option,gtm601", .data = (void *)&gtm601_dai },
0091     { .compatible = "broadmobi,bm818", .data = (void *)&bm818_dai },
0092     {},
0093 };
0094 MODULE_DEVICE_TABLE(of, gtm601_codec_of_match);
0095 
0096 static struct platform_driver gtm601_codec_driver = {
0097     .driver = {
0098         .name = "gtm601",
0099         .of_match_table = of_match_ptr(gtm601_codec_of_match),
0100     },
0101     .probe = gtm601_platform_probe,
0102 };
0103 
0104 module_platform_driver(gtm601_codec_driver);
0105 
0106 MODULE_DESCRIPTION("ASoC gtm601 driver");
0107 MODULE_AUTHOR("Marek Belisko <marek@goldelico.com>");
0108 MODULE_LICENSE("GPL");
0109 MODULE_ALIAS("platform:gtm601");