diff options
Diffstat (limited to 'sound/soc/codecs/wm8971.c')
| -rw-r--r-- | sound/soc/codecs/wm8971.c | 88 |
1 files changed, 65 insertions, 23 deletions
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 5ce647758443..67aba78a7ca5 100644 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
| 20 | #include <linux/pm.h> | 20 | #include <linux/pm.h> |
| 21 | #include <linux/i2c.h> | 21 | #include <linux/i2c.h> |
| 22 | #include <linux/regmap.h> | ||
| 22 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
| 23 | #include <sound/core.h> | 24 | #include <sound/core.h> |
| 24 | #include <sound/pcm.h> | 25 | #include <sound/pcm.h> |
| @@ -34,7 +35,6 @@ static struct workqueue_struct *wm8971_workq = NULL; | |||
| 34 | 35 | ||
| 35 | /* codec private data */ | 36 | /* codec private data */ |
| 36 | struct wm8971_priv { | 37 | struct wm8971_priv { |
| 37 | enum snd_soc_control_type control_type; | ||
| 38 | unsigned int sysclk; | 38 | unsigned int sysclk; |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| @@ -43,18 +43,50 @@ struct wm8971_priv { | |||
| 43 | * We can't read the WM8971 register space when we | 43 | * We can't read the WM8971 register space when we |
| 44 | * are using 2 wire for device control, so we cache them instead. | 44 | * are using 2 wire for device control, so we cache them instead. |
| 45 | */ | 45 | */ |
| 46 | static const u16 wm8971_reg[] = { | 46 | static const struct reg_default wm8971_reg_defaults[] = { |
| 47 | 0x0097, 0x0097, 0x0079, 0x0079, /* 0 */ | 47 | { 0, 0x0097 }, |
| 48 | 0x0000, 0x0008, 0x0000, 0x000a, /* 4 */ | 48 | { 1, 0x0097 }, |
| 49 | 0x0000, 0x0000, 0x00ff, 0x00ff, /* 8 */ | 49 | { 2, 0x0079 }, |
| 50 | 0x000f, 0x000f, 0x0000, 0x0000, /* 12 */ | 50 | { 3, 0x0079 }, |
| 51 | 0x0000, 0x007b, 0x0000, 0x0032, /* 16 */ | 51 | { 4, 0x0000 }, |
| 52 | 0x0000, 0x00c3, 0x00c3, 0x00c0, /* 20 */ | 52 | { 5, 0x0008 }, |
| 53 | 0x0000, 0x0000, 0x0000, 0x0000, /* 24 */ | 53 | { 6, 0x0000 }, |
| 54 | 0x0000, 0x0000, 0x0000, 0x0000, /* 28 */ | 54 | { 7, 0x000a }, |
| 55 | 0x0000, 0x0000, 0x0050, 0x0050, /* 32 */ | 55 | { 8, 0x0000 }, |
| 56 | 0x0050, 0x0050, 0x0050, 0x0050, /* 36 */ | 56 | { 9, 0x0000 }, |
| 57 | 0x0079, 0x0079, 0x0079, /* 40 */ | 57 | { 10, 0x00ff }, |
| 58 | { 11, 0x00ff }, | ||
| 59 | { 12, 0x000f }, | ||
| 60 | { 13, 0x000f }, | ||
| 61 | { 14, 0x0000 }, | ||
| 62 | { 15, 0x0000 }, | ||
| 63 | { 16, 0x0000 }, | ||
| 64 | { 17, 0x007b }, | ||
| 65 | { 18, 0x0000 }, | ||
| 66 | { 19, 0x0032 }, | ||
| 67 | { 20, 0x0000 }, | ||
| 68 | { 21, 0x00c3 }, | ||
| 69 | { 22, 0x00c3 }, | ||
| 70 | { 23, 0x00c0 }, | ||
| 71 | { 24, 0x0000 }, | ||
| 72 | { 25, 0x0000 }, | ||
| 73 | { 26, 0x0000 }, | ||
| 74 | { 27, 0x0000 }, | ||
| 75 | { 28, 0x0000 }, | ||
| 76 | { 29, 0x0000 }, | ||
| 77 | { 30, 0x0000 }, | ||
| 78 | { 31, 0x0000 }, | ||
| 79 | { 32, 0x0000 }, | ||
| 80 | { 33, 0x0000 }, | ||
| 81 | { 34, 0x0050 }, | ||
| 82 | { 35, 0x0050 }, | ||
| 83 | { 36, 0x0050 }, | ||
| 84 | { 37, 0x0050 }, | ||
| 85 | { 38, 0x0050 }, | ||
| 86 | { 39, 0x0050 }, | ||
| 87 | { 40, 0x0079 }, | ||
| 88 | { 41, 0x0079 }, | ||
| 89 | { 42, 0x0079 }, | ||
| 58 | }; | 90 | }; |
| 59 | 91 | ||
| 60 | #define wm8971_reset(c) snd_soc_write(c, WM8971_RESET, 0) | 92 | #define wm8971_reset(c) snd_soc_write(c, WM8971_RESET, 0) |
| @@ -613,11 +645,10 @@ static int wm8971_resume(struct snd_soc_codec *codec) | |||
| 613 | 645 | ||
| 614 | static int wm8971_probe(struct snd_soc_codec *codec) | 646 | static int wm8971_probe(struct snd_soc_codec *codec) |
| 615 | { | 647 | { |
| 616 | struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); | ||
| 617 | int ret = 0; | 648 | int ret = 0; |
| 618 | u16 reg; | 649 | u16 reg; |
| 619 | 650 | ||
| 620 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8971->control_type); | 651 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP); |
| 621 | if (ret < 0) { | 652 | if (ret < 0) { |
| 622 | printk(KERN_ERR "wm8971: failed to set cache I/O: %d\n", ret); | 653 | printk(KERN_ERR "wm8971: failed to set cache I/O: %d\n", ret); |
| 623 | return ret; | 654 | return ret; |
| @@ -667,9 +698,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8971 = { | |||
| 667 | .suspend = wm8971_suspend, | 698 | .suspend = wm8971_suspend, |
| 668 | .resume = wm8971_resume, | 699 | .resume = wm8971_resume, |
| 669 | .set_bias_level = wm8971_set_bias_level, | 700 | .set_bias_level = wm8971_set_bias_level, |
| 670 | .reg_cache_size = ARRAY_SIZE(wm8971_reg), | ||
| 671 | .reg_word_size = sizeof(u16), | ||
| 672 | .reg_cache_default = wm8971_reg, | ||
| 673 | 701 | ||
| 674 | .controls = wm8971_snd_controls, | 702 | .controls = wm8971_snd_controls, |
| 675 | .num_controls = ARRAY_SIZE(wm8971_snd_controls), | 703 | .num_controls = ARRAY_SIZE(wm8971_snd_controls), |
| @@ -679,10 +707,21 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8971 = { | |||
| 679 | .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), | 707 | .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), |
| 680 | }; | 708 | }; |
| 681 | 709 | ||
| 682 | static __devinit int wm8971_i2c_probe(struct i2c_client *i2c, | 710 | static const struct regmap_config wm8971_regmap = { |
| 683 | const struct i2c_device_id *id) | 711 | .reg_bits = 7, |
| 712 | .val_bits = 9, | ||
| 713 | .max_register = WM8971_MOUTV, | ||
| 714 | |||
| 715 | .reg_defaults = wm8971_reg_defaults, | ||
| 716 | .num_reg_defaults = ARRAY_SIZE(wm8971_reg_defaults), | ||
| 717 | .cache_type = REGCACHE_RBTREE, | ||
| 718 | }; | ||
| 719 | |||
| 720 | static int wm8971_i2c_probe(struct i2c_client *i2c, | ||
| 721 | const struct i2c_device_id *id) | ||
| 684 | { | 722 | { |
| 685 | struct wm8971_priv *wm8971; | 723 | struct wm8971_priv *wm8971; |
| 724 | struct regmap *regmap; | ||
| 686 | int ret; | 725 | int ret; |
| 687 | 726 | ||
| 688 | wm8971 = devm_kzalloc(&i2c->dev, sizeof(struct wm8971_priv), | 727 | wm8971 = devm_kzalloc(&i2c->dev, sizeof(struct wm8971_priv), |
| @@ -690,7 +729,10 @@ static __devinit int wm8971_i2c_probe(struct i2c_client *i2c, | |||
| 690 | if (wm8971 == NULL) | 729 | if (wm8971 == NULL) |
| 691 | return -ENOMEM; | 730 | return -ENOMEM; |
| 692 | 731 | ||
| 693 | wm8971->control_type = SND_SOC_I2C; | 732 | regmap = devm_regmap_init_i2c(i2c, &wm8971_regmap); |
| 733 | if (IS_ERR(regmap)) | ||
| 734 | return PTR_ERR(regmap); | ||
| 735 | |||
| 694 | i2c_set_clientdata(i2c, wm8971); | 736 | i2c_set_clientdata(i2c, wm8971); |
| 695 | 737 | ||
| 696 | ret = snd_soc_register_codec(&i2c->dev, | 738 | ret = snd_soc_register_codec(&i2c->dev, |
| @@ -699,7 +741,7 @@ static __devinit int wm8971_i2c_probe(struct i2c_client *i2c, | |||
| 699 | return ret; | 741 | return ret; |
| 700 | } | 742 | } |
| 701 | 743 | ||
| 702 | static __devexit int wm8971_i2c_remove(struct i2c_client *client) | 744 | static int wm8971_i2c_remove(struct i2c_client *client) |
| 703 | { | 745 | { |
| 704 | snd_soc_unregister_codec(&client->dev); | 746 | snd_soc_unregister_codec(&client->dev); |
| 705 | return 0; | 747 | return 0; |
| @@ -717,7 +759,7 @@ static struct i2c_driver wm8971_i2c_driver = { | |||
| 717 | .owner = THIS_MODULE, | 759 | .owner = THIS_MODULE, |
| 718 | }, | 760 | }, |
| 719 | .probe = wm8971_i2c_probe, | 761 | .probe = wm8971_i2c_probe, |
| 720 | .remove = __devexit_p(wm8971_i2c_remove), | 762 | .remove = wm8971_i2c_remove, |
| 721 | .id_table = wm8971_i2c_id, | 763 | .id_table = wm8971_i2c_id, |
| 722 | }; | 764 | }; |
| 723 | 765 | ||
