1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright 2007,2008 Simtec Electronics
5 // Based on sound/soc/pxa/spitz.c
6 // Copyright 2005 Wolfson Microelectronics PLC.
7 // Copyright 2005 Openedhand Ltd.
9 #include <linux/module.h>
10 #include <sound/soc.h>
12 #include <asm/mach-types.h>
14 #include "s3c2412-i2s.h"
15 #include "../codecs/wm8750.h"
17 static const struct snd_soc_dapm_route audio_map
[] = {
18 { "Headphone Jack", NULL
, "LOUT1" },
19 { "Headphone Jack", NULL
, "ROUT1" },
20 { "Internal Speaker", NULL
, "LOUT2" },
21 { "Internal Speaker", NULL
, "ROUT2" },
22 { "LINPUT1", NULL
, "Line Input" },
23 { "RINPUT1", NULL
, "Line Input" },
26 static const struct snd_soc_dapm_widget wm8750_dapm_widgets
[] = {
27 SND_SOC_DAPM_HP("Headphone Jack", NULL
),
28 SND_SOC_DAPM_SPK("Internal Speaker", NULL
),
29 SND_SOC_DAPM_LINE("Line In", NULL
),
32 static int jive_hw_params(struct snd_pcm_substream
*substream
,
33 struct snd_pcm_hw_params
*params
)
35 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
36 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
37 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
38 struct s3c_i2sv2_rate_calc div
;
42 switch (params_rate(params
)) {
56 s3c_i2sv2_iis_calc_rate(&div
, NULL
, params_rate(params
),
57 s3c_i2sv2_get_clock(cpu_dai
));
59 /* set the codec system clock for DAC and ADC */
60 ret
= snd_soc_dai_set_sysclk(codec_dai
, WM8750_SYSCLK
, clk
,
65 ret
= snd_soc_dai_set_clkdiv(cpu_dai
, S3C2412_DIV_RCLK
, div
.fs_div
);
69 ret
= snd_soc_dai_set_clkdiv(cpu_dai
, S3C2412_DIV_PRESCALER
,
77 static const struct snd_soc_ops jive_ops
= {
78 .hw_params
= jive_hw_params
,
81 SND_SOC_DAILINK_DEFS(wm8750
,
82 DAILINK_COMP_ARRAY(COMP_CPU("s3c2412-i2s")),
83 DAILINK_COMP_ARRAY(COMP_CODEC("wm8750.0-001a", "wm8750-hifi")),
84 DAILINK_COMP_ARRAY(COMP_PLATFORM("s3c2412-i2s")));
86 static struct snd_soc_dai_link jive_dai
= {
88 .stream_name
= "WM8750",
89 .dai_fmt
= SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
|
90 SND_SOC_DAIFMT_CBS_CFS
,
92 SND_SOC_DAILINK_REG(wm8750
),
95 /* jive audio machine driver */
96 static struct snd_soc_card snd_soc_machine_jive
= {
99 .dai_link
= &jive_dai
,
102 .dapm_widgets
= wm8750_dapm_widgets
,
103 .num_dapm_widgets
= ARRAY_SIZE(wm8750_dapm_widgets
),
104 .dapm_routes
= audio_map
,
105 .num_dapm_routes
= ARRAY_SIZE(audio_map
),
106 .fully_routed
= true,
109 static struct platform_device
*jive_snd_device
;
111 static int __init
jive_init(void)
115 if (!machine_is_jive())
118 printk("JIVE WM8750 Audio support\n");
120 jive_snd_device
= platform_device_alloc("soc-audio", -1);
121 if (!jive_snd_device
)
124 platform_set_drvdata(jive_snd_device
, &snd_soc_machine_jive
);
125 ret
= platform_device_add(jive_snd_device
);
128 platform_device_put(jive_snd_device
);
133 static void __exit
jive_exit(void)
135 platform_device_unregister(jive_snd_device
);
138 module_init(jive_init
);
139 module_exit(jive_exit
);
141 MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
142 MODULE_DESCRIPTION("ALSA SoC Jive Audio support");
143 MODULE_LICENSE("GPL");