diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-10-23 06:10:45 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-11-08 09:13:50 -0500 |
commit | bd132ec585c498ee27d7eedf8569703606743928 (patch) | |
tree | 6cc18bbb9efa29ac4676dfcbe74a435a670dce27 /sound/soc/codecs/wm5100.c | |
parent | 7b16f5601295d0dfd0d48753b9253d41957587fe (diff) |
ASoC: Convert wm5100 to direct regmap API usage
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm5100.c')
-rw-r--r-- | sound/soc/codecs/wm5100.c | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index 42d9039a49e9..b2d1f80648ff 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c | |||
@@ -51,6 +51,7 @@ struct wm5100_fll { | |||
51 | 51 | ||
52 | /* codec private data */ | 52 | /* codec private data */ |
53 | struct wm5100_priv { | 53 | struct wm5100_priv { |
54 | struct regmap *regmap; | ||
54 | struct snd_soc_codec *codec; | 55 | struct snd_soc_codec *codec; |
55 | 56 | ||
56 | struct regulator_bulk_data core_supplies[WM5100_NUM_CORE_SUPPLIES]; | 57 | struct regulator_bulk_data core_supplies[WM5100_NUM_CORE_SUPPLIES]; |
@@ -1375,7 +1376,7 @@ static int wm5100_set_bias_level(struct snd_soc_codec *codec, | |||
1375 | msleep(2); | 1376 | msleep(2); |
1376 | } | 1377 | } |
1377 | 1378 | ||
1378 | codec->cache_only = false; | 1379 | regcache_cache_only(wm5100->regmap, false); |
1379 | 1380 | ||
1380 | switch (wm5100->rev) { | 1381 | switch (wm5100->rev) { |
1381 | case 0: | 1382 | case 0: |
@@ -1993,6 +1994,9 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, | |||
1993 | else | 1994 | else |
1994 | timeout = 50; | 1995 | timeout = 50; |
1995 | 1996 | ||
1997 | snd_soc_update_bits(codec, WM5100_CLOCKING_3, WM5100_SYSCLK_ENA, | ||
1998 | WM5100_SYSCLK_ENA); | ||
1999 | |||
1996 | /* Poll for the lock; will use interrupt when we can test */ | 2000 | /* Poll for the lock; will use interrupt when we can test */ |
1997 | for (i = 0; i < timeout; i++) { | 2001 | for (i = 0; i < timeout; i++) { |
1998 | if (i2c->irq) { | 2002 | if (i2c->irq) { |
@@ -2453,8 +2457,9 @@ static int wm5100_probe(struct snd_soc_codec *codec) | |||
2453 | int ret, i, irq_flags; | 2457 | int ret, i, irq_flags; |
2454 | 2458 | ||
2455 | wm5100->codec = codec; | 2459 | wm5100->codec = codec; |
2460 | codec->control_data = wm5100->regmap; | ||
2456 | 2461 | ||
2457 | ret = snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_I2C); | 2462 | ret = snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP); |
2458 | if (ret != 0) { | 2463 | if (ret != 0) { |
2459 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 2464 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
2460 | return ret; | 2465 | return ret; |
@@ -2552,7 +2557,7 @@ static int wm5100_probe(struct snd_soc_codec *codec) | |||
2552 | goto err_reset; | 2557 | goto err_reset; |
2553 | } | 2558 | } |
2554 | 2559 | ||
2555 | codec->cache_only = true; | 2560 | regcache_cache_only(wm5100->regmap, true); |
2556 | 2561 | ||
2557 | wm5100_init_gpio(codec); | 2562 | wm5100_init_gpio(codec); |
2558 | 2563 | ||
@@ -2733,14 +2738,18 @@ static struct snd_soc_codec_driver soc_codec_dev_wm5100 = { | |||
2733 | .num_dapm_widgets = ARRAY_SIZE(wm5100_dapm_widgets), | 2738 | .num_dapm_widgets = ARRAY_SIZE(wm5100_dapm_widgets), |
2734 | .dapm_routes = wm5100_dapm_routes, | 2739 | .dapm_routes = wm5100_dapm_routes, |
2735 | .num_dapm_routes = ARRAY_SIZE(wm5100_dapm_routes), | 2740 | .num_dapm_routes = ARRAY_SIZE(wm5100_dapm_routes), |
2741 | }; | ||
2736 | 2742 | ||
2737 | .reg_cache_size = ARRAY_SIZE(wm5100_reg_defaults), | 2743 | static const struct regmap_config wm5100_regmap = { |
2738 | .reg_word_size = sizeof(u16), | 2744 | .reg_bits = 16, |
2739 | .compress_type = SND_SOC_RBTREE_COMPRESSION, | 2745 | .val_bits = 16, |
2740 | .reg_cache_default = wm5100_reg_defaults, | ||
2741 | 2746 | ||
2742 | .volatile_register = wm5100_volatile_register, | 2747 | .max_register = WM5100_MAX_REGISTER, |
2743 | .readable_register = wm5100_readable_register, | 2748 | .reg_defaults = wm5100_reg_defaults, |
2749 | .num_reg_defaults = ARRAY_SIZE(wm5100_reg_defaults), | ||
2750 | .volatile_reg = wm5100_volatile_register, | ||
2751 | .readable_reg = wm5100_readable_register, | ||
2752 | .cache_type = REGCACHE_RBTREE, | ||
2744 | }; | 2753 | }; |
2745 | 2754 | ||
2746 | static __devinit int wm5100_i2c_probe(struct i2c_client *i2c, | 2755 | static __devinit int wm5100_i2c_probe(struct i2c_client *i2c, |
@@ -2754,6 +2763,14 @@ static __devinit int wm5100_i2c_probe(struct i2c_client *i2c, | |||
2754 | if (wm5100 == NULL) | 2763 | if (wm5100 == NULL) |
2755 | return -ENOMEM; | 2764 | return -ENOMEM; |
2756 | 2765 | ||
2766 | wm5100->regmap = regmap_init_i2c(i2c, &wm5100_regmap); | ||
2767 | if (IS_ERR(wm5100->regmap)) { | ||
2768 | ret = PTR_ERR(wm5100->regmap); | ||
2769 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", | ||
2770 | ret); | ||
2771 | goto err_alloc; | ||
2772 | } | ||
2773 | |||
2757 | for (i = 0; i < ARRAY_SIZE(wm5100->fll); i++) | 2774 | for (i = 0; i < ARRAY_SIZE(wm5100->fll); i++) |
2758 | init_completion(&wm5100->fll[i].lock); | 2775 | init_completion(&wm5100->fll[i].lock); |
2759 | 2776 | ||
@@ -2767,16 +2784,26 @@ static __devinit int wm5100_i2c_probe(struct i2c_client *i2c, | |||
2767 | ARRAY_SIZE(wm5100_dai)); | 2784 | ARRAY_SIZE(wm5100_dai)); |
2768 | if (ret < 0) { | 2785 | if (ret < 0) { |
2769 | dev_err(&i2c->dev, "Failed to register WM5100: %d\n", ret); | 2786 | dev_err(&i2c->dev, "Failed to register WM5100: %d\n", ret); |
2770 | kfree(wm5100); | 2787 | goto err_regmap; |
2771 | } | 2788 | } |
2772 | 2789 | ||
2773 | return ret; | 2790 | return ret; |
2791 | |||
2792 | err_regmap: | ||
2793 | regmap_exit(wm5100->regmap); | ||
2794 | err_alloc: | ||
2795 | kfree(wm5100); | ||
2796 | return ret; | ||
2774 | } | 2797 | } |
2775 | 2798 | ||
2776 | static __devexit int wm5100_i2c_remove(struct i2c_client *client) | 2799 | static __devexit int wm5100_i2c_remove(struct i2c_client *client) |
2777 | { | 2800 | { |
2801 | struct wm5100_priv *wm5100 = i2c_get_clientdata(client); | ||
2802 | |||
2778 | snd_soc_unregister_codec(&client->dev); | 2803 | snd_soc_unregister_codec(&client->dev); |
2779 | kfree(i2c_get_clientdata(client)); | 2804 | regmap_exit(wm5100->regmap); |
2805 | kfree(wm5100); | ||
2806 | |||
2780 | return 0; | 2807 | return 0; |
2781 | } | 2808 | } |
2782 | 2809 | ||