aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8994.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-07-24 07:49:52 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-12 11:20:06 -0500
commitd9a7666ff3a9e109844bf5aca5f50e3743f65840 (patch)
tree3cdc431f7d0a97d60315effc3393e5c1c1387172 /sound/soc/codecs/wm8994.c
parent68556ca1e03d6a35be3b315eba58df2f8176e3a0 (diff)
ASoC: Remove ASoC-specific WM8994 I/O code
Just go directly to the regmap API, saving code and making integration that bit more direct. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8994.c')
-rw-r--r--sound/soc/codecs/wm8994.c63
1 files changed, 12 insertions, 51 deletions
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 3eaf56a33964..285890802d62 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -184,44 +184,6 @@ static int wm8994_volatile(struct snd_soc_codec *codec, unsigned int reg)
184 } 184 }
185} 185}
186 186
187static int wm8994_write(struct snd_soc_codec *codec, unsigned int reg,
188 unsigned int value)
189{
190 int ret;
191
192 BUG_ON(reg > WM8994_MAX_REGISTER);
193
194 if (!wm8994_volatile(codec, reg)) {
195 ret = snd_soc_cache_write(codec, reg, value);
196 if (ret != 0)
197 dev_err(codec->dev, "Cache write to %x failed: %d\n",
198 reg, ret);
199 }
200
201 return wm8994_reg_write(codec->control_data, reg, value);
202}
203
204static unsigned int wm8994_read(struct snd_soc_codec *codec,
205 unsigned int reg)
206{
207 unsigned int val;
208 int ret;
209
210 BUG_ON(reg > WM8994_MAX_REGISTER);
211
212 if (!wm8994_volatile(codec, reg) && wm8994_readable(codec, reg) &&
213 reg < codec->driver->reg_cache_size) {
214 ret = snd_soc_cache_read(codec, reg, &val);
215 if (ret >= 0)
216 return val;
217 else
218 dev_err(codec->dev, "Cache read from %x failed: %d\n",
219 reg, ret);
220 }
221
222 return wm8994_reg_read(codec->control_data, reg);
223}
224
225static int configure_aif_clock(struct snd_soc_codec *codec, int aif) 187static int configure_aif_clock(struct snd_soc_codec *codec, int aif)
226{ 188{
227 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 189 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
@@ -2839,8 +2801,8 @@ static int wm8994_resume(struct snd_soc_codec *codec)
2839 2801
2840 if (wm8994->revision < 4) { 2802 if (wm8994->revision < 4) {
2841 /* force a HW read */ 2803 /* force a HW read */
2842 val = wm8994_reg_read(codec->control_data, 2804 ret = regmap_read(control->regmap,
2843 WM8994_POWER_MANAGEMENT_5); 2805 WM8994_POWER_MANAGEMENT_5, &val);
2844 2806
2845 /* modify the cache only */ 2807 /* modify the cache only */
2846 codec->cache_only = 1; 2808 codec->cache_only = 1;
@@ -3455,13 +3417,13 @@ static irqreturn_t wm8994_temp_shut(int irq, void *data)
3455 3417
3456static int wm8994_codec_probe(struct snd_soc_codec *codec) 3418static int wm8994_codec_probe(struct snd_soc_codec *codec)
3457{ 3419{
3458 struct wm8994 *control; 3420 struct wm8994 *control = dev_get_drvdata(codec->dev->parent);
3459 struct wm8994_priv *wm8994; 3421 struct wm8994_priv *wm8994;
3460 struct snd_soc_dapm_context *dapm = &codec->dapm; 3422 struct snd_soc_dapm_context *dapm = &codec->dapm;
3423 unsigned int reg;
3461 int ret, i; 3424 int ret, i;
3462 3425
3463 codec->control_data = dev_get_drvdata(codec->dev->parent); 3426 codec->control_data = control->regmap;
3464 control = codec->control_data;
3465 3427
3466 wm8994 = devm_kzalloc(codec->dev, sizeof(struct wm8994_priv), 3428 wm8994 = devm_kzalloc(codec->dev, sizeof(struct wm8994_priv),
3467 GFP_KERNEL); 3429 GFP_KERNEL);
@@ -3469,6 +3431,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3469 return -ENOMEM; 3431 return -ENOMEM;
3470 snd_soc_codec_set_drvdata(codec, wm8994); 3432 snd_soc_codec_set_drvdata(codec, wm8994);
3471 3433
3434 snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP);
3472 3435
3473 wm8994->wm8994 = dev_get_drvdata(codec->dev->parent); 3436 wm8994->wm8994 = dev_get_drvdata(codec->dev->parent);
3474 wm8994->pdata = dev_get_platdata(codec->dev->parent); 3437 wm8994->pdata = dev_get_platdata(codec->dev->parent);
@@ -3494,11 +3457,11 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3494 if (!wm8994_readable(codec, i) || wm8994_volatile(codec, i)) 3457 if (!wm8994_readable(codec, i) || wm8994_volatile(codec, i))
3495 continue; 3458 continue;
3496 3459
3497 ret = wm8994_reg_read(codec->control_data, i); 3460 ret = regmap_read(control->regmap, i, &reg);
3498 if (ret <= 0) 3461 if (ret <= 0)
3499 continue; 3462 continue;
3500 3463
3501 ret = snd_soc_cache_write(codec, i, ret); 3464 ret = snd_soc_cache_write(codec, i, reg);
3502 if (ret != 0) { 3465 if (ret != 0) {
3503 dev_err(codec->dev, 3466 dev_err(codec->dev,
3504 "Failed to initialise cache for 0x%x: %d\n", 3467 "Failed to initialise cache for 0x%x: %d\n",
@@ -3653,24 +3616,24 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3653 * configured on init - if a system wants to do this dynamically 3616 * configured on init - if a system wants to do this dynamically
3654 * at runtime we can deal with that then. 3617 * at runtime we can deal with that then.
3655 */ 3618 */
3656 ret = wm8994_reg_read(codec->control_data, WM8994_GPIO_1); 3619 ret = regmap_read(control->regmap, WM8994_GPIO_1, &reg);
3657 if (ret < 0) { 3620 if (ret < 0) {
3658 dev_err(codec->dev, "Failed to read GPIO1 state: %d\n", ret); 3621 dev_err(codec->dev, "Failed to read GPIO1 state: %d\n", ret);
3659 goto err_irq; 3622 goto err_irq;
3660 } 3623 }
3661 if ((ret & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { 3624 if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) {
3662 wm8994->lrclk_shared[0] = 1; 3625 wm8994->lrclk_shared[0] = 1;
3663 wm8994_dai[0].symmetric_rates = 1; 3626 wm8994_dai[0].symmetric_rates = 1;
3664 } else { 3627 } else {
3665 wm8994->lrclk_shared[0] = 0; 3628 wm8994->lrclk_shared[0] = 0;
3666 } 3629 }
3667 3630
3668 ret = wm8994_reg_read(codec->control_data, WM8994_GPIO_6); 3631 ret = regmap_read(control->regmap, WM8994_GPIO_6, &reg);
3669 if (ret < 0) { 3632 if (ret < 0) {
3670 dev_err(codec->dev, "Failed to read GPIO6 state: %d\n", ret); 3633 dev_err(codec->dev, "Failed to read GPIO6 state: %d\n", ret);
3671 goto err_irq; 3634 goto err_irq;
3672 } 3635 }
3673 if ((ret & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { 3636 if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) {
3674 wm8994->lrclk_shared[1] = 1; 3637 wm8994->lrclk_shared[1] = 1;
3675 wm8994_dai[1].symmetric_rates = 1; 3638 wm8994_dai[1].symmetric_rates = 1;
3676 } else { 3639 } else {
@@ -3937,8 +3900,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8994 = {
3937 .remove = wm8994_codec_remove, 3900 .remove = wm8994_codec_remove,
3938 .suspend = wm8994_suspend, 3901 .suspend = wm8994_suspend,
3939 .resume = wm8994_resume, 3902 .resume = wm8994_resume,
3940 .read = wm8994_read,
3941 .write = wm8994_write,
3942 .readable_register = wm8994_readable, 3903 .readable_register = wm8994_readable,
3943 .volatile_register = wm8994_volatile, 3904 .volatile_register = wm8994_volatile,
3944 .set_bias_level = wm8994_set_bias_level, 3905 .set_bias_level = wm8994_set_bias_level,