1 // SPDX-License-Identifier: GPL-2.0-only
3 #include <linux/module.h>
6 #include <asm/mach-types.h>
8 #include "../codecs/wm8940.h"
9 #include "pxa2xx-i2s.h"
11 static int imote2_asoc_hw_params(struct snd_pcm_substream
*substream
,
12 struct snd_pcm_hw_params
*params
)
14 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
15 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
16 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
20 switch (params_rate(params
)) {
34 ret
= snd_soc_dai_set_sysclk(codec_dai
, 0, clk
,
39 /* set the I2S system clock as input (unused) */
40 ret
= snd_soc_dai_set_sysclk(cpu_dai
, PXA2XX_I2S_SYSCLK
, clk
,
46 static const struct snd_soc_ops imote2_asoc_ops
= {
47 .hw_params
= imote2_asoc_hw_params
,
50 SND_SOC_DAILINK_DEFS(wm8940
,
51 DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-i2s")),
52 DAILINK_COMP_ARRAY(COMP_CODEC("wm8940-codec.0-0034",
54 DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
56 static struct snd_soc_dai_link imote2_dai
= {
58 .stream_name
= "WM8940",
59 .dai_fmt
= SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
|
60 SND_SOC_DAIFMT_CBS_CFS
,
61 .ops
= &imote2_asoc_ops
,
62 SND_SOC_DAILINK_REG(wm8940
),
65 static struct snd_soc_card imote2
= {
68 .dai_link
= &imote2_dai
,
72 static int imote2_probe(struct platform_device
*pdev
)
74 struct snd_soc_card
*card
= &imote2
;
77 card
->dev
= &pdev
->dev
;
79 ret
= devm_snd_soc_register_card(&pdev
->dev
, card
);
81 dev_err(&pdev
->dev
, "snd_soc_register_card() failed: %d\n",
86 static struct platform_driver imote2_driver
= {
88 .name
= "imote2-audio",
89 .pm
= &snd_soc_pm_ops
,
91 .probe
= imote2_probe
,
94 module_platform_driver(imote2_driver
);
96 MODULE_AUTHOR("Jonathan Cameron");
97 MODULE_DESCRIPTION("ALSA SoC Imote 2");
98 MODULE_LICENSE("GPL");
99 MODULE_ALIAS("platform:imote2-audio");