2 * wm8750.c -- WM8750 ALSA SoC audio driver
4 * Copyright 2005 Openedhand Ltd.
6 * Author: Richard Purdie <richard@openedhand.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/module.h>
16 #include <linux/moduleparam.h>
17 #include <linux/init.h>
18 #include <linux/delay.h>
20 #include <linux/i2c.h>
21 #include <linux/platform_device.h>
22 #include <sound/driver.h>
23 #include <sound/core.h>
24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h>
26 #include <sound/soc.h>
27 #include <sound/soc-dapm.h>
28 #include <sound/initval.h>
32 #define AUDIO_NAME "WM8750"
33 #define WM8750_VERSION "0.11"
39 #define WM8750_DEBUG 0
42 #define dbg(format, arg...) \
43 printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg)
45 #define dbg(format, arg...) do {} while (0)
47 #define err(format, arg...) \
48 printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
49 #define info(format, arg...) \
50 printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
51 #define warn(format, arg...) \
52 printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)
54 static struct workqueue_struct *wm8750_workq = NULL;
55 static struct work_struct wm8750_dapm_work;
58 * wm8750 register cache
59 * We can't read the WM8750 register space when we
60 * are using 2 wire for device control, so we cache them instead.
62 static const u16 wm8750_reg[] = {
63 0x0097, 0x0097, 0x0079, 0x0079, /* 0 */
64 0x0000, 0x0008, 0x0000, 0x000a, /* 4 */
65 0x0000, 0x0000, 0x00ff, 0x00ff, /* 8 */
66 0x000f, 0x000f, 0x0000, 0x0000, /* 12 */
67 0x0000, 0x007b, 0x0000, 0x0032, /* 16 */
68 0x0000, 0x00c3, 0x00c3, 0x00c0, /* 20 */
69 0x0000, 0x0000, 0x0000, 0x0000, /* 24 */
70 0x0000, 0x0000, 0x0000, 0x0000, /* 28 */
71 0x0000, 0x0000, 0x0050, 0x0050, /* 32 */
72 0x0050, 0x0050, 0x0050, 0x0050, /* 36 */
73 0x0079, 0x0079, 0x0079, /* 40 */
76 #define WM8750_HIFI_DAIFMT \
77 (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_RIGHT_J | \
78 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_IB_NF | \
82 (SND_SOC_DAIDIR_PLAYBACK | SND_SOC_DAIDIR_CAPTURE)
84 #define WM8750_HIFI_FSB \
85 (SND_SOC_FSBD(1) | SND_SOC_FSBD(2) | SND_SOC_FSBD(4) | \
86 SND_SOC_FSBD(8) | SND_SOC_FSBD(16))
88 #define WM8750_HIFI_RATES \
89 (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \
90 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
91 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
93 #define WM8750_HIFI_BITS \
94 (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
95 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
97 static struct snd_soc_dai_mode wm8750_modes[] = {
98 /* common codec frame and clock master modes */
100 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
101 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_8000,
102 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 1536, WM8750_HIFI_FSB},
103 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
104 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_8000,
105 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 1408, WM8750_HIFI_FSB},
106 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
107 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_8000,
108 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 2304, WM8750_HIFI_FSB},
109 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
110 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_8000,
111 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 2112, WM8750_HIFI_FSB},
112 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
113 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_8000,
114 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 1500, WM8750_HIFI_FSB},
117 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
118 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_11025,
119 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 1024, WM8750_HIFI_FSB},
120 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
121 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_11025,
122 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 1536, WM8750_HIFI_FSB},
123 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
124 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_11025,
125 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 1088, WM8750_HIFI_FSB},
128 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
129 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_16000,
130 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 768, WM8750_HIFI_FSB},
131 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
132 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_16000,
133 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 1152, WM8750_HIFI_FSB},
134 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
135 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_16000,
136 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 750, WM8750_HIFI_FSB},
139 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
140 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_22050,
141 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 512, WM8750_HIFI_FSB},
142 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
143 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_22050,
144 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 768, WM8750_HIFI_FSB},
145 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
146 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_22050,
147 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 544, WM8750_HIFI_FSB},
150 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
151 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_16000,
152 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 384, WM8750_HIFI_FSB},
153 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
154 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_16000,
155 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 576, WM8750_HIFI_FSB},
156 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
157 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_16000,
158 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 375, WM8750_HIFI_FSB},
161 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
162 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_44100 |
163 SNDRV_PCM_RATE_48000, WM8750_DIR, SND_SOC_DAI_BFS_DIV, 256,
165 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
166 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_44100 |
167 SNDRV_PCM_RATE_48000, WM8750_DIR, SND_SOC_DAI_BFS_DIV, 384,
169 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
170 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_44100,
171 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 272, WM8750_HIFI_FSB},
172 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
173 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_48000,
174 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 250, WM8750_HIFI_FSB},
177 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
178 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_88200 |
179 SNDRV_PCM_RATE_96000, WM8750_DIR, SND_SOC_DAI_BFS_DIV, 128,
181 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
182 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_88200 |
183 SNDRV_PCM_RATE_96000, WM8750_DIR, SND_SOC_DAI_BFS_DIV, 192,
185 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
186 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_88200,
187 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 136, WM8750_HIFI_FSB},
188 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBM_CFM,
189 SND_SOC_DAITDM_LRDW(0,0), WM8750_HIFI_BITS, SNDRV_PCM_RATE_96000,
190 WM8750_DIR, SND_SOC_DAI_BFS_DIV, 125, WM8750_HIFI_FSB},
192 /* codec frame and clock slave modes */
193 {WM8750_HIFI_DAIFMT | SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAITDM_LRDW(0,0),
194 WM8750_HIFI_BITS, WM8750_HIFI_RATES, WM8750_DIR,
195 SND_SOC_DAI_BFS_DIV, SND_SOC_FS_ALL, SND_SOC_FSBD_ALL},
199 * read wm8750 register cache
201 static inline unsigned int wm8750_read_reg_cache(struct snd_soc_codec *codec,
204 u16 *cache = codec->reg_cache;
205 if (reg > WM8750_CACHE_REGNUM)
211 * write wm8750 register cache
213 static inline void wm8750_write_reg_cache(struct snd_soc_codec *codec,
214 unsigned int reg, unsigned int value)
216 u16 *cache = codec->reg_cache;
217 if (reg > WM8750_CACHE_REGNUM)
222 static int wm8750_write(struct snd_soc_codec *codec, unsigned int reg,
228 * D15..D9 WM8753 register offset
229 * D8...D0 register data
231 data[0] = (reg << 1) | ((value >> 8) & 0x0001);
232 data[1] = value & 0x00ff;
234 wm8750_write_reg_cache (codec, reg, value);
235 if (codec->hw_write(codec->control_data, data, 2) == 2)
241 #define wm8750_reset(c) wm8750_write(c, WM8750_RESET, 0)
246 static const char *wm8750_bass[] = {"Linear Control", "Adaptive Boost"};
247 static const char *wm8750_bass_filter[] = { "130Hz @ 48kHz", "200Hz @ 48kHz" };
248 static const char *wm8750_treble[] = {"8kHz", "4kHz"};
249 static const char *wm8750_3d_lc[] = {"200Hz", "500Hz"};
250 static const char *wm8750_3d_uc[] = {"2.2kHz", "1.5kHz"};
251 static const char *wm8750_3d_func[] = {"Capture", "Playback"};
252 static const char *wm8750_alc_func[] = {"Off", "Right", "Left", "Stereo"};
253 static const char *wm8750_ng_type[] = {"Constant PGA Gain",
255 static const char *wm8750_line_mux[] = {"Line 1", "Line 2", "Line 3", "PGA",
257 static const char *wm8750_pga_sel[] = {"Line 1", "Line 2", "Line 3",
259 static const char *wm8750_out3[] = {"VREF", "ROUT1 + Vol", "MonoOut",
261 static const char *wm8750_diff_sel[] = {"Line 1", "Line 2"};
262 static const char *wm8750_adcpol[] = {"Normal", "L Invert", "R Invert",
264 static const char *wm8750_deemph[] = {"None", "32Khz", "44.1Khz", "48Khz"};
265 static const char *wm8750_mono_mux[] = {"Stereo", "Mono (Left)",
266 "Mono (Right)", "Digital Mono"};
268 static const struct soc_enum wm8750_enum[] = {
269 SOC_ENUM_SINGLE(WM8750_BASS, 7, 2, wm8750_bass),
270 SOC_ENUM_SINGLE(WM8750_BASS, 6, 2, wm8750_bass_filter),
271 SOC_ENUM_SINGLE(WM8750_TREBLE, 6, 2, wm8750_treble),
272 SOC_ENUM_SINGLE(WM8750_3D, 5, 2, wm8750_3d_lc),
273 SOC_ENUM_SINGLE(WM8750_3D, 6, 2, wm8750_3d_uc),
274 SOC_ENUM_SINGLE(WM8750_3D, 7, 2, wm8750_3d_func),
275 SOC_ENUM_SINGLE(WM8750_ALC1, 7, 4, wm8750_alc_func),
276 SOC_ENUM_SINGLE(WM8750_NGATE, 1, 2, wm8750_ng_type),
277 SOC_ENUM_SINGLE(WM8750_LOUTM1, 0, 5, wm8750_line_mux),
278 SOC_ENUM_SINGLE(WM8750_ROUTM1, 0, 5, wm8750_line_mux),
279 SOC_ENUM_SINGLE(WM8750_LADCIN, 6, 4, wm8750_pga_sel), /* 10 */
280 SOC_ENUM_SINGLE(WM8750_RADCIN, 6, 4, wm8750_pga_sel),
281 SOC_ENUM_SINGLE(WM8750_ADCTL2, 7, 4, wm8750_out3),
282 SOC_ENUM_SINGLE(WM8750_ADCIN, 8, 2, wm8750_diff_sel),
283 SOC_ENUM_SINGLE(WM8750_ADCDAC, 5, 4, wm8750_adcpol),
284 SOC_ENUM_SINGLE(WM8750_ADCDAC, 1, 4, wm8750_deemph),
285 SOC_ENUM_SINGLE(WM8750_ADCIN, 6, 4, wm8750_mono_mux), /* 16 */
289 static const struct snd_kcontrol_new wm8750_snd_controls[] = {
291 SOC_DOUBLE_R("Capture Volume", WM8750_LINVOL, WM8750_RINVOL, 0, 63, 0),
292 SOC_DOUBLE_R("Capture ZC Switch", WM8750_LINVOL, WM8750_RINVOL, 6, 1, 0),
293 SOC_DOUBLE_R("Capture Switch", WM8750_LINVOL, WM8750_RINVOL, 7, 1, 1),
295 SOC_DOUBLE_R("Out1 Playback ZC Switch", WM8750_LOUT1V,
296 WM8750_ROUT1V, 7, 1, 0),
297 SOC_DOUBLE_R("Out2 Playback ZC Switch", WM8750_LOUT2V,
298 WM8750_ROUT2V, 7, 1, 0),
300 SOC_ENUM("Playback De-emphasis", wm8750_enum[15]),
302 SOC_ENUM("Capture Polarity", wm8750_enum[14]),
303 SOC_SINGLE("Playback 6dB Attenuate", WM8750_ADCDAC, 7, 1, 0),
304 SOC_SINGLE("Capture 6dB Attenuate", WM8750_ADCDAC, 8, 1, 0),
306 SOC_DOUBLE_R("PCM Volume", WM8750_LDAC, WM8750_RDAC, 0, 255, 0),
308 SOC_ENUM("Bass Boost", wm8750_enum[0]),
309 SOC_ENUM("Bass Filter", wm8750_enum[1]),
310 SOC_SINGLE("Bass Volume", WM8750_BASS, 0, 15, 1),
312 SOC_SINGLE("Treble Volume", WM8750_TREBLE, 0, 15, 0),
313 SOC_ENUM("Treble Cut-off", wm8750_enum[2]),
315 SOC_SINGLE("3D Switch", WM8750_3D, 0, 1, 0),
316 SOC_SINGLE("3D Volume", WM8750_3D, 1, 15, 0),
317 SOC_ENUM("3D Lower Cut-off", wm8750_enum[3]),
318 SOC_ENUM("3D Upper Cut-off", wm8750_enum[4]),
319 SOC_ENUM("3D Mode", wm8750_enum[5]),
321 SOC_SINGLE("ALC Capture Target Volume", WM8750_ALC1, 0, 7, 0),
322 SOC_SINGLE("ALC Capture Max Volume", WM8750_ALC1, 4, 7, 0),
323 SOC_ENUM("ALC Capture Function", wm8750_enum[6]),
324 SOC_SINGLE("ALC Capture ZC Switch", WM8750_ALC2, 7, 1, 0),
325 SOC_SINGLE("ALC Capture Hold Time", WM8750_ALC2, 0, 15, 0),
326 SOC_SINGLE("ALC Capture Decay Time", WM8750_ALC3, 4, 15, 0),
327 SOC_SINGLE("ALC Capture Attack Time", WM8750_ALC3, 0, 15, 0),
328 SOC_SINGLE("ALC Capture NG Threshold", WM8750_NGATE, 3, 31, 0),
329 SOC_ENUM("ALC Capture NG Type", wm8750_enum[4]),
330 SOC_SINGLE("ALC Capture NG Switch", WM8750_NGATE, 0, 1, 0),
332 SOC_SINGLE("Left ADC Capture Volume", WM8750_LADC, 0, 255, 0),
333 SOC_SINGLE("Right ADC Capture Volume", WM8750_RADC, 0, 255, 0),
335 SOC_SINGLE("ZC Timeout Switch", WM8750_ADCTL1, 0, 1, 0),
336 SOC_SINGLE("Playback Invert Switch", WM8750_ADCTL1, 1, 1, 0),
338 SOC_SINGLE("Right Out2 Playback Invert Switch", WM8750_ADCTL2, 4, 1, 0),
341 /* ADCDAC Bit 0 - ADCHPD */
342 /* ADCDAC Bit 4 - HPOR */
343 /* ADCTL1 Bit 2,3 - DATSEL */
344 /* ADCTL1 Bit 4,5 - DMONOMIX */
345 /* ADCTL1 Bit 6,7 - VSEL */
346 /* ADCTL2 Bit 2 - LRCM */
347 /* ADCTL2 Bit 3 - TRI */
348 /* ADCTL3 Bit 5 - HPFLREN */
349 /* ADCTL3 Bit 6 - VROI */
350 /* ADCTL3 Bit 7,8 - ADCLRM */
351 /* ADCIN Bit 4 - LDCM */
352 /* ADCIN Bit 5 - RDCM */
354 SOC_DOUBLE_R("Mic Boost", WM8750_LADCIN, WM8750_RADCIN, 4, 3, 0),
356 SOC_DOUBLE_R("Bypass Left Playback Volume", WM8750_LOUTM1,
357 WM8750_LOUTM2, 4, 7, 1),
358 SOC_DOUBLE_R("Bypass Right Playback Volume", WM8750_ROUTM1,
359 WM8750_ROUTM2, 4, 7, 1),
360 SOC_DOUBLE_R("Bypass Mono Playback Volume", WM8750_MOUTM1,
361 WM8750_MOUTM2, 4, 7, 1),
363 SOC_SINGLE("Mono Playback ZC Switch", WM8750_MOUTV, 7, 1, 0),
365 SOC_DOUBLE_R("Out1 Playback Volume", WM8750_LOUT1V, WM8750_ROUT1V, 0, 127, 0),
366 SOC_DOUBLE_R("Out2 Playback Volume", WM8750_LOUT2V, WM8750_ROUT2V, 0, 127, 0),
368 SOC_SINGLE("Mono Playback Volume", WM8750_MOUTV, 0, 127, 0),
372 /* add non dapm controls */
373 static int wm8750_add_controls(struct snd_soc_codec *codec)
377 for (i = 0; i < ARRAY_SIZE(wm8750_snd_controls); i++) {
378 err = snd_ctl_add(codec->card,
379 snd_soc_cnew(&wm8750_snd_controls[i],codec, NULL));
391 static const struct snd_kcontrol_new wm8750_left_mixer_controls[] = {
392 SOC_DAPM_SINGLE("Playback Switch", WM8750_LOUTM1, 8, 1, 0),
393 SOC_DAPM_SINGLE("Left Bypass Switch", WM8750_LOUTM1, 7, 1, 0),
394 SOC_DAPM_SINGLE("Right Playback Switch", WM8750_LOUTM2, 8, 1, 0),
395 SOC_DAPM_SINGLE("Right Bypass Switch", WM8750_LOUTM2, 7, 1, 0),
399 static const struct snd_kcontrol_new wm8750_right_mixer_controls[] = {
400 SOC_DAPM_SINGLE("Left Playback Switch", WM8750_ROUTM1, 8, 1, 0),
401 SOC_DAPM_SINGLE("Left Bypass Switch", WM8750_ROUTM1, 7, 1, 0),
402 SOC_DAPM_SINGLE("Playback Switch", WM8750_ROUTM2, 8, 1, 0),
403 SOC_DAPM_SINGLE("Right Bypass Switch", WM8750_ROUTM2, 7, 1, 0),
407 static const struct snd_kcontrol_new wm8750_mono_mixer_controls[] = {
408 SOC_DAPM_SINGLE("Left Playback Switch", WM8750_MOUTM1, 8, 1, 0),
409 SOC_DAPM_SINGLE("Left Bypass Switch", WM8750_MOUTM1, 7, 1, 0),
410 SOC_DAPM_SINGLE("Right Playback Switch", WM8750_MOUTM2, 8, 1, 0),
411 SOC_DAPM_SINGLE("Right Bypass Switch", WM8750_MOUTM2, 7, 1, 0),
415 static const struct snd_kcontrol_new wm8750_left_line_controls =
416 SOC_DAPM_ENUM("Route", wm8750_enum[8]);
419 static const struct snd_kcontrol_new wm8750_right_line_controls =
420 SOC_DAPM_ENUM("Route", wm8750_enum[9]);
423 static const struct snd_kcontrol_new wm8750_left_pga_controls =
424 SOC_DAPM_ENUM("Route", wm8750_enum[10]);
427 static const struct snd_kcontrol_new wm8750_right_pga_controls =
428 SOC_DAPM_ENUM("Route", wm8750_enum[11]);
431 static const struct snd_kcontrol_new wm8750_out3_controls =
432 SOC_DAPM_ENUM("Route", wm8750_enum[12]);
434 /* Differential Mux */
435 static const struct snd_kcontrol_new wm8750_diffmux_controls =
436 SOC_DAPM_ENUM("Route", wm8750_enum[13]);
439 static const struct snd_kcontrol_new wm8750_monomux_controls =
440 SOC_DAPM_ENUM("Route", wm8750_enum[16]);
442 static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
443 SND_SOC_DAPM_MIXER("Left Mixer", SND_SOC_NOPM, 0, 0,
444 &wm8750_left_mixer_controls[0],
445 ARRAY_SIZE(wm8750_left_mixer_controls)),
446 SND_SOC_DAPM_MIXER("Right Mixer", SND_SOC_NOPM, 0, 0,
447 &wm8750_right_mixer_controls[0],
448 ARRAY_SIZE(wm8750_right_mixer_controls)),
449 SND_SOC_DAPM_MIXER("Mono Mixer", WM8750_PWR2, 2, 0,
450 &wm8750_mono_mixer_controls[0],
451 ARRAY_SIZE(wm8750_mono_mixer_controls)),
453 SND_SOC_DAPM_PGA("Right Out 2", WM8750_PWR2, 3, 0, NULL, 0),
454 SND_SOC_DAPM_PGA("Left Out 2", WM8750_PWR2, 4, 0, NULL, 0),
455 SND_SOC_DAPM_PGA("Right Out 1", WM8750_PWR2, 5, 0, NULL, 0),
456 SND_SOC_DAPM_PGA("Left Out 1", WM8750_PWR2, 6, 0, NULL, 0),
457 SND_SOC_DAPM_DAC("Right DAC", "Right Playback", WM8750_PWR2, 7, 0),
458 SND_SOC_DAPM_DAC("Left DAC", "Left Playback", WM8750_PWR2, 8, 0),
460 SND_SOC_DAPM_MICBIAS("Mic Bias", WM8750_PWR1, 1, 0),
461 SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8750_PWR1, 2, 0),
462 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8750_PWR1, 3, 0),
464 SND_SOC_DAPM_MUX("Left PGA Mux", WM8750_PWR1, 5, 0,
465 &wm8750_left_pga_controls),
466 SND_SOC_DAPM_MUX("Right PGA Mux", WM8750_PWR1, 4, 0,
467 &wm8750_right_pga_controls),
468 SND_SOC_DAPM_MUX("Left Line Mux", SND_SOC_NOPM, 0, 0,
469 &wm8750_left_line_controls),
470 SND_SOC_DAPM_MUX("Right Line Mux", SND_SOC_NOPM, 0, 0,
471 &wm8750_right_line_controls),
473 SND_SOC_DAPM_MUX("Out3 Mux", SND_SOC_NOPM, 0, 0, &wm8750_out3_controls),
474 SND_SOC_DAPM_PGA("Out 3", WM8750_PWR2, 1, 0, NULL, 0),
475 SND_SOC_DAPM_PGA("Mono Out 1", WM8750_PWR2, 2, 0, NULL, 0),
477 SND_SOC_DAPM_MUX("Differential Mux", SND_SOC_NOPM, 0, 0,
478 &wm8750_diffmux_controls),
479 SND_SOC_DAPM_MUX("Left ADC Mux", SND_SOC_NOPM, 0, 0,
480 &wm8750_monomux_controls),
481 SND_SOC_DAPM_MUX("Right ADC Mux", SND_SOC_NOPM, 0, 0,
482 &wm8750_monomux_controls),
484 SND_SOC_DAPM_OUTPUT("LOUT1"),
485 SND_SOC_DAPM_OUTPUT("ROUT1"),
486 SND_SOC_DAPM_OUTPUT("LOUT2"),
487 SND_SOC_DAPM_OUTPUT("ROUT2"),
488 SND_SOC_DAPM_OUTPUT("MONO"),
489 SND_SOC_DAPM_OUTPUT("OUT3"),
491 SND_SOC_DAPM_INPUT("LINPUT1"),
492 SND_SOC_DAPM_INPUT("LINPUT2"),
493 SND_SOC_DAPM_INPUT("LINPUT3"),
494 SND_SOC_DAPM_INPUT("RINPUT1"),
495 SND_SOC_DAPM_INPUT("RINPUT2"),
496 SND_SOC_DAPM_INPUT("RINPUT3"),
499 static const char *audio_map[][3] = {
501 {"Left Mixer", "Playback Switch", "Left DAC"},
502 {"Left Mixer", "Left Bypass Switch", "Left Line Mux"},
503 {"Left Mixer", "Right Playback Switch", "Right DAC"},
504 {"Left Mixer", "Right Bypass Switch", "Right Line Mux"},
507 {"Right Mixer", "Left Playback Switch", "Left DAC"},
508 {"Right Mixer", "Left Bypass Switch", "Left Line Mux"},
509 {"Right Mixer", "Playback Switch", "Right DAC"},
510 {"Right Mixer", "Right Bypass Switch", "Right Line Mux"},
513 {"Left Out 1", NULL, "Left Mixer"},
514 {"LOUT1", NULL, "Left Out 1"},
517 {"Left Out 2", NULL, "Left Mixer"},
518 {"LOUT2", NULL, "Left Out 2"},
521 {"Right Out 1", NULL, "Right Mixer"},
522 {"ROUT1", NULL, "Right Out 1"},
525 {"Right Out 2", NULL, "Right Mixer"},
526 {"ROUT2", NULL, "Right Out 2"},
529 {"Mono Mixer", "Left Playback Switch", "Left DAC"},
530 {"Mono Mixer", "Left Bypass Switch", "Left Line Mux"},
531 {"Mono Mixer", "Right Playback Switch", "Right DAC"},
532 {"Mono Mixer", "Right Bypass Switch", "Right Line Mux"},
535 {"Mono Out 1", NULL, "Mono Mixer"},
536 {"MONO1", NULL, "Mono Out 1"},
539 {"Out3 Mux", "VREF", "VREF"},
540 {"Out3 Mux", "ROUT1 + Vol", "ROUT1"},
541 {"Out3 Mux", "ROUT1", "Right Mixer"},
542 {"Out3 Mux", "MonoOut", "MONO1"},
543 {"Out 3", NULL, "Out3 Mux"},
544 {"OUT3", NULL, "Out 3"},
547 {"Left Line Mux", "Line 1", "LINPUT1"},
548 {"Left Line Mux", "Line 2", "LINPUT2"},
549 {"Left Line Mux", "Line 3", "LINPUT3"},
550 {"Left Line Mux", "PGA", "Left PGA Mux"},
551 {"Left Line Mux", "Differential", "Differential Mux"},
554 {"Right Line Mux", "Line 1", "RINPUT1"},
555 {"Right Line Mux", "Line 2", "RINPUT2"},
556 {"Right Line Mux", "Line 3", "RINPUT3"},
557 {"Right Line Mux", "PGA", "Right PGA Mux"},
558 {"Right Line Mux", "Differential", "Differential Mux"},
561 {"Left PGA Mux", "Line 1", "LINPUT1"},
562 {"Left PGA Mux", "Line 2", "LINPUT2"},
563 {"Left PGA Mux", "Line 3", "LINPUT3"},
564 {"Left PGA Mux", "Differential", "Differential Mux"},
567 {"Right PGA Mux", "Line 1", "RINPUT1"},
568 {"Right PGA Mux", "Line 2", "RINPUT2"},
569 {"Right PGA Mux", "Line 3", "RINPUT3"},
570 {"Right PGA Mux", "Differential", "Differential Mux"},
572 /* Differential Mux */
573 {"Differential Mux", "Line 1", "LINPUT1"},
574 {"Differential Mux", "Line 1", "RINPUT1"},
575 {"Differential Mux", "Line 2", "LINPUT2"},
576 {"Differential Mux", "Line 2", "RINPUT2"},
579 {"Left ADC Mux", "Stereo", "Left PGA Mux"},
580 {"Left ADC Mux", "Mono (Left)", "Left PGA Mux"},
581 {"Left ADC Mux", "Digital Mono", "Left PGA Mux"},
584 {"Right ADC Mux", "Stereo", "Right PGA Mux"},
585 {"Right ADC Mux", "Mono (Right)", "Right PGA Mux"},
586 {"Right ADC Mux", "Digital Mono", "Right PGA Mux"},
589 {"Left ADC", NULL, "Left ADC Mux"},
590 {"Right ADC", NULL, "Right ADC Mux"},
596 static int wm8750_add_widgets(struct snd_soc_codec *codec)
600 for(i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++) {
601 snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]);
604 /* set up audio path audio_mapnects */
605 for(i = 0; audio_map[i][0] != NULL; i++) {
606 snd_soc_dapm_connect_input(codec, audio_map[i][0],
607 audio_map[i][1], audio_map[i][2]);
610 snd_soc_dapm_new_widgets(codec);
622 /* codec hifi mclk clock divider coefficients */
623 static const struct _coeff_div coeff_div[] = {
625 {12288000, 8000, 1536, 0x6, 0x0},
626 {11289600, 8000, 1408, 0x16, 0x0},
627 {18432000, 8000, 2304, 0x7, 0x0},
628 {16934400, 8000, 2112, 0x17, 0x0},
629 {12000000, 8000, 1500, 0x6, 0x1},
632 {11289600, 11025, 1024, 0x18, 0x0},
633 {16934400, 11025, 1536, 0x19, 0x0},
634 {12000000, 11025, 1088, 0x19, 0x1},
637 {12288000, 16000, 768, 0xa, 0x0},
638 {18432000, 16000, 1152, 0xb, 0x0},
639 {12000000, 16000, 750, 0xa, 0x1},
642 {11289600, 22050, 512, 0x1a, 0x0},
643 {16934400, 22050, 768, 0x1b, 0x0},
644 {12000000, 22050, 544, 0x1b, 0x1},
647 {12288000, 32000, 384, 0xc, 0x0},
648 {18432000, 32000, 576, 0xd, 0x0},
649 {12000000, 32000, 375, 0xa, 0x1},
652 {11289600, 44100, 256, 0x10, 0x0},
653 {16934400, 44100, 384, 0x11, 0x0},
654 {12000000, 44100, 272, 0x11, 0x1},
657 {12288000, 48000, 256, 0x0, 0x0},
658 {18432000, 48000, 384, 0x1, 0x0},
659 {12000000, 48000, 250, 0x0, 0x1},
662 {11289600, 88200, 128, 0x1e, 0x0},
663 {16934400, 88200, 192, 0x1f, 0x0},
664 {12000000, 88200, 136, 0x1f, 0x1},
667 {12288000, 96000, 128, 0xe, 0x0},
668 {18432000, 96000, 192, 0xf, 0x0},
669 {12000000, 96000, 125, 0xe, 0x1},
672 static inline int get_coeff(int mclk, int rate)
676 for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
677 if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
683 /* WM8750 supports numerous input clocks per sample rate */
684 static unsigned int wm8750_config_sysclk(struct snd_soc_codec_dai *dai,
685 struct snd_soc_clock_info *info, unsigned int clk)
689 /* check that the calculated FS and rate actually match a clock from
690 * the machine driver */
691 if (info->fs * info->rate == clk)
697 static int wm8750_pcm_prepare(struct snd_pcm_substream *substream)
699 struct snd_soc_pcm_runtime *rtd = substream->private_data;
700 struct snd_soc_device *socdev = rtd->socdev;
701 struct snd_soc_codec *codec = socdev->codec;
702 u16 iface = 0, bfs, srate = 0;
703 int i = get_coeff(rtd->codec_dai->mclk,
704 snd_soc_get_rate(rtd->codec_dai->dai_runtime.pcmrate));
706 /* is coefficient valid ? */
710 bfs = SND_SOC_FSB_REAL(rtd->codec_dai->dai_runtime.bfs);
712 /* set master/slave audio interface */
713 switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_CLOCK_MASK) {
714 case SND_SOC_DAIFMT_CBM_CFM:
717 case SND_SOC_DAIFMT_CBS_CFS:
721 /* interface format */
722 switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
723 case SND_SOC_DAIFMT_I2S:
726 case SND_SOC_DAIFMT_RIGHT_J:
728 case SND_SOC_DAIFMT_LEFT_J:
731 case SND_SOC_DAIFMT_DSP_A:
734 case SND_SOC_DAIFMT_DSP_B:
740 switch (rtd->codec_dai->dai_runtime.pcmfmt) {
741 case SNDRV_PCM_FMTBIT_S16_LE:
743 case SNDRV_PCM_FMTBIT_S20_3LE:
746 case SNDRV_PCM_FMTBIT_S24_LE:
749 case SNDRV_PCM_FMTBIT_S32_LE:
754 /* clock inversion */
755 switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_INV_MASK) {
756 case SND_SOC_DAIFMT_NB_NF:
758 case SND_SOC_DAIFMT_IB_IF:
761 case SND_SOC_DAIFMT_IB_NF:
764 case SND_SOC_DAIFMT_NB_IF:
769 /* set bclk divisor rate */
784 /* set iface & srate */
785 wm8750_write(codec, WM8750_IFACE, iface);
786 wm8750_write(codec, WM8750_SRATE, srate |
787 (coeff_div[i].sr << 1) | coeff_div[i].usb);
792 static int wm8750_mute(struct snd_soc_codec *codec,
793 struct snd_soc_codec_dai *dai, int mute)
795 u16 mute_reg = wm8750_read_reg_cache(codec, WM8750_ADCDAC) & 0xfff7;
797 wm8750_write(codec, WM8750_ADCDAC, mute_reg | 0x8);
799 wm8750_write(codec, WM8750_ADCDAC, mute_reg);
803 static int wm8750_dapm_event(struct snd_soc_codec *codec, int event)
805 u16 pwr_reg = wm8750_read_reg_cache(codec, WM8750_PWR1) & 0xfe3e;
808 case SNDRV_CTL_POWER_D0: /* full On */
809 /* set vmid to 50k and unmute dac */
810 wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x00c0);
812 case SNDRV_CTL_POWER_D1: /* partial On */
813 case SNDRV_CTL_POWER_D2: /* partial On */
814 /* set vmid to 5k for quick power up */
815 wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x01c1);
817 case SNDRV_CTL_POWER_D3hot: /* Off, with power */
818 /* mute dac and set vmid to 500k, enable VREF */
819 wm8750_write(codec, WM8750_PWR1, pwr_reg | 0x0141);
821 case SNDRV_CTL_POWER_D3cold: /* Off, without power */
822 wm8750_write(codec, WM8750_PWR1, 0x0001);
825 codec->dapm_state = event;
829 struct snd_soc_codec_dai wm8750_dai = {
832 .stream_name = "Playback",
837 .stream_name = "Capture",
841 .config_sysclk = wm8750_config_sysclk,
842 .digital_mute = wm8750_mute,
844 .prepare = wm8750_pcm_prepare,
847 .num_modes = ARRAY_SIZE(wm8750_modes),
848 .mode = wm8750_modes,
851 EXPORT_SYMBOL_GPL(wm8750_dai);
853 static void wm8750_work(void *data)
855 struct snd_soc_codec *codec = (struct snd_soc_codec *)data;
856 wm8750_dapm_event(codec, codec->dapm_state);
859 static int wm8750_suspend(struct platform_device *pdev, pm_message_t state)
861 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
862 struct snd_soc_codec *codec = socdev->codec;
864 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
868 static int wm8750_resume(struct platform_device *pdev)
870 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
871 struct snd_soc_codec *codec = socdev->codec;
874 u16 *cache = codec->reg_cache;
876 /* Sync reg_cache with the hardware */
877 for (i = 0; i < ARRAY_SIZE(wm8750_reg); i++) {
878 if (i == WM8750_RESET)
880 data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001);
881 data[1] = cache[i] & 0x00ff;
882 codec->hw_write(codec->control_data, data, 2);
885 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
887 /* charge wm8750 caps */
888 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) {
889 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2);
890 codec->dapm_state = SNDRV_CTL_POWER_D0;
891 queue_delayed_work(wm8750_workq, &wm8750_dapm_work,
892 msecs_to_jiffies(1000));
899 * initialise the WM8750 driver
900 * register the mixer and dsp interfaces with the kernel
902 static int wm8750_init(struct snd_soc_device *socdev)
904 struct snd_soc_codec *codec = socdev->codec;
907 codec->name = "WM8750";
908 codec->owner = THIS_MODULE;
909 codec->read = wm8750_read_reg_cache;
910 codec->write = wm8750_write;
911 codec->dapm_event = wm8750_dapm_event;
912 codec->dai = &wm8750_dai;
914 codec->reg_cache_size = ARRAY_SIZE(wm8750_reg);
917 kzalloc(sizeof(u16) * ARRAY_SIZE(wm8750_reg), GFP_KERNEL);
918 if (codec->reg_cache == NULL)
920 memcpy(codec->reg_cache, wm8750_reg,
921 sizeof(u16) * ARRAY_SIZE(wm8750_reg));
922 codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(wm8750_reg);
927 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
929 kfree(codec->reg_cache);
933 /* charge output caps */
934 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2);
935 codec->dapm_state = SNDRV_CTL_POWER_D3hot;
936 queue_delayed_work(wm8750_workq, &wm8750_dapm_work,
937 msecs_to_jiffies(1000));
939 /* set the update bits */
940 reg = wm8750_read_reg_cache(codec, WM8750_LDAC);
941 wm8750_write(codec, WM8750_LDAC, reg | 0x0100);
942 reg = wm8750_read_reg_cache(codec, WM8750_RDAC);
943 wm8750_write(codec, WM8750_RDAC, reg | 0x0100);
944 reg = wm8750_read_reg_cache(codec, WM8750_LOUT1V);
945 wm8750_write(codec, WM8750_LOUT1V, reg | 0x0100);
946 reg = wm8750_read_reg_cache(codec, WM8750_ROUT1V);
947 wm8750_write(codec, WM8750_ROUT1V, reg | 0x0100);
948 reg = wm8750_read_reg_cache(codec, WM8750_LOUT2V);
949 wm8750_write(codec, WM8750_LOUT2V, reg | 0x0100);
950 reg = wm8750_read_reg_cache(codec, WM8750_ROUT2V);
951 wm8750_write(codec, WM8750_ROUT2V, reg | 0x0100);
952 reg = wm8750_read_reg_cache(codec, WM8750_LINVOL);
953 wm8750_write(codec, WM8750_LINVOL, reg | 0x0100);
954 reg = wm8750_read_reg_cache(codec, WM8750_RINVOL);
955 wm8750_write(codec, WM8750_RINVOL, reg | 0x0100);
957 wm8750_add_controls(codec);
958 wm8750_add_widgets(codec);
959 ret = snd_soc_register_card(socdev);
961 snd_soc_free_pcms(socdev);
962 snd_soc_dapm_free(socdev);
968 /* If the i2c layer weren't so broken, we could pass this kind of data
970 static struct snd_soc_device *wm8750_socdev;
972 #if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
975 * WM8731 2 wire address is determined by GPIO5
976 * state during powerup.
980 static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END };
982 /* Magic definition of all other variables and things */
985 static struct i2c_driver wm8750_i2c_driver;
986 static struct i2c_client client_template;
988 static int wm8750_codec_probe(struct i2c_adapter *adap, int addr, int kind)
990 struct snd_soc_device *socdev = wm8750_socdev;
991 struct wm8750_setup_data *setup = socdev->codec_data;
992 struct snd_soc_codec *codec = socdev->codec;
993 struct i2c_client *i2c;
996 if (addr != setup->i2c_address)
999 client_template.adapter = adap;
1000 client_template.addr = addr;
1002 i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
1007 memcpy(i2c, &client_template, sizeof(struct i2c_client));
1008 i2c_set_clientdata(i2c, codec);
1009 codec->control_data = i2c;
1011 ret = i2c_attach_client(i2c);
1013 err("failed to attach codec at addr %x\n", addr);
1017 ret = wm8750_init(socdev);
1019 err("failed to initialise WM8750\n");
1030 static int wm8750_i2c_detach(struct i2c_client *client)
1032 struct snd_soc_codec *codec = i2c_get_clientdata(client);
1033 i2c_detach_client(client);
1034 kfree(codec->reg_cache);
1039 static int wm8750_i2c_attach(struct i2c_adapter *adap)
1041 return i2c_probe(adap, &addr_data, wm8750_codec_probe);
1044 /* corgi i2c codec control layer */
1045 static struct i2c_driver wm8750_i2c_driver = {
1047 .name = "WM8750 I2C Codec",
1048 .owner = THIS_MODULE,
1050 .id = I2C_DRIVERID_WM8750,
1051 .attach_adapter = wm8750_i2c_attach,
1052 .detach_client = wm8750_i2c_detach,
1056 static struct i2c_client client_template = {
1058 .driver = &wm8750_i2c_driver,
1062 static int wm8750_probe(struct platform_device *pdev)
1064 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1065 struct wm8750_setup_data *setup = socdev->codec_data;
1066 struct snd_soc_codec *codec;
1069 info("WM8750 Audio Codec %s", WM8750_VERSION);
1070 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
1074 socdev->codec = codec;
1075 mutex_init(&codec->mutex);
1076 INIT_LIST_HEAD(&codec->dapm_widgets);
1077 INIT_LIST_HEAD(&codec->dapm_paths);
1078 wm8750_socdev = socdev;
1079 INIT_WORK(&wm8750_dapm_work, wm8750_work, codec);
1080 wm8750_workq = create_workqueue("wm8750");
1081 if (wm8750_workq == NULL) {
1085 #if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
1086 if (setup->i2c_address) {
1087 normal_i2c[0] = setup->i2c_address;
1088 codec->hw_write = (hw_write_t)i2c_master_send;
1089 ret = i2c_add_driver(&wm8750_i2c_driver);
1091 printk(KERN_ERR "can't add i2c driver");
1094 /* Add other interfaces here */
1100 /* power down chip */
1101 static int wm8750_remove(struct platform_device *pdev)
1103 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1104 struct snd_soc_codec *codec = socdev->codec;
1106 if (codec->control_data)
1107 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
1109 destroy_workqueue(wm8750_workq);
1110 snd_soc_free_pcms(socdev);
1111 snd_soc_dapm_free(socdev);
1112 #if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
1113 i2c_del_driver(&wm8750_i2c_driver);
1120 struct snd_soc_codec_device soc_codec_dev_wm8750 = {
1121 .probe = wm8750_probe,
1122 .remove = wm8750_remove,
1123 .suspend = wm8750_suspend,
1124 .resume = wm8750_resume,
1127 EXPORT_SYMBOL_GPL(soc_codec_dev_wm8750);
1129 MODULE_DESCRIPTION("ASoC WM8750 driver");
1130 MODULE_AUTHOR("Liam Girdwood");
1131 MODULE_LICENSE("GPL");