| OLD | NEW |
| 1 /* | 1 /* |
| 2 * wm8804.c -- WM8804 S/PDIF transceiver driver | 2 * wm8804.c -- WM8804 S/PDIF transceiver driver |
| 3 * | 3 * |
| 4 * Copyright 2010 Wolfson Microelectronics plc | 4 * Copyright 2010 Wolfson Microelectronics plc |
| 5 * | 5 * |
| 6 * Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> | 6 * Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> |
| 7 * | 7 * |
| 8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
| 9 * it under the terms of the GNU General Public License version 2 as | 9 * it under the terms of the GNU General Public License version 2 as |
| 10 * published by the Free Software Foundation. | 10 * published by the Free Software Foundation. |
| 11 */ | 11 */ |
| 12 | 12 |
| 13 #include <linux/module.h> | 13 #include <linux/module.h> |
| 14 #include <linux/moduleparam.h> | 14 #include <linux/moduleparam.h> |
| 15 #include <linux/init.h> | 15 #include <linux/init.h> |
| 16 #include <linux/delay.h> | 16 #include <linux/delay.h> |
| 17 #include <linux/pm.h> | 17 #include <linux/pm.h> |
| 18 #include <linux/i2c.h> | 18 #include <linux/i2c.h> |
| 19 #include <linux/spi/spi.h> | 19 #include <linux/spi/spi.h> |
| 20 #include <linux/regulator/consumer.h> | 20 #include <linux/regulator/consumer.h> |
| 21 #include <linux/slab.h> | 21 #include <linux/slab.h> |
| 22 #include <sound/core.h> | 22 #include <sound/core.h> |
| 23 #include <sound/pcm.h> | 23 #include <sound/pcm.h> |
| 24 #include <sound/pcm_params.h> | 24 #include <sound/pcm_params.h> |
| 25 #include <sound/soc.h> | 25 #include <sound/soc.h> |
| 26 #include <sound/soc-dapm.h> | |
| 27 #include <sound/initval.h> | 26 #include <sound/initval.h> |
| 28 #include <sound/tlv.h> | 27 #include <sound/tlv.h> |
| 29 | 28 |
| 30 #include "wm8804.h" | 29 #include "wm8804.h" |
| 31 | 30 |
| 32 #define WM8804_NUM_SUPPLIES 2 | 31 #define WM8804_NUM_SUPPLIES 2 |
| 33 static const char *wm8804_supply_names[WM8804_NUM_SUPPLIES] = { | 32 static const char *wm8804_supply_names[WM8804_NUM_SUPPLIES] = { |
| 34 "PVDD", | 33 "PVDD", |
| 35 "DVDD" | 34 "DVDD" |
| 36 }; | 35 }; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 /* power up the receiver */ | 168 /* power up the receiver */ |
| 170 snd_soc_update_bits(codec, WM8804_PWRDN, 0x2, 0); | 169 snd_soc_update_bits(codec, WM8804_PWRDN, 0x2, 0); |
| 171 } | 170 } |
| 172 | 171 |
| 173 /* restore the transmitter's configuration */ | 172 /* restore the transmitter's configuration */ |
| 174 snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, txpwr); | 173 snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, txpwr); |
| 175 | 174 |
| 176 return 0; | 175 return 0; |
| 177 } | 176 } |
| 178 | 177 |
| 179 static int wm8804_volatile(unsigned int reg) | 178 static int wm8804_volatile(struct snd_soc_codec *codec, unsigned int reg) |
| 180 { | 179 { |
| 181 switch (reg) { | 180 switch (reg) { |
| 182 case WM8804_RST_DEVID1: | 181 case WM8804_RST_DEVID1: |
| 183 case WM8804_DEVID2: | 182 case WM8804_DEVID2: |
| 184 case WM8804_DEVREV: | 183 case WM8804_DEVREV: |
| 185 case WM8804_INTSTAT: | 184 case WM8804_INTSTAT: |
| 186 case WM8804_SPDSTAT: | 185 case WM8804_SPDSTAT: |
| 187 case WM8804_RXCHAN1: | 186 case WM8804_RXCHAN1: |
| 188 case WM8804_RXCHAN2: | 187 case WM8804_RXCHAN2: |
| 189 case WM8804_RXCHAN3: | 188 case WM8804_RXCHAN3: |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 | 507 |
| 509 wm8804 = snd_soc_codec_get_drvdata(codec); | 508 wm8804 = snd_soc_codec_get_drvdata(codec); |
| 510 switch (level) { | 509 switch (level) { |
| 511 case SND_SOC_BIAS_ON: | 510 case SND_SOC_BIAS_ON: |
| 512 break; | 511 break; |
| 513 case SND_SOC_BIAS_PREPARE: | 512 case SND_SOC_BIAS_PREPARE: |
| 514 /* power up the OSC and the PLL */ | 513 /* power up the OSC and the PLL */ |
| 515 snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0); | 514 snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0); |
| 516 break; | 515 break; |
| 517 case SND_SOC_BIAS_STANDBY: | 516 case SND_SOC_BIAS_STANDBY: |
| 518 » » if (codec->bias_level == SND_SOC_BIAS_OFF) { | 517 » » if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
| 519 ret = regulator_bulk_enable(ARRAY_SIZE(wm8804->supplies)
, | 518 ret = regulator_bulk_enable(ARRAY_SIZE(wm8804->supplies)
, |
| 520 wm8804->supplies); | 519 wm8804->supplies); |
| 521 if (ret) { | 520 if (ret) { |
| 522 dev_err(codec->dev, | 521 dev_err(codec->dev, |
| 523 "Failed to enable supplies: %d\n", | 522 "Failed to enable supplies: %d\n", |
| 524 ret); | 523 ret); |
| 525 return ret; | 524 return ret; |
| 526 } | 525 } |
| 527 wm8804_sync_cache(codec); | 526 wm8804_sync_cache(codec); |
| 528 } | 527 } |
| 529 /* power down the OSC and the PLL */ | 528 /* power down the OSC and the PLL */ |
| 530 snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0x9); | 529 snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0x9); |
| 531 break; | 530 break; |
| 532 case SND_SOC_BIAS_OFF: | 531 case SND_SOC_BIAS_OFF: |
| 533 /* power down the OSC and the PLL */ | 532 /* power down the OSC and the PLL */ |
| 534 snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0x9); | 533 snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0x9); |
| 535 regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), | 534 regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), |
| 536 wm8804->supplies); | 535 wm8804->supplies); |
| 537 break; | 536 break; |
| 538 } | 537 } |
| 539 | 538 |
| 540 » codec->bias_level = level; | 539 » codec->dapm.bias_level = level; |
| 541 return 0; | 540 return 0; |
| 542 } | 541 } |
| 543 | 542 |
| 544 #ifdef CONFIG_PM | 543 #ifdef CONFIG_PM |
| 545 static int wm8804_suspend(struct snd_soc_codec *codec, pm_message_t state) | 544 static int wm8804_suspend(struct snd_soc_codec *codec, pm_message_t state) |
| 546 { | 545 { |
| 547 wm8804_set_bias_level(codec, SND_SOC_BIAS_OFF); | 546 wm8804_set_bias_level(codec, SND_SOC_BIAS_OFF); |
| 548 return 0; | 547 return 0; |
| 549 } | 548 } |
| 550 | 549 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 574 } | 573 } |
| 575 | 574 |
| 576 static int wm8804_probe(struct snd_soc_codec *codec) | 575 static int wm8804_probe(struct snd_soc_codec *codec) |
| 577 { | 576 { |
| 578 struct wm8804_priv *wm8804; | 577 struct wm8804_priv *wm8804; |
| 579 int i, id1, id2, ret; | 578 int i, id1, id2, ret; |
| 580 | 579 |
| 581 wm8804 = snd_soc_codec_get_drvdata(codec); | 580 wm8804 = snd_soc_codec_get_drvdata(codec); |
| 582 wm8804->codec = codec; | 581 wm8804->codec = codec; |
| 583 | 582 |
| 584 » codec->idle_bias_off = 1; | 583 » codec->dapm.idle_bias_off = 1; |
| 585 | 584 |
| 586 ret = snd_soc_codec_set_cache_io(codec, 8, 8, wm8804->control_type); | 585 ret = snd_soc_codec_set_cache_io(codec, 8, 8, wm8804->control_type); |
| 587 if (ret < 0) { | 586 if (ret < 0) { |
| 588 dev_err(codec->dev, "Failed to set cache i/o: %d\n", ret); | 587 dev_err(codec->dev, "Failed to set cache i/o: %d\n", ret); |
| 589 return ret; | 588 return ret; |
| 590 } | 589 } |
| 591 | 590 |
| 592 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++) | 591 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++) |
| 593 wm8804->supplies[i].supply = wm8804_supply_names[i]; | 592 wm8804->supplies[i].supply = wm8804_supply_names[i]; |
| 594 | 593 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 #endif | 823 #endif |
| 825 #if defined(CONFIG_SPI_MASTER) | 824 #if defined(CONFIG_SPI_MASTER) |
| 826 spi_unregister_driver(&wm8804_spi_driver); | 825 spi_unregister_driver(&wm8804_spi_driver); |
| 827 #endif | 826 #endif |
| 828 } | 827 } |
| 829 module_exit(wm8804_exit); | 828 module_exit(wm8804_exit); |
| 830 | 829 |
| 831 MODULE_DESCRIPTION("ASoC WM8804 driver"); | 830 MODULE_DESCRIPTION("ASoC WM8804 driver"); |
| 832 MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>"); | 831 MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>"); |
| 833 MODULE_LICENSE("GPL"); | 832 MODULE_LICENSE("GPL"); |
| OLD | NEW |