Commit cce67af3 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/88pm860x', 'asoc/topic/ab8500',...

Merge remote-tracking branches 'asoc/topic/88pm860x', 'asoc/topic/ab8500', 'asoc/topic/ac97', 'asoc/topic/ad1836' and 'asoc/topic/ad193x' into asoc-next
...@@ -586,10 +586,17 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, ...@@ -586,10 +586,17 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg,
unsigned int mask, unsigned int value); unsigned int mask, unsigned int value);
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec); #define snd_soc_alloc_ac97_codec(codec) \
struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, snd_soc_alloc_ac97_component(&codec->component)
#define snd_soc_new_ac97_codec(codec, id, id_mask) \
snd_soc_new_ac97_component(&codec->component, id, id_mask)
#define snd_soc_free_ac97_codec(ac97) \
snd_soc_free_ac97_component(ac97)
struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
unsigned int id, unsigned int id_mask); unsigned int id, unsigned int id_mask);
void snd_soc_free_ac97_codec(struct snd_ac97 *ac97); void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops); int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops, int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
......
...@@ -139,7 +139,7 @@ struct pm860x_priv { ...@@ -139,7 +139,7 @@ struct pm860x_priv {
unsigned int pcmclk; unsigned int pcmclk;
unsigned int dir; unsigned int dir;
unsigned int filter; unsigned int filter;
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct i2c_client *i2c; struct i2c_client *i2c;
struct regmap *regmap; struct regmap *regmap;
struct pm860x_chip *chip; struct pm860x_chip *chip;
...@@ -272,15 +272,15 @@ static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, ...@@ -272,15 +272,15 @@ static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol,
{ {
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
unsigned int reg = mc->reg; unsigned int reg = mc->reg;
unsigned int reg2 = mc->rreg; unsigned int reg2 = mc->rreg;
int val[2], val2[2], i; int val[2], val2[2], i;
val[0] = snd_soc_read(codec, reg) & 0x3f; val[0] = snd_soc_component_read32(component, reg) & 0x3f;
val[1] = (snd_soc_read(codec, PM860X_SIDETONE_SHIFT) >> 4) & 0xf; val[1] = (snd_soc_component_read32(component, PM860X_SIDETONE_SHIFT) >> 4) & 0xf;
val2[0] = snd_soc_read(codec, reg2) & 0x3f; val2[0] = snd_soc_component_read32(component, reg2) & 0x3f;
val2[1] = (snd_soc_read(codec, PM860X_SIDETONE_SHIFT)) & 0xf; val2[1] = (snd_soc_component_read32(component, PM860X_SIDETONE_SHIFT)) & 0xf;
for (i = 0; i < ARRAY_SIZE(st_table); i++) { for (i = 0; i < ARRAY_SIZE(st_table); i++) {
if ((st_table[i].m == val[0]) && (st_table[i].n == val[1])) if ((st_table[i].m == val[0]) && (st_table[i].n == val[1]))
...@@ -296,7 +296,7 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol, ...@@ -296,7 +296,7 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol,
{ {
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
unsigned int reg = mc->reg; unsigned int reg = mc->reg;
unsigned int reg2 = mc->rreg; unsigned int reg2 = mc->rreg;
int err; int err;
...@@ -308,18 +308,18 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol, ...@@ -308,18 +308,18 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol,
if (val >= ARRAY_SIZE(st_table) || val2 >= ARRAY_SIZE(st_table)) if (val >= ARRAY_SIZE(st_table) || val2 >= ARRAY_SIZE(st_table))
return -EINVAL; return -EINVAL;
err = snd_soc_update_bits(codec, reg, 0x3f, st_table[val].m); err = snd_soc_component_update_bits(component, reg, 0x3f, st_table[val].m);
if (err < 0) if (err < 0)
return err; return err;
err = snd_soc_update_bits(codec, PM860X_SIDETONE_SHIFT, 0xf0, err = snd_soc_component_update_bits(component, PM860X_SIDETONE_SHIFT, 0xf0,
st_table[val].n << 4); st_table[val].n << 4);
if (err < 0) if (err < 0)
return err; return err;
err = snd_soc_update_bits(codec, reg2, 0x3f, st_table[val2].m); err = snd_soc_component_update_bits(component, reg2, 0x3f, st_table[val2].m);
if (err < 0) if (err < 0)
return err; return err;
err = snd_soc_update_bits(codec, PM860X_SIDETONE_SHIFT, 0x0f, err = snd_soc_component_update_bits(component, PM860X_SIDETONE_SHIFT, 0x0f,
st_table[val2].n); st_table[val2].n);
return err; return err;
} }
...@@ -329,15 +329,15 @@ static int snd_soc_get_volsw_2r_out(struct snd_kcontrol *kcontrol, ...@@ -329,15 +329,15 @@ static int snd_soc_get_volsw_2r_out(struct snd_kcontrol *kcontrol,
{ {
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
unsigned int reg = mc->reg; unsigned int reg = mc->reg;
unsigned int reg2 = mc->rreg; unsigned int reg2 = mc->rreg;
unsigned int shift = mc->shift; unsigned int shift = mc->shift;
int max = mc->max, val, val2; int max = mc->max, val, val2;
unsigned int mask = (1 << fls(max)) - 1; unsigned int mask = (1 << fls(max)) - 1;
val = snd_soc_read(codec, reg) >> shift; val = snd_soc_component_read32(component, reg) >> shift;
val2 = snd_soc_read(codec, reg2) >> shift; val2 = snd_soc_component_read32(component, reg2) >> shift;
ucontrol->value.integer.value[0] = (max - val) & mask; ucontrol->value.integer.value[0] = (max - val) & mask;
ucontrol->value.integer.value[1] = (max - val2) & mask; ucontrol->value.integer.value[1] = (max - val2) & mask;
...@@ -349,7 +349,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol, ...@@ -349,7 +349,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol,
{ {
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
unsigned int reg = mc->reg; unsigned int reg = mc->reg;
unsigned int reg2 = mc->rreg; unsigned int reg2 = mc->rreg;
unsigned int shift = mc->shift; unsigned int shift = mc->shift;
...@@ -365,11 +365,11 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol, ...@@ -365,11 +365,11 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol,
val = val << shift; val = val << shift;
val2 = val2 << shift; val2 = val2 << shift;
err = snd_soc_update_bits(codec, reg, val_mask, val); err = snd_soc_component_update_bits(component, reg, val_mask, val);
if (err < 0) if (err < 0)
return err; return err;
err = snd_soc_update_bits(codec, reg2, val_mask, val2); err = snd_soc_component_update_bits(component, reg2, val_mask, val2);
return err; return err;
} }
...@@ -382,7 +382,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol, ...@@ -382,7 +382,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol,
static int pm860x_rsync_event(struct snd_soc_dapm_widget *w, static int pm860x_rsync_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
/* /*
* In order to avoid current on the load, mute power-on and power-off * In order to avoid current on the load, mute power-on and power-off
...@@ -390,8 +390,8 @@ static int pm860x_rsync_event(struct snd_soc_dapm_widget *w, ...@@ -390,8 +390,8 @@ static int pm860x_rsync_event(struct snd_soc_dapm_widget *w,
* Unmute by DAC_MUTE. It should be unmuted when DAPM sequence is * Unmute by DAC_MUTE. It should be unmuted when DAPM sequence is
* finished. * finished.
*/ */
snd_soc_update_bits(codec, PM860X_DAC_OFFSET, DAC_MUTE, 0); snd_soc_component_update_bits(component, PM860X_DAC_OFFSET, DAC_MUTE, 0);
snd_soc_update_bits(codec, PM860X_EAR_CTRL_2, snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2,
RSYNC_CHANGE, RSYNC_CHANGE); RSYNC_CHANGE, RSYNC_CHANGE);
return 0; return 0;
} }
...@@ -399,7 +399,7 @@ static int pm860x_rsync_event(struct snd_soc_dapm_widget *w, ...@@ -399,7 +399,7 @@ static int pm860x_rsync_event(struct snd_soc_dapm_widget *w,
static int pm860x_dac_event(struct snd_soc_dapm_widget *w, static int pm860x_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
unsigned int dac = 0; unsigned int dac = 0;
int data; int data;
...@@ -412,28 +412,28 @@ static int pm860x_dac_event(struct snd_soc_dapm_widget *w, ...@@ -412,28 +412,28 @@ static int pm860x_dac_event(struct snd_soc_dapm_widget *w,
if (dac) { if (dac) {
/* Auto mute in power-on sequence. */ /* Auto mute in power-on sequence. */
dac |= MODULATOR; dac |= MODULATOR;
snd_soc_update_bits(codec, PM860X_DAC_OFFSET, snd_soc_component_update_bits(component, PM860X_DAC_OFFSET,
DAC_MUTE, DAC_MUTE); DAC_MUTE, DAC_MUTE);
snd_soc_update_bits(codec, PM860X_EAR_CTRL_2, snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2,
RSYNC_CHANGE, RSYNC_CHANGE); RSYNC_CHANGE, RSYNC_CHANGE);
/* update dac */ /* update dac */
snd_soc_update_bits(codec, PM860X_DAC_EN_2, snd_soc_component_update_bits(component, PM860X_DAC_EN_2,
dac, dac); dac, dac);
} }
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
if (dac) { if (dac) {
/* Auto mute in power-off sequence. */ /* Auto mute in power-off sequence. */
snd_soc_update_bits(codec, PM860X_DAC_OFFSET, snd_soc_component_update_bits(component, PM860X_DAC_OFFSET,
DAC_MUTE, DAC_MUTE); DAC_MUTE, DAC_MUTE);
snd_soc_update_bits(codec, PM860X_EAR_CTRL_2, snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2,
RSYNC_CHANGE, RSYNC_CHANGE); RSYNC_CHANGE, RSYNC_CHANGE);
/* update dac */ /* update dac */
data = snd_soc_read(codec, PM860X_DAC_EN_2); data = snd_soc_component_read32(component, PM860X_DAC_EN_2);
data &= ~dac; data &= ~dac;
if (!(data & (DAC_LEFT | DAC_RIGHT))) if (!(data & (DAC_LEFT | DAC_RIGHT)))
data &= ~MODULATOR; data &= ~MODULATOR;
snd_soc_write(codec, PM860X_DAC_EN_2, data); snd_soc_component_write(component, PM860X_DAC_EN_2, data);
} }
break; break;
} }
...@@ -922,13 +922,13 @@ static const struct snd_soc_dapm_route pm860x_dapm_routes[] = { ...@@ -922,13 +922,13 @@ static const struct snd_soc_dapm_route pm860x_dapm_routes[] = {
*/ */
static int pm860x_digital_mute(struct snd_soc_dai *codec_dai, int mute) static int pm860x_digital_mute(struct snd_soc_dai *codec_dai, int mute)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
int data = 0, mask = MUTE_LEFT | MUTE_RIGHT; int data = 0, mask = MUTE_LEFT | MUTE_RIGHT;
if (mute) if (mute)
data = mask; data = mask;
snd_soc_update_bits(codec, PM860X_DAC_OFFSET, mask, data); snd_soc_component_update_bits(component, PM860X_DAC_OFFSET, mask, data);
snd_soc_update_bits(codec, PM860X_EAR_CTRL_2, snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2,
RSYNC_CHANGE, RSYNC_CHANGE); RSYNC_CHANGE, RSYNC_CHANGE);
return 0; return 0;
} }
...@@ -937,7 +937,7 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -937,7 +937,7 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
unsigned char inf = 0, mask = 0; unsigned char inf = 0, mask = 0;
/* bit size */ /* bit size */
...@@ -952,7 +952,7 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -952,7 +952,7 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
mask |= PCM_INF2_18WL; mask |= PCM_INF2_18WL;
snd_soc_update_bits(codec, PM860X_PCM_IFACE_2, mask, inf); snd_soc_component_update_bits(component, PM860X_PCM_IFACE_2, mask, inf);
/* sample rate */ /* sample rate */
switch (params_rate(params)) { switch (params_rate(params)) {
...@@ -971,7 +971,7 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -971,7 +971,7 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream,
default: default:
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, PM860X_PCM_RATE, 0x0f, inf); snd_soc_component_update_bits(component, PM860X_PCM_RATE, 0x0f, inf);
return 0; return 0;
} }
...@@ -979,8 +979,8 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -979,8 +979,8 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream,
static int pm860x_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, static int pm860x_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
unsigned char inf = 0, mask = 0; unsigned char inf = 0, mask = 0;
int ret = -EINVAL; int ret = -EINVAL;
...@@ -1012,15 +1012,15 @@ static int pm860x_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -1012,15 +1012,15 @@ static int pm860x_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai,
mask |= PCM_MODE_MASK; mask |= PCM_MODE_MASK;
if (ret) if (ret)
return ret; return ret;
snd_soc_update_bits(codec, PM860X_PCM_IFACE_2, mask, inf); snd_soc_component_update_bits(component, PM860X_PCM_IFACE_2, mask, inf);
return 0; return 0;
} }
static int pm860x_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int pm860x_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
if (dir == PM860X_CLK_DIR_OUT) if (dir == PM860X_CLK_DIR_OUT)
pm860x->dir = PM860X_CLK_DIR_OUT; pm860x->dir = PM860X_CLK_DIR_OUT;
...@@ -1034,7 +1034,7 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -1034,7 +1034,7 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
unsigned char inf; unsigned char inf;
/* bit size */ /* bit size */
...@@ -1048,7 +1048,7 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -1048,7 +1048,7 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream,
default: default:
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, PM860X_I2S_IFACE_2, PCM_INF2_18WL, inf); snd_soc_component_update_bits(component, PM860X_I2S_IFACE_2, PCM_INF2_18WL, inf);
/* sample rate */ /* sample rate */
switch (params_rate(params)) { switch (params_rate(params)) {
...@@ -1076,7 +1076,7 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -1076,7 +1076,7 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream,
default: default:
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, PM860X_I2S_IFACE_4, 0xf, inf); snd_soc_component_update_bits(component, PM860X_I2S_IFACE_4, 0xf, inf);
return 0; return 0;
} }
...@@ -1084,8 +1084,8 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -1084,8 +1084,8 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream,
static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
unsigned char inf = 0, mask = 0; unsigned char inf = 0, mask = 0;
mask |= PCM_INF2_BCLK | PCM_INF2_FS | PCM_INF2_MASTER; mask |= PCM_INF2_BCLK | PCM_INF2_FS | PCM_INF2_MASTER;
...@@ -1116,14 +1116,14 @@ static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -1116,14 +1116,14 @@ static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
mask |= PCM_MODE_MASK; mask |= PCM_MODE_MASK;
snd_soc_update_bits(codec, PM860X_I2S_IFACE_2, mask, inf); snd_soc_component_update_bits(component, PM860X_I2S_IFACE_2, mask, inf);
return 0; return 0;
} }
static int pm860x_set_bias_level(struct snd_soc_codec *codec, static int pm860x_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
int data; int data;
switch (level) { switch (level) {
...@@ -1134,7 +1134,7 @@ static int pm860x_set_bias_level(struct snd_soc_codec *codec, ...@@ -1134,7 +1134,7 @@ static int pm860x_set_bias_level(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
/* Enable Audio PLL & Audio section */ /* Enable Audio PLL & Audio section */
data = AUDIO_PLL | AUDIO_SECTION_ON; data = AUDIO_PLL | AUDIO_SECTION_ON;
pm860x_reg_write(pm860x->i2c, REG_MISC2, data); pm860x_reg_write(pm860x->i2c, REG_MISC2, data);
...@@ -1216,7 +1216,7 @@ static struct snd_soc_dai_driver pm860x_dai[] = { ...@@ -1216,7 +1216,7 @@ static struct snd_soc_dai_driver pm860x_dai[] = {
}, },
}; };
static irqreturn_t pm860x_codec_handler(int irq, void *data) static irqreturn_t pm860x_component_handler(int irq, void *data)
{ {
struct pm860x_priv *pm860x = data; struct pm860x_priv *pm860x = data;
int status, shrt, report = 0, mic_report = 0; int status, shrt, report = 0, mic_report = 0;
...@@ -1230,7 +1230,7 @@ static irqreturn_t pm860x_codec_handler(int irq, void *data) ...@@ -1230,7 +1230,7 @@ static irqreturn_t pm860x_codec_handler(int irq, void *data)
#ifndef CONFIG_SND_SOC_88PM860X_MODULE #ifndef CONFIG_SND_SOC_88PM860X_MODULE
if (status & (HEADSET_STATUS | MIC_STATUS | SHORT_HS1 | SHORT_HS2 | if (status & (HEADSET_STATUS | MIC_STATUS | SHORT_HS1 | SHORT_HS2 |
SHORT_LO1 | SHORT_LO2)) SHORT_LO1 | SHORT_LO2))
trace_snd_soc_jack_irq(dev_name(pm860x->codec->dev)); trace_snd_soc_jack_irq(dev_name(pm860x->component->dev));
#endif #endif
if ((pm860x->det.hp_det & SND_JACK_HEADPHONE) if ((pm860x->det.hp_det & SND_JACK_HEADPHONE)
...@@ -1256,17 +1256,17 @@ static irqreturn_t pm860x_codec_handler(int irq, void *data) ...@@ -1256,17 +1256,17 @@ static irqreturn_t pm860x_codec_handler(int irq, void *data)
snd_soc_jack_report(pm860x->det.mic_jack, SND_JACK_MICROPHONE, snd_soc_jack_report(pm860x->det.mic_jack, SND_JACK_MICROPHONE,
SND_JACK_MICROPHONE); SND_JACK_MICROPHONE);
dev_dbg(pm860x->codec->dev, "headphone report:0x%x, mask:%x\n", dev_dbg(pm860x->component->dev, "headphone report:0x%x, mask:%x\n",
report, mask); report, mask);
dev_dbg(pm860x->codec->dev, "microphone report:0x%x\n", mic_report); dev_dbg(pm860x->component->dev, "microphone report:0x%x\n", mic_report);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
int pm860x_hs_jack_detect(struct snd_soc_codec *codec, int pm860x_hs_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *jack, struct snd_soc_jack *jack,
int det, int hook, int hs_shrt, int lo_shrt) int det, int hook, int hs_shrt, int lo_shrt)
{ {
struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
int data; int data;
pm860x->det.hp_jack = jack; pm860x->det.hp_jack = jack;
...@@ -1290,15 +1290,15 @@ int pm860x_hs_jack_detect(struct snd_soc_codec *codec, ...@@ -1290,15 +1290,15 @@ int pm860x_hs_jack_detect(struct snd_soc_codec *codec,
} }
/* sync status */ /* sync status */
pm860x_codec_handler(0, pm860x); pm860x_component_handler(0, pm860x);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(pm860x_hs_jack_detect); EXPORT_SYMBOL_GPL(pm860x_hs_jack_detect);
int pm860x_mic_jack_detect(struct snd_soc_codec *codec, int pm860x_mic_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *jack, int det) struct snd_soc_jack *jack, int det)
{ {
struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
pm860x->det.mic_jack = jack; pm860x->det.mic_jack = jack;
pm860x->det.mic_det = det; pm860x->det.mic_det = det;
...@@ -1308,25 +1308,25 @@ int pm860x_mic_jack_detect(struct snd_soc_codec *codec, ...@@ -1308,25 +1308,25 @@ int pm860x_mic_jack_detect(struct snd_soc_codec *codec,
MICDET_MASK, MICDET_MASK); MICDET_MASK, MICDET_MASK);
/* sync status */ /* sync status */
pm860x_codec_handler(0, pm860x); pm860x_component_handler(0, pm860x);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(pm860x_mic_jack_detect); EXPORT_SYMBOL_GPL(pm860x_mic_jack_detect);
static int pm860x_probe(struct snd_soc_codec *codec) static int pm860x_probe(struct snd_soc_component *component)
{ {
struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
int i, ret; int i, ret;
pm860x->codec = codec; pm860x->component = component;
snd_soc_codec_init_regmap(codec, pm860x->regmap); snd_soc_component_init_regmap(component, pm860x->regmap);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
ret = request_threaded_irq(pm860x->irq[i], NULL, ret = request_threaded_irq(pm860x->irq[i], NULL,
pm860x_codec_handler, IRQF_ONESHOT, pm860x_component_handler, IRQF_ONESHOT,
pm860x->name[i], pm860x); pm860x->name[i], pm860x);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to request IRQ!\n"); dev_err(component->dev, "Failed to request IRQ!\n");
goto out; goto out;
} }
} }
...@@ -1339,29 +1339,29 @@ static int pm860x_probe(struct snd_soc_codec *codec) ...@@ -1339,29 +1339,29 @@ static int pm860x_probe(struct snd_soc_codec *codec)
return ret; return ret;
} }
static int pm860x_remove(struct snd_soc_codec *codec) static void pm860x_remove(struct snd_soc_component *component)
{ {
struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
int i; int i;
for (i = 3; i >= 0; i--) for (i = 3; i >= 0; i--)
free_irq(pm860x->irq[i], pm860x); free_irq(pm860x->irq[i], pm860x);
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_pm860x = { static const struct snd_soc_component_driver soc_component_dev_pm860x = {
.probe = pm860x_probe, .probe = pm860x_probe,
.remove = pm860x_remove, .remove = pm860x_remove,
.set_bias_level = pm860x_set_bias_level, .set_bias_level = pm860x_set_bias_level,
.controls = pm860x_snd_controls,
.component_driver = { .num_controls = ARRAY_SIZE(pm860x_snd_controls),
.controls = pm860x_snd_controls, .dapm_widgets = pm860x_dapm_widgets,
.num_controls = ARRAY_SIZE(pm860x_snd_controls), .num_dapm_widgets = ARRAY_SIZE(pm860x_dapm_widgets),
.dapm_widgets = pm860x_dapm_widgets, .dapm_routes = pm860x_dapm_routes,
.num_dapm_widgets = ARRAY_SIZE(pm860x_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(pm860x_dapm_routes),
.dapm_routes = pm860x_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(pm860x_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int pm860x_codec_probe(struct platform_device *pdev) static int pm860x_codec_probe(struct platform_device *pdev)
...@@ -1393,10 +1393,11 @@ static int pm860x_codec_probe(struct platform_device *pdev) ...@@ -1393,10 +1393,11 @@ static int pm860x_codec_probe(struct platform_device *pdev)
strncpy(pm860x->name[i], res->name, MAX_NAME_LEN); strncpy(pm860x->name[i], res->name, MAX_NAME_LEN);
} }
ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_pm860x, ret = devm_snd_soc_register_component(&pdev->dev,
&soc_component_dev_pm860x,
pm860x_dai, ARRAY_SIZE(pm860x_dai)); pm860x_dai, ARRAY_SIZE(pm860x_dai));
if (ret) { if (ret) {
dev_err(&pdev->dev, "Failed to register codec\n"); dev_err(&pdev->dev, "Failed to register component\n");
return -EINVAL; return -EINVAL;
} }
return ret; return ret;
...@@ -1404,7 +1405,6 @@ static int pm860x_codec_probe(struct platform_device *pdev) ...@@ -1404,7 +1405,6 @@ static int pm860x_codec_probe(struct platform_device *pdev)
static int pm860x_codec_remove(struct platform_device *pdev) static int pm860x_codec_remove(struct platform_device *pdev)
{ {
snd_soc_unregister_codec(&pdev->dev);
return 0; return 0;
} }
......
...@@ -88,9 +88,9 @@ ...@@ -88,9 +88,9 @@
#define PM860X_SHORT_LINEOUT (1 << 4) #define PM860X_SHORT_LINEOUT (1 << 4)
#define PM860X_DET_MASK 0x1F #define PM860X_DET_MASK 0x1F
extern int pm860x_hs_jack_detect(struct snd_soc_codec *, struct snd_soc_jack *, extern int pm860x_hs_jack_detect(struct snd_soc_component *, struct snd_soc_jack *,
int, int, int, int); int, int, int, int);
extern int pm860x_mic_jack_detect(struct snd_soc_codec *, struct snd_soc_jack *, extern int pm860x_mic_jack_detect(struct snd_soc_component *, struct snd_soc_jack *,
int); int);
#endif /* __88PM860X_H */ #endif /* __88PM860X_H */
...@@ -1037,86 +1037,86 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes_mic2_vamicx[] = { ...@@ -1037,86 +1037,86 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes_mic2_vamicx[] = {
}; };
/* ANC FIR-coefficients configuration sequence */ /* ANC FIR-coefficients configuration sequence */
static void anc_fir(struct snd_soc_codec *codec, static void anc_fir(struct snd_soc_component *component,
unsigned int bnk, unsigned int par, unsigned int val) unsigned int bnk, unsigned int par, unsigned int val)
{ {
if (par == 0 && bnk == 0) if (par == 0 && bnk == 0)
snd_soc_update_bits(codec, AB8500_ANCCONF1, snd_soc_component_update_bits(component, AB8500_ANCCONF1,
BIT(AB8500_ANCCONF1_ANCFIRUPDATE), BIT(AB8500_ANCCONF1_ANCFIRUPDATE),
BIT(AB8500_ANCCONF1_ANCFIRUPDATE)); BIT(AB8500_ANCCONF1_ANCFIRUPDATE));
snd_soc_write(codec, AB8500_ANCCONF5, val >> 8 & 0xff); snd_soc_component_write(component, AB8500_ANCCONF5, val >> 8 & 0xff);
snd_soc_write(codec, AB8500_ANCCONF6, val & 0xff); snd_soc_component_write(component, AB8500_ANCCONF6, val & 0xff);
if (par == AB8500_ANC_FIR_COEFFS - 1 && bnk == 1) if (par == AB8500_ANC_FIR_COEFFS - 1 && bnk == 1)
snd_soc_update_bits(codec, AB8500_ANCCONF1, snd_soc_component_update_bits(component, AB8500_ANCCONF1,
BIT(AB8500_ANCCONF1_ANCFIRUPDATE), 0); BIT(AB8500_ANCCONF1_ANCFIRUPDATE), 0);
} }
/* ANC IIR-coefficients configuration sequence */ /* ANC IIR-coefficients configuration sequence */
static void anc_iir(struct snd_soc_codec *codec, unsigned int bnk, static void anc_iir(struct snd_soc_component *component, unsigned int bnk,
unsigned int par, unsigned int val) unsigned int par, unsigned int val)
{ {
if (par == 0) { if (par == 0) {
if (bnk == 0) { if (bnk == 0) {
snd_soc_update_bits(codec, AB8500_ANCCONF1, snd_soc_component_update_bits(component, AB8500_ANCCONF1,
BIT(AB8500_ANCCONF1_ANCIIRINIT), BIT(AB8500_ANCCONF1_ANCIIRINIT),
BIT(AB8500_ANCCONF1_ANCIIRINIT)); BIT(AB8500_ANCCONF1_ANCIIRINIT));
usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY); usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY);
snd_soc_update_bits(codec, AB8500_ANCCONF1, snd_soc_component_update_bits(component, AB8500_ANCCONF1,
BIT(AB8500_ANCCONF1_ANCIIRINIT), 0); BIT(AB8500_ANCCONF1_ANCIIRINIT), 0);
usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY); usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY);
} else { } else {
snd_soc_update_bits(codec, AB8500_ANCCONF1, snd_soc_component_update_bits(component, AB8500_ANCCONF1,
BIT(AB8500_ANCCONF1_ANCIIRUPDATE), BIT(AB8500_ANCCONF1_ANCIIRUPDATE),
BIT(AB8500_ANCCONF1_ANCIIRUPDATE)); BIT(AB8500_ANCCONF1_ANCIIRUPDATE));
} }
} else if (par > 3) { } else if (par > 3) {
snd_soc_write(codec, AB8500_ANCCONF7, 0); snd_soc_component_write(component, AB8500_ANCCONF7, 0);
snd_soc_write(codec, AB8500_ANCCONF8, val >> 16 & 0xff); snd_soc_component_write(component, AB8500_ANCCONF8, val >> 16 & 0xff);
} }
snd_soc_write(codec, AB8500_ANCCONF7, val >> 8 & 0xff); snd_soc_component_write(component, AB8500_ANCCONF7, val >> 8 & 0xff);
snd_soc_write(codec, AB8500_ANCCONF8, val & 0xff); snd_soc_component_write(component, AB8500_ANCCONF8, val & 0xff);
if (par == AB8500_ANC_IIR_COEFFS - 1 && bnk == 1) if (par == AB8500_ANC_IIR_COEFFS - 1 && bnk == 1)
snd_soc_update_bits(codec, AB8500_ANCCONF1, snd_soc_component_update_bits(component, AB8500_ANCCONF1,
BIT(AB8500_ANCCONF1_ANCIIRUPDATE), 0); BIT(AB8500_ANCCONF1_ANCIIRUPDATE), 0);
} }
/* ANC IIR-/FIR-coefficients configuration sequence */ /* ANC IIR-/FIR-coefficients configuration sequence */
static void anc_configure(struct snd_soc_codec *codec, static void anc_configure(struct snd_soc_component *component,
bool apply_fir, bool apply_iir) bool apply_fir, bool apply_iir)
{ {
struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev);
unsigned int bnk, par, val; unsigned int bnk, par, val;
dev_dbg(codec->dev, "%s: Enter.\n", __func__); dev_dbg(component->dev, "%s: Enter.\n", __func__);
if (apply_fir) if (apply_fir)
snd_soc_update_bits(codec, AB8500_ANCCONF1, snd_soc_component_update_bits(component, AB8500_ANCCONF1,
BIT(AB8500_ANCCONF1_ENANC), 0); BIT(AB8500_ANCCONF1_ENANC), 0);
snd_soc_update_bits(codec, AB8500_ANCCONF1, snd_soc_component_update_bits(component, AB8500_ANCCONF1,
BIT(AB8500_ANCCONF1_ENANC), BIT(AB8500_ANCCONF1_ENANC)); BIT(AB8500_ANCCONF1_ENANC), BIT(AB8500_ANCCONF1_ENANC));
if (apply_fir) if (apply_fir)
for (bnk = 0; bnk < AB8500_NR_OF_ANC_COEFF_BANKS; bnk++) for (bnk = 0; bnk < AB8500_NR_OF_ANC_COEFF_BANKS; bnk++)
for (par = 0; par < AB8500_ANC_FIR_COEFFS; par++) { for (par = 0; par < AB8500_ANC_FIR_COEFFS; par++) {
val = snd_soc_read(codec, val = snd_soc_component_read32(component,
drvdata->anc_fir_values[par]); drvdata->anc_fir_values[par]);
anc_fir(codec, bnk, par, val); anc_fir(component, bnk, par, val);
} }
if (apply_iir) if (apply_iir)
for (bnk = 0; bnk < AB8500_NR_OF_ANC_COEFF_BANKS; bnk++) for (bnk = 0; bnk < AB8500_NR_OF_ANC_COEFF_BANKS; bnk++)
for (par = 0; par < AB8500_ANC_IIR_COEFFS; par++) { for (par = 0; par < AB8500_ANC_IIR_COEFFS; par++) {
val = snd_soc_read(codec, val = snd_soc_component_read32(component,
drvdata->anc_iir_values[par]); drvdata->anc_iir_values[par]);
anc_iir(codec, bnk, par, val); anc_iir(component, bnk, par, val);
} }
dev_dbg(codec->dev, "%s: Exit.\n", __func__); dev_dbg(component->dev, "%s: Exit.\n", __func__);
} }
/* /*
...@@ -1126,8 +1126,8 @@ static void anc_configure(struct snd_soc_codec *codec, ...@@ -1126,8 +1126,8 @@ static void anc_configure(struct snd_soc_codec *codec,
static int sid_status_control_get(struct snd_kcontrol *kcontrol, static int sid_status_control_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev);
mutex_lock(&drvdata->ctrl_lock); mutex_lock(&drvdata->ctrl_lock);
ucontrol->value.enumerated.item[0] = drvdata->sid_status; ucontrol->value.enumerated.item[0] = drvdata->sid_status;
...@@ -1140,15 +1140,15 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol, ...@@ -1140,15 +1140,15 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol,
static int sid_status_control_put(struct snd_kcontrol *kcontrol, static int sid_status_control_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev);
unsigned int param, sidconf, val; unsigned int param, sidconf, val;
int status = 1; int status = 1;
dev_dbg(codec->dev, "%s: Enter\n", __func__); dev_dbg(component->dev, "%s: Enter\n", __func__);
if (ucontrol->value.enumerated.item[0] != SID_APPLY_FIR) { if (ucontrol->value.enumerated.item[0] != SID_APPLY_FIR) {
dev_err(codec->dev, dev_err(component->dev,
"%s: ERROR: This control supports '%s' only!\n", "%s: ERROR: This control supports '%s' only!\n",
__func__, enum_sid_state[SID_APPLY_FIR]); __func__, enum_sid_state[SID_APPLY_FIR]);
return -EIO; return -EIO;
...@@ -1156,10 +1156,10 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol, ...@@ -1156,10 +1156,10 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol,
mutex_lock(&drvdata->ctrl_lock); mutex_lock(&drvdata->ctrl_lock);
sidconf = snd_soc_read(codec, AB8500_SIDFIRCONF); sidconf = snd_soc_component_read32(component, AB8500_SIDFIRCONF);
if (((sidconf & BIT(AB8500_SIDFIRCONF_FIRSIDBUSY)) != 0)) { if (((sidconf & BIT(AB8500_SIDFIRCONF_FIRSIDBUSY)) != 0)) {
if ((sidconf & BIT(AB8500_SIDFIRCONF_ENFIRSIDS)) == 0) { if ((sidconf & BIT(AB8500_SIDFIRCONF_ENFIRSIDS)) == 0) {
dev_err(codec->dev, "%s: Sidetone busy while off!\n", dev_err(component->dev, "%s: Sidetone busy while off!\n",
__func__); __func__);
status = -EPERM; status = -EPERM;
} else { } else {
...@@ -1168,18 +1168,18 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol, ...@@ -1168,18 +1168,18 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol,
goto out; goto out;
} }
snd_soc_write(codec, AB8500_SIDFIRADR, 0); snd_soc_component_write(component, AB8500_SIDFIRADR, 0);
for (param = 0; param < AB8500_SID_FIR_COEFFS; param++) { for (param = 0; param < AB8500_SID_FIR_COEFFS; param++) {
val = snd_soc_read(codec, drvdata->sid_fir_values[param]); val = snd_soc_component_read32(component, drvdata->sid_fir_values[param]);
snd_soc_write(codec, AB8500_SIDFIRCOEF1, val >> 8 & 0xff); snd_soc_component_write(component, AB8500_SIDFIRCOEF1, val >> 8 & 0xff);
snd_soc_write(codec, AB8500_SIDFIRCOEF2, val & 0xff); snd_soc_component_write(component, AB8500_SIDFIRCOEF2, val & 0xff);
} }
snd_soc_update_bits(codec, AB8500_SIDFIRADR, snd_soc_component_update_bits(component, AB8500_SIDFIRADR,
BIT(AB8500_SIDFIRADR_FIRSIDSET), BIT(AB8500_SIDFIRADR_FIRSIDSET),
BIT(AB8500_SIDFIRADR_FIRSIDSET)); BIT(AB8500_SIDFIRADR_FIRSIDSET));
snd_soc_update_bits(codec, AB8500_SIDFIRADR, snd_soc_component_update_bits(component, AB8500_SIDFIRADR,
BIT(AB8500_SIDFIRADR_FIRSIDSET), 0); BIT(AB8500_SIDFIRADR_FIRSIDSET), 0);
drvdata->sid_status = SID_FIR_CONFIGURED; drvdata->sid_status = SID_FIR_CONFIGURED;
...@@ -1187,7 +1187,7 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol, ...@@ -1187,7 +1187,7 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol,
out: out:
mutex_unlock(&drvdata->ctrl_lock); mutex_unlock(&drvdata->ctrl_lock);
dev_dbg(codec->dev, "%s: Exit\n", __func__); dev_dbg(component->dev, "%s: Exit\n", __func__);
return status; return status;
} }
...@@ -1195,8 +1195,8 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol, ...@@ -1195,8 +1195,8 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol,
static int anc_status_control_get(struct snd_kcontrol *kcontrol, static int anc_status_control_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev);
mutex_lock(&drvdata->ctrl_lock); mutex_lock(&drvdata->ctrl_lock);
ucontrol->value.enumerated.item[0] = drvdata->anc_status; ucontrol->value.enumerated.item[0] = drvdata->anc_status;
...@@ -1208,10 +1208,10 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol, ...@@ -1208,10 +1208,10 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol,
static int anc_status_control_put(struct snd_kcontrol *kcontrol, static int anc_status_control_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev);
struct device *dev = codec->dev; struct device *dev = component->dev;
bool apply_fir, apply_iir; bool apply_fir, apply_iir;
unsigned int req; unsigned int req;
int status; int status;
...@@ -1244,7 +1244,7 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol, ...@@ -1244,7 +1244,7 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol,
} }
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
anc_configure(codec, apply_fir, apply_iir); anc_configure(component, apply_fir, apply_iir);
if (apply_fir) { if (apply_fir) {
if (drvdata->anc_status == ANC_IIR_CONFIGURED) if (drvdata->anc_status == ANC_IIR_CONFIGURED)
...@@ -1291,8 +1291,8 @@ static int filter_control_info(struct snd_kcontrol *kcontrol, ...@@ -1291,8 +1291,8 @@ static int filter_control_info(struct snd_kcontrol *kcontrol,
static int filter_control_get(struct snd_kcontrol *kcontrol, static int filter_control_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct ab8500_codec_drvdata *drvdata = snd_soc_codec_get_drvdata(codec); struct ab8500_codec_drvdata *drvdata = snd_soc_component_get_drvdata(component);
struct filter_control *fc = struct filter_control *fc =
(struct filter_control *)kcontrol->private_value; (struct filter_control *)kcontrol->private_value;
unsigned int i; unsigned int i;
...@@ -1308,8 +1308,8 @@ static int filter_control_get(struct snd_kcontrol *kcontrol, ...@@ -1308,8 +1308,8 @@ static int filter_control_get(struct snd_kcontrol *kcontrol,
static int filter_control_put(struct snd_kcontrol *kcontrol, static int filter_control_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct ab8500_codec_drvdata *drvdata = snd_soc_codec_get_drvdata(codec); struct ab8500_codec_drvdata *drvdata = snd_soc_component_get_drvdata(component);
struct filter_control *fc = struct filter_control *fc =
(struct filter_control *)kcontrol->private_value; (struct filter_control *)kcontrol->private_value;
unsigned int i; unsigned int i;
...@@ -1926,11 +1926,11 @@ enum ab8500_filter { ...@@ -1926,11 +1926,11 @@ enum ab8500_filter {
* Extended interface for codec-driver * Extended interface for codec-driver
*/ */
static int ab8500_audio_init_audioblock(struct snd_soc_codec *codec) static int ab8500_audio_init_audioblock(struct snd_soc_component *component)
{ {
int status; int status;
dev_dbg(codec->dev, "%s: Enter.\n", __func__); dev_dbg(component->dev, "%s: Enter.\n", __func__);
/* Reset audio-registers and disable 32kHz-clock output 2 */ /* Reset audio-registers and disable 32kHz-clock output 2 */
status = ab8500_sysctrl_write(AB8500_STW4500CTRL3, status = ab8500_sysctrl_write(AB8500_STW4500CTRL3,
...@@ -1943,26 +1943,26 @@ static int ab8500_audio_init_audioblock(struct snd_soc_codec *codec) ...@@ -1943,26 +1943,26 @@ static int ab8500_audio_init_audioblock(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int ab8500_audio_setup_mics(struct snd_soc_codec *codec, static int ab8500_audio_setup_mics(struct snd_soc_component *component,
struct amic_settings *amics) struct amic_settings *amics)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
u8 value8; u8 value8;
unsigned int value; unsigned int value;
int status; int status;
const struct snd_soc_dapm_route *route; const struct snd_soc_dapm_route *route;
dev_dbg(codec->dev, "%s: Enter.\n", __func__); dev_dbg(component->dev, "%s: Enter.\n", __func__);
/* Set DMic-clocks to outputs */ /* Set DMic-clocks to outputs */
status = abx500_get_register_interruptible(codec->dev, AB8500_MISC, status = abx500_get_register_interruptible(component->dev, AB8500_MISC,
AB8500_GPIO_DIR4_REG, AB8500_GPIO_DIR4_REG,
&value8); &value8);
if (status < 0) if (status < 0)
return status; return status;
value = value8 | GPIO27_DIR_OUTPUT | GPIO29_DIR_OUTPUT | value = value8 | GPIO27_DIR_OUTPUT | GPIO29_DIR_OUTPUT |
GPIO31_DIR_OUTPUT; GPIO31_DIR_OUTPUT;
status = abx500_set_register_interruptible(codec->dev, status = abx500_set_register_interruptible(component->dev,
AB8500_MISC, AB8500_MISC,
AB8500_GPIO_DIR4_REG, AB8500_GPIO_DIR4_REG,
value); value);
...@@ -1970,41 +1970,41 @@ static int ab8500_audio_setup_mics(struct snd_soc_codec *codec, ...@@ -1970,41 +1970,41 @@ static int ab8500_audio_setup_mics(struct snd_soc_codec *codec,
return status; return status;
/* Attach regulators to AMic DAPM-paths */ /* Attach regulators to AMic DAPM-paths */
dev_dbg(codec->dev, "%s: Mic 1a regulator: %s\n", __func__, dev_dbg(component->dev, "%s: Mic 1a regulator: %s\n", __func__,
amic_micbias_str(amics->mic1a_micbias)); amic_micbias_str(amics->mic1a_micbias));
route = &ab8500_dapm_routes_mic1a_vamicx[amics->mic1a_micbias]; route = &ab8500_dapm_routes_mic1a_vamicx[amics->mic1a_micbias];
status = snd_soc_dapm_add_routes(dapm, route, 1); status = snd_soc_dapm_add_routes(dapm, route, 1);
dev_dbg(codec->dev, "%s: Mic 1b regulator: %s\n", __func__, dev_dbg(component->dev, "%s: Mic 1b regulator: %s\n", __func__,
amic_micbias_str(amics->mic1b_micbias)); amic_micbias_str(amics->mic1b_micbias));
route = &ab8500_dapm_routes_mic1b_vamicx[amics->mic1b_micbias]; route = &ab8500_dapm_routes_mic1b_vamicx[amics->mic1b_micbias];
status |= snd_soc_dapm_add_routes(dapm, route, 1); status |= snd_soc_dapm_add_routes(dapm, route, 1);
dev_dbg(codec->dev, "%s: Mic 2 regulator: %s\n", __func__, dev_dbg(component->dev, "%s: Mic 2 regulator: %s\n", __func__,
amic_micbias_str(amics->mic2_micbias)); amic_micbias_str(amics->mic2_micbias));
route = &ab8500_dapm_routes_mic2_vamicx[amics->mic2_micbias]; route = &ab8500_dapm_routes_mic2_vamicx[amics->mic2_micbias];
status |= snd_soc_dapm_add_routes(dapm, route, 1); status |= snd_soc_dapm_add_routes(dapm, route, 1);
if (status < 0) { if (status < 0) {
dev_err(codec->dev, dev_err(component->dev,
"%s: Failed to add AMic-regulator DAPM-routes (%d).\n", "%s: Failed to add AMic-regulator DAPM-routes (%d).\n",
__func__, status); __func__, status);
return status; return status;
} }
/* Set AMic-configuration */ /* Set AMic-configuration */
dev_dbg(codec->dev, "%s: Mic 1 mic-type: %s\n", __func__, dev_dbg(component->dev, "%s: Mic 1 mic-type: %s\n", __func__,
amic_type_str(amics->mic1_type)); amic_type_str(amics->mic1_type));
snd_soc_update_bits(codec, AB8500_ANAGAIN1, AB8500_ANAGAINX_ENSEMICX, snd_soc_component_update_bits(component, AB8500_ANAGAIN1, AB8500_ANAGAINX_ENSEMICX,
amics->mic1_type == AMIC_TYPE_DIFFERENTIAL ? amics->mic1_type == AMIC_TYPE_DIFFERENTIAL ?
0 : AB8500_ANAGAINX_ENSEMICX); 0 : AB8500_ANAGAINX_ENSEMICX);
dev_dbg(codec->dev, "%s: Mic 2 mic-type: %s\n", __func__, dev_dbg(component->dev, "%s: Mic 2 mic-type: %s\n", __func__,
amic_type_str(amics->mic2_type)); amic_type_str(amics->mic2_type));
snd_soc_update_bits(codec, AB8500_ANAGAIN2, AB8500_ANAGAINX_ENSEMICX, snd_soc_component_update_bits(component, AB8500_ANAGAIN2, AB8500_ANAGAINX_ENSEMICX,
amics->mic2_type == AMIC_TYPE_DIFFERENTIAL ? amics->mic2_type == AMIC_TYPE_DIFFERENTIAL ?
0 : AB8500_ANAGAINX_ENSEMICX); 0 : AB8500_ANAGAINX_ENSEMICX);
return 0; return 0;
} }
static int ab8500_audio_set_ear_cmv(struct snd_soc_codec *codec, static int ab8500_audio_set_ear_cmv(struct snd_soc_component *component,
enum ear_cm_voltage ear_cmv) enum ear_cm_voltage ear_cmv)
{ {
char *cmv_str; char *cmv_str;
...@@ -2023,14 +2023,14 @@ static int ab8500_audio_set_ear_cmv(struct snd_soc_codec *codec, ...@@ -2023,14 +2023,14 @@ static int ab8500_audio_set_ear_cmv(struct snd_soc_codec *codec,
cmv_str = "1.58V"; cmv_str = "1.58V";
break; break;
default: default:
dev_err(codec->dev, dev_err(component->dev,
"%s: Unknown earpiece CM-voltage (%d)!\n", "%s: Unknown earpiece CM-voltage (%d)!\n",
__func__, (int)ear_cmv); __func__, (int)ear_cmv);
return -EINVAL; return -EINVAL;
} }
dev_dbg(codec->dev, "%s: Earpiece CM-voltage: %s\n", __func__, dev_dbg(component->dev, "%s: Earpiece CM-voltage: %s\n", __func__,
cmv_str); cmv_str);
snd_soc_update_bits(codec, AB8500_ANACONF1, AB8500_ANACONF1_EARSELCM, snd_soc_component_update_bits(component, AB8500_ANACONF1, AB8500_ANACONF1_EARSELCM,
ear_cmv); ear_cmv);
return 0; return 0;
...@@ -2040,7 +2040,7 @@ static int ab8500_audio_set_bit_delay(struct snd_soc_dai *dai, ...@@ -2040,7 +2040,7 @@ static int ab8500_audio_set_bit_delay(struct snd_soc_dai *dai,
unsigned int delay) unsigned int delay)
{ {
unsigned int mask, val; unsigned int mask, val;
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
mask = BIT(AB8500_DIGIFCONF2_IF0DEL); mask = BIT(AB8500_DIGIFCONF2_IF0DEL);
val = 0; val = 0;
...@@ -2052,21 +2052,21 @@ static int ab8500_audio_set_bit_delay(struct snd_soc_dai *dai, ...@@ -2052,21 +2052,21 @@ static int ab8500_audio_set_bit_delay(struct snd_soc_dai *dai,
val |= BIT(AB8500_DIGIFCONF2_IF0DEL); val |= BIT(AB8500_DIGIFCONF2_IF0DEL);
break; break;
default: default:
dev_err(dai->codec->dev, dev_err(dai->component->dev,
"%s: ERROR: Unsupported bit-delay (0x%x)!\n", "%s: ERROR: Unsupported bit-delay (0x%x)!\n",
__func__, delay); __func__, delay);
return -EINVAL; return -EINVAL;
} }
dev_dbg(dai->codec->dev, "%s: IF0 Bit-delay: %d bits.\n", dev_dbg(dai->component->dev, "%s: IF0 Bit-delay: %d bits.\n",
__func__, delay); __func__, delay);
snd_soc_update_bits(codec, AB8500_DIGIFCONF2, mask, val); snd_soc_component_update_bits(component, AB8500_DIGIFCONF2, mask, val);
return 0; return 0;
} }
/* Gates clocking according format mask */ /* Gates clocking according format mask */
static int ab8500_codec_set_dai_clock_gate(struct snd_soc_codec *codec, static int ab8500_codec_set_dai_clock_gate(struct snd_soc_component *component,
unsigned int fmt) unsigned int fmt)
{ {
unsigned int mask; unsigned int mask;
...@@ -2079,22 +2079,22 @@ static int ab8500_codec_set_dai_clock_gate(struct snd_soc_codec *codec, ...@@ -2079,22 +2079,22 @@ static int ab8500_codec_set_dai_clock_gate(struct snd_soc_codec *codec,
switch (fmt & SND_SOC_DAIFMT_CLOCK_MASK) { switch (fmt & SND_SOC_DAIFMT_CLOCK_MASK) {
case SND_SOC_DAIFMT_CONT: /* continuous clock */ case SND_SOC_DAIFMT_CONT: /* continuous clock */
dev_dbg(codec->dev, "%s: IF0 Clock is continuous.\n", dev_dbg(component->dev, "%s: IF0 Clock is continuous.\n",
__func__); __func__);
val |= BIT(AB8500_DIGIFCONF1_ENFSBITCLK0); val |= BIT(AB8500_DIGIFCONF1_ENFSBITCLK0);
break; break;
case SND_SOC_DAIFMT_GATED: /* clock is gated */ case SND_SOC_DAIFMT_GATED: /* clock is gated */
dev_dbg(codec->dev, "%s: IF0 Clock is gated.\n", dev_dbg(component->dev, "%s: IF0 Clock is gated.\n",
__func__); __func__);
break; break;
default: default:
dev_err(codec->dev, dev_err(component->dev,
"%s: ERROR: Unsupported clock mask (0x%x)!\n", "%s: ERROR: Unsupported clock mask (0x%x)!\n",
__func__, fmt & SND_SOC_DAIFMT_CLOCK_MASK); __func__, fmt & SND_SOC_DAIFMT_CLOCK_MASK);
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, AB8500_DIGIFCONF1, mask, val); snd_soc_component_update_bits(component, AB8500_DIGIFCONF1, mask, val);
return 0; return 0;
} }
...@@ -2103,10 +2103,10 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2103,10 +2103,10 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
unsigned int mask; unsigned int mask;
unsigned int val; unsigned int val;
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
int status; int status;
dev_dbg(codec->dev, "%s: Enter (fmt = 0x%x)\n", __func__, fmt); dev_dbg(component->dev, "%s: Enter (fmt = 0x%x)\n", __func__, fmt);
mask = BIT(AB8500_DIGIFCONF3_IF1DATOIF0AD) | mask = BIT(AB8500_DIGIFCONF3_IF1DATOIF0AD) |
BIT(AB8500_DIGIFCONF3_IF1CLKTOIF0CLK) | BIT(AB8500_DIGIFCONF3_IF1CLKTOIF0CLK) |
...@@ -2116,32 +2116,32 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2116,32 +2116,32 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & FRM master */ case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & FRM master */
dev_dbg(dai->codec->dev, dev_dbg(dai->component->dev,
"%s: IF0 Master-mode: AB8500 master.\n", __func__); "%s: IF0 Master-mode: AB8500 master.\n", __func__);
val |= BIT(AB8500_DIGIFCONF3_IF0MASTER); val |= BIT(AB8500_DIGIFCONF3_IF0MASTER);
break; break;
case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & FRM slave */ case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & FRM slave */
dev_dbg(dai->codec->dev, dev_dbg(dai->component->dev,
"%s: IF0 Master-mode: AB8500 slave.\n", __func__); "%s: IF0 Master-mode: AB8500 slave.\n", __func__);
break; break;
case SND_SOC_DAIFMT_CBS_CFM: /* codec clk slave & FRM master */ case SND_SOC_DAIFMT_CBS_CFM: /* codec clk slave & FRM master */
case SND_SOC_DAIFMT_CBM_CFS: /* codec clk master & frame slave */ case SND_SOC_DAIFMT_CBM_CFS: /* codec clk master & frame slave */
dev_err(dai->codec->dev, dev_err(dai->component->dev,
"%s: ERROR: The device is either a master or a slave.\n", "%s: ERROR: The device is either a master or a slave.\n",
__func__); __func__);
default: default:
dev_err(dai->codec->dev, dev_err(dai->component->dev,
"%s: ERROR: Unsupporter master mask 0x%x\n", "%s: ERROR: Unsupporter master mask 0x%x\n",
__func__, fmt & SND_SOC_DAIFMT_MASTER_MASK); __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, AB8500_DIGIFCONF3, mask, val); snd_soc_component_update_bits(component, AB8500_DIGIFCONF3, mask, val);
/* Set clock gating */ /* Set clock gating */
status = ab8500_codec_set_dai_clock_gate(codec, fmt); status = ab8500_codec_set_dai_clock_gate(component, fmt);
if (status) { if (status) {
dev_err(dai->codec->dev, dev_err(dai->component->dev,
"%s: ERROR: Failed to set clock gate (%d).\n", "%s: ERROR: Failed to set clock gate (%d).\n",
__func__, status); __func__, status);
return status; return status;
...@@ -2157,27 +2157,27 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2157,27 +2157,27 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S: /* I2S mode */ case SND_SOC_DAIFMT_I2S: /* I2S mode */
dev_dbg(dai->codec->dev, "%s: IF0 Protocol: I2S\n", __func__); dev_dbg(dai->component->dev, "%s: IF0 Protocol: I2S\n", __func__);
val |= BIT(AB8500_DIGIFCONF2_IF0FORMAT1); val |= BIT(AB8500_DIGIFCONF2_IF0FORMAT1);
ab8500_audio_set_bit_delay(dai, 0); ab8500_audio_set_bit_delay(dai, 0);
break; break;
case SND_SOC_DAIFMT_DSP_A: /* L data MSB after FRM LRC */ case SND_SOC_DAIFMT_DSP_A: /* L data MSB after FRM LRC */
dev_dbg(dai->codec->dev, dev_dbg(dai->component->dev,
"%s: IF0 Protocol: DSP A (TDM)\n", __func__); "%s: IF0 Protocol: DSP A (TDM)\n", __func__);
val |= BIT(AB8500_DIGIFCONF2_IF0FORMAT0); val |= BIT(AB8500_DIGIFCONF2_IF0FORMAT0);
ab8500_audio_set_bit_delay(dai, 1); ab8500_audio_set_bit_delay(dai, 1);
break; break;
case SND_SOC_DAIFMT_DSP_B: /* L data MSB during FRM LRC */ case SND_SOC_DAIFMT_DSP_B: /* L data MSB during FRM LRC */
dev_dbg(dai->codec->dev, dev_dbg(dai->component->dev,
"%s: IF0 Protocol: DSP B (TDM)\n", __func__); "%s: IF0 Protocol: DSP B (TDM)\n", __func__);
val |= BIT(AB8500_DIGIFCONF2_IF0FORMAT0); val |= BIT(AB8500_DIGIFCONF2_IF0FORMAT0);
ab8500_audio_set_bit_delay(dai, 0); ab8500_audio_set_bit_delay(dai, 0);
break; break;
default: default:
dev_err(dai->codec->dev, dev_err(dai->component->dev,
"%s: ERROR: Unsupported format (0x%x)!\n", "%s: ERROR: Unsupported format (0x%x)!\n",
__func__, fmt & SND_SOC_DAIFMT_FORMAT_MASK); __func__, fmt & SND_SOC_DAIFMT_FORMAT_MASK);
return -EINVAL; return -EINVAL;
...@@ -2185,37 +2185,37 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2185,37 +2185,37 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
switch (fmt & SND_SOC_DAIFMT_INV_MASK) { switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_NB_NF: /* normal bit clock + frame */ case SND_SOC_DAIFMT_NB_NF: /* normal bit clock + frame */
dev_dbg(dai->codec->dev, dev_dbg(dai->component->dev,
"%s: IF0: Normal bit clock, normal frame\n", "%s: IF0: Normal bit clock, normal frame\n",
__func__); __func__);
break; break;
case SND_SOC_DAIFMT_NB_IF: /* normal BCLK + inv FRM */ case SND_SOC_DAIFMT_NB_IF: /* normal BCLK + inv FRM */
dev_dbg(dai->codec->dev, dev_dbg(dai->component->dev,
"%s: IF0: Normal bit clock, inverted frame\n", "%s: IF0: Normal bit clock, inverted frame\n",
__func__); __func__);
val |= BIT(AB8500_DIGIFCONF2_FSYNC0P); val |= BIT(AB8500_DIGIFCONF2_FSYNC0P);
break; break;
case SND_SOC_DAIFMT_IB_NF: /* invert BCLK + nor FRM */ case SND_SOC_DAIFMT_IB_NF: /* invert BCLK + nor FRM */
dev_dbg(dai->codec->dev, dev_dbg(dai->component->dev,
"%s: IF0: Inverted bit clock, normal frame\n", "%s: IF0: Inverted bit clock, normal frame\n",
__func__); __func__);
val |= BIT(AB8500_DIGIFCONF2_BITCLK0P); val |= BIT(AB8500_DIGIFCONF2_BITCLK0P);
break; break;
case SND_SOC_DAIFMT_IB_IF: /* invert BCLK + FRM */ case SND_SOC_DAIFMT_IB_IF: /* invert BCLK + FRM */
dev_dbg(dai->codec->dev, dev_dbg(dai->component->dev,
"%s: IF0: Inverted bit clock, inverted frame\n", "%s: IF0: Inverted bit clock, inverted frame\n",
__func__); __func__);
val |= BIT(AB8500_DIGIFCONF2_FSYNC0P); val |= BIT(AB8500_DIGIFCONF2_FSYNC0P);
val |= BIT(AB8500_DIGIFCONF2_BITCLK0P); val |= BIT(AB8500_DIGIFCONF2_BITCLK0P);
break; break;
default: default:
dev_err(dai->codec->dev, dev_err(dai->component->dev,
"%s: ERROR: Unsupported INV mask 0x%x\n", "%s: ERROR: Unsupported INV mask 0x%x\n",
__func__, fmt & SND_SOC_DAIFMT_INV_MASK); __func__, fmt & SND_SOC_DAIFMT_INV_MASK);
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, AB8500_DIGIFCONF2, mask, val); snd_soc_component_update_bits(component, AB8500_DIGIFCONF2, mask, val);
return 0; return 0;
} }
...@@ -2224,7 +2224,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -2224,7 +2224,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,
unsigned int tx_mask, unsigned int rx_mask, unsigned int tx_mask, unsigned int rx_mask,
int slots, int slot_width) int slots, int slot_width)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
unsigned int val, mask, slot, slots_active; unsigned int val, mask, slot, slots_active;
mask = BIT(AB8500_DIGIFCONF2_IF0WL0) | mask = BIT(AB8500_DIGIFCONF2_IF0WL0) |
...@@ -2245,17 +2245,17 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -2245,17 +2245,17 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,
BIT(AB8500_DIGIFCONF2_IF0WL0); BIT(AB8500_DIGIFCONF2_IF0WL0);
break; break;
default: default:
dev_err(dai->codec->dev, "%s: Unsupported slot-width 0x%x\n", dev_err(dai->component->dev, "%s: Unsupported slot-width 0x%x\n",
__func__, slot_width); __func__, slot_width);
return -EINVAL; return -EINVAL;
} }
dev_dbg(dai->codec->dev, "%s: IF0 slot-width: %d bits.\n", dev_dbg(dai->component->dev, "%s: IF0 slot-width: %d bits.\n",
__func__, slot_width); __func__, slot_width);
snd_soc_update_bits(codec, AB8500_DIGIFCONF2, mask, val); snd_soc_component_update_bits(component, AB8500_DIGIFCONF2, mask, val);
/* Setup TDM clocking according to slot count */ /* Setup TDM clocking according to slot count */
dev_dbg(dai->codec->dev, "%s: Slots, total: %d\n", __func__, slots); dev_dbg(dai->component->dev, "%s: Slots, total: %d\n", __func__, slots);
mask = BIT(AB8500_DIGIFCONF1_IF0BITCLKOS0) | mask = BIT(AB8500_DIGIFCONF1_IF0BITCLKOS0) |
BIT(AB8500_DIGIFCONF1_IF0BITCLKOS1); BIT(AB8500_DIGIFCONF1_IF0BITCLKOS1);
switch (slots) { switch (slots) {
...@@ -2273,12 +2273,12 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -2273,12 +2273,12 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,
BIT(AB8500_DIGIFCONF1_IF0BITCLKOS1); BIT(AB8500_DIGIFCONF1_IF0BITCLKOS1);
break; break;
default: default:
dev_err(dai->codec->dev, dev_err(dai->component->dev,
"%s: ERROR: Unsupported number of slots (%d)!\n", "%s: ERROR: Unsupported number of slots (%d)!\n",
__func__, slots); __func__, slots);
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, AB8500_DIGIFCONF1, mask, val); snd_soc_component_update_bits(component, AB8500_DIGIFCONF1, mask, val);
/* Setup TDM DA according to active tx slots */ /* Setup TDM DA according to active tx slots */
...@@ -2289,7 +2289,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -2289,7 +2289,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,
tx_mask = tx_mask << AB8500_DA_DATA0_OFFSET; tx_mask = tx_mask << AB8500_DA_DATA0_OFFSET;
slots_active = hweight32(tx_mask); slots_active = hweight32(tx_mask);
dev_dbg(dai->codec->dev, "%s: Slots, active, TX: %d\n", __func__, dev_dbg(dai->component->dev, "%s: Slots, active, TX: %d\n", __func__,
slots_active); slots_active);
switch (slots_active) { switch (slots_active) {
...@@ -2297,26 +2297,26 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -2297,26 +2297,26 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,
break; break;
case 1: case 1:
slot = ffs(tx_mask); slot = ffs(tx_mask);
snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); snd_soc_component_update_bits(component, AB8500_DASLOTCONF1, mask, slot);
snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); snd_soc_component_update_bits(component, AB8500_DASLOTCONF3, mask, slot);
snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); snd_soc_component_update_bits(component, AB8500_DASLOTCONF2, mask, slot);
snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); snd_soc_component_update_bits(component, AB8500_DASLOTCONF4, mask, slot);
break; break;
case 2: case 2:
slot = ffs(tx_mask); slot = ffs(tx_mask);
snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); snd_soc_component_update_bits(component, AB8500_DASLOTCONF1, mask, slot);
snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); snd_soc_component_update_bits(component, AB8500_DASLOTCONF3, mask, slot);
slot = fls(tx_mask); slot = fls(tx_mask);
snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); snd_soc_component_update_bits(component, AB8500_DASLOTCONF2, mask, slot);
snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); snd_soc_component_update_bits(component, AB8500_DASLOTCONF4, mask, slot);
break; break;
case 8: case 8:
dev_dbg(dai->codec->dev, dev_dbg(dai->component->dev,
"%s: In 8-channel mode DA-from-slot mapping is set manually.", "%s: In 8-channel mode DA-from-slot mapping is set manually.",
__func__); __func__);
break; break;
default: default:
dev_err(dai->codec->dev, dev_err(dai->component->dev,
"%s: Unsupported number of active TX-slots (%d)!\n", "%s: Unsupported number of active TX-slots (%d)!\n",
__func__, slots_active); __func__, slots_active);
return -EINVAL; return -EINVAL;
...@@ -2330,7 +2330,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -2330,7 +2330,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,
rx_mask = rx_mask << AB8500_AD_DATA0_OFFSET; rx_mask = rx_mask << AB8500_AD_DATA0_OFFSET;
slots_active = hweight32(rx_mask); slots_active = hweight32(rx_mask);
dev_dbg(dai->codec->dev, "%s: Slots, active, RX: %d\n", __func__, dev_dbg(dai->component->dev, "%s: Slots, active, RX: %d\n", __func__,
slots_active); slots_active);
switch (slots_active) { switch (slots_active) {
...@@ -2338,29 +2338,29 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -2338,29 +2338,29 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,
break; break;
case 1: case 1:
slot = ffs(rx_mask); slot = ffs(rx_mask);
snd_soc_update_bits(codec, AB8500_ADSLOTSEL(slot), snd_soc_component_update_bits(component, AB8500_ADSLOTSEL(slot),
AB8500_MASK_SLOT(slot), AB8500_MASK_SLOT(slot),
AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot));
break; break;
case 2: case 2:
slot = ffs(rx_mask); slot = ffs(rx_mask);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
AB8500_ADSLOTSEL(slot), AB8500_ADSLOTSEL(slot),
AB8500_MASK_SLOT(slot), AB8500_MASK_SLOT(slot),
AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot));
slot = fls(rx_mask); slot = fls(rx_mask);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
AB8500_ADSLOTSEL(slot), AB8500_ADSLOTSEL(slot),
AB8500_MASK_SLOT(slot), AB8500_MASK_SLOT(slot),
AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT2, slot)); AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT2, slot));
break; break;
case 8: case 8:
dev_dbg(dai->codec->dev, dev_dbg(dai->component->dev,
"%s: In 8-channel mode AD-to-slot mapping is set manually.", "%s: In 8-channel mode AD-to-slot mapping is set manually.",
__func__); __func__);
break; break;
default: default:
dev_err(dai->codec->dev, dev_err(dai->component->dev,
"%s: Unsupported number of active RX-slots (%d)!\n", "%s: Unsupported number of active RX-slots (%d)!\n",
__func__, slots_active); __func__, slots_active);
return -EINVAL; return -EINVAL;
...@@ -2458,10 +2458,10 @@ static void ab8500_codec_of_probe(struct device *dev, struct device_node *np, ...@@ -2458,10 +2458,10 @@ static void ab8500_codec_of_probe(struct device *dev, struct device_node *np,
} }
} }
static int ab8500_codec_probe(struct snd_soc_codec *codec) static int ab8500_codec_probe(struct snd_soc_component *component)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct device *dev = codec->dev; struct device *dev = component->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(dev); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(dev);
struct ab8500_codec_platform_data codec_pdata; struct ab8500_codec_platform_data codec_pdata;
...@@ -2472,19 +2472,19 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) ...@@ -2472,19 +2472,19 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
ab8500_codec_of_probe(dev, np, &codec_pdata); ab8500_codec_of_probe(dev, np, &codec_pdata);
status = ab8500_audio_setup_mics(codec, &codec_pdata.amics); status = ab8500_audio_setup_mics(component, &codec_pdata.amics);
if (status < 0) { if (status < 0) {
pr_err("%s: Failed to setup mics (%d)!\n", __func__, status); pr_err("%s: Failed to setup mics (%d)!\n", __func__, status);
return status; return status;
} }
status = ab8500_audio_set_ear_cmv(codec, codec_pdata.ear_cmv); status = ab8500_audio_set_ear_cmv(component, codec_pdata.ear_cmv);
if (status < 0) { if (status < 0) {
pr_err("%s: Failed to set earpiece CM-voltage (%d)!\n", pr_err("%s: Failed to set earpiece CM-voltage (%d)!\n",
__func__, status); __func__, status);
return status; return status;
} }
status = ab8500_audio_init_audioblock(codec); status = ab8500_audio_init_audioblock(component);
if (status < 0) { if (status < 0) {
dev_err(dev, "%s: failed to init audio-block (%d)!\n", dev_err(dev, "%s: failed to init audio-block (%d)!\n",
__func__, status); __func__, status);
...@@ -2492,13 +2492,13 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) ...@@ -2492,13 +2492,13 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
} }
/* Override HW-defaults */ /* Override HW-defaults */
snd_soc_write(codec, AB8500_ANACONF5, snd_soc_component_write(component, AB8500_ANACONF5,
BIT(AB8500_ANACONF5_HSAUTOEN)); BIT(AB8500_ANACONF5_HSAUTOEN));
snd_soc_write(codec, AB8500_SHORTCIRCONF, snd_soc_component_write(component, AB8500_SHORTCIRCONF,
BIT(AB8500_SHORTCIRCONF_HSZCDDIS)); BIT(AB8500_SHORTCIRCONF_HSZCDDIS));
/* Add filter controls */ /* Add filter controls */
status = snd_soc_add_codec_controls(codec, ab8500_filter_controls, status = snd_soc_add_component_controls(component, ab8500_filter_controls,
ARRAY_SIZE(ab8500_filter_controls)); ARRAY_SIZE(ab8500_filter_controls));
if (status < 0) { if (status < 0) {
dev_err(dev, dev_err(dev,
...@@ -2523,16 +2523,18 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) ...@@ -2523,16 +2523,18 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
return status; return status;
} }
static const struct snd_soc_codec_driver ab8500_codec_driver = { static const struct snd_soc_component_driver ab8500_component_driver = {
.probe = ab8500_codec_probe, .probe = ab8500_codec_probe,
.component_driver = { .controls = ab8500_ctrls,
.controls = ab8500_ctrls, .num_controls = ARRAY_SIZE(ab8500_ctrls),
.num_controls = ARRAY_SIZE(ab8500_ctrls), .dapm_widgets = ab8500_dapm_widgets,
.dapm_widgets = ab8500_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ab8500_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(ab8500_dapm_widgets), .dapm_routes = ab8500_dapm_routes,
.dapm_routes = ab8500_dapm_routes, .num_dapm_routes = ARRAY_SIZE(ab8500_dapm_routes),
.num_dapm_routes = ARRAY_SIZE(ab8500_dapm_routes), .idle_bias_on = 1,
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int ab8500_codec_driver_probe(struct platform_device *pdev) static int ab8500_codec_driver_probe(struct platform_device *pdev)
...@@ -2561,7 +2563,8 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) ...@@ -2561,7 +2563,8 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev)
} }
dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__); dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__);
status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver, status = devm_snd_soc_register_component(&pdev->dev,
&ab8500_component_driver,
ab8500_codec_dai, ab8500_codec_dai,
ARRAY_SIZE(ab8500_codec_dai)); ARRAY_SIZE(ab8500_codec_dai));
if (status < 0) if (status < 0)
...@@ -2572,21 +2575,11 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) ...@@ -2572,21 +2575,11 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev)
return status; return status;
} }
static int ab8500_codec_driver_remove(struct platform_device *pdev)
{
dev_dbg(&pdev->dev, "%s Enter.\n", __func__);
snd_soc_unregister_codec(&pdev->dev);
return 0;
}
static struct platform_driver ab8500_codec_platform_driver = { static struct platform_driver ab8500_codec_platform_driver = {
.driver = { .driver = {
.name = "ab8500-codec", .name = "ab8500-codec",
}, },
.probe = ab8500_codec_driver_probe, .probe = ab8500_codec_driver_probe,
.remove = ab8500_codec_driver_remove,
}; };
module_platform_driver(ab8500_codec_platform_driver); module_platform_driver(ab8500_codec_platform_driver);
......
...@@ -36,8 +36,8 @@ static const struct snd_soc_dapm_route ac97_routes[] = { ...@@ -36,8 +36,8 @@ static const struct snd_soc_dapm_route ac97_routes[] = {
static int ac97_prepare(struct snd_pcm_substream *substream, static int ac97_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE; AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE;
...@@ -65,7 +65,7 @@ static struct snd_soc_dai_driver ac97_dai = { ...@@ -65,7 +65,7 @@ static struct snd_soc_dai_driver ac97_dai = {
.ops = &ac97_dai_ops, .ops = &ac97_dai_ops,
}; };
static int ac97_soc_probe(struct snd_soc_codec *codec) static int ac97_soc_probe(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
struct snd_ac97_bus *ac97_bus; struct snd_ac97_bus *ac97_bus;
...@@ -73,7 +73,7 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) ...@@ -73,7 +73,7 @@ static int ac97_soc_probe(struct snd_soc_codec *codec)
int ret; int ret;
/* add codec as bus device for standard ac97 */ /* add codec as bus device for standard ac97 */
ret = snd_ac97_bus(codec->component.card->snd_card, 0, soc_ac97_ops, ret = snd_ac97_bus(component->card->snd_card, 0, soc_ac97_ops,
NULL, &ac97_bus); NULL, &ac97_bus);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -83,25 +83,25 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) ...@@ -83,25 +83,25 @@ static int ac97_soc_probe(struct snd_soc_codec *codec)
if (ret < 0) if (ret < 0)
return ret; return ret;
snd_soc_codec_set_drvdata(codec, ac97); snd_soc_component_set_drvdata(component, ac97);
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int ac97_soc_suspend(struct snd_soc_codec *codec) static int ac97_soc_suspend(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_ac97_suspend(ac97); snd_ac97_suspend(ac97);
return 0; return 0;
} }
static int ac97_soc_resume(struct snd_soc_codec *codec) static int ac97_soc_resume(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_ac97_resume(ac97); snd_ac97_resume(ac97);
...@@ -112,28 +112,28 @@ static int ac97_soc_resume(struct snd_soc_codec *codec) ...@@ -112,28 +112,28 @@ static int ac97_soc_resume(struct snd_soc_codec *codec)
#define ac97_soc_resume NULL #define ac97_soc_resume NULL
#endif #endif
static const struct snd_soc_codec_driver soc_codec_dev_ac97 = { static const struct snd_soc_component_driver soc_component_dev_ac97 = {
.probe = ac97_soc_probe, .probe = ac97_soc_probe,
.suspend = ac97_soc_suspend, .suspend = ac97_soc_suspend,
.resume = ac97_soc_resume, .resume = ac97_soc_resume,
.dapm_widgets = ac97_widgets,
.component_driver = { .num_dapm_widgets = ARRAY_SIZE(ac97_widgets),
.dapm_widgets = ac97_widgets, .dapm_routes = ac97_routes,
.num_dapm_widgets = ARRAY_SIZE(ac97_widgets), .num_dapm_routes = ARRAY_SIZE(ac97_routes),
.dapm_routes = ac97_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(ac97_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int ac97_probe(struct platform_device *pdev) static int ac97_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_ac97, &ac97_dai, 1); &soc_component_dev_ac97, &ac97_dai, 1);
} }
static int ac97_remove(struct platform_device *pdev) static int ac97_remove(struct platform_device *pdev)
{ {
snd_soc_unregister_codec(&pdev->dev);
return 0; return 0;
} }
......
...@@ -164,7 +164,7 @@ static int ad1836_hw_params(struct snd_pcm_substream *substream, ...@@ -164,7 +164,7 @@ static int ad1836_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(dai->codec); struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(dai->component);
int word_len = 0; int word_len = 0;
/* bit size */ /* bit size */
...@@ -228,17 +228,17 @@ static struct snd_soc_dai_driver ad183x_dais[] = { ...@@ -228,17 +228,17 @@ static struct snd_soc_dai_driver ad183x_dais[] = {
}; };
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int ad1836_suspend(struct snd_soc_codec *codec) static int ad1836_suspend(struct snd_soc_component *component)
{ {
struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component);
/* reset clock control mode */ /* reset clock control mode */
return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2, return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2,
AD1836_ADC_SERFMT_MASK, 0); AD1836_ADC_SERFMT_MASK, 0);
} }
static int ad1836_resume(struct snd_soc_codec *codec) static int ad1836_resume(struct snd_soc_component *component)
{ {
struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component);
/* restore clock control mode */ /* restore clock control mode */
return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2, return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2,
AD1836_ADC_SERFMT_MASK, AD1836_ADC_AUX); AD1836_ADC_SERFMT_MASK, AD1836_ADC_AUX);
...@@ -248,10 +248,10 @@ static int ad1836_resume(struct snd_soc_codec *codec) ...@@ -248,10 +248,10 @@ static int ad1836_resume(struct snd_soc_codec *codec)
#define ad1836_resume NULL #define ad1836_resume NULL
#endif #endif
static int ad1836_probe(struct snd_soc_codec *codec) static int ad1836_probe(struct snd_soc_component *component)
{ {
struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
int num_dacs, num_adcs; int num_dacs, num_adcs;
int ret = 0; int ret = 0;
int i; int i;
...@@ -277,7 +277,7 @@ static int ad1836_probe(struct snd_soc_codec *codec) ...@@ -277,7 +277,7 @@ static int ad1836_probe(struct snd_soc_codec *codec)
if (ad1836->type == AD1836) { if (ad1836->type == AD1836) {
/* left/right diff:PGA/MUX */ /* left/right diff:PGA/MUX */
regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x3A); regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x3A);
ret = snd_soc_add_codec_controls(codec, ad1836_controls, ret = snd_soc_add_component_controls(component, ad1836_controls,
ARRAY_SIZE(ad1836_controls)); ARRAY_SIZE(ad1836_controls));
if (ret) if (ret)
return ret; return ret;
...@@ -285,11 +285,11 @@ static int ad1836_probe(struct snd_soc_codec *codec) ...@@ -285,11 +285,11 @@ static int ad1836_probe(struct snd_soc_codec *codec)
regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x00); regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x00);
} }
ret = snd_soc_add_codec_controls(codec, ad183x_dac_controls, num_dacs * 2); ret = snd_soc_add_component_controls(component, ad183x_dac_controls, num_dacs * 2);
if (ret) if (ret)
return ret; return ret;
ret = snd_soc_add_codec_controls(codec, ad183x_adc_controls, num_adcs); ret = snd_soc_add_component_controls(component, ad183x_adc_controls, num_adcs);
if (ret) if (ret)
return ret; return ret;
...@@ -313,28 +313,29 @@ static int ad1836_probe(struct snd_soc_codec *codec) ...@@ -313,28 +313,29 @@ static int ad1836_probe(struct snd_soc_codec *codec)
} }
/* power down chip */ /* power down chip */
static int ad1836_remove(struct snd_soc_codec *codec) static void ad1836_remove(struct snd_soc_component *component)
{ {
struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component);
/* reset clock control mode */ /* reset clock control mode */
return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2, regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2,
AD1836_ADC_SERFMT_MASK, 0); AD1836_ADC_SERFMT_MASK, 0);
} }
static const struct snd_soc_codec_driver soc_codec_dev_ad1836 = { static const struct snd_soc_component_driver soc_component_dev_ad1836 = {
.probe = ad1836_probe, .probe = ad1836_probe,
.remove = ad1836_remove, .remove = ad1836_remove,
.suspend = ad1836_suspend, .suspend = ad1836_suspend,
.resume = ad1836_resume, .resume = ad1836_resume,
.controls = ad183x_controls,
.component_driver = { .num_controls = ARRAY_SIZE(ad183x_controls),
.controls = ad183x_controls, .dapm_widgets = ad183x_dapm_widgets,
.num_controls = ARRAY_SIZE(ad183x_controls), .num_dapm_widgets = ARRAY_SIZE(ad183x_dapm_widgets),
.dapm_widgets = ad183x_dapm_widgets, .dapm_routes = ad183x_dapm_routes,
.num_dapm_widgets = ARRAY_SIZE(ad183x_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(ad183x_dapm_routes),
.dapm_routes = ad183x_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(ad183x_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct reg_default ad1836_reg_defaults[] = { static const struct reg_default ad1836_reg_defaults[] = {
...@@ -382,17 +383,11 @@ static int ad1836_spi_probe(struct spi_device *spi) ...@@ -382,17 +383,11 @@ static int ad1836_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, ad1836); spi_set_drvdata(spi, ad1836);
ret = snd_soc_register_codec(&spi->dev, ret = devm_snd_soc_register_component(&spi->dev,
&soc_codec_dev_ad1836, &ad183x_dais[ad1836->type], 1); &soc_component_dev_ad1836, &ad183x_dais[ad1836->type], 1);
return ret; return ret;
} }
static int ad1836_spi_remove(struct spi_device *spi)
{
snd_soc_unregister_codec(&spi->dev);
return 0;
}
static const struct spi_device_id ad1836_ids[] = { static const struct spi_device_id ad1836_ids[] = {
{ "ad1835", AD1835 }, { "ad1835", AD1835 },
{ "ad1836", AD1836 }, { "ad1836", AD1836 },
...@@ -408,7 +403,6 @@ static struct spi_driver ad1836_spi_driver = { ...@@ -408,7 +403,6 @@ static struct spi_driver ad1836_spi_driver = {
.name = "ad1836", .name = "ad1836",
}, },
.probe = ad1836_spi_probe, .probe = ad1836_spi_probe,
.remove = ad1836_spi_remove,
.id_table = ad1836_ids, .id_table = ad1836_ids,
}; };
......
...@@ -35,18 +35,11 @@ static int ad193x_i2c_probe(struct i2c_client *client, ...@@ -35,18 +35,11 @@ static int ad193x_i2c_probe(struct i2c_client *client,
(enum ad193x_type)id->driver_data); (enum ad193x_type)id->driver_data);
} }
static int ad193x_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static struct i2c_driver ad193x_i2c_driver = { static struct i2c_driver ad193x_i2c_driver = {
.driver = { .driver = {
.name = "ad193x", .name = "ad193x",
}, },
.probe = ad193x_i2c_probe, .probe = ad193x_i2c_probe,
.remove = ad193x_i2c_remove,
.id_table = ad193x_id, .id_table = ad193x_id,
}; };
module_i2c_driver(ad193x_i2c_driver); module_i2c_driver(ad193x_i2c_driver);
......
...@@ -29,12 +29,6 @@ static int ad193x_spi_probe(struct spi_device *spi) ...@@ -29,12 +29,6 @@ static int ad193x_spi_probe(struct spi_device *spi)
(enum ad193x_type)id->driver_data); (enum ad193x_type)id->driver_data);
} }
static int ad193x_spi_remove(struct spi_device *spi)
{
snd_soc_unregister_codec(&spi->dev);
return 0;
}
static const struct spi_device_id ad193x_spi_id[] = { static const struct spi_device_id ad193x_spi_id[] = {
{ "ad193x", AD193X }, { "ad193x", AD193X },
{ "ad1933", AD1933 }, { "ad1933", AD1933 },
...@@ -51,7 +45,6 @@ static struct spi_driver ad193x_spi_driver = { ...@@ -51,7 +45,6 @@ static struct spi_driver ad193x_spi_driver = {
.name = "ad193x", .name = "ad193x",
}, },
.probe = ad193x_spi_probe, .probe = ad193x_spi_probe,
.remove = ad193x_spi_remove,
.id_table = ad193x_spi_id, .id_table = ad193x_spi_id,
}; };
module_spi_driver(ad193x_spi_driver); module_spi_driver(ad193x_spi_driver);
......
...@@ -130,7 +130,7 @@ static inline bool ad193x_has_adc(const struct ad193x_priv *ad193x) ...@@ -130,7 +130,7 @@ static inline bool ad193x_has_adc(const struct ad193x_priv *ad193x)
static int ad193x_mute(struct snd_soc_dai *dai, int mute) static int ad193x_mute(struct snd_soc_dai *dai, int mute)
{ {
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(dai->component);
if (mute) if (mute)
regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2, regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2,
...@@ -146,7 +146,7 @@ static int ad193x_mute(struct snd_soc_dai *dai, int mute) ...@@ -146,7 +146,7 @@ static int ad193x_mute(struct snd_soc_dai *dai, int mute)
static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots, int width) unsigned int rx_mask, int slots, int width)
{ {
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(dai->component);
unsigned int channels; unsigned int channels;
switch (slots) { switch (slots) {
...@@ -179,7 +179,7 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, ...@@ -179,7 +179,7 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec_dai->codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(codec_dai->component);
unsigned int adc_serfmt = 0; unsigned int adc_serfmt = 0;
unsigned int adc_fmt = 0; unsigned int adc_fmt = 0;
unsigned int dac_fmt = 0; unsigned int dac_fmt = 0;
...@@ -257,8 +257,8 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -257,8 +257,8 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai,
static int ad193x_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int ad193x_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component);
switch (freq) { switch (freq) {
case 12288000: case 12288000:
case 18432000: case 18432000:
...@@ -275,8 +275,8 @@ static int ad193x_hw_params(struct snd_pcm_substream *substream, ...@@ -275,8 +275,8 @@ static int ad193x_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
int word_len = 0, master_rate = 0; int word_len = 0, master_rate = 0;
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component);
/* bit size */ /* bit size */
switch (params_width(params)) { switch (params_width(params)) {
...@@ -351,10 +351,10 @@ static struct snd_soc_dai_driver ad193x_dai = { ...@@ -351,10 +351,10 @@ static struct snd_soc_dai_driver ad193x_dai = {
.ops = &ad193x_dai_ops, .ops = &ad193x_dai_ops,
}; };
static int ad193x_codec_probe(struct snd_soc_codec *codec) static int ad193x_component_probe(struct snd_soc_component *component)
{ {
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
int num, ret; int num, ret;
/* default setting for ad193x */ /* default setting for ad193x */
...@@ -382,7 +382,7 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec) ...@@ -382,7 +382,7 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec)
if (ad193x_has_adc(ad193x)) { if (ad193x_has_adc(ad193x)) {
/* add adc controls */ /* add adc controls */
num = ARRAY_SIZE(ad193x_adc_snd_controls); num = ARRAY_SIZE(ad193x_adc_snd_controls);
ret = snd_soc_add_codec_controls(codec, ret = snd_soc_add_component_controls(component,
ad193x_adc_snd_controls, ad193x_adc_snd_controls,
num); num);
if (ret) if (ret)
...@@ -408,16 +408,18 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec) ...@@ -408,16 +408,18 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_ad193x = { static const struct snd_soc_component_driver soc_component_dev_ad193x = {
.probe = ad193x_codec_probe, .probe = ad193x_component_probe,
.component_driver = { .controls = ad193x_snd_controls,
.controls = ad193x_snd_controls, .num_controls = ARRAY_SIZE(ad193x_snd_controls),
.num_controls = ARRAY_SIZE(ad193x_snd_controls), .dapm_widgets = ad193x_dapm_widgets,
.dapm_widgets = ad193x_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ad193x_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(ad193x_dapm_widgets), .dapm_routes = audio_paths,
.dapm_routes = audio_paths, .num_dapm_routes = ARRAY_SIZE(audio_paths),
.num_dapm_routes = ARRAY_SIZE(audio_paths), .idle_bias_on = 1,
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
const struct regmap_config ad193x_regmap_config = { const struct regmap_config ad193x_regmap_config = {
...@@ -442,7 +444,7 @@ int ad193x_probe(struct device *dev, struct regmap *regmap, ...@@ -442,7 +444,7 @@ int ad193x_probe(struct device *dev, struct regmap *regmap,
dev_set_drvdata(dev, ad193x); dev_set_drvdata(dev, ad193x);
return snd_soc_register_codec(dev, &soc_codec_dev_ad193x, return devm_snd_soc_register_component(dev, &soc_component_dev_ad193x,
&ad193x_dai, 1); &ad193x_dai, 1);
} }
EXPORT_SYMBOL_GPL(ad193x_probe); EXPORT_SYMBOL_GPL(ad193x_probe);
......
...@@ -205,9 +205,9 @@ static struct snd_soc_dai_driver ad1980_dai = { ...@@ -205,9 +205,9 @@ static struct snd_soc_dai_driver ad1980_dai = {
#define AD1980_VENDOR_ID 0x41445300 #define AD1980_VENDOR_ID 0x41445300
#define AD1980_VENDOR_MASK 0xffffff00 #define AD1980_VENDOR_MASK 0xffffff00
static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) static int ad1980_reset(struct snd_soc_component *component, int try_warm)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
unsigned int retry_cnt = 0; unsigned int retry_cnt = 0;
int ret; int ret;
...@@ -223,16 +223,16 @@ static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) ...@@ -223,16 +223,16 @@ static int ad1980_reset(struct snd_soc_codec *codec, int try_warm)
* case the first nibble of data is eaten by the addr. (Tag is * case the first nibble of data is eaten by the addr. (Tag is
* always 16 bit) * always 16 bit)
*/ */
snd_soc_write(codec, AC97_AD_SERIAL_CFG, 0x9900); snd_soc_component_write(component, AC97_AD_SERIAL_CFG, 0x9900);
} while (retry_cnt++ < 10); } while (retry_cnt++ < 10);
dev_err(codec->dev, "Failed to reset: AC97 link error\n"); dev_err(component->dev, "Failed to reset: AC97 link error\n");
return -EIO; return -EIO;
} }
static int ad1980_soc_probe(struct snd_soc_codec *codec) static int ad1980_soc_probe(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
struct regmap *regmap; struct regmap *regmap;
...@@ -240,10 +240,10 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec) ...@@ -240,10 +240,10 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
u16 vendor_id2; u16 vendor_id2;
u16 ext_status; u16 ext_status;
ac97 = snd_soc_new_ac97_codec(codec, 0, 0); ac97 = snd_soc_new_ac97_component(component, 0, 0);
if (IS_ERR(ac97)) { if (IS_ERR(ac97)) {
ret = PTR_ERR(ac97); ret = PTR_ERR(ac97);
dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); dev_err(component->dev, "Failed to register AC97 component: %d\n", ret);
return ret; return ret;
} }
...@@ -253,72 +253,66 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec) ...@@ -253,72 +253,66 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
goto err_free_ac97; goto err_free_ac97;
} }
snd_soc_codec_init_regmap(codec, regmap); snd_soc_component_init_regmap(component, regmap);
snd_soc_codec_set_drvdata(codec, ac97); snd_soc_component_set_drvdata(component, ac97);
ret = ad1980_reset(codec, 0); ret = ad1980_reset(component, 0);
if (ret < 0) if (ret < 0)
goto reset_err; goto reset_err;
vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2); vendor_id2 = snd_soc_component_read32(component, AC97_VENDOR_ID2);
if (vendor_id2 == 0x5374) { if (vendor_id2 == 0x5374) {
dev_warn(codec->dev, dev_warn(component->dev,
"Found AD1981 - only 2/2 IN/OUT Channels supported\n"); "Found AD1981 - only 2/2 IN/OUT Channels supported\n");
} }
/* unmute captures and playbacks volume */ /* unmute captures and playbacks volume */
snd_soc_write(codec, AC97_MASTER, 0x0000); snd_soc_component_write(component, AC97_MASTER, 0x0000);
snd_soc_write(codec, AC97_PCM, 0x0000); snd_soc_component_write(component, AC97_PCM, 0x0000);
snd_soc_write(codec, AC97_REC_GAIN, 0x0000); snd_soc_component_write(component, AC97_REC_GAIN, 0x0000);
snd_soc_write(codec, AC97_CENTER_LFE_MASTER, 0x0000); snd_soc_component_write(component, AC97_CENTER_LFE_MASTER, 0x0000);
snd_soc_write(codec, AC97_SURROUND_MASTER, 0x0000); snd_soc_component_write(component, AC97_SURROUND_MASTER, 0x0000);
/*power on LFE/CENTER/Surround DACs*/ /*power on LFE/CENTER/Surround DACs*/
ext_status = snd_soc_read(codec, AC97_EXTENDED_STATUS); ext_status = snd_soc_component_read32(component, AC97_EXTENDED_STATUS);
snd_soc_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); snd_soc_component_write(component, AC97_EXTENDED_STATUS, ext_status&~0x3800);
return 0; return 0;
reset_err: reset_err:
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
err_free_ac97: err_free_ac97:
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return ret; return ret;
} }
static int ad1980_soc_remove(struct snd_soc_codec *codec) static void ad1980_soc_remove(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_ad1980 = { static const struct snd_soc_component_driver soc_component_dev_ad1980 = {
.probe = ad1980_soc_probe, .probe = ad1980_soc_probe,
.remove = ad1980_soc_remove, .remove = ad1980_soc_remove,
.controls = ad1980_snd_ac97_controls,
.component_driver = { .num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls),
.controls = ad1980_snd_ac97_controls, .dapm_widgets = ad1980_dapm_widgets,
.num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls), .num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets),
.dapm_widgets = ad1980_dapm_widgets, .dapm_routes = ad1980_dapm_routes,
.num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes),
.dapm_routes = ad1980_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int ad1980_probe(struct platform_device *pdev) static int ad1980_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_ad1980, &ad1980_dai, 1); &soc_component_dev_ad1980, &ad1980_dai, 1);
}
static int ad1980_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver ad1980_codec_driver = { static struct platform_driver ad1980_codec_driver = {
...@@ -327,7 +321,6 @@ static struct platform_driver ad1980_codec_driver = { ...@@ -327,7 +321,6 @@ static struct platform_driver ad1980_codec_driver = {
}, },
.probe = ad1980_probe, .probe = ad1980_probe,
.remove = ad1980_remove,
}; };
module_platform_driver(ad1980_codec_driver); module_platform_driver(ad1980_codec_driver);
......
...@@ -54,25 +54,21 @@ static struct snd_soc_dai_driver ad73311_dai = { ...@@ -54,25 +54,21 @@ static struct snd_soc_dai_driver ad73311_dai = {
.formats = SNDRV_PCM_FMTBIT_S16_LE, }, .formats = SNDRV_PCM_FMTBIT_S16_LE, },
}; };
static const struct snd_soc_codec_driver soc_codec_dev_ad73311 = { static const struct snd_soc_component_driver soc_component_dev_ad73311 = {
.component_driver = { .dapm_widgets = ad73311_dapm_widgets,
.dapm_widgets = ad73311_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets), .dapm_routes = ad73311_dapm_routes,
.dapm_routes = ad73311_dapm_routes, .num_dapm_routes = ARRAY_SIZE(ad73311_dapm_routes),
.num_dapm_routes = ARRAY_SIZE(ad73311_dapm_routes), .idle_bias_on = 1,
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int ad73311_probe(struct platform_device *pdev) static int ad73311_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_ad73311, &ad73311_dai, 1); &soc_component_dev_ad73311, &ad73311_dai, 1);
}
static int ad73311_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver ad73311_codec_driver = { static struct platform_driver ad73311_codec_driver = {
...@@ -81,7 +77,6 @@ static struct platform_driver ad73311_codec_driver = { ...@@ -81,7 +77,6 @@ static struct platform_driver ad73311_codec_driver = {
}, },
.probe = ad73311_probe, .probe = ad73311_probe,
.remove = ad73311_remove,
}; };
module_platform_driver(ad73311_codec_driver); module_platform_driver(ad73311_codec_driver);
......
...@@ -168,58 +168,58 @@ static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = { ...@@ -168,58 +168,58 @@ static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = {
static int ac97_analog_prepare(struct snd_pcm_substream *substream, static int ac97_analog_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
unsigned short reg; unsigned short reg;
/* enable variable rate audio, disable SPDIF output */ /* enable variable rate audio, disable SPDIF output */
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x5, 0x1); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x5, 0x1);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
else else
reg = AC97_PCM_LR_ADC_RATE; reg = AC97_PCM_LR_ADC_RATE;
return snd_soc_write(codec, reg, runtime->rate); return snd_soc_component_write(component, reg, runtime->rate);
} }
static int ac97_digital_prepare(struct snd_pcm_substream *substream, static int ac97_digital_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
unsigned short reg; unsigned short reg;
snd_soc_write(codec, AC97_SPDIF, 0x2002); snd_soc_component_write(component, AC97_SPDIF, 0x2002);
/* Enable VRA and SPDIF out */ /* Enable VRA and SPDIF out */
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x5, 0x5); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x5, 0x5);
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
return snd_soc_write(codec, reg, runtime->rate); return snd_soc_component_write(component, reg, runtime->rate);
} }
static int stac9766_set_bias_level(struct snd_soc_codec *codec, static int stac9766_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: /* full On */ case SND_SOC_BIAS_ON: /* full On */
case SND_SOC_BIAS_PREPARE: /* partial On */ case SND_SOC_BIAS_PREPARE: /* partial On */
case SND_SOC_BIAS_STANDBY: /* Off, with power */ case SND_SOC_BIAS_STANDBY: /* Off, with power */
snd_soc_write(codec, AC97_POWERDOWN, 0x0000); snd_soc_component_write(component, AC97_POWERDOWN, 0x0000);
break; break;
case SND_SOC_BIAS_OFF: /* Off, without power */ case SND_SOC_BIAS_OFF: /* Off, without power */
/* disable everything including AC link */ /* disable everything including AC link */
snd_soc_write(codec, AC97_POWERDOWN, 0xffff); snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
break; break;
} }
return 0; return 0;
} }
static int stac9766_codec_resume(struct snd_soc_codec *codec) static int stac9766_component_resume(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
return snd_ac97_reset(ac97, true, STAC9766_VENDOR_ID, return snd_ac97_reset(ac97, true, STAC9766_VENDOR_ID,
STAC9766_VENDOR_ID_MASK); STAC9766_VENDOR_ID_MASK);
...@@ -272,13 +272,13 @@ static struct snd_soc_dai_driver stac9766_dai[] = { ...@@ -272,13 +272,13 @@ static struct snd_soc_dai_driver stac9766_dai[] = {
} }
}; };
static int stac9766_codec_probe(struct snd_soc_codec *codec) static int stac9766_component_probe(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
struct regmap *regmap; struct regmap *regmap;
int ret; int ret;
ac97 = snd_soc_new_ac97_codec(codec, STAC9766_VENDOR_ID, ac97 = snd_soc_new_ac97_component(component, STAC9766_VENDOR_ID,
STAC9766_VENDOR_ID_MASK); STAC9766_VENDOR_ID_MASK);
if (IS_ERR(ac97)) if (IS_ERR(ac97))
return PTR_ERR(ac97); return PTR_ERR(ac97);
...@@ -289,46 +289,42 @@ static int stac9766_codec_probe(struct snd_soc_codec *codec) ...@@ -289,46 +289,42 @@ static int stac9766_codec_probe(struct snd_soc_codec *codec)
goto err_free_ac97; goto err_free_ac97;
} }
snd_soc_codec_init_regmap(codec, regmap); snd_soc_component_init_regmap(component, regmap);
snd_soc_codec_set_drvdata(codec, ac97); snd_soc_component_set_drvdata(component, ac97);
return 0; return 0;
err_free_ac97: err_free_ac97:
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return ret; return ret;
} }
static int stac9766_codec_remove(struct snd_soc_codec *codec) static void stac9766_component_remove(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_stac9766 = { static const struct snd_soc_component_driver soc_component_dev_stac9766 = {
.component_driver = { .controls = stac9766_snd_ac97_controls,
.controls = stac9766_snd_ac97_controls, .num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls),
.num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls), .set_bias_level = stac9766_set_bias_level,
}, .probe = stac9766_component_probe,
.set_bias_level = stac9766_set_bias_level, .remove = stac9766_component_remove,
.suspend_bias_off = true, .resume = stac9766_component_resume,
.probe = stac9766_codec_probe, .suspend_bias_off = 1,
.remove = stac9766_codec_remove, .idle_bias_on = 1,
.resume = stac9766_codec_resume, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int stac9766_probe(struct platform_device *pdev) static int stac9766_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_stac9766, stac9766_dai, ARRAY_SIZE(stac9766_dai)); &soc_component_dev_stac9766, stac9766_dai, ARRAY_SIZE(stac9766_dai));
}
static int stac9766_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver stac9766_codec_driver = { static struct platform_driver stac9766_codec_driver = {
...@@ -337,7 +333,6 @@ static struct platform_driver stac9766_codec_driver = { ...@@ -337,7 +333,6 @@ static struct platform_driver stac9766_codec_driver = {
}, },
.probe = stac9766_probe, .probe = stac9766_probe,
.remove = stac9766_remove,
}; };
module_platform_driver(stac9766_codec_driver); module_platform_driver(stac9766_codec_driver);
......
...@@ -235,17 +235,17 @@ static const struct snd_soc_dapm_route wm9705_audio_map[] = { ...@@ -235,17 +235,17 @@ static const struct snd_soc_dapm_route wm9705_audio_map[] = {
static int ac97_prepare(struct snd_pcm_substream *substream, static int ac97_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
int reg; int reg;
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
else else
reg = AC97_PCM_LR_ADC_RATE; reg = AC97_PCM_LR_ADC_RATE;
return snd_soc_write(codec, reg, substream->runtime->rate); return snd_soc_component_write(component, reg, substream->runtime->rate);
} }
#define WM9705_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | \ #define WM9705_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | \
...@@ -289,18 +289,18 @@ static struct snd_soc_dai_driver wm9705_dai[] = { ...@@ -289,18 +289,18 @@ static struct snd_soc_dai_driver wm9705_dai[] = {
}; };
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int wm9705_soc_suspend(struct snd_soc_codec *codec) static int wm9705_soc_suspend(struct snd_soc_component *component)
{ {
regcache_cache_bypass(codec->component.regmap, true); regcache_cache_bypass(component->regmap, true);
snd_soc_write(codec, AC97_POWERDOWN, 0xffff); snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
regcache_cache_bypass(codec->component.regmap, false); regcache_cache_bypass(component->regmap, false);
return 0; return 0;
} }
static int wm9705_soc_resume(struct snd_soc_codec *codec) static int wm9705_soc_resume(struct snd_soc_component *component)
{ {
struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component);
int ret; int ret;
ret = snd_ac97_reset(wm9705->ac97, true, WM9705_VENDOR_ID, ret = snd_ac97_reset(wm9705->ac97, true, WM9705_VENDOR_ID,
...@@ -308,7 +308,7 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec) ...@@ -308,7 +308,7 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)
if (ret < 0) if (ret < 0)
return ret; return ret;
regcache_sync(codec->component.regmap); snd_soc_component_cache_sync(component);
return 0; return 0;
} }
...@@ -317,9 +317,9 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec) ...@@ -317,9 +317,9 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)
#define wm9705_soc_resume NULL #define wm9705_soc_resume NULL
#endif #endif
static int wm9705_soc_probe(struct snd_soc_codec *codec) static int wm9705_soc_probe(struct snd_soc_component *component)
{ {
struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component);
struct regmap *regmap; struct regmap *regmap;
if (wm9705->mfd_pdata) { if (wm9705->mfd_pdata) {
...@@ -327,54 +327,54 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec) ...@@ -327,54 +327,54 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec)
regmap = wm9705->mfd_pdata->regmap; regmap = wm9705->mfd_pdata->regmap;
} else { } else {
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID, wm9705->ac97 = snd_soc_new_ac97_component(component, WM9705_VENDOR_ID,
WM9705_VENDOR_ID_MASK); WM9705_VENDOR_ID_MASK);
if (IS_ERR(wm9705->ac97)) { if (IS_ERR(wm9705->ac97)) {
dev_err(codec->dev, "Failed to register AC97 codec\n"); dev_err(component->dev, "Failed to register AC97 codec\n");
return PTR_ERR(wm9705->ac97); return PTR_ERR(wm9705->ac97);
} }
regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config); regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config);
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
snd_soc_free_ac97_codec(wm9705->ac97); snd_soc_free_ac97_component(wm9705->ac97);
return PTR_ERR(regmap); return PTR_ERR(regmap);
} }
#endif #endif
} }
snd_soc_codec_set_drvdata(codec, wm9705->ac97); snd_soc_component_set_drvdata(component, wm9705->ac97);
snd_soc_codec_init_regmap(codec, regmap); snd_soc_component_init_regmap(component, regmap);
return 0; return 0;
} }
static int wm9705_soc_remove(struct snd_soc_codec *codec) static void wm9705_soc_remove(struct snd_soc_component *component)
{ {
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component);
if (!wm9705->mfd_pdata) { if (!wm9705->mfd_pdata) {
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
snd_soc_free_ac97_codec(wm9705->ac97); snd_soc_free_ac97_component(wm9705->ac97);
} }
#endif #endif
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm9705 = { static const struct snd_soc_component_driver soc_component_dev_wm9705 = {
.probe = wm9705_soc_probe, .probe = wm9705_soc_probe,
.remove = wm9705_soc_remove, .remove = wm9705_soc_remove,
.suspend = wm9705_soc_suspend, .suspend = wm9705_soc_suspend,
.resume = wm9705_soc_resume, .resume = wm9705_soc_resume,
.controls = wm9705_snd_ac97_controls,
.component_driver = { .num_controls = ARRAY_SIZE(wm9705_snd_ac97_controls),
.controls = wm9705_snd_ac97_controls, .dapm_widgets = wm9705_dapm_widgets,
.num_controls = ARRAY_SIZE(wm9705_snd_ac97_controls), .num_dapm_widgets = ARRAY_SIZE(wm9705_dapm_widgets),
.dapm_widgets = wm9705_dapm_widgets, .dapm_routes = wm9705_audio_map,
.num_dapm_widgets = ARRAY_SIZE(wm9705_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(wm9705_audio_map),
.dapm_routes = wm9705_audio_map, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(wm9705_audio_map), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int wm9705_probe(struct platform_device *pdev) static int wm9705_probe(struct platform_device *pdev)
...@@ -388,14 +388,8 @@ static int wm9705_probe(struct platform_device *pdev) ...@@ -388,14 +388,8 @@ static int wm9705_probe(struct platform_device *pdev)
wm9705->mfd_pdata = dev_get_platdata(&pdev->dev); wm9705->mfd_pdata = dev_get_platdata(&pdev->dev);
platform_set_drvdata(pdev, wm9705); platform_set_drvdata(pdev, wm9705);
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai)); &soc_component_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai));
}
static int wm9705_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver wm9705_codec_driver = { static struct platform_driver wm9705_codec_driver = {
...@@ -404,7 +398,6 @@ static struct platform_driver wm9705_codec_driver = { ...@@ -404,7 +398,6 @@ static struct platform_driver wm9705_codec_driver = {
}, },
.probe = wm9705_probe, .probe = wm9705_probe,
.remove = wm9705_remove,
}; };
module_platform_driver(wm9705_codec_driver); module_platform_driver(wm9705_codec_driver);
......
...@@ -220,8 +220,8 @@ static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol, ...@@ -220,8 +220,8 @@ static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
unsigned int val = ucontrol->value.integer.value[0]; unsigned int val = ucontrol->value.integer.value[0];
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
...@@ -264,8 +264,8 @@ static int wm9712_hp_mixer_get(struct snd_kcontrol *kcontrol, ...@@ -264,8 +264,8 @@ static int wm9712_hp_mixer_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
unsigned int shift, mixer; unsigned int shift, mixer;
...@@ -527,33 +527,33 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = { ...@@ -527,33 +527,33 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = {
static int ac97_prepare(struct snd_pcm_substream *substream, static int ac97_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
int reg; int reg;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
else else
reg = AC97_PCM_LR_ADC_RATE; reg = AC97_PCM_LR_ADC_RATE;
return snd_soc_write(codec, reg, runtime->rate); return snd_soc_component_write(component, reg, runtime->rate);
} }
static int ac97_aux_prepare(struct snd_pcm_substream *substream, static int ac97_aux_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1);
snd_soc_update_bits(codec, AC97_PCI_SID, 0x8000, 0x8000); snd_soc_component_update_bits(component, AC97_PCI_SID, 0x8000, 0x8000);
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
return -ENODEV; return -ENODEV;
return snd_soc_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate); return snd_soc_component_write(component, AC97_PCM_SURR_DAC_RATE, runtime->rate);
} }
#define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ #define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
...@@ -597,7 +597,7 @@ static struct snd_soc_dai_driver wm9712_dai[] = { ...@@ -597,7 +597,7 @@ static struct snd_soc_dai_driver wm9712_dai[] = {
} }
}; };
static int wm9712_set_bias_level(struct snd_soc_codec *codec, static int wm9712_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
...@@ -605,20 +605,20 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec, ...@@ -605,20 +605,20 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
snd_soc_write(codec, AC97_POWERDOWN, 0x0000); snd_soc_component_write(component, AC97_POWERDOWN, 0x0000);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* disable everything including AC link */ /* disable everything including AC link */
snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff);
snd_soc_write(codec, AC97_POWERDOWN, 0xffff); snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
break; break;
} }
return 0; return 0;
} }
static int wm9712_soc_resume(struct snd_soc_codec *codec) static int wm9712_soc_resume(struct snd_soc_component *component)
{ {
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
int ret; int ret;
ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID, ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID,
...@@ -626,17 +626,17 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec) ...@@ -626,17 +626,17 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec)
if (ret < 0) if (ret < 0)
return ret; return ret;
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
if (ret == 0) if (ret == 0)
regcache_sync(codec->component.regmap); snd_soc_component_cache_sync(component);
return ret; return ret;
} }
static int wm9712_soc_probe(struct snd_soc_codec *codec) static int wm9712_soc_probe(struct snd_soc_component *component)
{ {
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
struct regmap *regmap; struct regmap *regmap;
int ret; int ret;
...@@ -645,59 +645,59 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec) ...@@ -645,59 +645,59 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
regmap = wm9712->mfd_pdata->regmap; regmap = wm9712->mfd_pdata->regmap;
} else { } else {
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID, wm9712->ac97 = snd_soc_new_ac97_component(component, WM9712_VENDOR_ID,
WM9712_VENDOR_ID_MASK); WM9712_VENDOR_ID_MASK);
if (IS_ERR(wm9712->ac97)) { if (IS_ERR(wm9712->ac97)) {
ret = PTR_ERR(wm9712->ac97); ret = PTR_ERR(wm9712->ac97);
dev_err(codec->dev, dev_err(component->dev,
"Failed to register AC97 codec: %d\n", ret); "Failed to register AC97 codec: %d\n", ret);
return ret; return ret;
} }
regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config); regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config);
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
snd_soc_free_ac97_codec(wm9712->ac97); snd_soc_free_ac97_component(wm9712->ac97);
return PTR_ERR(regmap); return PTR_ERR(regmap);
} }
#endif #endif
} }
snd_soc_codec_init_regmap(codec, regmap); snd_soc_component_init_regmap(component, regmap);
/* set alc mux to none */ /* set alc mux to none */
snd_soc_update_bits(codec, AC97_VIDEO, 0x3000, 0x3000); snd_soc_component_update_bits(component, AC97_VIDEO, 0x3000, 0x3000);
return 0; return 0;
} }
static int wm9712_soc_remove(struct snd_soc_codec *codec) static void wm9712_soc_remove(struct snd_soc_component *component)
{ {
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
if (!wm9712->mfd_pdata) { if (!wm9712->mfd_pdata) {
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
snd_soc_free_ac97_codec(wm9712->ac97); snd_soc_free_ac97_component(wm9712->ac97);
} }
#endif #endif
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm9712 = { static const struct snd_soc_component_driver soc_component_dev_wm9712 = {
.probe = wm9712_soc_probe, .probe = wm9712_soc_probe,
.remove = wm9712_soc_remove, .remove = wm9712_soc_remove,
.resume = wm9712_soc_resume, .resume = wm9712_soc_resume,
.set_bias_level = wm9712_set_bias_level, .set_bias_level = wm9712_set_bias_level,
.suspend_bias_off = true, .controls = wm9712_snd_ac97_controls,
.num_controls = ARRAY_SIZE(wm9712_snd_ac97_controls),
.component_driver = { .dapm_widgets = wm9712_dapm_widgets,
.controls = wm9712_snd_ac97_controls, .num_dapm_widgets = ARRAY_SIZE(wm9712_dapm_widgets),
.num_controls = ARRAY_SIZE(wm9712_snd_ac97_controls), .dapm_routes = wm9712_audio_map,
.dapm_widgets = wm9712_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(wm9712_audio_map),
.num_dapm_widgets = ARRAY_SIZE(wm9712_dapm_widgets), .suspend_bias_off = 1,
.dapm_routes = wm9712_audio_map, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(wm9712_audio_map), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int wm9712_probe(struct platform_device *pdev) static int wm9712_probe(struct platform_device *pdev)
...@@ -713,26 +713,19 @@ static int wm9712_probe(struct platform_device *pdev) ...@@ -713,26 +713,19 @@ static int wm9712_probe(struct platform_device *pdev)
wm9712->mfd_pdata = dev_get_platdata(&pdev->dev); wm9712->mfd_pdata = dev_get_platdata(&pdev->dev);
platform_set_drvdata(pdev, wm9712); platform_set_drvdata(pdev, wm9712);
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_wm9712, wm9712_dai, ARRAY_SIZE(wm9712_dai)); &soc_component_dev_wm9712, wm9712_dai, ARRAY_SIZE(wm9712_dai));
}
static int wm9712_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver wm9712_codec_driver = { static struct platform_driver wm9712_component_driver = {
.driver = { .driver = {
.name = "wm9712-codec", .name = "wm9712-component",
}, },
.probe = wm9712_probe, .probe = wm9712_probe,
.remove = wm9712_remove,
}; };
module_platform_driver(wm9712_codec_driver); module_platform_driver(wm9712_component_driver);
MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver"); MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver");
MODULE_AUTHOR("Liam Girdwood"); MODULE_AUTHOR("Liam Girdwood");
......
...@@ -196,16 +196,16 @@ SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1), ...@@ -196,16 +196,16 @@ SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1),
static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w, static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
if (WARN_ON(event != SND_SOC_DAPM_PRE_PMD)) if (WARN_ON(event != SND_SOC_DAPM_PRE_PMD))
return -EINVAL; return -EINVAL;
/* Gracefully shut down the voice interface. */ /* Gracefully shut down the voice interface. */
snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0f00, 0x0200); snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, 0x0200);
schedule_timeout_interruptible(msecs_to_jiffies(1)); schedule_timeout_interruptible(msecs_to_jiffies(1));
snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0f00, 0x0f00); snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, 0x0f00);
snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x1000, 0x1000); snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x1000, 0x1000);
return 0; return 0;
} }
...@@ -229,8 +229,8 @@ static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol, ...@@ -229,8 +229,8 @@ static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component);
unsigned int val = ucontrol->value.integer.value[0]; unsigned int val = ucontrol->value.integer.value[0];
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
...@@ -273,8 +273,8 @@ static int wm9713_hp_mixer_get(struct snd_kcontrol *kcontrol, ...@@ -273,8 +273,8 @@ static int wm9713_hp_mixer_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component);
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
unsigned int mixer, shift; unsigned int mixer, shift;
...@@ -753,7 +753,7 @@ struct _pll_div { ...@@ -753,7 +753,7 @@ struct _pll_div {
* to allow rounding later */ * to allow rounding later */
#define FIXED_PLL_SIZE ((1 << 22) * 10) #define FIXED_PLL_SIZE ((1 << 22) * 10)
static void pll_factors(struct snd_soc_codec *codec, static void pll_factors(struct snd_soc_component *component,
struct _pll_div *pll_div, unsigned int source) struct _pll_div *pll_div, unsigned int source)
{ {
u64 Kpart; u64 Kpart;
...@@ -789,7 +789,7 @@ static void pll_factors(struct snd_soc_codec *codec, ...@@ -789,7 +789,7 @@ static void pll_factors(struct snd_soc_codec *codec,
Ndiv = target / source; Ndiv = target / source;
if ((Ndiv < 5) || (Ndiv > 12)) if ((Ndiv < 5) || (Ndiv > 12))
dev_warn(codec->dev, dev_warn(component->dev,
"WM9713 PLL N value %u out of recommended range!\n", "WM9713 PLL N value %u out of recommended range!\n",
Ndiv); Ndiv);
...@@ -815,28 +815,28 @@ static void pll_factors(struct snd_soc_codec *codec, ...@@ -815,28 +815,28 @@ static void pll_factors(struct snd_soc_codec *codec,
* Please note that changing the PLL input frequency may require * Please note that changing the PLL input frequency may require
* resynchronisation with the AC97 controller. * resynchronisation with the AC97 controller.
*/ */
static int wm9713_set_pll(struct snd_soc_codec *codec, static int wm9713_set_pll(struct snd_soc_component *component,
int pll_id, unsigned int freq_in, unsigned int freq_out) int pll_id, unsigned int freq_in, unsigned int freq_out)
{ {
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component);
u16 reg, reg2; u16 reg, reg2;
struct _pll_div pll_div; struct _pll_div pll_div;
/* turn PLL off ? */ /* turn PLL off ? */
if (freq_in == 0) { if (freq_in == 0) {
/* disable PLL power and select ext source */ /* disable PLL power and select ext source */
snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0080, 0x0080); snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0080, 0x0080);
snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x0200, 0x0200); snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x0200, 0x0200);
wm9713->pll_in = 0; wm9713->pll_in = 0;
return 0; return 0;
} }
pll_factors(codec, &pll_div, freq_in); pll_factors(component, &pll_div, freq_in);
if (pll_div.k == 0) { if (pll_div.k == 0) {
reg = (pll_div.n << 12) | (pll_div.lf << 11) | reg = (pll_div.n << 12) | (pll_div.lf << 11) |
(pll_div.divsel << 9) | (pll_div.divctl << 8); (pll_div.divsel << 9) | (pll_div.divctl << 8);
snd_soc_write(codec, AC97_LINE1_LEVEL, reg); snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
} else { } else {
/* write the fractional k to the reg 0x46 pages */ /* write the fractional k to the reg 0x46 pages */
reg2 = (pll_div.n << 12) | (pll_div.lf << 11) | (1 << 10) | reg2 = (pll_div.n << 12) | (pll_div.lf << 11) | (1 << 10) |
...@@ -844,31 +844,31 @@ static int wm9713_set_pll(struct snd_soc_codec *codec, ...@@ -844,31 +844,31 @@ static int wm9713_set_pll(struct snd_soc_codec *codec,
/* K [21:20] */ /* K [21:20] */
reg = reg2 | (0x5 << 4) | (pll_div.k >> 20); reg = reg2 | (0x5 << 4) | (pll_div.k >> 20);
snd_soc_write(codec, AC97_LINE1_LEVEL, reg); snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
/* K [19:16] */ /* K [19:16] */
reg = reg2 | (0x4 << 4) | ((pll_div.k >> 16) & 0xf); reg = reg2 | (0x4 << 4) | ((pll_div.k >> 16) & 0xf);
snd_soc_write(codec, AC97_LINE1_LEVEL, reg); snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
/* K [15:12] */ /* K [15:12] */
reg = reg2 | (0x3 << 4) | ((pll_div.k >> 12) & 0xf); reg = reg2 | (0x3 << 4) | ((pll_div.k >> 12) & 0xf);
snd_soc_write(codec, AC97_LINE1_LEVEL, reg); snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
/* K [11:8] */ /* K [11:8] */
reg = reg2 | (0x2 << 4) | ((pll_div.k >> 8) & 0xf); reg = reg2 | (0x2 << 4) | ((pll_div.k >> 8) & 0xf);
snd_soc_write(codec, AC97_LINE1_LEVEL, reg); snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
/* K [7:4] */ /* K [7:4] */
reg = reg2 | (0x1 << 4) | ((pll_div.k >> 4) & 0xf); reg = reg2 | (0x1 << 4) | ((pll_div.k >> 4) & 0xf);
snd_soc_write(codec, AC97_LINE1_LEVEL, reg); snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
reg = reg2 | (0x0 << 4) | (pll_div.k & 0xf); /* K [3:0] */ reg = reg2 | (0x0 << 4) | (pll_div.k & 0xf); /* K [3:0] */
snd_soc_write(codec, AC97_LINE1_LEVEL, reg); snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
} }
/* turn PLL on and select as source */ /* turn PLL on and select as source */
snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x0200, 0x0000); snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x0200, 0x0000);
snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0080, 0x0000); snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0080, 0x0000);
wm9713->pll_in = freq_in; wm9713->pll_in = freq_in;
/* wait 10ms AC97 link frames for the link to stabilise */ /* wait 10ms AC97 link frames for the link to stabilise */
...@@ -879,8 +879,8 @@ static int wm9713_set_pll(struct snd_soc_codec *codec, ...@@ -879,8 +879,8 @@ static int wm9713_set_pll(struct snd_soc_codec *codec,
static int wm9713_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm9713_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
int source, unsigned int freq_in, unsigned int freq_out) int source, unsigned int freq_in, unsigned int freq_out)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
return wm9713_set_pll(codec, pll_id, freq_in, freq_out); return wm9713_set_pll(component, pll_id, freq_in, freq_out);
} }
/* /*
...@@ -890,10 +890,10 @@ static int wm9713_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, ...@@ -890,10 +890,10 @@ static int wm9713_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
static int wm9713_set_dai_tristate(struct snd_soc_dai *codec_dai, static int wm9713_set_dai_tristate(struct snd_soc_dai *codec_dai,
int tristate) int tristate)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
if (tristate) if (tristate)
snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER,
0x6000, 0x0000); 0x6000, 0x0000);
return 0; return 0;
...@@ -906,30 +906,30 @@ static int wm9713_set_dai_tristate(struct snd_soc_dai *codec_dai, ...@@ -906,30 +906,30 @@ static int wm9713_set_dai_tristate(struct snd_soc_dai *codec_dai,
static int wm9713_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm9713_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
int div_id, int div) int div_id, int div)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
switch (div_id) { switch (div_id) {
case WM9713_PCMCLK_DIV: case WM9713_PCMCLK_DIV:
snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0f00, div); snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, div);
break; break;
case WM9713_CLKA_MULT: case WM9713_CLKA_MULT:
snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0002, div); snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0002, div);
break; break;
case WM9713_CLKB_MULT: case WM9713_CLKB_MULT:
snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0004, div); snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0004, div);
break; break;
case WM9713_HIFI_DIV: case WM9713_HIFI_DIV:
snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x7000, div); snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x7000, div);
break; break;
case WM9713_PCMBCLK_DIV: case WM9713_PCMBCLK_DIV:
snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, 0x0e00, div); snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x0e00, div);
break; break;
case WM9713_PCMCLK_PLL_DIV: case WM9713_PCMCLK_PLL_DIV:
snd_soc_update_bits(codec, AC97_LINE1_LEVEL, snd_soc_component_update_bits(component, AC97_LINE1_LEVEL,
0x007f, div | 0x60); 0x007f, div | 0x60);
break; break;
case WM9713_HIFI_PLL_DIV: case WM9713_HIFI_PLL_DIV:
snd_soc_update_bits(codec, AC97_LINE1_LEVEL, snd_soc_component_update_bits(component, AC97_LINE1_LEVEL,
0x007f, div | 0x70); 0x007f, div | 0x70);
break; break;
default: default:
...@@ -942,8 +942,8 @@ static int wm9713_set_dai_clkdiv(struct snd_soc_dai *codec_dai, ...@@ -942,8 +942,8 @@ static int wm9713_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
static int wm9713_set_dai_fmt(struct snd_soc_dai *codec_dai, static int wm9713_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
u16 gpio = snd_soc_read(codec, AC97_GPIO_CFG) & 0xffc5; u16 gpio = snd_soc_component_read32(component, AC97_GPIO_CFG) & 0xffc5;
u16 reg = 0x8000; u16 reg = 0x8000;
/* clock masters */ /* clock masters */
...@@ -996,8 +996,8 @@ static int wm9713_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -996,8 +996,8 @@ static int wm9713_set_dai_fmt(struct snd_soc_dai *codec_dai,
break; break;
} }
snd_soc_write(codec, AC97_GPIO_CFG, gpio); snd_soc_component_write(component, AC97_GPIO_CFG, gpio);
snd_soc_write(codec, AC97_CENTER_LFE_MASTER, reg); snd_soc_component_write(component, AC97_CENTER_LFE_MASTER, reg);
return 0; return 0;
} }
...@@ -1005,22 +1005,22 @@ static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -1005,22 +1005,22 @@ static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
/* enable PCM interface in master mode */ /* enable PCM interface in master mode */
switch (params_width(params)) { switch (params_width(params)) {
case 16: case 16:
break; break;
case 20: case 20:
snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER,
0x000c, 0x0004); 0x000c, 0x0004);
break; break;
case 24: case 24:
snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER,
0x000c, 0x0008); 0x000c, 0x0008);
break; break;
case 32: case 32:
snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER,
0x000c, 0x000c); 0x000c, 0x000c);
break; break;
} }
...@@ -1030,33 +1030,33 @@ static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -1030,33 +1030,33 @@ static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream,
static int ac97_hifi_prepare(struct snd_pcm_substream *substream, static int ac97_hifi_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
int reg; int reg;
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x0001, 0x0001); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x0001, 0x0001);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
else else
reg = AC97_PCM_LR_ADC_RATE; reg = AC97_PCM_LR_ADC_RATE;
return snd_soc_write(codec, reg, runtime->rate); return snd_soc_component_write(component, reg, runtime->rate);
} }
static int ac97_aux_prepare(struct snd_pcm_substream *substream, static int ac97_aux_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x0001, 0x0001); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x0001, 0x0001);
snd_soc_update_bits(codec, AC97_PCI_SID, 0x8000, 0x8000); snd_soc_component_update_bits(component, AC97_PCI_SID, 0x8000, 0x8000);
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
return -ENODEV; return -ENODEV;
return snd_soc_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate); return snd_soc_component_write(component, AC97_PCM_SURR_DAC_RATE, runtime->rate);
} }
#define WM9713_RATES (SNDRV_PCM_RATE_8000 | \ #define WM9713_RATES (SNDRV_PCM_RATE_8000 | \
...@@ -1142,48 +1142,48 @@ static struct snd_soc_dai_driver wm9713_dai[] = { ...@@ -1142,48 +1142,48 @@ static struct snd_soc_dai_driver wm9713_dai[] = {
}, },
}; };
static int wm9713_set_bias_level(struct snd_soc_codec *codec, static int wm9713_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
/* enable thermal shutdown */ /* enable thermal shutdown */
snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0xe400, 0x0000); snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0xe400, 0x0000);
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
/* enable master bias and vmid */ /* enable master bias and vmid */
snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0xc400, 0x0000); snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0xc400, 0x0000);
snd_soc_write(codec, AC97_POWERDOWN, 0x0000); snd_soc_component_write(component, AC97_POWERDOWN, 0x0000);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* disable everything including AC link */ /* disable everything including AC link */
snd_soc_write(codec, AC97_EXTENDED_MID, 0xffff); snd_soc_component_write(component, AC97_EXTENDED_MID, 0xffff);
snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff);
snd_soc_write(codec, AC97_POWERDOWN, 0xffff); snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
break; break;
} }
return 0; return 0;
} }
static int wm9713_soc_suspend(struct snd_soc_codec *codec) static int wm9713_soc_suspend(struct snd_soc_component *component)
{ {
/* Disable everything except touchpanel - that will be handled /* Disable everything except touchpanel - that will be handled
* by the touch driver and left disabled if touch is not in * by the touch driver and left disabled if touch is not in
* use. */ * use. */
snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x7fff, snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x7fff,
0x7fff); 0x7fff);
snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff);
snd_soc_write(codec, AC97_POWERDOWN, 0x6f00); snd_soc_component_write(component, AC97_POWERDOWN, 0x6f00);
snd_soc_write(codec, AC97_POWERDOWN, 0xffff); snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
return 0; return 0;
} }
static int wm9713_soc_resume(struct snd_soc_codec *codec) static int wm9713_soc_resume(struct snd_soc_component *component)
{ {
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component);
int ret; int ret;
ret = snd_ac97_reset(wm9713->ac97, true, WM9713_VENDOR_ID, ret = snd_ac97_reset(wm9713->ac97, true, WM9713_VENDOR_ID,
...@@ -1191,24 +1191,24 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec) ...@@ -1191,24 +1191,24 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec)
if (ret < 0) if (ret < 0)
return ret; return ret;
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
/* do we need to re-start the PLL ? */ /* do we need to re-start the PLL ? */
if (wm9713->pll_in) if (wm9713->pll_in)
wm9713_set_pll(codec, 0, wm9713->pll_in, 0); wm9713_set_pll(component, 0, wm9713->pll_in, 0);
/* only synchronise the codec if warm reset failed */ /* only synchronise the codec if warm reset failed */
if (ret == 0) { if (ret == 0) {
regcache_mark_dirty(codec->component.regmap); regcache_mark_dirty(component->regmap);
snd_soc_cache_sync(codec); snd_soc_component_cache_sync(component);
} }
return ret; return ret;
} }
static int wm9713_soc_probe(struct snd_soc_codec *codec) static int wm9713_soc_probe(struct snd_soc_component *component)
{ {
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component);
struct regmap *regmap = NULL; struct regmap *regmap = NULL;
if (wm9713->mfd_pdata) { if (wm9713->mfd_pdata) {
...@@ -1216,54 +1216,54 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) ...@@ -1216,54 +1216,54 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
regmap = wm9713->mfd_pdata->regmap; regmap = wm9713->mfd_pdata->regmap;
} else { } else {
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
wm9713->ac97 = snd_soc_new_ac97_codec(codec, WM9713_VENDOR_ID, wm9713->ac97 = snd_soc_new_ac97_component(component, WM9713_VENDOR_ID,
WM9713_VENDOR_ID_MASK); WM9713_VENDOR_ID_MASK);
if (IS_ERR(wm9713->ac97)) if (IS_ERR(wm9713->ac97))
return PTR_ERR(wm9713->ac97); return PTR_ERR(wm9713->ac97);
regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config); regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config);
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
snd_soc_free_ac97_codec(wm9713->ac97); snd_soc_free_ac97_component(wm9713->ac97);
return PTR_ERR(regmap); return PTR_ERR(regmap);
} }
#endif #endif
} }
snd_soc_codec_init_regmap(codec, regmap); snd_soc_component_init_regmap(component, regmap);
/* unmute the adc - move to kcontrol */ /* unmute the adc - move to kcontrol */
snd_soc_update_bits(codec, AC97_CD, 0x7fff, 0x0000); snd_soc_component_update_bits(component, AC97_CD, 0x7fff, 0x0000);
return 0; return 0;
} }
static int wm9713_soc_remove(struct snd_soc_codec *codec) static void wm9713_soc_remove(struct snd_soc_component *component)
{ {
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component);
if (!wm9713->mfd_pdata) { if (!wm9713->mfd_pdata) {
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
snd_soc_free_ac97_codec(wm9713->ac97); snd_soc_free_ac97_component(wm9713->ac97);
} }
#endif #endif
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm9713 = { static const struct snd_soc_component_driver soc_component_dev_wm9713 = {
.probe = wm9713_soc_probe, .probe = wm9713_soc_probe,
.remove = wm9713_soc_remove, .remove = wm9713_soc_remove,
.suspend = wm9713_soc_suspend, .suspend = wm9713_soc_suspend,
.resume = wm9713_soc_resume, .resume = wm9713_soc_resume,
.set_bias_level = wm9713_set_bias_level, .set_bias_level = wm9713_set_bias_level,
.controls = wm9713_snd_ac97_controls,
.component_driver = { .num_controls = ARRAY_SIZE(wm9713_snd_ac97_controls),
.controls = wm9713_snd_ac97_controls, .dapm_widgets = wm9713_dapm_widgets,
.num_controls = ARRAY_SIZE(wm9713_snd_ac97_controls), .num_dapm_widgets = ARRAY_SIZE(wm9713_dapm_widgets),
.dapm_widgets = wm9713_dapm_widgets, .dapm_routes = wm9713_audio_map,
.num_dapm_widgets = ARRAY_SIZE(wm9713_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(wm9713_audio_map),
.dapm_routes = wm9713_audio_map, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(wm9713_audio_map), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int wm9713_probe(struct platform_device *pdev) static int wm9713_probe(struct platform_device *pdev)
...@@ -1279,14 +1279,8 @@ static int wm9713_probe(struct platform_device *pdev) ...@@ -1279,14 +1279,8 @@ static int wm9713_probe(struct platform_device *pdev)
wm9713->mfd_pdata = dev_get_platdata(&pdev->dev); wm9713->mfd_pdata = dev_get_platdata(&pdev->dev);
platform_set_drvdata(pdev, wm9713); platform_set_drvdata(pdev, wm9713);
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai)); &soc_component_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai));
}
static int wm9713_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver wm9713_codec_driver = { static struct platform_driver wm9713_codec_driver = {
...@@ -1295,7 +1289,6 @@ static struct platform_driver wm9713_codec_driver = { ...@@ -1295,7 +1289,6 @@ static struct platform_driver wm9713_codec_driver = {
}, },
.probe = wm9713_probe, .probe = wm9713_probe,
.remove = wm9713_remove,
}; };
module_platform_driver(wm9713_codec_driver); module_platform_driver(wm9713_codec_driver);
......
...@@ -58,20 +58,20 @@ ...@@ -58,20 +58,20 @@
#define AC97_GPIO_PULL 0x58 #define AC97_GPIO_PULL 0x58
/* Use GPIO8 for rear speaker amplifier */ /* Use GPIO8 for rear speaker amplifier */
static int rear_amp_power(struct snd_soc_codec *codec, int power) static int rear_amp_power(struct snd_soc_component *component, int power)
{ {
unsigned short reg; unsigned short reg;
if (power) { if (power) {
reg = snd_soc_read(codec, AC97_GPIO_CFG); reg = snd_soc_component_read32(component, AC97_GPIO_CFG);
snd_soc_write(codec, AC97_GPIO_CFG, reg | 0x0100); snd_soc_component_write(component, AC97_GPIO_CFG, reg | 0x0100);
reg = snd_soc_read(codec, AC97_GPIO_PULL); reg = snd_soc_component_read32(component, AC97_GPIO_PULL);
snd_soc_write(codec, AC97_GPIO_PULL, reg | (1<<15)); snd_soc_component_write(component, AC97_GPIO_PULL, reg | (1<<15));
} else { } else {
reg = snd_soc_read(codec, AC97_GPIO_CFG); reg = snd_soc_component_read32(component, AC97_GPIO_CFG);
snd_soc_write(codec, AC97_GPIO_CFG, reg & ~0x0100); snd_soc_component_write(component, AC97_GPIO_CFG, reg & ~0x0100);
reg = snd_soc_read(codec, AC97_GPIO_PULL); reg = snd_soc_component_read32(component, AC97_GPIO_PULL);
snd_soc_write(codec, AC97_GPIO_PULL, reg & ~(1<<15)); snd_soc_component_write(component, AC97_GPIO_PULL, reg & ~(1<<15));
} }
return 0; return 0;
...@@ -82,11 +82,11 @@ static int rear_amp_event(struct snd_soc_dapm_widget *widget, ...@@ -82,11 +82,11 @@ static int rear_amp_event(struct snd_soc_dapm_widget *widget,
{ {
struct snd_soc_card *card = widget->dapm->card; struct snd_soc_card *card = widget->dapm->card;
struct snd_soc_pcm_runtime *rtd; struct snd_soc_pcm_runtime *rtd;
struct snd_soc_codec *codec; struct snd_soc_component *component;
rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
codec = rtd->codec; component = rtd->codec_dai->component;
return rear_amp_power(codec, SND_SOC_DAPM_EVENT_ON(event)); return rear_amp_power(component, SND_SOC_DAPM_EVENT_ON(event));
} }
/* mioa701 machine dapm widgets */ /* mioa701 machine dapm widgets */
...@@ -129,13 +129,13 @@ static const struct snd_soc_dapm_route audio_map[] = { ...@@ -129,13 +129,13 @@ static const struct snd_soc_dapm_route audio_map[] = {
static int mioa701_wm9713_init(struct snd_soc_pcm_runtime *rtd) static int mioa701_wm9713_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
/* Prepare GPIO8 for rear speaker amplifier */ /* Prepare GPIO8 for rear speaker amplifier */
snd_soc_update_bits(codec, AC97_GPIO_CFG, 0x100, 0x100); snd_soc_component_update_bits(component, AC97_GPIO_CFG, 0x100, 0x100);
/* Prepare MIC input */ /* Prepare MIC input */
snd_soc_update_bits(codec, AC97_3D_CONTROL, 0xc000, 0xc000); snd_soc_component_update_bits(component, AC97_3D_CONTROL, 0xc000, 0xc000);
return 0; return 0;
} }
......
...@@ -75,7 +75,7 @@ static const struct snd_soc_dapm_route ttc_audio_map[] = { ...@@ -75,7 +75,7 @@ static const struct snd_soc_dapm_route ttc_audio_map[] = {
static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd) static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
/* Headset jack detection */ /* Headset jack detection */
snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE | snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE |
...@@ -86,9 +86,9 @@ static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd) ...@@ -86,9 +86,9 @@ static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
ARRAY_SIZE(mic_jack_pins)); ARRAY_SIZE(mic_jack_pins));
/* headphone, microphone detection & headset short detection */ /* headphone, microphone detection & headset short detection */
pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE, pm860x_hs_jack_detect(component, &hs_jack, SND_JACK_HEADPHONE,
SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2); SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2);
pm860x_mic_jack_detect(codec, &hs_jack, SND_JACK_MICROPHONE); pm860x_mic_jack_detect(component, &hs_jack, SND_JACK_MICROPHONE);
return 0; return 0;
} }
......
...@@ -44,7 +44,7 @@ struct snd_ac97_gpio_priv { ...@@ -44,7 +44,7 @@ struct snd_ac97_gpio_priv {
struct gpio_chip gpio_chip; struct gpio_chip gpio_chip;
#endif #endif
unsigned int gpios_set; unsigned int gpios_set;
struct snd_soc_codec *codec; struct snd_soc_component *component;
}; };
static struct snd_ac97_bus soc_ac97_bus = { static struct snd_ac97_bus soc_ac97_bus = {
...@@ -57,11 +57,11 @@ static void soc_ac97_device_release(struct device *dev) ...@@ -57,11 +57,11 @@ static void soc_ac97_device_release(struct device *dev)
} }
#ifdef CONFIG_GPIOLIB #ifdef CONFIG_GPIOLIB
static inline struct snd_soc_codec *gpio_to_codec(struct gpio_chip *chip) static inline struct snd_soc_component *gpio_to_component(struct gpio_chip *chip)
{ {
struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip);
return gpio_priv->codec; return gpio_priv->component;
} }
static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset) static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset)
...@@ -75,20 +75,22 @@ static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset) ...@@ -75,20 +75,22 @@ static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset)
static int snd_soc_ac97_gpio_direction_in(struct gpio_chip *chip, static int snd_soc_ac97_gpio_direction_in(struct gpio_chip *chip,
unsigned offset) unsigned offset)
{ {
struct snd_soc_codec *codec = gpio_to_codec(chip); struct snd_soc_component *component = gpio_to_component(chip);
dev_dbg(codec->dev, "set gpio %d to output\n", offset); dev_dbg(component->dev, "set gpio %d to output\n", offset);
return snd_soc_update_bits(codec, AC97_GPIO_CFG, return snd_soc_component_update_bits(component, AC97_GPIO_CFG,
1 << offset, 1 << offset); 1 << offset, 1 << offset);
} }
static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset) static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset)
{ {
struct snd_soc_codec *codec = gpio_to_codec(chip); struct snd_soc_component *component = gpio_to_component(chip);
int ret; int ret;
ret = snd_soc_read(codec, AC97_GPIO_STATUS); if (snd_soc_component_read(component, AC97_GPIO_STATUS, &ret) < 0)
dev_dbg(codec->dev, "get gpio %d : %d\n", offset, ret = -1;
dev_dbg(component->dev, "get gpio %d : %d\n", offset,
ret < 0 ? ret : ret & (1 << offset)); ret < 0 ? ret : ret & (1 << offset));
return ret < 0 ? ret : !!(ret & (1 << offset)); return ret < 0 ? ret : !!(ret & (1 << offset));
...@@ -98,22 +100,24 @@ static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset, ...@@ -98,22 +100,24 @@ static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset,
int value) int value)
{ {
struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip);
struct snd_soc_codec *codec = gpio_to_codec(chip); struct snd_soc_component *component = gpio_to_component(chip);
gpio_priv->gpios_set &= ~(1 << offset); gpio_priv->gpios_set &= ~(1 << offset);
gpio_priv->gpios_set |= (!!value) << offset; gpio_priv->gpios_set |= (!!value) << offset;
snd_soc_write(codec, AC97_GPIO_STATUS, gpio_priv->gpios_set); snd_soc_component_write(component, AC97_GPIO_STATUS,
dev_dbg(codec->dev, "set gpio %d to %d\n", offset, !!value); gpio_priv->gpios_set);
dev_dbg(component->dev, "set gpio %d to %d\n", offset, !!value);
} }
static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip, static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip,
unsigned offset, int value) unsigned offset, int value)
{ {
struct snd_soc_codec *codec = gpio_to_codec(chip); struct snd_soc_component *component = gpio_to_component(chip);
dev_dbg(codec->dev, "set gpio %d to output\n", offset); dev_dbg(component->dev, "set gpio %d to output\n", offset);
snd_soc_ac97_gpio_set(chip, offset, value); snd_soc_ac97_gpio_set(chip, offset, value);
return snd_soc_update_bits(codec, AC97_GPIO_CFG, 1 << offset, 0); return snd_soc_component_update_bits(component, AC97_GPIO_CFG,
1 << offset, 0);
} }
static const struct gpio_chip snd_soc_ac97_gpio_chip = { static const struct gpio_chip snd_soc_ac97_gpio_chip = {
...@@ -128,24 +132,24 @@ static const struct gpio_chip snd_soc_ac97_gpio_chip = { ...@@ -128,24 +132,24 @@ static const struct gpio_chip snd_soc_ac97_gpio_chip = {
}; };
static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97,
struct snd_soc_codec *codec) struct snd_soc_component *component)
{ {
struct snd_ac97_gpio_priv *gpio_priv; struct snd_ac97_gpio_priv *gpio_priv;
int ret; int ret;
gpio_priv = devm_kzalloc(codec->dev, sizeof(*gpio_priv), GFP_KERNEL); gpio_priv = devm_kzalloc(component->dev, sizeof(*gpio_priv), GFP_KERNEL);
if (!gpio_priv) if (!gpio_priv)
return -ENOMEM; return -ENOMEM;
ac97->gpio_priv = gpio_priv; ac97->gpio_priv = gpio_priv;
gpio_priv->codec = codec; gpio_priv->component = component;
gpio_priv->gpio_chip = snd_soc_ac97_gpio_chip; gpio_priv->gpio_chip = snd_soc_ac97_gpio_chip;
gpio_priv->gpio_chip.ngpio = AC97_NUM_GPIOS; gpio_priv->gpio_chip.ngpio = AC97_NUM_GPIOS;
gpio_priv->gpio_chip.parent = codec->dev; gpio_priv->gpio_chip.parent = component->dev;
gpio_priv->gpio_chip.base = -1; gpio_priv->gpio_chip.base = -1;
ret = gpiochip_add_data(&gpio_priv->gpio_chip, gpio_priv); ret = gpiochip_add_data(&gpio_priv->gpio_chip, gpio_priv);
if (ret != 0) if (ret != 0)
dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); dev_err(component->dev, "Failed to add GPIOs: %d\n", ret);
return ret; return ret;
} }
...@@ -155,7 +159,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) ...@@ -155,7 +159,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97)
} }
#else #else
static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97,
struct snd_soc_codec *codec) struct snd_soc_component *component)
{ {
return 0; return 0;
} }
...@@ -166,8 +170,8 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) ...@@ -166,8 +170,8 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97)
#endif #endif
/** /**
* snd_soc_alloc_ac97_codec() - Allocate new a AC'97 device * snd_soc_alloc_ac97_component() - Allocate new a AC'97 device
* @codec: The CODEC for which to create the AC'97 device * @component: The COMPONENT for which to create the AC'97 device
* *
* Allocated a new snd_ac97 device and intializes it, but does not yet register * Allocated a new snd_ac97 device and intializes it, but does not yet register
* it. The caller is responsible to either call device_add(&ac97->dev) to * it. The caller is responsible to either call device_add(&ac97->dev) to
...@@ -175,7 +179,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) ...@@ -175,7 +179,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97)
* *
* Returns: A snd_ac97 device or a PTR_ERR in case of an error. * Returns: A snd_ac97 device or a PTR_ERR in case of an error.
*/ */
struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
...@@ -187,26 +191,26 @@ struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) ...@@ -187,26 +191,26 @@ struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec)
ac97->num = 0; ac97->num = 0;
ac97->dev.bus = &ac97_bus_type; ac97->dev.bus = &ac97_bus_type;
ac97->dev.parent = codec->component.card->dev; ac97->dev.parent = component->card->dev;
ac97->dev.release = soc_ac97_device_release; ac97->dev.release = soc_ac97_device_release;
dev_set_name(&ac97->dev, "%d-%d:%s", dev_set_name(&ac97->dev, "%d-%d:%s",
codec->component.card->snd_card->number, 0, component->card->snd_card->number, 0,
codec->component.name); component->name);
device_initialize(&ac97->dev); device_initialize(&ac97->dev);
return ac97; return ac97;
} }
EXPORT_SYMBOL(snd_soc_alloc_ac97_codec); EXPORT_SYMBOL(snd_soc_alloc_ac97_component);
/** /**
* snd_soc_new_ac97_codec - initailise AC97 device * snd_soc_new_ac97_component - initailise AC97 device
* @codec: audio codec * @component: audio component
* @id: The expected device ID * @id: The expected device ID
* @id_mask: Mask that is applied to the device ID before comparing with @id * @id_mask: Mask that is applied to the device ID before comparing with @id
* *
* Initialises AC97 codec resources for use by ad-hoc devices only. * Initialises AC97 component resources for use by ad-hoc devices only.
* *
* If @id is not 0 this function will reset the device, then read the ID from * If @id is not 0 this function will reset the device, then read the ID from
* the device and check if it matches the expected ID. If it doesn't match an * the device and check if it matches the expected ID. If it doesn't match an
...@@ -214,20 +218,20 @@ EXPORT_SYMBOL(snd_soc_alloc_ac97_codec); ...@@ -214,20 +218,20 @@ EXPORT_SYMBOL(snd_soc_alloc_ac97_codec);
* *
* Returns: A PTR_ERR() on failure or a valid snd_ac97 struct on success. * Returns: A PTR_ERR() on failure or a valid snd_ac97 struct on success.
*/ */
struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
unsigned int id, unsigned int id_mask) unsigned int id, unsigned int id_mask)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
int ret; int ret;
ac97 = snd_soc_alloc_ac97_codec(codec); ac97 = snd_soc_alloc_ac97_component(component);
if (IS_ERR(ac97)) if (IS_ERR(ac97))
return ac97; return ac97;
if (id) { if (id) {
ret = snd_ac97_reset(ac97, false, id, id_mask); ret = snd_ac97_reset(ac97, false, id, id_mask);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to reset AC97 device: %d\n", dev_err(component->dev, "Failed to reset AC97 device: %d\n",
ret); ret);
goto err_put_device; goto err_put_device;
} }
...@@ -237,7 +241,7 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, ...@@ -237,7 +241,7 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
if (ret) if (ret)
goto err_put_device; goto err_put_device;
ret = snd_soc_ac97_init_gpio(ac97, codec); ret = snd_soc_ac97_init_gpio(ac97, component);
if (ret) if (ret)
goto err_put_device; goto err_put_device;
...@@ -247,22 +251,22 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, ...@@ -247,22 +251,22 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
put_device(&ac97->dev); put_device(&ac97->dev);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec); EXPORT_SYMBOL_GPL(snd_soc_new_ac97_component);
/** /**
* snd_soc_free_ac97_codec - free AC97 codec device * snd_soc_free_ac97_component - free AC97 component device
* @ac97: snd_ac97 device to be freed * @ac97: snd_ac97 device to be freed
* *
* Frees AC97 codec device resources. * Frees AC97 component device resources.
*/ */
void snd_soc_free_ac97_codec(struct snd_ac97 *ac97) void snd_soc_free_ac97_component(struct snd_ac97 *ac97)
{ {
snd_soc_ac97_free_gpio(ac97); snd_soc_ac97_free_gpio(ac97);
device_del(&ac97->dev); device_del(&ac97->dev);
ac97->bus = NULL; ac97->bus = NULL;
put_device(&ac97->dev); put_device(&ac97->dev);
} }
EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); EXPORT_SYMBOL_GPL(snd_soc_free_ac97_component);
static struct snd_ac97_reset_cfg snd_ac97_rst_cfg; static struct snd_ac97_reset_cfg snd_ac97_rst_cfg;
......
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