Lars-Peter Clausen | 53a93d5 | 2011-06-13 15:26:21 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Machine driver for EVAL-ADAU1701MINIZ on Analog Devices bfin |
| 3 | * evaluation boards. |
| 4 | * |
| 5 | * Copyright 2011 Analog Devices Inc. |
| 6 | * Author: Lars-Peter Clausen <lars@metafoo.de> |
| 7 | * |
| 8 | * Licensed under the GPL-2 or later. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/device.h> |
| 13 | #include <sound/core.h> |
| 14 | #include <sound/pcm.h> |
| 15 | #include <sound/soc.h> |
| 16 | #include <sound/pcm_params.h> |
| 17 | |
| 18 | #include "../codecs/adau1701.h" |
| 19 | |
| 20 | static const struct snd_soc_dapm_widget bfin_eval_adau1701_dapm_widgets[] = { |
| 21 | SND_SOC_DAPM_SPK("Speaker", NULL), |
| 22 | SND_SOC_DAPM_LINE("Line Out", NULL), |
| 23 | SND_SOC_DAPM_LINE("Line In", NULL), |
| 24 | }; |
| 25 | |
| 26 | static const struct snd_soc_dapm_route bfin_eval_adau1701_dapm_routes[] = { |
| 27 | { "Speaker", NULL, "OUT0" }, |
| 28 | { "Speaker", NULL, "OUT1" }, |
| 29 | { "Line Out", NULL, "OUT2" }, |
| 30 | { "Line Out", NULL, "OUT3" }, |
| 31 | |
| 32 | { "IN0", NULL, "Line In" }, |
| 33 | { "IN1", NULL, "Line In" }, |
| 34 | }; |
| 35 | |
| 36 | static int bfin_eval_adau1701_hw_params(struct snd_pcm_substream *substream, |
| 37 | struct snd_pcm_hw_params *params) |
| 38 | { |
| 39 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
Lars-Peter Clausen | 53a93d5 | 2011-06-13 15:26:21 +0200 | [diff] [blame] | 40 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 41 | int ret; |
| 42 | |
Lars-Peter Clausen | 53a93d5 | 2011-06-13 15:26:21 +0200 | [diff] [blame] | 43 | ret = snd_soc_dai_set_sysclk(codec_dai, ADAU1701_CLK_SRC_OSC, 12288000, |
| 44 | SND_SOC_CLOCK_IN); |
| 45 | |
| 46 | return ret; |
| 47 | } |
| 48 | |
| 49 | static struct snd_soc_ops bfin_eval_adau1701_ops = { |
| 50 | .hw_params = bfin_eval_adau1701_hw_params, |
| 51 | }; |
| 52 | |
Lars-Peter Clausen | 980b0bc | 2012-02-01 19:24:21 +0100 | [diff] [blame] | 53 | #define BFIN_EVAL_ADAU1701_DAI_FMT (SND_SOC_DAIFMT_I2S | \ |
| 54 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM) |
| 55 | |
Lars-Peter Clausen | 53a93d5 | 2011-06-13 15:26:21 +0200 | [diff] [blame] | 56 | static struct snd_soc_dai_link bfin_eval_adau1701_dai[] = { |
| 57 | { |
| 58 | .name = "adau1701", |
| 59 | .stream_name = "adau1701", |
| 60 | .cpu_dai_name = "bfin-i2s.0", |
| 61 | .codec_dai_name = "adau1701", |
| 62 | .platform_name = "bfin-i2s-pcm-audio", |
| 63 | .codec_name = "adau1701.0-0034", |
| 64 | .ops = &bfin_eval_adau1701_ops, |
Lars-Peter Clausen | 980b0bc | 2012-02-01 19:24:21 +0100 | [diff] [blame] | 65 | .dai_fmt = BFIN_EVAL_ADAU1701_DAI_FMT, |
Lars-Peter Clausen | 53a93d5 | 2011-06-13 15:26:21 +0200 | [diff] [blame] | 66 | }, |
| 67 | { |
| 68 | .name = "adau1701", |
| 69 | .stream_name = "adau1701", |
| 70 | .cpu_dai_name = "bfin-i2s.1", |
| 71 | .codec_dai_name = "adau1701", |
| 72 | .platform_name = "bfin-i2s-pcm-audio", |
| 73 | .codec_name = "adau1701.0-0034", |
| 74 | .ops = &bfin_eval_adau1701_ops, |
Lars-Peter Clausen | 980b0bc | 2012-02-01 19:24:21 +0100 | [diff] [blame] | 75 | .dai_fmt = BFIN_EVAL_ADAU1701_DAI_FMT, |
Lars-Peter Clausen | 53a93d5 | 2011-06-13 15:26:21 +0200 | [diff] [blame] | 76 | }, |
| 77 | }; |
| 78 | |
| 79 | static struct snd_soc_card bfin_eval_adau1701 = { |
| 80 | .name = "bfin-eval-adau1701", |
Axel Lin | 30e4953 | 2011-12-22 21:17:22 +0800 | [diff] [blame] | 81 | .owner = THIS_MODULE, |
Lars-Peter Clausen | 53a93d5 | 2011-06-13 15:26:21 +0200 | [diff] [blame] | 82 | .dai_link = &bfin_eval_adau1701_dai[CONFIG_SND_BF5XX_SPORT_NUM], |
| 83 | .num_links = 1, |
| 84 | |
| 85 | .dapm_widgets = bfin_eval_adau1701_dapm_widgets, |
| 86 | .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1701_dapm_widgets), |
| 87 | .dapm_routes = bfin_eval_adau1701_dapm_routes, |
| 88 | .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1701_dapm_routes), |
| 89 | }; |
| 90 | |
| 91 | static int bfin_eval_adau1701_probe(struct platform_device *pdev) |
| 92 | { |
| 93 | struct snd_soc_card *card = &bfin_eval_adau1701; |
| 94 | |
| 95 | card->dev = &pdev->dev; |
| 96 | |
| 97 | return snd_soc_register_card(&bfin_eval_adau1701); |
| 98 | } |
| 99 | |
Bill Pemberton | dca66da | 2012-12-07 09:26:13 -0500 | [diff] [blame] | 100 | static int bfin_eval_adau1701_remove(struct platform_device *pdev) |
Lars-Peter Clausen | 53a93d5 | 2011-06-13 15:26:21 +0200 | [diff] [blame] | 101 | { |
| 102 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
| 103 | |
| 104 | snd_soc_unregister_card(card); |
| 105 | |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | static struct platform_driver bfin_eval_adau1701_driver = { |
| 110 | .driver = { |
| 111 | .name = "bfin-eval-adau1701", |
| 112 | .owner = THIS_MODULE, |
| 113 | .pm = &snd_soc_pm_ops, |
| 114 | }, |
| 115 | .probe = bfin_eval_adau1701_probe, |
Bill Pemberton | dca66da | 2012-12-07 09:26:13 -0500 | [diff] [blame] | 116 | .remove = bfin_eval_adau1701_remove, |
Lars-Peter Clausen | 53a93d5 | 2011-06-13 15:26:21 +0200 | [diff] [blame] | 117 | }; |
| 118 | |
Axel Lin | fb80297 | 2011-11-24 14:44:52 +0800 | [diff] [blame] | 119 | module_platform_driver(bfin_eval_adau1701_driver); |
Lars-Peter Clausen | 53a93d5 | 2011-06-13 15:26:21 +0200 | [diff] [blame] | 120 | |
| 121 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); |
| 122 | MODULE_DESCRIPTION("ALSA SoC bfin ADAU1701 driver"); |
| 123 | MODULE_LICENSE("GPL"); |
| 124 | MODULE_ALIAS("platform:bfin-eval-adau1701"); |