Commit 0d1b2881 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/wm8960', 'asoc/topic/wm8961',...

Merge remote-tracking branches 'asoc/topic/wm8960', 'asoc/topic/wm8961', 'asoc/topic/wm8962', 'asoc/topic/wm8971' and 'asoc/topic/wm8974' into asoc-next
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#define WM8960_DRES_MASK 0x30 #define WM8960_DRES_MASK 0x30
static bool is_pll_freq_available(unsigned int source, unsigned int target); static bool is_pll_freq_available(unsigned int source, unsigned int target);
static int wm8960_set_pll(struct snd_soc_codec *codec, static int wm8960_set_pll(struct snd_soc_component *component,
unsigned int freq_in, unsigned int freq_out); unsigned int freq_in, unsigned int freq_out);
/* /*
* wm8960 register cache * wm8960 register cache
...@@ -123,7 +123,7 @@ static bool wm8960_volatile(struct device *dev, unsigned int reg) ...@@ -123,7 +123,7 @@ static bool wm8960_volatile(struct device *dev, unsigned int reg)
struct wm8960_priv { struct wm8960_priv {
struct clk *mclk; struct clk *mclk;
struct regmap *regmap; struct regmap *regmap;
int (*set_bias_level)(struct snd_soc_codec *, int (*set_bias_level)(struct snd_soc_component *,
enum snd_soc_bias_level level); enum snd_soc_bias_level level);
struct snd_soc_dapm_widget *lout1; struct snd_soc_dapm_widget *lout1;
struct snd_soc_dapm_widget *rout1; struct snd_soc_dapm_widget *rout1;
...@@ -168,9 +168,9 @@ static const struct soc_enum wm8960_enum[] = { ...@@ -168,9 +168,9 @@ static const struct soc_enum wm8960_enum[] = {
static const int deemph_settings[] = { 0, 32000, 44100, 48000 }; static const int deemph_settings[] = { 0, 32000, 44100, 48000 };
static int wm8960_set_deemph(struct snd_soc_codec *codec) static int wm8960_set_deemph(struct snd_soc_component *component)
{ {
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
int val, i, best; int val, i, best;
/* If we're using deemphasis select the nearest available sample /* If we're using deemphasis select the nearest available sample
...@@ -189,17 +189,17 @@ static int wm8960_set_deemph(struct snd_soc_codec *codec) ...@@ -189,17 +189,17 @@ static int wm8960_set_deemph(struct snd_soc_codec *codec)
val = 0; val = 0;
} }
dev_dbg(codec->dev, "Set deemphasis %d\n", val); dev_dbg(component->dev, "Set deemphasis %d\n", val);
return snd_soc_update_bits(codec, WM8960_DACCTL1, return snd_soc_component_update_bits(component, WM8960_DACCTL1,
0x6, val); 0x6, val);
} }
static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, static int wm8960_get_deemph(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 wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wm8960->deemph; ucontrol->value.integer.value[0] = wm8960->deemph;
return 0; return 0;
...@@ -208,8 +208,8 @@ static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, ...@@ -208,8 +208,8 @@ static int wm8960_get_deemph(struct snd_kcontrol *kcontrol,
static int wm8960_put_deemph(struct snd_kcontrol *kcontrol, static int wm8960_put_deemph(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 wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
unsigned int deemph = ucontrol->value.integer.value[0]; unsigned int deemph = ucontrol->value.integer.value[0];
if (deemph > 1) if (deemph > 1)
...@@ -217,7 +217,7 @@ static int wm8960_put_deemph(struct snd_kcontrol *kcontrol, ...@@ -217,7 +217,7 @@ static int wm8960_put_deemph(struct snd_kcontrol *kcontrol,
wm8960->deemph = deemph; wm8960->deemph = deemph;
return wm8960_set_deemph(codec); return wm8960_set_deemph(component);
} }
static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1); static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1);
...@@ -470,11 +470,11 @@ static const struct snd_soc_dapm_route audio_paths_capless[] = { ...@@ -470,11 +470,11 @@ static const struct snd_soc_dapm_route audio_paths_capless[] = {
{ "OUT3 VMID", NULL, "Right Output Mixer" }, { "OUT3 VMID", NULL, "Right Output Mixer" },
}; };
static int wm8960_add_widgets(struct snd_soc_codec *codec) static int wm8960_add_widgets(struct snd_soc_component *component)
{ {
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
struct wm8960_data *pdata = &wm8960->pdata; struct wm8960_data *pdata = &wm8960->pdata;
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 snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
snd_soc_dapm_new_controls(dapm, wm8960_dapm_widgets, snd_soc_dapm_new_controls(dapm, wm8960_dapm_widgets,
...@@ -504,7 +504,7 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec) ...@@ -504,7 +504,7 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec)
* list each time to find the desired power state do so now * list each time to find the desired power state do so now
* and save the result. * and save the result.
*/ */
list_for_each_entry(w, &codec->component.card->widgets, list) { list_for_each_entry(w, &component->card->widgets, list) {
if (w->dapm != dapm) if (w->dapm != dapm)
continue; continue;
if (strcmp(w->name, "LOUT1 PGA") == 0) if (strcmp(w->name, "LOUT1 PGA") == 0)
...@@ -521,7 +521,7 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec) ...@@ -521,7 +521,7 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec)
static int wm8960_set_dai_fmt(struct snd_soc_dai *codec_dai, static int wm8960_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 iface = 0; u16 iface = 0;
/* set master/slave audio interface */ /* set master/slave audio interface */
...@@ -573,7 +573,7 @@ static int wm8960_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -573,7 +573,7 @@ static int wm8960_set_dai_fmt(struct snd_soc_dai *codec_dai,
} }
/* set iface */ /* set iface */
snd_soc_write(codec, WM8960_IFACE1, iface); snd_soc_component_write(component, WM8960_IFACE1, iface);
return 0; return 0;
} }
...@@ -683,7 +683,7 @@ int wm8960_configure_sysclk(struct wm8960_priv *wm8960, int mclk, ...@@ -683,7 +683,7 @@ int wm8960_configure_sysclk(struct wm8960_priv *wm8960, int mclk,
* triplet, we relax the bclk such that bclk is chosen as the * triplet, we relax the bclk such that bclk is chosen as the
* closest available frequency greater than expected bclk. * closest available frequency greater than expected bclk.
* *
* @codec: codec structure * @component: component structure
* @freq_in: input frequency used to derive freq out via PLL * @freq_in: input frequency used to derive freq out via PLL
* @sysclk_idx: sysclk_divs index for found sysclk * @sysclk_idx: sysclk_divs index for found sysclk
* @dac_idx: dac_divs index for found lrclk * @dac_idx: dac_divs index for found lrclk
...@@ -695,10 +695,10 @@ int wm8960_configure_sysclk(struct wm8960_priv *wm8960, int mclk, ...@@ -695,10 +695,10 @@ int wm8960_configure_sysclk(struct wm8960_priv *wm8960, int mclk,
* (@sysclk_idx, @dac_idx, @bclk_idx) dividers * (@sysclk_idx, @dac_idx, @bclk_idx) dividers
*/ */
static static
int wm8960_configure_pll(struct snd_soc_codec *codec, int freq_in, int wm8960_configure_pll(struct snd_soc_component *component, int freq_in,
int *sysclk_idx, int *dac_idx, int *bclk_idx) int *sysclk_idx, int *dac_idx, int *bclk_idx)
{ {
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
int sysclk, bclk, lrclk, freq_out; int sysclk, bclk, lrclk, freq_out;
int diff, closest, best_freq_out; int diff, closest, best_freq_out;
int i, j, k; int i, j, k;
...@@ -741,22 +741,22 @@ int wm8960_configure_pll(struct snd_soc_codec *codec, int freq_in, ...@@ -741,22 +741,22 @@ int wm8960_configure_pll(struct snd_soc_codec *codec, int freq_in,
return best_freq_out; return best_freq_out;
} }
static int wm8960_configure_clocking(struct snd_soc_codec *codec) static int wm8960_configure_clocking(struct snd_soc_component *component)
{ {
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
int freq_out, freq_in; int freq_out, freq_in;
u16 iface1 = snd_soc_read(codec, WM8960_IFACE1); u16 iface1 = snd_soc_component_read32(component, WM8960_IFACE1);
int i, j, k; int i, j, k;
int ret; int ret;
if (!(iface1 & (1<<6))) { if (!(iface1 & (1<<6))) {
dev_dbg(codec->dev, dev_dbg(component->dev,
"Codec is slave mode, no need to configure clock\n"); "Codec is slave mode, no need to configure clock\n");
return 0; return 0;
} }
if (wm8960->clk_id != WM8960_SYSCLK_MCLK && !wm8960->freq_in) { if (wm8960->clk_id != WM8960_SYSCLK_MCLK && !wm8960->freq_in) {
dev_err(codec->dev, "No MCLK configured\n"); dev_err(component->dev, "No MCLK configured\n");
return -EINVAL; return -EINVAL;
} }
...@@ -769,12 +769,12 @@ static int wm8960_configure_clocking(struct snd_soc_codec *codec) ...@@ -769,12 +769,12 @@ static int wm8960_configure_clocking(struct snd_soc_codec *codec)
*/ */
if (wm8960->clk_id == WM8960_SYSCLK_AUTO) { if (wm8960->clk_id == WM8960_SYSCLK_AUTO) {
/* disable the PLL and using MCLK to provide sysclk */ /* disable the PLL and using MCLK to provide sysclk */
wm8960_set_pll(codec, 0, 0); wm8960_set_pll(component, 0, 0);
freq_out = freq_in; freq_out = freq_in;
} else if (wm8960->sysclk) { } else if (wm8960->sysclk) {
freq_out = wm8960->sysclk; freq_out = wm8960->sysclk;
} else { } else {
dev_err(codec->dev, "No SYSCLK configured\n"); dev_err(component->dev, "No SYSCLK configured\n");
return -EINVAL; return -EINVAL;
} }
...@@ -783,28 +783,28 @@ static int wm8960_configure_clocking(struct snd_soc_codec *codec) ...@@ -783,28 +783,28 @@ static int wm8960_configure_clocking(struct snd_soc_codec *codec)
if (ret >= 0) { if (ret >= 0) {
goto configure_clock; goto configure_clock;
} else if (wm8960->clk_id != WM8960_SYSCLK_AUTO) { } else if (wm8960->clk_id != WM8960_SYSCLK_AUTO) {
dev_err(codec->dev, "failed to configure clock\n"); dev_err(component->dev, "failed to configure clock\n");
return -EINVAL; return -EINVAL;
} }
} }
freq_out = wm8960_configure_pll(codec, freq_in, &i, &j, &k); freq_out = wm8960_configure_pll(component, freq_in, &i, &j, &k);
if (freq_out < 0) { if (freq_out < 0) {
dev_err(codec->dev, "failed to configure clock via PLL\n"); dev_err(component->dev, "failed to configure clock via PLL\n");
return freq_out; return freq_out;
} }
wm8960_set_pll(codec, freq_in, freq_out); wm8960_set_pll(component, freq_in, freq_out);
configure_clock: configure_clock:
/* configure sysclk clock */ /* configure sysclk clock */
snd_soc_update_bits(codec, WM8960_CLOCK1, 3 << 1, i << 1); snd_soc_component_update_bits(component, WM8960_CLOCK1, 3 << 1, i << 1);
/* configure frame clock */ /* configure frame clock */
snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 3, j << 3); snd_soc_component_update_bits(component, WM8960_CLOCK1, 0x7 << 3, j << 3);
snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 6, j << 6); snd_soc_component_update_bits(component, WM8960_CLOCK1, 0x7 << 6, j << 6);
/* configure bit clock */ /* configure bit clock */
snd_soc_update_bits(codec, WM8960_CLOCK2, 0xf, k); snd_soc_component_update_bits(component, WM8960_CLOCK2, 0xf, k);
return 0; return 0;
} }
...@@ -813,9 +813,9 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, ...@@ -813,9 +813,9 @@ static int wm8960_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;
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
u16 iface = snd_soc_read(codec, WM8960_IFACE1) & 0xfff3; u16 iface = snd_soc_component_read32(component, WM8960_IFACE1) & 0xfff3;
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
int i; int i;
...@@ -840,7 +840,7 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, ...@@ -840,7 +840,7 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream,
break; break;
} }
default: default:
dev_err(codec->dev, "unsupported width %d\n", dev_err(component->dev, "unsupported width %d\n",
params_width(params)); params_width(params));
return -EINVAL; return -EINVAL;
} }
...@@ -848,23 +848,23 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, ...@@ -848,23 +848,23 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream,
wm8960->lrclk = params_rate(params); wm8960->lrclk = params_rate(params);
/* Update filters for the new rate */ /* Update filters for the new rate */
if (tx) { if (tx) {
wm8960_set_deemph(codec); wm8960_set_deemph(component);
} else { } else {
for (i = 0; i < ARRAY_SIZE(alc_rates); i++) for (i = 0; i < ARRAY_SIZE(alc_rates); i++)
if (alc_rates[i].rate == params_rate(params)) if (alc_rates[i].rate == params_rate(params))
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
WM8960_ADDCTL3, 0x7, WM8960_ADDCTL3, 0x7,
alc_rates[i].val); alc_rates[i].val);
} }
/* set iface */ /* set iface */
snd_soc_write(codec, WM8960_IFACE1, iface); snd_soc_component_write(component, WM8960_IFACE1, iface);
wm8960->is_stream_in_use[tx] = true; wm8960->is_stream_in_use[tx] = true;
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON && if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON &&
!wm8960->is_stream_in_use[!tx]) !wm8960->is_stream_in_use[!tx])
return wm8960_configure_clocking(codec); return wm8960_configure_clocking(component);
return 0; return 0;
} }
...@@ -872,8 +872,8 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, ...@@ -872,8 +872,8 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream,
static int wm8960_hw_free(struct snd_pcm_substream *substream, static int wm8960_hw_free(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 wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
wm8960->is_stream_in_use[tx] = false; wm8960->is_stream_in_use[tx] = false;
...@@ -883,20 +883,20 @@ static int wm8960_hw_free(struct snd_pcm_substream *substream, ...@@ -883,20 +883,20 @@ static int wm8960_hw_free(struct snd_pcm_substream *substream,
static int wm8960_mute(struct snd_soc_dai *dai, int mute) static int wm8960_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
if (mute) if (mute)
snd_soc_update_bits(codec, WM8960_DACCTL1, 0x8, 0x8); snd_soc_component_update_bits(component, WM8960_DACCTL1, 0x8, 0x8);
else else
snd_soc_update_bits(codec, WM8960_DACCTL1, 0x8, 0); snd_soc_component_update_bits(component, WM8960_DACCTL1, 0x8, 0);
return 0; return 0;
} }
static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, static int wm8960_set_bias_level_out3(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
u16 pm2 = snd_soc_read(codec, WM8960_POWER2); u16 pm2 = snd_soc_component_read32(component, WM8960_POWER2);
int ret; int ret;
switch (level) { switch (level) {
...@@ -904,24 +904,24 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, ...@@ -904,24 +904,24 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
switch (snd_soc_codec_get_bias_level(codec)) { switch (snd_soc_component_get_bias_level(component)) {
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (!IS_ERR(wm8960->mclk)) { if (!IS_ERR(wm8960->mclk)) {
ret = clk_prepare_enable(wm8960->mclk); ret = clk_prepare_enable(wm8960->mclk);
if (ret) { if (ret) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to enable MCLK: %d\n", "Failed to enable MCLK: %d\n",
ret); ret);
return ret; return ret;
} }
} }
ret = wm8960_configure_clocking(codec); ret = wm8960_configure_clocking(component);
if (ret) if (ret)
return ret; return ret;
/* Set VMID to 2x50k */ /* Set VMID to 2x50k */
snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x80); snd_soc_component_update_bits(component, WM8960_POWER1, 0x180, 0x80);
break; break;
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
...@@ -930,7 +930,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, ...@@ -930,7 +930,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
* disable the pll * disable the pll
*/ */
if (wm8960->clk_id == WM8960_SYSCLK_AUTO && (pm2 & 0x1)) if (wm8960->clk_id == WM8960_SYSCLK_AUTO && (pm2 & 0x1))
wm8960_set_pll(codec, 0, 0); wm8960_set_pll(component, 0, 0);
if (!IS_ERR(wm8960->mclk)) if (!IS_ERR(wm8960->mclk))
clk_disable_unprepare(wm8960->mclk); clk_disable_unprepare(wm8960->mclk);
...@@ -943,38 +943,38 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, ...@@ -943,38 +943,38 @@ static int wm8960_set_bias_level_out3(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) {
regcache_sync(wm8960->regmap); regcache_sync(wm8960->regmap);
/* Enable anti-pop features */ /* Enable anti-pop features */
snd_soc_write(codec, WM8960_APOP1, snd_soc_component_write(component, WM8960_APOP1,
WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_POBCTRL | WM8960_SOFT_ST |
WM8960_BUFDCOPEN | WM8960_BUFIOEN); WM8960_BUFDCOPEN | WM8960_BUFIOEN);
/* Enable & ramp VMID at 2x50k */ /* Enable & ramp VMID at 2x50k */
snd_soc_update_bits(codec, WM8960_POWER1, 0x80, 0x80); snd_soc_component_update_bits(component, WM8960_POWER1, 0x80, 0x80);
msleep(100); msleep(100);
/* Enable VREF */ /* Enable VREF */
snd_soc_update_bits(codec, WM8960_POWER1, WM8960_VREF, snd_soc_component_update_bits(component, WM8960_POWER1, WM8960_VREF,
WM8960_VREF); WM8960_VREF);
/* Disable anti-pop features */ /* Disable anti-pop features */
snd_soc_write(codec, WM8960_APOP1, WM8960_BUFIOEN); snd_soc_component_write(component, WM8960_APOP1, WM8960_BUFIOEN);
} }
/* Set VMID to 2x250k */ /* Set VMID to 2x250k */
snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x100); snd_soc_component_update_bits(component, WM8960_POWER1, 0x180, 0x100);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* Enable anti-pop features */ /* Enable anti-pop features */
snd_soc_write(codec, WM8960_APOP1, snd_soc_component_write(component, WM8960_APOP1,
WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_POBCTRL | WM8960_SOFT_ST |
WM8960_BUFDCOPEN | WM8960_BUFIOEN); WM8960_BUFDCOPEN | WM8960_BUFIOEN);
/* Disable VMID and VREF, let them discharge */ /* Disable VMID and VREF, let them discharge */
snd_soc_write(codec, WM8960_POWER1, 0); snd_soc_component_write(component, WM8960_POWER1, 0);
msleep(600); msleep(600);
break; break;
} }
...@@ -982,11 +982,11 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, ...@@ -982,11 +982,11 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec,
return 0; return 0;
} }
static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, static int wm8960_set_bias_level_capless(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
u16 pm2 = snd_soc_read(codec, WM8960_POWER2); u16 pm2 = snd_soc_component_read32(component, WM8960_POWER2);
int reg, ret; int reg, ret;
switch (level) { switch (level) {
...@@ -994,10 +994,10 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, ...@@ -994,10 +994,10 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
switch (snd_soc_codec_get_bias_level(codec)) { switch (snd_soc_component_get_bias_level(component)) {
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
/* Enable anti pop mode */ /* Enable anti pop mode */
snd_soc_update_bits(codec, WM8960_APOP1, snd_soc_component_update_bits(component, WM8960_APOP1,
WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_POBCTRL | WM8960_SOFT_ST |
WM8960_BUFDCOPEN, WM8960_BUFDCOPEN,
WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_POBCTRL | WM8960_SOFT_ST |
...@@ -1011,20 +1011,20 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, ...@@ -1011,20 +1011,20 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec,
reg |= WM8960_PWR2_ROUT1; reg |= WM8960_PWR2_ROUT1;
if (wm8960->out3 && wm8960->out3->power) if (wm8960->out3 && wm8960->out3->power)
reg |= WM8960_PWR2_OUT3; reg |= WM8960_PWR2_OUT3;
snd_soc_update_bits(codec, WM8960_POWER2, snd_soc_component_update_bits(component, WM8960_POWER2,
WM8960_PWR2_LOUT1 | WM8960_PWR2_LOUT1 |
WM8960_PWR2_ROUT1 | WM8960_PWR2_ROUT1 |
WM8960_PWR2_OUT3, reg); WM8960_PWR2_OUT3, reg);
/* Enable VMID at 2*50k */ /* Enable VMID at 2*50k */
snd_soc_update_bits(codec, WM8960_POWER1, snd_soc_component_update_bits(component, WM8960_POWER1,
WM8960_VMID_MASK, 0x80); WM8960_VMID_MASK, 0x80);
/* Ramp */ /* Ramp */
msleep(100); msleep(100);
/* Enable VREF */ /* Enable VREF */
snd_soc_update_bits(codec, WM8960_POWER1, snd_soc_component_update_bits(component, WM8960_POWER1,
WM8960_VREF, WM8960_VREF); WM8960_VREF, WM8960_VREF);
msleep(100); msleep(100);
...@@ -1032,14 +1032,14 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, ...@@ -1032,14 +1032,14 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec,
if (!IS_ERR(wm8960->mclk)) { if (!IS_ERR(wm8960->mclk)) {
ret = clk_prepare_enable(wm8960->mclk); ret = clk_prepare_enable(wm8960->mclk);
if (ret) { if (ret) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to enable MCLK: %d\n", "Failed to enable MCLK: %d\n",
ret); ret);
return ret; return ret;
} }
} }
ret = wm8960_configure_clocking(codec); ret = wm8960_configure_clocking(component);
if (ret) if (ret)
return ret; return ret;
...@@ -1051,20 +1051,20 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, ...@@ -1051,20 +1051,20 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec,
* disable the pll * disable the pll
*/ */
if (wm8960->clk_id == WM8960_SYSCLK_AUTO && (pm2 & 0x1)) if (wm8960->clk_id == WM8960_SYSCLK_AUTO && (pm2 & 0x1))
wm8960_set_pll(codec, 0, 0); wm8960_set_pll(component, 0, 0);
if (!IS_ERR(wm8960->mclk)) if (!IS_ERR(wm8960->mclk))
clk_disable_unprepare(wm8960->mclk); clk_disable_unprepare(wm8960->mclk);
/* Enable anti-pop mode */ /* Enable anti-pop mode */
snd_soc_update_bits(codec, WM8960_APOP1, snd_soc_component_update_bits(component, WM8960_APOP1,
WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_POBCTRL | WM8960_SOFT_ST |
WM8960_BUFDCOPEN, WM8960_BUFDCOPEN,
WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_POBCTRL | WM8960_SOFT_ST |
WM8960_BUFDCOPEN); WM8960_BUFDCOPEN);
/* Disable VMID and VREF */ /* Disable VMID and VREF */
snd_soc_update_bits(codec, WM8960_POWER1, snd_soc_component_update_bits(component, WM8960_POWER1,
WM8960_VREF | WM8960_VMID_MASK, 0); WM8960_VREF | WM8960_VMID_MASK, 0);
break; break;
...@@ -1077,15 +1077,15 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, ...@@ -1077,15 +1077,15 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
switch (snd_soc_codec_get_bias_level(codec)) { switch (snd_soc_component_get_bias_level(component)) {
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* Disable HP discharge */ /* Disable HP discharge */
snd_soc_update_bits(codec, WM8960_APOP2, snd_soc_component_update_bits(component, WM8960_APOP2,
WM8960_DISOP | WM8960_DRES_MASK, WM8960_DISOP | WM8960_DRES_MASK,
0); 0);
/* Disable anti-pop features */ /* Disable anti-pop features */
snd_soc_update_bits(codec, WM8960_APOP1, snd_soc_component_update_bits(component, WM8960_APOP1,
WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_POBCTRL | WM8960_SOFT_ST |
WM8960_BUFDCOPEN, WM8960_BUFDCOPEN,
WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_POBCTRL | WM8960_SOFT_ST |
...@@ -1184,7 +1184,7 @@ static int pll_factors(unsigned int source, unsigned int target, ...@@ -1184,7 +1184,7 @@ static int pll_factors(unsigned int source, unsigned int target,
return 0; return 0;
} }
static int wm8960_set_pll(struct snd_soc_codec *codec, static int wm8960_set_pll(struct snd_soc_component *component,
unsigned int freq_in, unsigned int freq_out) unsigned int freq_in, unsigned int freq_out)
{ {
u16 reg; u16 reg;
...@@ -1199,29 +1199,29 @@ static int wm8960_set_pll(struct snd_soc_codec *codec, ...@@ -1199,29 +1199,29 @@ static int wm8960_set_pll(struct snd_soc_codec *codec,
/* Disable the PLL: even if we are changing the frequency the /* Disable the PLL: even if we are changing the frequency the
* PLL needs to be disabled while we do so. */ * PLL needs to be disabled while we do so. */
snd_soc_update_bits(codec, WM8960_CLOCK1, 0x1, 0); snd_soc_component_update_bits(component, WM8960_CLOCK1, 0x1, 0);
snd_soc_update_bits(codec, WM8960_POWER2, 0x1, 0); snd_soc_component_update_bits(component, WM8960_POWER2, 0x1, 0);
if (!freq_in || !freq_out) if (!freq_in || !freq_out)
return 0; return 0;
reg = snd_soc_read(codec, WM8960_PLL1) & ~0x3f; reg = snd_soc_component_read32(component, WM8960_PLL1) & ~0x3f;
reg |= pll_div.pre_div << 4; reg |= pll_div.pre_div << 4;
reg |= pll_div.n; reg |= pll_div.n;
if (pll_div.k) { if (pll_div.k) {
reg |= 0x20; reg |= 0x20;
snd_soc_write(codec, WM8960_PLL2, (pll_div.k >> 16) & 0xff); snd_soc_component_write(component, WM8960_PLL2, (pll_div.k >> 16) & 0xff);
snd_soc_write(codec, WM8960_PLL3, (pll_div.k >> 8) & 0xff); snd_soc_component_write(component, WM8960_PLL3, (pll_div.k >> 8) & 0xff);
snd_soc_write(codec, WM8960_PLL4, pll_div.k & 0xff); snd_soc_component_write(component, WM8960_PLL4, pll_div.k & 0xff);
} }
snd_soc_write(codec, WM8960_PLL1, reg); snd_soc_component_write(component, WM8960_PLL1, reg);
/* Turn it on */ /* Turn it on */
snd_soc_update_bits(codec, WM8960_POWER2, 0x1, 0x1); snd_soc_component_update_bits(component, WM8960_POWER2, 0x1, 0x1);
msleep(250); msleep(250);
snd_soc_update_bits(codec, WM8960_CLOCK1, 0x1, 0x1); snd_soc_component_update_bits(component, WM8960_CLOCK1, 0x1, 0x1);
return 0; return 0;
} }
...@@ -1229,43 +1229,43 @@ static int wm8960_set_pll(struct snd_soc_codec *codec, ...@@ -1229,43 +1229,43 @@ static int wm8960_set_pll(struct snd_soc_codec *codec,
static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8960_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;
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
wm8960->freq_in = freq_in; wm8960->freq_in = freq_in;
if (pll_id == WM8960_SYSCLK_AUTO) if (pll_id == WM8960_SYSCLK_AUTO)
return 0; return 0;
return wm8960_set_pll(codec, freq_in, freq_out); return wm8960_set_pll(component, freq_in, freq_out);
} }
static int wm8960_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8960_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;
u16 reg; u16 reg;
switch (div_id) { switch (div_id) {
case WM8960_SYSCLKDIV: case WM8960_SYSCLKDIV:
reg = snd_soc_read(codec, WM8960_CLOCK1) & 0x1f9; reg = snd_soc_component_read32(component, WM8960_CLOCK1) & 0x1f9;
snd_soc_write(codec, WM8960_CLOCK1, reg | div); snd_soc_component_write(component, WM8960_CLOCK1, reg | div);
break; break;
case WM8960_DACDIV: case WM8960_DACDIV:
reg = snd_soc_read(codec, WM8960_CLOCK1) & 0x1c7; reg = snd_soc_component_read32(component, WM8960_CLOCK1) & 0x1c7;
snd_soc_write(codec, WM8960_CLOCK1, reg | div); snd_soc_component_write(component, WM8960_CLOCK1, reg | div);
break; break;
case WM8960_OPCLKDIV: case WM8960_OPCLKDIV:
reg = snd_soc_read(codec, WM8960_PLL1) & 0x03f; reg = snd_soc_component_read32(component, WM8960_PLL1) & 0x03f;
snd_soc_write(codec, WM8960_PLL1, reg | div); snd_soc_component_write(component, WM8960_PLL1, reg | div);
break; break;
case WM8960_DCLKDIV: case WM8960_DCLKDIV:
reg = snd_soc_read(codec, WM8960_CLOCK2) & 0x03f; reg = snd_soc_component_read32(component, WM8960_CLOCK2) & 0x03f;
snd_soc_write(codec, WM8960_CLOCK2, reg | div); snd_soc_component_write(component, WM8960_CLOCK2, reg | div);
break; break;
case WM8960_TOCLKSEL: case WM8960_TOCLKSEL:
reg = snd_soc_read(codec, WM8960_ADDCTL1) & 0x1fd; reg = snd_soc_component_read32(component, WM8960_ADDCTL1) & 0x1fd;
snd_soc_write(codec, WM8960_ADDCTL1, reg | div); snd_soc_component_write(component, WM8960_ADDCTL1, reg | div);
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -1274,27 +1274,27 @@ static int wm8960_set_dai_clkdiv(struct snd_soc_dai *codec_dai, ...@@ -1274,27 +1274,27 @@ static int wm8960_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
return 0; return 0;
} }
static int wm8960_set_bias_level(struct snd_soc_codec *codec, static int wm8960_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
return wm8960->set_bias_level(codec, level); return wm8960->set_bias_level(component, level);
} }
static int wm8960_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, static int wm8960_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
unsigned int freq, int dir) unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
switch (clk_id) { switch (clk_id) {
case WM8960_SYSCLK_MCLK: case WM8960_SYSCLK_MCLK:
snd_soc_update_bits(codec, WM8960_CLOCK1, snd_soc_component_update_bits(component, WM8960_CLOCK1,
0x1, WM8960_SYSCLK_MCLK); 0x1, WM8960_SYSCLK_MCLK);
break; break;
case WM8960_SYSCLK_PLL: case WM8960_SYSCLK_PLL:
snd_soc_update_bits(codec, WM8960_CLOCK1, snd_soc_component_update_bits(component, WM8960_CLOCK1,
0x1, WM8960_SYSCLK_PLL); 0x1, WM8960_SYSCLK_PLL);
break; break;
case WM8960_SYSCLK_AUTO: case WM8960_SYSCLK_AUTO:
...@@ -1343,9 +1343,9 @@ static struct snd_soc_dai_driver wm8960_dai = { ...@@ -1343,9 +1343,9 @@ static struct snd_soc_dai_driver wm8960_dai = {
.symmetric_rates = 1, .symmetric_rates = 1,
}; };
static int wm8960_probe(struct snd_soc_codec *codec) static int wm8960_probe(struct snd_soc_component *component)
{ {
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component);
struct wm8960_data *pdata = &wm8960->pdata; struct wm8960_data *pdata = &wm8960->pdata;
if (pdata->capless) if (pdata->capless)
...@@ -1353,17 +1353,21 @@ static int wm8960_probe(struct snd_soc_codec *codec) ...@@ -1353,17 +1353,21 @@ static int wm8960_probe(struct snd_soc_codec *codec)
else else
wm8960->set_bias_level = wm8960_set_bias_level_out3; wm8960->set_bias_level = wm8960_set_bias_level_out3;
snd_soc_add_codec_controls(codec, wm8960_snd_controls, snd_soc_add_component_controls(component, wm8960_snd_controls,
ARRAY_SIZE(wm8960_snd_controls)); ARRAY_SIZE(wm8960_snd_controls));
wm8960_add_widgets(codec); wm8960_add_widgets(component);
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm8960 = { static const struct snd_soc_component_driver soc_component_dev_wm8960 = {
.probe = wm8960_probe, .probe = wm8960_probe,
.set_bias_level = wm8960_set_bias_level, .set_bias_level = wm8960_set_bias_level,
.suspend_bias_off = true, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config wm8960_regmap = { static const struct regmap_config wm8960_regmap = {
...@@ -1447,15 +1451,14 @@ static int wm8960_i2c_probe(struct i2c_client *i2c, ...@@ -1447,15 +1451,14 @@ static int wm8960_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8960); i2c_set_clientdata(i2c, wm8960);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8960, &wm8960_dai, 1); &soc_component_dev_wm8960, &wm8960_dai, 1);
return ret; return ret;
} }
static int wm8960_i2c_remove(struct i2c_client *client) static int wm8960_i2c_remove(struct i2c_client *client)
{ {
snd_soc_unregister_codec(&client->dev);
return 0; return 0;
} }
......
...@@ -194,89 +194,89 @@ static bool wm8961_readable(struct device *dev, unsigned int reg) ...@@ -194,89 +194,89 @@ static bool wm8961_readable(struct device *dev, unsigned int reg)
static int wm8961_hp_event(struct snd_soc_dapm_widget *w, static int wm8961_hp_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);
u16 hp_reg = snd_soc_read(codec, WM8961_ANALOGUE_HP_0); u16 hp_reg = snd_soc_component_read32(component, WM8961_ANALOGUE_HP_0);
u16 cp_reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_1); u16 cp_reg = snd_soc_component_read32(component, WM8961_CHARGE_PUMP_1);
u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2); u16 pwr_reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_2);
u16 dcs_reg = snd_soc_read(codec, WM8961_DC_SERVO_1); u16 dcs_reg = snd_soc_component_read32(component, WM8961_DC_SERVO_1);
int timeout = 500; int timeout = 500;
if (event & SND_SOC_DAPM_POST_PMU) { if (event & SND_SOC_DAPM_POST_PMU) {
/* Make sure the output is shorted */ /* Make sure the output is shorted */
hp_reg &= ~(WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT); hp_reg &= ~(WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT);
snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Enable the charge pump */ /* Enable the charge pump */
cp_reg |= WM8961_CP_ENA; cp_reg |= WM8961_CP_ENA;
snd_soc_write(codec, WM8961_CHARGE_PUMP_1, cp_reg); snd_soc_component_write(component, WM8961_CHARGE_PUMP_1, cp_reg);
mdelay(5); mdelay(5);
/* Enable the PGA */ /* Enable the PGA */
pwr_reg |= WM8961_LOUT1_PGA | WM8961_ROUT1_PGA; pwr_reg |= WM8961_LOUT1_PGA | WM8961_ROUT1_PGA;
snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg);
/* Enable the amplifier */ /* Enable the amplifier */
hp_reg |= WM8961_HPR_ENA | WM8961_HPL_ENA; hp_reg |= WM8961_HPR_ENA | WM8961_HPL_ENA;
snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Second stage enable */ /* Second stage enable */
hp_reg |= WM8961_HPR_ENA_DLY | WM8961_HPL_ENA_DLY; hp_reg |= WM8961_HPR_ENA_DLY | WM8961_HPL_ENA_DLY;
snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Enable the DC servo & trigger startup */ /* Enable the DC servo & trigger startup */
dcs_reg |= dcs_reg |=
WM8961_DCS_ENA_CHAN_HPR | WM8961_DCS_TRIG_STARTUP_HPR | WM8961_DCS_ENA_CHAN_HPR | WM8961_DCS_TRIG_STARTUP_HPR |
WM8961_DCS_ENA_CHAN_HPL | WM8961_DCS_TRIG_STARTUP_HPL; WM8961_DCS_ENA_CHAN_HPL | WM8961_DCS_TRIG_STARTUP_HPL;
dev_dbg(codec->dev, "Enabling DC servo\n"); dev_dbg(component->dev, "Enabling DC servo\n");
snd_soc_write(codec, WM8961_DC_SERVO_1, dcs_reg); snd_soc_component_write(component, WM8961_DC_SERVO_1, dcs_reg);
do { do {
msleep(1); msleep(1);
dcs_reg = snd_soc_read(codec, WM8961_DC_SERVO_1); dcs_reg = snd_soc_component_read32(component, WM8961_DC_SERVO_1);
} while (--timeout && } while (--timeout &&
dcs_reg & (WM8961_DCS_TRIG_STARTUP_HPR | dcs_reg & (WM8961_DCS_TRIG_STARTUP_HPR |
WM8961_DCS_TRIG_STARTUP_HPL)); WM8961_DCS_TRIG_STARTUP_HPL));
if (dcs_reg & (WM8961_DCS_TRIG_STARTUP_HPR | if (dcs_reg & (WM8961_DCS_TRIG_STARTUP_HPR |
WM8961_DCS_TRIG_STARTUP_HPL)) WM8961_DCS_TRIG_STARTUP_HPL))
dev_err(codec->dev, "DC servo timed out\n"); dev_err(component->dev, "DC servo timed out\n");
else else
dev_dbg(codec->dev, "DC servo startup complete\n"); dev_dbg(component->dev, "DC servo startup complete\n");
/* Enable the output stage */ /* Enable the output stage */
hp_reg |= WM8961_HPR_ENA_OUTP | WM8961_HPL_ENA_OUTP; hp_reg |= WM8961_HPR_ENA_OUTP | WM8961_HPL_ENA_OUTP;
snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Remove the short on the output stage */ /* Remove the short on the output stage */
hp_reg |= WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT; hp_reg |= WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT;
snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
} }
if (event & SND_SOC_DAPM_PRE_PMD) { if (event & SND_SOC_DAPM_PRE_PMD) {
/* Short the output */ /* Short the output */
hp_reg &= ~(WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT); hp_reg &= ~(WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT);
snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Disable the output stage */ /* Disable the output stage */
hp_reg &= ~(WM8961_HPR_ENA_OUTP | WM8961_HPL_ENA_OUTP); hp_reg &= ~(WM8961_HPR_ENA_OUTP | WM8961_HPL_ENA_OUTP);
snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Disable DC offset cancellation */ /* Disable DC offset cancellation */
dcs_reg &= ~(WM8961_DCS_ENA_CHAN_HPR | dcs_reg &= ~(WM8961_DCS_ENA_CHAN_HPR |
WM8961_DCS_ENA_CHAN_HPL); WM8961_DCS_ENA_CHAN_HPL);
snd_soc_write(codec, WM8961_DC_SERVO_1, dcs_reg); snd_soc_component_write(component, WM8961_DC_SERVO_1, dcs_reg);
/* Finish up */ /* Finish up */
hp_reg &= ~(WM8961_HPR_ENA_DLY | WM8961_HPR_ENA | hp_reg &= ~(WM8961_HPR_ENA_DLY | WM8961_HPR_ENA |
WM8961_HPL_ENA_DLY | WM8961_HPL_ENA); WM8961_HPL_ENA_DLY | WM8961_HPL_ENA);
snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Disable the PGA */ /* Disable the PGA */
pwr_reg &= ~(WM8961_LOUT1_PGA | WM8961_ROUT1_PGA); pwr_reg &= ~(WM8961_LOUT1_PGA | WM8961_ROUT1_PGA);
snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg);
/* Disable the charge pump */ /* Disable the charge pump */
dev_dbg(codec->dev, "Disabling charge pump\n"); dev_dbg(component->dev, "Disabling charge pump\n");
snd_soc_write(codec, WM8961_CHARGE_PUMP_1, snd_soc_component_write(component, WM8961_CHARGE_PUMP_1,
cp_reg & ~WM8961_CP_ENA); cp_reg & ~WM8961_CP_ENA);
} }
...@@ -286,28 +286,28 @@ static int wm8961_hp_event(struct snd_soc_dapm_widget *w, ...@@ -286,28 +286,28 @@ static int wm8961_hp_event(struct snd_soc_dapm_widget *w,
static int wm8961_spk_event(struct snd_soc_dapm_widget *w, static int wm8961_spk_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);
u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2); u16 pwr_reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_2);
u16 spk_reg = snd_soc_read(codec, WM8961_CLASS_D_CONTROL_1); u16 spk_reg = snd_soc_component_read32(component, WM8961_CLASS_D_CONTROL_1);
if (event & SND_SOC_DAPM_POST_PMU) { if (event & SND_SOC_DAPM_POST_PMU) {
/* Enable the PGA */ /* Enable the PGA */
pwr_reg |= WM8961_SPKL_PGA | WM8961_SPKR_PGA; pwr_reg |= WM8961_SPKL_PGA | WM8961_SPKR_PGA;
snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg);
/* Enable the amplifier */ /* Enable the amplifier */
spk_reg |= WM8961_SPKL_ENA | WM8961_SPKR_ENA; spk_reg |= WM8961_SPKL_ENA | WM8961_SPKR_ENA;
snd_soc_write(codec, WM8961_CLASS_D_CONTROL_1, spk_reg); snd_soc_component_write(component, WM8961_CLASS_D_CONTROL_1, spk_reg);
} }
if (event & SND_SOC_DAPM_PRE_PMD) { if (event & SND_SOC_DAPM_PRE_PMD) {
/* Disable the amplifier */ /* Disable the amplifier */
spk_reg &= ~(WM8961_SPKL_ENA | WM8961_SPKR_ENA); spk_reg &= ~(WM8961_SPKL_ENA | WM8961_SPKR_ENA);
snd_soc_write(codec, WM8961_CLASS_D_CONTROL_1, spk_reg); snd_soc_component_write(component, WM8961_CLASS_D_CONTROL_1, spk_reg);
/* Disable the PGA */ /* Disable the PGA */
pwr_reg &= ~(WM8961_SPKL_PGA | WM8961_SPKR_PGA); pwr_reg &= ~(WM8961_SPKL_PGA | WM8961_SPKR_PGA);
snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg);
} }
return 0; return 0;
...@@ -505,15 +505,15 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, ...@@ -505,15 +505,15 @@ static int wm8961_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;
struct wm8961_priv *wm8961 = snd_soc_codec_get_drvdata(codec); struct wm8961_priv *wm8961 = snd_soc_component_get_drvdata(component);
int i, best, target, fs; int i, best, target, fs;
u16 reg; u16 reg;
fs = params_rate(params); fs = params_rate(params);
if (!wm8961->sysclk) { if (!wm8961->sysclk) {
dev_err(codec->dev, "MCLK has not been specified\n"); dev_err(component->dev, "MCLK has not been specified\n");
return -EINVAL; return -EINVAL;
} }
...@@ -524,23 +524,23 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, ...@@ -524,23 +524,23 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream,
abs(wm8961_srate[best].rate - fs)) abs(wm8961_srate[best].rate - fs))
best = i; best = i;
} }
reg = snd_soc_read(codec, WM8961_ADDITIONAL_CONTROL_3); reg = snd_soc_component_read32(component, WM8961_ADDITIONAL_CONTROL_3);
reg &= ~WM8961_SAMPLE_RATE_MASK; reg &= ~WM8961_SAMPLE_RATE_MASK;
reg |= wm8961_srate[best].val; reg |= wm8961_srate[best].val;
snd_soc_write(codec, WM8961_ADDITIONAL_CONTROL_3, reg); snd_soc_component_write(component, WM8961_ADDITIONAL_CONTROL_3, reg);
dev_dbg(codec->dev, "Selected SRATE %dHz for %dHz\n", dev_dbg(component->dev, "Selected SRATE %dHz for %dHz\n",
wm8961_srate[best].rate, fs); wm8961_srate[best].rate, fs);
/* Select a CLK_SYS/fs ratio equal to or higher than required */ /* Select a CLK_SYS/fs ratio equal to or higher than required */
target = wm8961->sysclk / fs; target = wm8961->sysclk / fs;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && target < 64) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && target < 64) {
dev_err(codec->dev, dev_err(component->dev,
"SYSCLK must be at least 64*fs for DAC\n"); "SYSCLK must be at least 64*fs for DAC\n");
return -EINVAL; return -EINVAL;
} }
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && target < 256) { if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && target < 256) {
dev_err(codec->dev, dev_err(component->dev,
"SYSCLK must be at least 256*fs for ADC\n"); "SYSCLK must be at least 256*fs for ADC\n");
return -EINVAL; return -EINVAL;
} }
...@@ -550,19 +550,19 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, ...@@ -550,19 +550,19 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream,
break; break;
} }
if (i == ARRAY_SIZE(wm8961_clk_sys_ratio)) { if (i == ARRAY_SIZE(wm8961_clk_sys_ratio)) {
dev_err(codec->dev, "Unable to generate CLK_SYS_RATE\n"); dev_err(component->dev, "Unable to generate CLK_SYS_RATE\n");
return -EINVAL; return -EINVAL;
} }
dev_dbg(codec->dev, "Selected CLK_SYS_RATE of %d for %d/%d=%d\n", dev_dbg(component->dev, "Selected CLK_SYS_RATE of %d for %d/%d=%d\n",
wm8961_clk_sys_ratio[i].ratio, wm8961->sysclk, fs, wm8961_clk_sys_ratio[i].ratio, wm8961->sysclk, fs,
wm8961->sysclk / fs); wm8961->sysclk / fs);
reg = snd_soc_read(codec, WM8961_CLOCKING_4); reg = snd_soc_component_read32(component, WM8961_CLOCKING_4);
reg &= ~WM8961_CLK_SYS_RATE_MASK; reg &= ~WM8961_CLK_SYS_RATE_MASK;
reg |= wm8961_clk_sys_ratio[i].val << WM8961_CLK_SYS_RATE_SHIFT; reg |= wm8961_clk_sys_ratio[i].val << WM8961_CLK_SYS_RATE_SHIFT;
snd_soc_write(codec, WM8961_CLOCKING_4, reg); snd_soc_component_write(component, WM8961_CLOCKING_4, reg);
reg = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_0); reg = snd_soc_component_read32(component, WM8961_AUDIO_INTERFACE_0);
reg &= ~WM8961_WL_MASK; reg &= ~WM8961_WL_MASK;
switch (params_width(params)) { switch (params_width(params)) {
case 16: case 16:
...@@ -579,15 +579,15 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, ...@@ -579,15 +579,15 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream,
default: default:
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, WM8961_AUDIO_INTERFACE_0, reg); snd_soc_component_write(component, WM8961_AUDIO_INTERFACE_0, reg);
/* Sloping stop-band filter is recommended for <= 24kHz */ /* Sloping stop-band filter is recommended for <= 24kHz */
reg = snd_soc_read(codec, WM8961_ADC_DAC_CONTROL_2); reg = snd_soc_component_read32(component, WM8961_ADC_DAC_CONTROL_2);
if (fs <= 24000) if (fs <= 24000)
reg |= WM8961_DACSLOPE; reg |= WM8961_DACSLOPE;
else else
reg &= ~WM8961_DACSLOPE; reg &= ~WM8961_DACSLOPE;
snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_2, reg); snd_soc_component_write(component, WM8961_ADC_DAC_CONTROL_2, reg);
return 0; return 0;
} }
...@@ -596,25 +596,25 @@ static int wm8961_set_sysclk(struct snd_soc_dai *dai, int clk_id, ...@@ -596,25 +596,25 @@ static int wm8961_set_sysclk(struct snd_soc_dai *dai, int clk_id,
unsigned int freq, unsigned int freq,
int dir) int dir)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm8961_priv *wm8961 = snd_soc_codec_get_drvdata(codec); struct wm8961_priv *wm8961 = snd_soc_component_get_drvdata(component);
u16 reg = snd_soc_read(codec, WM8961_CLOCKING1); u16 reg = snd_soc_component_read32(component, WM8961_CLOCKING1);
if (freq > 33000000) { if (freq > 33000000) {
dev_err(codec->dev, "MCLK must be <33MHz\n"); dev_err(component->dev, "MCLK must be <33MHz\n");
return -EINVAL; return -EINVAL;
} }
if (freq > 16500000) { if (freq > 16500000) {
dev_dbg(codec->dev, "Using MCLK/2 for %dHz MCLK\n", freq); dev_dbg(component->dev, "Using MCLK/2 for %dHz MCLK\n", freq);
reg |= WM8961_MCLKDIV; reg |= WM8961_MCLKDIV;
freq /= 2; freq /= 2;
} else { } else {
dev_dbg(codec->dev, "Using MCLK/1 for %dHz MCLK\n", freq); dev_dbg(component->dev, "Using MCLK/1 for %dHz MCLK\n", freq);
reg &= ~WM8961_MCLKDIV; reg &= ~WM8961_MCLKDIV;
} }
snd_soc_write(codec, WM8961_CLOCKING1, reg); snd_soc_component_write(component, WM8961_CLOCKING1, reg);
wm8961->sysclk = freq; wm8961->sysclk = freq;
...@@ -623,8 +623,8 @@ static int wm8961_set_sysclk(struct snd_soc_dai *dai, int clk_id, ...@@ -623,8 +623,8 @@ static int wm8961_set_sysclk(struct snd_soc_dai *dai, int clk_id,
static int wm8961_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int wm8961_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u16 aif = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_0); u16 aif = snd_soc_component_read32(component, WM8961_AUDIO_INTERFACE_0);
aif &= ~(WM8961_BCLKINV | WM8961_LRP | aif &= ~(WM8961_BCLKINV | WM8961_LRP |
WM8961_MS | WM8961_FORMAT_MASK); WM8961_MS | WM8961_FORMAT_MASK);
...@@ -684,26 +684,26 @@ static int wm8961_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -684,26 +684,26 @@ static int wm8961_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
return -EINVAL; return -EINVAL;
} }
return snd_soc_write(codec, WM8961_AUDIO_INTERFACE_0, aif); return snd_soc_component_write(component, WM8961_AUDIO_INTERFACE_0, aif);
} }
static int wm8961_set_tristate(struct snd_soc_dai *dai, int tristate) static int wm8961_set_tristate(struct snd_soc_dai *dai, int tristate)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u16 reg = snd_soc_read(codec, WM8961_ADDITIONAL_CONTROL_2); u16 reg = snd_soc_component_read32(component, WM8961_ADDITIONAL_CONTROL_2);
if (tristate) if (tristate)
reg |= WM8961_TRIS; reg |= WM8961_TRIS;
else else
reg &= ~WM8961_TRIS; reg &= ~WM8961_TRIS;
return snd_soc_write(codec, WM8961_ADDITIONAL_CONTROL_2, reg); return snd_soc_component_write(component, WM8961_ADDITIONAL_CONTROL_2, reg);
} }
static int wm8961_digital_mute(struct snd_soc_dai *dai, int mute) static int wm8961_digital_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u16 reg = snd_soc_read(codec, WM8961_ADC_DAC_CONTROL_1); u16 reg = snd_soc_component_read32(component, WM8961_ADC_DAC_CONTROL_1);
if (mute) if (mute)
reg |= WM8961_DACMU; reg |= WM8961_DACMU;
...@@ -712,27 +712,27 @@ static int wm8961_digital_mute(struct snd_soc_dai *dai, int mute) ...@@ -712,27 +712,27 @@ static int wm8961_digital_mute(struct snd_soc_dai *dai, int mute)
msleep(17); msleep(17);
return snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_1, reg); return snd_soc_component_write(component, WM8961_ADC_DAC_CONTROL_1, reg);
} }
static int wm8961_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) static int wm8961_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u16 reg; u16 reg;
switch (div_id) { switch (div_id) {
case WM8961_BCLK: case WM8961_BCLK:
reg = snd_soc_read(codec, WM8961_CLOCKING2); reg = snd_soc_component_read32(component, WM8961_CLOCKING2);
reg &= ~WM8961_BCLKDIV_MASK; reg &= ~WM8961_BCLKDIV_MASK;
reg |= div; reg |= div;
snd_soc_write(codec, WM8961_CLOCKING2, reg); snd_soc_component_write(component, WM8961_CLOCKING2, reg);
break; break;
case WM8961_LRCLK: case WM8961_LRCLK:
reg = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_2); reg = snd_soc_component_read32(component, WM8961_AUDIO_INTERFACE_2);
reg &= ~WM8961_LRCLK_RATE_MASK; reg &= ~WM8961_LRCLK_RATE_MASK;
reg |= div; reg |= div;
snd_soc_write(codec, WM8961_AUDIO_INTERFACE_2, reg); snd_soc_component_write(component, WM8961_AUDIO_INTERFACE_2, reg);
break; break;
default: default:
...@@ -742,7 +742,7 @@ static int wm8961_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) ...@@ -742,7 +742,7 @@ static int wm8961_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
return 0; return 0;
} }
static int wm8961_set_bias_level(struct snd_soc_codec *codec, static int wm8961_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
u16 reg; u16 reg;
...@@ -757,36 +757,36 @@ static int wm8961_set_bias_level(struct snd_soc_codec *codec, ...@@ -757,36 +757,36 @@ static int wm8961_set_bias_level(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) {
/* Enable bias generation */ /* Enable bias generation */
reg = snd_soc_read(codec, WM8961_ANTI_POP); reg = snd_soc_component_read32(component, WM8961_ANTI_POP);
reg |= WM8961_BUFIOEN | WM8961_BUFDCOPEN; reg |= WM8961_BUFIOEN | WM8961_BUFDCOPEN;
snd_soc_write(codec, WM8961_ANTI_POP, reg); snd_soc_component_write(component, WM8961_ANTI_POP, reg);
/* VMID=2*50k, VREF */ /* VMID=2*50k, VREF */
reg = snd_soc_read(codec, WM8961_PWR_MGMT_1); reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_1);
reg &= ~WM8961_VMIDSEL_MASK; reg &= ~WM8961_VMIDSEL_MASK;
reg |= (1 << WM8961_VMIDSEL_SHIFT) | WM8961_VREF; reg |= (1 << WM8961_VMIDSEL_SHIFT) | WM8961_VREF;
snd_soc_write(codec, WM8961_PWR_MGMT_1, reg); snd_soc_component_write(component, WM8961_PWR_MGMT_1, reg);
} }
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) {
/* VREF off */ /* VREF off */
reg = snd_soc_read(codec, WM8961_PWR_MGMT_1); reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_1);
reg &= ~WM8961_VREF; reg &= ~WM8961_VREF;
snd_soc_write(codec, WM8961_PWR_MGMT_1, reg); snd_soc_component_write(component, WM8961_PWR_MGMT_1, reg);
/* Bias generation off */ /* Bias generation off */
reg = snd_soc_read(codec, WM8961_ANTI_POP); reg = snd_soc_component_read32(component, WM8961_ANTI_POP);
reg &= ~(WM8961_BUFIOEN | WM8961_BUFDCOPEN); reg &= ~(WM8961_BUFIOEN | WM8961_BUFDCOPEN);
snd_soc_write(codec, WM8961_ANTI_POP, reg); snd_soc_component_write(component, WM8961_ANTI_POP, reg);
/* VMID off */ /* VMID off */
reg = snd_soc_read(codec, WM8961_PWR_MGMT_1); reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_1);
reg &= ~WM8961_VMIDSEL_MASK; reg &= ~WM8961_VMIDSEL_MASK;
snd_soc_write(codec, WM8961_PWR_MGMT_1, reg); snd_soc_component_write(component, WM8961_PWR_MGMT_1, reg);
} }
break; break;
...@@ -830,51 +830,51 @@ static struct snd_soc_dai_driver wm8961_dai = { ...@@ -830,51 +830,51 @@ static struct snd_soc_dai_driver wm8961_dai = {
.ops = &wm8961_dai_ops, .ops = &wm8961_dai_ops,
}; };
static int wm8961_probe(struct snd_soc_codec *codec) static int wm8961_probe(struct snd_soc_component *component)
{ {
u16 reg; u16 reg;
/* Enable class W */ /* Enable class W */
reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_B); reg = snd_soc_component_read32(component, WM8961_CHARGE_PUMP_B);
reg |= WM8961_CP_DYN_PWR_MASK; reg |= WM8961_CP_DYN_PWR_MASK;
snd_soc_write(codec, WM8961_CHARGE_PUMP_B, reg); snd_soc_component_write(component, WM8961_CHARGE_PUMP_B, reg);
/* Latch volume update bits (right channel only, we always /* Latch volume update bits (right channel only, we always
* write both out) and default ZC on. */ * write both out) and default ZC on. */
reg = snd_soc_read(codec, WM8961_ROUT1_VOLUME); reg = snd_soc_component_read32(component, WM8961_ROUT1_VOLUME);
snd_soc_write(codec, WM8961_ROUT1_VOLUME, snd_soc_component_write(component, WM8961_ROUT1_VOLUME,
reg | WM8961_LO1ZC | WM8961_OUT1VU); reg | WM8961_LO1ZC | WM8961_OUT1VU);
snd_soc_write(codec, WM8961_LOUT1_VOLUME, reg | WM8961_LO1ZC); snd_soc_component_write(component, WM8961_LOUT1_VOLUME, reg | WM8961_LO1ZC);
reg = snd_soc_read(codec, WM8961_ROUT2_VOLUME); reg = snd_soc_component_read32(component, WM8961_ROUT2_VOLUME);
snd_soc_write(codec, WM8961_ROUT2_VOLUME, snd_soc_component_write(component, WM8961_ROUT2_VOLUME,
reg | WM8961_SPKRZC | WM8961_SPKVU); reg | WM8961_SPKRZC | WM8961_SPKVU);
snd_soc_write(codec, WM8961_LOUT2_VOLUME, reg | WM8961_SPKLZC); snd_soc_component_write(component, WM8961_LOUT2_VOLUME, reg | WM8961_SPKLZC);
reg = snd_soc_read(codec, WM8961_RIGHT_ADC_VOLUME); reg = snd_soc_component_read32(component, WM8961_RIGHT_ADC_VOLUME);
snd_soc_write(codec, WM8961_RIGHT_ADC_VOLUME, reg | WM8961_ADCVU); snd_soc_component_write(component, WM8961_RIGHT_ADC_VOLUME, reg | WM8961_ADCVU);
reg = snd_soc_read(codec, WM8961_RIGHT_INPUT_VOLUME); reg = snd_soc_component_read32(component, WM8961_RIGHT_INPUT_VOLUME);
snd_soc_write(codec, WM8961_RIGHT_INPUT_VOLUME, reg | WM8961_IPVU); snd_soc_component_write(component, WM8961_RIGHT_INPUT_VOLUME, reg | WM8961_IPVU);
/* Use soft mute by default */ /* Use soft mute by default */
reg = snd_soc_read(codec, WM8961_ADC_DAC_CONTROL_2); reg = snd_soc_component_read32(component, WM8961_ADC_DAC_CONTROL_2);
reg |= WM8961_DACSMM; reg |= WM8961_DACSMM;
snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_2, reg); snd_soc_component_write(component, WM8961_ADC_DAC_CONTROL_2, reg);
/* Use automatic clocking mode by default; for now this is all /* Use automatic clocking mode by default; for now this is all
* we support. * we support.
*/ */
reg = snd_soc_read(codec, WM8961_CLOCKING_3); reg = snd_soc_component_read32(component, WM8961_CLOCKING_3);
reg &= ~WM8961_MANUAL_MODE; reg &= ~WM8961_MANUAL_MODE;
snd_soc_write(codec, WM8961_CLOCKING_3, reg); snd_soc_component_write(component, WM8961_CLOCKING_3, reg);
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int wm8961_resume(struct snd_soc_codec *codec) static int wm8961_resume(struct snd_soc_component *component)
{ {
snd_soc_cache_sync(codec); snd_soc_component_cache_sync(component);
return 0; return 0;
} }
...@@ -882,20 +882,21 @@ static int wm8961_resume(struct snd_soc_codec *codec) ...@@ -882,20 +882,21 @@ static int wm8961_resume(struct snd_soc_codec *codec)
#define wm8961_resume NULL #define wm8961_resume NULL
#endif #endif
static const struct snd_soc_codec_driver soc_codec_dev_wm8961 = { static const struct snd_soc_component_driver soc_component_dev_wm8961 = {
.probe = wm8961_probe, .probe = wm8961_probe,
.resume = wm8961_resume, .resume = wm8961_resume,
.set_bias_level = wm8961_set_bias_level, .set_bias_level = wm8961_set_bias_level,
.suspend_bias_off = true,
.component_driver = {
.controls = wm8961_snd_controls, .controls = wm8961_snd_controls,
.num_controls = ARRAY_SIZE(wm8961_snd_controls), .num_controls = ARRAY_SIZE(wm8961_snd_controls),
.dapm_widgets = wm8961_dapm_widgets, .dapm_widgets = wm8961_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(wm8961_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(wm8961_dapm_widgets),
.dapm_routes = audio_paths, .dapm_routes = audio_paths,
.num_dapm_routes = ARRAY_SIZE(audio_paths), .num_dapm_routes = ARRAY_SIZE(audio_paths),
}, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config wm8961_regmap = { static const struct regmap_config wm8961_regmap = {
...@@ -961,19 +962,12 @@ static int wm8961_i2c_probe(struct i2c_client *i2c, ...@@ -961,19 +962,12 @@ static int wm8961_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8961); i2c_set_clientdata(i2c, wm8961);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8961, &wm8961_dai, 1); &soc_component_dev_wm8961, &wm8961_dai, 1);
return ret; return ret;
} }
static int wm8961_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id wm8961_i2c_id[] = { static const struct i2c_device_id wm8961_i2c_id[] = {
{ "wm8961", 0 }, { "wm8961", 0 },
{ } { }
...@@ -985,7 +979,6 @@ static struct i2c_driver wm8961_i2c_driver = { ...@@ -985,7 +979,6 @@ static struct i2c_driver wm8961_i2c_driver = {
.name = "wm8961", .name = "wm8961",
}, },
.probe = wm8961_i2c_probe, .probe = wm8961_i2c_probe,
.remove = wm8961_i2c_remove,
.id_table = wm8961_i2c_id, .id_table = wm8961_i2c_id,
}; };
......
...@@ -55,7 +55,7 @@ static const char *wm8962_supply_names[WM8962_NUM_SUPPLIES] = { ...@@ -55,7 +55,7 @@ static const char *wm8962_supply_names[WM8962_NUM_SUPPLIES] = {
struct wm8962_priv { struct wm8962_priv {
struct wm8962_pdata pdata; struct wm8962_pdata pdata;
struct regmap *regmap; struct regmap *regmap;
struct snd_soc_codec *codec; struct snd_soc_component *component;
int sysclk; int sysclk;
int sysclk_rate; int sysclk_rate;
...@@ -1475,55 +1475,55 @@ static const DECLARE_TLV_DB_RANGE(classd_tlv, ...@@ -1475,55 +1475,55 @@ static const DECLARE_TLV_DB_RANGE(classd_tlv,
); );
static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
static int wm8962_dsp2_write_config(struct snd_soc_codec *codec) static int wm8962_dsp2_write_config(struct snd_soc_component *component)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
return regcache_sync_region(wm8962->regmap, return regcache_sync_region(wm8962->regmap,
WM8962_HDBASS_AI_1, WM8962_MAX_REGISTER); WM8962_HDBASS_AI_1, WM8962_MAX_REGISTER);
} }
static int wm8962_dsp2_set_enable(struct snd_soc_codec *codec, u16 val) static int wm8962_dsp2_set_enable(struct snd_soc_component *component, u16 val)
{ {
u16 adcl = snd_soc_read(codec, WM8962_LEFT_ADC_VOLUME); u16 adcl = snd_soc_component_read32(component, WM8962_LEFT_ADC_VOLUME);
u16 adcr = snd_soc_read(codec, WM8962_RIGHT_ADC_VOLUME); u16 adcr = snd_soc_component_read32(component, WM8962_RIGHT_ADC_VOLUME);
u16 dac = snd_soc_read(codec, WM8962_ADC_DAC_CONTROL_1); u16 dac = snd_soc_component_read32(component, WM8962_ADC_DAC_CONTROL_1);
/* Mute the ADCs and DACs */ /* Mute the ADCs and DACs */
snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, 0); snd_soc_component_write(component, WM8962_LEFT_ADC_VOLUME, 0);
snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, WM8962_ADC_VU); snd_soc_component_write(component, WM8962_RIGHT_ADC_VOLUME, WM8962_ADC_VU);
snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1,
WM8962_DAC_MUTE, WM8962_DAC_MUTE); WM8962_DAC_MUTE, WM8962_DAC_MUTE);
snd_soc_write(codec, WM8962_SOUNDSTAGE_ENABLES_0, val); snd_soc_component_write(component, WM8962_SOUNDSTAGE_ENABLES_0, val);
/* Restore the ADCs and DACs */ /* Restore the ADCs and DACs */
snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, adcl); snd_soc_component_write(component, WM8962_LEFT_ADC_VOLUME, adcl);
snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, adcr); snd_soc_component_write(component, WM8962_RIGHT_ADC_VOLUME, adcr);
snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1,
WM8962_DAC_MUTE, dac); WM8962_DAC_MUTE, dac);
return 0; return 0;
} }
static int wm8962_dsp2_start(struct snd_soc_codec *codec) static int wm8962_dsp2_start(struct snd_soc_component *component)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
wm8962_dsp2_write_config(codec); wm8962_dsp2_write_config(component);
snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_RUNR); snd_soc_component_write(component, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_RUNR);
wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena); wm8962_dsp2_set_enable(component, wm8962->dsp2_ena);
return 0; return 0;
} }
static int wm8962_dsp2_stop(struct snd_soc_codec *codec) static int wm8962_dsp2_stop(struct snd_soc_component *component)
{ {
wm8962_dsp2_set_enable(codec, 0); wm8962_dsp2_set_enable(component, 0);
snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_STOP); snd_soc_component_write(component, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_STOP);
return 0; return 0;
} }
...@@ -1550,8 +1550,8 @@ static int wm8962_dsp2_ena_get(struct snd_kcontrol *kcontrol, ...@@ -1550,8 +1550,8 @@ static int wm8962_dsp2_ena_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int shift = kcontrol->private_value; int shift = kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift); ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift);
...@@ -1562,11 +1562,11 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol, ...@@ -1562,11 +1562,11 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int shift = kcontrol->private_value; int shift = kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
int old = wm8962->dsp2_ena; int old = wm8962->dsp2_ena;
int ret = 0; int ret = 0;
int dsp2_running = snd_soc_read(codec, WM8962_DSP2_POWER_MANAGEMENT) & int dsp2_running = snd_soc_component_read32(component, WM8962_DSP2_POWER_MANAGEMENT) &
WM8962_DSP2_ENA; WM8962_DSP2_ENA;
mutex_lock(&wm8962->dsp2_ena_lock); mutex_lock(&wm8962->dsp2_ena_lock);
...@@ -1583,9 +1583,9 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol, ...@@ -1583,9 +1583,9 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol,
if (dsp2_running) { if (dsp2_running) {
if (wm8962->dsp2_ena) if (wm8962->dsp2_ena)
wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena); wm8962_dsp2_set_enable(component, wm8962->dsp2_ena);
else else
wm8962_dsp2_stop(codec); wm8962_dsp2_stop(component);
} }
out: out:
...@@ -1600,7 +1600,7 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol, ...@@ -1600,7 +1600,7 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol,
static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, static int wm8962_put_hp_sw(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);
int ret; int ret;
/* Apply the update (if any) */ /* Apply the update (if any) */
...@@ -1609,17 +1609,17 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, ...@@ -1609,17 +1609,17 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol,
return 0; return 0;
/* If the left PGA is enabled hit that VU bit... */ /* If the left PGA is enabled hit that VU bit... */
ret = snd_soc_read(codec, WM8962_PWR_MGMT_2); ret = snd_soc_component_read32(component, WM8962_PWR_MGMT_2);
if (ret & WM8962_HPOUTL_PGA_ENA) { if (ret & WM8962_HPOUTL_PGA_ENA) {
snd_soc_write(codec, WM8962_HPOUTL_VOLUME, snd_soc_component_write(component, WM8962_HPOUTL_VOLUME,
snd_soc_read(codec, WM8962_HPOUTL_VOLUME)); snd_soc_component_read32(component, WM8962_HPOUTL_VOLUME));
return 1; return 1;
} }
/* ...otherwise the right. The VU is stereo. */ /* ...otherwise the right. The VU is stereo. */
if (ret & WM8962_HPOUTR_PGA_ENA) if (ret & WM8962_HPOUTR_PGA_ENA)
snd_soc_write(codec, WM8962_HPOUTR_VOLUME, snd_soc_component_write(component, WM8962_HPOUTR_VOLUME,
snd_soc_read(codec, WM8962_HPOUTR_VOLUME)); snd_soc_component_read32(component, WM8962_HPOUTR_VOLUME));
return 1; return 1;
} }
...@@ -1630,7 +1630,7 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, ...@@ -1630,7 +1630,7 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol,
static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol, static int wm8962_put_spk_sw(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);
int ret; int ret;
/* Apply the update (if any) */ /* Apply the update (if any) */
...@@ -1639,17 +1639,17 @@ static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol, ...@@ -1639,17 +1639,17 @@ static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol,
return 0; return 0;
/* If the left PGA is enabled hit that VU bit... */ /* If the left PGA is enabled hit that VU bit... */
ret = snd_soc_read(codec, WM8962_PWR_MGMT_2); ret = snd_soc_component_read32(component, WM8962_PWR_MGMT_2);
if (ret & WM8962_SPKOUTL_PGA_ENA) { if (ret & WM8962_SPKOUTL_PGA_ENA) {
snd_soc_write(codec, WM8962_SPKOUTL_VOLUME, snd_soc_component_write(component, WM8962_SPKOUTL_VOLUME,
snd_soc_read(codec, WM8962_SPKOUTL_VOLUME)); snd_soc_component_read32(component, WM8962_SPKOUTL_VOLUME));
return 1; return 1;
} }
/* ...otherwise the right. The VU is stereo. */ /* ...otherwise the right. The VU is stereo. */
if (ret & WM8962_SPKOUTR_PGA_ENA) if (ret & WM8962_SPKOUTR_PGA_ENA)
snd_soc_write(codec, WM8962_SPKOUTR_VOLUME, snd_soc_component_write(component, WM8962_SPKOUTR_VOLUME,
snd_soc_read(codec, WM8962_SPKOUTR_VOLUME)); snd_soc_component_read32(component, WM8962_SPKOUTR_VOLUME));
return 1; return 1;
} }
...@@ -1863,7 +1863,7 @@ static int cp_event(struct snd_soc_dapm_widget *w, ...@@ -1863,7 +1863,7 @@ static int cp_event(struct snd_soc_dapm_widget *w,
static int hp_event(struct snd_soc_dapm_widget *w, static int hp_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);
int timeout; int timeout;
int reg; int reg;
int expected = (WM8962_DCS_STARTUP_DONE_HP1L | int expected = (WM8962_DCS_STARTUP_DONE_HP1L |
...@@ -1871,17 +1871,17 @@ static int hp_event(struct snd_soc_dapm_widget *w, ...@@ -1871,17 +1871,17 @@ static int hp_event(struct snd_soc_dapm_widget *w,
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
WM8962_HP1L_ENA | WM8962_HP1R_ENA, WM8962_HP1L_ENA | WM8962_HP1R_ENA,
WM8962_HP1L_ENA | WM8962_HP1R_ENA); WM8962_HP1L_ENA | WM8962_HP1R_ENA);
udelay(20); udelay(20);
snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY, WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY,
WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY); WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY);
/* Start the DC servo */ /* Start the DC servo */
snd_soc_update_bits(codec, WM8962_DC_SERVO_1, snd_soc_component_update_bits(component, WM8962_DC_SERVO_1,
WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA | WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA |
WM8962_HP1L_DCS_STARTUP | WM8962_HP1L_DCS_STARTUP |
WM8962_HP1R_DCS_STARTUP, WM8962_HP1R_DCS_STARTUP,
...@@ -1893,30 +1893,30 @@ static int hp_event(struct snd_soc_dapm_widget *w, ...@@ -1893,30 +1893,30 @@ static int hp_event(struct snd_soc_dapm_widget *w,
timeout = 0; timeout = 0;
do { do {
msleep(1); msleep(1);
reg = snd_soc_read(codec, WM8962_DC_SERVO_6); reg = snd_soc_component_read32(component, WM8962_DC_SERVO_6);
if (reg < 0) { if (reg < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to read DCS status: %d\n", "Failed to read DCS status: %d\n",
reg); reg);
continue; continue;
} }
dev_dbg(codec->dev, "DCS status: %x\n", reg); dev_dbg(component->dev, "DCS status: %x\n", reg);
} while (++timeout < 200 && (reg & expected) != expected); } while (++timeout < 200 && (reg & expected) != expected);
if ((reg & expected) != expected) if ((reg & expected) != expected)
dev_err(codec->dev, "DC servo timed out\n"); dev_err(component->dev, "DC servo timed out\n");
else else
dev_dbg(codec->dev, "DC servo complete after %dms\n", dev_dbg(component->dev, "DC servo complete after %dms\n",
timeout); timeout);
snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
WM8962_HP1L_ENA_OUTP | WM8962_HP1L_ENA_OUTP |
WM8962_HP1R_ENA_OUTP, WM8962_HP1R_ENA_OUTP,
WM8962_HP1L_ENA_OUTP | WM8962_HP1L_ENA_OUTP |
WM8962_HP1R_ENA_OUTP); WM8962_HP1R_ENA_OUTP);
udelay(20); udelay(20);
snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
WM8962_HP1L_RMV_SHORT | WM8962_HP1L_RMV_SHORT |
WM8962_HP1R_RMV_SHORT, WM8962_HP1R_RMV_SHORT,
WM8962_HP1L_RMV_SHORT | WM8962_HP1L_RMV_SHORT |
...@@ -1924,19 +1924,19 @@ static int hp_event(struct snd_soc_dapm_widget *w, ...@@ -1924,19 +1924,19 @@ static int hp_event(struct snd_soc_dapm_widget *w,
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
WM8962_HP1L_RMV_SHORT | WM8962_HP1L_RMV_SHORT |
WM8962_HP1R_RMV_SHORT, 0); WM8962_HP1R_RMV_SHORT, 0);
udelay(20); udelay(20);
snd_soc_update_bits(codec, WM8962_DC_SERVO_1, snd_soc_component_update_bits(component, WM8962_DC_SERVO_1,
WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA | WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA |
WM8962_HP1L_DCS_STARTUP | WM8962_HP1L_DCS_STARTUP |
WM8962_HP1R_DCS_STARTUP, WM8962_HP1R_DCS_STARTUP,
0); 0);
snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0,
WM8962_HP1L_ENA | WM8962_HP1R_ENA | WM8962_HP1L_ENA | WM8962_HP1R_ENA |
WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY | WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY |
WM8962_HP1L_ENA_OUTP | WM8962_HP1L_ENA_OUTP |
...@@ -1957,7 +1957,7 @@ static int hp_event(struct snd_soc_dapm_widget *w, ...@@ -1957,7 +1957,7 @@ static int hp_event(struct snd_soc_dapm_widget *w,
static int out_pga_event(struct snd_soc_dapm_widget *w, static int out_pga_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);
int reg; int reg;
switch (w->shift) { switch (w->shift) {
...@@ -1980,7 +1980,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, ...@@ -1980,7 +1980,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w,
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
return snd_soc_write(codec, reg, snd_soc_read(codec, reg)); return snd_soc_component_write(component, reg, snd_soc_component_read32(component, reg));
default: default:
WARN(1, "Invalid event %d\n", event); WARN(1, "Invalid event %d\n", event);
return -EINVAL; return -EINVAL;
...@@ -1990,18 +1990,18 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, ...@@ -1990,18 +1990,18 @@ static int out_pga_event(struct snd_soc_dapm_widget *w,
static int dsp2_event(struct snd_soc_dapm_widget *w, static int dsp2_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);
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
if (wm8962->dsp2_ena) if (wm8962->dsp2_ena)
wm8962_dsp2_start(codec); wm8962_dsp2_start(component);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
if (wm8962->dsp2_ena) if (wm8962->dsp2_ena)
wm8962_dsp2_stop(codec); wm8962_dsp2_stop(component);
break; break;
default: default:
...@@ -2354,19 +2354,19 @@ static const struct snd_soc_dapm_route wm8962_spk_stereo_intercon[] = { ...@@ -2354,19 +2354,19 @@ static const struct snd_soc_dapm_route wm8962_spk_stereo_intercon[] = {
{ "SPKOUTR", NULL, "SPKOUTR Output" }, { "SPKOUTR", NULL, "SPKOUTR Output" },
}; };
static int wm8962_add_widgets(struct snd_soc_codec *codec) static int wm8962_add_widgets(struct snd_soc_component *component)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
struct wm8962_pdata *pdata = &wm8962->pdata; struct wm8962_pdata *pdata = &wm8962->pdata;
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
snd_soc_add_codec_controls(codec, wm8962_snd_controls, snd_soc_add_component_controls(component, wm8962_snd_controls,
ARRAY_SIZE(wm8962_snd_controls)); ARRAY_SIZE(wm8962_snd_controls));
if (pdata->spk_mono) if (pdata->spk_mono)
snd_soc_add_codec_controls(codec, wm8962_spk_mono_controls, snd_soc_add_component_controls(component, wm8962_spk_mono_controls,
ARRAY_SIZE(wm8962_spk_mono_controls)); ARRAY_SIZE(wm8962_spk_mono_controls));
else else
snd_soc_add_codec_controls(codec, wm8962_spk_stereo_controls, snd_soc_add_component_controls(component, wm8962_spk_stereo_controls,
ARRAY_SIZE(wm8962_spk_stereo_controls)); ARRAY_SIZE(wm8962_spk_stereo_controls));
...@@ -2403,21 +2403,21 @@ static const int sysclk_rates[] = { ...@@ -2403,21 +2403,21 @@ static const int sysclk_rates[] = {
64, 128, 192, 256, 384, 512, 768, 1024, 1408, 1536, 3072, 6144 64, 128, 192, 256, 384, 512, 768, 1024, 1408, 1536, 3072, 6144
}; };
static void wm8962_configure_bclk(struct snd_soc_codec *codec) static void wm8962_configure_bclk(struct snd_soc_component *component)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
int dspclk, i; int dspclk, i;
int clocking2 = 0; int clocking2 = 0;
int clocking4 = 0; int clocking4 = 0;
int aif2 = 0; int aif2 = 0;
if (!wm8962->sysclk_rate) { if (!wm8962->sysclk_rate) {
dev_dbg(codec->dev, "No SYSCLK configured\n"); dev_dbg(component->dev, "No SYSCLK configured\n");
return; return;
} }
if (!wm8962->bclk || !wm8962->lrclk) { if (!wm8962->bclk || !wm8962->lrclk) {
dev_dbg(codec->dev, "No audio clocks configured\n"); dev_dbg(component->dev, "No audio clocks configured\n");
return; return;
} }
...@@ -2429,32 +2429,32 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) ...@@ -2429,32 +2429,32 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec)
} }
if (i == ARRAY_SIZE(sysclk_rates)) { if (i == ARRAY_SIZE(sysclk_rates)) {
dev_err(codec->dev, "Unsupported sysclk ratio %d\n", dev_err(component->dev, "Unsupported sysclk ratio %d\n",
wm8962->sysclk_rate / wm8962->lrclk); wm8962->sysclk_rate / wm8962->lrclk);
return; return;
} }
dev_dbg(codec->dev, "Selected sysclk ratio %d\n", sysclk_rates[i]); dev_dbg(component->dev, "Selected sysclk ratio %d\n", sysclk_rates[i]);
snd_soc_update_bits(codec, WM8962_CLOCKING_4, snd_soc_component_update_bits(component, WM8962_CLOCKING_4,
WM8962_SYSCLK_RATE_MASK, clocking4); WM8962_SYSCLK_RATE_MASK, clocking4);
/* DSPCLK_DIV can be only generated correctly after enabling SYSCLK. /* DSPCLK_DIV can be only generated correctly after enabling SYSCLK.
* So we here provisionally enable it and then disable it afterward * So we here provisionally enable it and then disable it afterward
* if current bias_level hasn't reached SND_SOC_BIAS_ON. * if current bias_level hasn't reached SND_SOC_BIAS_ON.
*/ */
if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON) if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON)
snd_soc_update_bits(codec, WM8962_CLOCKING2, snd_soc_component_update_bits(component, WM8962_CLOCKING2,
WM8962_SYSCLK_ENA_MASK, WM8962_SYSCLK_ENA); WM8962_SYSCLK_ENA_MASK, WM8962_SYSCLK_ENA);
dspclk = snd_soc_read(codec, WM8962_CLOCKING1); dspclk = snd_soc_component_read32(component, WM8962_CLOCKING1);
if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON) if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON)
snd_soc_update_bits(codec, WM8962_CLOCKING2, snd_soc_component_update_bits(component, WM8962_CLOCKING2,
WM8962_SYSCLK_ENA_MASK, 0); WM8962_SYSCLK_ENA_MASK, 0);
if (dspclk < 0) { if (dspclk < 0) {
dev_err(codec->dev, "Failed to read DSPCLK: %d\n", dspclk); dev_err(component->dev, "Failed to read DSPCLK: %d\n", dspclk);
return; return;
} }
...@@ -2470,11 +2470,11 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) ...@@ -2470,11 +2470,11 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec)
dspclk = wm8962->sysclk_rate / 4; dspclk = wm8962->sysclk_rate / 4;
break; break;
default: default:
dev_warn(codec->dev, "Unknown DSPCLK divisor read back\n"); dev_warn(component->dev, "Unknown DSPCLK divisor read back\n");
dspclk = wm8962->sysclk_rate; dspclk = wm8962->sysclk_rate;
} }
dev_dbg(codec->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk); dev_dbg(component->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk);
/* We're expecting an exact match */ /* We're expecting an exact match */
for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) { for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) {
...@@ -2482,29 +2482,29 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) ...@@ -2482,29 +2482,29 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec)
continue; continue;
if (dspclk / bclk_divs[i] == wm8962->bclk) { if (dspclk / bclk_divs[i] == wm8962->bclk) {
dev_dbg(codec->dev, "Selected BCLK_DIV %d for %dHz\n", dev_dbg(component->dev, "Selected BCLK_DIV %d for %dHz\n",
bclk_divs[i], wm8962->bclk); bclk_divs[i], wm8962->bclk);
clocking2 |= i; clocking2 |= i;
break; break;
} }
} }
if (i == ARRAY_SIZE(bclk_divs)) { if (i == ARRAY_SIZE(bclk_divs)) {
dev_err(codec->dev, "Unsupported BCLK ratio %d\n", dev_err(component->dev, "Unsupported BCLK ratio %d\n",
dspclk / wm8962->bclk); dspclk / wm8962->bclk);
return; return;
} }
aif2 |= wm8962->bclk / wm8962->lrclk; aif2 |= wm8962->bclk / wm8962->lrclk;
dev_dbg(codec->dev, "Selected LRCLK divisor %d for %dHz\n", dev_dbg(component->dev, "Selected LRCLK divisor %d for %dHz\n",
wm8962->bclk / wm8962->lrclk, wm8962->lrclk); wm8962->bclk / wm8962->lrclk, wm8962->lrclk);
snd_soc_update_bits(codec, WM8962_CLOCKING2, snd_soc_component_update_bits(component, WM8962_CLOCKING2,
WM8962_BCLK_DIV_MASK, clocking2); WM8962_BCLK_DIV_MASK, clocking2);
snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_2, snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_2,
WM8962_AIF_RATE_MASK, aif2); WM8962_AIF_RATE_MASK, aif2);
} }
static int wm8962_set_bias_level(struct snd_soc_codec *codec, static int wm8962_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
...@@ -2513,18 +2513,18 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec, ...@@ -2513,18 +2513,18 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* VMID 2*50k */ /* VMID 2*50k */
snd_soc_update_bits(codec, WM8962_PWR_MGMT_1, snd_soc_component_update_bits(component, WM8962_PWR_MGMT_1,
WM8962_VMID_SEL_MASK, 0x80); WM8962_VMID_SEL_MASK, 0x80);
wm8962_configure_bclk(codec); wm8962_configure_bclk(component);
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
/* VMID 2*250k */ /* VMID 2*250k */
snd_soc_update_bits(codec, WM8962_PWR_MGMT_1, snd_soc_component_update_bits(component, WM8962_PWR_MGMT_1,
WM8962_VMID_SEL_MASK, 0x100); WM8962_VMID_SEL_MASK, 0x100);
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
msleep(100); msleep(100);
break; break;
...@@ -2556,8 +2556,8 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, ...@@ -2556,8 +2556,8 @@ static int wm8962_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;
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
int i; int i;
int aif0 = 0; int aif0 = 0;
int adctl3 = 0; int adctl3 = 0;
...@@ -2575,7 +2575,7 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, ...@@ -2575,7 +2575,7 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream,
} }
} }
if (i == ARRAY_SIZE(sr_vals)) { if (i == ARRAY_SIZE(sr_vals)) {
dev_err(codec->dev, "Unsupported rate %dHz\n", wm8962->lrclk); dev_err(component->dev, "Unsupported rate %dHz\n", wm8962->lrclk);
return -EINVAL; return -EINVAL;
} }
...@@ -2598,17 +2598,17 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, ...@@ -2598,17 +2598,17 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0, snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_0,
WM8962_WL_MASK, aif0); WM8962_WL_MASK, aif0);
snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_3, snd_soc_component_update_bits(component, WM8962_ADDITIONAL_CONTROL_3,
WM8962_SAMPLE_RATE_INT_MODE | WM8962_SAMPLE_RATE_INT_MODE |
WM8962_SAMPLE_RATE_MASK, adctl3); WM8962_SAMPLE_RATE_MASK, adctl3);
dev_dbg(codec->dev, "hw_params set BCLK %dHz LRCLK %dHz\n", dev_dbg(component->dev, "hw_params set BCLK %dHz LRCLK %dHz\n",
wm8962->bclk, wm8962->lrclk); wm8962->bclk, wm8962->lrclk);
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON)
wm8962_configure_bclk(codec); wm8962_configure_bclk(component);
return 0; return 0;
} }
...@@ -2616,8 +2616,8 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, ...@@ -2616,8 +2616,8 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream,
static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
unsigned int freq, int dir) unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
int src; int src;
switch (clk_id) { switch (clk_id) {
...@@ -2633,7 +2633,7 @@ static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, ...@@ -2633,7 +2633,7 @@ static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_SRC_MASK, snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_SYSCLK_SRC_MASK,
src); src);
wm8962->sysclk_rate = freq; wm8962->sysclk_rate = freq;
...@@ -2643,7 +2643,7 @@ static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, ...@@ -2643,7 +2643,7 @@ static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
int aif0 = 0; int aif0 = 0;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
...@@ -2699,7 +2699,7 @@ static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2699,7 +2699,7 @@ static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0, snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_0,
WM8962_FMT_MASK | WM8962_BCLK_INV | WM8962_MSTR | WM8962_FMT_MASK | WM8962_BCLK_INV | WM8962_MSTR |
WM8962_LRCLK_INV, aif0); WM8962_LRCLK_INV, aif0);
...@@ -2809,10 +2809,10 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, ...@@ -2809,10 +2809,10 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
return 0; return 0;
} }
static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int source,
unsigned int Fref, unsigned int Fout) unsigned int Fref, unsigned int Fout)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
struct _fll_div fll_div; struct _fll_div fll_div;
unsigned long timeout; unsigned long timeout;
int ret; int ret;
...@@ -2824,15 +2824,15 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -2824,15 +2824,15 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
return 0; return 0;
if (Fout == 0) { if (Fout == 0) {
dev_dbg(codec->dev, "FLL disabled\n"); dev_dbg(component->dev, "FLL disabled\n");
wm8962->fll_fref = 0; wm8962->fll_fref = 0;
wm8962->fll_fout = 0; wm8962->fll_fout = 0;
snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
WM8962_FLL_ENA, 0); WM8962_FLL_ENA, 0);
pm_runtime_put(codec->dev); pm_runtime_put(component->dev);
return 0; return 0;
} }
...@@ -2842,7 +2842,7 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -2842,7 +2842,7 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
return ret; return ret;
/* Parameters good, disable so we can reprogram */ /* Parameters good, disable so we can reprogram */
snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);
switch (fll_id) { switch (fll_id) {
case WM8962_FLL_MCLK: case WM8962_FLL_MCLK:
...@@ -2851,13 +2851,13 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -2851,13 +2851,13 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT; fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
break; break;
case WM8962_FLL_INT: case WM8962_FLL_INT:
snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
WM8962_FLL_OSC_ENA, WM8962_FLL_OSC_ENA); WM8962_FLL_OSC_ENA, WM8962_FLL_OSC_ENA);
snd_soc_update_bits(codec, WM8962_FLL_CONTROL_5, snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_5,
WM8962_FLL_FRC_NCO, WM8962_FLL_FRC_NCO); WM8962_FLL_FRC_NCO, WM8962_FLL_FRC_NCO);
break; break;
default: default:
dev_err(codec->dev, "Unknown FLL source %d\n", ret); dev_err(component->dev, "Unknown FLL source %d\n", ret);
return -EINVAL; return -EINVAL;
} }
...@@ -2865,34 +2865,34 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -2865,34 +2865,34 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
fll1 |= WM8962_FLL_FRAC; fll1 |= WM8962_FLL_FRAC;
/* Stop the FLL while we reconfigure */ /* Stop the FLL while we reconfigure */
snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);
snd_soc_update_bits(codec, WM8962_FLL_CONTROL_2, snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_2,
WM8962_FLL_OUTDIV_MASK | WM8962_FLL_OUTDIV_MASK |
WM8962_FLL_REFCLK_DIV_MASK, WM8962_FLL_REFCLK_DIV_MASK,
(fll_div.fll_outdiv << WM8962_FLL_OUTDIV_SHIFT) | (fll_div.fll_outdiv << WM8962_FLL_OUTDIV_SHIFT) |
(fll_div.fll_refclk_div)); (fll_div.fll_refclk_div));
snd_soc_update_bits(codec, WM8962_FLL_CONTROL_3, snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_3,
WM8962_FLL_FRATIO_MASK, fll_div.fll_fratio); WM8962_FLL_FRATIO_MASK, fll_div.fll_fratio);
snd_soc_write(codec, WM8962_FLL_CONTROL_6, fll_div.theta); snd_soc_component_write(component, WM8962_FLL_CONTROL_6, fll_div.theta);
snd_soc_write(codec, WM8962_FLL_CONTROL_7, fll_div.lambda); snd_soc_component_write(component, WM8962_FLL_CONTROL_7, fll_div.lambda);
snd_soc_write(codec, WM8962_FLL_CONTROL_8, fll_div.n); snd_soc_component_write(component, WM8962_FLL_CONTROL_8, fll_div.n);
reinit_completion(&wm8962->fll_lock); reinit_completion(&wm8962->fll_lock);
ret = pm_runtime_get_sync(codec->dev); ret = pm_runtime_get_sync(component->dev);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to resume device: %d\n", ret); dev_err(component->dev, "Failed to resume device: %d\n", ret);
return ret; return ret;
} }
snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
WM8962_FLL_FRAC | WM8962_FLL_REFCLK_SRC_MASK | WM8962_FLL_FRAC | WM8962_FLL_REFCLK_SRC_MASK |
WM8962_FLL_ENA, fll1 | WM8962_FLL_ENA); WM8962_FLL_ENA, fll1 | WM8962_FLL_ENA);
dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout);
/* This should be a massive overestimate but go even /* This should be a massive overestimate but go even
* higher if we'll error out * higher if we'll error out
...@@ -2906,10 +2906,10 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -2906,10 +2906,10 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
timeout); timeout);
if (timeout == 0 && wm8962->irq) { if (timeout == 0 && wm8962->irq) {
dev_err(codec->dev, "FLL lock timed out"); dev_err(component->dev, "FLL lock timed out");
snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
WM8962_FLL_ENA, 0); WM8962_FLL_ENA, 0);
pm_runtime_put(codec->dev); pm_runtime_put(component->dev);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
...@@ -2922,7 +2922,7 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -2922,7 +2922,7 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
static int wm8962_mute(struct snd_soc_dai *dai, int mute) static int wm8962_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
int val, ret; int val, ret;
if (mute) if (mute)
...@@ -2934,12 +2934,12 @@ static int wm8962_mute(struct snd_soc_dai *dai, int mute) ...@@ -2934,12 +2934,12 @@ static int wm8962_mute(struct snd_soc_dai *dai, int mute)
* The DAC mute bit is mirrored in two registers, update both to keep * The DAC mute bit is mirrored in two registers, update both to keep
* the register cache consistent. * the register cache consistent.
*/ */
ret = snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_1, ret = snd_soc_component_update_bits(component, WM8962_CLASS_D_CONTROL_1,
WM8962_DAC_MUTE_ALT, val); WM8962_DAC_MUTE_ALT, val);
if (ret < 0) if (ret < 0)
return ret; return ret;
return snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, return snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1,
WM8962_DAC_MUTE, val); WM8962_DAC_MUTE, val);
} }
...@@ -2981,12 +2981,12 @@ static void wm8962_mic_work(struct work_struct *work) ...@@ -2981,12 +2981,12 @@ static void wm8962_mic_work(struct work_struct *work)
struct wm8962_priv *wm8962 = container_of(work, struct wm8962_priv *wm8962 = container_of(work,
struct wm8962_priv, struct wm8962_priv,
mic_work.work); mic_work.work);
struct snd_soc_codec *codec = wm8962->codec; struct snd_soc_component *component = wm8962->component;
int status = 0; int status = 0;
int irq_pol = 0; int irq_pol = 0;
int reg; int reg;
reg = snd_soc_read(codec, WM8962_ADDITIONAL_CONTROL_4); reg = snd_soc_component_read32(component, WM8962_ADDITIONAL_CONTROL_4);
if (reg & WM8962_MICDET_STS) { if (reg & WM8962_MICDET_STS) {
status |= SND_JACK_MICROPHONE; status |= SND_JACK_MICROPHONE;
...@@ -3001,7 +3001,7 @@ static void wm8962_mic_work(struct work_struct *work) ...@@ -3001,7 +3001,7 @@ static void wm8962_mic_work(struct work_struct *work)
snd_soc_jack_report(wm8962->jack, status, snd_soc_jack_report(wm8962->jack, status,
SND_JACK_MICROPHONE | SND_JACK_BTN_0); SND_JACK_MICROPHONE | SND_JACK_BTN_0);
snd_soc_update_bits(codec, WM8962_MICINT_SOURCE_POL, snd_soc_component_update_bits(component, WM8962_MICINT_SOURCE_POL,
WM8962_MICSCD_IRQ_POL | WM8962_MICSCD_IRQ_POL |
WM8962_MICD_IRQ_POL, irq_pol); WM8962_MICD_IRQ_POL, irq_pol);
} }
...@@ -3099,7 +3099,7 @@ static irqreturn_t wm8962_irq(int irq, void *data) ...@@ -3099,7 +3099,7 @@ static irqreturn_t wm8962_irq(int irq, void *data)
/** /**
* wm8962_mic_detect - Enable microphone detection via the WM8962 IRQ * wm8962_mic_detect - Enable microphone detection via the WM8962 IRQ
* *
* @codec: WM8962 codec * @component: WM8962 component
* @jack: jack to report detection events on * @jack: jack to report detection events on
* *
* Enable microphone detection via IRQ on the WM8962. If GPIOs are * Enable microphone detection via IRQ on the WM8962. If GPIOs are
...@@ -3109,10 +3109,10 @@ static irqreturn_t wm8962_irq(int irq, void *data) ...@@ -3109,10 +3109,10 @@ static irqreturn_t wm8962_irq(int irq, void *data)
* *
* If no jack is supplied detection will be disabled. * If no jack is supplied detection will be disabled.
*/ */
int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = 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 irq_mask, enable; int irq_mask, enable;
wm8962->jack = jack; wm8962->jack = jack;
...@@ -3124,9 +3124,9 @@ int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) ...@@ -3124,9 +3124,9 @@ int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
enable = 0; enable = 0;
} }
snd_soc_update_bits(codec, WM8962_INTERRUPT_STATUS_2_MASK, snd_soc_component_update_bits(component, WM8962_INTERRUPT_STATUS_2_MASK,
WM8962_MICD_EINT | WM8962_MICSCD_EINT, irq_mask); WM8962_MICD_EINT | WM8962_MICSCD_EINT, irq_mask);
snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4, snd_soc_component_update_bits(component, WM8962_ADDITIONAL_CONTROL_4,
WM8962_MICDET_ENA, enable); WM8962_MICDET_ENA, enable);
/* Send an initial empty report */ /* Send an initial empty report */
...@@ -3157,8 +3157,8 @@ static void wm8962_beep_work(struct work_struct *work) ...@@ -3157,8 +3157,8 @@ static void wm8962_beep_work(struct work_struct *work)
{ {
struct wm8962_priv *wm8962 = struct wm8962_priv *wm8962 =
container_of(work, struct wm8962_priv, beep_work); container_of(work, struct wm8962_priv, beep_work);
struct snd_soc_codec *codec = wm8962->codec; struct snd_soc_component *component = wm8962->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 i; int i;
int reg = 0; int reg = 0;
int best = 0; int best = 0;
...@@ -3170,18 +3170,18 @@ static void wm8962_beep_work(struct work_struct *work) ...@@ -3170,18 +3170,18 @@ static void wm8962_beep_work(struct work_struct *work)
best = i; best = i;
} }
dev_dbg(codec->dev, "Set beep rate %dHz for requested %dHz\n", dev_dbg(component->dev, "Set beep rate %dHz for requested %dHz\n",
beep_rates[best], wm8962->beep_rate); beep_rates[best], wm8962->beep_rate);
reg = WM8962_BEEP_ENA | (best << WM8962_BEEP_RATE_SHIFT); reg = WM8962_BEEP_ENA | (best << WM8962_BEEP_RATE_SHIFT);
snd_soc_dapm_enable_pin(dapm, "Beep"); snd_soc_dapm_enable_pin(dapm, "Beep");
} else { } else {
dev_dbg(codec->dev, "Disabling beep\n"); dev_dbg(component->dev, "Disabling beep\n");
snd_soc_dapm_disable_pin(dapm, "Beep"); snd_soc_dapm_disable_pin(dapm, "Beep");
} }
snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, snd_soc_component_update_bits(component, WM8962_BEEP_GENERATOR_1,
WM8962_BEEP_ENA | WM8962_BEEP_RATE_MASK, reg); WM8962_BEEP_ENA | WM8962_BEEP_RATE_MASK, reg);
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
...@@ -3193,10 +3193,10 @@ static void wm8962_beep_work(struct work_struct *work) ...@@ -3193,10 +3193,10 @@ static void wm8962_beep_work(struct work_struct *work)
static int wm8962_beep_event(struct input_dev *dev, unsigned int type, static int wm8962_beep_event(struct input_dev *dev, unsigned int type,
unsigned int code, int hz) unsigned int code, int hz)
{ {
struct snd_soc_codec *codec = input_get_drvdata(dev); struct snd_soc_component *component = input_get_drvdata(dev);
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
dev_dbg(codec->dev, "Beep event %x %x\n", code, hz); dev_dbg(component->dev, "Beep event %x %x\n", code, hz);
switch (code) { switch (code) {
case SND_BELL: case SND_BELL:
...@@ -3233,14 +3233,14 @@ static ssize_t wm8962_beep_set(struct device *dev, ...@@ -3233,14 +3233,14 @@ static ssize_t wm8962_beep_set(struct device *dev,
static DEVICE_ATTR(beep, 0200, NULL, wm8962_beep_set); static DEVICE_ATTR(beep, 0200, NULL, wm8962_beep_set);
static void wm8962_init_beep(struct snd_soc_codec *codec) static void wm8962_init_beep(struct snd_soc_component *component)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
int ret; int ret;
wm8962->beep = devm_input_allocate_device(codec->dev); wm8962->beep = devm_input_allocate_device(component->dev);
if (!wm8962->beep) { if (!wm8962->beep) {
dev_err(codec->dev, "Failed to allocate beep device\n"); dev_err(component->dev, "Failed to allocate beep device\n");
return; return;
} }
...@@ -3248,37 +3248,37 @@ static void wm8962_init_beep(struct snd_soc_codec *codec) ...@@ -3248,37 +3248,37 @@ static void wm8962_init_beep(struct snd_soc_codec *codec)
wm8962->beep_rate = 0; wm8962->beep_rate = 0;
wm8962->beep->name = "WM8962 Beep Generator"; wm8962->beep->name = "WM8962 Beep Generator";
wm8962->beep->phys = dev_name(codec->dev); wm8962->beep->phys = dev_name(component->dev);
wm8962->beep->id.bustype = BUS_I2C; wm8962->beep->id.bustype = BUS_I2C;
wm8962->beep->evbit[0] = BIT_MASK(EV_SND); wm8962->beep->evbit[0] = BIT_MASK(EV_SND);
wm8962->beep->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); wm8962->beep->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
wm8962->beep->event = wm8962_beep_event; wm8962->beep->event = wm8962_beep_event;
wm8962->beep->dev.parent = codec->dev; wm8962->beep->dev.parent = component->dev;
input_set_drvdata(wm8962->beep, codec); input_set_drvdata(wm8962->beep, component);
ret = input_register_device(wm8962->beep); ret = input_register_device(wm8962->beep);
if (ret != 0) { if (ret != 0) {
wm8962->beep = NULL; wm8962->beep = NULL;
dev_err(codec->dev, "Failed to register beep device\n"); dev_err(component->dev, "Failed to register beep device\n");
} }
ret = device_create_file(codec->dev, &dev_attr_beep); ret = device_create_file(component->dev, &dev_attr_beep);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Failed to create keyclick file: %d\n", dev_err(component->dev, "Failed to create keyclick file: %d\n",
ret); ret);
} }
} }
static void wm8962_free_beep(struct snd_soc_codec *codec) static void wm8962_free_beep(struct snd_soc_component *component)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
device_remove_file(codec->dev, &dev_attr_beep); device_remove_file(component->dev, &dev_attr_beep);
cancel_work_sync(&wm8962->beep_work); cancel_work_sync(&wm8962->beep_work);
wm8962->beep = NULL; wm8962->beep = NULL;
snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA,0); snd_soc_component_update_bits(component, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA,0);
} }
static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio) static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio)
...@@ -3333,9 +3333,9 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) ...@@ -3333,9 +3333,9 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{ {
struct wm8962_priv *wm8962 = gpiochip_get_data(chip); struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
struct snd_soc_codec *codec = wm8962->codec; struct snd_soc_component *component = wm8962->component;
snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, snd_soc_component_update_bits(component, WM8962_GPIO_BASE + offset,
WM8962_GP2_LVL, !!value << WM8962_GP2_LVL_SHIFT); WM8962_GP2_LVL, !!value << WM8962_GP2_LVL_SHIFT);
} }
...@@ -3343,13 +3343,13 @@ static int wm8962_gpio_direction_out(struct gpio_chip *chip, ...@@ -3343,13 +3343,13 @@ static int wm8962_gpio_direction_out(struct gpio_chip *chip,
unsigned offset, int value) unsigned offset, int value)
{ {
struct wm8962_priv *wm8962 = gpiochip_get_data(chip); struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
struct snd_soc_codec *codec = wm8962->codec; struct snd_soc_component *component = wm8962->component;
int ret, val; int ret, val;
/* Force function 1 (logic output) */ /* Force function 1 (logic output) */
val = (1 << WM8962_GP2_FN_SHIFT) | (value << WM8962_GP2_LVL_SHIFT); val = (1 << WM8962_GP2_FN_SHIFT) | (value << WM8962_GP2_LVL_SHIFT);
ret = snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, ret = snd_soc_component_update_bits(component, WM8962_GPIO_BASE + offset,
WM8962_GP2_FN_MASK | WM8962_GP2_LVL, val); WM8962_GP2_FN_MASK | WM8962_GP2_LVL, val);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -3366,15 +3366,15 @@ static const struct gpio_chip wm8962_template_chip = { ...@@ -3366,15 +3366,15 @@ static const struct gpio_chip wm8962_template_chip = {
.can_sleep = 1, .can_sleep = 1,
}; };
static void wm8962_init_gpio(struct snd_soc_codec *codec) static void wm8962_init_gpio(struct snd_soc_component *component)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
struct wm8962_pdata *pdata = &wm8962->pdata; struct wm8962_pdata *pdata = &wm8962->pdata;
int ret; int ret;
wm8962->gpio_chip = wm8962_template_chip; wm8962->gpio_chip = wm8962_template_chip;
wm8962->gpio_chip.ngpio = WM8962_MAX_GPIO; wm8962->gpio_chip.ngpio = WM8962_MAX_GPIO;
wm8962->gpio_chip.parent = codec->dev; wm8962->gpio_chip.parent = component->dev;
if (pdata->gpio_base) if (pdata->gpio_base)
wm8962->gpio_chip.base = pdata->gpio_base; wm8962->gpio_chip.base = pdata->gpio_base;
...@@ -3383,34 +3383,34 @@ static void wm8962_init_gpio(struct snd_soc_codec *codec) ...@@ -3383,34 +3383,34 @@ static void wm8962_init_gpio(struct snd_soc_codec *codec)
ret = gpiochip_add_data(&wm8962->gpio_chip, wm8962); ret = gpiochip_add_data(&wm8962->gpio_chip, wm8962);
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);
} }
static void wm8962_free_gpio(struct snd_soc_codec *codec) static void wm8962_free_gpio(struct snd_soc_component *component)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
gpiochip_remove(&wm8962->gpio_chip); gpiochip_remove(&wm8962->gpio_chip);
} }
#else #else
static void wm8962_init_gpio(struct snd_soc_codec *codec) static void wm8962_init_gpio(struct snd_soc_component *component)
{ {
} }
static void wm8962_free_gpio(struct snd_soc_codec *codec) static void wm8962_free_gpio(struct snd_soc_component *component)
{ {
} }
#endif #endif
static int wm8962_probe(struct snd_soc_codec *codec) static int wm8962_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);
int ret; int ret;
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
int i; int i;
bool dmicclk, dmicdat; bool dmicclk, dmicdat;
wm8962->codec = codec; wm8962->component = component;
wm8962->disable_nb[0].notifier_call = wm8962_regulator_event_0; wm8962->disable_nb[0].notifier_call = wm8962_regulator_event_0;
wm8962->disable_nb[1].notifier_call = wm8962_regulator_event_1; wm8962->disable_nb[1].notifier_call = wm8962_regulator_event_1;
...@@ -3426,19 +3426,19 @@ static int wm8962_probe(struct snd_soc_codec *codec) ...@@ -3426,19 +3426,19 @@ static int wm8962_probe(struct snd_soc_codec *codec)
ret = regulator_register_notifier(wm8962->supplies[i].consumer, ret = regulator_register_notifier(wm8962->supplies[i].consumer,
&wm8962->disable_nb[i]); &wm8962->disable_nb[i]);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to register regulator notifier: %d\n", "Failed to register regulator notifier: %d\n",
ret); ret);
} }
} }
wm8962_add_widgets(codec); wm8962_add_widgets(component);
/* Save boards having to disable DMIC when not in use */ /* Save boards having to disable DMIC when not in use */
dmicclk = false; dmicclk = false;
dmicdat = false; dmicdat = false;
for (i = 0; i < WM8962_MAX_GPIO; i++) { for (i = 0; i < WM8962_MAX_GPIO; i++) {
switch (snd_soc_read(codec, WM8962_GPIO_BASE + i) switch (snd_soc_component_read32(component, WM8962_GPIO_BASE + i)
& WM8962_GP2_FN_MASK) { & WM8962_GP2_FN_MASK) {
case WM8962_GPIO_FN_DMICCLK: case WM8962_GPIO_FN_DMICCLK:
dmicclk = true; dmicclk = true;
...@@ -3451,40 +3451,40 @@ static int wm8962_probe(struct snd_soc_codec *codec) ...@@ -3451,40 +3451,40 @@ static int wm8962_probe(struct snd_soc_codec *codec)
} }
} }
if (!dmicclk || !dmicdat) { if (!dmicclk || !dmicdat) {
dev_dbg(codec->dev, "DMIC not in use, disabling\n"); dev_dbg(component->dev, "DMIC not in use, disabling\n");
snd_soc_dapm_nc_pin(dapm, "DMICDAT"); snd_soc_dapm_nc_pin(dapm, "DMICDAT");
} }
if (dmicclk != dmicdat) if (dmicclk != dmicdat)
dev_warn(codec->dev, "DMIC GPIOs partially configured\n"); dev_warn(component->dev, "DMIC GPIOs partially configured\n");
wm8962_init_beep(codec); wm8962_init_beep(component);
wm8962_init_gpio(codec); wm8962_init_gpio(component);
return 0; return 0;
} }
static int wm8962_remove(struct snd_soc_codec *codec) static void wm8962_remove(struct snd_soc_component *component)
{ {
struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
int i; int i;
cancel_delayed_work_sync(&wm8962->mic_work); cancel_delayed_work_sync(&wm8962->mic_work);
wm8962_free_gpio(codec); wm8962_free_gpio(component);
wm8962_free_beep(codec); wm8962_free_beep(component);
for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++)
regulator_unregister_notifier(wm8962->supplies[i].consumer, regulator_unregister_notifier(wm8962->supplies[i].consumer,
&wm8962->disable_nb[i]); &wm8962->disable_nb[i]);
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm8962 = { static const struct snd_soc_component_driver soc_component_dev_wm8962 = {
.probe = wm8962_probe, .probe = wm8962_probe,
.remove = wm8962_remove, .remove = wm8962_remove,
.set_bias_level = wm8962_set_bias_level, .set_bias_level = wm8962_set_bias_level,
.set_pll = wm8962_set_fll, .set_pll = wm8962_set_fll,
.idle_bias_off = true, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
/* Improve power consumption for IN4 DC measurement mode */ /* Improve power consumption for IN4 DC measurement mode */
...@@ -3751,8 +3751,8 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, ...@@ -3751,8 +3751,8 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
pm_runtime_enable(&i2c->dev); pm_runtime_enable(&i2c->dev);
pm_request_idle(&i2c->dev); pm_request_idle(&i2c->dev);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8962, &wm8962_dai, 1); &soc_component_dev_wm8962, &wm8962_dai, 1);
if (ret < 0) if (ret < 0)
goto err_pm_runtime; goto err_pm_runtime;
...@@ -3773,7 +3773,6 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, ...@@ -3773,7 +3773,6 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
static int wm8962_i2c_remove(struct i2c_client *client) static int wm8962_i2c_remove(struct i2c_client *client)
{ {
snd_soc_unregister_codec(&client->dev);
pm_runtime_disable(&client->dev); pm_runtime_disable(&client->dev);
return 0; return 0;
} }
......
...@@ -3779,6 +3779,6 @@ ...@@ -3779,6 +3779,6 @@
#define WM8962_VSS_ENA_SHIFT 0 /* VSS_ENA */ #define WM8962_VSS_ENA_SHIFT 0 /* VSS_ENA */
#define WM8962_VSS_ENA_WIDTH 1 /* VSS_ENA */ #define WM8962_VSS_ENA_WIDTH 1 /* VSS_ENA */
int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack);
#endif #endif
...@@ -89,7 +89,7 @@ static const struct reg_default wm8971_reg_defaults[] = { ...@@ -89,7 +89,7 @@ static const struct reg_default wm8971_reg_defaults[] = {
{ 42, 0x0079 }, { 42, 0x0079 },
}; };
#define wm8971_reset(c) snd_soc_write(c, WM8971_RESET, 0) #define wm8971_reset(c) snd_soc_component_write(c, WM8971_RESET, 0)
/* WM8971 Controls */ /* WM8971 Controls */
static const char *wm8971_bass[] = { "Linear Control", "Adaptive Boost" }; static const char *wm8971_bass[] = { "Linear Control", "Adaptive Boost" };
...@@ -433,8 +433,8 @@ static int get_coeff(int mclk, int rate) ...@@ -433,8 +433,8 @@ static int get_coeff(int mclk, int rate)
static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8971_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 wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
switch (freq) { switch (freq) {
case 11289600: case 11289600:
...@@ -451,7 +451,7 @@ static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -451,7 +451,7 @@ static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai, static int wm8971_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 iface = 0; u16 iface = 0;
/* set master/slave audio interface */ /* set master/slave audio interface */
...@@ -502,7 +502,7 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -502,7 +502,7 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, WM8971_IFACE, iface); snd_soc_component_write(component, WM8971_IFACE, iface);
return 0; return 0;
} }
...@@ -510,10 +510,10 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -510,10 +510,10 @@ static int wm8971_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;
struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
u16 iface = snd_soc_read(codec, WM8971_IFACE) & 0x1f3; u16 iface = snd_soc_component_read32(component, WM8971_IFACE) & 0x1f3;
u16 srate = snd_soc_read(codec, WM8971_SRATE) & 0x1c0; u16 srate = snd_soc_component_read32(component, WM8971_SRATE) & 0x1c0;
int coeff = get_coeff(wm8971->sysclk, params_rate(params)); int coeff = get_coeff(wm8971->sysclk, params_rate(params));
/* bit size */ /* bit size */
...@@ -532,9 +532,9 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -532,9 +532,9 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream,
} }
/* set iface & srate */ /* set iface & srate */
snd_soc_write(codec, WM8971_IFACE, iface); snd_soc_component_write(component, WM8971_IFACE, iface);
if (coeff >= 0) if (coeff >= 0)
snd_soc_write(codec, WM8971_SRATE, srate | snd_soc_component_write(component, WM8971_SRATE, srate |
(coeff_div[coeff].sr << 1) | coeff_div[coeff].usb); (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);
return 0; return 0;
...@@ -542,13 +542,13 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -542,13 +542,13 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream,
static int wm8971_mute(struct snd_soc_dai *dai, int mute) static int wm8971_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u16 mute_reg = snd_soc_read(codec, WM8971_ADCDAC) & 0xfff7; u16 mute_reg = snd_soc_component_read32(component, WM8971_ADCDAC) & 0xfff7;
if (mute) if (mute)
snd_soc_write(codec, WM8971_ADCDAC, mute_reg | 0x8); snd_soc_component_write(component, WM8971_ADCDAC, mute_reg | 0x8);
else else
snd_soc_write(codec, WM8971_ADCDAC, mute_reg); snd_soc_component_write(component, WM8971_ADCDAC, mute_reg);
return 0; return 0;
} }
...@@ -561,37 +561,37 @@ static void wm8971_charge_work(struct work_struct *work) ...@@ -561,37 +561,37 @@ static void wm8971_charge_work(struct work_struct *work)
regmap_update_bits(wm8971->regmap, WM8971_PWR1, 0x0180, 0x0100); regmap_update_bits(wm8971->regmap, WM8971_PWR1, 0x0180, 0x0100);
} }
static int wm8971_set_bias_level(struct snd_soc_codec *codec, static int wm8971_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
u16 pwr_reg = snd_soc_read(codec, WM8971_PWR1) & 0xfe3e; u16 pwr_reg = snd_soc_component_read32(component, WM8971_PWR1) & 0xfe3e;
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
/* set vmid to 50k and unmute dac */ /* set vmid to 50k and unmute dac */
snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x00c1); snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x00c1);
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* Wait until fully charged */ /* Wait until fully charged */
flush_delayed_work(&wm8971->charge_work); flush_delayed_work(&wm8971->charge_work);
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) {
snd_soc_cache_sync(codec); snd_soc_component_cache_sync(component);
/* charge output caps - set vmid to 5k for quick power up */ /* charge output caps - set vmid to 5k for quick power up */
snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x01c0); snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x01c0);
queue_delayed_work(system_power_efficient_wq, queue_delayed_work(system_power_efficient_wq,
&wm8971->charge_work, msecs_to_jiffies(1000)); &wm8971->charge_work, msecs_to_jiffies(1000));
} else { } else {
/* mute dac and set vmid to 500k, enable VREF */ /* mute dac and set vmid to 500k, enable VREF */
snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x0140); snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x0140);
} }
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
cancel_delayed_work_sync(&wm8971->charge_work); cancel_delayed_work_sync(&wm8971->charge_work);
snd_soc_write(codec, WM8971_PWR1, 0x0001); snd_soc_component_write(component, WM8971_PWR1, 0x0001);
break; break;
} }
return 0; return 0;
...@@ -628,40 +628,41 @@ static struct snd_soc_dai_driver wm8971_dai = { ...@@ -628,40 +628,41 @@ static struct snd_soc_dai_driver wm8971_dai = {
.ops = &wm8971_dai_ops, .ops = &wm8971_dai_ops,
}; };
static int wm8971_probe(struct snd_soc_codec *codec) static int wm8971_probe(struct snd_soc_component *component)
{ {
struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
INIT_DELAYED_WORK(&wm8971->charge_work, wm8971_charge_work); INIT_DELAYED_WORK(&wm8971->charge_work, wm8971_charge_work);
wm8971_reset(codec); wm8971_reset(component);
/* set the update bits */ /* set the update bits */
snd_soc_update_bits(codec, WM8971_LDAC, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_LDAC, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_RDAC, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_RDAC, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_LOUT1V, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_LOUT1V, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_ROUT1V, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_ROUT1V, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_LOUT2V, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_LOUT2V, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_ROUT2V, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_ROUT2V, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_LINVOL, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_LINVOL, 0x0100, 0x0100);
snd_soc_update_bits(codec, WM8971_RINVOL, 0x0100, 0x0100); snd_soc_component_update_bits(component, WM8971_RINVOL, 0x0100, 0x0100);
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm8971 = { static const struct snd_soc_component_driver soc_component_dev_wm8971 = {
.probe = wm8971_probe, .probe = wm8971_probe,
.set_bias_level = wm8971_set_bias_level, .set_bias_level = wm8971_set_bias_level,
.suspend_bias_off = true,
.component_driver = {
.controls = wm8971_snd_controls, .controls = wm8971_snd_controls,
.num_controls = ARRAY_SIZE(wm8971_snd_controls), .num_controls = ARRAY_SIZE(wm8971_snd_controls),
.dapm_widgets = wm8971_dapm_widgets, .dapm_widgets = wm8971_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets),
.dapm_routes = wm8971_dapm_routes, .dapm_routes = wm8971_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes),
}, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config wm8971_regmap = { static const struct regmap_config wm8971_regmap = {
...@@ -691,18 +692,12 @@ static int wm8971_i2c_probe(struct i2c_client *i2c, ...@@ -691,18 +692,12 @@ static int wm8971_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8971); i2c_set_clientdata(i2c, wm8971);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8971, &wm8971_dai, 1); &soc_component_dev_wm8971, &wm8971_dai, 1);
return ret; return ret;
} }
static int wm8971_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id wm8971_i2c_id[] = { static const struct i2c_device_id wm8971_i2c_id[] = {
{ "wm8971", 0 }, { "wm8971", 0 },
{ } { }
...@@ -714,7 +709,6 @@ static struct i2c_driver wm8971_i2c_driver = { ...@@ -714,7 +709,6 @@ static struct i2c_driver wm8971_i2c_driver = {
.name = "wm8971", .name = "wm8971",
}, },
.probe = wm8971_i2c_probe, .probe = wm8971_i2c_probe,
.remove = wm8971_i2c_remove,
.id_table = wm8971_i2c_id, .id_table = wm8971_i2c_id,
}; };
......
...@@ -54,7 +54,7 @@ static const struct reg_default wm8974_reg_defaults[] = { ...@@ -54,7 +54,7 @@ static const struct reg_default wm8974_reg_defaults[] = {
#define WM8974_POWER1_BIASEN 0x08 #define WM8974_POWER1_BIASEN 0x08
#define WM8974_POWER1_BUFIOEN 0x04 #define WM8974_POWER1_BUFIOEN 0x04
#define wm8974_reset(c) snd_soc_write(c, WM8974_RESET, 0) #define wm8974_reset(c) snd_soc_component_write(c, WM8974_RESET, 0)
static const char *wm8974_companding[] = {"Off", "NC", "u-law", "A-law" }; static const char *wm8974_companding[] = {"Off", "NC", "u-law", "A-law" };
static const char *wm8974_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz" }; static const char *wm8974_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz" };
...@@ -324,33 +324,33 @@ static void pll_factors(struct pll_ *pll_div, ...@@ -324,33 +324,33 @@ static void pll_factors(struct pll_ *pll_div,
static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8974_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;
struct pll_ pll_div; struct pll_ pll_div;
u16 reg; u16 reg;
if (freq_in == 0 || freq_out == 0) { if (freq_in == 0 || freq_out == 0) {
/* Clock CODEC directly from MCLK */ /* Clock CODEC directly from MCLK */
reg = snd_soc_read(codec, WM8974_CLOCK); reg = snd_soc_component_read32(component, WM8974_CLOCK);
snd_soc_write(codec, WM8974_CLOCK, reg & 0x0ff); snd_soc_component_write(component, WM8974_CLOCK, reg & 0x0ff);
/* Turn off PLL */ /* Turn off PLL */
reg = snd_soc_read(codec, WM8974_POWER1); reg = snd_soc_component_read32(component, WM8974_POWER1);
snd_soc_write(codec, WM8974_POWER1, reg & 0x1df); snd_soc_component_write(component, WM8974_POWER1, reg & 0x1df);
return 0; return 0;
} }
pll_factors(&pll_div, freq_out, freq_in); pll_factors(&pll_div, freq_out, freq_in);
snd_soc_write(codec, WM8974_PLLN, (pll_div.pre_div << 4) | pll_div.n); snd_soc_component_write(component, WM8974_PLLN, (pll_div.pre_div << 4) | pll_div.n);
snd_soc_write(codec, WM8974_PLLK1, pll_div.k >> 18); snd_soc_component_write(component, WM8974_PLLK1, pll_div.k >> 18);
snd_soc_write(codec, WM8974_PLLK2, (pll_div.k >> 9) & 0x1ff); snd_soc_component_write(component, WM8974_PLLK2, (pll_div.k >> 9) & 0x1ff);
snd_soc_write(codec, WM8974_PLLK3, pll_div.k & 0x1ff); snd_soc_component_write(component, WM8974_PLLK3, pll_div.k & 0x1ff);
reg = snd_soc_read(codec, WM8974_POWER1); reg = snd_soc_component_read32(component, WM8974_POWER1);
snd_soc_write(codec, WM8974_POWER1, reg | 0x020); snd_soc_component_write(component, WM8974_POWER1, reg | 0x020);
/* Run CODEC from PLL instead of MCLK */ /* Run CODEC from PLL instead of MCLK */
reg = snd_soc_read(codec, WM8974_CLOCK); reg = snd_soc_component_read32(component, WM8974_CLOCK);
snd_soc_write(codec, WM8974_CLOCK, reg | 0x100); snd_soc_component_write(component, WM8974_CLOCK, reg | 0x100);
return 0; return 0;
} }
...@@ -361,21 +361,21 @@ static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, ...@@ -361,21 +361,21 @@ static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
static int wm8974_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8974_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;
u16 reg; u16 reg;
switch (div_id) { switch (div_id) {
case WM8974_OPCLKDIV: case WM8974_OPCLKDIV:
reg = snd_soc_read(codec, WM8974_GPIO) & 0x1cf; reg = snd_soc_component_read32(component, WM8974_GPIO) & 0x1cf;
snd_soc_write(codec, WM8974_GPIO, reg | div); snd_soc_component_write(component, WM8974_GPIO, reg | div);
break; break;
case WM8974_MCLKDIV: case WM8974_MCLKDIV:
reg = snd_soc_read(codec, WM8974_CLOCK) & 0x11f; reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x11f;
snd_soc_write(codec, WM8974_CLOCK, reg | div); snd_soc_component_write(component, WM8974_CLOCK, reg | div);
break; break;
case WM8974_BCLKDIV: case WM8974_BCLKDIV:
reg = snd_soc_read(codec, WM8974_CLOCK) & 0x1e3; reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1e3;
snd_soc_write(codec, WM8974_CLOCK, reg | div); snd_soc_component_write(component, WM8974_CLOCK, reg | div);
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -418,8 +418,8 @@ static unsigned int wm8974_get_mclkdiv(unsigned int f_in, unsigned int f_out, ...@@ -418,8 +418,8 @@ static unsigned int wm8974_get_mclkdiv(unsigned int f_in, unsigned int f_out,
static int wm8974_update_clocks(struct snd_soc_dai *dai) static int wm8974_update_clocks(struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); struct wm8974_priv *priv = snd_soc_component_get_drvdata(component);
unsigned int fs256; unsigned int fs256;
unsigned int fpll = 0; unsigned int fpll = 0;
unsigned int f; unsigned int f;
...@@ -446,8 +446,8 @@ static int wm8974_update_clocks(struct snd_soc_dai *dai) ...@@ -446,8 +446,8 @@ static int wm8974_update_clocks(struct snd_soc_dai *dai)
static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
unsigned int freq, int dir) unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); struct wm8974_priv *priv = snd_soc_component_get_drvdata(component);
if (dir != SND_SOC_CLOCK_IN) if (dir != SND_SOC_CLOCK_IN)
return -EINVAL; return -EINVAL;
...@@ -460,9 +460,9 @@ static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, ...@@ -460,9 +460,9 @@ static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
static int wm8974_set_dai_fmt(struct snd_soc_dai *codec_dai, static int wm8974_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 iface = 0; u16 iface = 0;
u16 clk = snd_soc_read(codec, WM8974_CLOCK) & 0x1fe; u16 clk = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1fe;
/* set master/slave audio interface */ /* set master/slave audio interface */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
...@@ -509,8 +509,8 @@ static int wm8974_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -509,8 +509,8 @@ static int wm8974_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, WM8974_IFACE, iface); snd_soc_component_write(component, WM8974_IFACE, iface);
snd_soc_write(codec, WM8974_CLOCK, clk); snd_soc_component_write(component, WM8974_CLOCK, clk);
return 0; return 0;
} }
...@@ -518,10 +518,10 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -518,10 +518,10 @@ static int wm8974_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;
struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); struct wm8974_priv *priv = snd_soc_component_get_drvdata(component);
u16 iface = snd_soc_read(codec, WM8974_IFACE) & 0x19f; u16 iface = snd_soc_component_read32(component, WM8974_IFACE) & 0x19f;
u16 adn = snd_soc_read(codec, WM8974_ADD) & 0x1f1; u16 adn = snd_soc_component_read32(component, WM8974_ADD) & 0x1f1;
int err; int err;
priv->fs = params_rate(params); priv->fs = params_rate(params);
...@@ -566,55 +566,55 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -566,55 +566,55 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream,
break; break;
} }
snd_soc_write(codec, WM8974_IFACE, iface); snd_soc_component_write(component, WM8974_IFACE, iface);
snd_soc_write(codec, WM8974_ADD, adn); snd_soc_component_write(component, WM8974_ADD, adn);
return 0; return 0;
} }
static int wm8974_mute(struct snd_soc_dai *dai, int mute) static int wm8974_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u16 mute_reg = snd_soc_read(codec, WM8974_DAC) & 0xffbf; u16 mute_reg = snd_soc_component_read32(component, WM8974_DAC) & 0xffbf;
if (mute) if (mute)
snd_soc_write(codec, WM8974_DAC, mute_reg | 0x40); snd_soc_component_write(component, WM8974_DAC, mute_reg | 0x40);
else else
snd_soc_write(codec, WM8974_DAC, mute_reg); snd_soc_component_write(component, WM8974_DAC, mute_reg);
return 0; return 0;
} }
/* liam need to make this lower power with dapm */ /* liam need to make this lower power with dapm */
static int wm8974_set_bias_level(struct snd_soc_codec *codec, static int wm8974_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
u16 power1 = snd_soc_read(codec, WM8974_POWER1) & ~0x3; u16 power1 = snd_soc_component_read32(component, WM8974_POWER1) & ~0x3;
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
power1 |= 0x1; /* VMID 50k */ power1 |= 0x1; /* VMID 50k */
snd_soc_write(codec, WM8974_POWER1, power1); snd_soc_component_write(component, WM8974_POWER1, power1);
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN;
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
regcache_sync(dev_get_regmap(codec->dev, NULL)); regcache_sync(dev_get_regmap(component->dev, NULL));
/* Initial cap charge at VMID 5k */ /* Initial cap charge at VMID 5k */
snd_soc_write(codec, WM8974_POWER1, power1 | 0x3); snd_soc_component_write(component, WM8974_POWER1, power1 | 0x3);
mdelay(100); mdelay(100);
} }
power1 |= 0x2; /* VMID 500k */ power1 |= 0x2; /* VMID 500k */
snd_soc_write(codec, WM8974_POWER1, power1); snd_soc_component_write(component, WM8974_POWER1, power1);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_write(codec, WM8974_POWER1, 0); snd_soc_component_write(component, WM8974_POWER1, 0);
snd_soc_write(codec, WM8974_POWER2, 0); snd_soc_component_write(component, WM8974_POWER2, 0);
snd_soc_write(codec, WM8974_POWER3, 0); snd_soc_component_write(component, WM8974_POWER3, 0);
break; break;
} }
...@@ -663,32 +663,33 @@ static const struct regmap_config wm8974_regmap = { ...@@ -663,32 +663,33 @@ static const struct regmap_config wm8974_regmap = {
.cache_type = REGCACHE_FLAT, .cache_type = REGCACHE_FLAT,
}; };
static int wm8974_probe(struct snd_soc_codec *codec) static int wm8974_probe(struct snd_soc_component *component)
{ {
int ret = 0; int ret = 0;
ret = wm8974_reset(codec); ret = wm8974_reset(component);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to issue reset\n"); dev_err(component->dev, "Failed to issue reset\n");
return ret; return ret;
} }
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm8974 = { static const struct snd_soc_component_driver soc_component_dev_wm8974 = {
.probe = wm8974_probe, .probe = wm8974_probe,
.set_bias_level = wm8974_set_bias_level, .set_bias_level = wm8974_set_bias_level,
.suspend_bias_off = true,
.component_driver = {
.controls = wm8974_snd_controls, .controls = wm8974_snd_controls,
.num_controls = ARRAY_SIZE(wm8974_snd_controls), .num_controls = ARRAY_SIZE(wm8974_snd_controls),
.dapm_widgets = wm8974_dapm_widgets, .dapm_widgets = wm8974_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(wm8974_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(wm8974_dapm_widgets),
.dapm_routes = wm8974_dapm_routes, .dapm_routes = wm8974_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(wm8974_dapm_routes), .num_dapm_routes = ARRAY_SIZE(wm8974_dapm_routes),
}, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int wm8974_i2c_probe(struct i2c_client *i2c, static int wm8974_i2c_probe(struct i2c_client *i2c,
...@@ -708,19 +709,12 @@ static int wm8974_i2c_probe(struct i2c_client *i2c, ...@@ -708,19 +709,12 @@ static int wm8974_i2c_probe(struct i2c_client *i2c,
if (IS_ERR(regmap)) if (IS_ERR(regmap))
return PTR_ERR(regmap); return PTR_ERR(regmap);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8974, &wm8974_dai, 1); &soc_component_dev_wm8974, &wm8974_dai, 1);
return ret; return ret;
} }
static int wm8974_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id wm8974_i2c_id[] = { static const struct i2c_device_id wm8974_i2c_id[] = {
{ "wm8974", 0 }, { "wm8974", 0 },
{ } { }
...@@ -739,7 +733,6 @@ static struct i2c_driver wm8974_i2c_driver = { ...@@ -739,7 +733,6 @@ static struct i2c_driver wm8974_i2c_driver = {
.of_match_table = wm8974_of_match, .of_match_table = wm8974_of_match,
}, },
.probe = wm8974_i2c_probe, .probe = wm8974_i2c_probe,
.remove = wm8974_i2c_remove,
.id_table = wm8974_i2c_id, .id_table = wm8974_i2c_id,
}; };
......
...@@ -179,12 +179,12 @@ static struct snd_soc_jack_pin tobermory_headset_pins[] = { ...@@ -179,12 +179,12 @@ static struct snd_soc_jack_pin tobermory_headset_pins[] = {
static int tobermory_late_probe(struct snd_soc_card *card) static int tobermory_late_probe(struct snd_soc_card *card)
{ {
struct snd_soc_pcm_runtime *rtd; struct snd_soc_pcm_runtime *rtd;
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
int ret; int ret;
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;
codec_dai = rtd->codec_dai; codec_dai = rtd->codec_dai;
ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK, ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK,
...@@ -199,7 +199,7 @@ static int tobermory_late_probe(struct snd_soc_card *card) ...@@ -199,7 +199,7 @@ static int tobermory_late_probe(struct snd_soc_card *card)
if (ret) if (ret)
return ret; return ret;
wm8962_mic_detect(codec, &tobermory_headset); wm8962_mic_detect(component, &tobermory_headset);
return 0; return 0;
} }
......
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