| OLD | NEW |
| 1 /* | 1 /* |
| 2 * wm8741.c -- WM8741 ALSA SoC Audio driver | 2 * wm8741.c -- WM8741 ALSA SoC Audio driver |
| 3 * | 3 * |
| 4 * Copyright 2010 Wolfson Microelectronics plc | 4 * Copyright 2010 Wolfson Microelectronics plc |
| 5 * | 5 * |
| 6 * Author: Ian Lartey <ian@opensource.wolfsonmicro.com> | 6 * Author: Ian Lartey <ian@opensource.wolfsonmicro.com> |
| 7 * | 7 * |
| 8 * | 8 * |
| 9 * This program is free software; you can redistribute it and/or modify | 9 * This program is free software; you can redistribute it and/or modify |
| 10 * it under the terms of the GNU General Public License version 2 as | 10 * it under the terms of the GNU General Public License version 2 as |
| 11 * published by the Free Software Foundation. | 11 * published by the Free Software Foundation. |
| 12 */ | 12 */ |
| 13 | 13 |
| 14 #include <linux/module.h> | 14 #include <linux/module.h> |
| 15 #include <linux/moduleparam.h> | 15 #include <linux/moduleparam.h> |
| 16 #include <linux/init.h> | 16 #include <linux/init.h> |
| 17 #include <linux/delay.h> | 17 #include <linux/delay.h> |
| 18 #include <linux/pm.h> | 18 #include <linux/pm.h> |
| 19 #include <linux/i2c.h> | 19 #include <linux/i2c.h> |
| 20 #include <linux/platform_device.h> | 20 #include <linux/platform_device.h> |
| 21 #include <linux/regulator/consumer.h> | 21 #include <linux/regulator/consumer.h> |
| 22 #include <linux/slab.h> | 22 #include <linux/slab.h> |
| 23 #include <sound/core.h> | 23 #include <sound/core.h> |
| 24 #include <sound/pcm.h> | 24 #include <sound/pcm.h> |
| 25 #include <sound/pcm_params.h> | 25 #include <sound/pcm_params.h> |
| 26 #include <sound/soc.h> | 26 #include <sound/soc.h> |
| 27 #include <sound/soc-dapm.h> | |
| 28 #include <sound/initval.h> | 27 #include <sound/initval.h> |
| 29 #include <sound/tlv.h> | 28 #include <sound/tlv.h> |
| 30 | 29 |
| 31 #include "wm8741.h" | 30 #include "wm8741.h" |
| 32 | 31 |
| 33 #define WM8741_NUM_SUPPLIES 2 | 32 #define WM8741_NUM_SUPPLIES 2 |
| 34 static const char *wm8741_supply_names[WM8741_NUM_SUPPLIES] = { | 33 static const char *wm8741_supply_names[WM8741_NUM_SUPPLIES] = { |
| 35 "AVDD", | 34 "AVDD", |
| 36 "DVDD", | 35 "DVDD", |
| 37 }; | 36 }; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 86 |
| 88 static const struct snd_soc_dapm_route intercon[] = { | 87 static const struct snd_soc_dapm_route intercon[] = { |
| 89 { "VOUTLP", NULL, "DACL" }, | 88 { "VOUTLP", NULL, "DACL" }, |
| 90 { "VOUTLN", NULL, "DACL" }, | 89 { "VOUTLN", NULL, "DACL" }, |
| 91 { "VOUTRP", NULL, "DACR" }, | 90 { "VOUTRP", NULL, "DACR" }, |
| 92 { "VOUTRN", NULL, "DACR" }, | 91 { "VOUTRN", NULL, "DACR" }, |
| 93 }; | 92 }; |
| 94 | 93 |
| 95 static int wm8741_add_widgets(struct snd_soc_codec *codec) | 94 static int wm8741_add_widgets(struct snd_soc_codec *codec) |
| 96 { | 95 { |
| 97 » snd_soc_dapm_new_controls(codec, wm8741_dapm_widgets, | 96 » struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 97 |
| 98 » snd_soc_dapm_new_controls(dapm, wm8741_dapm_widgets, |
| 98 ARRAY_SIZE(wm8741_dapm_widgets)); | 99 ARRAY_SIZE(wm8741_dapm_widgets)); |
| 99 | 100 » snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon)); |
| 100 » snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon)); | |
| 101 | 101 |
| 102 return 0; | 102 return 0; |
| 103 } | 103 } |
| 104 | 104 |
| 105 static struct { | 105 static struct { |
| 106 int value; | 106 int value; |
| 107 int ratio; | 107 int ratio; |
| 108 } lrclk_ratios[WM8741_NUM_RATES] = { | 108 } lrclk_ratios[WM8741_NUM_RATES] = { |
| 109 { 1, 128 }, | 109 { 1, 128 }, |
| 110 { 2, 192 }, | 110 { 2, 192 }, |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 return 0; | 414 return 0; |
| 415 } | 415 } |
| 416 #else | 416 #else |
| 417 #define wm8741_suspend NULL | 417 #define wm8741_suspend NULL |
| 418 #define wm8741_resume NULL | 418 #define wm8741_resume NULL |
| 419 #endif | 419 #endif |
| 420 | 420 |
| 421 static int wm8741_probe(struct snd_soc_codec *codec) | 421 static int wm8741_probe(struct snd_soc_codec *codec) |
| 422 { | 422 { |
| 423 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); | 423 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); |
| 424 u16 *reg_cache = codec->reg_cache; | |
| 425 int ret = 0; | 424 int ret = 0; |
| 426 | 425 |
| 427 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8741->control_type); | 426 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8741->control_type); |
| 428 if (ret != 0) { | 427 if (ret != 0) { |
| 429 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 428 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
| 430 return ret; | 429 return ret; |
| 431 } | 430 } |
| 432 | 431 |
| 433 ret = wm8741_reset(codec); | 432 ret = wm8741_reset(codec); |
| 434 if (ret < 0) { | 433 if (ret < 0) { |
| 435 dev_err(codec->dev, "Failed to issue reset\n"); | 434 dev_err(codec->dev, "Failed to issue reset\n"); |
| 436 return ret; | 435 return ret; |
| 437 } | 436 } |
| 438 | 437 |
| 439 /* Change some default settings - latch VU */ | 438 /* Change some default settings - latch VU */ |
| 440 » reg_cache[WM8741_DACLLSB_ATTENUATION] |= WM8741_UPDATELL; | 439 » snd_soc_update_bits(codec, WM8741_DACLLSB_ATTENUATION, |
| 441 » reg_cache[WM8741_DACLMSB_ATTENUATION] |= WM8741_UPDATELM; | 440 » » » WM8741_UPDATELL, WM8741_UPDATELL); |
| 442 » reg_cache[WM8741_DACRLSB_ATTENUATION] |= WM8741_UPDATERL; | 441 » snd_soc_update_bits(codec, WM8741_DACLMSB_ATTENUATION, |
| 443 » reg_cache[WM8741_DACRLSB_ATTENUATION] |= WM8741_UPDATERM; | 442 » » » WM8741_UPDATELM, WM8741_UPDATELM); |
| 443 » snd_soc_update_bits(codec, WM8741_DACRLSB_ATTENUATION, |
| 444 » » » WM8741_UPDATERL, WM8741_UPDATERL); |
| 445 » snd_soc_update_bits(codec, WM8741_DACRLSB_ATTENUATION, |
| 446 » » » WM8741_UPDATERM, WM8741_UPDATERM); |
| 444 | 447 |
| 445 snd_soc_add_controls(codec, wm8741_snd_controls, | 448 snd_soc_add_controls(codec, wm8741_snd_controls, |
| 446 ARRAY_SIZE(wm8741_snd_controls)); | 449 ARRAY_SIZE(wm8741_snd_controls)); |
| 447 wm8741_add_widgets(codec); | 450 wm8741_add_widgets(codec); |
| 448 | 451 |
| 449 dev_dbg(codec->dev, "Successful registration\n"); | 452 dev_dbg(codec->dev, "Successful registration\n"); |
| 450 return ret; | 453 return ret; |
| 451 } | 454 } |
| 452 | 455 |
| 453 static struct snd_soc_codec_driver soc_codec_dev_wm8741 = { | 456 static struct snd_soc_codec_driver soc_codec_dev_wm8741 = { |
| 454 .probe = wm8741_probe, | 457 .probe = wm8741_probe, |
| 455 .resume = wm8741_resume, | 458 .resume = wm8741_resume, |
| 456 .reg_cache_size = ARRAY_SIZE(wm8741_reg_defaults), | 459 .reg_cache_size = ARRAY_SIZE(wm8741_reg_defaults), |
| 457 .reg_word_size = sizeof(u16), | 460 .reg_word_size = sizeof(u16), |
| 458 » .reg_cache_default = &wm8741_reg_defaults, | 461 » .reg_cache_default = wm8741_reg_defaults, |
| 459 }; | 462 }; |
| 460 | 463 |
| 461 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 464 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 462 static int wm8741_i2c_probe(struct i2c_client *i2c, | 465 static int wm8741_i2c_probe(struct i2c_client *i2c, |
| 463 const struct i2c_device_id *id) | 466 const struct i2c_device_id *id) |
| 464 { | 467 { |
| 465 struct wm8741_priv *wm8741; | 468 struct wm8741_priv *wm8741; |
| 466 int ret, i; | 469 int ret, i; |
| 467 | 470 |
| 468 wm8741 = kzalloc(sizeof(struct wm8741_priv), GFP_KERNEL); | 471 wm8741 = kzalloc(sizeof(struct wm8741_priv), GFP_KERNEL); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 { | 553 { |
| 551 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 554 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 552 i2c_del_driver(&wm8741_i2c_driver); | 555 i2c_del_driver(&wm8741_i2c_driver); |
| 553 #endif | 556 #endif |
| 554 } | 557 } |
| 555 module_exit(wm8741_exit); | 558 module_exit(wm8741_exit); |
| 556 | 559 |
| 557 MODULE_DESCRIPTION("ASoC WM8741 driver"); | 560 MODULE_DESCRIPTION("ASoC WM8741 driver"); |
| 558 MODULE_AUTHOR("Ian Lartey <ian@opensource.wolfsonmicro.com>"); | 561 MODULE_AUTHOR("Ian Lartey <ian@opensource.wolfsonmicro.com>"); |
| 559 MODULE_LICENSE("GPL"); | 562 MODULE_LICENSE("GPL"); |
| OLD | NEW |