Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 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 |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/slab.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/kernel.h> |
Angus Ainslie (Purism) | 057a317 | 2019-12-23 07:47:11 -0800 | [diff] [blame^] | 16 | #include <linux/of_device.h> |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 17 | #include <sound/core.h> |
| 18 | #include <sound/pcm.h> |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 19 | #include <sound/initval.h> |
| 20 | #include <sound/soc.h> |
| 21 | |
| 22 | static const struct snd_soc_dapm_widget gtm601_dapm_widgets[] = { |
| 23 | SND_SOC_DAPM_OUTPUT("AOUT"), |
| 24 | SND_SOC_DAPM_INPUT("AIN"), |
| 25 | }; |
| 26 | |
| 27 | static const struct snd_soc_dapm_route gtm601_dapm_routes[] = { |
| 28 | { "AOUT", NULL, "Playback" }, |
| 29 | { "Capture", NULL, "AIN" }, |
| 30 | }; |
| 31 | |
kbuild test robot | beb5f86 | 2015-06-22 23:48:25 +0800 | [diff] [blame] | 32 | static struct snd_soc_dai_driver gtm601_dai = { |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 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 | |
Angus Ainslie (Purism) | 057a317 | 2019-12-23 07:47:11 -0800 | [diff] [blame^] | 50 | static 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 | |
Kuninori Morimoto | 993709b | 2018-01-29 04:41:22 +0000 | [diff] [blame] | 68 | static 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, |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | static int gtm601_platform_probe(struct platform_device *pdev) |
| 80 | { |
Angus Ainslie (Purism) | 057a317 | 2019-12-23 07:47:11 -0800 | [diff] [blame^] | 81 | const struct snd_soc_dai_driver *dai_driver; |
| 82 | |
| 83 | dai_driver = of_device_get_match_data(&pdev->dev); |
| 84 | |
Kuninori Morimoto | 993709b | 2018-01-29 04:41:22 +0000 | [diff] [blame] | 85 | return devm_snd_soc_register_component(&pdev->dev, |
Angus Ainslie (Purism) | 057a317 | 2019-12-23 07:47:11 -0800 | [diff] [blame^] | 86 | &soc_component_dev_gtm601, |
| 87 | (struct snd_soc_dai_driver *)dai_driver, 1); |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 88 | } |
| 89 | |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 90 | #if defined(CONFIG_OF) |
| 91 | static const struct of_device_id gtm601_codec_of_match[] = { |
Angus Ainslie (Purism) | 057a317 | 2019-12-23 07:47:11 -0800 | [diff] [blame^] | 92 | { .compatible = "option,gtm601", .data = (void *)>m601_dai }, |
| 93 | { .compatible = "broadmobi,bm818", .data = (void *)&bm818_dai }, |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 94 | {}, |
| 95 | }; |
| 96 | MODULE_DEVICE_TABLE(of, gtm601_codec_of_match); |
| 97 | #endif |
| 98 | |
| 99 | static struct platform_driver gtm601_codec_driver = { |
| 100 | .driver = { |
Axel Lin | 02a9547 | 2015-07-07 12:57:19 +0800 | [diff] [blame] | 101 | .name = "gtm601", |
| 102 | .of_match_table = of_match_ptr(gtm601_codec_of_match), |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 103 | }, |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 104 | .probe = gtm601_platform_probe, |
Marek Belisko | efc4720 | 2015-06-20 22:47:01 +0200 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | module_platform_driver(gtm601_codec_driver); |
| 108 | |
| 109 | MODULE_DESCRIPTION("ASoC gtm601 driver"); |
| 110 | MODULE_AUTHOR("Marek Belisko <marek@goldelico.com>"); |
| 111 | MODULE_LICENSE("GPL"); |
Axel Lin | d497963 | 2015-06-24 10:55:24 +0800 | [diff] [blame] | 112 | MODULE_ALIAS("platform:gtm601"); |