blob: 66d18a3e57f6f6b7dc07f6e469314131fffb2af1 [file] [log] [blame]
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001/*
2 * wm8753.c -- WM8753 ALSA Soc Audio driver
3 *
4 * Copyright 2003 Wolfson Microelectronics PLC.
Liam Girdwoodd3311242008-10-12 13:17:36 +01005 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
Liam Girdwood1f53aee2007-04-16 19:17:44 +02006 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * Notes:
13 * The WM8753 is a low power, high quality stereo codec with integrated PCM
14 * codec designed for portable digital telephony applications.
15 *
16 * Dual DAI:-
17 *
18 * This driver support 2 DAI PCM's. This makes the default PCM available for
19 * HiFi audio (e.g. MP3, ogg) playback/capture and the other PCM available for
20 * voice.
21 *
22 * Please note that the voice PCM can be connected directly to a Bluetooth
23 * codec or GSM modem and thus cannot be read or written to, although it is
24 * available to be configured with snd_hw_params(), etc and kcontrols in the
25 * normal alsa manner.
26 *
27 * Fast DAI switching:-
28 *
29 * The driver can now fast switch between the DAI configurations via a
30 * an alsa kcontrol. This allows the PCM to remain open.
31 *
32 */
33
34#include <linux/module.h>
35#include <linux/moduleparam.h>
Liam Girdwood1f53aee2007-04-16 19:17:44 +020036#include <linux/kernel.h>
37#include <linux/init.h>
38#include <linux/delay.h>
39#include <linux/pm.h>
40#include <linux/i2c.h>
41#include <linux/platform_device.h>
Mark Browndd0c0c82008-10-06 16:54:34 +010042#include <linux/spi/spi.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090043#include <linux/slab.h>
Liam Girdwood1f53aee2007-04-16 19:17:44 +020044#include <sound/core.h>
45#include <sound/pcm.h>
46#include <sound/pcm_params.h>
47#include <sound/soc.h>
Liam Girdwood1f53aee2007-04-16 19:17:44 +020048#include <sound/initval.h>
Liam Girdwood2d6a4ac2008-01-10 14:43:48 +010049#include <sound/tlv.h>
Liam Girdwood1f53aee2007-04-16 19:17:44 +020050#include <asm/div64.h>
51
52#include "wm8753.h"
53
Liam Girdwood1f53aee2007-04-16 19:17:44 +020054static int caps_charge = 2000;
55module_param(caps_charge, int, 0);
56MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)");
57
Lars-Peter Clausen338ee252011-02-06 10:04:11 +010058static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec,
59 unsigned int fmt);
60static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec,
61 unsigned int fmt);
Liam Girdwood1f53aee2007-04-16 19:17:44 +020062
Liam Girdwood1f53aee2007-04-16 19:17:44 +020063/*
64 * wm8753 register cache
65 * We can't read the WM8753 register space when we
66 * are using 2 wire for device control, so we cache them instead.
67 */
68static const u16 wm8753_reg[] = {
Lars-Peter Clausen776065e2010-12-28 21:38:03 +010069 0x0000, 0x0008, 0x0000, 0x000a,
70 0x000a, 0x0033, 0x0000, 0x0007,
71 0x00ff, 0x00ff, 0x000f, 0x000f,
72 0x007b, 0x0000, 0x0032, 0x0000,
73 0x00c3, 0x00c3, 0x00c0, 0x0000,
Liam Girdwood1f53aee2007-04-16 19:17:44 +020074 0x0000, 0x0000, 0x0000, 0x0000,
75 0x0000, 0x0000, 0x0000, 0x0000,
Lars-Peter Clausen776065e2010-12-28 21:38:03 +010076 0x0000, 0x0000, 0x0000, 0x0000,
77 0x0055, 0x0005, 0x0050, 0x0055,
78 0x0050, 0x0055, 0x0050, 0x0055,
Liam Girdwood1f53aee2007-04-16 19:17:44 +020079 0x0079, 0x0079, 0x0079, 0x0079,
Lars-Peter Clausen776065e2010-12-28 21:38:03 +010080 0x0079, 0x0000, 0x0000, 0x0000,
81 0x0000, 0x0097, 0x0097, 0x0000,
82 0x0004, 0x0000, 0x0083, 0x0024,
83 0x01ba, 0x0000, 0x0083, 0x0024,
84 0x01ba, 0x0000, 0x0000, 0x0000
Liam Girdwood1f53aee2007-04-16 19:17:44 +020085};
86
Mark Brownc2bac162009-02-24 23:33:12 +000087/* codec private data */
88struct wm8753_priv {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000089 enum snd_soc_control_type control_type;
Mark Brownc2bac162009-02-24 23:33:12 +000090 unsigned int sysclk;
91 unsigned int pcmclk;
Lars-Peter Clausen338ee252011-02-06 10:04:11 +010092
93 unsigned int voice_fmt;
94 unsigned int hifi_fmt;
95
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000096 int dai_func;
Mark Brownc2bac162009-02-24 23:33:12 +000097};
98
Lars-Peter Clausen776065e2010-12-28 21:38:03 +010099#define wm8753_reset(c) snd_soc_write(c, WM8753_RESET, 0)
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200100
101/*
102 * WM8753 Controls
103 */
104static const char *wm8753_base[] = {"Linear Control", "Adaptive Boost"};
105static const char *wm8753_base_filter[] =
106 {"130Hz @ 48kHz", "200Hz @ 48kHz", "100Hz @ 16kHz", "400Hz @ 48kHz",
107 "100Hz @ 8kHz", "200Hz @ 8kHz"};
108static const char *wm8753_treble[] = {"8kHz", "4kHz"};
109static const char *wm8753_alc_func[] = {"Off", "Right", "Left", "Stereo"};
110static const char *wm8753_ng_type[] = {"Constant PGA Gain", "Mute ADC Output"};
111static const char *wm8753_3d_func[] = {"Capture", "Playback"};
112static const char *wm8753_3d_uc[] = {"2.2kHz", "1.5kHz"};
113static const char *wm8753_3d_lc[] = {"200Hz", "500Hz"};
114static const char *wm8753_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz"};
115static const char *wm8753_mono_mix[] = {"Stereo", "Left", "Right", "Mono"};
116static const char *wm8753_dac_phase[] = {"Non Inverted", "Inverted"};
117static const char *wm8753_line_mix[] = {"Line 1 + 2", "Line 1 - 2",
118 "Line 1", "Line 2"};
119static const char *wm8753_mono_mux[] = {"Line Mix", "Rx Mix"};
120static const char *wm8753_right_mux[] = {"Line 2", "Rx Mix"};
121static const char *wm8753_left_mux[] = {"Line 1", "Rx Mix"};
122static const char *wm8753_rxmsel[] = {"RXP - RXN", "RXP + RXN", "RXP", "RXN"};
123static const char *wm8753_sidetone_mux[] = {"Left PGA", "Mic 1", "Mic 2",
124 "Right PGA"};
125static const char *wm8753_mono2_src[] = {"Inverted Mono 1", "Left", "Right",
126 "Left + Right"};
127static const char *wm8753_out3[] = {"VREF", "ROUT2", "Left + Right"};
128static const char *wm8753_out4[] = {"VREF", "Capture ST", "LOUT2"};
129static const char *wm8753_radcsel[] = {"PGA", "Line or RXP-RXN", "Sidetone"};
130static const char *wm8753_ladcsel[] = {"PGA", "Line or RXP-RXN", "Line"};
131static const char *wm8753_mono_adc[] = {"Stereo", "Analogue Mix Left",
132 "Analogue Mix Right", "Digital Mono Mix"};
133static const char *wm8753_adc_hp[] = {"3.4Hz @ 48kHz", "82Hz @ 16k",
134 "82Hz @ 8kHz", "170Hz @ 8kHz"};
135static const char *wm8753_adc_filter[] = {"HiFi", "Voice"};
136static const char *wm8753_mic_sel[] = {"Mic 1", "Mic 2", "Mic 3"};
137static const char *wm8753_dai_mode[] = {"DAI 0", "DAI 1", "DAI 2", "DAI 3"};
138static const char *wm8753_dat_sel[] = {"Stereo", "Left ADC", "Right ADC",
139 "Channel Swap"};
Graeme Gregoryae092c92008-03-03 17:19:45 +0100140static const char *wm8753_rout2_phase[] = {"Non Inverted", "Inverted"};
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200141
142static const struct soc_enum wm8753_enum[] = {
143SOC_ENUM_SINGLE(WM8753_BASS, 7, 2, wm8753_base),
144SOC_ENUM_SINGLE(WM8753_BASS, 4, 6, wm8753_base_filter),
145SOC_ENUM_SINGLE(WM8753_TREBLE, 6, 2, wm8753_treble),
146SOC_ENUM_SINGLE(WM8753_ALC1, 7, 4, wm8753_alc_func),
147SOC_ENUM_SINGLE(WM8753_NGATE, 1, 2, wm8753_ng_type),
148SOC_ENUM_SINGLE(WM8753_3D, 7, 2, wm8753_3d_func),
149SOC_ENUM_SINGLE(WM8753_3D, 6, 2, wm8753_3d_uc),
150SOC_ENUM_SINGLE(WM8753_3D, 5, 2, wm8753_3d_lc),
151SOC_ENUM_SINGLE(WM8753_DAC, 1, 4, wm8753_deemp),
152SOC_ENUM_SINGLE(WM8753_DAC, 4, 4, wm8753_mono_mix),
153SOC_ENUM_SINGLE(WM8753_DAC, 6, 2, wm8753_dac_phase),
154SOC_ENUM_SINGLE(WM8753_INCTL1, 3, 4, wm8753_line_mix),
155SOC_ENUM_SINGLE(WM8753_INCTL1, 2, 2, wm8753_mono_mux),
156SOC_ENUM_SINGLE(WM8753_INCTL1, 1, 2, wm8753_right_mux),
157SOC_ENUM_SINGLE(WM8753_INCTL1, 0, 2, wm8753_left_mux),
158SOC_ENUM_SINGLE(WM8753_INCTL2, 6, 4, wm8753_rxmsel),
159SOC_ENUM_SINGLE(WM8753_INCTL2, 4, 4, wm8753_sidetone_mux),
160SOC_ENUM_SINGLE(WM8753_OUTCTL, 7, 4, wm8753_mono2_src),
161SOC_ENUM_SINGLE(WM8753_OUTCTL, 0, 3, wm8753_out3),
162SOC_ENUM_SINGLE(WM8753_ADCTL2, 7, 3, wm8753_out4),
163SOC_ENUM_SINGLE(WM8753_ADCIN, 2, 3, wm8753_radcsel),
164SOC_ENUM_SINGLE(WM8753_ADCIN, 0, 3, wm8753_ladcsel),
165SOC_ENUM_SINGLE(WM8753_ADCIN, 4, 4, wm8753_mono_adc),
166SOC_ENUM_SINGLE(WM8753_ADC, 2, 4, wm8753_adc_hp),
167SOC_ENUM_SINGLE(WM8753_ADC, 4, 2, wm8753_adc_filter),
168SOC_ENUM_SINGLE(WM8753_MICBIAS, 6, 3, wm8753_mic_sel),
169SOC_ENUM_SINGLE(WM8753_IOCTL, 2, 4, wm8753_dai_mode),
170SOC_ENUM_SINGLE(WM8753_ADC, 7, 4, wm8753_dat_sel),
Graeme Gregoryae092c92008-03-03 17:19:45 +0100171SOC_ENUM_SINGLE(WM8753_OUTCTL, 2, 2, wm8753_rout2_phase),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200172};
173
174
175static int wm8753_get_dai(struct snd_kcontrol *kcontrol,
176 struct snd_ctl_elem_value *ucontrol)
177{
178 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Lars-Peter Clausen338ee252011-02-06 10:04:11 +0100179 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200180
Lars-Peter Clausen338ee252011-02-06 10:04:11 +0100181 ucontrol->value.integer.value[0] = wm8753->dai_func;
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200182 return 0;
183}
184
185static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
186 struct snd_ctl_elem_value *ucontrol)
187{
188 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000189 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
Lars-Peter Clausen338ee252011-02-06 10:04:11 +0100190 u16 ioctl;
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200191
Timo Juhani Lindforse8799742011-11-17 02:52:50 +0200192 if (wm8753->dai_func == ucontrol->value.integer.value[0])
193 return 0;
194
Lars-Peter Clausen338ee252011-02-06 10:04:11 +0100195 if (codec->active)
196 return -EBUSY;
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200197
Lars-Peter Clausen338ee252011-02-06 10:04:11 +0100198 ioctl = snd_soc_read(codec, WM8753_IOCTL);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200199
Lars-Peter Clausen338ee252011-02-06 10:04:11 +0100200 wm8753->dai_func = ucontrol->value.integer.value[0];
201
202 if (((ioctl >> 2) & 0x3) == wm8753->dai_func)
203 return 1;
204
205 ioctl = (ioctl & 0x1f3) | (wm8753->dai_func << 2);
206 snd_soc_write(codec, WM8753_IOCTL, ioctl);
207
208
209 wm8753_hifi_write_dai_fmt(codec, wm8753->hifi_fmt);
210 wm8753_voice_write_dai_fmt(codec, wm8753->voice_fmt);
211
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200212 return 1;
213}
214
Mike Montour2cc8c602008-06-11 13:47:12 +0100215static const DECLARE_TLV_DB_SCALE(rec_mix_tlv, -1500, 300, 0);
216static const DECLARE_TLV_DB_SCALE(mic_preamp_tlv, 1200, 600, 0);
217static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1);
218static const DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 1);
219static const unsigned int out_tlv[] = {
220 TLV_DB_RANGE_HEAD(2),
221 /* 0000000 - 0101111 = "Analogue mute" */
222 0, 48, TLV_DB_SCALE_ITEM(-25500, 0, 0),
223 48, 127, TLV_DB_SCALE_ITEM(-7300, 100, 0),
224};
225static const DECLARE_TLV_DB_SCALE(mix_tlv, -1500, 300, 0);
226static const DECLARE_TLV_DB_SCALE(voice_mix_tlv, -1200, 300, 0);
227static const DECLARE_TLV_DB_SCALE(pga_tlv, -1725, 75, 0);
Liam Girdwood2d6a4ac2008-01-10 14:43:48 +0100228
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200229static const struct snd_kcontrol_new wm8753_snd_controls[] = {
Mike Montour2cc8c602008-06-11 13:47:12 +0100230SOC_DOUBLE_R_TLV("PCM Volume", WM8753_LDAC, WM8753_RDAC, 0, 255, 0, dac_tlv),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200231
Mike Montour2cc8c602008-06-11 13:47:12 +0100232SOC_DOUBLE_R_TLV("ADC Capture Volume", WM8753_LADC, WM8753_RADC, 0, 255, 0,
233 adc_tlv),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200234
Mike Montour2cc8c602008-06-11 13:47:12 +0100235SOC_DOUBLE_R_TLV("Headphone Playback Volume", WM8753_LOUT1V, WM8753_ROUT1V,
236 0, 127, 0, out_tlv),
237SOC_DOUBLE_R_TLV("Speaker Playback Volume", WM8753_LOUT2V, WM8753_ROUT2V, 0,
238 127, 0, out_tlv),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200239
Mike Montour2cc8c602008-06-11 13:47:12 +0100240SOC_SINGLE_TLV("Mono Playback Volume", WM8753_MOUTV, 0, 127, 0, out_tlv),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200241
Mike Montour2cc8c602008-06-11 13:47:12 +0100242SOC_DOUBLE_R_TLV("Bypass Playback Volume", WM8753_LOUTM1, WM8753_ROUTM1, 4, 7,
243 1, mix_tlv),
244SOC_DOUBLE_R_TLV("Sidetone Playback Volume", WM8753_LOUTM2, WM8753_ROUTM2, 4,
245 7, 1, mix_tlv),
246SOC_DOUBLE_R_TLV("Voice Playback Volume", WM8753_LOUTM2, WM8753_ROUTM2, 0, 7,
247 1, voice_mix_tlv),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200248
Mike Montour2cc8c602008-06-11 13:47:12 +0100249SOC_DOUBLE_R("Headphone Playback ZC Switch", WM8753_LOUT1V, WM8753_ROUT1V, 7,
250 1, 0),
251SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8753_LOUT2V, WM8753_ROUT2V, 7,
252 1, 0),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200253
Mike Montour2cc8c602008-06-11 13:47:12 +0100254SOC_SINGLE_TLV("Mono Bypass Playback Volume", WM8753_MOUTM1, 4, 7, 1, mix_tlv),
255SOC_SINGLE_TLV("Mono Sidetone Playback Volume", WM8753_MOUTM2, 4, 7, 1,
256 mix_tlv),
257SOC_SINGLE_TLV("Mono Voice Playback Volume", WM8753_MOUTM2, 0, 7, 1,
258 voice_mix_tlv),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200259SOC_SINGLE("Mono Playback ZC Switch", WM8753_MOUTV, 7, 1, 0),
260
261SOC_ENUM("Bass Boost", wm8753_enum[0]),
262SOC_ENUM("Bass Filter", wm8753_enum[1]),
263SOC_SINGLE("Bass Volume", WM8753_BASS, 0, 15, 1),
264
265SOC_SINGLE("Treble Volume", WM8753_TREBLE, 0, 15, 1),
266SOC_ENUM("Treble Cut-off", wm8753_enum[2]),
267
Mike Montour2cc8c602008-06-11 13:47:12 +0100268SOC_DOUBLE_TLV("Sidetone Capture Volume", WM8753_RECMIX1, 0, 4, 7, 1,
269 rec_mix_tlv),
270SOC_SINGLE_TLV("Voice Sidetone Capture Volume", WM8753_RECMIX2, 0, 7, 1,
271 rec_mix_tlv),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200272
Mike Montour2cc8c602008-06-11 13:47:12 +0100273SOC_DOUBLE_R_TLV("Capture Volume", WM8753_LINVOL, WM8753_RINVOL, 0, 63, 0,
274 pga_tlv),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200275SOC_DOUBLE_R("Capture ZC Switch", WM8753_LINVOL, WM8753_RINVOL, 6, 1, 0),
276SOC_DOUBLE_R("Capture Switch", WM8753_LINVOL, WM8753_RINVOL, 7, 1, 1),
277
278SOC_ENUM("Capture Filter Select", wm8753_enum[23]),
279SOC_ENUM("Capture Filter Cut-off", wm8753_enum[24]),
280SOC_SINGLE("Capture Filter Switch", WM8753_ADC, 0, 1, 1),
281
282SOC_SINGLE("ALC Capture Target Volume", WM8753_ALC1, 0, 7, 0),
283SOC_SINGLE("ALC Capture Max Volume", WM8753_ALC1, 4, 7, 0),
284SOC_ENUM("ALC Capture Function", wm8753_enum[3]),
285SOC_SINGLE("ALC Capture ZC Switch", WM8753_ALC2, 8, 1, 0),
286SOC_SINGLE("ALC Capture Hold Time", WM8753_ALC2, 0, 15, 1),
287SOC_SINGLE("ALC Capture Decay Time", WM8753_ALC3, 4, 15, 1),
288SOC_SINGLE("ALC Capture Attack Time", WM8753_ALC3, 0, 15, 0),
289SOC_SINGLE("ALC Capture NG Threshold", WM8753_NGATE, 3, 31, 0),
290SOC_ENUM("ALC Capture NG Type", wm8753_enum[4]),
291SOC_SINGLE("ALC Capture NG Switch", WM8753_NGATE, 0, 1, 0),
292
293SOC_ENUM("3D Function", wm8753_enum[5]),
294SOC_ENUM("3D Upper Cut-off", wm8753_enum[6]),
295SOC_ENUM("3D Lower Cut-off", wm8753_enum[7]),
296SOC_SINGLE("3D Volume", WM8753_3D, 1, 15, 0),
297SOC_SINGLE("3D Switch", WM8753_3D, 0, 1, 0),
298
299SOC_SINGLE("Capture 6dB Attenuate", WM8753_ADCTL1, 2, 1, 0),
300SOC_SINGLE("Playback 6dB Attenuate", WM8753_ADCTL1, 1, 1, 0),
301
302SOC_ENUM("De-emphasis", wm8753_enum[8]),
303SOC_ENUM("Playback Mono Mix", wm8753_enum[9]),
304SOC_ENUM("Playback Phase", wm8753_enum[10]),
305
Mike Montour2cc8c602008-06-11 13:47:12 +0100306SOC_SINGLE_TLV("Mic2 Capture Volume", WM8753_INCTL1, 7, 3, 0, mic_preamp_tlv),
307SOC_SINGLE_TLV("Mic1 Capture Volume", WM8753_INCTL1, 5, 3, 0, mic_preamp_tlv),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200308
309SOC_ENUM_EXT("DAI Mode", wm8753_enum[26], wm8753_get_dai, wm8753_set_dai),
310
311SOC_ENUM("ADC Data Select", wm8753_enum[27]),
Graeme Gregoryae092c92008-03-03 17:19:45 +0100312SOC_ENUM("ROUT2 Phase", wm8753_enum[28]),
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200313};
314
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200315/*
316 * _DAPM_ Controls
317 */
318
319/* Left Mixer */
320static const struct snd_kcontrol_new wm8753_left_mixer_controls[] = {
321SOC_DAPM_SINGLE("Voice Playback Switch", WM8753_LOUTM2, 8, 1, 0),
322SOC_DAPM_SINGLE("Sidetone Playback Switch", WM8753_LOUTM2, 7, 1, 0),
323SOC_DAPM_SINGLE("Left Playback Switch", WM8753_LOUTM1, 8, 1, 0),
324SOC_DAPM_SINGLE("Bypass Playback Switch", WM8753_LOUTM1, 7, 1, 0),
325};
326
327/* Right mixer */
328static const struct snd_kcontrol_new wm8753_right_mixer_controls[] = {
329SOC_DAPM_SINGLE("Voice Playback Switch", WM8753_ROUTM2, 8, 1, 0),
330SOC_DAPM_SINGLE("Sidetone Playback Switch", WM8753_ROUTM2, 7, 1, 0),
331SOC_DAPM_SINGLE("Right Playback Switch", WM8753_ROUTM1, 8, 1, 0),
332SOC_DAPM_SINGLE("Bypass Playback Switch", WM8753_ROUTM1, 7, 1, 0),
333};
334
335/* Mono mixer */
336static const struct snd_kcontrol_new wm8753_mono_mixer_controls[] = {
337SOC_DAPM_SINGLE("Left Playback Switch", WM8753_MOUTM1, 8, 1, 0),
338SOC_DAPM_SINGLE("Right Playback Switch", WM8753_MOUTM2, 8, 1, 0),
339SOC_DAPM_SINGLE("Voice Playback Switch", WM8753_MOUTM2, 3, 1, 0),
340SOC_DAPM_SINGLE("Sidetone Playback Switch", WM8753_MOUTM2, 7, 1, 0),
341SOC_DAPM_SINGLE("Bypass Playback Switch", WM8753_MOUTM1, 7, 1, 0),
342};
343
344/* Mono 2 Mux */
345static const struct snd_kcontrol_new wm8753_mono2_controls =
346SOC_DAPM_ENUM("Route", wm8753_enum[17]);
347
348/* Out 3 Mux */
349static const struct snd_kcontrol_new wm8753_out3_controls =
350SOC_DAPM_ENUM("Route", wm8753_enum[18]);
351
352/* Out 4 Mux */
353static const struct snd_kcontrol_new wm8753_out4_controls =
354SOC_DAPM_ENUM("Route", wm8753_enum[19]);
355
356/* ADC Mono Mix */
357static const struct snd_kcontrol_new wm8753_adc_mono_controls =
358SOC_DAPM_ENUM("Route", wm8753_enum[22]);
359
360/* Record mixer */
361static const struct snd_kcontrol_new wm8753_record_mixer_controls[] = {
362SOC_DAPM_SINGLE("Voice Capture Switch", WM8753_RECMIX2, 3, 1, 0),
363SOC_DAPM_SINGLE("Left Capture Switch", WM8753_RECMIX1, 3, 1, 0),
364SOC_DAPM_SINGLE("Right Capture Switch", WM8753_RECMIX1, 7, 1, 0),
365};
366
367/* Left ADC mux */
368static const struct snd_kcontrol_new wm8753_adc_left_controls =
369SOC_DAPM_ENUM("Route", wm8753_enum[21]);
370
371/* Right ADC mux */
372static const struct snd_kcontrol_new wm8753_adc_right_controls =
373SOC_DAPM_ENUM("Route", wm8753_enum[20]);
374
375/* MIC mux */
376static const struct snd_kcontrol_new wm8753_mic_mux_controls =
377SOC_DAPM_ENUM("Route", wm8753_enum[16]);
378
379/* ALC mixer */
380static const struct snd_kcontrol_new wm8753_alc_mixer_controls[] = {
381SOC_DAPM_SINGLE("Line Capture Switch", WM8753_INCTL2, 3, 1, 0),
382SOC_DAPM_SINGLE("Mic2 Capture Switch", WM8753_INCTL2, 2, 1, 0),
383SOC_DAPM_SINGLE("Mic1 Capture Switch", WM8753_INCTL2, 1, 1, 0),
384SOC_DAPM_SINGLE("Rx Capture Switch", WM8753_INCTL2, 0, 1, 0),
385};
386
387/* Left Line mux */
388static const struct snd_kcontrol_new wm8753_line_left_controls =
389SOC_DAPM_ENUM("Route", wm8753_enum[14]);
390
391/* Right Line mux */
392static const struct snd_kcontrol_new wm8753_line_right_controls =
393SOC_DAPM_ENUM("Route", wm8753_enum[13]);
394
395/* Mono Line mux */
396static const struct snd_kcontrol_new wm8753_line_mono_controls =
397SOC_DAPM_ENUM("Route", wm8753_enum[12]);
398
399/* Line mux and mixer */
400static const struct snd_kcontrol_new wm8753_line_mux_mix_controls =
401SOC_DAPM_ENUM("Route", wm8753_enum[11]);
402
403/* Rx mux and mixer */
404static const struct snd_kcontrol_new wm8753_rx_mux_mix_controls =
405SOC_DAPM_ENUM("Route", wm8753_enum[15]);
406
407/* Mic Selector Mux */
408static const struct snd_kcontrol_new wm8753_mic_sel_mux_controls =
409SOC_DAPM_ENUM("Route", wm8753_enum[25]);
410
411static const struct snd_soc_dapm_widget wm8753_dapm_widgets[] = {
412SND_SOC_DAPM_MICBIAS("Mic Bias", WM8753_PWR1, 5, 0),
413SND_SOC_DAPM_MIXER("Left Mixer", WM8753_PWR4, 0, 0,
414 &wm8753_left_mixer_controls[0], ARRAY_SIZE(wm8753_left_mixer_controls)),
415SND_SOC_DAPM_PGA("Left Out 1", WM8753_PWR3, 8, 0, NULL, 0),
416SND_SOC_DAPM_PGA("Left Out 2", WM8753_PWR3, 6, 0, NULL, 0),
417SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", WM8753_PWR1, 3, 0),
418SND_SOC_DAPM_OUTPUT("LOUT1"),
419SND_SOC_DAPM_OUTPUT("LOUT2"),
420SND_SOC_DAPM_MIXER("Right Mixer", WM8753_PWR4, 1, 0,
421 &wm8753_right_mixer_controls[0], ARRAY_SIZE(wm8753_right_mixer_controls)),
422SND_SOC_DAPM_PGA("Right Out 1", WM8753_PWR3, 7, 0, NULL, 0),
423SND_SOC_DAPM_PGA("Right Out 2", WM8753_PWR3, 5, 0, NULL, 0),
424SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", WM8753_PWR1, 2, 0),
425SND_SOC_DAPM_OUTPUT("ROUT1"),
426SND_SOC_DAPM_OUTPUT("ROUT2"),
427SND_SOC_DAPM_MIXER("Mono Mixer", WM8753_PWR4, 2, 0,
428 &wm8753_mono_mixer_controls[0], ARRAY_SIZE(wm8753_mono_mixer_controls)),
429SND_SOC_DAPM_PGA("Mono Out 1", WM8753_PWR3, 2, 0, NULL, 0),
430SND_SOC_DAPM_PGA("Mono Out 2", WM8753_PWR3, 1, 0, NULL, 0),
431SND_SOC_DAPM_DAC("Voice DAC", "Voice Playback", WM8753_PWR1, 4, 0),
432SND_SOC_DAPM_OUTPUT("MONO1"),
433SND_SOC_DAPM_MUX("Mono 2 Mux", SND_SOC_NOPM, 0, 0, &wm8753_mono2_controls),
434SND_SOC_DAPM_OUTPUT("MONO2"),
435SND_SOC_DAPM_MIXER("Out3 Left + Right", -1, 0, 0, NULL, 0),
436SND_SOC_DAPM_MUX("Out3 Mux", SND_SOC_NOPM, 0, 0, &wm8753_out3_controls),
437SND_SOC_DAPM_PGA("Out 3", WM8753_PWR3, 4, 0, NULL, 0),
438SND_SOC_DAPM_OUTPUT("OUT3"),
439SND_SOC_DAPM_MUX("Out4 Mux", SND_SOC_NOPM, 0, 0, &wm8753_out4_controls),
440SND_SOC_DAPM_PGA("Out 4", WM8753_PWR3, 3, 0, NULL, 0),
441SND_SOC_DAPM_OUTPUT("OUT4"),
442SND_SOC_DAPM_MIXER("Playback Mixer", WM8753_PWR4, 3, 0,
443 &wm8753_record_mixer_controls[0],
444 ARRAY_SIZE(wm8753_record_mixer_controls)),
445SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8753_PWR2, 3, 0),
446SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8753_PWR2, 2, 0),
447SND_SOC_DAPM_MUX("Capture Left Mixer", SND_SOC_NOPM, 0, 0,
448 &wm8753_adc_mono_controls),
449SND_SOC_DAPM_MUX("Capture Right Mixer", SND_SOC_NOPM, 0, 0,
450 &wm8753_adc_mono_controls),
451SND_SOC_DAPM_MUX("Capture Left Mux", SND_SOC_NOPM, 0, 0,
452 &wm8753_adc_left_controls),
453SND_SOC_DAPM_MUX("Capture Right Mux", SND_SOC_NOPM, 0, 0,
454 &wm8753_adc_right_controls),
455SND_SOC_DAPM_MUX("Mic Sidetone Mux", SND_SOC_NOPM, 0, 0,
456 &wm8753_mic_mux_controls),
457SND_SOC_DAPM_PGA("Left Capture Volume", WM8753_PWR2, 5, 0, NULL, 0),
458SND_SOC_DAPM_PGA("Right Capture Volume", WM8753_PWR2, 4, 0, NULL, 0),
459SND_SOC_DAPM_MIXER("ALC Mixer", WM8753_PWR2, 6, 0,
460 &wm8753_alc_mixer_controls[0], ARRAY_SIZE(wm8753_alc_mixer_controls)),
461SND_SOC_DAPM_MUX("Line Left Mux", SND_SOC_NOPM, 0, 0,
462 &wm8753_line_left_controls),
463SND_SOC_DAPM_MUX("Line Right Mux", SND_SOC_NOPM, 0, 0,
464 &wm8753_line_right_controls),
465SND_SOC_DAPM_MUX("Line Mono Mux", SND_SOC_NOPM, 0, 0,
466 &wm8753_line_mono_controls),
467SND_SOC_DAPM_MUX("Line Mixer", WM8753_PWR2, 0, 0,
468 &wm8753_line_mux_mix_controls),
469SND_SOC_DAPM_MUX("Rx Mixer", WM8753_PWR2, 1, 0,
470 &wm8753_rx_mux_mix_controls),
471SND_SOC_DAPM_PGA("Mic 1 Volume", WM8753_PWR2, 8, 0, NULL, 0),
472SND_SOC_DAPM_PGA("Mic 2 Volume", WM8753_PWR2, 7, 0, NULL, 0),
473SND_SOC_DAPM_MUX("Mic Selection Mux", SND_SOC_NOPM, 0, 0,
474 &wm8753_mic_sel_mux_controls),
475SND_SOC_DAPM_INPUT("LINE1"),
476SND_SOC_DAPM_INPUT("LINE2"),
477SND_SOC_DAPM_INPUT("RXP"),
478SND_SOC_DAPM_INPUT("RXN"),
479SND_SOC_DAPM_INPUT("ACIN"),
480SND_SOC_DAPM_OUTPUT("ACOP"),
481SND_SOC_DAPM_INPUT("MIC1N"),
482SND_SOC_DAPM_INPUT("MIC1"),
483SND_SOC_DAPM_INPUT("MIC2N"),
484SND_SOC_DAPM_INPUT("MIC2"),
485SND_SOC_DAPM_VMID("VREF"),
486};
487
Mark Browna65f0562008-05-13 14:54:43 +0200488static const struct snd_soc_dapm_route audio_map[] = {
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200489 /* left mixer */
490 {"Left Mixer", "Left Playback Switch", "Left DAC"},
491 {"Left Mixer", "Voice Playback Switch", "Voice DAC"},
492 {"Left Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
493 {"Left Mixer", "Bypass Playback Switch", "Line Left Mux"},
494
495 /* right mixer */
496 {"Right Mixer", "Right Playback Switch", "Right DAC"},
497 {"Right Mixer", "Voice Playback Switch", "Voice DAC"},
498 {"Right Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
499 {"Right Mixer", "Bypass Playback Switch", "Line Right Mux"},
500
501 /* mono mixer */
502 {"Mono Mixer", "Voice Playback Switch", "Voice DAC"},
503 {"Mono Mixer", "Left Playback Switch", "Left DAC"},
504 {"Mono Mixer", "Right Playback Switch", "Right DAC"},
505 {"Mono Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
506 {"Mono Mixer", "Bypass Playback Switch", "Line Mono Mux"},
507
508 /* left out */
509 {"Left Out 1", NULL, "Left Mixer"},
510 {"Left Out 2", NULL, "Left Mixer"},
511 {"LOUT1", NULL, "Left Out 1"},
512 {"LOUT2", NULL, "Left Out 2"},
513
514 /* right out */
515 {"Right Out 1", NULL, "Right Mixer"},
516 {"Right Out 2", NULL, "Right Mixer"},
517 {"ROUT1", NULL, "Right Out 1"},
518 {"ROUT2", NULL, "Right Out 2"},
519
520 /* mono 1 out */
521 {"Mono Out 1", NULL, "Mono Mixer"},
522 {"MONO1", NULL, "Mono Out 1"},
523
524 /* mono 2 out */
525 {"Mono 2 Mux", "Left + Right", "Out3 Left + Right"},
526 {"Mono 2 Mux", "Inverted Mono 1", "MONO1"},
527 {"Mono 2 Mux", "Left", "Left Mixer"},
528 {"Mono 2 Mux", "Right", "Right Mixer"},
529 {"Mono Out 2", NULL, "Mono 2 Mux"},
530 {"MONO2", NULL, "Mono Out 2"},
531
532 /* out 3 */
533 {"Out3 Left + Right", NULL, "Left Mixer"},
534 {"Out3 Left + Right", NULL, "Right Mixer"},
535 {"Out3 Mux", "VREF", "VREF"},
536 {"Out3 Mux", "Left + Right", "Out3 Left + Right"},
537 {"Out3 Mux", "ROUT2", "ROUT2"},
538 {"Out 3", NULL, "Out3 Mux"},
539 {"OUT3", NULL, "Out 3"},
540
541 /* out 4 */
542 {"Out4 Mux", "VREF", "VREF"},
Rob Sims40373142008-10-01 21:47:31 +0200543 {"Out4 Mux", "Capture ST", "Playback Mixer"},
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200544 {"Out4 Mux", "LOUT2", "LOUT2"},
545 {"Out 4", NULL, "Out4 Mux"},
546 {"OUT4", NULL, "Out 4"},
547
548 /* record mixer */
549 {"Playback Mixer", "Left Capture Switch", "Left Mixer"},
550 {"Playback Mixer", "Voice Capture Switch", "Mono Mixer"},
551 {"Playback Mixer", "Right Capture Switch", "Right Mixer"},
552
553 /* Mic/SideTone Mux */
554 {"Mic Sidetone Mux", "Left PGA", "Left Capture Volume"},
555 {"Mic Sidetone Mux", "Right PGA", "Right Capture Volume"},
556 {"Mic Sidetone Mux", "Mic 1", "Mic 1 Volume"},
557 {"Mic Sidetone Mux", "Mic 2", "Mic 2 Volume"},
558
559 /* Capture Left Mux */
560 {"Capture Left Mux", "PGA", "Left Capture Volume"},
561 {"Capture Left Mux", "Line or RXP-RXN", "Line Left Mux"},
562 {"Capture Left Mux", "Line", "LINE1"},
563
564 /* Capture Right Mux */
565 {"Capture Right Mux", "PGA", "Right Capture Volume"},
566 {"Capture Right Mux", "Line or RXP-RXN", "Line Right Mux"},
Rob Sims40373142008-10-01 21:47:31 +0200567 {"Capture Right Mux", "Sidetone", "Playback Mixer"},
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200568
569 /* Mono Capture mixer-mux */
570 {"Capture Right Mixer", "Stereo", "Capture Right Mux"},
Phil Vandry877ae702009-09-21 11:36:08 -0400571 {"Capture Left Mixer", "Stereo", "Capture Left Mux"},
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200572 {"Capture Left Mixer", "Analogue Mix Left", "Capture Left Mux"},
573 {"Capture Left Mixer", "Analogue Mix Left", "Capture Right Mux"},
574 {"Capture Right Mixer", "Analogue Mix Right", "Capture Left Mux"},
575 {"Capture Right Mixer", "Analogue Mix Right", "Capture Right Mux"},
576 {"Capture Left Mixer", "Digital Mono Mix", "Capture Left Mux"},
577 {"Capture Left Mixer", "Digital Mono Mix", "Capture Right Mux"},
578 {"Capture Right Mixer", "Digital Mono Mix", "Capture Left Mux"},
579 {"Capture Right Mixer", "Digital Mono Mix", "Capture Right Mux"},
580
581 /* ADC */
582 {"Left ADC", NULL, "Capture Left Mixer"},
583 {"Right ADC", NULL, "Capture Right Mixer"},
584
585 /* Left Capture Volume */
586 {"Left Capture Volume", NULL, "ACIN"},
587
588 /* Right Capture Volume */
589 {"Right Capture Volume", NULL, "Mic 2 Volume"},
590
591 /* ALC Mixer */
592 {"ALC Mixer", "Line Capture Switch", "Line Mixer"},
593 {"ALC Mixer", "Mic2 Capture Switch", "Mic 2 Volume"},
594 {"ALC Mixer", "Mic1 Capture Switch", "Mic 1 Volume"},
595 {"ALC Mixer", "Rx Capture Switch", "Rx Mixer"},
596
597 /* Line Left Mux */
598 {"Line Left Mux", "Line 1", "LINE1"},
599 {"Line Left Mux", "Rx Mix", "Rx Mixer"},
600
601 /* Line Right Mux */
602 {"Line Right Mux", "Line 2", "LINE2"},
603 {"Line Right Mux", "Rx Mix", "Rx Mixer"},
604
605 /* Line Mono Mux */
606 {"Line Mono Mux", "Line Mix", "Line Mixer"},
607 {"Line Mono Mux", "Rx Mix", "Rx Mixer"},
608
609 /* Line Mixer/Mux */
610 {"Line Mixer", "Line 1 + 2", "LINE1"},
611 {"Line Mixer", "Line 1 - 2", "LINE1"},
612 {"Line Mixer", "Line 1 + 2", "LINE2"},
613 {"Line Mixer", "Line 1 - 2", "LINE2"},
614 {"Line Mixer", "Line 1", "LINE1"},
615 {"Line Mixer", "Line 2", "LINE2"},
616
617 /* Rx Mixer/Mux */
618 {"Rx Mixer", "RXP - RXN", "RXP"},
619 {"Rx Mixer", "RXP + RXN", "RXP"},
620 {"Rx Mixer", "RXP - RXN", "RXN"},
621 {"Rx Mixer", "RXP + RXN", "RXN"},
622 {"Rx Mixer", "RXP", "RXP"},
623 {"Rx Mixer", "RXN", "RXN"},
624
625 /* Mic 1 Volume */
626 {"Mic 1 Volume", NULL, "MIC1N"},
627 {"Mic 1 Volume", NULL, "Mic Selection Mux"},
628
629 /* Mic 2 Volume */
630 {"Mic 2 Volume", NULL, "MIC2N"},
631 {"Mic 2 Volume", NULL, "MIC2"},
632
633 /* Mic Selector Mux */
634 {"Mic Selection Mux", "Mic 1", "MIC1"},
635 {"Mic Selection Mux", "Mic 2", "MIC2N"},
636 {"Mic Selection Mux", "Mic 3", "MIC2"},
637
638 /* ACOP */
639 {"ACOP", NULL, "ALC Mixer"},
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200640};
641
642static int wm8753_add_widgets(struct snd_soc_codec *codec)
643{
Liam Girdwoodce6120c2010-11-05 15:53:46 +0200644 struct snd_soc_dapm_context *dapm = &codec->dapm;
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200645
Liam Girdwoodce6120c2010-11-05 15:53:46 +0200646 snd_soc_dapm_new_controls(dapm, wm8753_dapm_widgets,
647 ARRAY_SIZE(wm8753_dapm_widgets));
648 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200649
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200650 return 0;
651}
652
653/* PLL divisors */
654struct _pll_div {
655 u32 div2:1;
656 u32 n:4;
657 u32 k:24;
658};
659
660/* The size in bits of the pll divide multiplied by 10
661 * to allow rounding later */
662#define FIXED_PLL_SIZE ((1 << 22) * 10)
663
664static void pll_factors(struct _pll_div *pll_div, unsigned int target,
665 unsigned int source)
666{
667 u64 Kpart;
668 unsigned int K, Ndiv, Nmod;
669
670 Ndiv = target / source;
671 if (Ndiv < 6) {
672 source >>= 1;
673 pll_div->div2 = 1;
674 Ndiv = target / source;
675 } else
676 pll_div->div2 = 0;
677
678 if ((Ndiv < 6) || (Ndiv > 12))
679 printk(KERN_WARNING
Roel Kluin449bd542009-05-27 17:08:39 -0700680 "wm8753: unsupported N = %u\n", Ndiv);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200681
682 pll_div->n = Ndiv;
683 Nmod = target % source;
684 Kpart = FIXED_PLL_SIZE * (long long)Nmod;
685
686 do_div(Kpart, source);
687
688 K = Kpart & 0xFFFFFFFF;
689
690 /* Check if we need to round */
691 if ((K % 10) >= 5)
692 K += 5;
693
694 /* Move down to proper range now rounding is done */
695 K /= 10;
696
697 pll_div->k = K;
698}
699
Mark Brown85488032009-09-05 18:52:16 +0100700static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
701 int source, unsigned int freq_in, unsigned int freq_out)
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200702{
703 u16 reg, enable;
704 int offset;
705 struct snd_soc_codec *codec = codec_dai->codec;
706
707 if (pll_id < WM8753_PLL1 || pll_id > WM8753_PLL2)
708 return -ENODEV;
709
710 if (pll_id == WM8753_PLL1) {
711 offset = 0;
712 enable = 0x10;
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100713 reg = snd_soc_read(codec, WM8753_CLOCK) & 0xffef;
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200714 } else {
715 offset = 4;
716 enable = 0x8;
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100717 reg = snd_soc_read(codec, WM8753_CLOCK) & 0xfff7;
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200718 }
719
720 if (!freq_in || !freq_out) {
721 /* disable PLL */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100722 snd_soc_write(codec, WM8753_PLL1CTL1 + offset, 0x0026);
723 snd_soc_write(codec, WM8753_CLOCK, reg);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200724 return 0;
725 } else {
726 u16 value = 0;
727 struct _pll_div pll_div;
728
729 pll_factors(&pll_div, freq_out * 8, freq_in);
730
731 /* set up N and K PLL divisor ratios */
732 /* bits 8:5 = PLL_N, bits 3:0 = PLL_K[21:18] */
733 value = (pll_div.n << 5) + ((pll_div.k & 0x3c0000) >> 18);
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100734 snd_soc_write(codec, WM8753_PLL1CTL2 + offset, value);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200735
736 /* bits 8:0 = PLL_K[17:9] */
737 value = (pll_div.k & 0x03fe00) >> 9;
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100738 snd_soc_write(codec, WM8753_PLL1CTL3 + offset, value);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200739
740 /* bits 8:0 = PLL_K[8:0] */
741 value = pll_div.k & 0x0001ff;
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100742 snd_soc_write(codec, WM8753_PLL1CTL4 + offset, value);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200743
744 /* set PLL as input and enable */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100745 snd_soc_write(codec, WM8753_PLL1CTL1 + offset, 0x0027 |
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200746 (pll_div.div2 << 3));
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100747 snd_soc_write(codec, WM8753_CLOCK, reg | enable);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200748 }
749 return 0;
750}
751
752struct _coeff_div {
753 u32 mclk;
754 u32 rate;
755 u8 sr:5;
756 u8 usb:1;
757};
758
759/* codec hifi mclk (after PLL) clock divider coefficients */
760static const struct _coeff_div coeff_div[] = {
761 /* 8k */
762 {12288000, 8000, 0x6, 0x0},
763 {11289600, 8000, 0x16, 0x0},
764 {18432000, 8000, 0x7, 0x0},
765 {16934400, 8000, 0x17, 0x0},
766 {12000000, 8000, 0x6, 0x1},
767
768 /* 11.025k */
769 {11289600, 11025, 0x18, 0x0},
770 {16934400, 11025, 0x19, 0x0},
771 {12000000, 11025, 0x19, 0x1},
772
773 /* 16k */
774 {12288000, 16000, 0xa, 0x0},
775 {18432000, 16000, 0xb, 0x0},
776 {12000000, 16000, 0xa, 0x1},
777
778 /* 22.05k */
779 {11289600, 22050, 0x1a, 0x0},
780 {16934400, 22050, 0x1b, 0x0},
781 {12000000, 22050, 0x1b, 0x1},
782
783 /* 32k */
784 {12288000, 32000, 0xc, 0x0},
785 {18432000, 32000, 0xd, 0x0},
786 {12000000, 32000, 0xa, 0x1},
787
788 /* 44.1k */
789 {11289600, 44100, 0x10, 0x0},
790 {16934400, 44100, 0x11, 0x0},
791 {12000000, 44100, 0x11, 0x1},
792
793 /* 48k */
794 {12288000, 48000, 0x0, 0x0},
795 {18432000, 48000, 0x1, 0x0},
796 {12000000, 48000, 0x0, 0x1},
797
798 /* 88.2k */
799 {11289600, 88200, 0x1e, 0x0},
800 {16934400, 88200, 0x1f, 0x0},
801 {12000000, 88200, 0x1f, 0x1},
802
803 /* 96k */
804 {12288000, 96000, 0xe, 0x0},
805 {18432000, 96000, 0xf, 0x0},
806 {12000000, 96000, 0xe, 0x1},
807};
808
809static int get_coeff(int mclk, int rate)
810{
811 int i;
812
813 for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
814 if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
815 return i;
816 }
817 return -EINVAL;
818}
819
820/*
821 * Clock after PLL and dividers
822 */
Liam Girdwoode550e172008-07-07 16:07:52 +0100823static int wm8753_set_dai_sysclk(struct snd_soc_dai *codec_dai,
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200824 int clk_id, unsigned int freq, int dir)
825{
826 struct snd_soc_codec *codec = codec_dai->codec;
Mark Brownb2c812e2010-04-14 15:35:19 +0900827 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200828
829 switch (freq) {
830 case 11289600:
831 case 12000000:
832 case 12288000:
833 case 16934400:
834 case 18432000:
835 if (clk_id == WM8753_MCLK) {
836 wm8753->sysclk = freq;
837 return 0;
838 } else if (clk_id == WM8753_PCMCLK) {
839 wm8753->pcmclk = freq;
840 return 0;
841 }
842 break;
843 }
844 return -EINVAL;
845}
846
847/*
848 * Set's ADC and Voice DAC format.
849 */
Lars-Peter Clausen338ee252011-02-06 10:04:11 +0100850static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_codec *codec,
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200851 unsigned int fmt)
852{
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100853 u16 voice = snd_soc_read(codec, WM8753_PCM) & 0x01ec;
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200854
855 /* interface format */
856 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
857 case SND_SOC_DAIFMT_I2S:
858 voice |= 0x0002;
859 break;
860 case SND_SOC_DAIFMT_RIGHT_J:
861 break;
862 case SND_SOC_DAIFMT_LEFT_J:
863 voice |= 0x0001;
864 break;
865 case SND_SOC_DAIFMT_DSP_A:
866 voice |= 0x0003;
867 break;
868 case SND_SOC_DAIFMT_DSP_B:
869 voice |= 0x0013;
870 break;
871 default:
872 return -EINVAL;
873 }
874
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100875 snd_soc_write(codec, WM8753_PCM, voice);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200876 return 0;
877}
878
879/*
880 * Set PCM DAI bit size and sample rate.
881 */
882static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream,
Mark Browndee89c42008-11-18 22:11:38 +0000883 struct snd_pcm_hw_params *params,
884 struct snd_soc_dai *dai)
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200885{
886 struct snd_soc_pcm_runtime *rtd = substream->private_data;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000887 struct snd_soc_codec *codec = rtd->codec;
Mark Brownb2c812e2010-04-14 15:35:19 +0900888 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100889 u16 voice = snd_soc_read(codec, WM8753_PCM) & 0x01f3;
890 u16 srate = snd_soc_read(codec, WM8753_SRATE1) & 0x017f;
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200891
892 /* bit size */
893 switch (params_format(params)) {
894 case SNDRV_PCM_FORMAT_S16_LE:
895 break;
896 case SNDRV_PCM_FORMAT_S20_3LE:
897 voice |= 0x0004;
898 break;
899 case SNDRV_PCM_FORMAT_S24_LE:
900 voice |= 0x0008;
901 break;
902 case SNDRV_PCM_FORMAT_S32_LE:
903 voice |= 0x000c;
904 break;
905 }
906
907 /* sample rate */
908 if (params_rate(params) * 384 == wm8753->pcmclk)
909 srate |= 0x80;
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100910 snd_soc_write(codec, WM8753_SRATE1, srate);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200911
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100912 snd_soc_write(codec, WM8753_PCM, voice);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200913 return 0;
914}
915
916/*
917 * Set's PCM dai fmt and BCLK.
918 */
Lars-Peter Clausen338ee252011-02-06 10:04:11 +0100919static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec *codec,
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200920 unsigned int fmt)
921{
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200922 u16 voice, ioctl;
923
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100924 voice = snd_soc_read(codec, WM8753_PCM) & 0x011f;
925 ioctl = snd_soc_read(codec, WM8753_IOCTL) & 0x015d;
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200926
927 /* set master/slave audio interface */
928 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
929 case SND_SOC_DAIFMT_CBS_CFS:
930 break;
931 case SND_SOC_DAIFMT_CBM_CFM:
932 ioctl |= 0x2;
933 case SND_SOC_DAIFMT_CBM_CFS:
934 voice |= 0x0040;
935 break;
936 default:
937 return -EINVAL;
938 }
939
940 /* clock inversion */
941 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
942 case SND_SOC_DAIFMT_DSP_A:
943 case SND_SOC_DAIFMT_DSP_B:
944 /* frame inversion not valid for DSP modes */
945 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
946 case SND_SOC_DAIFMT_NB_NF:
947 break;
948 case SND_SOC_DAIFMT_IB_NF:
949 voice |= 0x0080;
950 break;
951 default:
952 return -EINVAL;
953 }
954 break;
955 case SND_SOC_DAIFMT_I2S:
956 case SND_SOC_DAIFMT_RIGHT_J:
957 case SND_SOC_DAIFMT_LEFT_J:
958 voice &= ~0x0010;
959 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
960 case SND_SOC_DAIFMT_NB_NF:
961 break;
962 case SND_SOC_DAIFMT_IB_IF:
963 voice |= 0x0090;
964 break;
965 case SND_SOC_DAIFMT_IB_NF:
966 voice |= 0x0080;
967 break;
968 case SND_SOC_DAIFMT_NB_IF:
969 voice |= 0x0010;
970 break;
971 default:
972 return -EINVAL;
973 }
974 break;
975 default:
976 return -EINVAL;
977 }
978
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100979 snd_soc_write(codec, WM8753_PCM, voice);
980 snd_soc_write(codec, WM8753_IOCTL, ioctl);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200981 return 0;
982}
983
Liam Girdwoode550e172008-07-07 16:07:52 +0100984static int wm8753_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200985 int div_id, int div)
986{
987 struct snd_soc_codec *codec = codec_dai->codec;
988 u16 reg;
989
990 switch (div_id) {
991 case WM8753_PCMDIV:
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100992 reg = snd_soc_read(codec, WM8753_CLOCK) & 0x003f;
993 snd_soc_write(codec, WM8753_CLOCK, reg | div);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200994 break;
995 case WM8753_BCLKDIV:
Lars-Peter Clausen776065e2010-12-28 21:38:03 +0100996 reg = snd_soc_read(codec, WM8753_SRATE2) & 0x01c7;
997 snd_soc_write(codec, WM8753_SRATE2, reg | div);
Liam Girdwood1f53aee2007-04-16 19:17:44 +0200998 break;
999 case WM8753_VXCLKDIV:
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001000 reg = snd_soc_read(codec, WM8753_SRATE2) & 0x003f;
1001 snd_soc_write(codec, WM8753_SRATE2, reg | div);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001002 break;
1003 default:
1004 return -EINVAL;
1005 }
1006 return 0;
1007}
1008
1009/*
1010 * Set's HiFi DAC format.
1011 */
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001012static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec *codec,
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001013 unsigned int fmt)
1014{
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001015 u16 hifi = snd_soc_read(codec, WM8753_HIFI) & 0x01e0;
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001016
1017 /* interface format */
1018 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
1019 case SND_SOC_DAIFMT_I2S:
1020 hifi |= 0x0002;
1021 break;
1022 case SND_SOC_DAIFMT_RIGHT_J:
1023 break;
1024 case SND_SOC_DAIFMT_LEFT_J:
1025 hifi |= 0x0001;
1026 break;
1027 case SND_SOC_DAIFMT_DSP_A:
1028 hifi |= 0x0003;
1029 break;
1030 case SND_SOC_DAIFMT_DSP_B:
1031 hifi |= 0x0013;
1032 break;
1033 default:
1034 return -EINVAL;
1035 }
1036
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001037 snd_soc_write(codec, WM8753_HIFI, hifi);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001038 return 0;
1039}
1040
1041/*
1042 * Set's I2S DAI format.
1043 */
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001044static int wm8753_i2s_set_dai_fmt(struct snd_soc_codec *codec,
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001045 unsigned int fmt)
1046{
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001047 u16 ioctl, hifi;
1048
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001049 hifi = snd_soc_read(codec, WM8753_HIFI) & 0x011f;
1050 ioctl = snd_soc_read(codec, WM8753_IOCTL) & 0x00ae;
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001051
1052 /* set master/slave audio interface */
1053 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
1054 case SND_SOC_DAIFMT_CBS_CFS:
1055 break;
1056 case SND_SOC_DAIFMT_CBM_CFM:
1057 ioctl |= 0x1;
1058 case SND_SOC_DAIFMT_CBM_CFS:
1059 hifi |= 0x0040;
1060 break;
1061 default:
1062 return -EINVAL;
1063 }
1064
1065 /* clock inversion */
1066 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
1067 case SND_SOC_DAIFMT_DSP_A:
1068 case SND_SOC_DAIFMT_DSP_B:
1069 /* frame inversion not valid for DSP modes */
1070 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
1071 case SND_SOC_DAIFMT_NB_NF:
1072 break;
1073 case SND_SOC_DAIFMT_IB_NF:
1074 hifi |= 0x0080;
1075 break;
1076 default:
1077 return -EINVAL;
1078 }
1079 break;
1080 case SND_SOC_DAIFMT_I2S:
1081 case SND_SOC_DAIFMT_RIGHT_J:
1082 case SND_SOC_DAIFMT_LEFT_J:
1083 hifi &= ~0x0010;
1084 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
1085 case SND_SOC_DAIFMT_NB_NF:
1086 break;
1087 case SND_SOC_DAIFMT_IB_IF:
1088 hifi |= 0x0090;
1089 break;
1090 case SND_SOC_DAIFMT_IB_NF:
1091 hifi |= 0x0080;
1092 break;
1093 case SND_SOC_DAIFMT_NB_IF:
1094 hifi |= 0x0010;
1095 break;
1096 default:
1097 return -EINVAL;
1098 }
1099 break;
1100 default:
1101 return -EINVAL;
1102 }
1103
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001104 snd_soc_write(codec, WM8753_HIFI, hifi);
1105 snd_soc_write(codec, WM8753_IOCTL, ioctl);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001106 return 0;
1107}
1108
1109/*
1110 * Set PCM DAI bit size and sample rate.
1111 */
1112static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream,
Mark Browndee89c42008-11-18 22:11:38 +00001113 struct snd_pcm_hw_params *params,
1114 struct snd_soc_dai *dai)
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001115{
1116 struct snd_soc_pcm_runtime *rtd = substream->private_data;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001117 struct snd_soc_codec *codec = rtd->codec;
Mark Brownb2c812e2010-04-14 15:35:19 +09001118 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001119 u16 srate = snd_soc_read(codec, WM8753_SRATE1) & 0x01c0;
1120 u16 hifi = snd_soc_read(codec, WM8753_HIFI) & 0x01f3;
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001121 int coeff;
1122
1123 /* is digital filter coefficient valid ? */
1124 coeff = get_coeff(wm8753->sysclk, params_rate(params));
1125 if (coeff < 0) {
1126 printk(KERN_ERR "wm8753 invalid MCLK or rate\n");
1127 return coeff;
1128 }
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001129 snd_soc_write(codec, WM8753_SRATE1, srate | (coeff_div[coeff].sr << 1) |
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001130 coeff_div[coeff].usb);
1131
1132 /* bit size */
1133 switch (params_format(params)) {
1134 case SNDRV_PCM_FORMAT_S16_LE:
1135 break;
1136 case SNDRV_PCM_FORMAT_S20_3LE:
1137 hifi |= 0x0004;
1138 break;
1139 case SNDRV_PCM_FORMAT_S24_LE:
1140 hifi |= 0x0008;
1141 break;
1142 case SNDRV_PCM_FORMAT_S32_LE:
1143 hifi |= 0x000c;
1144 break;
1145 }
1146
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001147 snd_soc_write(codec, WM8753_HIFI, hifi);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001148 return 0;
1149}
1150
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001151static int wm8753_mode1v_set_dai_fmt(struct snd_soc_codec *codec,
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001152 unsigned int fmt)
1153{
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001154 u16 clock;
1155
1156 /* set clk source as pcmclk */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001157 clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb;
1158 snd_soc_write(codec, WM8753_CLOCK, clock);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001159
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001160 return wm8753_vdac_adc_set_dai_fmt(codec, fmt);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001161}
1162
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001163static int wm8753_mode1h_set_dai_fmt(struct snd_soc_codec *codec,
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001164 unsigned int fmt)
1165{
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001166 return wm8753_hdac_set_dai_fmt(codec, fmt);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001167}
1168
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001169static int wm8753_mode2_set_dai_fmt(struct snd_soc_codec *codec,
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001170 unsigned int fmt)
1171{
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001172 u16 clock;
1173
1174 /* set clk source as pcmclk */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001175 clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb;
1176 snd_soc_write(codec, WM8753_CLOCK, clock);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001177
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001178 return wm8753_vdac_adc_set_dai_fmt(codec, fmt);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001179}
1180
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001181static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_codec *codec,
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001182 unsigned int fmt)
1183{
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001184 u16 clock;
1185
1186 /* set clk source as mclk */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001187 clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb;
1188 snd_soc_write(codec, WM8753_CLOCK, clock | 0x4);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001189
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001190 if (wm8753_hdac_set_dai_fmt(codec, fmt) < 0)
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001191 return -EINVAL;
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001192 return wm8753_vdac_adc_set_dai_fmt(codec, fmt);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001193}
1194
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001195static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec,
1196 unsigned int fmt)
1197{
1198 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
1199 int ret = 0;
1200
1201 switch (wm8753->dai_func) {
1202 case 0:
1203 ret = wm8753_mode1h_set_dai_fmt(codec, fmt);
1204 break;
1205 case 1:
1206 ret = wm8753_mode2_set_dai_fmt(codec, fmt);
1207 break;
1208 case 2:
1209 case 3:
1210 ret = wm8753_mode3_4_set_dai_fmt(codec, fmt);
1211 break;
1212 default:
1213 break;
1214 }
1215 if (ret)
1216 return ret;
1217
1218 return wm8753_i2s_set_dai_fmt(codec, fmt);
1219}
1220
1221static int wm8753_hifi_set_dai_fmt(struct snd_soc_dai *codec_dai,
1222 unsigned int fmt)
1223{
1224 struct snd_soc_codec *codec = codec_dai->codec;
1225 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
1226
1227 wm8753->hifi_fmt = fmt;
1228
1229 return wm8753_hifi_write_dai_fmt(codec, fmt);
1230};
1231
1232static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec,
1233 unsigned int fmt)
1234{
1235 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
1236 int ret = 0;
1237
1238 if (wm8753->dai_func != 0)
1239 return 0;
1240
1241 ret = wm8753_mode1v_set_dai_fmt(codec, fmt);
1242 if (ret)
1243 return ret;
1244 ret = wm8753_pcm_set_dai_fmt(codec, fmt);
1245 if (ret)
1246 return ret;
1247
1248 return 0;
1249};
1250
1251static int wm8753_voice_set_dai_fmt(struct snd_soc_dai *codec_dai,
1252 unsigned int fmt)
1253{
1254 struct snd_soc_codec *codec = codec_dai->codec;
1255 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
1256
1257 wm8753->voice_fmt = fmt;
1258
1259 return wm8753_voice_write_dai_fmt(codec, fmt);
1260};
1261
Liam Girdwoode550e172008-07-07 16:07:52 +01001262static int wm8753_mute(struct snd_soc_dai *dai, int mute)
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001263{
1264 struct snd_soc_codec *codec = dai->codec;
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001265 u16 mute_reg = snd_soc_read(codec, WM8753_DAC) & 0xfff7;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001266 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001267
1268 /* the digital mute covers the HiFi and Voice DAC's on the WM8753.
1269 * make sure we check if they are not both active when we mute */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001270 if (mute && wm8753->dai_func == 1) {
1271 if (!codec->active)
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001272 snd_soc_write(codec, WM8753_DAC, mute_reg | 0x8);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001273 } else {
1274 if (mute)
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001275 snd_soc_write(codec, WM8753_DAC, mute_reg | 0x8);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001276 else
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001277 snd_soc_write(codec, WM8753_DAC, mute_reg);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001278 }
1279
1280 return 0;
1281}
1282
Mark Brown0be98982008-05-19 12:31:28 +02001283static int wm8753_set_bias_level(struct snd_soc_codec *codec,
1284 enum snd_soc_bias_level level)
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001285{
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001286 u16 pwr_reg = snd_soc_read(codec, WM8753_PWR1) & 0xfe3e;
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001287
Mark Brown0be98982008-05-19 12:31:28 +02001288 switch (level) {
1289 case SND_SOC_BIAS_ON:
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001290 /* set vmid to 50k and unmute dac */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001291 snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x00c0);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001292 break;
Mark Brown0be98982008-05-19 12:31:28 +02001293 case SND_SOC_BIAS_PREPARE:
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001294 /* set vmid to 5k for quick power up */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001295 snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x01c1);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001296 break;
Mark Brown0be98982008-05-19 12:31:28 +02001297 case SND_SOC_BIAS_STANDBY:
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001298 /* mute dac and set vmid to 500k, enable VREF */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001299 snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x0141);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001300 break;
Mark Brown0be98982008-05-19 12:31:28 +02001301 case SND_SOC_BIAS_OFF:
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001302 snd_soc_write(codec, WM8753_PWR1, 0x0001);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001303 break;
1304 }
Liam Girdwoodce6120c2010-11-05 15:53:46 +02001305 codec->dapm.bias_level = level;
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001306 return 0;
1307}
1308
1309#define WM8753_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
Mark Brown60fc6842008-04-30 17:18:43 +02001310 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
1311 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
1312 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001313
1314#define WM8753_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
1315 SNDRV_PCM_FMTBIT_S24_LE)
1316
1317/*
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001318 * The WM8753 supports up to 4 different and mutually exclusive DAI
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001319 * configurations. This gives 2 PCM's available for use, hifi and voice.
1320 * NOTE: The Voice PCM cannot play or capture audio to the CPU as it's DAI
1321 * is connected between the wm8753 and a BT codec or GSM modem.
1322 *
1323 * 1. Voice over PCM DAI - HIFI DAC over HIFI DAI
1324 * 2. Voice over HIFI DAI - HIFI disabled
1325 * 3. Voice disabled - HIFI over HIFI
1326 * 4. Voice disabled - HIFI over HIFI, uses voice DAI LRC for capture
1327 */
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001328static struct snd_soc_dai_ops wm8753_dai_ops_hifi_mode = {
Eric Miao6335d052009-03-03 09:41:00 +08001329 .hw_params = wm8753_i2s_hw_params,
1330 .digital_mute = wm8753_mute,
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001331 .set_fmt = wm8753_hifi_set_dai_fmt,
Eric Miao6335d052009-03-03 09:41:00 +08001332 .set_clkdiv = wm8753_set_dai_clkdiv,
1333 .set_pll = wm8753_set_dai_pll,
1334 .set_sysclk = wm8753_set_dai_sysclk,
1335};
1336
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001337static struct snd_soc_dai_ops wm8753_dai_ops_voice_mode = {
Eric Miao6335d052009-03-03 09:41:00 +08001338 .hw_params = wm8753_pcm_hw_params,
1339 .digital_mute = wm8753_mute,
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001340 .set_fmt = wm8753_voice_set_dai_fmt,
Eric Miao6335d052009-03-03 09:41:00 +08001341 .set_clkdiv = wm8753_set_dai_clkdiv,
1342 .set_pll = wm8753_set_dai_pll,
1343 .set_sysclk = wm8753_set_dai_sysclk,
1344};
1345
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001346static struct snd_soc_dai_driver wm8753_dai[] = {
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001347/* DAI HiFi mode 1 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001348{ .name = "wm8753-hifi",
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001349 .playback = {
1350 .stream_name = "HiFi Playback",
1351 .channels_min = 1,
1352 .channels_max = 2,
1353 .rates = WM8753_RATES,
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001354 .formats = WM8753_FORMATS
1355 },
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001356 .capture = { /* dummy for fast DAI switching */
1357 .stream_name = "Capture",
1358 .channels_min = 1,
1359 .channels_max = 2,
1360 .rates = WM8753_RATES,
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001361 .formats = WM8753_FORMATS
1362 },
1363 .ops = &wm8753_dai_ops_hifi_mode,
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001364},
1365/* DAI Voice mode 1 */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001366{ .name = "wm8753-voice",
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001367 .playback = {
1368 .stream_name = "Voice Playback",
1369 .channels_min = 1,
1370 .channels_max = 1,
1371 .rates = WM8753_RATES,
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001372 .formats = WM8753_FORMATS,
1373 },
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001374 .capture = {
1375 .stream_name = "Capture",
1376 .channels_min = 1,
1377 .channels_max = 2,
1378 .rates = WM8753_RATES,
Lars-Peter Clausen338ee252011-02-06 10:04:11 +01001379 .formats = WM8753_FORMATS,
1380 },
1381 .ops = &wm8753_dai_ops_voice_mode,
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001382},
1383};
1384
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001385static void wm8753_work(struct work_struct *work)
1386{
Liam Girdwoodce6120c2010-11-05 15:53:46 +02001387 struct snd_soc_dapm_context *dapm =
1388 container_of(work, struct snd_soc_dapm_context,
1389 delayed_work.work);
1390 struct snd_soc_codec *codec = dapm->codec;
1391 wm8753_set_bias_level(codec, dapm->bias_level);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001392}
1393
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001394static int wm8753_suspend(struct snd_soc_codec *codec, pm_message_t state)
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001395{
Mark Brown0be98982008-05-19 12:31:28 +02001396 wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001397 return 0;
1398}
1399
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001400static int wm8753_resume(struct snd_soc_codec *codec)
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001401{
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001402 u16 *reg_cache = codec->reg_cache;
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001403 int i;
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001404
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001405 /* Sync reg_cache with the hardware */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001406 for (i = 1; i < ARRAY_SIZE(wm8753_reg); i++) {
1407 if (i == WM8753_RESET)
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001408 continue;
Mark Browne611bd82009-02-22 20:04:41 +00001409
1410 /* No point in writing hardware default values back */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001411 if (reg_cache[i] == wm8753_reg[i])
Mark Browne611bd82009-02-22 20:04:41 +00001412 continue;
1413
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001414 snd_soc_write(codec, i, reg_cache[i]);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001415 }
1416
Mark Brown0be98982008-05-19 12:31:28 +02001417 wm8753_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001418
1419 /* charge wm8753 caps */
Liam Girdwoodce6120c2010-11-05 15:53:46 +02001420 if (codec->dapm.suspend_bias_level == SND_SOC_BIAS_ON) {
Mark Brown0be98982008-05-19 12:31:28 +02001421 wm8753_set_bias_level(codec, SND_SOC_BIAS_PREPARE);
Liam Girdwoodce6120c2010-11-05 15:53:46 +02001422 codec->dapm.bias_level = SND_SOC_BIAS_ON;
1423 schedule_delayed_work(&codec->dapm.delayed_work,
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001424 msecs_to_jiffies(caps_charge));
1425 }
1426
1427 return 0;
1428}
1429
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001430static int wm8753_probe(struct snd_soc_codec *codec)
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001431{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001432 struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001433 int ret;
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001434
Liam Girdwoodce6120c2010-11-05 15:53:46 +02001435 INIT_DELAYED_WORK(&codec->dapm.delayed_work, wm8753_work);
Mark Brownc2bac162009-02-24 23:33:12 +00001436
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001437 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8753->control_type);
1438 if (ret < 0) {
1439 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
1440 return ret;
1441 }
1442
Mark Brownc2bac162009-02-24 23:33:12 +00001443 ret = wm8753_reset(codec);
1444 if (ret < 0) {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001445 dev_err(codec->dev, "Failed to issue reset: %d\n", ret);
1446 return ret;
Mark Brownc2bac162009-02-24 23:33:12 +00001447 }
1448
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001449 wm8753_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
1450 wm8753->dai_func = 0;
1451
Mark Brownc2bac162009-02-24 23:33:12 +00001452 /* charge output caps */
1453 wm8753_set_bias_level(codec, SND_SOC_BIAS_PREPARE);
Liam Girdwoodce6120c2010-11-05 15:53:46 +02001454 schedule_delayed_work(&codec->dapm.delayed_work,
Mark Brownc2bac162009-02-24 23:33:12 +00001455 msecs_to_jiffies(caps_charge));
1456
1457 /* set the update bits */
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001458 snd_soc_update_bits(codec, WM8753_LDAC, 0x0100, 0x0100);
1459 snd_soc_update_bits(codec, WM8753_RDAC, 0x0100, 0x0100);
Axel Lina6712582011-10-02 20:41:04 +08001460 snd_soc_update_bits(codec, WM8753_LADC, 0x0100, 0x0100);
1461 snd_soc_update_bits(codec, WM8753_RADC, 0x0100, 0x0100);
Lars-Peter Clausen776065e2010-12-28 21:38:03 +01001462 snd_soc_update_bits(codec, WM8753_LOUT1V, 0x0100, 0x0100);
1463 snd_soc_update_bits(codec, WM8753_ROUT1V, 0x0100, 0x0100);
1464 snd_soc_update_bits(codec, WM8753_LOUT2V, 0x0100, 0x0100);
1465 snd_soc_update_bits(codec, WM8753_ROUT2V, 0x0100, 0x0100);
1466 snd_soc_update_bits(codec, WM8753_LINVOL, 0x0100, 0x0100);
1467 snd_soc_update_bits(codec, WM8753_RINVOL, 0x0100, 0x0100);
Mark Brownc2bac162009-02-24 23:33:12 +00001468
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001469 snd_soc_add_controls(codec, wm8753_snd_controls,
1470 ARRAY_SIZE(wm8753_snd_controls));
1471 wm8753_add_widgets(codec);
Mark Brownc2bac162009-02-24 23:33:12 +00001472
1473 return 0;
Mark Brownc2bac162009-02-24 23:33:12 +00001474}
1475
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001476/* power down chip */
1477static int wm8753_remove(struct snd_soc_codec *codec)
Mark Brownc2bac162009-02-24 23:33:12 +00001478{
Takashi Iwaifdea0572010-12-13 12:55:39 +01001479 flush_delayed_work_sync(&codec->dapm.delayed_work);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001480 wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF);
1481
1482 return 0;
Mark Brownc2bac162009-02-24 23:33:12 +00001483}
1484
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001485static struct snd_soc_codec_driver soc_codec_dev_wm8753 = {
1486 .probe = wm8753_probe,
1487 .remove = wm8753_remove,
1488 .suspend = wm8753_suspend,
1489 .resume = wm8753_resume,
1490 .set_bias_level = wm8753_set_bias_level,
Dimitris Papastamose5eec342010-09-10 18:14:56 +01001491 .reg_cache_size = ARRAY_SIZE(wm8753_reg),
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001492 .reg_word_size = sizeof(u16),
1493 .reg_cache_default = wm8753_reg,
1494};
Mark Brown69e169d2009-02-22 14:39:03 +00001495
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001496#if defined(CONFIG_SPI_MASTER)
1497static int __devinit wm8753_spi_probe(struct spi_device *spi)
Mark Brown69e169d2009-02-22 14:39:03 +00001498{
Mark Brownc2bac162009-02-24 23:33:12 +00001499 struct wm8753_priv *wm8753;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001500 int ret;
Mark Brown69e169d2009-02-22 14:39:03 +00001501
Mark Brownc2bac162009-02-24 23:33:12 +00001502 wm8753 = kzalloc(sizeof(struct wm8753_priv), GFP_KERNEL);
1503 if (wm8753 == NULL)
1504 return -ENOMEM;
Mark Brown69e169d2009-02-22 14:39:03 +00001505
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001506 wm8753->control_type = SND_SOC_SPI;
1507 spi_set_drvdata(spi, wm8753);
Mark Brown69e169d2009-02-22 14:39:03 +00001508
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001509 ret = snd_soc_register_codec(&spi->dev,
1510 &soc_codec_dev_wm8753, wm8753_dai, ARRAY_SIZE(wm8753_dai));
1511 if (ret < 0)
1512 kfree(wm8753);
1513 return ret;
Mark Brown69e169d2009-02-22 14:39:03 +00001514}
1515
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001516static int __devexit wm8753_spi_remove(struct spi_device *spi)
Mark Brown69e169d2009-02-22 14:39:03 +00001517{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001518 snd_soc_unregister_codec(&spi->dev);
1519 kfree(spi_get_drvdata(spi));
1520 return 0;
1521}
1522
1523static struct spi_driver wm8753_spi_driver = {
1524 .driver = {
1525 .name = "wm8753-codec",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001526 .owner = THIS_MODULE,
1527 },
1528 .probe = wm8753_spi_probe,
1529 .remove = __devexit_p(wm8753_spi_remove),
1530};
1531#endif /* CONFIG_SPI_MASTER */
1532
1533#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1534static __devinit int wm8753_i2c_probe(struct i2c_client *i2c,
1535 const struct i2c_device_id *id)
1536{
1537 struct wm8753_priv *wm8753;
1538 int ret;
1539
1540 wm8753 = kzalloc(sizeof(struct wm8753_priv), GFP_KERNEL);
1541 if (wm8753 == NULL)
1542 return -ENOMEM;
1543
1544 i2c_set_clientdata(i2c, wm8753);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001545 wm8753->control_type = SND_SOC_I2C;
1546
1547 ret = snd_soc_register_codec(&i2c->dev,
1548 &soc_codec_dev_wm8753, wm8753_dai, ARRAY_SIZE(wm8753_dai));
1549 if (ret < 0)
1550 kfree(wm8753);
1551 return ret;
1552}
1553
1554static __devexit int wm8753_i2c_remove(struct i2c_client *client)
1555{
1556 snd_soc_unregister_codec(&client->dev);
1557 kfree(i2c_get_clientdata(client));
1558 return 0;
Mark Brown69e169d2009-02-22 14:39:03 +00001559}
1560
1561static const struct i2c_device_id wm8753_i2c_id[] = {
1562 { "wm8753", 0 },
1563 { }
1564};
1565MODULE_DEVICE_TABLE(i2c, wm8753_i2c_id);
1566
1567static struct i2c_driver wm8753_i2c_driver = {
1568 .driver = {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001569 .name = "wm8753-codec",
Mark Brown69e169d2009-02-22 14:39:03 +00001570 .owner = THIS_MODULE,
1571 },
1572 .probe = wm8753_i2c_probe,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001573 .remove = __devexit_p(wm8753_i2c_remove),
Mark Brown69e169d2009-02-22 14:39:03 +00001574 .id_table = wm8753_i2c_id,
1575};
1576#endif
1577
Takashi Iwaic9b3a402008-12-10 07:47:22 +01001578static int __init wm8753_modinit(void)
Mark Brown64089b82008-12-08 19:17:58 +00001579{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001580 int ret = 0;
Mark Brownc2bac162009-02-24 23:33:12 +00001581#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1582 ret = i2c_add_driver(&wm8753_i2c_driver);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001583 if (ret != 0) {
1584 printk(KERN_ERR "Failed to register wm8753 I2C driver: %d\n",
1585 ret);
1586 }
Mark Brownc2bac162009-02-24 23:33:12 +00001587#endif
1588#if defined(CONFIG_SPI_MASTER)
1589 ret = spi_register_driver(&wm8753_spi_driver);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001590 if (ret != 0) {
1591 printk(KERN_ERR "Failed to register wm8753 SPI driver: %d\n",
1592 ret);
1593 }
Mark Brownc2bac162009-02-24 23:33:12 +00001594#endif
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001595 return ret;
Mark Brown64089b82008-12-08 19:17:58 +00001596}
1597module_init(wm8753_modinit);
1598
1599static void __exit wm8753_exit(void)
1600{
Mark Brownc2bac162009-02-24 23:33:12 +00001601#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1602 i2c_del_driver(&wm8753_i2c_driver);
1603#endif
1604#if defined(CONFIG_SPI_MASTER)
1605 spi_unregister_driver(&wm8753_spi_driver);
1606#endif
Mark Brown64089b82008-12-08 19:17:58 +00001607}
1608module_exit(wm8753_exit);
1609
Liam Girdwood1f53aee2007-04-16 19:17:44 +02001610MODULE_DESCRIPTION("ASoC WM8753 driver");
1611MODULE_AUTHOR("Liam Girdwood");
1612MODULE_LICENSE("GPL");