ASoC: Convert wm5100 to direct regmap API usage
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
7b16f56012
commit
bd132ec585
File diff suppressed because it is too large
Load Diff
|
@ -51,6 +51,7 @@ struct wm5100_fll {
|
||||||
|
|
||||||
/* codec private data */
|
/* codec private data */
|
||||||
struct wm5100_priv {
|
struct wm5100_priv {
|
||||||
|
struct regmap *regmap;
|
||||||
struct snd_soc_codec *codec;
|
struct snd_soc_codec *codec;
|
||||||
|
|
||||||
struct regulator_bulk_data core_supplies[WM5100_NUM_CORE_SUPPLIES];
|
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,
|
||||||
msleep(2);
|
msleep(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
codec->cache_only = false;
|
regcache_cache_only(wm5100->regmap, false);
|
||||||
|
|
||||||
switch (wm5100->rev) {
|
switch (wm5100->rev) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1993,6 +1994,9 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
|
||||||
else
|
else
|
||||||
timeout = 50;
|
timeout = 50;
|
||||||
|
|
||||||
|
snd_soc_update_bits(codec, WM5100_CLOCKING_3, WM5100_SYSCLK_ENA,
|
||||||
|
WM5100_SYSCLK_ENA);
|
||||||
|
|
||||||
/* Poll for the lock; will use interrupt when we can test */
|
/* Poll for the lock; will use interrupt when we can test */
|
||||||
for (i = 0; i < timeout; i++) {
|
for (i = 0; i < timeout; i++) {
|
||||||
if (i2c->irq) {
|
if (i2c->irq) {
|
||||||
|
@ -2453,8 +2457,9 @@ static int wm5100_probe(struct snd_soc_codec *codec)
|
||||||
int ret, i, irq_flags;
|
int ret, i, irq_flags;
|
||||||
|
|
||||||
wm5100->codec = codec;
|
wm5100->codec = codec;
|
||||||
|
codec->control_data = wm5100->regmap;
|
||||||
|
|
||||||
ret = snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_I2C);
|
ret = snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
|
dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2552,7 +2557,7 @@ static int wm5100_probe(struct snd_soc_codec *codec)
|
||||||
goto err_reset;
|
goto err_reset;
|
||||||
}
|
}
|
||||||
|
|
||||||
codec->cache_only = true;
|
regcache_cache_only(wm5100->regmap, true);
|
||||||
|
|
||||||
wm5100_init_gpio(codec);
|
wm5100_init_gpio(codec);
|
||||||
|
|
||||||
|
@ -2733,14 +2738,18 @@ static struct snd_soc_codec_driver soc_codec_dev_wm5100 = {
|
||||||
.num_dapm_widgets = ARRAY_SIZE(wm5100_dapm_widgets),
|
.num_dapm_widgets = ARRAY_SIZE(wm5100_dapm_widgets),
|
||||||
.dapm_routes = wm5100_dapm_routes,
|
.dapm_routes = wm5100_dapm_routes,
|
||||||
.num_dapm_routes = ARRAY_SIZE(wm5100_dapm_routes),
|
.num_dapm_routes = ARRAY_SIZE(wm5100_dapm_routes),
|
||||||
|
};
|
||||||
|
|
||||||
.reg_cache_size = ARRAY_SIZE(wm5100_reg_defaults),
|
static const struct regmap_config wm5100_regmap = {
|
||||||
.reg_word_size = sizeof(u16),
|
.reg_bits = 16,
|
||||||
.compress_type = SND_SOC_RBTREE_COMPRESSION,
|
.val_bits = 16,
|
||||||
.reg_cache_default = wm5100_reg_defaults,
|
|
||||||
|
|
||||||
.volatile_register = wm5100_volatile_register,
|
.max_register = WM5100_MAX_REGISTER,
|
||||||
.readable_register = wm5100_readable_register,
|
.reg_defaults = wm5100_reg_defaults,
|
||||||
|
.num_reg_defaults = ARRAY_SIZE(wm5100_reg_defaults),
|
||||||
|
.volatile_reg = wm5100_volatile_register,
|
||||||
|
.readable_reg = wm5100_readable_register,
|
||||||
|
.cache_type = REGCACHE_RBTREE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static __devinit int wm5100_i2c_probe(struct i2c_client *i2c,
|
static __devinit int wm5100_i2c_probe(struct i2c_client *i2c,
|
||||||
|
@ -2754,6 +2763,14 @@ static __devinit int wm5100_i2c_probe(struct i2c_client *i2c,
|
||||||
if (wm5100 == NULL)
|
if (wm5100 == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
wm5100->regmap = regmap_init_i2c(i2c, &wm5100_regmap);
|
||||||
|
if (IS_ERR(wm5100->regmap)) {
|
||||||
|
ret = PTR_ERR(wm5100->regmap);
|
||||||
|
dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
|
||||||
|
ret);
|
||||||
|
goto err_alloc;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(wm5100->fll); i++)
|
for (i = 0; i < ARRAY_SIZE(wm5100->fll); i++)
|
||||||
init_completion(&wm5100->fll[i].lock);
|
init_completion(&wm5100->fll[i].lock);
|
||||||
|
|
||||||
|
@ -2767,16 +2784,26 @@ static __devinit int wm5100_i2c_probe(struct i2c_client *i2c,
|
||||||
ARRAY_SIZE(wm5100_dai));
|
ARRAY_SIZE(wm5100_dai));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&i2c->dev, "Failed to register WM5100: %d\n", ret);
|
dev_err(&i2c->dev, "Failed to register WM5100: %d\n", ret);
|
||||||
kfree(wm5100);
|
goto err_regmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
err_regmap:
|
||||||
|
regmap_exit(wm5100->regmap);
|
||||||
|
err_alloc:
|
||||||
|
kfree(wm5100);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __devexit int wm5100_i2c_remove(struct i2c_client *client)
|
static __devexit int wm5100_i2c_remove(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
|
struct wm5100_priv *wm5100 = i2c_get_clientdata(client);
|
||||||
|
|
||||||
snd_soc_unregister_codec(&client->dev);
|
snd_soc_unregister_codec(&client->dev);
|
||||||
kfree(i2c_get_clientdata(client));
|
regmap_exit(wm5100->regmap);
|
||||||
|
kfree(wm5100);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#define WM5100_ASOC_H
|
#define WM5100_ASOC_H
|
||||||
|
|
||||||
#include <sound/soc.h>
|
#include <sound/soc.h>
|
||||||
|
#include <linux/regmap.h>
|
||||||
|
|
||||||
int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack);
|
int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack);
|
||||||
|
|
||||||
|
@ -5147,9 +5148,9 @@ int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack);
|
||||||
#define WM5100_DSP3_ZM_END_SHIFT 0 /* DSP3_ZM_END - [15:0] */
|
#define WM5100_DSP3_ZM_END_SHIFT 0 /* DSP3_ZM_END - [15:0] */
|
||||||
#define WM5100_DSP3_ZM_END_WIDTH 16 /* DSP3_ZM_END - [15:0] */
|
#define WM5100_DSP3_ZM_END_WIDTH 16 /* DSP3_ZM_END - [15:0] */
|
||||||
|
|
||||||
int wm5100_readable_register(struct snd_soc_codec *codec, unsigned int reg);
|
bool wm5100_readable_register(struct device *dev, unsigned int reg);
|
||||||
int wm5100_volatile_register(struct snd_soc_codec *codec, unsigned int reg);
|
bool wm5100_volatile_register(struct device *dev, unsigned int reg);
|
||||||
|
|
||||||
extern u16 wm5100_reg_defaults[WM5100_MAX_REGISTER + 1];
|
extern struct reg_default wm5100_reg_defaults[WM5100_REGISTER_COUNT];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue