]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/i2c/chips/tlv320aic23.c
Merge source.mvista.com:linux-omap
[linux-2.6-omap-h63xx.git] / drivers / i2c / chips / tlv320aic23.c
1 /*
2  *   Texas Instrumens TLV320AIC23 audio codec's i2c interface.
3  *
4  *   Copyright (c) by Kai Svahn <kai.svahn@nokia.com>
5  *   Copyright (c) by Jussi Laako <jussi.laako@nokia.com>
6  *
7  *   This program is free software; you can redistribute it and/or modify
8  *   it under the terms of the GNU General Public License as published by
9  *   the Free Software Foundation; either version 2 of the License, or
10  *   (at your option) any later version.
11  *
12  *   This program is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with this program; if not, write to the Free Software
19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20  *
21  */
22
23 #include <linux/config.h>
24 #include <linux/module.h>
25 #include <linux/init.h>
26 #include <linux/i2c.h>
27 #include <linux/slab.h>
28 #include <linux/device.h>
29 #include <linux/platform_device.h>
30 #include <asm/io.h>
31 #include <asm/arch/aic23.h>
32 #include <asm/arch/mcbsp.h>
33
34 #define TLV320AIC23_VERSION     "1.8"
35 #define TLV320AIC23_DATE        "10-Feb-2006"
36 #define MAX_VOL                 100
37 #define MIN_VOL                 0
38 #define MAX_GAIN                100
39 #define MIN_GAIN                0
40 #define OUTPUT_VOLUME_MIN       LHV_MIN
41 #define OUTPUT_VOLUME_MAX       LHV_MAX
42 #define OUTPUT_VOLUME_RANGE     (OUTPUT_VOLUME_MAX - OUTPUT_VOLUME_MIN)
43 #define INPUT_VOLUME_MIN        LIV_MIN
44 #define INPUT_VOLUME_MAX        LIV_MAX
45 #define INPUT_VOLUME_RANGE      (INPUT_VOLUME_MAX - INPUT_VOLUME_MIN)
46
47 /* I2C Addresses to scan */
48 static unsigned short normal_i2c[] = { TLV320AIC23ID1, TLV320AIC23ID2, \
49                                        I2C_CLIENT_END };
50 /*static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };*/
51
52 /* This makes all addr_data:s */
53 I2C_CLIENT_INSMOD;
54
55 static struct i2c_driver aic23_driver;
56 static struct i2c_client *new_client;
57 static int selftest;
58
59 static struct aic23_info {
60         u16 volume_reg_left;
61         u16 volume_reg_right;
62         u16 input_gain_reg_left;
63         u16 input_gain_reg_right;
64         u16 power;                      /* For POWER_DOWN_CONTROL_ADDR */
65         u16 mask;                       /* For ANALOG_AUDIO_CONTROL_ADDR */
66         int mic_loopback;
67         int mic_enable;
68         int sta;
69         int power_down;
70         int initialized;
71 } aic23_info_l;
72
73 static int _aic23_write_value(struct i2c_client *client, u8 reg, u16 value)
74 {
75         u8 val, wreg;
76
77         /* TLV320AIC23 has 7 bit address and 9 bits of data
78          * so we need to switch one data bit into reg and rest
79          * of data into val
80          */
81
82         wreg = (reg << 1);
83         val = (0x01 & (value >> 8));
84         wreg = (wreg | val);
85         val = (0x00ff & value);
86
87         return i2c_smbus_write_byte_data(client, wreg, val);
88 }
89
90 int aic23_write_value(u8 reg, u16 value)
91 {
92         static struct i2c_client *client;
93         client = new_client;
94         _aic23_write_value(client, reg, value);
95
96         return 0;
97 }
98
99 static int aic23_detect_client(struct i2c_adapter *adapter, int address,
100                                      int kind)
101 {
102         int err = 0;
103         const char *client_name = "TLV320AIC23 Audio Codec";
104
105         if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA |
106                                      I2C_FUNC_SMBUS_WRITE_BYTE)) {
107                 printk(KERN_WARNING "%s functinality check failed\n", 
108                        client_name);
109                 return err;
110         }
111
112         if (!(new_client = kmalloc(sizeof(struct i2c_client),
113                                    GFP_KERNEL))) {
114                 err = -ENOMEM;
115                 printk(KERN_WARNING "Couldn't allocate memory for %s\n", 
116                        client_name);
117                 return err;
118         }
119
120         memset(new_client, 0x00, sizeof(struct i2c_client));
121         new_client->addr = address;
122         new_client->adapter = adapter;
123         new_client->driver = &aic23_driver;
124         new_client->flags = 0;
125         strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
126
127         if ((err = i2c_attach_client(new_client))) {
128                 printk(KERN_WARNING "Couldn't attach %s\n", client_name);
129                 kfree(new_client);
130                 return err;
131         }
132         return 0;
133 }
134
135 static int aic23_detach_client(struct i2c_client *client)
136 {
137         int err;
138
139         if ((err = i2c_detach_client(client))) {
140                 printk("aic23.o: Client deregistration failed, \
141                        client not detached.\n");
142                 return err;
143         }
144         kfree(client);
145         return 0;
146 }
147
148 static int aic23_attach_adapter(struct i2c_adapter *adapter)
149 {
150         int res;
151
152         res = i2c_probe(adapter, &addr_data, &aic23_detect_client);
153         return res;
154 }
155
156 static struct i2c_driver aic23_driver = {
157         .driver {
158                 .name   = "OMAP+TLV320AIC23 codec",
159                 /*.flags        = I2C_DF_NOTIFY,*/
160         },
161         .id             = I2C_DRIVERID_MISC, /* Experimental ID */
162         .attach_adapter = aic23_attach_adapter,
163         .detach_client  = aic23_detach_client,
164 };
165
166 /*
167  * Configures the McBSP3 which is used to send clock to the AIC23 codec.
168  * The input clock rate from DSP is 12MHz.
169  * The DSP clock must be on before this is called. 
170  */
171 static int omap_mcbsp3_aic23_clock_init(void)
172 {
173         u16 w;
174
175         /* enable 12MHz clock to mcbsp 1 & 3 */
176         __raw_writew(__raw_readw(DSP_IDLECT2) | (1<<1), DSP_IDLECT2);
177         __raw_writew(__raw_readw(DSP_RSTCT2) | 1 | 1<<1, DSP_RSTCT2);
178
179         /* disable sample rate generator */
180         OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR1, 0x0000);
181         OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, 0x0000);
182
183         /* pin control register */
184         OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, PCR0,(CLKXM | CLKXP | CLKRP));
185
186         /* configure srg to send 12MHz pulse from dsp peripheral clock */
187         OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR1, 0x0000);
188         OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SRGR2, CLKSM);
189
190         /* enable sample rate generator */
191         w = OMAP_MCBSP_READ(OMAP1610_MCBSP3_BASE, SPCR2);
192         OMAP_MCBSP_WRITE(OMAP1610_MCBSP3_BASE, SPCR2, (w | FREE | GRST));
193         printk("Clock enabled to MCBSP1 & 3 \n");
194
195         return 0;
196 }
197
198 static void update_volume_left(int volume)
199 {
200         u16 val = 0;
201         val = ((volume * OUTPUT_VOLUME_RANGE) / 100) + OUTPUT_VOLUME_MIN;
202         aic23_write_value(LEFT_CHANNEL_VOLUME_ADDR, val);
203         aic23_info_l.volume_reg_left = volume;
204 }
205
206 static void update_volume_right(int volume)
207 {
208         u16 val = 0;
209         val = ((volume * OUTPUT_VOLUME_RANGE) / 100) + OUTPUT_VOLUME_MIN;
210         aic23_write_value(RIGHT_CHANNEL_VOLUME_ADDR, val);
211         aic23_info_l.volume_reg_right = volume;
212 }
213
214 static void set_mic(int mic_en)
215 {
216         u16 dg_ctrl;
217
218         if (mic_en) {
219                 aic23_info_l.power = OSC_OFF | LINE_OFF;
220                 dg_ctrl = ADCHP_ON;
221                 aic23_info_l.mask &= ~MICM_MUTED;
222                 aic23_info_l.mask |= MICB_20DB; /* STE_ENABLED */
223         } else {
224                 aic23_info_l.power =
225                         OSC_OFF | ADC_OFF | MIC_OFF | LINE_OFF;
226                 dg_ctrl = 0x00;
227                 aic23_info_l.mask = 
228                         DAC_SELECTED | INSEL_MIC | MICM_MUTED;
229         }
230         aic23_write_value(POWER_DOWN_CONTROL_ADDR,
231                                 aic23_info_l.power);
232         aic23_write_value(DIGITAL_AUDIO_CONTROL_ADDR, dg_ctrl);
233         aic23_write_value(ANALOG_AUDIO_CONTROL_ADDR,
234                                 aic23_info_l.mask);
235         aic23_info_l.mic_enable = mic_en;
236
237         printk(KERN_INFO "aic23 mic state: %i\n", mic_en);
238 }
239
240 static void aic23_init_power(void)
241 {
242         aic23_write_value(RESET_CONTROL_ADDR, 0x00);
243         
244         if (aic23_info_l.initialized == 0) {
245                 aic23_write_value(LEFT_CHANNEL_VOLUME_ADDR, LHV_MIN);
246                 aic23_write_value(RIGHT_CHANNEL_VOLUME_ADDR, LHV_MIN);
247         }
248         else {
249                 update_volume_left(aic23_info_l.volume_reg_left);
250                 update_volume_right(aic23_info_l.volume_reg_right);
251         }
252         
253         aic23_info_l.mask = DAC_SELECTED | INSEL_MIC | MICM_MUTED;
254         aic23_write_value(ANALOG_AUDIO_CONTROL_ADDR,
255                                 aic23_info_l.mask);
256         aic23_write_value(DIGITAL_AUDIO_CONTROL_ADDR, 0x00);
257         aic23_write_value(DIGITAL_AUDIO_FORMAT_ADDR, LRP_ON | FOR_DSP);
258         aic23_write_value(SAMPLE_RATE_CONTROL_ADDR, USB_CLK_ON);
259         aic23_write_value(DIGITAL_INTERFACE_ACT_ADDR, ACT_ON);
260         aic23_info_l.power = OSC_OFF | ADC_OFF | MIC_OFF | LINE_OFF;
261         aic23_write_value(POWER_DOWN_CONTROL_ADDR,
262                                 aic23_info_l.power);
263
264         /* enable mic input */
265         if (aic23_info_l.mic_enable)
266                 set_mic(aic23_info_l.mic_enable);
267
268         printk(KERN_INFO "aic23_init_power() done\n");
269 }
270
271 void aic23_power_down(void)
272 {
273         if (aic23_info_l.initialized) {
274                 printk("aic23 powering down\n");
275                 aic23_write_value(POWER_DOWN_CONTROL_ADDR, 0xff);
276         }
277         aic23_info_l.power_down = 1;
278 }
279
280 void aic23_power_up(void)
281 {
282         if (aic23_info_l.initialized) {
283                 printk("aic23 powering up\n");
284                 aic23_init_power();
285         }
286         aic23_info_l.power_down = 0;
287 }
288
289 /*----------------------------------------------------------------------*/
290 /*                      sysfs initializations                           */
291 /*----------------------------------------------------------------------*/
292
293 static ssize_t store_volume_left(struct device *dev,
294                                  struct device_attribute *attr,
295                                  const char *buf, size_t count)
296 {
297         signed volume;
298
299         sscanf(buf, "%i", &volume);
300
301         if (volume < MIN_VOL) {
302                 aic23_power_down();
303                 return count;
304         } else if (volume > MIN_VOL && aic23_info_l.power_down) {
305                 aic23_info_l.volume_reg_left = volume;
306                 aic23_power_up();
307                 return count;
308         }
309         if (volume > MAX_VOL)
310                 volume = MAX_VOL;
311
312         update_volume_left(volume);
313         return count;
314 }
315
316 static ssize_t show_volume_left(struct device *dev,
317                                 struct device_attribute *attr, char *buf)
318 {
319         return sprintf(buf, "%u\n", aic23_info_l.volume_reg_left);
320 }
321
322 static DEVICE_ATTR(volume_left, S_IRUGO | S_IWUGO,
323                    show_volume_left, store_volume_left);
324
325 static ssize_t store_volume_right(struct device *dev,
326                                   struct device_attribute *attr,
327                                   const char *buf, size_t count)
328 {
329         signed volume;
330
331         sscanf(buf, "%i", &volume);
332         if (volume < MIN_VOL) {
333                 aic23_power_down();
334                 return count;
335         } else if (volume > MIN_VOL && aic23_info_l.power_down) {
336                 aic23_info_l.volume_reg_right = volume;
337                 aic23_power_up();
338                 return count;
339         }
340         if (volume > MAX_VOL)
341                 volume = MAX_VOL;
342
343         update_volume_right(volume);
344         return count;
345 }
346
347 static ssize_t show_volume_right(struct device *dev,
348                                  struct device_attribute *attr, char *buf)
349 {
350         return sprintf(buf, "%u\n", aic23_info_l.volume_reg_right);
351 }
352
353 static DEVICE_ATTR(volume_right, S_IRUGO | S_IWUGO,
354                    show_volume_right, store_volume_right);
355
356 static ssize_t store_gain_left(struct device *dev,
357                                struct device_attribute *attr,
358                                const char *buf, size_t count)
359 {
360         u16 val = 0;
361         unsigned gain;
362
363         sscanf(buf, "%u", &gain);
364         if (gain > MAX_VOL)
365                 gain = MAX_VOL;
366
367         val = ((gain * INPUT_VOLUME_RANGE) / 100) + INPUT_VOLUME_MIN;
368         aic23_write_value(LEFT_LINE_VOLUME_ADDR, val);
369         aic23_info_l.input_gain_reg_left = gain;
370
371         return count;
372 }
373
374 static ssize_t show_gain_left(struct device *dev,
375                               struct device_attribute *attr, char *buf)
376 {
377         return sprintf(buf, "%u\n", aic23_info_l.input_gain_reg_left);
378 }
379
380 static DEVICE_ATTR(gain_left, S_IRUGO | S_IWUSR, show_gain_left,
381                    store_gain_left);
382
383 static ssize_t store_gain_right(struct device *dev,
384                                 struct device_attribute *attr,
385                                 const char *buf, size_t count)
386 {
387         u16 val = 0;
388         unsigned gain;
389
390         sscanf(buf, "%u", &gain);
391         if (gain > MAX_VOL)
392                 gain = MAX_VOL;
393
394         val = ((gain * INPUT_VOLUME_RANGE) / 100) + INPUT_VOLUME_MIN;
395         aic23_write_value(RIGHT_LINE_VOLUME_ADDR, val);
396         aic23_info_l.input_gain_reg_right = gain;
397
398         return count;
399 }
400
401 static ssize_t show_gain_right(struct device *dev,
402                                struct device_attribute *attr, char *buf)
403 {
404         return sprintf(buf, "%u\n", aic23_info_l.input_gain_reg_right);
405 }
406
407 static DEVICE_ATTR(gain_right, S_IRUGO | S_IWUSR, show_gain_right,
408                    store_gain_right);
409
410 static ssize_t store_mic_loopback(struct device *dev,
411                                   struct device_attribute *attr,
412                                   const char *buf, size_t count)
413 {
414         int mic;
415
416         sscanf(buf, "%i", &mic);
417         if (mic > 0) {
418                 aic23_write_value(POWER_DOWN_CONTROL_ADDR, \
419                                         OSC_OFF | ADC_OFF | LINE_OFF);
420                 aic23_info_l.mask = STE_ENABLED | DAC_SELECTED \
421                                           | INSEL_MIC | MICB_20DB;
422                 aic23_write_value(ANALOG_AUDIO_CONTROL_ADDR, 
423                                         aic23_info_l.mask);
424                 mic = 1;
425         }
426         else {
427                 aic23_write_value(POWER_DOWN_CONTROL_ADDR, \
428                                         OSC_OFF | ADC_OFF | MIC_OFF | LINE_OFF);
429                 mic = 0;
430         }
431         aic23_info_l.mic_loopback = mic;
432
433         return count;
434 }
435
436 static ssize_t show_mic_loopback(struct device *dev,
437                                  struct device_attribute *attr, char *buf)
438 {
439         return sprintf(buf, "%i\n", aic23_info_l.mic_loopback);
440 }
441
442 static DEVICE_ATTR(mic_loopback, S_IRUGO | S_IWUSR,
443                    show_mic_loopback, store_mic_loopback);
444
445 static ssize_t store_st_attenuation(struct device *dev,
446                                     struct device_attribute *attr,
447                                     const char *buf, size_t count)
448 {
449         unsigned sta;
450         u16 tmp;
451
452         sscanf(buf, "%u", &sta);
453         if (sta > 3)
454                 sta = 3;
455
456         tmp = aic23_info_l.mask;
457         tmp &= 0x3f;
458
459         aic23_info_l.mask =  tmp | STA_REG(sta);
460         aic23_write_value(ANALOG_AUDIO_CONTROL_ADDR,
461                                 aic23_info_l.mask);
462         aic23_info_l.sta = sta;
463
464         return count;
465 }
466
467 static ssize_t show_st_attenuation(struct device *dev,
468                                    struct device_attribute *attr, char *buf)
469 {
470         return sprintf(buf, "%i\n", aic23_info_l.sta);
471 }
472
473 static DEVICE_ATTR(st_attenuation, S_IRUGO | S_IWUSR,
474                    show_st_attenuation, store_st_attenuation);
475
476 static ssize_t store_mic_enable(struct device *dev,
477                                 struct device_attribute *attr,
478                                 const char *buf, size_t count)
479 {
480         int mic;
481
482         sscanf(buf, "%i", &mic);
483         set_mic(mic);
484
485         return count;
486 }
487
488 static ssize_t show_mic_enable(struct device *dev,
489                                struct device_attribute *attr, char *buf)
490 {
491         return sprintf(buf, "%i\n", aic23_info_l.mic_enable);
492 }
493
494 static DEVICE_ATTR(mic_enable, S_IRUGO | S_IWUSR,
495         show_mic_enable, store_mic_enable);
496
497 static ssize_t show_audio_selftest(struct device *dev,
498                                    struct device_attribute *attr, char *buf)
499 {
500         return sprintf(buf, "%i\n", selftest);
501 }
502
503 static DEVICE_ATTR(audio_selftest, S_IRUGO | S_IWUSR,
504                 show_audio_selftest, NULL);
505
506 static int audio_i2c_probe(struct platform_device *dev)
507 {
508         int r;
509
510         if ((r = device_create_file(&dev->dev, &dev_attr_volume_left)) != 0)
511                 return r;
512         else if ((r = device_create_file(&dev->dev,
513                 &dev_attr_volume_right)) != 0)
514                 goto err_volume_left;
515         else if ((r = device_create_file(&dev->dev,
516                 &dev_attr_gain_right)) != 0)
517                 goto err_volume_right;
518         else if ((r = device_create_file(&dev->dev,
519                 &dev_attr_gain_left)) != 0)
520                 goto err_gain_right;
521         else if ((r = device_create_file(&dev->dev,
522                 &dev_attr_mic_loopback)) != 0)
523                 goto err_gain_left;
524         else if ((r = device_create_file(&dev->dev,
525                 &dev_attr_mic_enable)) != 0)
526                 goto err_mic_loopback;
527         else if ((r = device_create_file(&dev->dev,
528                 &dev_attr_st_attenuation)) != 0)
529                 goto err_mic_enable;
530         else if ((r = device_create_file(&dev->dev,
531                 &dev_attr_audio_selftest)) != 0)
532                 goto err_st_attenuation;
533         else
534                 return r;
535
536 err_st_attenuation:
537         device_remove_file(&dev->dev, &dev_attr_st_attenuation);
538 err_mic_enable:
539         device_remove_file(&dev->dev, &dev_attr_mic_enable);
540 err_mic_loopback:
541         device_remove_file(&dev->dev, &dev_attr_mic_loopback);
542 err_gain_left:
543         device_remove_file(&dev->dev, &dev_attr_gain_left);
544 err_gain_right:
545         device_remove_file(&dev->dev, &dev_attr_gain_right);
546 err_volume_right:
547         device_remove_file(&dev->dev, &dev_attr_volume_right);
548 err_volume_left:
549         device_remove_file(&dev->dev, &dev_attr_volume_left);
550
551         return r;
552 }
553
554 static int audio_i2c_remove(struct platform_device *dev)
555 {
556         device_remove_file(&dev->dev, &dev_attr_st_attenuation);
557         device_remove_file(&dev->dev, &dev_attr_mic_enable);
558         device_remove_file(&dev->dev, &dev_attr_mic_loopback);
559         device_remove_file(&dev->dev, &dev_attr_gain_left);
560         device_remove_file(&dev->dev, &dev_attr_gain_right);
561         device_remove_file(&dev->dev, &dev_attr_volume_right);
562         device_remove_file(&dev->dev, &dev_attr_volume_left);
563
564         return 0;
565 }
566
567 /*----------------------------------------------------------------*/
568 /*                      PM functions                              */
569 /*----------------------------------------------------------------*/
570
571 static void audio_i2c_shutdown(struct platform_device *dev)
572 {
573         /* Let's mute the codec before powering off to prevent
574         * glitch in the sound
575         */
576         aic23_write_value(LEFT_CHANNEL_VOLUME_ADDR, LHV_MIN);
577         aic23_write_value(RIGHT_CHANNEL_VOLUME_ADDR, LHV_MIN);
578         aic23_power_down();
579 }
580
581 static int audio_i2c_suspend(struct platform_device *dev, pm_message_t state)
582 {
583         /* Let's mute the codec before powering off to prevent
584          * glitch in the sound
585          */
586         aic23_write_value(LEFT_CHANNEL_VOLUME_ADDR, LHV_MIN);
587         aic23_write_value(RIGHT_CHANNEL_VOLUME_ADDR, LHV_MIN);
588         aic23_power_down();
589
590         return 0;
591 }
592
593 static int audio_i2c_resume(struct platform_device *dev)
594 {
595         aic23_power_up();
596
597         return 0;
598 }
599
600 static struct platform_driver audio_i2c_driver = {
601         .driver = {
602                 .owner  = THIS_MODULE,
603                 .name   = "audio-i2c",
604         },
605         .shutdown       = audio_i2c_shutdown,
606         .probe          = audio_i2c_probe,
607         .remove         = audio_i2c_remove,
608         .suspend        = audio_i2c_suspend,
609         .resume         = audio_i2c_resume,
610 };
611
612 static struct platform_device audio_i2c_device = {
613         .name           = "audio-i2c",
614         .id             = -1,
615 };
616
617 /*----------------------------------------------------------------*/
618
619 static int __init aic23_init(void)
620 {
621         selftest =  0;
622         aic23_info_l.initialized = 0;
623
624         if (i2c_add_driver(&aic23_driver)) {
625                 printk("aic23 i2c: Driver registration failed, \
626                       module not inserted.\n");
627                 selftest = -ENODEV;
628                 return selftest;
629         }
630
631         if (platform_driver_register(&audio_i2c_driver)) {
632                 printk(KERN_WARNING "Failed to register audio i2c driver\n");
633                 selftest = -ENODEV;
634                 return selftest;
635         }
636
637         if (platform_device_register(&audio_i2c_device)) {
638                 printk(KERN_WARNING "Failed to register audio i2c device\n");
639                 platform_driver_unregister(&audio_i2c_driver);
640                 selftest = -ENODEV;
641                 return selftest;
642         }
643         /* FIXME: Do in board-specific file */
644         omap_mcbsp3_aic23_clock_init();
645         if (!aic23_info_l.power_down)
646                 aic23_power_up();
647         aic23_info_l.initialized = 1;
648         printk("TLV320AIC23 I2C version %s (%s)\n", 
649                TLV320AIC23_VERSION, TLV320AIC23_DATE);
650
651         return selftest;
652 }
653
654 static void __exit aic23_exit(void)
655 {
656         int res;
657
658         aic23_power_down();
659         if ((res = i2c_del_driver(&aic23_driver))) 
660                 printk("aic23 i2c: Driver remove failed, module not removed.\n");
661
662         platform_device_unregister(&audio_i2c_device);
663         platform_driver_unregister(&audio_i2c_driver);
664 }
665
666 MODULE_AUTHOR("Kai Svahn <kai.svahn@nokia.com>");
667 MODULE_DESCRIPTION("I2C interface for TLV320AIC23 codec.");
668 MODULE_LICENSE("GPL");
669
670 module_init(aic23_init)
671 module_exit(aic23_exit)
672
673 EXPORT_SYMBOL(aic23_write_value);
674 EXPORT_SYMBOL(aic23_power_up);
675 EXPORT_SYMBOL(aic23_power_down);