Commit d9a7666f authored by Mark Brown's avatar Mark Brown

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: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 68556ca1
...@@ -184,44 +184,6 @@ static int wm8994_volatile(struct snd_soc_codec *codec, unsigned int reg) ...@@ -184,44 +184,6 @@ static int wm8994_volatile(struct snd_soc_codec *codec, unsigned int reg)
} }
} }
static int wm8994_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value)
{
int ret;
BUG_ON(reg > WM8994_MAX_REGISTER);
if (!wm8994_volatile(codec, reg)) {
ret = snd_soc_cache_write(codec, reg, value);
if (ret != 0)
dev_err(codec->dev, "Cache write to %x failed: %d\n",
reg, ret);
}
return wm8994_reg_write(codec->control_data, reg, value);
}
static unsigned int wm8994_read(struct snd_soc_codec *codec,
unsigned int reg)
{
unsigned int val;
int ret;
BUG_ON(reg > WM8994_MAX_REGISTER);
if (!wm8994_volatile(codec, reg) && wm8994_readable(codec, reg) &&
reg < codec->driver->reg_cache_size) {
ret = snd_soc_cache_read(codec, reg, &val);
if (ret >= 0)
return val;
else
dev_err(codec->dev, "Cache read from %x failed: %d\n",
reg, ret);
}
return wm8994_reg_read(codec->control_data, reg);
}
static int configure_aif_clock(struct snd_soc_codec *codec, int aif) static int configure_aif_clock(struct snd_soc_codec *codec, int aif)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
...@@ -2839,8 +2801,8 @@ static int wm8994_resume(struct snd_soc_codec *codec) ...@@ -2839,8 +2801,8 @@ static int wm8994_resume(struct snd_soc_codec *codec)
if (wm8994->revision < 4) { if (wm8994->revision < 4) {
/* force a HW read */ /* force a HW read */
val = wm8994_reg_read(codec->control_data, ret = regmap_read(control->regmap,
WM8994_POWER_MANAGEMENT_5); WM8994_POWER_MANAGEMENT_5, &val);
/* modify the cache only */ /* modify the cache only */
codec->cache_only = 1; codec->cache_only = 1;
...@@ -3455,13 +3417,13 @@ static irqreturn_t wm8994_temp_shut(int irq, void *data) ...@@ -3455,13 +3417,13 @@ static irqreturn_t wm8994_temp_shut(int irq, void *data)
static int wm8994_codec_probe(struct snd_soc_codec *codec) static int wm8994_codec_probe(struct snd_soc_codec *codec)
{ {
struct wm8994 *control; struct wm8994 *control = dev_get_drvdata(codec->dev->parent);
struct wm8994_priv *wm8994; struct wm8994_priv *wm8994;
struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_dapm_context *dapm = &codec->dapm;
unsigned int reg;
int ret, i; int ret, i;
codec->control_data = dev_get_drvdata(codec->dev->parent); codec->control_data = control->regmap;
control = codec->control_data;
wm8994 = devm_kzalloc(codec->dev, sizeof(struct wm8994_priv), wm8994 = devm_kzalloc(codec->dev, sizeof(struct wm8994_priv),
GFP_KERNEL); GFP_KERNEL);
...@@ -3469,6 +3431,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -3469,6 +3431,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
return -ENOMEM; return -ENOMEM;
snd_soc_codec_set_drvdata(codec, wm8994); snd_soc_codec_set_drvdata(codec, wm8994);
snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP);
wm8994->wm8994 = dev_get_drvdata(codec->dev->parent); wm8994->wm8994 = dev_get_drvdata(codec->dev->parent);
wm8994->pdata = dev_get_platdata(codec->dev->parent); wm8994->pdata = dev_get_platdata(codec->dev->parent);
...@@ -3494,11 +3457,11 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -3494,11 +3457,11 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
if (!wm8994_readable(codec, i) || wm8994_volatile(codec, i)) if (!wm8994_readable(codec, i) || wm8994_volatile(codec, i))
continue; continue;
ret = wm8994_reg_read(codec->control_data, i); ret = regmap_read(control->regmap, i, &reg);
if (ret <= 0) if (ret <= 0)
continue; continue;
ret = snd_soc_cache_write(codec, i, ret); ret = snd_soc_cache_write(codec, i, reg);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, dev_err(codec->dev,
"Failed to initialise cache for 0x%x: %d\n", "Failed to initialise cache for 0x%x: %d\n",
...@@ -3653,24 +3616,24 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -3653,24 +3616,24 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
* configured on init - if a system wants to do this dynamically * configured on init - if a system wants to do this dynamically
* at runtime we can deal with that then. * at runtime we can deal with that then.
*/ */
ret = wm8994_reg_read(codec->control_data, WM8994_GPIO_1); ret = regmap_read(control->regmap, WM8994_GPIO_1, &reg);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to read GPIO1 state: %d\n", ret); dev_err(codec->dev, "Failed to read GPIO1 state: %d\n", ret);
goto err_irq; goto err_irq;
} }
if ((ret & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) {
wm8994->lrclk_shared[0] = 1; wm8994->lrclk_shared[0] = 1;
wm8994_dai[0].symmetric_rates = 1; wm8994_dai[0].symmetric_rates = 1;
} else { } else {
wm8994->lrclk_shared[0] = 0; wm8994->lrclk_shared[0] = 0;
} }
ret = wm8994_reg_read(codec->control_data, WM8994_GPIO_6); ret = regmap_read(control->regmap, WM8994_GPIO_6, &reg);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to read GPIO6 state: %d\n", ret); dev_err(codec->dev, "Failed to read GPIO6 state: %d\n", ret);
goto err_irq; goto err_irq;
} }
if ((ret & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) {
wm8994->lrclk_shared[1] = 1; wm8994->lrclk_shared[1] = 1;
wm8994_dai[1].symmetric_rates = 1; wm8994_dai[1].symmetric_rates = 1;
} else { } else {
...@@ -3937,8 +3900,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8994 = { ...@@ -3937,8 +3900,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8994 = {
.remove = wm8994_codec_remove, .remove = wm8994_codec_remove,
.suspend = wm8994_suspend, .suspend = wm8994_suspend,
.resume = wm8994_resume, .resume = wm8994_resume,
.read = wm8994_read,
.write = wm8994_write,
.readable_register = wm8994_readable, .readable_register = wm8994_readable,
.volatile_register = wm8994_volatile, .volatile_register = wm8994_volatile,
.set_bias_level = wm8994_set_bias_level, .set_bias_level = wm8994_set_bias_level,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment