2 * ASoC machine driver for Snow boards
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
17 #include <linux/of_device.h>
19 #include <sound/soc.h>
23 #define FIN_PLL_RATE 24000000
25 static struct snd_soc_dai_link snow_dai
[] = {
28 .stream_name
= "Primary",
29 .codec_dai_name
= "HiFi",
30 .dai_fmt
= SND_SOC_DAIFMT_I2S
|
31 SND_SOC_DAIFMT_NB_NF
|
32 SND_SOC_DAIFMT_CBS_CFS
,
36 static int snow_late_probe(struct snd_soc_card
*card
)
38 struct snd_soc_pcm_runtime
*rtd
;
39 struct snd_soc_dai
*codec_dai
;
40 struct snd_soc_dai
*cpu_dai
;
43 rtd
= snd_soc_get_pcm_runtime(card
, card
->dai_link
[0].name
);
44 codec_dai
= rtd
->codec_dai
;
45 cpu_dai
= rtd
->cpu_dai
;
47 /* Set the MCLK rate for the codec */
48 ret
= snd_soc_dai_set_sysclk(codec_dai
, 0,
49 FIN_PLL_RATE
, SND_SOC_CLOCK_IN
);
53 /* Select I2S Bus clock to set RCLK and BCLK */
54 ret
= snd_soc_dai_set_sysclk(cpu_dai
, SAMSUNG_I2S_RCLKSRC_0
,
62 static struct snd_soc_card snow_snd
= {
66 .num_links
= ARRAY_SIZE(snow_dai
),
68 .late_probe
= snow_late_probe
,
71 static int snow_probe(struct platform_device
*pdev
)
73 struct snd_soc_card
*card
= &snow_snd
;
74 struct device_node
*i2s_node
, *codec_node
;
77 i2s_node
= of_parse_phandle(pdev
->dev
.of_node
,
78 "samsung,i2s-controller", 0);
81 "Property 'i2s-controller' missing or invalid\n");
85 codec_node
= of_parse_phandle(pdev
->dev
.of_node
,
86 "samsung,audio-codec", 0);
89 "Property 'audio-codec' missing or invalid\n");
93 for (i
= 0; i
< ARRAY_SIZE(snow_dai
); i
++) {
94 snow_dai
[i
].codec_of_node
= codec_node
;
95 snow_dai
[i
].cpu_of_node
= i2s_node
;
96 snow_dai
[i
].platform_of_node
= i2s_node
;
99 card
->dev
= &pdev
->dev
;
101 /* Update card-name if provided through DT, else use default name */
102 snd_soc_of_parse_card_name(card
, "samsung,model");
104 ret
= devm_snd_soc_register_card(&pdev
->dev
, card
);
106 dev_err(&pdev
->dev
, "snd_soc_register_card failed (%d)\n", ret
);
113 static const struct of_device_id snow_of_match
[] = {
114 { .compatible
= "google,snow-audio-max98090", },
115 { .compatible
= "google,snow-audio-max98091", },
116 { .compatible
= "google,snow-audio-max98095", },
119 MODULE_DEVICE_TABLE(of
, snow_of_match
);
121 static struct platform_driver snow_driver
= {
123 .name
= "snow-audio",
124 .pm
= &snd_soc_pm_ops
,
125 .of_match_table
= snow_of_match
,
130 module_platform_driver(snow_driver
);
132 MODULE_DESCRIPTION("ALSA SoC Audio machine driver for Snow");
133 MODULE_LICENSE("GPL");