]> git.karo-electronics.de Git - karo-tx-linux.git/blob - sound/soc/codecs/da7210.c
3bd867de597b14b4a87dd52e8f04aa53abb9de3a
[karo-tx-linux.git] / sound / soc / codecs / da7210.c
1 /*
2  * DA7210 ALSA Soc codec driver
3  *
4  * Copyright (c) 2009 Dialog Semiconductor
5  * Written by David Chen <Dajun.chen@diasemi.com>
6  *
7  * Copyright (C) 2009 Renesas Solutions Corp.
8  * Cleanups by Kuninori Morimoto <morimoto.kuninori@renesas.com>
9  *
10  * Tested on SuperH Ecovec24 board with S16/S24 LE in 48KHz using I2S
11  *
12  * This program is free software; you can redistribute  it and/or modify it
13  * under  the terms of  the GNU General  Public License as published by the
14  * Free Software Foundation;  either version 2 of the  License, or (at your
15  * option) any later version.
16  */
17
18 #include <linux/module.h>
19 #include <linux/moduleparam.h>
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/delay.h>
23 #include <linux/pm.h>
24 #include <linux/i2c.h>
25 #include <linux/platform_device.h>
26 #include <sound/core.h>
27 #include <sound/pcm.h>
28 #include <sound/pcm_params.h>
29 #include <sound/soc.h>
30 #include <sound/soc-dapm.h>
31 #include <sound/tlv.h>
32 #include <sound/initval.h>
33 #include <asm/div64.h>
34
35 #include "da7210.h"
36
37 /* DA7210 register space */
38 #define DA7210_STATUS                   0x02
39 #define DA7210_STARTUP1                 0x03
40 #define DA7210_MIC_L                    0x07
41 #define DA7210_MIC_R                    0x08
42 #define DA7210_INMIX_L                  0x0D
43 #define DA7210_INMIX_R                  0x0E
44 #define DA7210_ADC_HPF                  0x0F
45 #define DA7210_ADC                      0x10
46 #define DA7210_DAC_HPF                  0x14
47 #define DA7210_DAC_L                    0x15
48 #define DA7210_DAC_R                    0x16
49 #define DA7210_DAC_SEL                  0x17
50 #define DA7210_OUTMIX_L                 0x1C
51 #define DA7210_OUTMIX_R                 0x1D
52 #define DA7210_HP_L_VOL                 0x21
53 #define DA7210_HP_R_VOL                 0x22
54 #define DA7210_HP_CFG                   0x23
55 #define DA7210_DAI_SRC_SEL              0x25
56 #define DA7210_DAI_CFG1                 0x26
57 #define DA7210_DAI_CFG3                 0x28
58 #define DA7210_PLL_DIV3                 0x2B
59 #define DA7210_PLL                      0x2C
60
61 /* STARTUP1 bit fields */
62 #define DA7210_SC_MST_EN                (1 << 0)
63
64 /* MIC_L bit fields */
65 #define DA7210_MICBIAS_EN               (1 << 6)
66 #define DA7210_MIC_L_EN                 (1 << 7)
67
68 /* MIC_R bit fields */
69 #define DA7210_MIC_R_EN                 (1 << 7)
70
71 /* INMIX_L bit fields */
72 #define DA7210_IN_L_EN                  (1 << 7)
73
74 /* INMIX_R bit fields */
75 #define DA7210_IN_R_EN                  (1 << 7)
76
77 /* ADC bit fields */
78 #define DA7210_ADC_L_EN                 (1 << 3)
79 #define DA7210_ADC_R_EN                 (1 << 7)
80
81 /* DAC/ADC HPF fields */
82 #define DA7210_VOICE_F0_MASK            (0x7 << 4)
83 #define DA7210_VOICE_F0_25              (1 << 4)
84 #define DA7210_VOICE_EN                 (1 << 7)
85
86 /* DAC_SEL bit fields */
87 #define DA7210_DAC_L_SRC_DAI_L          (4 << 0)
88 #define DA7210_DAC_L_EN                 (1 << 3)
89 #define DA7210_DAC_R_SRC_DAI_R          (5 << 4)
90 #define DA7210_DAC_R_EN                 (1 << 7)
91
92 /* OUTMIX_L bit fields */
93 #define DA7210_OUT_L_EN                 (1 << 7)
94
95 /* OUTMIX_R bit fields */
96 #define DA7210_OUT_R_EN                 (1 << 7)
97
98 /* HP_CFG bit fields */
99 #define DA7210_HP_2CAP_MODE             (1 << 1)
100 #define DA7210_HP_SENSE_EN              (1 << 2)
101 #define DA7210_HP_L_EN                  (1 << 3)
102 #define DA7210_HP_MODE                  (1 << 6)
103 #define DA7210_HP_R_EN                  (1 << 7)
104
105 /* DAI_SRC_SEL bit fields */
106 #define DA7210_DAI_OUT_L_SRC            (6 << 0)
107 #define DA7210_DAI_OUT_R_SRC            (7 << 4)
108
109 /* DAI_CFG1 bit fields */
110 #define DA7210_DAI_WORD_S16_LE          (0 << 0)
111 #define DA7210_DAI_WORD_S24_LE          (2 << 0)
112 #define DA7210_DAI_FLEN_64BIT           (1 << 2)
113 #define DA7210_DAI_MODE_MASTER          (1 << 7)
114
115 /* DAI_CFG3 bit fields */
116 #define DA7210_DAI_FORMAT_I2SMODE       (0 << 0)
117 #define DA7210_DAI_OE                   (1 << 3)
118 #define DA7210_DAI_EN                   (1 << 7)
119
120 /*PLL_DIV3 bit fields */
121 #define DA7210_MCLK_RANGE_10_20_MHZ     (1 << 4)
122 #define DA7210_PLL_BYP                  (1 << 6)
123
124 /* PLL bit fields */
125 #define DA7210_PLL_FS_MASK              (0xF << 0)
126 #define DA7210_PLL_FS_8000              (0x1 << 0)
127 #define DA7210_PLL_FS_12000             (0x3 << 0)
128 #define DA7210_PLL_FS_16000             (0x5 << 0)
129 #define DA7210_PLL_FS_24000             (0x7 << 0)
130 #define DA7210_PLL_FS_32000             (0x9 << 0)
131 #define DA7210_PLL_FS_48000             (0xB << 0)
132 #define DA7210_PLL_FS_96000             (0xF << 0)
133
134
135 #define DA7210_VERSION "0.0.1"
136
137 /* Codec private data */
138 struct da7210_priv {
139         struct snd_soc_codec codec;
140 };
141
142 static struct snd_soc_codec *da7210_codec;
143
144 /*
145  * Register cache
146  */
147 static const u8 da7210_reg[] = {
148         0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R0  - R7  */
149         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, /* R8  - RF  */
150         0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x10, 0x54, /* R10 - R17 */
151         0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R18 - R1F */
152         0x00, 0x00, 0x00, 0x02, 0x00, 0x76, 0x00, 0x00, /* R20 - R27 */
153         0x04, 0x00, 0x00, 0x30, 0x2A, 0x00, 0x40, 0x00, /* R28 - R2F */
154         0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, /* R30 - R37 */
155         0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, /* R38 - R3F */
156         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R40 - R4F */
157         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R48 - R4F */
158         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R50 - R57 */
159         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R58 - R5F */
160         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R60 - R67 */
161         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R68 - R6F */
162         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* R70 - R77 */
163         0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x54, 0x00, /* R78 - R7F */
164         0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x00, /* R80 - R87 */
165         0x00,                                           /* R88       */
166 };
167
168 /*
169  * Read da7210 register cache
170  */
171 static inline u32 da7210_read_reg_cache(struct snd_soc_codec *codec, u32 reg)
172 {
173         u8 *cache = codec->reg_cache;
174         BUG_ON(reg > ARRAY_SIZE(da7210_reg));
175         return cache[reg];
176 }
177
178 /*
179  * Write to the da7210 register space
180  */
181 static int da7210_write(struct snd_soc_codec *codec, u32 reg, u32 value)
182 {
183         u8 *cache = codec->reg_cache;
184         u8 data[2];
185
186         BUG_ON(codec->volatile_register);
187
188         data[0] = reg & 0xff;
189         data[1] = value & 0xff;
190
191         if (reg >= codec->reg_cache_size)
192                 return -EIO;
193
194         if (2 != codec->hw_write(codec->control_data, data, 2))
195                 return -EIO;
196
197         cache[reg] = value;
198         return 0;
199 }
200
201 /*
202  * Read from the da7210 register space.
203  */
204 static inline u32 da7210_read(struct snd_soc_codec *codec, u32 reg)
205 {
206         if (DA7210_STATUS == reg)
207                 return i2c_smbus_read_byte_data(codec->control_data, reg);
208
209         return da7210_read_reg_cache(codec, reg);
210 }
211
212 static int da7210_startup(struct snd_pcm_substream *substream,
213                           struct snd_soc_dai *dai)
214 {
215         int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
216         struct snd_soc_codec *codec = dai->codec;
217
218         if (is_play) {
219                 /* PlayBack Volume 40 */
220                 snd_soc_update_bits(codec, DA7210_HP_L_VOL, 0x3F, 40);
221                 snd_soc_update_bits(codec, DA7210_HP_R_VOL, 0x3F, 40);
222
223                 /* Enable Out */
224                 snd_soc_update_bits(codec, DA7210_OUTMIX_L, 0x1F, 0x10);
225                 snd_soc_update_bits(codec, DA7210_OUTMIX_R, 0x1F, 0x10);
226
227         } else {
228                 /* Volume 7 */
229                 snd_soc_update_bits(codec, DA7210_MIC_L, 0x7, 0x7);
230                 snd_soc_update_bits(codec, DA7210_MIC_R, 0x7, 0x7);
231
232                 /* Enable Mic */
233                 snd_soc_update_bits(codec, DA7210_INMIX_L, 0x1F, 0x1);
234                 snd_soc_update_bits(codec, DA7210_INMIX_R, 0x1F, 0x1);
235         }
236
237         return 0;
238 }
239
240 /*
241  * Set PCM DAI word length.
242  */
243 static int da7210_hw_params(struct snd_pcm_substream *substream,
244                             struct snd_pcm_hw_params *params,
245                             struct snd_soc_dai *dai)
246 {
247         struct snd_soc_pcm_runtime *rtd = substream->private_data;
248         struct snd_soc_device *socdev = rtd->socdev;
249         struct snd_soc_codec *codec = socdev->card->codec;
250         u32 dai_cfg1;
251         u32 hpf_reg, hpf_mask, hpf_value;
252         u32 fs;
253
254         /* set DAI source to Left and Right ADC */
255         da7210_write(codec, DA7210_DAI_SRC_SEL,
256                      DA7210_DAI_OUT_R_SRC | DA7210_DAI_OUT_L_SRC);
257
258         /* Enable DAI */
259         da7210_write(codec, DA7210_DAI_CFG3, DA7210_DAI_OE | DA7210_DAI_EN);
260
261         dai_cfg1 = 0xFC & da7210_read(codec, DA7210_DAI_CFG1);
262
263         switch (params_format(params)) {
264         case SNDRV_PCM_FORMAT_S16_LE:
265                 dai_cfg1 |= DA7210_DAI_WORD_S16_LE;
266                 break;
267         case SNDRV_PCM_FORMAT_S24_LE:
268                 dai_cfg1 |= DA7210_DAI_WORD_S24_LE;
269                 break;
270         default:
271                 return -EINVAL;
272         }
273
274         da7210_write(codec, DA7210_DAI_CFG1, dai_cfg1);
275
276         hpf_reg = (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) ?
277                 DA7210_DAC_HPF : DA7210_ADC_HPF;
278
279         switch (params_rate(params)) {
280         case 8000:
281                 fs              = DA7210_PLL_FS_8000;
282                 hpf_mask        = DA7210_VOICE_F0_MASK  | DA7210_VOICE_EN;
283                 hpf_value       = DA7210_VOICE_F0_25    | DA7210_VOICE_EN;
284                 break;
285         case 12000:
286                 fs              = DA7210_PLL_FS_12000;
287                 hpf_mask        = DA7210_VOICE_F0_MASK  | DA7210_VOICE_EN;
288                 hpf_value       = DA7210_VOICE_F0_25    | DA7210_VOICE_EN;
289                 break;
290         case 16000:
291                 fs              = DA7210_PLL_FS_16000;
292                 hpf_mask        = DA7210_VOICE_F0_MASK  | DA7210_VOICE_EN;
293                 hpf_value       = DA7210_VOICE_F0_25    | DA7210_VOICE_EN;
294                 break;
295         case 32000:
296                 fs              = DA7210_PLL_FS_32000;
297                 hpf_mask        = DA7210_VOICE_EN;
298                 hpf_value       = 0;
299                 break;
300         case 48000:
301                 fs              = DA7210_PLL_FS_48000;
302                 hpf_mask        = DA7210_VOICE_EN;
303                 hpf_value       = 0;
304                 break;
305         case 96000:
306                 fs              = DA7210_PLL_FS_96000;
307                 hpf_mask        = DA7210_VOICE_EN;
308                 hpf_value       = 0;
309                 break;
310         default:
311                 return -EINVAL;
312         }
313
314         snd_soc_update_bits(codec, hpf_reg, hpf_mask, hpf_value);
315         snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs);
316
317         return 0;
318 }
319
320 /*
321  * Set DAI mode and Format
322  */
323 static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt)
324 {
325         struct snd_soc_codec *codec = codec_dai->codec;
326         u32 dai_cfg1;
327         u32 dai_cfg3;
328
329         dai_cfg1 = 0x7f & da7210_read(codec, DA7210_DAI_CFG1);
330         dai_cfg3 = 0xfc & da7210_read(codec, DA7210_DAI_CFG3);
331
332         switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
333         case SND_SOC_DAIFMT_CBM_CFM:
334                 dai_cfg1 |= DA7210_DAI_MODE_MASTER;
335                 break;
336         default:
337                 return -EINVAL;
338         }
339
340         /* FIXME
341          *
342          * It support I2S only now
343          */
344         switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
345         case SND_SOC_DAIFMT_I2S:
346                 dai_cfg3 |= DA7210_DAI_FORMAT_I2SMODE;
347                 break;
348         default:
349                 return -EINVAL;
350         }
351
352         /* FIXME
353          *
354          * It support 64bit data transmission only now
355          */
356         dai_cfg1 |= DA7210_DAI_FLEN_64BIT;
357
358         da7210_write(codec, DA7210_DAI_CFG1, dai_cfg1);
359         da7210_write(codec, DA7210_DAI_CFG3, dai_cfg3);
360
361         return 0;
362 }
363
364 #define DA7210_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
365
366 /* DAI operations */
367 static struct snd_soc_dai_ops da7210_dai_ops = {
368         .startup        = da7210_startup,
369         .hw_params      = da7210_hw_params,
370         .set_fmt        = da7210_set_dai_fmt,
371 };
372
373 struct snd_soc_dai da7210_dai = {
374         .name = "DA7210 IIS",
375         .id = 0,
376         /* playback capabilities */
377         .playback = {
378                 .stream_name = "Playback",
379                 .channels_min = 1,
380                 .channels_max = 2,
381                 .rates = SNDRV_PCM_RATE_8000_96000,
382                 .formats = DA7210_FORMATS,
383         },
384         /* capture capabilities */
385         .capture = {
386                 .stream_name = "Capture",
387                 .channels_min = 1,
388                 .channels_max = 2,
389                 .rates = SNDRV_PCM_RATE_8000_96000,
390                 .formats = DA7210_FORMATS,
391         },
392         .ops = &da7210_dai_ops,
393 };
394 EXPORT_SYMBOL_GPL(da7210_dai);
395
396 /*
397  * Initialize the DA7210 driver
398  * register the mixer and dsp interfaces with the kernel
399  */
400 static int da7210_init(struct da7210_priv *da7210)
401 {
402         struct snd_soc_codec *codec = &da7210->codec;
403         int ret = 0;
404
405         if (da7210_codec) {
406                 dev_err(codec->dev, "Another da7210 is registered\n");
407                 return -EINVAL;
408         }
409
410         mutex_init(&codec->mutex);
411         INIT_LIST_HEAD(&codec->dapm_widgets);
412         INIT_LIST_HEAD(&codec->dapm_paths);
413
414         codec->private_data     = da7210;
415         codec->name             = "DA7210";
416         codec->owner            = THIS_MODULE;
417         codec->read             = da7210_read;
418         codec->write            = da7210_write;
419         codec->dai              = &da7210_dai;
420         codec->num_dai          = 1;
421         codec->hw_write         = (hw_write_t)i2c_master_send;
422         codec->reg_cache_size   = ARRAY_SIZE(da7210_reg);
423         codec->reg_cache        = kmemdup(da7210_reg,
424                                           sizeof(da7210_reg), GFP_KERNEL);
425
426         if (!codec->reg_cache)
427                 return -ENOMEM;
428
429         da7210_dai.dev = codec->dev;
430         da7210_codec = codec;
431
432         ret = snd_soc_register_codec(codec);
433         if (ret) {
434                 dev_err(codec->dev, "Failed to register CODEC: %d\n", ret);
435                 goto init_err;
436         }
437
438         ret = snd_soc_register_dai(&da7210_dai);
439         if (ret) {
440                 dev_err(codec->dev, "Failed to register DAI: %d\n", ret);
441                 goto init_err;
442         }
443
444         /* FIXME
445          *
446          * This driver use fixed value here
447          */
448
449         /*
450          * ADC settings
451          */
452
453         /* Enable Left & Right MIC PGA and Mic Bias */
454         da7210_write(codec, DA7210_MIC_L, DA7210_MIC_L_EN | DA7210_MICBIAS_EN);
455         da7210_write(codec, DA7210_MIC_R, DA7210_MIC_R_EN);
456
457         /* Enable Left and Right input PGA */
458         da7210_write(codec, DA7210_INMIX_L, DA7210_IN_L_EN);
459         da7210_write(codec, DA7210_INMIX_R, DA7210_IN_R_EN);
460
461         /* Enable Left and Right ADC */
462         da7210_write(codec, DA7210_ADC, DA7210_ADC_L_EN | DA7210_ADC_R_EN);
463
464         /*
465          * DAC settings
466          */
467
468         /* Enable Left and Right DAC */
469         da7210_write(codec, DA7210_DAC_SEL,
470                      DA7210_DAC_L_SRC_DAI_L | DA7210_DAC_L_EN |
471                      DA7210_DAC_R_SRC_DAI_R | DA7210_DAC_R_EN);
472
473         /* Enable Left and Right out PGA */
474         da7210_write(codec, DA7210_OUTMIX_L, DA7210_OUT_L_EN);
475         da7210_write(codec, DA7210_OUTMIX_R, DA7210_OUT_R_EN);
476
477         /* Enable Left and Right HeadPhone PGA */
478         da7210_write(codec, DA7210_HP_CFG,
479                      DA7210_HP_2CAP_MODE | DA7210_HP_SENSE_EN |
480                      DA7210_HP_L_EN | DA7210_HP_MODE | DA7210_HP_R_EN);
481
482         /* Diable PLL and bypass it */
483         da7210_write(codec, DA7210_PLL, DA7210_PLL_FS_48000);
484
485         /* Bypass PLL and set MCLK freq rang to 10-20MHz */
486         da7210_write(codec, DA7210_PLL_DIV3,
487                      DA7210_MCLK_RANGE_10_20_MHZ | DA7210_PLL_BYP);
488
489         /* Activate all enabled subsystem */
490         da7210_write(codec, DA7210_STARTUP1, DA7210_SC_MST_EN);
491
492         return ret;
493
494 init_err:
495         kfree(codec->reg_cache);
496         codec->reg_cache = NULL;
497
498         return ret;
499
500 }
501
502 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
503 static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
504                                       const struct i2c_device_id *id)
505 {
506         struct da7210_priv *da7210;
507         struct snd_soc_codec *codec;
508         int ret;
509
510         da7210 = kzalloc(sizeof(struct da7210_priv), GFP_KERNEL);
511         if (!da7210)
512                 return -ENOMEM;
513
514         codec = &da7210->codec;
515         codec->dev = &i2c->dev;
516
517         i2c_set_clientdata(i2c, da7210);
518         codec->control_data = i2c;
519
520         ret = da7210_init(da7210);
521         if (ret < 0)
522                 pr_err("Failed to initialise da7210 audio codec\n");
523
524         return ret;
525 }
526
527 static int __devexit da7210_i2c_remove(struct i2c_client *client)
528 {
529         struct da7210_priv *da7210 = i2c_get_clientdata(client);
530
531         snd_soc_unregister_dai(&da7210_dai);
532         kfree(da7210->codec.reg_cache);
533         kfree(da7210);
534         da7210_codec = NULL;
535
536         return 0;
537 }
538
539 static const struct i2c_device_id da7210_i2c_id[] = {
540         { "da7210", 0 },
541         { }
542 };
543 MODULE_DEVICE_TABLE(i2c, da7210_i2c_id);
544
545 /* I2C codec control layer */
546 static struct i2c_driver da7210_i2c_driver = {
547         .driver = {
548                 .name = "DA7210 I2C Codec",
549                 .owner = THIS_MODULE,
550         },
551         .probe = da7210_i2c_probe,
552         .remove =  __devexit_p(da7210_i2c_remove),
553         .id_table = da7210_i2c_id,
554 };
555 #endif
556
557 static int da7210_probe(struct platform_device *pdev)
558 {
559         struct snd_soc_device *socdev = platform_get_drvdata(pdev);
560         struct snd_soc_codec *codec;
561         int ret;
562
563         if (!da7210_codec) {
564                 dev_err(&pdev->dev, "Codec device not registered\n");
565                 return -ENODEV;
566         }
567
568         socdev->card->codec = da7210_codec;
569         codec = da7210_codec;
570
571         /* Register pcms */
572         ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
573         if (ret < 0)
574                 goto pcm_err;
575
576         dev_info(&pdev->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION);
577
578 pcm_err:
579         return ret;
580 }
581
582 static int da7210_remove(struct platform_device *pdev)
583 {
584         struct snd_soc_device *socdev = platform_get_drvdata(pdev);
585
586         snd_soc_free_pcms(socdev);
587         snd_soc_dapm_free(socdev);
588
589         return 0;
590 }
591
592 struct snd_soc_codec_device soc_codec_dev_da7210 = {
593         .probe =        da7210_probe,
594         .remove =       da7210_remove,
595 };
596 EXPORT_SYMBOL_GPL(soc_codec_dev_da7210);
597
598 static int __init da7210_modinit(void)
599 {
600         int ret = 0;
601 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
602         ret = i2c_add_driver(&da7210_i2c_driver);
603 #endif
604         return ret;
605 }
606 module_init(da7210_modinit);
607
608 static void __exit da7210_exit(void)
609 {
610 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
611         i2c_del_driver(&da7210_i2c_driver);
612 #endif
613 }
614 module_exit(da7210_exit);
615
616 MODULE_DESCRIPTION("ASoC DA7210 driver");
617 MODULE_AUTHOR("David Chen, Kuninori Morimoto");
618 MODULE_LICENSE("GPL");