2 * ASoC Driver for ADAU1977 ADC
4 * Author: Andrey Grodzovsky <andrey2805@gmail.com>
7 * This file is based on hifibery_dac driver by Florian Meier.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
22 #include <sound/core.h>
23 #include <sound/pcm.h>
24 #include <sound/pcm_params.h>
25 #include <sound/soc.h>
26 #include <sound/jack.h>
28 enum adau1977_clk_id
{
32 enum adau1977_sysclk_src
{
33 ADAU1977_SYSCLK_SRC_MCLK
,
34 ADAU1977_SYSCLK_SRC_LRCLK
,
37 static int eval_adau1977_init(struct snd_soc_pcm_runtime
*rtd
)
40 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
42 ret
= snd_soc_dai_set_tdm_slot(codec_dai
, 0, 0, 0, 0);
46 return snd_soc_codec_set_sysclk(rtd
->codec
, ADAU1977_SYSCLK
,
47 ADAU1977_SYSCLK_SRC_MCLK
, 11289600, SND_SOC_CLOCK_IN
);
50 static struct snd_soc_dai_link snd_rpi_adau1977_dai
[] = {
53 .stream_name
= "ADAU1977",
54 .cpu_dai_name
= "bcm2708-i2s.0",
55 .codec_dai_name
= "adau1977-hifi",
56 .platform_name
= "bcm2708-i2s.0",
57 .codec_name
= "adau1977.1-0011",
58 .init
= eval_adau1977_init
,
59 .dai_fmt
= SND_SOC_DAIFMT_I2S
|
60 SND_SOC_DAIFMT_NB_NF
|
61 SND_SOC_DAIFMT_CBM_CFM
,
65 /* audio machine driver */
66 static struct snd_soc_card snd_adau1977_adc
= {
67 .name
= "snd_rpi_adau1977_adc",
69 .dai_link
= snd_rpi_adau1977_dai
,
70 .num_links
= ARRAY_SIZE(snd_rpi_adau1977_dai
),
73 static int snd_adau1977_adc_probe(struct platform_device
*pdev
)
77 snd_adau1977_adc
.dev
= &pdev
->dev
;
78 if (pdev
->dev
.of_node
) {
79 struct device_node
*i2s_node
;
80 struct snd_soc_dai_link
*dai
= &snd_rpi_adau1977_dai
[0];
81 i2s_node
= of_parse_phandle(pdev
->dev
.of_node
,
85 dai
->cpu_dai_name
= NULL
;
86 dai
->cpu_of_node
= i2s_node
;
87 dai
->platform_name
= NULL
;
88 dai
->platform_of_node
= i2s_node
;
92 ret
= snd_soc_register_card(&snd_adau1977_adc
);
93 if (ret
&& ret
!= -EPROBE_DEFER
)
94 dev_err(&pdev
->dev
, "snd_soc_register_card() failed: %d\n", ret
);
99 static int snd_adau1977_adc_remove(struct platform_device
*pdev
)
101 return snd_soc_unregister_card(&snd_adau1977_adc
);
104 static const struct of_device_id snd_adau1977_adc_of_match
[] = {
105 { .compatible
= "adi,adau1977-adc", },
109 MODULE_DEVICE_TABLE(of
, snd_adau1977_adc_of_match
);
111 static struct platform_driver snd_adau1977_adc_driver
= {
113 .name
= "snd-adau1977-adc",
114 .owner
= THIS_MODULE
,
115 .of_match_table
= snd_adau1977_adc_of_match
,
117 .probe
= snd_adau1977_adc_probe
,
118 .remove
= snd_adau1977_adc_remove
,
121 module_platform_driver(snd_adau1977_adc_driver
);
123 MODULE_AUTHOR("Andrey Grodzovsky <andrey2805@gmail.com>");
124 MODULE_DESCRIPTION("ASoC Driver for ADAU1977 ADC");
125 MODULE_LICENSE("GPL v2");