| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Texas Instruments TLV320AIC26 low power audio CODEC | 2 * Texas Instruments TLV320AIC26 low power audio CODEC |
| 3 * ALSA SoC CODEC driver | 3 * ALSA SoC CODEC driver |
| 4 * | 4 * |
| 5 * Copyright (C) 2008 Secret Lab Technologies Ltd. | 5 * Copyright (C) 2008 Secret Lab Technologies Ltd. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include <linux/module.h> | 8 #include <linux/module.h> |
| 9 #include <linux/moduleparam.h> | 9 #include <linux/moduleparam.h> |
| 10 #include <linux/init.h> | 10 #include <linux/init.h> |
| 11 #include <linux/delay.h> | 11 #include <linux/delay.h> |
| 12 #include <linux/pm.h> | 12 #include <linux/pm.h> |
| 13 #include <linux/device.h> | 13 #include <linux/device.h> |
| 14 #include <linux/sysfs.h> | 14 #include <linux/sysfs.h> |
| 15 #include <linux/spi/spi.h> | 15 #include <linux/spi/spi.h> |
| 16 #include <linux/slab.h> | 16 #include <linux/slab.h> |
| 17 #include <sound/core.h> | 17 #include <sound/core.h> |
| 18 #include <sound/pcm.h> | 18 #include <sound/pcm.h> |
| 19 #include <sound/pcm_params.h> | 19 #include <sound/pcm_params.h> |
| 20 #include <sound/soc.h> | 20 #include <sound/soc.h> |
| 21 #include <sound/soc-dapm.h> | |
| 22 #include <sound/initval.h> | 21 #include <sound/initval.h> |
| 23 | 22 |
| 24 #include "tlv320aic26.h" | 23 #include "tlv320aic26.h" |
| 25 | 24 |
| 26 MODULE_DESCRIPTION("ASoC TLV320AIC26 codec driver"); | 25 MODULE_DESCRIPTION("ASoC TLV320AIC26 codec driver"); |
| 27 MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); | 26 MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>"); |
| 28 MODULE_LICENSE("GPL"); | 27 MODULE_LICENSE("GPL"); |
| 29 | 28 |
| 30 /* AIC26 driver private data */ | 29 /* AIC26 driver private data */ |
| 31 struct aic26 { | 30 struct aic26 { |
| 32 struct spi_device *spi; | 31 struct spi_device *spi; |
| 33 struct snd_soc_codec codec; | 32 struct snd_soc_codec codec; |
| 34 u16 reg_cache[AIC26_NUM_REGS]; /* shadow registers */ | |
| 35 int master; | 33 int master; |
| 36 int datfm; | 34 int datfm; |
| 37 int mclk; | 35 int mclk; |
| 38 | 36 |
| 39 /* Keyclick parameters */ | 37 /* Keyclick parameters */ |
| 40 int keyclick_amplitude; | 38 int keyclick_amplitude; |
| 41 int keyclick_freq; | 39 int keyclick_freq; |
| 42 int keyclick_len; | 40 int keyclick_len; |
| 43 }; | 41 }; |
| 44 | 42 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 return count; | 346 return count; |
| 349 } | 347 } |
| 350 | 348 |
| 351 static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set); | 349 static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set); |
| 352 | 350 |
| 353 /* --------------------------------------------------------------------- | 351 /* --------------------------------------------------------------------- |
| 354 * SoC CODEC portion of driver: probe and release routines | 352 * SoC CODEC portion of driver: probe and release routines |
| 355 */ | 353 */ |
| 356 static int aic26_probe(struct snd_soc_codec *codec) | 354 static int aic26_probe(struct snd_soc_codec *codec) |
| 357 { | 355 { |
| 358 struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | |
| 359 int ret, err, i, reg; | 356 int ret, err, i, reg; |
| 360 | 357 |
| 361 dev_info(codec->dev, "Probing AIC26 SoC CODEC driver\n"); | 358 dev_info(codec->dev, "Probing AIC26 SoC CODEC driver\n"); |
| 362 | 359 |
| 363 /* Reset the codec to power on defaults */ | 360 /* Reset the codec to power on defaults */ |
| 364 aic26_reg_write(codec, AIC26_REG_RESET, 0xBB00); | 361 aic26_reg_write(codec, AIC26_REG_RESET, 0xBB00); |
| 365 | 362 |
| 366 /* Power up CODEC */ | 363 /* Power up CODEC */ |
| 367 aic26_reg_write(codec, AIC26_REG_POWER_CTRL, 0); | 364 aic26_reg_write(codec, AIC26_REG_POWER_CTRL, 0); |
| 368 | 365 |
| 369 /* Audio Control 3 (master mode, fsref rate) */ | 366 /* Audio Control 3 (master mode, fsref rate) */ |
| 370 reg = aic26_reg_read(codec, AIC26_REG_AUDIO_CTRL3); | 367 reg = aic26_reg_read(codec, AIC26_REG_AUDIO_CTRL3); |
| 371 reg &= ~0xf800; | 368 reg &= ~0xf800; |
| 372 reg |= 0x0800; /* set master mode */ | 369 reg |= 0x0800; /* set master mode */ |
| 373 aic26_reg_write(codec, AIC26_REG_AUDIO_CTRL3, reg); | 370 aic26_reg_write(codec, AIC26_REG_AUDIO_CTRL3, reg); |
| 374 | 371 |
| 375 /* Fill register cache */ | 372 /* Fill register cache */ |
| 376 » for (i = 0; i < ARRAY_SIZE(aic26->reg_cache); i++) | 373 » for (i = 0; i < codec->driver->reg_cache_size; i++) |
| 377 aic26_reg_read(codec, i); | 374 aic26_reg_read(codec, i); |
| 378 | 375 |
| 379 /* Register the sysfs files for debugging */ | 376 /* Register the sysfs files for debugging */ |
| 380 /* Create SysFS files */ | 377 /* Create SysFS files */ |
| 381 ret = device_create_file(codec->dev, &dev_attr_keyclick); | 378 ret = device_create_file(codec->dev, &dev_attr_keyclick); |
| 382 if (ret) | 379 if (ret) |
| 383 dev_info(codec->dev, "error creating sysfs files\n"); | 380 dev_info(codec->dev, "error creating sysfs files\n"); |
| 384 | 381 |
| 385 /* register controls */ | 382 /* register controls */ |
| 386 dev_dbg(codec->dev, "Registering controls\n"); | 383 dev_dbg(codec->dev, "Registering controls\n"); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 { | 447 { |
| 451 return spi_register_driver(&aic26_spi); | 448 return spi_register_driver(&aic26_spi); |
| 452 } | 449 } |
| 453 module_init(aic26_init); | 450 module_init(aic26_init); |
| 454 | 451 |
| 455 static void __exit aic26_exit(void) | 452 static void __exit aic26_exit(void) |
| 456 { | 453 { |
| 457 spi_unregister_driver(&aic26_spi); | 454 spi_unregister_driver(&aic26_spi); |
| 458 } | 455 } |
| 459 module_exit(aic26_exit); | 456 module_exit(aic26_exit); |
| OLD | NEW |