aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/ad193x.c
diff options
context:
space:
mode:
authorBarry Song <21cnbao@gmail.com>2010-03-19 02:48:33 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-03-19 08:12:16 -0400
commita1533d94c6b930ef4263941adfd1e1132ca95627 (patch)
tree7d2d2635342d413a2411d7d19986d22125d6e41f /sound/soc/codecs/ad193x.c
parent8ecbabd977dc64d2d8c9980420a3d72db06fe551 (diff)
ASoC: rename ad1938 to ad193x and add support for ad1936/7/8/9
Signed-off-by: Barry Song <barry.song@analog.com> Signed-off-by: Yi Li <yi.li@analog.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/ad193x.c')
-rw-r--r--sound/soc/codecs/ad193x.c560
1 files changed, 560 insertions, 0 deletions
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c
new file mode 100644
index 000000000000..d7426990b66e
--- /dev/null
+++ b/sound/soc/codecs/ad193x.c
@@ -0,0 +1,560 @@
1/*
2 * AD193X Audio Codec driver supporting AD1936/7/8/9
3 *
4 * Copyright 2010 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/init.h>
10#include <linux/module.h>
11#include <linux/kernel.h>
12#include <linux/device.h>
13#include <linux/i2c.h>
14#include <linux/spi/spi.h>
15#include <sound/core.h>
16#include <sound/pcm.h>
17#include <sound/pcm_params.h>
18#include <sound/initval.h>
19#include <sound/soc.h>
20#include <sound/tlv.h>
21#include <sound/soc-dapm.h>
22#include "ad193x.h"
23
24/* codec private data */
25struct ad193x_priv {
26 struct snd_soc_codec codec;
27 u8 reg_cache[AD193X_NUM_REGS];
28};
29
30/* ad193x register cache & default register settings */
31static const u8 ad193x_reg[AD193X_NUM_REGS] = {
32 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0,
33};
34
35static struct snd_soc_codec *ad193x_codec;
36struct snd_soc_codec_device soc_codec_dev_ad193x;
37static int ad193x_register(struct ad193x_priv *ad193x, int bus_type);
38static void ad193x_unregister(struct ad193x_priv *ad193x);
39
40/*
41 * AD193X volume/mute/de-emphasis etc. controls
42 */
43static const char *ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"};
44
45static const struct soc_enum ad193x_deemp_enum =
46 SOC_ENUM_SINGLE(AD193X_DAC_CTRL2, 1, 4, ad193x_deemp);
47
48static const struct snd_kcontrol_new ad193x_snd_controls[] = {
49 /* DAC volume control */
50 SOC_DOUBLE_R("DAC1 Volume", AD193X_DAC_L1_VOL,
51 AD193X_DAC_R1_VOL, 0, 0xFF, 1),
52 SOC_DOUBLE_R("DAC2 Volume", AD193X_DAC_L2_VOL,
53 AD193X_DAC_R2_VOL, 0, 0xFF, 1),
54 SOC_DOUBLE_R("DAC3 Volume", AD193X_DAC_L3_VOL,
55 AD193X_DAC_R3_VOL, 0, 0xFF, 1),
56 SOC_DOUBLE_R("DAC4 Volume", AD193X_DAC_L4_VOL,
57 AD193X_DAC_R4_VOL, 0, 0xFF, 1),
58
59 /* ADC switch control */
60 SOC_DOUBLE("ADC1 Switch", AD193X_ADC_CTRL0, AD193X_ADCL1_MUTE,
61 AD193X_ADCR1_MUTE, 1, 1),
62 SOC_DOUBLE("ADC2 Switch", AD193X_ADC_CTRL0, AD193X_ADCL2_MUTE,
63 AD193X_ADCR2_MUTE, 1, 1),
64
65 /* DAC switch control */
66 SOC_DOUBLE("DAC1 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL1_MUTE,
67 AD193X_DACR1_MUTE, 1, 1),
68 SOC_DOUBLE("DAC2 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL2_MUTE,
69 AD193X_DACR2_MUTE, 1, 1),
70 SOC_DOUBLE("DAC3 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL3_MUTE,
71 AD193X_DACR3_MUTE, 1, 1),
72 SOC_DOUBLE("DAC4 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL4_MUTE,
73 AD193X_DACR4_MUTE, 1, 1),
74
75 /* ADC high-pass filter */
76 SOC_SINGLE("ADC High Pass Filter Switch", AD193X_ADC_CTRL0,
77 AD193X_ADC_HIGHPASS_FILTER, 1, 0),
78
79 /* DAC de-emphasis */
80 SOC_ENUM("Playback Deemphasis", ad193x_deemp_enum),
81};
82
83static const struct snd_soc_dapm_widget ad193x_dapm_widgets[] = {
84 SND_SOC_DAPM_DAC("DAC", "Playback", AD193X_DAC_CTRL0, 0, 1),
85 SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0),
86 SND_SOC_DAPM_SUPPLY("PLL_PWR", AD193X_PLL_CLK_CTRL0, 0, 1, NULL, 0),
87 SND_SOC_DAPM_SUPPLY("ADC_PWR", AD193X_ADC_CTRL0, 0, 1, NULL, 0),
88 SND_SOC_DAPM_OUTPUT("DAC1OUT"),
89 SND_SOC_DAPM_OUTPUT("DAC2OUT"),
90 SND_SOC_DAPM_OUTPUT("DAC3OUT"),
91 SND_SOC_DAPM_OUTPUT("DAC4OUT"),
92 SND_SOC_DAPM_INPUT("ADC1IN"),
93 SND_SOC_DAPM_INPUT("ADC2IN"),
94};
95
96static const struct snd_soc_dapm_route audio_paths[] = {
97 { "DAC", NULL, "PLL_PWR" },
98 { "ADC", NULL, "PLL_PWR" },
99 { "DAC", NULL, "ADC_PWR" },
100 { "ADC", NULL, "ADC_PWR" },
101 { "DAC1OUT", "DAC1 Switch", "DAC" },
102 { "DAC2OUT", "DAC2 Switch", "DAC" },
103 { "DAC3OUT", "DAC3 Switch", "DAC" },
104 { "DAC4OUT", "DAC4 Switch", "DAC" },
105 { "ADC", "ADC1 Switch", "ADC1IN" },
106 { "ADC", "ADC2 Switch", "ADC2IN" },
107};
108
109/*
110 * DAI ops entries
111 */
112
113static int ad193x_mute(struct snd_soc_dai *dai, int mute)
114{
115 struct snd_soc_codec *codec = dai->codec;
116 int reg;
117
118 reg = snd_soc_read(codec, AD193X_DAC_CTRL2);
119 reg = (mute > 0) ? reg | AD193X_DAC_MASTER_MUTE : reg &
120 (~AD193X_DAC_MASTER_MUTE);
121 snd_soc_write(codec, AD193X_DAC_CTRL2, reg);
122
123 return 0;
124}
125
126static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
127 unsigned int rx_mask, int slots, int width)
128{
129 struct snd_soc_codec *codec = dai->codec;
130 int dac_reg = snd_soc_read(codec, AD193X_DAC_CTRL1);
131 int adc_reg = snd_soc_read(codec, AD193X_ADC_CTRL2);
132
133 dac_reg &= ~AD193X_DAC_CHAN_MASK;
134 adc_reg &= ~AD193X_ADC_CHAN_MASK;
135
136 switch (slots) {
137 case 2:
138 dac_reg |= AD193X_DAC_2_CHANNELS << AD193X_DAC_CHAN_SHFT;
139 adc_reg |= AD193X_ADC_2_CHANNELS << AD193X_ADC_CHAN_SHFT;
140 break;
141 case 4:
142 dac_reg |= AD193X_DAC_4_CHANNELS << AD193X_DAC_CHAN_SHFT;
143 adc_reg |= AD193X_ADC_4_CHANNELS << AD193X_ADC_CHAN_SHFT;
144 break;
145 case 8:
146 dac_reg |= AD193X_DAC_8_CHANNELS << AD193X_DAC_CHAN_SHFT;
147 adc_reg |= AD193X_ADC_8_CHANNELS << AD193X_ADC_CHAN_SHFT;
148 break;
149 case 16:
150 dac_reg |= AD193X_DAC_16_CHANNELS << AD193X_DAC_CHAN_SHFT;
151 adc_reg |= AD193X_ADC_16_CHANNELS << AD193X_ADC_CHAN_SHFT;
152 break;
153 default:
154 return -EINVAL;
155 }
156
157 snd_soc_write(codec, AD193X_DAC_CTRL1, dac_reg);
158 snd_soc_write(codec, AD193X_ADC_CTRL2, adc_reg);
159
160 return 0;
161}
162
163static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai,
164 unsigned int fmt)
165{
166 struct snd_soc_codec *codec = codec_dai->codec;
167 int adc_reg, dac_reg;
168
169 adc_reg = snd_soc_read(codec, AD193X_ADC_CTRL2);
170 dac_reg = snd_soc_read(codec, AD193X_DAC_CTRL1);
171
172 /* At present, the driver only support AUX ADC mode(SND_SOC_DAIFMT_I2S
173 * with TDM) and ADC&DAC TDM mode(SND_SOC_DAIFMT_DSP_A)
174 */
175 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
176 case SND_SOC_DAIFMT_I2S:
177 adc_reg &= ~AD193X_ADC_SERFMT_MASK;
178 adc_reg |= AD193X_ADC_SERFMT_TDM;
179 break;
180 case SND_SOC_DAIFMT_DSP_A:
181 adc_reg &= ~AD193X_ADC_SERFMT_MASK;
182 adc_reg |= AD193X_ADC_SERFMT_AUX;
183 break;
184 default:
185 return -EINVAL;
186 }
187
188 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
189 case SND_SOC_DAIFMT_NB_NF: /* normal bit clock + frame */
190 adc_reg &= ~AD193X_ADC_LEFT_HIGH;
191 adc_reg &= ~AD193X_ADC_BCLK_INV;
192 dac_reg &= ~AD193X_DAC_LEFT_HIGH;
193 dac_reg &= ~AD193X_DAC_BCLK_INV;
194 break;
195 case SND_SOC_DAIFMT_NB_IF: /* normal bclk + invert frm */
196 adc_reg |= AD193X_ADC_LEFT_HIGH;
197 adc_reg &= ~AD193X_ADC_BCLK_INV;
198 dac_reg |= AD193X_DAC_LEFT_HIGH;
199 dac_reg &= ~AD193X_DAC_BCLK_INV;
200 break;
201 case SND_SOC_DAIFMT_IB_NF: /* invert bclk + normal frm */
202 adc_reg &= ~AD193X_ADC_LEFT_HIGH;
203 adc_reg |= AD193X_ADC_BCLK_INV;
204 dac_reg &= ~AD193X_DAC_LEFT_HIGH;
205 dac_reg |= AD193X_DAC_BCLK_INV;
206 break;
207
208 case SND_SOC_DAIFMT_IB_IF: /* invert bclk + frm */
209 adc_reg |= AD193X_ADC_LEFT_HIGH;
210 adc_reg |= AD193X_ADC_BCLK_INV;
211 dac_reg |= AD193X_DAC_LEFT_HIGH;
212 dac_reg |= AD193X_DAC_BCLK_INV;
213 break;
214 default:
215 return -EINVAL;
216 }
217
218 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
219 case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & frm master */
220 adc_reg |= AD193X_ADC_LCR_MASTER;
221 adc_reg |= AD193X_ADC_BCLK_MASTER;
222 dac_reg |= AD193X_DAC_LCR_MASTER;
223 dac_reg |= AD193X_DAC_BCLK_MASTER;
224 break;
225 case SND_SOC_DAIFMT_CBS_CFM: /* codec clk slave & frm master */
226 adc_reg |= AD193X_ADC_LCR_MASTER;
227 adc_reg &= ~AD193X_ADC_BCLK_MASTER;
228 dac_reg |= AD193X_DAC_LCR_MASTER;
229 dac_reg &= ~AD193X_DAC_BCLK_MASTER;
230 break;
231 case SND_SOC_DAIFMT_CBM_CFS: /* codec clk master & frame slave */
232 adc_reg &= ~AD193X_ADC_LCR_MASTER;
233 adc_reg |= AD193X_ADC_BCLK_MASTER;
234 dac_reg &= ~AD193X_DAC_LCR_MASTER;
235 dac_reg |= AD193X_DAC_BCLK_MASTER;
236 break;
237 case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & frm slave */
238 adc_reg &= ~AD193X_ADC_LCR_MASTER;
239 adc_reg &= ~AD193X_ADC_BCLK_MASTER;
240 dac_reg &= ~AD193X_DAC_LCR_MASTER;
241 dac_reg &= ~AD193X_DAC_BCLK_MASTER;
242 break;
243 default:
244 return -EINVAL;
245 }
246
247 snd_soc_write(codec, AD193X_ADC_CTRL2, adc_reg);
248 snd_soc_write(codec, AD193X_DAC_CTRL1, dac_reg);
249
250 return 0;
251}
252
253static int ad193x_hw_params(struct snd_pcm_substream *substream,
254 struct snd_pcm_hw_params *params,
255 struct snd_soc_dai *dai)
256{
257 int word_len = 0, reg = 0;
258
259 struct snd_soc_pcm_runtime *rtd = substream->private_data;
260 struct snd_soc_device *socdev = rtd->socdev;
261 struct snd_soc_codec *codec = socdev->card->codec;
262
263 /* bit size */
264 switch (params_format(params)) {
265 case SNDRV_PCM_FORMAT_S16_LE:
266 word_len = 3;
267 break;
268 case SNDRV_PCM_FORMAT_S20_3LE:
269 word_len = 1;
270 break;
271 case SNDRV_PCM_FORMAT_S24_LE:
272 case SNDRV_PCM_FORMAT_S32_LE:
273 word_len = 0;
274 break;
275 }
276
277 reg = snd_soc_read(codec, AD193X_DAC_CTRL2);
278 reg = (reg & (~AD193X_DAC_WORD_LEN_MASK)) | word_len;
279 snd_soc_write(codec, AD193X_DAC_CTRL2, reg);
280
281 reg = snd_soc_read(codec, AD193X_ADC_CTRL1);
282 reg = (reg & (~AD193X_ADC_WORD_LEN_MASK)) | word_len;
283 snd_soc_write(codec, AD193X_ADC_CTRL1, reg);
284
285 return 0;
286}
287
288int ad193x_bus_probe(struct device *dev, void *ctrl_data, int bus_type)
289{
290 struct snd_soc_codec *codec;
291 struct ad193x_priv *ad193x;
292
293 ad193x = kzalloc(sizeof(struct ad193x_priv), GFP_KERNEL);
294 if (ad193x == NULL)
295 return -ENOMEM;
296
297 codec = &ad193x->codec;
298 codec->control_data = ctrl_data;
299 codec->dev = dev;
300
301 dev_set_drvdata(dev, ad193x);
302
303 return ad193x_register(ad193x, bus_type);
304}
305EXPORT_SYMBOL_GPL(ad193x_bus_probe);
306
307int ad193x_bus_remove(struct device *dev)
308{
309 struct ad193x_priv *ad193x = dev_get_drvdata(dev);
310
311 ad193x_unregister(ad193x);
312 return 0;
313}
314EXPORT_SYMBOL_GPL(ad193x_bus_remove);
315
316static struct snd_soc_dai_ops ad193x_dai_ops = {
317 .hw_params = ad193x_hw_params,
318 .digital_mute = ad193x_mute,
319 .set_tdm_slot = ad193x_set_tdm_slot,
320 .set_fmt = ad193x_set_dai_fmt,
321};
322
323/* codec DAI instance */
324struct snd_soc_dai ad193x_dai = {
325 .name = "AD193X",
326 .playback = {
327 .stream_name = "Playback",
328 .channels_min = 2,
329 .channels_max = 8,
330 .rates = SNDRV_PCM_RATE_48000,
331 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE |
332 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
333 },
334 .capture = {
335 .stream_name = "Capture",
336 .channels_min = 2,
337 .channels_max = 4,
338 .rates = SNDRV_PCM_RATE_48000,
339 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE |
340 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
341 },
342 .ops = &ad193x_dai_ops,
343};
344EXPORT_SYMBOL_GPL(ad193x_dai);
345
346static int ad193x_register(struct ad193x_priv *ad193x, int bus_type)
347{
348 int ret;
349 struct snd_soc_codec *codec = &ad193x->codec;
350
351 if (ad193x_codec) {
352 dev_err(codec->dev, "Another ad193x is registered\n");
353 return -EINVAL;
354 }
355
356 mutex_init(&codec->mutex);
357 codec->private_data = ad193x;
358 codec->reg_cache = ad193x->reg_cache;
359 codec->reg_cache_size = AD193X_NUM_REGS;
360 codec->name = "AD193X";
361 codec->owner = THIS_MODULE;
362 codec->dai = &ad193x_dai;
363 codec->num_dai = 1;
364 INIT_LIST_HEAD(&codec->dapm_widgets);
365 INIT_LIST_HEAD(&codec->dapm_paths);
366
367 ad193x_dai.dev = codec->dev;
368 ad193x_codec = codec;
369
370 memcpy(codec->reg_cache, ad193x_reg, AD193X_NUM_REGS);
371
372 if (bus_type == SND_SOC_I2C)
373 ret = snd_soc_codec_set_cache_io(codec, 8, 8, bus_type);
374 else
375 ret = snd_soc_codec_set_cache_io(codec, 16, 8, bus_type);
376 if (ret < 0) {
377 dev_err(codec->dev, "failed to set cache I/O: %d\n",
378 ret);
379 kfree(ad193x);
380 return ret;
381 }
382
383 /* default setting for ad193x */
384
385 /* unmute dac channels */
386 snd_soc_write(codec, AD193X_DAC_CHNL_MUTE, 0x0);
387 /* de-emphasis: 48kHz, powedown dac */
388 snd_soc_write(codec, AD193X_DAC_CTRL2, 0x1A);
389 /* powerdown dac, dac in tdm mode */
390 snd_soc_write(codec, AD193X_DAC_CTRL0, 0x41);
391 /* high-pass filter enable */
392 snd_soc_write(codec, AD193X_ADC_CTRL0, 0x3);
393 /* sata delay=1, adc aux mode */
394 snd_soc_write(codec, AD193X_ADC_CTRL1, 0x43);
395 /* pll input: mclki/xi */
396 snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9D; mclk=12.288Mhz: 0x99 */
397 snd_soc_write(codec, AD193X_PLL_CLK_CTRL1, 0x04);
398
399 ret = snd_soc_register_codec(codec);
400 if (ret != 0) {
401 dev_err(codec->dev, "Failed to register codec: %d\n", ret);
402 kfree(ad193x);
403 return ret;
404 }
405
406 ret = snd_soc_register_dai(&ad193x_dai);
407 if (ret != 0) {
408 dev_err(codec->dev, "Failed to register DAI: %d\n", ret);
409 snd_soc_unregister_codec(codec);
410 kfree(ad193x);
411 return ret;
412 }
413
414 return 0;
415}
416
417static void ad193x_unregister(struct ad193x_priv *ad193x)
418{
419 snd_soc_unregister_dai(&ad193x_dai);
420 snd_soc_unregister_codec(&ad193x->codec);
421 kfree(ad193x);
422 ad193x_codec = NULL;
423}
424
425static int ad193x_probe(struct platform_device *pdev)
426{
427 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
428 struct snd_soc_codec *codec;
429 int ret = 0;
430
431 if (ad193x_codec == NULL) {
432 dev_err(&pdev->dev, "Codec device not registered\n");
433 return -ENODEV;
434 }
435
436 socdev->card->codec = ad193x_codec;
437 codec = ad193x_codec;
438
439 /* register pcms */
440 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
441 if (ret < 0) {
442 dev_err(codec->dev, "failed to create pcms: %d\n", ret);
443 goto pcm_err;
444 }
445
446 snd_soc_add_controls(codec, ad193x_snd_controls,
447 ARRAY_SIZE(ad193x_snd_controls));
448 snd_soc_dapm_new_controls(codec, ad193x_dapm_widgets,
449 ARRAY_SIZE(ad193x_dapm_widgets));
450 snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths));
451
452pcm_err:
453 return ret;
454}
455
456/* power down chip */
457static int ad193x_remove(struct platform_device *pdev)
458{
459 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
460
461 snd_soc_free_pcms(socdev);
462 snd_soc_dapm_free(socdev);
463
464 return 0;
465}
466
467struct snd_soc_codec_device soc_codec_dev_ad193x = {
468 .probe = ad193x_probe,
469 .remove = ad193x_remove,
470};
471EXPORT_SYMBOL_GPL(soc_codec_dev_ad193x);
472
473#if defined(CONFIG_SPI_MASTER)
474static int __devinit ad193x_spi_probe(struct spi_device *spi)
475{
476 return ad193x_bus_probe(&spi->dev, spi, SND_SOC_SPI);
477}
478
479static int __devexit ad193x_spi_remove(struct spi_device *spi)
480{
481 return ad193x_bus_remove(&spi->dev);
482}
483
484static struct spi_driver ad193x_spi_driver = {
485 .driver = {
486 .name = "ad193x",
487 .owner = THIS_MODULE,
488 },
489 .probe = ad193x_spi_probe,
490 .remove = __devexit_p(ad193x_spi_remove),
491};
492#endif
493
494#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
495static const struct i2c_device_id ad193x_id[] = {
496 { "ad1936", 0 },
497 { "ad1937", 0 },
498 { }
499};
500MODULE_DEVICE_TABLE(i2c, ad193x_id);
501
502static int __devinit ad193x_i2c_probe(struct i2c_client *client,
503 const struct i2c_device_id *id)
504{
505 return ad193x_bus_probe(&client->dev, client, SND_SOC_I2C);
506}
507
508static int __devexit ad193x_i2c_remove(struct i2c_client *client)
509{
510 return ad193x_bus_remove(&client->dev);
511}
512
513static struct i2c_driver ad193x_i2c_driver = {
514 .driver = {
515 .name = "ad193x",
516 },
517 .probe = ad193x_i2c_probe,
518 .remove = __devexit_p(ad193x_i2c_remove),
519 .id_table = ad193x_id,
520};
521#endif
522
523static int __init ad193x_modinit(void)
524{
525 int ret;
526
527#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
528 ret = i2c_add_driver(&ad193x_i2c_driver);
529 if (ret != 0) {
530 printk(KERN_ERR "Failed to register AD193X I2C driver: %d\n",
531 ret);
532 }
533#endif
534
535#if defined(CONFIG_SPI_MASTER)
536 ret = spi_register_driver(&ad193x_spi_driver);
537 if (ret != 0) {
538 printk(KERN_ERR "Failed to register AD193X SPI driver: %d\n",
539 ret);
540 }
541#endif
542 return ret;
543}
544module_init(ad193x_modinit);
545
546static void __exit ad193x_modexit(void)
547{
548#if defined(CONFIG_SPI_MASTER)
549 spi_unregister_driver(&ad193x_spi_driver);
550#endif
551
552#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
553 i2c_del_driver(&ad193x_i2c_driver);
554#endif
555}
556module_exit(ad193x_modexit);
557
558MODULE_DESCRIPTION("ASoC ad193x driver");
559MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
560MODULE_LICENSE("GPL");