1 /* sound/soc/s3c24xx/jive_wm8750.c
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 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/module.h>
15 #include <linux/moduleparam.h>
16 #include <linux/timer.h>
17 #include <linux/interrupt.h>
18 #include <linux/platform_device.h>
19 #include <linux/clk.h>
21 #include <sound/core.h>
22 #include <sound/pcm.h>
23 #include <sound/soc.h>
25 #include <asm/mach-types.h>
28 #include "s3c2412-i2s.h"
30 #include "../codecs/wm8750.h"
32 static const struct snd_soc_dapm_route audio_map
[] = {
33 { "Headphone Jack", NULL
, "LOUT1" },
34 { "Headphone Jack", NULL
, "ROUT1" },
35 { "Internal Speaker", NULL
, "LOUT2" },
36 { "Internal Speaker", NULL
, "ROUT2" },
37 { "LINPUT1", NULL
, "Line Input" },
38 { "RINPUT1", NULL
, "Line Input" },
41 static const struct snd_soc_dapm_widget wm8750_dapm_widgets
[] = {
42 SND_SOC_DAPM_HP("Headphone Jack", NULL
),
43 SND_SOC_DAPM_SPK("Internal Speaker", NULL
),
44 SND_SOC_DAPM_LINE("Line In", NULL
),
47 static int jive_hw_params(struct snd_pcm_substream
*substream
,
48 struct snd_pcm_hw_params
*params
)
50 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
51 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
52 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
53 struct s3c_i2sv2_rate_calc div
;
57 switch (params_rate(params
)) {
71 s3c_i2sv2_iis_calc_rate(&div
, NULL
, params_rate(params
),
72 s3c_i2sv2_get_clock(cpu_dai
));
74 /* set codec DAI configuration */
75 ret
= snd_soc_dai_set_fmt(codec_dai
, SND_SOC_DAIFMT_I2S
|
76 SND_SOC_DAIFMT_NB_NF
|
77 SND_SOC_DAIFMT_CBS_CFS
);
81 /* set cpu DAI configuration */
82 ret
= snd_soc_dai_set_fmt(cpu_dai
, SND_SOC_DAIFMT_I2S
|
83 SND_SOC_DAIFMT_NB_NF
|
84 SND_SOC_DAIFMT_CBS_CFS
);
88 /* set the codec system clock for DAC and ADC */
89 ret
= snd_soc_dai_set_sysclk(codec_dai
, WM8750_SYSCLK
, clk
,
94 ret
= snd_soc_dai_set_clkdiv(cpu_dai
, S3C2412_DIV_RCLK
, div
.fs_div
);
98 ret
= snd_soc_dai_set_clkdiv(cpu_dai
, S3C2412_DIV_PRESCALER
,
106 static struct snd_soc_ops jive_ops
= {
107 .hw_params
= jive_hw_params
,
110 static int jive_wm8750_init(struct snd_soc_pcm_runtime
*rtd
)
112 struct snd_soc_codec
*codec
= rtd
->codec
;
113 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
116 /* These endpoints are not being used. */
117 snd_soc_dapm_nc_pin(dapm
, "LINPUT2");
118 snd_soc_dapm_nc_pin(dapm
, "RINPUT2");
119 snd_soc_dapm_nc_pin(dapm
, "LINPUT3");
120 snd_soc_dapm_nc_pin(dapm
, "RINPUT3");
121 snd_soc_dapm_nc_pin(dapm
, "OUT3");
122 snd_soc_dapm_nc_pin(dapm
, "MONO");
124 /* Add jive specific widgets */
125 err
= snd_soc_dapm_new_controls(dapm
, wm8750_dapm_widgets
,
126 ARRAY_SIZE(wm8750_dapm_widgets
));
128 printk(KERN_ERR
"%s: failed to add widgets (%d)\n",
133 snd_soc_dapm_add_routes(dapm
, audio_map
, ARRAY_SIZE(audio_map
));
134 snd_soc_dapm_sync(dapm
);
139 static struct snd_soc_dai_link jive_dai
= {
141 .stream_name
= "WM8750",
142 .cpu_dai_name
= "s3c2412-i2s",
143 .codec_dai_name
= "wm8750-hifi",
144 .platform_name
= "samsung-audio",
145 .codec_name
= "wm8750-codec.0-0x1a",
146 .init
= jive_wm8750_init
,
150 /* jive audio machine driver */
151 static struct snd_soc_card snd_soc_machine_jive
= {
153 .dai_link
= &jive_dai
,
157 static struct platform_device
*jive_snd_device
;
159 static int __init
jive_init(void)
163 if (!machine_is_jive())
166 printk("JIVE WM8750 Audio support\n");
168 jive_snd_device
= platform_device_alloc("soc-audio", -1);
169 if (!jive_snd_device
)
172 platform_set_drvdata(jive_snd_device
, &snd_soc_machine_jive
);
173 ret
= platform_device_add(jive_snd_device
);
176 platform_device_put(jive_snd_device
);
181 static void __exit
jive_exit(void)
183 platform_device_unregister(jive_snd_device
);
186 module_init(jive_init
);
187 module_exit(jive_exit
);
189 MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
190 MODULE_DESCRIPTION("ALSA SoC Jive Audio support");
191 MODULE_LICENSE("GPL");