Commit 45101122 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: hdac_hdmi/nau8825/rt286/rt298/rt5663/da7219: replace codec to component

Now we can replace Codec to Component. Let's do it.

Because intal/rockchip boards are using multi-codecs in 1 driver,
we need to update these all related drivers in same time.
Otherwise compile error/warning happen

Note:

hdac_hdmi
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 1	->	.idle_bias_on = 0
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1

nau8825
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 0	->	.idle_bias_on = 1
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1

rt286
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 1	->	.idle_bias_on = 0
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1

rt298
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 1	->	.idle_bias_on = 0
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1

rt5663
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 1	->	.idle_bias_on = 0
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1

da7219
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 0	->	.idle_bias_on = 1
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 29c5b8fd
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
* Detection control * Detection control
*/ */
void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack) void da7219_aad_jack_det(struct snd_soc_component *component, struct snd_soc_jack *jack)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
da7219->aad->jack = jack; da7219->aad->jack = jack;
da7219->aad->jack_inserted = false; da7219->aad->jack_inserted = false;
...@@ -43,7 +43,7 @@ void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack) ...@@ -43,7 +43,7 @@ void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
snd_soc_jack_report(jack, 0, DA7219_AAD_REPORT_ALL_MASK); snd_soc_jack_report(jack, 0, DA7219_AAD_REPORT_ALL_MASK);
/* Enable/Disable jack detection */ /* Enable/Disable jack detection */
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1,
DA7219_ACCDET_EN_MASK, DA7219_ACCDET_EN_MASK,
(jack ? DA7219_ACCDET_EN_MASK : 0)); (jack ? DA7219_ACCDET_EN_MASK : 0));
} }
...@@ -57,17 +57,17 @@ static void da7219_aad_btn_det_work(struct work_struct *work) ...@@ -57,17 +57,17 @@ static void da7219_aad_btn_det_work(struct work_struct *work)
{ {
struct da7219_aad_priv *da7219_aad = struct da7219_aad_priv *da7219_aad =
container_of(work, struct da7219_aad_priv, btn_det_work); container_of(work, struct da7219_aad_priv, btn_det_work);
struct snd_soc_codec *codec = da7219_aad->codec; struct snd_soc_component *component = da7219_aad->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);
u8 statusa, micbias_ctrl; u8 statusa, micbias_ctrl;
bool micbias_up = false; bool micbias_up = false;
int retries = 0; int retries = 0;
/* Drive headphones/lineout */ /* Drive headphones/lineout */
snd_soc_update_bits(codec, DA7219_HP_L_CTRL, snd_soc_component_update_bits(component, DA7219_HP_L_CTRL,
DA7219_HP_L_AMP_OE_MASK, DA7219_HP_L_AMP_OE_MASK,
DA7219_HP_L_AMP_OE_MASK); DA7219_HP_L_AMP_OE_MASK);
snd_soc_update_bits(codec, DA7219_HP_R_CTRL, snd_soc_component_update_bits(component, DA7219_HP_R_CTRL,
DA7219_HP_R_AMP_OE_MASK, DA7219_HP_R_AMP_OE_MASK,
DA7219_HP_R_AMP_OE_MASK); DA7219_HP_R_AMP_OE_MASK);
...@@ -76,7 +76,7 @@ static void da7219_aad_btn_det_work(struct work_struct *work) ...@@ -76,7 +76,7 @@ static void da7219_aad_btn_det_work(struct work_struct *work)
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
do { do {
statusa = snd_soc_read(codec, DA7219_ACCDET_STATUS_A); statusa = snd_soc_component_read32(component, DA7219_ACCDET_STATUS_A);
if (statusa & DA7219_MICBIAS_UP_STS_MASK) if (statusa & DA7219_MICBIAS_UP_STS_MASK)
micbias_up = true; micbias_up = true;
else if (retries++ < DA7219_AAD_MICBIAS_CHK_RETRIES) else if (retries++ < DA7219_AAD_MICBIAS_CHK_RETRIES)
...@@ -84,7 +84,7 @@ static void da7219_aad_btn_det_work(struct work_struct *work) ...@@ -84,7 +84,7 @@ static void da7219_aad_btn_det_work(struct work_struct *work)
} while ((!micbias_up) && (retries < DA7219_AAD_MICBIAS_CHK_RETRIES)); } while ((!micbias_up) && (retries < DA7219_AAD_MICBIAS_CHK_RETRIES));
if (retries >= DA7219_AAD_MICBIAS_CHK_RETRIES) if (retries >= DA7219_AAD_MICBIAS_CHK_RETRIES)
dev_warn(codec->dev, "Mic bias status check timed out"); dev_warn(component->dev, "Mic bias status check timed out");
/* /*
* Mic bias pulse required to enable mic, must be done before enabling * Mic bias pulse required to enable mic, must be done before enabling
...@@ -92,16 +92,16 @@ static void da7219_aad_btn_det_work(struct work_struct *work) ...@@ -92,16 +92,16 @@ static void da7219_aad_btn_det_work(struct work_struct *work)
*/ */
if (da7219_aad->micbias_pulse_lvl && da7219_aad->micbias_pulse_time) { if (da7219_aad->micbias_pulse_lvl && da7219_aad->micbias_pulse_time) {
/* Pulse higher level voltage */ /* Pulse higher level voltage */
micbias_ctrl = snd_soc_read(codec, DA7219_MICBIAS_CTRL); micbias_ctrl = snd_soc_component_read32(component, DA7219_MICBIAS_CTRL);
snd_soc_update_bits(codec, DA7219_MICBIAS_CTRL, snd_soc_component_update_bits(component, DA7219_MICBIAS_CTRL,
DA7219_MICBIAS1_LEVEL_MASK, DA7219_MICBIAS1_LEVEL_MASK,
da7219_aad->micbias_pulse_lvl); da7219_aad->micbias_pulse_lvl);
msleep(da7219_aad->micbias_pulse_time); msleep(da7219_aad->micbias_pulse_time);
snd_soc_write(codec, DA7219_MICBIAS_CTRL, micbias_ctrl); snd_soc_component_write(component, DA7219_MICBIAS_CTRL, micbias_ctrl);
} }
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1,
DA7219_BUTTON_CONFIG_MASK, DA7219_BUTTON_CONFIG_MASK,
da7219_aad->btn_cfg); da7219_aad->btn_cfg);
} }
...@@ -110,9 +110,9 @@ static void da7219_aad_hptest_work(struct work_struct *work) ...@@ -110,9 +110,9 @@ static void da7219_aad_hptest_work(struct work_struct *work)
{ {
struct da7219_aad_priv *da7219_aad = struct da7219_aad_priv *da7219_aad =
container_of(work, struct da7219_aad_priv, hptest_work); container_of(work, struct da7219_aad_priv, hptest_work);
struct snd_soc_codec *codec = da7219_aad->codec; struct snd_soc_component *component = da7219_aad->component;
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
u16 tonegen_freq_hptest; u16 tonegen_freq_hptest;
u8 pll_srm_sts, pll_ctrl, gain_ramp_ctrl, accdet_cfg8; u8 pll_srm_sts, pll_ctrl, gain_ramp_ctrl, accdet_cfg8;
...@@ -127,7 +127,7 @@ static void da7219_aad_hptest_work(struct work_struct *work) ...@@ -127,7 +127,7 @@ static void da7219_aad_hptest_work(struct work_struct *work)
if (da7219->mclk) { if (da7219->mclk) {
ret = clk_prepare_enable(da7219->mclk); ret = clk_prepare_enable(da7219->mclk);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to enable mclk - %d\n", ret); dev_err(component->dev, "Failed to enable mclk - %d\n", ret);
mutex_unlock(&da7219->pll_lock); mutex_unlock(&da7219->pll_lock);
mutex_unlock(&da7219->ctrl_lock); mutex_unlock(&da7219->ctrl_lock);
snd_soc_dapm_mutex_unlock(dapm); snd_soc_dapm_mutex_unlock(dapm);
...@@ -142,90 +142,90 @@ static void da7219_aad_hptest_work(struct work_struct *work) ...@@ -142,90 +142,90 @@ static void da7219_aad_hptest_work(struct work_struct *work)
* If MCLK is present, but PLL is not enabled then we enable it here to * If MCLK is present, but PLL is not enabled then we enable it here to
* ensure a consistent detection procedure. * ensure a consistent detection procedure.
*/ */
pll_srm_sts = snd_soc_read(codec, DA7219_PLL_SRM_STS); pll_srm_sts = snd_soc_component_read32(component, DA7219_PLL_SRM_STS);
if (pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) { if (pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) {
tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ); tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ);
pll_ctrl = snd_soc_read(codec, DA7219_PLL_CTRL); pll_ctrl = snd_soc_component_read32(component, DA7219_PLL_CTRL);
if ((pll_ctrl & DA7219_PLL_MODE_MASK) == DA7219_PLL_MODE_BYPASS) if ((pll_ctrl & DA7219_PLL_MODE_MASK) == DA7219_PLL_MODE_BYPASS)
da7219_set_pll(codec, DA7219_SYSCLK_PLL, da7219_set_pll(component, DA7219_SYSCLK_PLL,
DA7219_PLL_FREQ_OUT_98304); DA7219_PLL_FREQ_OUT_98304);
} else { } else {
tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ_INT_OSC); tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ_INT_OSC);
} }
/* Ensure gain ramping at fastest rate */ /* Ensure gain ramping at fastest rate */
gain_ramp_ctrl = snd_soc_read(codec, DA7219_GAIN_RAMP_CTRL); gain_ramp_ctrl = snd_soc_component_read32(component, DA7219_GAIN_RAMP_CTRL);
snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, DA7219_GAIN_RAMP_RATE_X8); snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL, DA7219_GAIN_RAMP_RATE_X8);
/* Bypass cache so it saves current settings */ /* Bypass cache so it saves current settings */
regcache_cache_bypass(da7219->regmap, true); regcache_cache_bypass(da7219->regmap, true);
/* Make sure Tone Generator is disabled */ /* Make sure Tone Generator is disabled */
snd_soc_write(codec, DA7219_TONE_GEN_CFG1, 0); snd_soc_component_write(component, DA7219_TONE_GEN_CFG1, 0);
/* Enable HPTest block, 1KOhms check */ /* Enable HPTest block, 1KOhms check */
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_8, snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_8,
DA7219_HPTEST_EN_MASK | DA7219_HPTEST_RES_SEL_MASK, DA7219_HPTEST_EN_MASK | DA7219_HPTEST_RES_SEL_MASK,
DA7219_HPTEST_EN_MASK | DA7219_HPTEST_EN_MASK |
DA7219_HPTEST_RES_SEL_1KOHMS); DA7219_HPTEST_RES_SEL_1KOHMS);
/* Set gains to 0db */ /* Set gains to 0db */
snd_soc_write(codec, DA7219_DAC_L_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); snd_soc_component_write(component, DA7219_DAC_L_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB);
snd_soc_write(codec, DA7219_DAC_R_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); snd_soc_component_write(component, DA7219_DAC_R_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB);
snd_soc_write(codec, DA7219_HP_L_GAIN, DA7219_HP_AMP_GAIN_0DB); snd_soc_component_write(component, DA7219_HP_L_GAIN, DA7219_HP_AMP_GAIN_0DB);
snd_soc_write(codec, DA7219_HP_R_GAIN, DA7219_HP_AMP_GAIN_0DB); snd_soc_component_write(component, DA7219_HP_R_GAIN, DA7219_HP_AMP_GAIN_0DB);
/* Disable DAC filters, EQs and soft mute */ /* Disable DAC filters, EQs and soft mute */
snd_soc_update_bits(codec, DA7219_DAC_FILTERS1, DA7219_HPF_MODE_MASK, snd_soc_component_update_bits(component, DA7219_DAC_FILTERS1, DA7219_HPF_MODE_MASK,
0); 0);
snd_soc_update_bits(codec, DA7219_DAC_FILTERS4, DA7219_DAC_EQ_EN_MASK, snd_soc_component_update_bits(component, DA7219_DAC_FILTERS4, DA7219_DAC_EQ_EN_MASK,
0); 0);
snd_soc_update_bits(codec, DA7219_DAC_FILTERS5, snd_soc_component_update_bits(component, DA7219_DAC_FILTERS5,
DA7219_DAC_SOFTMUTE_EN_MASK, 0); DA7219_DAC_SOFTMUTE_EN_MASK, 0);
/* Enable HP left & right paths */ /* Enable HP left & right paths */
snd_soc_update_bits(codec, DA7219_CP_CTRL, DA7219_CP_EN_MASK, snd_soc_component_update_bits(component, DA7219_CP_CTRL, DA7219_CP_EN_MASK,
DA7219_CP_EN_MASK); DA7219_CP_EN_MASK);
snd_soc_update_bits(codec, DA7219_DIG_ROUTING_DAC, snd_soc_component_update_bits(component, DA7219_DIG_ROUTING_DAC,
DA7219_DAC_L_SRC_MASK | DA7219_DAC_R_SRC_MASK, DA7219_DAC_L_SRC_MASK | DA7219_DAC_R_SRC_MASK,
DA7219_DAC_L_SRC_TONEGEN | DA7219_DAC_L_SRC_TONEGEN |
DA7219_DAC_R_SRC_TONEGEN); DA7219_DAC_R_SRC_TONEGEN);
snd_soc_update_bits(codec, DA7219_DAC_L_CTRL, snd_soc_component_update_bits(component, DA7219_DAC_L_CTRL,
DA7219_DAC_L_EN_MASK | DA7219_DAC_L_MUTE_EN_MASK, DA7219_DAC_L_EN_MASK | DA7219_DAC_L_MUTE_EN_MASK,
DA7219_DAC_L_EN_MASK); DA7219_DAC_L_EN_MASK);
snd_soc_update_bits(codec, DA7219_DAC_R_CTRL, snd_soc_component_update_bits(component, DA7219_DAC_R_CTRL,
DA7219_DAC_R_EN_MASK | DA7219_DAC_R_MUTE_EN_MASK, DA7219_DAC_R_EN_MASK | DA7219_DAC_R_MUTE_EN_MASK,
DA7219_DAC_R_EN_MASK); DA7219_DAC_R_EN_MASK);
snd_soc_update_bits(codec, DA7219_MIXOUT_L_SELECT, snd_soc_component_update_bits(component, DA7219_MIXOUT_L_SELECT,
DA7219_MIXOUT_L_MIX_SELECT_MASK, DA7219_MIXOUT_L_MIX_SELECT_MASK,
DA7219_MIXOUT_L_MIX_SELECT_MASK); DA7219_MIXOUT_L_MIX_SELECT_MASK);
snd_soc_update_bits(codec, DA7219_MIXOUT_R_SELECT, snd_soc_component_update_bits(component, DA7219_MIXOUT_R_SELECT,
DA7219_MIXOUT_R_MIX_SELECT_MASK, DA7219_MIXOUT_R_MIX_SELECT_MASK,
DA7219_MIXOUT_R_MIX_SELECT_MASK); DA7219_MIXOUT_R_MIX_SELECT_MASK);
snd_soc_update_bits(codec, DA7219_DROUTING_ST_OUTFILT_1L, snd_soc_component_update_bits(component, DA7219_DROUTING_ST_OUTFILT_1L,
DA7219_OUTFILT_ST_1L_SRC_MASK, DA7219_OUTFILT_ST_1L_SRC_MASK,
DA7219_DMIX_ST_SRC_OUTFILT1L); DA7219_DMIX_ST_SRC_OUTFILT1L);
snd_soc_update_bits(codec, DA7219_DROUTING_ST_OUTFILT_1R, snd_soc_component_update_bits(component, DA7219_DROUTING_ST_OUTFILT_1R,
DA7219_OUTFILT_ST_1R_SRC_MASK, DA7219_OUTFILT_ST_1R_SRC_MASK,
DA7219_DMIX_ST_SRC_OUTFILT1R); DA7219_DMIX_ST_SRC_OUTFILT1R);
snd_soc_update_bits(codec, DA7219_MIXOUT_L_CTRL, snd_soc_component_update_bits(component, DA7219_MIXOUT_L_CTRL,
DA7219_MIXOUT_L_AMP_EN_MASK, DA7219_MIXOUT_L_AMP_EN_MASK,
DA7219_MIXOUT_L_AMP_EN_MASK); DA7219_MIXOUT_L_AMP_EN_MASK);
snd_soc_update_bits(codec, DA7219_MIXOUT_R_CTRL, snd_soc_component_update_bits(component, DA7219_MIXOUT_R_CTRL,
DA7219_MIXOUT_R_AMP_EN_MASK, DA7219_MIXOUT_R_AMP_EN_MASK,
DA7219_MIXOUT_R_AMP_EN_MASK); DA7219_MIXOUT_R_AMP_EN_MASK);
snd_soc_update_bits(codec, DA7219_HP_L_CTRL, snd_soc_component_update_bits(component, DA7219_HP_L_CTRL,
DA7219_HP_L_AMP_OE_MASK | DA7219_HP_L_AMP_EN_MASK, DA7219_HP_L_AMP_OE_MASK | DA7219_HP_L_AMP_EN_MASK,
DA7219_HP_L_AMP_OE_MASK | DA7219_HP_L_AMP_EN_MASK); DA7219_HP_L_AMP_OE_MASK | DA7219_HP_L_AMP_EN_MASK);
snd_soc_update_bits(codec, DA7219_HP_R_CTRL, snd_soc_component_update_bits(component, DA7219_HP_R_CTRL,
DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK, DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK,
DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK); DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK);
msleep(DA7219_SETTLING_DELAY); msleep(DA7219_SETTLING_DELAY);
snd_soc_update_bits(codec, DA7219_HP_L_CTRL, snd_soc_component_update_bits(component, DA7219_HP_L_CTRL,
DA7219_HP_L_AMP_MUTE_EN_MASK | DA7219_HP_L_AMP_MUTE_EN_MASK |
DA7219_HP_L_AMP_MIN_GAIN_EN_MASK, 0); DA7219_HP_L_AMP_MIN_GAIN_EN_MASK, 0);
snd_soc_update_bits(codec, DA7219_HP_R_CTRL, snd_soc_component_update_bits(component, DA7219_HP_R_CTRL,
DA7219_HP_R_AMP_MUTE_EN_MASK | DA7219_HP_R_AMP_MUTE_EN_MASK |
DA7219_HP_R_AMP_MIN_GAIN_EN_MASK, 0); DA7219_HP_R_AMP_MIN_GAIN_EN_MASK, 0);
...@@ -237,26 +237,26 @@ static void da7219_aad_hptest_work(struct work_struct *work) ...@@ -237,26 +237,26 @@ static void da7219_aad_hptest_work(struct work_struct *work)
msleep(DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY); msleep(DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY);
/* Configure & start Tone Generator */ /* Configure & start Tone Generator */
snd_soc_write(codec, DA7219_TONE_GEN_ON_PER, DA7219_BEEP_ON_PER_MASK); snd_soc_component_write(component, DA7219_TONE_GEN_ON_PER, DA7219_BEEP_ON_PER_MASK);
regmap_raw_write(da7219->regmap, DA7219_TONE_GEN_FREQ1_L, regmap_raw_write(da7219->regmap, DA7219_TONE_GEN_FREQ1_L,
&tonegen_freq_hptest, sizeof(tonegen_freq_hptest)); &tonegen_freq_hptest, sizeof(tonegen_freq_hptest));
snd_soc_update_bits(codec, DA7219_TONE_GEN_CFG2, snd_soc_component_update_bits(component, DA7219_TONE_GEN_CFG2,
DA7219_SWG_SEL_MASK | DA7219_TONE_GEN_GAIN_MASK, DA7219_SWG_SEL_MASK | DA7219_TONE_GEN_GAIN_MASK,
DA7219_SWG_SEL_SRAMP | DA7219_SWG_SEL_SRAMP |
DA7219_TONE_GEN_GAIN_MINUS_15DB); DA7219_TONE_GEN_GAIN_MINUS_15DB);
snd_soc_write(codec, DA7219_TONE_GEN_CFG1, DA7219_START_STOPN_MASK); snd_soc_component_write(component, DA7219_TONE_GEN_CFG1, DA7219_START_STOPN_MASK);
msleep(DA7219_AAD_HPTEST_PERIOD); msleep(DA7219_AAD_HPTEST_PERIOD);
/* Grab comparator reading */ /* Grab comparator reading */
accdet_cfg8 = snd_soc_read(codec, DA7219_ACCDET_CONFIG_8); accdet_cfg8 = snd_soc_component_read32(component, DA7219_ACCDET_CONFIG_8);
if (accdet_cfg8 & DA7219_HPTEST_COMP_MASK) if (accdet_cfg8 & DA7219_HPTEST_COMP_MASK)
report |= SND_JACK_HEADPHONE; report |= SND_JACK_HEADPHONE;
else else
report |= SND_JACK_LINEOUT; report |= SND_JACK_LINEOUT;
/* Stop tone generator */ /* Stop tone generator */
snd_soc_write(codec, DA7219_TONE_GEN_CFG1, 0); snd_soc_component_write(component, DA7219_TONE_GEN_CFG1, 0);
msleep(DA7219_AAD_HPTEST_PERIOD); msleep(DA7219_AAD_HPTEST_PERIOD);
...@@ -294,7 +294,7 @@ static void da7219_aad_hptest_work(struct work_struct *work) ...@@ -294,7 +294,7 @@ static void da7219_aad_hptest_work(struct work_struct *work)
regcache_cache_bypass(da7219->regmap, false); regcache_cache_bypass(da7219->regmap, false);
/* Disable HPTest block */ /* Disable HPTest block */
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_8, snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_8,
DA7219_HPTEST_EN_MASK, 0); DA7219_HPTEST_EN_MASK, 0);
/* /*
...@@ -305,18 +305,18 @@ static void da7219_aad_hptest_work(struct work_struct *work) ...@@ -305,18 +305,18 @@ static void da7219_aad_hptest_work(struct work_struct *work)
msleep(DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY); msleep(DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY);
/* Restore gain ramping rate */ /* Restore gain ramping rate */
snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, gain_ramp_ctrl); snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL, gain_ramp_ctrl);
/* Drive Headphones/lineout */ /* Drive Headphones/lineout */
snd_soc_update_bits(codec, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK,
DA7219_HP_L_AMP_OE_MASK); DA7219_HP_L_AMP_OE_MASK);
snd_soc_update_bits(codec, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK,
DA7219_HP_R_AMP_OE_MASK); DA7219_HP_R_AMP_OE_MASK);
/* Restore PLL to previous configuration, if re-configured */ /* Restore PLL to previous configuration, if re-configured */
if ((pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) && if ((pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) &&
((pll_ctrl & DA7219_PLL_MODE_MASK) == DA7219_PLL_MODE_BYPASS)) ((pll_ctrl & DA7219_PLL_MODE_MASK) == DA7219_PLL_MODE_BYPASS))
da7219_set_pll(codec, DA7219_SYSCLK_MCLK, 0); da7219_set_pll(component, DA7219_SYSCLK_MCLK, 0);
/* Remove MCLK, if previously enabled */ /* Remove MCLK, if previously enabled */
if (da7219->mclk) if (da7219->mclk)
...@@ -343,9 +343,9 @@ static void da7219_aad_hptest_work(struct work_struct *work) ...@@ -343,9 +343,9 @@ static void da7219_aad_hptest_work(struct work_struct *work)
static irqreturn_t da7219_aad_irq_thread(int irq, void *data) static irqreturn_t da7219_aad_irq_thread(int irq, void *data)
{ {
struct da7219_aad_priv *da7219_aad = data; struct da7219_aad_priv *da7219_aad = data;
struct snd_soc_codec *codec = da7219_aad->codec; struct snd_soc_component *component = da7219_aad->component;
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
u8 events[DA7219_AAD_IRQ_REG_MAX]; u8 events[DA7219_AAD_IRQ_REG_MAX];
u8 statusa; u8 statusa;
int i, report = 0, mask = 0; int i, report = 0, mask = 0;
...@@ -358,13 +358,13 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data) ...@@ -358,13 +358,13 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data)
return IRQ_NONE; return IRQ_NONE;
/* Read status register for jack insertion & type status */ /* Read status register for jack insertion & type status */
statusa = snd_soc_read(codec, DA7219_ACCDET_STATUS_A); statusa = snd_soc_component_read32(component, DA7219_ACCDET_STATUS_A);
/* Clear events */ /* Clear events */
regmap_bulk_write(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A, regmap_bulk_write(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A,
events, DA7219_AAD_IRQ_REG_MAX); events, DA7219_AAD_IRQ_REG_MAX);
dev_dbg(codec->dev, "IRQ events = 0x%x|0x%x, status = 0x%x\n", dev_dbg(component->dev, "IRQ events = 0x%x|0x%x, status = 0x%x\n",
events[DA7219_AAD_IRQ_REG_A], events[DA7219_AAD_IRQ_REG_B], events[DA7219_AAD_IRQ_REG_A], events[DA7219_AAD_IRQ_REG_B],
statusa); statusa);
...@@ -430,13 +430,13 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data) ...@@ -430,13 +430,13 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data)
da7219_aad->jack_inserted = false; da7219_aad->jack_inserted = false;
/* Un-drive headphones/lineout */ /* Un-drive headphones/lineout */
snd_soc_update_bits(codec, DA7219_HP_R_CTRL, snd_soc_component_update_bits(component, DA7219_HP_R_CTRL,
DA7219_HP_R_AMP_OE_MASK, 0); DA7219_HP_R_AMP_OE_MASK, 0);
snd_soc_update_bits(codec, DA7219_HP_L_CTRL, snd_soc_component_update_bits(component, DA7219_HP_L_CTRL,
DA7219_HP_L_AMP_OE_MASK, 0); DA7219_HP_L_AMP_OE_MASK, 0);
/* Ensure button detection disabled */ /* Ensure button detection disabled */
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1,
DA7219_BUTTON_CONFIG_MASK, 0); DA7219_BUTTON_CONFIG_MASK, 0);
/* Disable mic bias */ /* Disable mic bias */
...@@ -459,7 +459,7 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data) ...@@ -459,7 +459,7 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data)
*/ */
static enum da7219_aad_micbias_pulse_lvl static enum da7219_aad_micbias_pulse_lvl
da7219_aad_fw_micbias_pulse_lvl(struct snd_soc_codec *codec, u32 val) da7219_aad_fw_micbias_pulse_lvl(struct snd_soc_component *component, u32 val)
{ {
switch (val) { switch (val) {
case 2800: case 2800:
...@@ -467,13 +467,13 @@ static enum da7219_aad_micbias_pulse_lvl ...@@ -467,13 +467,13 @@ static enum da7219_aad_micbias_pulse_lvl
case 2900: case 2900:
return DA7219_AAD_MICBIAS_PULSE_LVL_2_9V; return DA7219_AAD_MICBIAS_PULSE_LVL_2_9V;
default: default:
dev_warn(codec->dev, "Invalid micbias pulse level"); dev_warn(component->dev, "Invalid micbias pulse level");
return DA7219_AAD_MICBIAS_PULSE_LVL_OFF; return DA7219_AAD_MICBIAS_PULSE_LVL_OFF;
} }
} }
static enum da7219_aad_btn_cfg static enum da7219_aad_btn_cfg
da7219_aad_fw_btn_cfg(struct snd_soc_codec *codec, u32 val) da7219_aad_fw_btn_cfg(struct snd_soc_component *component, u32 val)
{ {
switch (val) { switch (val) {
case 2: case 2:
...@@ -491,13 +491,13 @@ static enum da7219_aad_btn_cfg ...@@ -491,13 +491,13 @@ static enum da7219_aad_btn_cfg
case 500: case 500:
return DA7219_AAD_BTN_CFG_500MS; return DA7219_AAD_BTN_CFG_500MS;
default: default:
dev_warn(codec->dev, "Invalid button config"); dev_warn(component->dev, "Invalid button config");
return DA7219_AAD_BTN_CFG_10MS; return DA7219_AAD_BTN_CFG_10MS;
} }
} }
static enum da7219_aad_mic_det_thr static enum da7219_aad_mic_det_thr
da7219_aad_fw_mic_det_thr(struct snd_soc_codec *codec, u32 val) da7219_aad_fw_mic_det_thr(struct snd_soc_component *component, u32 val)
{ {
switch (val) { switch (val) {
case 200: case 200:
...@@ -509,13 +509,13 @@ static enum da7219_aad_mic_det_thr ...@@ -509,13 +509,13 @@ static enum da7219_aad_mic_det_thr
case 1000: case 1000:
return DA7219_AAD_MIC_DET_THR_1000_OHMS; return DA7219_AAD_MIC_DET_THR_1000_OHMS;
default: default:
dev_warn(codec->dev, "Invalid mic detect threshold"); dev_warn(component->dev, "Invalid mic detect threshold");
return DA7219_AAD_MIC_DET_THR_500_OHMS; return DA7219_AAD_MIC_DET_THR_500_OHMS;
} }
} }
static enum da7219_aad_jack_ins_deb static enum da7219_aad_jack_ins_deb
da7219_aad_fw_jack_ins_deb(struct snd_soc_codec *codec, u32 val) da7219_aad_fw_jack_ins_deb(struct snd_soc_component *component, u32 val)
{ {
switch (val) { switch (val) {
case 5: case 5:
...@@ -535,13 +535,13 @@ static enum da7219_aad_jack_ins_deb ...@@ -535,13 +535,13 @@ static enum da7219_aad_jack_ins_deb
case 1000: case 1000:
return DA7219_AAD_JACK_INS_DEB_1S; return DA7219_AAD_JACK_INS_DEB_1S;
default: default:
dev_warn(codec->dev, "Invalid jack insert debounce"); dev_warn(component->dev, "Invalid jack insert debounce");
return DA7219_AAD_JACK_INS_DEB_20MS; return DA7219_AAD_JACK_INS_DEB_20MS;
} }
} }
static enum da7219_aad_jack_det_rate static enum da7219_aad_jack_det_rate
da7219_aad_fw_jack_det_rate(struct snd_soc_codec *codec, const char *str) da7219_aad_fw_jack_det_rate(struct snd_soc_component *component, const char *str)
{ {
if (!strcmp(str, "32ms_64ms")) { if (!strcmp(str, "32ms_64ms")) {
return DA7219_AAD_JACK_DET_RATE_32_64MS; return DA7219_AAD_JACK_DET_RATE_32_64MS;
...@@ -552,13 +552,13 @@ static enum da7219_aad_jack_det_rate ...@@ -552,13 +552,13 @@ static enum da7219_aad_jack_det_rate
} else if (!strcmp(str, "256ms_512ms")) { } else if (!strcmp(str, "256ms_512ms")) {
return DA7219_AAD_JACK_DET_RATE_256_512MS; return DA7219_AAD_JACK_DET_RATE_256_512MS;
} else { } else {
dev_warn(codec->dev, "Invalid jack detect rate"); dev_warn(component->dev, "Invalid jack detect rate");
return DA7219_AAD_JACK_DET_RATE_256_512MS; return DA7219_AAD_JACK_DET_RATE_256_512MS;
} }
} }
static enum da7219_aad_jack_rem_deb static enum da7219_aad_jack_rem_deb
da7219_aad_fw_jack_rem_deb(struct snd_soc_codec *codec, u32 val) da7219_aad_fw_jack_rem_deb(struct snd_soc_component *component, u32 val)
{ {
switch (val) { switch (val) {
case 1: case 1:
...@@ -570,13 +570,13 @@ static enum da7219_aad_jack_rem_deb ...@@ -570,13 +570,13 @@ static enum da7219_aad_jack_rem_deb
case 20: case 20:
return DA7219_AAD_JACK_REM_DEB_20MS; return DA7219_AAD_JACK_REM_DEB_20MS;
default: default:
dev_warn(codec->dev, "Invalid jack removal debounce"); dev_warn(component->dev, "Invalid jack removal debounce");
return DA7219_AAD_JACK_REM_DEB_1MS; return DA7219_AAD_JACK_REM_DEB_1MS;
} }
} }
static enum da7219_aad_btn_avg static enum da7219_aad_btn_avg
da7219_aad_fw_btn_avg(struct snd_soc_codec *codec, u32 val) da7219_aad_fw_btn_avg(struct snd_soc_component *component, u32 val)
{ {
switch (val) { switch (val) {
case 1: case 1:
...@@ -588,13 +588,13 @@ static enum da7219_aad_btn_avg ...@@ -588,13 +588,13 @@ static enum da7219_aad_btn_avg
case 8: case 8:
return DA7219_AAD_BTN_AVG_8; return DA7219_AAD_BTN_AVG_8;
default: default:
dev_warn(codec->dev, "Invalid button average value"); dev_warn(component->dev, "Invalid button average value");
return DA7219_AAD_BTN_AVG_2; return DA7219_AAD_BTN_AVG_2;
} }
} }
static enum da7219_aad_adc_1bit_rpt static enum da7219_aad_adc_1bit_rpt
da7219_aad_fw_adc_1bit_rpt(struct snd_soc_codec *codec, u32 val) da7219_aad_fw_adc_1bit_rpt(struct snd_soc_component *component, u32 val)
{ {
switch (val) { switch (val) {
case 1: case 1:
...@@ -606,14 +606,14 @@ static enum da7219_aad_adc_1bit_rpt ...@@ -606,14 +606,14 @@ static enum da7219_aad_adc_1bit_rpt
case 8: case 8:
return DA7219_AAD_ADC_1BIT_RPT_8; return DA7219_AAD_ADC_1BIT_RPT_8;
default: default:
dev_warn(codec->dev, "Invalid ADC 1-bit repeat value"); dev_warn(component->dev, "Invalid ADC 1-bit repeat value");
return DA7219_AAD_ADC_1BIT_RPT_1; return DA7219_AAD_ADC_1BIT_RPT_1;
} }
} }
static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *codec) static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_component *component)
{ {
struct device *dev = codec->dev; struct device *dev = component->dev;
struct i2c_client *i2c = to_i2c_client(dev); struct i2c_client *i2c = to_i2c_client(dev);
struct fwnode_handle *aad_np; struct fwnode_handle *aad_np;
struct da7219_aad_pdata *aad_pdata; struct da7219_aad_pdata *aad_pdata;
...@@ -624,7 +624,7 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod ...@@ -624,7 +624,7 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod
if (!aad_np) if (!aad_np)
return NULL; return NULL;
aad_pdata = devm_kzalloc(codec->dev, sizeof(*aad_pdata), GFP_KERNEL); aad_pdata = devm_kzalloc(dev, sizeof(*aad_pdata), GFP_KERNEL);
if (!aad_pdata) if (!aad_pdata)
return NULL; return NULL;
...@@ -633,7 +633,7 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod ...@@ -633,7 +633,7 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod
if (fwnode_property_read_u32(aad_np, "dlg,micbias-pulse-lvl", if (fwnode_property_read_u32(aad_np, "dlg,micbias-pulse-lvl",
&fw_val32) >= 0) &fw_val32) >= 0)
aad_pdata->micbias_pulse_lvl = aad_pdata->micbias_pulse_lvl =
da7219_aad_fw_micbias_pulse_lvl(codec, fw_val32); da7219_aad_fw_micbias_pulse_lvl(component, fw_val32);
else else
aad_pdata->micbias_pulse_lvl = DA7219_AAD_MICBIAS_PULSE_LVL_OFF; aad_pdata->micbias_pulse_lvl = DA7219_AAD_MICBIAS_PULSE_LVL_OFF;
...@@ -642,31 +642,31 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod ...@@ -642,31 +642,31 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod
aad_pdata->micbias_pulse_time = fw_val32; aad_pdata->micbias_pulse_time = fw_val32;
if (fwnode_property_read_u32(aad_np, "dlg,btn-cfg", &fw_val32) >= 0) if (fwnode_property_read_u32(aad_np, "dlg,btn-cfg", &fw_val32) >= 0)
aad_pdata->btn_cfg = da7219_aad_fw_btn_cfg(codec, fw_val32); aad_pdata->btn_cfg = da7219_aad_fw_btn_cfg(component, fw_val32);
else else
aad_pdata->btn_cfg = DA7219_AAD_BTN_CFG_10MS; aad_pdata->btn_cfg = DA7219_AAD_BTN_CFG_10MS;
if (fwnode_property_read_u32(aad_np, "dlg,mic-det-thr", &fw_val32) >= 0) if (fwnode_property_read_u32(aad_np, "dlg,mic-det-thr", &fw_val32) >= 0)
aad_pdata->mic_det_thr = aad_pdata->mic_det_thr =
da7219_aad_fw_mic_det_thr(codec, fw_val32); da7219_aad_fw_mic_det_thr(component, fw_val32);
else else
aad_pdata->mic_det_thr = DA7219_AAD_MIC_DET_THR_500_OHMS; aad_pdata->mic_det_thr = DA7219_AAD_MIC_DET_THR_500_OHMS;
if (fwnode_property_read_u32(aad_np, "dlg,jack-ins-deb", &fw_val32) >= 0) if (fwnode_property_read_u32(aad_np, "dlg,jack-ins-deb", &fw_val32) >= 0)
aad_pdata->jack_ins_deb = aad_pdata->jack_ins_deb =
da7219_aad_fw_jack_ins_deb(codec, fw_val32); da7219_aad_fw_jack_ins_deb(component, fw_val32);
else else
aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS; aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS;
if (!fwnode_property_read_string(aad_np, "dlg,jack-det-rate", &fw_str)) if (!fwnode_property_read_string(aad_np, "dlg,jack-det-rate", &fw_str))
aad_pdata->jack_det_rate = aad_pdata->jack_det_rate =
da7219_aad_fw_jack_det_rate(codec, fw_str); da7219_aad_fw_jack_det_rate(component, fw_str);
else else
aad_pdata->jack_det_rate = DA7219_AAD_JACK_DET_RATE_256_512MS; aad_pdata->jack_det_rate = DA7219_AAD_JACK_DET_RATE_256_512MS;
if (fwnode_property_read_u32(aad_np, "dlg,jack-rem-deb", &fw_val32) >= 0) if (fwnode_property_read_u32(aad_np, "dlg,jack-rem-deb", &fw_val32) >= 0)
aad_pdata->jack_rem_deb = aad_pdata->jack_rem_deb =
da7219_aad_fw_jack_rem_deb(codec, fw_val32); da7219_aad_fw_jack_rem_deb(component, fw_val32);
else else
aad_pdata->jack_rem_deb = DA7219_AAD_JACK_REM_DEB_1MS; aad_pdata->jack_rem_deb = DA7219_AAD_JACK_REM_DEB_1MS;
...@@ -691,22 +691,22 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod ...@@ -691,22 +691,22 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod
aad_pdata->c_mic_btn_thr = 0x3E; aad_pdata->c_mic_btn_thr = 0x3E;
if (fwnode_property_read_u32(aad_np, "dlg,btn-avg", &fw_val32) >= 0) if (fwnode_property_read_u32(aad_np, "dlg,btn-avg", &fw_val32) >= 0)
aad_pdata->btn_avg = da7219_aad_fw_btn_avg(codec, fw_val32); aad_pdata->btn_avg = da7219_aad_fw_btn_avg(component, fw_val32);
else else
aad_pdata->btn_avg = DA7219_AAD_BTN_AVG_2; aad_pdata->btn_avg = DA7219_AAD_BTN_AVG_2;
if (fwnode_property_read_u32(aad_np, "dlg,adc-1bit-rpt", &fw_val32) >= 0) if (fwnode_property_read_u32(aad_np, "dlg,adc-1bit-rpt", &fw_val32) >= 0)
aad_pdata->adc_1bit_rpt = aad_pdata->adc_1bit_rpt =
da7219_aad_fw_adc_1bit_rpt(codec, fw_val32); da7219_aad_fw_adc_1bit_rpt(component, fw_val32);
else else
aad_pdata->adc_1bit_rpt = DA7219_AAD_ADC_1BIT_RPT_1; aad_pdata->adc_1bit_rpt = DA7219_AAD_ADC_1BIT_RPT_1;
return aad_pdata; return aad_pdata;
} }
static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) static void da7219_aad_handle_pdata(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
struct da7219_aad_priv *da7219_aad = da7219->aad; struct da7219_aad_priv *da7219_aad = da7219->aad;
struct da7219_pdata *pdata = da7219->pdata; struct da7219_pdata *pdata = da7219->pdata;
...@@ -752,7 +752,7 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) ...@@ -752,7 +752,7 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec)
DA7219_MIC_DET_THRESH_SHIFT); DA7219_MIC_DET_THRESH_SHIFT);
mask |= DA7219_MIC_DET_THRESH_MASK; mask |= DA7219_MIC_DET_THRESH_MASK;
} }
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, mask, cfg); snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, mask, cfg);
cfg = 0; cfg = 0;
mask = 0; mask = 0;
...@@ -787,15 +787,15 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) ...@@ -787,15 +787,15 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec)
DA7219_JACKDET_REM_DEB_SHIFT); DA7219_JACKDET_REM_DEB_SHIFT);
mask |= DA7219_JACKDET_REM_DEB_MASK; mask |= DA7219_JACKDET_REM_DEB_MASK;
} }
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_2, mask, cfg); snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_2, mask, cfg);
snd_soc_write(codec, DA7219_ACCDET_CONFIG_3, snd_soc_component_write(component, DA7219_ACCDET_CONFIG_3,
aad_pdata->a_d_btn_thr); aad_pdata->a_d_btn_thr);
snd_soc_write(codec, DA7219_ACCDET_CONFIG_4, snd_soc_component_write(component, DA7219_ACCDET_CONFIG_4,
aad_pdata->d_b_btn_thr); aad_pdata->d_b_btn_thr);
snd_soc_write(codec, DA7219_ACCDET_CONFIG_5, snd_soc_component_write(component, DA7219_ACCDET_CONFIG_5,
aad_pdata->b_c_btn_thr); aad_pdata->b_c_btn_thr);
snd_soc_write(codec, DA7219_ACCDET_CONFIG_6, snd_soc_component_write(component, DA7219_ACCDET_CONFIG_6,
aad_pdata->c_mic_btn_thr); aad_pdata->c_mic_btn_thr);
cfg = 0; cfg = 0;
...@@ -818,7 +818,7 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) ...@@ -818,7 +818,7 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec)
DA7219_ADC_1_BIT_REPEAT_SHIFT); DA7219_ADC_1_BIT_REPEAT_SHIFT);
mask |= DA7219_ADC_1_BIT_REPEAT_MASK; mask |= DA7219_ADC_1_BIT_REPEAT_MASK;
} }
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_7, mask, cfg); snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_7, mask, cfg);
} }
} }
...@@ -827,16 +827,16 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) ...@@ -827,16 +827,16 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec)
* Suspend/Resume * Suspend/Resume
*/ */
void da7219_aad_suspend(struct snd_soc_codec *codec) void da7219_aad_suspend(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
struct da7219_aad_priv *da7219_aad = da7219->aad; struct da7219_aad_priv *da7219_aad = da7219->aad;
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
u8 micbias_ctrl; u8 micbias_ctrl;
if (da7219_aad->jack) { if (da7219_aad->jack) {
/* Disable jack detection during suspend */ /* Disable jack detection during suspend */
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1,
DA7219_ACCDET_EN_MASK, 0); DA7219_ACCDET_EN_MASK, 0);
/* /*
...@@ -846,7 +846,7 @@ void da7219_aad_suspend(struct snd_soc_codec *codec) ...@@ -846,7 +846,7 @@ void da7219_aad_suspend(struct snd_soc_codec *codec)
* suspend then this will be dealt with through the IRQ handler. * suspend then this will be dealt with through the IRQ handler.
*/ */
if (da7219_aad->jack_inserted) { if (da7219_aad->jack_inserted) {
micbias_ctrl = snd_soc_read(codec, DA7219_MICBIAS_CTRL); micbias_ctrl = snd_soc_component_read32(component, DA7219_MICBIAS_CTRL);
if (micbias_ctrl & DA7219_MICBIAS1_EN_MASK) { if (micbias_ctrl & DA7219_MICBIAS1_EN_MASK) {
snd_soc_dapm_disable_pin(dapm, "Mic Bias"); snd_soc_dapm_disable_pin(dapm, "Mic Bias");
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
...@@ -856,11 +856,11 @@ void da7219_aad_suspend(struct snd_soc_codec *codec) ...@@ -856,11 +856,11 @@ void da7219_aad_suspend(struct snd_soc_codec *codec)
} }
} }
void da7219_aad_resume(struct snd_soc_codec *codec) void da7219_aad_resume(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
struct da7219_aad_priv *da7219_aad = da7219->aad; struct da7219_aad_priv *da7219_aad = da7219->aad;
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
if (da7219_aad->jack) { if (da7219_aad->jack) {
/* Re-enable micbias if previously enabled for 4-pole jack */ /* Re-enable micbias if previously enabled for 4-pole jack */
...@@ -872,7 +872,7 @@ void da7219_aad_resume(struct snd_soc_codec *codec) ...@@ -872,7 +872,7 @@ void da7219_aad_resume(struct snd_soc_codec *codec)
} }
/* Re-enable jack detection */ /* Re-enable jack detection */
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1,
DA7219_ACCDET_EN_MASK, DA7219_ACCDET_EN_MASK,
DA7219_ACCDET_EN_MASK); DA7219_ACCDET_EN_MASK);
} }
...@@ -883,28 +883,28 @@ void da7219_aad_resume(struct snd_soc_codec *codec) ...@@ -883,28 +883,28 @@ void da7219_aad_resume(struct snd_soc_codec *codec)
* Init/Exit * Init/Exit
*/ */
int da7219_aad_init(struct snd_soc_codec *codec) int da7219_aad_init(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
struct da7219_aad_priv *da7219_aad; struct da7219_aad_priv *da7219_aad;
u8 mask[DA7219_AAD_IRQ_REG_MAX]; u8 mask[DA7219_AAD_IRQ_REG_MAX];
int ret; int ret;
da7219_aad = devm_kzalloc(codec->dev, sizeof(*da7219_aad), GFP_KERNEL); da7219_aad = devm_kzalloc(component->dev, sizeof(*da7219_aad), GFP_KERNEL);
if (!da7219_aad) if (!da7219_aad)
return -ENOMEM; return -ENOMEM;
da7219->aad = da7219_aad; da7219->aad = da7219_aad;
da7219_aad->codec = codec; da7219_aad->component = component;
/* Handle any DT/ACPI/platform data */ /* Handle any DT/ACPI/platform data */
if (da7219->pdata && !da7219->pdata->aad_pdata) if (da7219->pdata && !da7219->pdata->aad_pdata)
da7219->pdata->aad_pdata = da7219_aad_fw_to_pdata(codec); da7219->pdata->aad_pdata = da7219_aad_fw_to_pdata(component);
da7219_aad_handle_pdata(codec); da7219_aad_handle_pdata(component);
/* Disable button detection */ /* Disable button detection */
snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1,
DA7219_BUTTON_CONFIG_MASK, 0); DA7219_BUTTON_CONFIG_MASK, 0);
INIT_WORK(&da7219_aad->btn_det_work, da7219_aad_btn_det_work); INIT_WORK(&da7219_aad->btn_det_work, da7219_aad_btn_det_work);
...@@ -915,7 +915,7 @@ int da7219_aad_init(struct snd_soc_codec *codec) ...@@ -915,7 +915,7 @@ int da7219_aad_init(struct snd_soc_codec *codec)
IRQF_TRIGGER_LOW | IRQF_ONESHOT, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
"da7219-aad", da7219_aad); "da7219-aad", da7219_aad);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to request IRQ: %d\n", ret); dev_err(component->dev, "Failed to request IRQ: %d\n", ret);
return ret; return ret;
} }
...@@ -928,9 +928,9 @@ int da7219_aad_init(struct snd_soc_codec *codec) ...@@ -928,9 +928,9 @@ int da7219_aad_init(struct snd_soc_codec *codec)
} }
EXPORT_SYMBOL_GPL(da7219_aad_init); EXPORT_SYMBOL_GPL(da7219_aad_init);
void da7219_aad_exit(struct snd_soc_codec *codec) void da7219_aad_exit(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
struct da7219_aad_priv *da7219_aad = da7219->aad; struct da7219_aad_priv *da7219_aad = da7219->aad;
u8 mask[DA7219_AAD_IRQ_REG_MAX]; u8 mask[DA7219_AAD_IRQ_REG_MAX];
......
...@@ -189,7 +189,7 @@ enum da7219_aad_event_regs { ...@@ -189,7 +189,7 @@ enum da7219_aad_event_regs {
/* Private data */ /* Private data */
struct da7219_aad_priv { struct da7219_aad_priv {
struct snd_soc_codec *codec; struct snd_soc_component *component;
int irq; int irq;
u8 micbias_pulse_lvl; u8 micbias_pulse_lvl;
...@@ -206,14 +206,14 @@ struct da7219_aad_priv { ...@@ -206,14 +206,14 @@ struct da7219_aad_priv {
}; };
/* AAD control */ /* AAD control */
void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack); void da7219_aad_jack_det(struct snd_soc_component *component, struct snd_soc_jack *jack);
/* Suspend/Resume */ /* Suspend/Resume */
void da7219_aad_suspend(struct snd_soc_codec *codec); void da7219_aad_suspend(struct snd_soc_component *component);
void da7219_aad_resume(struct snd_soc_codec *codec); void da7219_aad_resume(struct snd_soc_component *component);
/* Init/Exit */ /* Init/Exit */
int da7219_aad_init(struct snd_soc_codec *codec); int da7219_aad_init(struct snd_soc_component *component);
void da7219_aad_exit(struct snd_soc_codec *codec); void da7219_aad_exit(struct snd_soc_component *component);
#endif /* __DA7219_AAD_H */ #endif /* __DA7219_AAD_H */
...@@ -256,8 +256,8 @@ static const struct soc_enum da7219_cp_track_mode = ...@@ -256,8 +256,8 @@ static const struct soc_enum da7219_cp_track_mode =
static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol, static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
int ret; int ret;
mutex_lock(&da7219->ctrl_lock); mutex_lock(&da7219->ctrl_lock);
...@@ -270,8 +270,8 @@ static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol, ...@@ -270,8 +270,8 @@ static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol,
static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol, static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
int ret; int ret;
mutex_lock(&da7219->ctrl_lock); mutex_lock(&da7219->ctrl_lock);
...@@ -284,8 +284,8 @@ static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol, ...@@ -284,8 +284,8 @@ static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol,
static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol, static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
int ret; int ret;
mutex_lock(&da7219->ctrl_lock); mutex_lock(&da7219->ctrl_lock);
...@@ -298,8 +298,8 @@ static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol, ...@@ -298,8 +298,8 @@ static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol,
static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol, static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
int ret; int ret;
mutex_lock(&da7219->ctrl_lock); mutex_lock(&da7219->ctrl_lock);
...@@ -310,55 +310,55 @@ static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol, ...@@ -310,55 +310,55 @@ static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol,
} }
/* ALC */ /* ALC */
static void da7219_alc_calib(struct snd_soc_codec *codec) static void da7219_alc_calib(struct snd_soc_component *component)
{ {
u8 mic_ctrl, mixin_ctrl, adc_ctrl, calib_ctrl; u8 mic_ctrl, mixin_ctrl, adc_ctrl, calib_ctrl;
/* Save current state of mic control register */ /* Save current state of mic control register */
mic_ctrl = snd_soc_read(codec, DA7219_MIC_1_CTRL); mic_ctrl = snd_soc_component_read32(component, DA7219_MIC_1_CTRL);
/* Save current state of input mixer control register */ /* Save current state of input mixer control register */
mixin_ctrl = snd_soc_read(codec, DA7219_MIXIN_L_CTRL); mixin_ctrl = snd_soc_component_read32(component, DA7219_MIXIN_L_CTRL);
/* Save current state of input ADC control register */ /* Save current state of input ADC control register */
adc_ctrl = snd_soc_read(codec, DA7219_ADC_L_CTRL); adc_ctrl = snd_soc_component_read32(component, DA7219_ADC_L_CTRL);
/* Enable then Mute MIC PGAs */ /* Enable then Mute MIC PGAs */
snd_soc_update_bits(codec, DA7219_MIC_1_CTRL, DA7219_MIC_1_AMP_EN_MASK, snd_soc_component_update_bits(component, DA7219_MIC_1_CTRL, DA7219_MIC_1_AMP_EN_MASK,
DA7219_MIC_1_AMP_EN_MASK); DA7219_MIC_1_AMP_EN_MASK);
snd_soc_update_bits(codec, DA7219_MIC_1_CTRL, snd_soc_component_update_bits(component, DA7219_MIC_1_CTRL,
DA7219_MIC_1_AMP_MUTE_EN_MASK, DA7219_MIC_1_AMP_MUTE_EN_MASK,
DA7219_MIC_1_AMP_MUTE_EN_MASK); DA7219_MIC_1_AMP_MUTE_EN_MASK);
/* Enable input mixers unmuted */ /* Enable input mixers unmuted */
snd_soc_update_bits(codec, DA7219_MIXIN_L_CTRL, snd_soc_component_update_bits(component, DA7219_MIXIN_L_CTRL,
DA7219_MIXIN_L_AMP_EN_MASK | DA7219_MIXIN_L_AMP_EN_MASK |
DA7219_MIXIN_L_AMP_MUTE_EN_MASK, DA7219_MIXIN_L_AMP_MUTE_EN_MASK,
DA7219_MIXIN_L_AMP_EN_MASK); DA7219_MIXIN_L_AMP_EN_MASK);
/* Enable input filters unmuted */ /* Enable input filters unmuted */
snd_soc_update_bits(codec, DA7219_ADC_L_CTRL, snd_soc_component_update_bits(component, DA7219_ADC_L_CTRL,
DA7219_ADC_L_MUTE_EN_MASK | DA7219_ADC_L_EN_MASK, DA7219_ADC_L_MUTE_EN_MASK | DA7219_ADC_L_EN_MASK,
DA7219_ADC_L_EN_MASK); DA7219_ADC_L_EN_MASK);
/* Perform auto calibration */ /* Perform auto calibration */
snd_soc_update_bits(codec, DA7219_ALC_CTRL1, snd_soc_component_update_bits(component, DA7219_ALC_CTRL1,
DA7219_ALC_AUTO_CALIB_EN_MASK, DA7219_ALC_AUTO_CALIB_EN_MASK,
DA7219_ALC_AUTO_CALIB_EN_MASK); DA7219_ALC_AUTO_CALIB_EN_MASK);
do { do {
calib_ctrl = snd_soc_read(codec, DA7219_ALC_CTRL1); calib_ctrl = snd_soc_component_read32(component, DA7219_ALC_CTRL1);
} while (calib_ctrl & DA7219_ALC_AUTO_CALIB_EN_MASK); } while (calib_ctrl & DA7219_ALC_AUTO_CALIB_EN_MASK);
/* If auto calibration fails, disable DC offset, hybrid ALC */ /* If auto calibration fails, disable DC offset, hybrid ALC */
if (calib_ctrl & DA7219_ALC_CALIB_OVERFLOW_MASK) { if (calib_ctrl & DA7219_ALC_CALIB_OVERFLOW_MASK) {
dev_warn(codec->dev, dev_warn(component->dev,
"ALC auto calibration failed with overflow\n"); "ALC auto calibration failed with overflow\n");
snd_soc_update_bits(codec, DA7219_ALC_CTRL1, snd_soc_component_update_bits(component, DA7219_ALC_CTRL1,
DA7219_ALC_OFFSET_EN_MASK | DA7219_ALC_OFFSET_EN_MASK |
DA7219_ALC_SYNC_MODE_MASK, 0); DA7219_ALC_SYNC_MODE_MASK, 0);
} else { } else {
/* Enable DC offset cancellation, hybrid mode */ /* Enable DC offset cancellation, hybrid mode */
snd_soc_update_bits(codec, DA7219_ALC_CTRL1, snd_soc_component_update_bits(component, DA7219_ALC_CTRL1,
DA7219_ALC_OFFSET_EN_MASK | DA7219_ALC_OFFSET_EN_MASK |
DA7219_ALC_SYNC_MODE_MASK, DA7219_ALC_SYNC_MODE_MASK,
DA7219_ALC_OFFSET_EN_MASK | DA7219_ALC_OFFSET_EN_MASK |
...@@ -366,20 +366,20 @@ static void da7219_alc_calib(struct snd_soc_codec *codec) ...@@ -366,20 +366,20 @@ static void da7219_alc_calib(struct snd_soc_codec *codec)
} }
/* Restore input filter control register to original state */ /* Restore input filter control register to original state */
snd_soc_write(codec, DA7219_ADC_L_CTRL, adc_ctrl); snd_soc_component_write(component, DA7219_ADC_L_CTRL, adc_ctrl);
/* Restore input mixer control registers to original state */ /* Restore input mixer control registers to original state */
snd_soc_write(codec, DA7219_MIXIN_L_CTRL, mixin_ctrl); snd_soc_component_write(component, DA7219_MIXIN_L_CTRL, mixin_ctrl);
/* Restore MIC control registers to original states */ /* Restore MIC control registers to original states */
snd_soc_write(codec, DA7219_MIC_1_CTRL, mic_ctrl); snd_soc_component_write(component, DA7219_MIC_1_CTRL, mic_ctrl);
} }
static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
int ret; int ret;
ret = snd_soc_put_volsw(kcontrol, ucontrol); ret = snd_soc_put_volsw(kcontrol, ucontrol);
...@@ -389,7 +389,7 @@ static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, ...@@ -389,7 +389,7 @@ static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol,
* make sure calibrated offsets are updated. * make sure calibrated offsets are updated.
*/ */
if ((ret == 1) && (da7219->alc_en)) if ((ret == 1) && (da7219->alc_en))
da7219_alc_calib(codec); da7219_alc_calib(component);
return ret; return ret;
} }
...@@ -397,13 +397,13 @@ static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, ...@@ -397,13 +397,13 @@ static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol,
static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol, static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
/* Force ALC offset calibration if enabling ALC */ /* Force ALC offset calibration if enabling ALC */
if ((ucontrol->value.integer.value[0]) && (!da7219->alc_en)) { if ((ucontrol->value.integer.value[0]) && (!da7219->alc_en)) {
da7219_alc_calib(codec); da7219_alc_calib(component);
da7219->alc_en = true; da7219->alc_en = true;
} else { } else {
da7219->alc_en = false; da7219->alc_en = false;
...@@ -416,8 +416,8 @@ static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol, ...@@ -416,8 +416,8 @@ static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol,
static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol, static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
struct soc_mixer_control *mixer_ctrl = struct soc_mixer_control *mixer_ctrl =
(struct soc_mixer_control *) kcontrol->private_value; (struct soc_mixer_control *) kcontrol->private_value;
unsigned int reg = mixer_ctrl->reg; unsigned int reg = mixer_ctrl->reg;
...@@ -443,8 +443,8 @@ static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol, ...@@ -443,8 +443,8 @@ static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol,
static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol, static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
struct soc_mixer_control *mixer_ctrl = struct soc_mixer_control *mixer_ctrl =
(struct soc_mixer_control *) kcontrol->private_value; (struct soc_mixer_control *) kcontrol->private_value;
unsigned int reg = mixer_ctrl->reg; unsigned int reg = mixer_ctrl->reg;
...@@ -769,8 +769,8 @@ static const struct snd_kcontrol_new da7219_st_out_filtr_mix_controls[] = { ...@@ -769,8 +769,8 @@ static const struct snd_kcontrol_new da7219_st_out_filtr_mix_controls[] = {
static int da7219_dai_event(struct snd_soc_dapm_widget *w, static int da7219_dai_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 da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
u8 pll_ctrl, pll_status; u8 pll_ctrl, pll_status;
int i = 0; int i = 0;
bool srm_lock = false; bool srm_lock = false;
...@@ -779,22 +779,22 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w, ...@@ -779,22 +779,22 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w,
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
if (da7219->master) if (da7219->master)
/* Enable DAI clks for master mode */ /* Enable DAI clks for master mode */
snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
DA7219_DAI_CLK_EN_MASK, DA7219_DAI_CLK_EN_MASK,
DA7219_DAI_CLK_EN_MASK); DA7219_DAI_CLK_EN_MASK);
/* PC synchronised to DAI */ /* PC synchronised to DAI */
snd_soc_update_bits(codec, DA7219_PC_COUNT, snd_soc_component_update_bits(component, DA7219_PC_COUNT,
DA7219_PC_FREERUN_MASK, 0); DA7219_PC_FREERUN_MASK, 0);
/* Slave mode, if SRM not enabled no need for status checks */ /* Slave mode, if SRM not enabled no need for status checks */
pll_ctrl = snd_soc_read(codec, DA7219_PLL_CTRL); pll_ctrl = snd_soc_component_read32(component, DA7219_PLL_CTRL);
if ((pll_ctrl & DA7219_PLL_MODE_MASK) != DA7219_PLL_MODE_SRM) if ((pll_ctrl & DA7219_PLL_MODE_MASK) != DA7219_PLL_MODE_SRM)
return 0; return 0;
/* Check SRM has locked */ /* Check SRM has locked */
do { do {
pll_status = snd_soc_read(codec, DA7219_PLL_SRM_STS); pll_status = snd_soc_component_read32(component, DA7219_PLL_SRM_STS);
if (pll_status & DA7219_PLL_SRM_STS_SRM_LOCK) { if (pll_status & DA7219_PLL_SRM_STS_SRM_LOCK) {
srm_lock = true; srm_lock = true;
} else { } else {
...@@ -804,18 +804,18 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w, ...@@ -804,18 +804,18 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w,
} while ((i < DA7219_SRM_CHECK_RETRIES) & (!srm_lock)); } while ((i < DA7219_SRM_CHECK_RETRIES) & (!srm_lock));
if (!srm_lock) if (!srm_lock)
dev_warn(codec->dev, "SRM failed to lock\n"); dev_warn(component->dev, "SRM failed to lock\n");
return 0; return 0;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
/* PC free-running */ /* PC free-running */
snd_soc_update_bits(codec, DA7219_PC_COUNT, snd_soc_component_update_bits(component, DA7219_PC_COUNT,
DA7219_PC_FREERUN_MASK, DA7219_PC_FREERUN_MASK,
DA7219_PC_FREERUN_MASK); DA7219_PC_FREERUN_MASK);
/* Disable DAI clks if in master mode */ /* Disable DAI clks if in master mode */
if (da7219->master) if (da7219->master)
snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
DA7219_DAI_CLK_EN_MASK, 0); DA7219_DAI_CLK_EN_MASK, 0);
return 0; return 0;
default: default:
...@@ -841,7 +841,7 @@ static int da7219_settling_event(struct snd_soc_dapm_widget *w, ...@@ -841,7 +841,7 @@ static int da7219_settling_event(struct snd_soc_dapm_widget *w,
static int da7219_mixout_event(struct snd_soc_dapm_widget *w, static int da7219_mixout_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);
u8 hp_ctrl, min_gain_mask; u8 hp_ctrl, min_gain_mask;
switch (w->reg) { switch (w->reg) {
...@@ -860,7 +860,7 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w, ...@@ -860,7 +860,7 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w,
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
/* Enable minimum gain on HP to avoid pops */ /* Enable minimum gain on HP to avoid pops */
snd_soc_update_bits(codec, hp_ctrl, min_gain_mask, snd_soc_component_update_bits(component, hp_ctrl, min_gain_mask,
min_gain_mask); min_gain_mask);
msleep(DA7219_MIN_GAIN_DELAY); msleep(DA7219_MIN_GAIN_DELAY);
...@@ -868,7 +868,7 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w, ...@@ -868,7 +868,7 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w,
break; break;
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
/* Remove minimum gain on HP */ /* Remove minimum gain on HP */
snd_soc_update_bits(codec, hp_ctrl, min_gain_mask, 0); snd_soc_component_update_bits(component, hp_ctrl, min_gain_mask, 0);
break; break;
} }
...@@ -879,22 +879,22 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w, ...@@ -879,22 +879,22 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w,
static int da7219_gain_ramp_event(struct snd_soc_dapm_widget *w, static int da7219_gain_ramp_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 da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
/* Ensure nominal gain ramping for DAPM sequence */ /* Ensure nominal gain ramping for DAPM sequence */
da7219->gain_ramp_ctrl = da7219->gain_ramp_ctrl =
snd_soc_read(codec, DA7219_GAIN_RAMP_CTRL); snd_soc_component_read32(component, DA7219_GAIN_RAMP_CTRL);
snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL,
DA7219_GAIN_RAMP_RATE_NOMINAL); DA7219_GAIN_RAMP_RATE_NOMINAL);
break; break;
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
/* Restore previous gain ramp settings */ /* Restore previous gain ramp settings */
snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL,
da7219->gain_ramp_ctrl); da7219->gain_ramp_ctrl);
break; break;
} }
...@@ -1116,8 +1116,8 @@ static const struct snd_soc_dapm_route da7219_audio_map[] = { ...@@ -1116,8 +1116,8 @@ static const struct snd_soc_dapm_route da7219_audio_map[] = {
static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int da7219_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 da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
int ret = 0; int ret = 0;
if ((da7219->clk_src == clk_id) && (da7219->mclk_rate == freq)) if ((da7219->clk_src == clk_id) && (da7219->mclk_rate == freq))
...@@ -1133,12 +1133,12 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -1133,12 +1133,12 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
switch (clk_id) { switch (clk_id) {
case DA7219_CLKSRC_MCLK_SQR: case DA7219_CLKSRC_MCLK_SQR:
snd_soc_update_bits(codec, DA7219_PLL_CTRL, snd_soc_component_update_bits(component, DA7219_PLL_CTRL,
DA7219_PLL_MCLK_SQR_EN_MASK, DA7219_PLL_MCLK_SQR_EN_MASK,
DA7219_PLL_MCLK_SQR_EN_MASK); DA7219_PLL_MCLK_SQR_EN_MASK);
break; break;
case DA7219_CLKSRC_MCLK: case DA7219_CLKSRC_MCLK:
snd_soc_update_bits(codec, DA7219_PLL_CTRL, snd_soc_component_update_bits(component, DA7219_PLL_CTRL,
DA7219_PLL_MCLK_SQR_EN_MASK, 0); DA7219_PLL_MCLK_SQR_EN_MASK, 0);
break; break;
default: default:
...@@ -1167,9 +1167,9 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -1167,9 +1167,9 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
return 0; return 0;
} }
int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) int da7219_set_pll(struct snd_soc_component *component, int source, unsigned int fout)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
u8 pll_ctrl, indiv_bits, indiv; u8 pll_ctrl, indiv_bits, indiv;
u8 pll_frac_top, pll_frac_bot, pll_integer; u8 pll_frac_top, pll_frac_bot, pll_integer;
...@@ -1178,7 +1178,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) ...@@ -1178,7 +1178,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout)
/* Verify 2MHz - 54MHz MCLK provided, and set input divider */ /* Verify 2MHz - 54MHz MCLK provided, and set input divider */
if (da7219->mclk_rate < 2000000) { if (da7219->mclk_rate < 2000000) {
dev_err(codec->dev, "PLL input clock %d below valid range\n", dev_err(component->dev, "PLL input clock %d below valid range\n",
da7219->mclk_rate); da7219->mclk_rate);
return -EINVAL; return -EINVAL;
} else if (da7219->mclk_rate <= 4500000) { } else if (da7219->mclk_rate <= 4500000) {
...@@ -1197,7 +1197,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) ...@@ -1197,7 +1197,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout)
indiv_bits = DA7219_PLL_INDIV_36_TO_54_MHZ; indiv_bits = DA7219_PLL_INDIV_36_TO_54_MHZ;
indiv = DA7219_PLL_INDIV_36_TO_54_MHZ_VAL; indiv = DA7219_PLL_INDIV_36_TO_54_MHZ_VAL;
} else { } else {
dev_err(codec->dev, "PLL input clock %d above valid range\n", dev_err(component->dev, "PLL input clock %d above valid range\n",
da7219->mclk_rate); da7219->mclk_rate);
return -EINVAL; return -EINVAL;
} }
...@@ -1208,7 +1208,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) ...@@ -1208,7 +1208,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout)
switch (source) { switch (source) {
case DA7219_SYSCLK_MCLK: case DA7219_SYSCLK_MCLK:
pll_ctrl |= DA7219_PLL_MODE_BYPASS; pll_ctrl |= DA7219_PLL_MODE_BYPASS;
snd_soc_update_bits(codec, DA7219_PLL_CTRL, snd_soc_component_update_bits(component, DA7219_PLL_CTRL,
DA7219_PLL_INDIV_MASK | DA7219_PLL_INDIV_MASK |
DA7219_PLL_MODE_MASK, pll_ctrl); DA7219_PLL_MODE_MASK, pll_ctrl);
return 0; return 0;
...@@ -1219,7 +1219,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) ...@@ -1219,7 +1219,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout)
pll_ctrl |= DA7219_PLL_MODE_SRM; pll_ctrl |= DA7219_PLL_MODE_SRM;
break; break;
default: default:
dev_err(codec->dev, "Invalid PLL config\n"); dev_err(component->dev, "Invalid PLL config\n");
return -EINVAL; return -EINVAL;
} }
...@@ -1231,10 +1231,10 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) ...@@ -1231,10 +1231,10 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout)
pll_frac_bot = (frac_div) & DA7219_BYTE_MASK; pll_frac_bot = (frac_div) & DA7219_BYTE_MASK;
/* Write PLL config & dividers */ /* Write PLL config & dividers */
snd_soc_write(codec, DA7219_PLL_FRAC_TOP, pll_frac_top); snd_soc_component_write(component, DA7219_PLL_FRAC_TOP, pll_frac_top);
snd_soc_write(codec, DA7219_PLL_FRAC_BOT, pll_frac_bot); snd_soc_component_write(component, DA7219_PLL_FRAC_BOT, pll_frac_bot);
snd_soc_write(codec, DA7219_PLL_INTEGER, pll_integer); snd_soc_component_write(component, DA7219_PLL_INTEGER, pll_integer);
snd_soc_update_bits(codec, DA7219_PLL_CTRL, snd_soc_component_update_bits(component, DA7219_PLL_CTRL,
DA7219_PLL_INDIV_MASK | DA7219_PLL_MODE_MASK, DA7219_PLL_INDIV_MASK | DA7219_PLL_MODE_MASK,
pll_ctrl); pll_ctrl);
...@@ -1244,12 +1244,12 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) ...@@ -1244,12 +1244,12 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout)
static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
int source, unsigned int fref, unsigned int fout) int source, unsigned int fref, unsigned int fout)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
int ret; int ret;
mutex_lock(&da7219->pll_lock); mutex_lock(&da7219->pll_lock);
ret = da7219_set_pll(codec, source, fout); ret = da7219_set_pll(component, source, fout);
mutex_unlock(&da7219->pll_lock); mutex_unlock(&da7219->pll_lock);
return ret; return ret;
...@@ -1257,8 +1257,8 @@ static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, ...@@ -1257,8 +1257,8 @@ static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
u8 dai_clk_mode = 0, dai_ctrl = 0; u8 dai_clk_mode = 0, dai_ctrl = 0;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
...@@ -1335,11 +1335,11 @@ static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -1335,11 +1335,11 @@ static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
/* By default 64 BCLKs per WCLK is supported */ /* By default 64 BCLKs per WCLK is supported */
dai_clk_mode |= DA7219_DAI_BCLKS_PER_WCLK_64; dai_clk_mode |= DA7219_DAI_BCLKS_PER_WCLK_64;
snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
DA7219_DAI_BCLKS_PER_WCLK_MASK | DA7219_DAI_BCLKS_PER_WCLK_MASK |
DA7219_DAI_CLK_POL_MASK | DA7219_DAI_WCLK_POL_MASK, DA7219_DAI_CLK_POL_MASK | DA7219_DAI_WCLK_POL_MASK,
dai_clk_mode); dai_clk_mode);
snd_soc_update_bits(codec, DA7219_DAI_CTRL, DA7219_DAI_FORMAT_MASK, snd_soc_component_update_bits(component, DA7219_DAI_CTRL, DA7219_DAI_FORMAT_MASK,
dai_ctrl); dai_ctrl);
return 0; return 0;
...@@ -1349,18 +1349,18 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -1349,18 +1349,18 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai,
unsigned int tx_mask, unsigned int rx_mask, unsigned int tx_mask, unsigned int rx_mask,
int slots, int slot_width) int slots, int slot_width)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
u8 dai_bclks_per_wclk; u8 dai_bclks_per_wclk;
u16 offset; u16 offset;
u32 frame_size; u32 frame_size;
/* No channels enabled so disable TDM, revert to 64-bit frames */ /* No channels enabled so disable TDM, revert to 64-bit frames */
if (!tx_mask) { if (!tx_mask) {
snd_soc_update_bits(codec, DA7219_DAI_TDM_CTRL, snd_soc_component_update_bits(component, DA7219_DAI_TDM_CTRL,
DA7219_DAI_TDM_CH_EN_MASK | DA7219_DAI_TDM_CH_EN_MASK |
DA7219_DAI_TDM_MODE_EN_MASK, 0); DA7219_DAI_TDM_MODE_EN_MASK, 0);
snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
DA7219_DAI_BCLKS_PER_WCLK_MASK, DA7219_DAI_BCLKS_PER_WCLK_MASK,
DA7219_DAI_BCLKS_PER_WCLK_64); DA7219_DAI_BCLKS_PER_WCLK_64);
return 0; return 0;
...@@ -1368,14 +1368,14 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -1368,14 +1368,14 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai,
/* Check we have valid slots */ /* Check we have valid slots */
if (fls(tx_mask) > DA7219_DAI_TDM_MAX_SLOTS) { if (fls(tx_mask) > DA7219_DAI_TDM_MAX_SLOTS) {
dev_err(codec->dev, "Invalid number of slots, max = %d\n", dev_err(component->dev, "Invalid number of slots, max = %d\n",
DA7219_DAI_TDM_MAX_SLOTS); DA7219_DAI_TDM_MAX_SLOTS);
return -EINVAL; return -EINVAL;
} }
/* Check we have a valid offset given */ /* Check we have a valid offset given */
if (rx_mask > DA7219_DAI_OFFSET_MAX) { if (rx_mask > DA7219_DAI_OFFSET_MAX) {
dev_err(codec->dev, "Invalid slot offset, max = %d\n", dev_err(component->dev, "Invalid slot offset, max = %d\n",
DA7219_DAI_OFFSET_MAX); DA7219_DAI_OFFSET_MAX);
return -EINVAL; return -EINVAL;
} }
...@@ -1396,11 +1396,11 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -1396,11 +1396,11 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai,
dai_bclks_per_wclk = DA7219_DAI_BCLKS_PER_WCLK_256; dai_bclks_per_wclk = DA7219_DAI_BCLKS_PER_WCLK_256;
break; break;
default: default:
dev_err(codec->dev, "Invalid frame size %d\n", frame_size); dev_err(component->dev, "Invalid frame size %d\n", frame_size);
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
DA7219_DAI_BCLKS_PER_WCLK_MASK, DA7219_DAI_BCLKS_PER_WCLK_MASK,
dai_bclks_per_wclk); dai_bclks_per_wclk);
...@@ -1408,7 +1408,7 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -1408,7 +1408,7 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai,
regmap_bulk_write(da7219->regmap, DA7219_DAI_OFFSET_LOWER, regmap_bulk_write(da7219->regmap, DA7219_DAI_OFFSET_LOWER,
&offset, sizeof(offset)); &offset, sizeof(offset));
snd_soc_update_bits(codec, DA7219_DAI_TDM_CTRL, snd_soc_component_update_bits(component, DA7219_DAI_TDM_CTRL,
DA7219_DAI_TDM_CH_EN_MASK | DA7219_DAI_TDM_CH_EN_MASK |
DA7219_DAI_TDM_MODE_EN_MASK, DA7219_DAI_TDM_MODE_EN_MASK,
(tx_mask << DA7219_DAI_TDM_CH_EN_SHIFT) | (tx_mask << DA7219_DAI_TDM_CH_EN_SHIFT) |
...@@ -1421,7 +1421,7 @@ static int da7219_hw_params(struct snd_pcm_substream *substream, ...@@ -1421,7 +1421,7 @@ static int da7219_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;
u8 dai_ctrl = 0, fs; u8 dai_ctrl = 0, fs;
unsigned int channels; unsigned int channels;
...@@ -1444,7 +1444,7 @@ static int da7219_hw_params(struct snd_pcm_substream *substream, ...@@ -1444,7 +1444,7 @@ static int da7219_hw_params(struct snd_pcm_substream *substream,
channels = params_channels(params); channels = params_channels(params);
if ((channels < 1) || (channels > DA7219_DAI_CH_NUM_MAX)) { if ((channels < 1) || (channels > DA7219_DAI_CH_NUM_MAX)) {
dev_err(codec->dev, dev_err(component->dev,
"Invalid number of channels, only 1 to %d supported\n", "Invalid number of channels, only 1 to %d supported\n",
DA7219_DAI_CH_NUM_MAX); DA7219_DAI_CH_NUM_MAX);
return -EINVAL; return -EINVAL;
...@@ -1489,11 +1489,11 @@ static int da7219_hw_params(struct snd_pcm_substream *substream, ...@@ -1489,11 +1489,11 @@ static int da7219_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, DA7219_DAI_CTRL, snd_soc_component_update_bits(component, DA7219_DAI_CTRL,
DA7219_DAI_WORD_LENGTH_MASK | DA7219_DAI_WORD_LENGTH_MASK |
DA7219_DAI_CH_NUM_MASK, DA7219_DAI_CH_NUM_MASK,
dai_ctrl); dai_ctrl);
snd_soc_write(codec, DA7219_SR, fs); snd_soc_component_write(component, DA7219_SR, fs);
return 0; return 0;
} }
...@@ -1585,9 +1585,9 @@ static enum da7219_mic_amp_in_sel ...@@ -1585,9 +1585,9 @@ static enum da7219_mic_amp_in_sel
} }
} }
static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_codec *codec) static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *component)
{ {
struct device *dev = codec->dev; struct device *dev = component->dev;
struct da7219_pdata *pdata; struct da7219_pdata *pdata;
const char *of_str; const char *of_str;
u32 of_val32; u32 of_val32;
...@@ -1616,10 +1616,10 @@ static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_codec *codec) ...@@ -1616,10 +1616,10 @@ static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_codec *codec)
* Codec driver functions * Codec driver functions
*/ */
static int da7219_set_bias_level(struct snd_soc_codec *codec, static int da7219_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
int ret; int ret;
switch (level) { switch (level) {
...@@ -1627,11 +1627,11 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec, ...@@ -1627,11 +1627,11 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* Enable MCLK for transition to ON state */ /* Enable MCLK for transition to ON state */
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) {
if (da7219->mclk) { if (da7219->mclk) {
ret = clk_prepare_enable(da7219->mclk); ret = clk_prepare_enable(da7219->mclk);
if (ret) { if (ret) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to enable mclk\n"); "Failed to enable mclk\n");
return ret; return ret;
} }
...@@ -1640,13 +1640,13 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec, ...@@ -1640,13 +1640,13 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
/* Master bias */ /* Master bias */
snd_soc_update_bits(codec, DA7219_REFERENCES, snd_soc_component_update_bits(component, DA7219_REFERENCES,
DA7219_BIAS_EN_MASK, DA7219_BIAS_EN_MASK,
DA7219_BIAS_EN_MASK); DA7219_BIAS_EN_MASK);
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) {
/* Remove MCLK */ /* Remove MCLK */
if (da7219->mclk) if (da7219->mclk)
clk_disable_unprepare(da7219->mclk); clk_disable_unprepare(da7219->mclk);
...@@ -1655,7 +1655,7 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec, ...@@ -1655,7 +1655,7 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* Only disable master bias if we're not a wake-up source */ /* Only disable master bias if we're not a wake-up source */
if (!da7219->wakeup_source) if (!da7219->wakeup_source)
snd_soc_update_bits(codec, DA7219_REFERENCES, snd_soc_component_update_bits(component, DA7219_REFERENCES,
DA7219_BIAS_EN_MASK, 0); DA7219_BIAS_EN_MASK, 0);
break; break;
...@@ -1670,9 +1670,9 @@ static const char *da7219_supply_names[DA7219_NUM_SUPPLIES] = { ...@@ -1670,9 +1670,9 @@ static const char *da7219_supply_names[DA7219_NUM_SUPPLIES] = {
[DA7219_SUPPLY_VDDIO] = "VDDIO", [DA7219_SUPPLY_VDDIO] = "VDDIO",
}; };
static int da7219_handle_supplies(struct snd_soc_codec *codec) static int da7219_handle_supplies(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
struct regulator *vddio; struct regulator *vddio;
u8 io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_2_5V_3_6V; u8 io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_2_5V_3_6V;
int i, ret; int i, ret;
...@@ -1681,10 +1681,10 @@ static int da7219_handle_supplies(struct snd_soc_codec *codec) ...@@ -1681,10 +1681,10 @@ static int da7219_handle_supplies(struct snd_soc_codec *codec)
for (i = 0; i < DA7219_NUM_SUPPLIES; ++i) for (i = 0; i < DA7219_NUM_SUPPLIES; ++i)
da7219->supplies[i].supply = da7219_supply_names[i]; da7219->supplies[i].supply = da7219_supply_names[i];
ret = devm_regulator_bulk_get(codec->dev, DA7219_NUM_SUPPLIES, ret = devm_regulator_bulk_get(component->dev, DA7219_NUM_SUPPLIES,
da7219->supplies); da7219->supplies);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to get supplies"); dev_err(component->dev, "Failed to get supplies");
return ret; return ret;
} }
...@@ -1692,29 +1692,29 @@ static int da7219_handle_supplies(struct snd_soc_codec *codec) ...@@ -1692,29 +1692,29 @@ static int da7219_handle_supplies(struct snd_soc_codec *codec)
vddio = da7219->supplies[DA7219_SUPPLY_VDDIO].consumer; vddio = da7219->supplies[DA7219_SUPPLY_VDDIO].consumer;
ret = regulator_get_voltage(vddio); ret = regulator_get_voltage(vddio);
if (ret < 1200000) if (ret < 1200000)
dev_warn(codec->dev, "Invalid VDDIO voltage\n"); dev_warn(component->dev, "Invalid VDDIO voltage\n");
else if (ret < 2800000) else if (ret < 2800000)
io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_1_2V_2_8V; io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_1_2V_2_8V;
/* Enable main supplies */ /* Enable main supplies */
ret = regulator_bulk_enable(DA7219_NUM_SUPPLIES, da7219->supplies); ret = regulator_bulk_enable(DA7219_NUM_SUPPLIES, da7219->supplies);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to enable supplies"); dev_err(component->dev, "Failed to enable supplies");
return ret; return ret;
} }
/* Ensure device in active mode */ /* Ensure device in active mode */
snd_soc_write(codec, DA7219_SYSTEM_ACTIVE, DA7219_SYSTEM_ACTIVE_MASK); snd_soc_component_write(component, DA7219_SYSTEM_ACTIVE, DA7219_SYSTEM_ACTIVE_MASK);
/* Update IO voltage level range */ /* Update IO voltage level range */
snd_soc_write(codec, DA7219_IO_CTRL, io_voltage_lvl); snd_soc_component_write(component, DA7219_IO_CTRL, io_voltage_lvl);
return 0; return 0;
} }
static void da7219_handle_pdata(struct snd_soc_codec *codec) static void da7219_handle_pdata(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
struct da7219_pdata *pdata = da7219->pdata; struct da7219_pdata *pdata = da7219->pdata;
if (pdata) { if (pdata) {
...@@ -1735,14 +1735,14 @@ static void da7219_handle_pdata(struct snd_soc_codec *codec) ...@@ -1735,14 +1735,14 @@ static void da7219_handle_pdata(struct snd_soc_codec *codec)
break; break;
} }
snd_soc_write(codec, DA7219_MICBIAS_CTRL, micbias_lvl); snd_soc_component_write(component, DA7219_MICBIAS_CTRL, micbias_lvl);
/* Mic */ /* Mic */
switch (pdata->mic_amp_in_sel) { switch (pdata->mic_amp_in_sel) {
case DA7219_MIC_AMP_IN_SEL_DIFF: case DA7219_MIC_AMP_IN_SEL_DIFF:
case DA7219_MIC_AMP_IN_SEL_SE_P: case DA7219_MIC_AMP_IN_SEL_SE_P:
case DA7219_MIC_AMP_IN_SEL_SE_N: case DA7219_MIC_AMP_IN_SEL_SE_N:
snd_soc_write(codec, DA7219_MIC_1_SELECT, snd_soc_component_write(component, DA7219_MIC_1_SELECT,
pdata->mic_amp_in_sel); pdata->mic_amp_in_sel);
break; break;
} }
...@@ -1753,9 +1753,9 @@ static struct reg_sequence da7219_rev_aa_patch[] = { ...@@ -1753,9 +1753,9 @@ static struct reg_sequence da7219_rev_aa_patch[] = {
{ DA7219_REFERENCES, 0x08 }, { DA7219_REFERENCES, 0x08 },
}; };
static int da7219_probe(struct snd_soc_codec *codec) static int da7219_probe(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
unsigned int rev; unsigned int rev;
int ret; int ret;
...@@ -1763,13 +1763,13 @@ static int da7219_probe(struct snd_soc_codec *codec) ...@@ -1763,13 +1763,13 @@ static int da7219_probe(struct snd_soc_codec *codec)
mutex_init(&da7219->pll_lock); mutex_init(&da7219->pll_lock);
/* Regulator configuration */ /* Regulator configuration */
ret = da7219_handle_supplies(codec); ret = da7219_handle_supplies(component);
if (ret) if (ret)
return ret; return ret;
ret = regmap_read(da7219->regmap, DA7219_CHIP_REVISION, &rev); ret = regmap_read(da7219->regmap, DA7219_CHIP_REVISION, &rev);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to read chip revision: %d\n", ret); dev_err(component->dev, "Failed to read chip revision: %d\n", ret);
goto err_disable_reg; goto err_disable_reg;
} }
...@@ -1778,7 +1778,7 @@ static int da7219_probe(struct snd_soc_codec *codec) ...@@ -1778,7 +1778,7 @@ static int da7219_probe(struct snd_soc_codec *codec)
ret = regmap_register_patch(da7219->regmap, da7219_rev_aa_patch, ret = regmap_register_patch(da7219->regmap, da7219_rev_aa_patch,
ARRAY_SIZE(da7219_rev_aa_patch)); ARRAY_SIZE(da7219_rev_aa_patch));
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to register AA patch: %d\n", dev_err(component->dev, "Failed to register AA patch: %d\n",
ret); ret);
goto err_disable_reg; goto err_disable_reg;
} }
...@@ -1788,14 +1788,14 @@ static int da7219_probe(struct snd_soc_codec *codec) ...@@ -1788,14 +1788,14 @@ static int da7219_probe(struct snd_soc_codec *codec)
} }
/* Handle DT/ACPI/Platform data */ /* Handle DT/ACPI/Platform data */
da7219->pdata = dev_get_platdata(codec->dev); da7219->pdata = dev_get_platdata(component->dev);
if (!da7219->pdata) if (!da7219->pdata)
da7219->pdata = da7219_fw_to_pdata(codec); da7219->pdata = da7219_fw_to_pdata(component);
da7219_handle_pdata(codec); da7219_handle_pdata(component);
/* Check if MCLK provided */ /* Check if MCLK provided */
da7219->mclk = devm_clk_get(codec->dev, "mclk"); da7219->mclk = devm_clk_get(component->dev, "mclk");
if (IS_ERR(da7219->mclk)) { if (IS_ERR(da7219->mclk)) {
if (PTR_ERR(da7219->mclk) != -ENOENT) { if (PTR_ERR(da7219->mclk) != -ENOENT) {
ret = PTR_ERR(da7219->mclk); ret = PTR_ERR(da7219->mclk);
...@@ -1806,39 +1806,39 @@ static int da7219_probe(struct snd_soc_codec *codec) ...@@ -1806,39 +1806,39 @@ static int da7219_probe(struct snd_soc_codec *codec)
} }
/* Default PC counter to free-running */ /* Default PC counter to free-running */
snd_soc_update_bits(codec, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK, snd_soc_component_update_bits(component, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK,
DA7219_PC_FREERUN_MASK); DA7219_PC_FREERUN_MASK);
/* Default gain ramping */ /* Default gain ramping */
snd_soc_update_bits(codec, DA7219_MIXIN_L_CTRL, snd_soc_component_update_bits(component, DA7219_MIXIN_L_CTRL,
DA7219_MIXIN_L_AMP_RAMP_EN_MASK, DA7219_MIXIN_L_AMP_RAMP_EN_MASK,
DA7219_MIXIN_L_AMP_RAMP_EN_MASK); DA7219_MIXIN_L_AMP_RAMP_EN_MASK);
snd_soc_update_bits(codec, DA7219_ADC_L_CTRL, DA7219_ADC_L_RAMP_EN_MASK, snd_soc_component_update_bits(component, DA7219_ADC_L_CTRL, DA7219_ADC_L_RAMP_EN_MASK,
DA7219_ADC_L_RAMP_EN_MASK); DA7219_ADC_L_RAMP_EN_MASK);
snd_soc_update_bits(codec, DA7219_DAC_L_CTRL, DA7219_DAC_L_RAMP_EN_MASK, snd_soc_component_update_bits(component, DA7219_DAC_L_CTRL, DA7219_DAC_L_RAMP_EN_MASK,
DA7219_DAC_L_RAMP_EN_MASK); DA7219_DAC_L_RAMP_EN_MASK);
snd_soc_update_bits(codec, DA7219_DAC_R_CTRL, DA7219_DAC_R_RAMP_EN_MASK, snd_soc_component_update_bits(component, DA7219_DAC_R_CTRL, DA7219_DAC_R_RAMP_EN_MASK,
DA7219_DAC_R_RAMP_EN_MASK); DA7219_DAC_R_RAMP_EN_MASK);
snd_soc_update_bits(codec, DA7219_HP_L_CTRL, snd_soc_component_update_bits(component, DA7219_HP_L_CTRL,
DA7219_HP_L_AMP_RAMP_EN_MASK, DA7219_HP_L_AMP_RAMP_EN_MASK,
DA7219_HP_L_AMP_RAMP_EN_MASK); DA7219_HP_L_AMP_RAMP_EN_MASK);
snd_soc_update_bits(codec, DA7219_HP_R_CTRL, snd_soc_component_update_bits(component, DA7219_HP_R_CTRL,
DA7219_HP_R_AMP_RAMP_EN_MASK, DA7219_HP_R_AMP_RAMP_EN_MASK,
DA7219_HP_R_AMP_RAMP_EN_MASK); DA7219_HP_R_AMP_RAMP_EN_MASK);
/* Default minimum gain on HP to avoid pops during DAPM sequencing */ /* Default minimum gain on HP to avoid pops during DAPM sequencing */
snd_soc_update_bits(codec, DA7219_HP_L_CTRL, snd_soc_component_update_bits(component, DA7219_HP_L_CTRL,
DA7219_HP_L_AMP_MIN_GAIN_EN_MASK, DA7219_HP_L_AMP_MIN_GAIN_EN_MASK,
DA7219_HP_L_AMP_MIN_GAIN_EN_MASK); DA7219_HP_L_AMP_MIN_GAIN_EN_MASK);
snd_soc_update_bits(codec, DA7219_HP_R_CTRL, snd_soc_component_update_bits(component, DA7219_HP_R_CTRL,
DA7219_HP_R_AMP_MIN_GAIN_EN_MASK, DA7219_HP_R_AMP_MIN_GAIN_EN_MASK,
DA7219_HP_R_AMP_MIN_GAIN_EN_MASK); DA7219_HP_R_AMP_MIN_GAIN_EN_MASK);
/* Default infinite tone gen, start/stop by Kcontrol */ /* Default infinite tone gen, start/stop by Kcontrol */
snd_soc_write(codec, DA7219_TONE_GEN_CYCLES, DA7219_BEEP_CYCLES_MASK); snd_soc_component_write(component, DA7219_TONE_GEN_CYCLES, DA7219_BEEP_CYCLES_MASK);
/* Initialise AAD block */ /* Initialise AAD block */
ret = da7219_aad_init(codec); ret = da7219_aad_init(component);
if (ret) if (ret)
goto err_disable_reg; goto err_disable_reg;
...@@ -1850,39 +1850,39 @@ static int da7219_probe(struct snd_soc_codec *codec) ...@@ -1850,39 +1850,39 @@ static int da7219_probe(struct snd_soc_codec *codec)
return ret; return ret;
} }
static int da7219_remove(struct snd_soc_codec *codec) static void da7219_remove(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
da7219_aad_exit(codec); da7219_aad_exit(component);
/* Supplies */ /* Supplies */
return regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies); regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies);
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int da7219_suspend(struct snd_soc_codec *codec) static int da7219_suspend(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
/* Suspend AAD if we're not a wake-up source */ /* Suspend AAD if we're not a wake-up source */
if (!da7219->wakeup_source) if (!da7219->wakeup_source)
da7219_aad_suspend(codec); da7219_aad_suspend(component);
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
return 0; return 0;
} }
static int da7219_resume(struct snd_soc_codec *codec) static int da7219_resume(struct snd_soc_component *component)
{ {
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
/* Resume AAD if previously suspended */ /* Resume AAD if previously suspended */
if (!da7219->wakeup_source) if (!da7219->wakeup_source)
da7219_aad_resume(codec); da7219_aad_resume(component);
return 0; return 0;
} }
...@@ -1891,21 +1891,22 @@ static int da7219_resume(struct snd_soc_codec *codec) ...@@ -1891,21 +1891,22 @@ static int da7219_resume(struct snd_soc_codec *codec)
#define da7219_resume NULL #define da7219_resume NULL
#endif #endif
static const struct snd_soc_codec_driver soc_codec_dev_da7219 = { static const struct snd_soc_component_driver soc_component_dev_da7219 = {
.probe = da7219_probe, .probe = da7219_probe,
.remove = da7219_remove, .remove = da7219_remove,
.suspend = da7219_suspend, .suspend = da7219_suspend,
.resume = da7219_resume, .resume = da7219_resume,
.set_bias_level = da7219_set_bias_level, .set_bias_level = da7219_set_bias_level,
.component_driver = {
.controls = da7219_snd_controls, .controls = da7219_snd_controls,
.num_controls = ARRAY_SIZE(da7219_snd_controls), .num_controls = ARRAY_SIZE(da7219_snd_controls),
.dapm_widgets = da7219_dapm_widgets, .dapm_widgets = da7219_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(da7219_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(da7219_dapm_widgets),
.dapm_routes = da7219_audio_map, .dapm_routes = da7219_audio_map,
.num_dapm_routes = ARRAY_SIZE(da7219_audio_map), .num_dapm_routes = ARRAY_SIZE(da7219_audio_map),
}, .idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
...@@ -2090,7 +2091,7 @@ static int da7219_i2c_probe(struct i2c_client *i2c, ...@@ -2090,7 +2091,7 @@ static int da7219_i2c_probe(struct i2c_client *i2c,
} }
} }
/* Soft reset codec */ /* Soft reset component */
regmap_write_bits(da7219->regmap, DA7219_ACCDET_CONFIG_1, regmap_write_bits(da7219->regmap, DA7219_ACCDET_CONFIG_1,
DA7219_ACCDET_EN_MASK, 0); DA7219_ACCDET_EN_MASK, 0);
regmap_write_bits(da7219->regmap, DA7219_CIF_CTRL, regmap_write_bits(da7219->regmap, DA7219_CIF_CTRL,
...@@ -2101,10 +2102,11 @@ static int da7219_i2c_probe(struct i2c_client *i2c, ...@@ -2101,10 +2102,11 @@ static int da7219_i2c_probe(struct i2c_client *i2c,
regcache_cache_bypass(da7219->regmap, false); regcache_cache_bypass(da7219->regmap, false);
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da7219, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_da7219,
&da7219_dai, 1); &da7219_dai, 1);
if (ret < 0) { if (ret < 0) {
dev_err(&i2c->dev, "Failed to register da7219 codec: %d\n", dev_err(&i2c->dev, "Failed to register da7219 component: %d\n",
ret); ret);
} }
return ret; return ret;
...@@ -2112,7 +2114,6 @@ static int da7219_i2c_probe(struct i2c_client *i2c, ...@@ -2112,7 +2114,6 @@ static int da7219_i2c_probe(struct i2c_client *i2c,
static int da7219_i2c_remove(struct i2c_client *client) static int da7219_i2c_remove(struct i2c_client *client)
{ {
snd_soc_unregister_codec(&client->dev);
return 0; return 0;
} }
......
...@@ -822,6 +822,6 @@ struct da7219_priv { ...@@ -822,6 +822,6 @@ struct da7219_priv {
u8 gain_ramp_ctrl; u8 gain_ramp_ctrl;
}; };
int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout); int da7219_set_pll(struct snd_soc_component *component, int source, unsigned int fout);
#endif /* __DA7219_H */ #endif /* __DA7219_H */
...@@ -1536,7 +1536,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) ...@@ -1536,7 +1536,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
struct hdac_hdmi_pin *pin = NULL; struct hdac_hdmi_pin *pin = NULL;
struct hdac_hdmi_port *hport = NULL; struct hdac_hdmi_port *hport = NULL;
struct snd_soc_codec *codec = edev->scodec; struct snd_soc_component *component = edev->scodec;
int i; int i;
/* Don't know how this mapping is derived */ /* Don't know how this mapping is derived */
...@@ -1551,7 +1551,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) ...@@ -1551,7 +1551,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
* connection states are updated in anyway at the end of the resume, * connection states are updated in anyway at the end of the resume,
* we can skip it when received during PM process. * we can skip it when received during PM process.
*/ */
if (snd_power_get_state(codec->component.card->snd_card) != if (snd_power_get_state(component->card->snd_card) !=
SNDRV_CTL_POWER_D0) SNDRV_CTL_POWER_D0)
return; return;
...@@ -1609,10 +1609,10 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card, ...@@ -1609,10 +1609,10 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card,
char kc_name[NAME_SIZE], xname[NAME_SIZE]; char kc_name[NAME_SIZE], xname[NAME_SIZE];
char *name; char *name;
int i = 0, j; int i = 0, j;
struct snd_soc_codec *codec = edev->scodec; struct snd_soc_component *component = edev->scodec;
struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
kc = devm_kcalloc(codec->dev, hdmi->num_ports, kc = devm_kcalloc(component->dev, hdmi->num_ports,
sizeof(*kc), GFP_KERNEL); sizeof(*kc), GFP_KERNEL);
if (!kc) if (!kc)
...@@ -1622,11 +1622,11 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card, ...@@ -1622,11 +1622,11 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card,
for (j = 0; j < pin->num_ports; j++) { for (j = 0; j < pin->num_ports; j++) {
snprintf(xname, sizeof(xname), "hif%d-%d Jack", snprintf(xname, sizeof(xname), "hif%d-%d Jack",
pin->nid, pin->ports[j].id); pin->nid, pin->ports[j].id);
name = devm_kstrdup(codec->dev, xname, GFP_KERNEL); name = devm_kstrdup(component->dev, xname, GFP_KERNEL);
if (!name) if (!name)
return -ENOMEM; return -ENOMEM;
snprintf(kc_name, sizeof(kc_name), "%s Switch", xname); snprintf(kc_name, sizeof(kc_name), "%s Switch", xname);
kc[i].name = devm_kstrdup(codec->dev, kc_name, kc[i].name = devm_kstrdup(component->dev, kc_name,
GFP_KERNEL); GFP_KERNEL);
if (!kc[i].name) if (!kc[i].name)
return -ENOMEM; return -ENOMEM;
...@@ -1644,10 +1644,10 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card, ...@@ -1644,10 +1644,10 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card,
return snd_soc_add_card_controls(card, kc, i); return snd_soc_add_card_controls(card, kc, i);
} }
int hdac_hdmi_jack_port_init(struct snd_soc_codec *codec, int hdac_hdmi_jack_port_init(struct snd_soc_component *component,
struct snd_soc_dapm_context *dapm) struct snd_soc_dapm_context *dapm)
{ {
struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component);
struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
struct hdac_hdmi_pin *pin; struct hdac_hdmi_pin *pin;
struct snd_soc_dapm_widget *widgets; struct snd_soc_dapm_widget *widgets;
...@@ -1722,8 +1722,8 @@ EXPORT_SYMBOL_GPL(hdac_hdmi_jack_port_init); ...@@ -1722,8 +1722,8 @@ EXPORT_SYMBOL_GPL(hdac_hdmi_jack_port_init);
int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device, int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device,
struct snd_soc_jack *jack) struct snd_soc_jack *jack)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component);
struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
struct hdac_hdmi_pcm *pcm; struct hdac_hdmi_pcm *pcm;
struct snd_pcm *snd_pcm; struct snd_pcm *snd_pcm;
...@@ -1784,16 +1784,16 @@ static void hdac_hdmi_present_sense_all_pins(struct hdac_ext_device *edev, ...@@ -1784,16 +1784,16 @@ static void hdac_hdmi_present_sense_all_pins(struct hdac_ext_device *edev,
} }
} }
static int hdmi_codec_probe(struct snd_soc_codec *codec) static int hdmi_codec_probe(struct snd_soc_component *component)
{ {
struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component);
struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev);
struct snd_soc_dapm_context *dapm = struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(&codec->component); snd_soc_component_get_dapm(component);
struct hdac_ext_link *hlink = NULL; struct hdac_ext_link *hlink = NULL;
int ret; int ret;
edev->scodec = codec; edev->scodec = component;
/* /*
* hold the ref while we probe, also no need to drop the ref on * hold the ref while we probe, also no need to drop the ref on
...@@ -1834,12 +1834,11 @@ static int hdmi_codec_probe(struct snd_soc_codec *codec) ...@@ -1834,12 +1834,11 @@ static int hdmi_codec_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int hdmi_codec_remove(struct snd_soc_codec *codec) static void hdmi_codec_remove(struct snd_soc_component *component)
{ {
struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component);
pm_runtime_disable(&edev->hdev.dev); pm_runtime_disable(&edev->hdev.dev);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -1891,10 +1890,12 @@ static void hdmi_codec_complete(struct device *dev) ...@@ -1891,10 +1890,12 @@ static void hdmi_codec_complete(struct device *dev)
#define hdmi_codec_complete NULL #define hdmi_codec_complete NULL
#endif #endif
static const struct snd_soc_codec_driver hdmi_hda_codec = { static const struct snd_soc_component_driver hdmi_hda_codec = {
.probe = hdmi_codec_probe, .probe = hdmi_codec_probe,
.remove = hdmi_codec_remove, .remove = hdmi_codec_remove,
.idle_bias_off = true, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static void hdac_hdmi_get_chmap(struct hdac_device *hdev, int pcm_idx, static void hdac_hdmi_get_chmap(struct hdac_device *hdev, int pcm_idx,
...@@ -2042,7 +2043,7 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) ...@@ -2042,7 +2043,7 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev)
snd_hdac_refresh_widgets(hdev, true); snd_hdac_refresh_widgets(hdev, true);
/* ASoC specific initialization */ /* ASoC specific initialization */
ret = snd_soc_register_codec(&hdev->dev, &hdmi_hda_codec, ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec,
hdmi_dais, num_dais); hdmi_dais, num_dais);
snd_hdac_ext_bus_link_put(edev->ebus, hlink); snd_hdac_ext_bus_link_put(edev->ebus, hlink);
...@@ -2059,8 +2060,6 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev) ...@@ -2059,8 +2060,6 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev)
struct hdac_hdmi_port *port, *port_next; struct hdac_hdmi_port *port, *port_next;
int i; int i;
snd_soc_unregister_codec(&edev->hdev.dev);
list_for_each_entry_safe(pcm, pcm_next, &hdmi->pcm_list, head) { list_for_each_entry_safe(pcm, pcm_next, &hdmi->pcm_list, head) {
pcm->cvt = NULL; pcm->cvt = NULL;
if (list_empty(&pcm->port_list)) if (list_empty(&pcm->port_list))
......
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int pcm, int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int pcm,
struct snd_soc_jack *jack); struct snd_soc_jack *jack);
int hdac_hdmi_jack_port_init(struct snd_soc_codec *codec, int hdac_hdmi_jack_port_init(struct snd_soc_component *component,
struct snd_soc_dapm_context *dapm); struct snd_soc_dapm_context *dapm);
#endif /* __HDAC_HDMI_H__ */ #endif /* __HDAC_HDMI_H__ */
...@@ -914,8 +914,8 @@ static bool nau8825_volatile_reg(struct device *dev, unsigned int reg) ...@@ -914,8 +914,8 @@ static bool nau8825_volatile_reg(struct device *dev, unsigned int reg)
static int nau8825_adc_event(struct snd_soc_dapm_widget *w, static int nau8825_adc_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 nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
...@@ -938,8 +938,8 @@ static int nau8825_adc_event(struct snd_soc_dapm_widget *w, ...@@ -938,8 +938,8 @@ static int nau8825_adc_event(struct snd_soc_dapm_widget *w,
static int nau8825_pump_event(struct snd_soc_dapm_widget *w, static int nau8825_pump_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 nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
...@@ -962,8 +962,8 @@ static int nau8825_pump_event(struct snd_soc_dapm_widget *w, ...@@ -962,8 +962,8 @@ static int nau8825_pump_event(struct snd_soc_dapm_widget *w,
static int nau8825_output_dac_event(struct snd_soc_dapm_widget *w, static int nau8825_output_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
...@@ -1244,8 +1244,8 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream, ...@@ -1244,8 +1244,8 @@ static int nau8825_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 nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div; unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div;
nau8825_sema_acquire(nau8825, 3 * HZ); nau8825_sema_acquire(nau8825, 3 * HZ);
...@@ -1329,8 +1329,8 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream, ...@@ -1329,8 +1329,8 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream,
static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
unsigned int ctrl1_val = 0, ctrl2_val = 0; unsigned int ctrl1_val = 0, ctrl2_val = 0;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
...@@ -1427,10 +1427,10 @@ static struct snd_soc_dai_driver nau8825_dai = { ...@@ -1427,10 +1427,10 @@ static struct snd_soc_dai_driver nau8825_dai = {
* events will be routed to the given jack. Jack can be null to stop * events will be routed to the given jack. Jack can be null to stop
* reporting. * reporting.
*/ */
int nau8825_enable_jack_detect(struct snd_soc_codec *codec, int nau8825_enable_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *jack) struct snd_soc_jack *jack)
{ {
struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
struct regmap *regmap = nau8825->regmap; struct regmap *regmap = nau8825->regmap;
nau8825->jack = jack; nau8825->jack = jack;
...@@ -1952,24 +1952,22 @@ static const struct regmap_config nau8825_regmap_config = { ...@@ -1952,24 +1952,22 @@ static const struct regmap_config nau8825_regmap_config = {
.num_reg_defaults = ARRAY_SIZE(nau8825_reg_defaults), .num_reg_defaults = ARRAY_SIZE(nau8825_reg_defaults),
}; };
static int nau8825_codec_probe(struct snd_soc_codec *codec) static int nau8825_component_probe(struct snd_soc_component *component)
{ {
struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = 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);
nau8825->dapm = dapm; nau8825->dapm = dapm;
return 0; return 0;
} }
static int nau8825_codec_remove(struct snd_soc_codec *codec) static void nau8825_component_remove(struct snd_soc_component *component)
{ {
struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
/* Cancel and reset cross tak suppresstion detection funciton */ /* Cancel and reset cross tak suppresstion detection funciton */
nau8825_xtalk_cancel(nau8825); nau8825_xtalk_cancel(nau8825);
return 0;
} }
/** /**
...@@ -2084,20 +2082,20 @@ static void nau8825_fll_apply(struct nau8825 *nau8825, ...@@ -2084,20 +2082,20 @@ static void nau8825_fll_apply(struct nau8825 *nau8825,
} }
/* freq_out must be 256*Fs in order to achieve the best performance */ /* freq_out must be 256*Fs in order to achieve the best performance */
static int nau8825_set_pll(struct snd_soc_codec *codec, int pll_id, int source, static int nau8825_set_pll(struct snd_soc_component *component, int pll_id, int source,
unsigned int freq_in, unsigned int freq_out) unsigned int freq_in, unsigned int freq_out)
{ {
struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
struct nau8825_fll fll_param; struct nau8825_fll fll_param;
int ret, fs; int ret, fs;
fs = freq_out / 256; fs = freq_out / 256;
ret = nau8825_calc_fll_param(freq_in, fs, &fll_param); ret = nau8825_calc_fll_param(freq_in, fs, &fll_param);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Unsupported input clock %d\n", freq_in); dev_err(component->dev, "Unsupported input clock %d\n", freq_in);
return ret; return ret;
} }
dev_dbg(codec->dev, "mclk_src=%x ratio=%x fll_frac=%x fll_int=%x clk_ref_div=%x\n", dev_dbg(component->dev, "mclk_src=%x ratio=%x fll_frac=%x fll_int=%x clk_ref_div=%x\n",
fll_param.mclk_src, fll_param.ratio, fll_param.fll_frac, fll_param.mclk_src, fll_param.ratio, fll_param.fll_frac,
fll_param.fll_int, fll_param.clk_ref_div); fll_param.fll_int, fll_param.clk_ref_div);
...@@ -2298,10 +2296,10 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, ...@@ -2298,10 +2296,10 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id,
return 0; return 0;
} }
static int nau8825_set_sysclk(struct snd_soc_codec *codec, int clk_id, static int nau8825_set_sysclk(struct snd_soc_component *component, int clk_id,
int source, unsigned int freq, int dir) int source, unsigned int freq, int dir)
{ {
struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
return nau8825_configure_sysclk(nau8825, clk_id, freq); return nau8825_configure_sysclk(nau8825, clk_id, freq);
} }
...@@ -2331,10 +2329,10 @@ static int nau8825_resume_setup(struct nau8825 *nau8825) ...@@ -2331,10 +2329,10 @@ static int nau8825_resume_setup(struct nau8825 *nau8825)
return 0; return 0;
} }
static int nau8825_set_bias_level(struct snd_soc_codec *codec, static int nau8825_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
int ret; int ret;
switch (level) { switch (level) {
...@@ -2345,11 +2343,11 @@ static int nau8825_set_bias_level(struct snd_soc_codec *codec, ...@@ -2345,11 +2343,11 @@ static int nau8825_set_bias_level(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
if (nau8825->mclk_freq) { if (nau8825->mclk_freq) {
ret = clk_prepare_enable(nau8825->mclk); ret = clk_prepare_enable(nau8825->mclk);
if (ret) { if (ret) {
dev_err(nau8825->dev, "Unable to prepare codec mclk\n"); dev_err(nau8825->dev, "Unable to prepare component mclk\n");
return ret; return ret;
} }
} }
...@@ -2383,12 +2381,12 @@ static int nau8825_set_bias_level(struct snd_soc_codec *codec, ...@@ -2383,12 +2381,12 @@ static int nau8825_set_bias_level(struct snd_soc_codec *codec,
return 0; return 0;
} }
static int __maybe_unused nau8825_suspend(struct snd_soc_codec *codec) static int __maybe_unused nau8825_suspend(struct snd_soc_component *component)
{ {
struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
disable_irq(nau8825->irq); disable_irq(nau8825->irq);
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
/* Power down codec power; don't suppoet button wakeup */ /* Power down codec power; don't suppoet button wakeup */
snd_soc_dapm_disable_pin(nau8825->dapm, "SAR"); snd_soc_dapm_disable_pin(nau8825->dapm, "SAR");
snd_soc_dapm_disable_pin(nau8825->dapm, "MICBIAS"); snd_soc_dapm_disable_pin(nau8825->dapm, "MICBIAS");
...@@ -2399,9 +2397,9 @@ static int __maybe_unused nau8825_suspend(struct snd_soc_codec *codec) ...@@ -2399,9 +2397,9 @@ static int __maybe_unused nau8825_suspend(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) static int __maybe_unused nau8825_resume(struct snd_soc_component *component)
{ {
struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component);
int ret; int ret;
regcache_cache_only(nau8825->regmap, false); regcache_cache_only(nau8825->regmap, false);
...@@ -2415,24 +2413,25 @@ static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) ...@@ -2415,24 +2413,25 @@ static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec)
return 0; return 0;
} }
static const struct snd_soc_codec_driver nau8825_codec_driver = { static const struct snd_soc_component_driver nau8825_component_driver = {
.probe = nau8825_codec_probe, .probe = nau8825_component_probe,
.remove = nau8825_codec_remove, .remove = nau8825_component_remove,
.set_sysclk = nau8825_set_sysclk, .set_sysclk = nau8825_set_sysclk,
.set_pll = nau8825_set_pll, .set_pll = nau8825_set_pll,
.set_bias_level = nau8825_set_bias_level, .set_bias_level = nau8825_set_bias_level,
.suspend_bias_off = true,
.suspend = nau8825_suspend, .suspend = nau8825_suspend,
.resume = nau8825_resume, .resume = nau8825_resume,
.component_driver = {
.controls = nau8825_controls, .controls = nau8825_controls,
.num_controls = ARRAY_SIZE(nau8825_controls), .num_controls = ARRAY_SIZE(nau8825_controls),
.dapm_widgets = nau8825_dapm_widgets, .dapm_widgets = nau8825_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(nau8825_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(nau8825_dapm_widgets),
.dapm_routes = nau8825_dapm_routes, .dapm_routes = nau8825_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(nau8825_dapm_routes), .num_dapm_routes = ARRAY_SIZE(nau8825_dapm_routes),
}, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static void nau8825_reset_chip(struct regmap *regmap) static void nau8825_reset_chip(struct regmap *regmap)
...@@ -2619,13 +2618,13 @@ static int nau8825_i2c_probe(struct i2c_client *i2c, ...@@ -2619,13 +2618,13 @@ static int nau8825_i2c_probe(struct i2c_client *i2c,
if (i2c->irq) if (i2c->irq)
nau8825_setup_irq(nau8825); nau8825_setup_irq(nau8825);
return snd_soc_register_codec(&i2c->dev, &nau8825_codec_driver, return devm_snd_soc_register_component(&i2c->dev,
&nau8825_component_driver,
&nau8825_dai, 1); &nau8825_dai, 1);
} }
static int nau8825_i2c_remove(struct i2c_client *client) static int nau8825_i2c_remove(struct i2c_client *client)
{ {
snd_soc_unregister_codec(&client->dev);
return 0; return 0;
} }
......
...@@ -480,7 +480,7 @@ struct nau8825 { ...@@ -480,7 +480,7 @@ struct nau8825 {
bool xtalk_baktab_initialized; /* True if initialized. */ bool xtalk_baktab_initialized; /* True if initialized. */
}; };
int nau8825_enable_jack_detect(struct snd_soc_codec *codec, int nau8825_enable_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *jack); struct snd_soc_jack *jack);
......
...@@ -40,7 +40,7 @@ struct rt286_priv { ...@@ -40,7 +40,7 @@ struct rt286_priv {
struct reg_default *index_cache; struct reg_default *index_cache;
int index_cache_size; int index_cache_size;
struct regmap *regmap; struct regmap *regmap;
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct rt286_platform_data pdata; struct rt286_platform_data pdata;
struct i2c_client *i2c; struct i2c_client *i2c;
struct snd_soc_jack *jack; struct snd_soc_jack *jack;
...@@ -187,13 +187,13 @@ static bool rt286_readable_register(struct device *dev, unsigned int reg) ...@@ -187,13 +187,13 @@ static bool rt286_readable_register(struct device *dev, unsigned int reg)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static void rt286_index_sync(struct snd_soc_codec *codec) static void rt286_index_sync(struct snd_soc_component *component)
{ {
struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
int i; int i;
for (i = 0; i < INDEX_CACHE_SIZE; i++) { for (i = 0; i < INDEX_CACHE_SIZE; i++) {
snd_soc_write(codec, rt286->index_cache[i].reg, snd_soc_component_write(component, rt286->index_cache[i].reg,
rt286->index_cache[i].def); rt286->index_cache[i].def);
} }
} }
...@@ -220,10 +220,10 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic) ...@@ -220,10 +220,10 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic)
*hp = false; *hp = false;
*mic = false; *mic = false;
if (!rt286->codec) if (!rt286->component)
return -EINVAL; return -EINVAL;
dapm = snd_soc_codec_get_dapm(rt286->codec); dapm = snd_soc_component_get_dapm(rt286->component);
if (rt286->pdata.cbj_en) { if (rt286->pdata.cbj_en) {
regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf);
...@@ -305,10 +305,10 @@ static void rt286_jack_detect_work(struct work_struct *work) ...@@ -305,10 +305,10 @@ static void rt286_jack_detect_work(struct work_struct *work)
SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
} }
int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack)
{ {
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 rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
rt286->jack = jack; rt286->jack = jack;
...@@ -334,8 +334,8 @@ EXPORT_SYMBOL_GPL(rt286_mic_detect); ...@@ -334,8 +334,8 @@ EXPORT_SYMBOL_GPL(rt286_mic_detect);
static int is_mclk_mode(struct snd_soc_dapm_widget *source, static int is_mclk_mode(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink) struct snd_soc_dapm_widget *sink)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
if (rt286->clk_id == RT286_SCLK_S_MCLK) if (rt286->clk_id == RT286_SCLK_S_MCLK)
return 1; return 1;
...@@ -434,15 +434,15 @@ SOC_DAPM_ENUM("SPO source", rt286_spo_enum); ...@@ -434,15 +434,15 @@ SOC_DAPM_ENUM("SPO source", rt286_spo_enum);
static int rt286_spk_event(struct snd_soc_dapm_widget *w, static int rt286_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);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_write(codec, snd_soc_component_write(component,
RT286_SPK_EAPD, RT286_SET_EAPD_HIGH); RT286_SPK_EAPD, RT286_SET_EAPD_HIGH);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_write(codec, snd_soc_component_write(component,
RT286_SPK_EAPD, RT286_SET_EAPD_LOW); RT286_SPK_EAPD, RT286_SET_EAPD_LOW);
break; break;
...@@ -456,14 +456,14 @@ static int rt286_spk_event(struct snd_soc_dapm_widget *w, ...@@ -456,14 +456,14 @@ static int rt286_spk_event(struct snd_soc_dapm_widget *w,
static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w, static int rt286_set_dmic1_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);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_write(codec, RT286_SET_PIN_DMIC1, 0x20); snd_soc_component_write(component, RT286_SET_PIN_DMIC1, 0x20);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_write(codec, RT286_SET_PIN_DMIC1, 0); snd_soc_component_write(component, RT286_SET_PIN_DMIC1, 0);
break; break;
default: default:
return 0; return 0;
...@@ -475,14 +475,14 @@ static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w, ...@@ -475,14 +475,14 @@ static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w,
static int rt286_ldo2_event(struct snd_soc_dapm_widget *w, static int rt286_ldo2_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);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_update_bits(codec, RT286_POWER_CTRL2, 0x38, 0x08); snd_soc_component_update_bits(component, RT286_POWER_CTRL2, 0x38, 0x08);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, RT286_POWER_CTRL2, 0x38, 0x30); snd_soc_component_update_bits(component, RT286_POWER_CTRL2, 0x38, 0x30);
break; break;
default: default:
return 0; return 0;
...@@ -494,19 +494,19 @@ static int rt286_ldo2_event(struct snd_soc_dapm_widget *w, ...@@ -494,19 +494,19 @@ static int rt286_ldo2_event(struct snd_soc_dapm_widget *w,
static int rt286_mic1_event(struct snd_soc_dapm_widget *w, static int rt286_mic1_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);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_A_BIAS_CTRL3, 0xc000, 0x8000); RT286_A_BIAS_CTRL3, 0xc000, 0x8000);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_A_BIAS_CTRL2, 0xc000, 0x8000); RT286_A_BIAS_CTRL2, 0xc000, 0x8000);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_A_BIAS_CTRL3, 0xc000, 0x0000); RT286_A_BIAS_CTRL3, 0xc000, 0x0000);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_A_BIAS_CTRL2, 0xc000, 0x0000); RT286_A_BIAS_CTRL2, 0xc000, 0x0000);
break; break;
default: default:
...@@ -674,8 +674,8 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, ...@@ -674,8 +674,8 @@ static int rt286_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 rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
unsigned int val = 0; unsigned int val = 0;
int d_len_code; int d_len_code;
...@@ -687,7 +687,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, ...@@ -687,7 +687,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream,
case 48000: case 48000:
break; break;
default: default:
dev_err(codec->dev, "Unsupported sample rate %d\n", dev_err(component->dev, "Unsupported sample rate %d\n",
params_rate(params)); params_rate(params));
return -EINVAL; return -EINVAL;
} }
...@@ -695,7 +695,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, ...@@ -695,7 +695,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream,
case 12288000: case 12288000:
case 24576000: case 24576000:
if (params_rate(params) != 48000) { if (params_rate(params) != 48000) {
dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", dev_err(component->dev, "Sys_clk is not matched (%d %d)\n",
params_rate(params), rt286->sys_clk); params_rate(params), rt286->sys_clk);
return -EINVAL; return -EINVAL;
} }
...@@ -703,7 +703,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, ...@@ -703,7 +703,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream,
case 11289600: case 11289600:
case 22579200: case 22579200:
if (params_rate(params) != 44100) { if (params_rate(params) != 44100) {
dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", dev_err(component->dev, "Sys_clk is not matched (%d %d)\n",
params_rate(params), rt286->sys_clk); params_rate(params), rt286->sys_clk);
return -EINVAL; return -EINVAL;
} }
...@@ -714,7 +714,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, ...@@ -714,7 +714,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream,
/* bit 3:0 Number of Channel */ /* bit 3:0 Number of Channel */
val |= (params_channels(params) - 1); val |= (params_channels(params) - 1);
} else { } else {
dev_err(codec->dev, "Unsupported channels %d\n", dev_err(component->dev, "Unsupported channels %d\n",
params_channels(params)); params_channels(params));
return -EINVAL; return -EINVAL;
} }
...@@ -745,27 +745,27 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, ...@@ -745,27 +745,27 @@ static int rt286_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL1, 0x0018, d_len_code << 3); RT286_I2S_CTRL1, 0x0018, d_len_code << 3);
dev_dbg(codec->dev, "format val = 0x%x\n", val); dev_dbg(component->dev, "format val = 0x%x\n", val);
snd_soc_update_bits(codec, RT286_DAC_FORMAT, 0x407f, val); snd_soc_component_update_bits(component, RT286_DAC_FORMAT, 0x407f, val);
snd_soc_update_bits(codec, RT286_ADC_FORMAT, 0x407f, val); snd_soc_component_update_bits(component, RT286_ADC_FORMAT, 0x407f, val);
return 0; return 0;
} }
static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt286_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;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFM:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL1, 0x800, 0x800); RT286_I2S_CTRL1, 0x800, 0x800);
break; break;
case SND_SOC_DAIFMT_CBS_CFS: case SND_SOC_DAIFMT_CBS_CFS:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL1, 0x800, 0x0); RT286_I2S_CTRL1, 0x800, 0x0);
break; break;
default: default:
...@@ -774,27 +774,27 @@ static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -774,27 +774,27 @@ static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_I2S:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL1, 0x300, 0x0); RT286_I2S_CTRL1, 0x300, 0x0);
break; break;
case SND_SOC_DAIFMT_LEFT_J: case SND_SOC_DAIFMT_LEFT_J:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL1, 0x300, 0x1 << 8); RT286_I2S_CTRL1, 0x300, 0x1 << 8);
break; break;
case SND_SOC_DAIFMT_DSP_A: case SND_SOC_DAIFMT_DSP_A:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL1, 0x300, 0x2 << 8); RT286_I2S_CTRL1, 0x300, 0x2 << 8);
break; break;
case SND_SOC_DAIFMT_DSP_B: case SND_SOC_DAIFMT_DSP_B:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL1, 0x300, 0x3 << 8); RT286_I2S_CTRL1, 0x300, 0x3 << 8);
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
/* bit 15 Stream Type 0:PCM 1:Non-PCM */ /* bit 15 Stream Type 0:PCM 1:Non-PCM */
snd_soc_update_bits(codec, RT286_DAC_FORMAT, 0x8000, 0); snd_soc_component_update_bits(component, RT286_DAC_FORMAT, 0x8000, 0);
snd_soc_update_bits(codec, RT286_ADC_FORMAT, 0x8000, 0); snd_soc_component_update_bits(component, RT286_ADC_FORMAT, 0x8000, 0);
return 0; return 0;
} }
...@@ -802,58 +802,58 @@ static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -802,58 +802,58 @@ static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
static int rt286_set_dai_sysclk(struct snd_soc_dai *dai, static int rt286_set_dai_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq); dev_dbg(component->dev, "%s freq=%d\n", __func__, freq);
if (RT286_SCLK_S_MCLK == clk_id) { if (RT286_SCLK_S_MCLK == clk_id) {
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL2, 0x0100, 0x0); RT286_I2S_CTRL2, 0x0100, 0x0);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_PLL_CTRL1, 0x20, 0x20); RT286_PLL_CTRL1, 0x20, 0x20);
} else { } else {
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL2, 0x0100, 0x0100); RT286_I2S_CTRL2, 0x0100, 0x0100);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_PLL_CTRL, 0x4, 0x4); RT286_PLL_CTRL, 0x4, 0x4);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_PLL_CTRL1, 0x20, 0x0); RT286_PLL_CTRL1, 0x20, 0x0);
} }
switch (freq) { switch (freq) {
case 19200000: case 19200000:
if (RT286_SCLK_S_MCLK == clk_id) { if (RT286_SCLK_S_MCLK == clk_id) {
dev_err(codec->dev, "Should not use MCLK\n"); dev_err(component->dev, "Should not use MCLK\n");
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL2, 0x40, 0x40); RT286_I2S_CTRL2, 0x40, 0x40);
break; break;
case 24000000: case 24000000:
if (RT286_SCLK_S_MCLK == clk_id) { if (RT286_SCLK_S_MCLK == clk_id) {
dev_err(codec->dev, "Should not use MCLK\n"); dev_err(component->dev, "Should not use MCLK\n");
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL2, 0x40, 0x0); RT286_I2S_CTRL2, 0x40, 0x0);
break; break;
case 12288000: case 12288000:
case 11289600: case 11289600:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL2, 0x8, 0x0); RT286_I2S_CTRL2, 0x8, 0x0);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_CLK_DIV, 0xfc1e, 0x0004); RT286_CLK_DIV, 0xfc1e, 0x0004);
break; break;
case 24576000: case 24576000:
case 22579200: case 22579200:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL2, 0x8, 0x8); RT286_I2S_CTRL2, 0x8, 0x8);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_CLK_DIV, 0xfc1e, 0x5406); RT286_CLK_DIV, 0xfc1e, 0x5406);
break; break;
default: default:
dev_err(codec->dev, "Unsupported system clock\n"); dev_err(component->dev, "Unsupported system clock\n");
return -EINVAL; return -EINVAL;
} }
...@@ -865,42 +865,42 @@ static int rt286_set_dai_sysclk(struct snd_soc_dai *dai, ...@@ -865,42 +865,42 @@ static int rt286_set_dai_sysclk(struct snd_soc_dai *dai,
static int rt286_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) static int rt286_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio);
if (50 == ratio) if (50 == ratio)
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL1, 0x1000, 0x1000); RT286_I2S_CTRL1, 0x1000, 0x1000);
else else
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_I2S_CTRL1, 0x1000, 0x0); RT286_I2S_CTRL1, 0x1000, 0x0);
return 0; return 0;
} }
static int rt286_set_bias_level(struct snd_soc_codec *codec, static int rt286_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
if (SND_SOC_BIAS_STANDBY == snd_soc_codec_get_bias_level(codec)) { if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) {
snd_soc_write(codec, snd_soc_component_write(component,
RT286_SET_AUDIO_POWER, AC_PWRST_D0); RT286_SET_AUDIO_POWER, AC_PWRST_D0);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_DC_GAIN, 0x200, 0x200); RT286_DC_GAIN, 0x200, 0x200);
} }
break; break;
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
mdelay(10); mdelay(10);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT286_DC_GAIN, 0x200, 0x0); RT286_DC_GAIN, 0x200, 0x0);
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
snd_soc_write(codec, snd_soc_component_write(component,
RT286_SET_AUDIO_POWER, AC_PWRST_D3); RT286_SET_AUDIO_POWER, AC_PWRST_D3);
break; break;
...@@ -937,11 +937,11 @@ static irqreturn_t rt286_irq(int irq, void *data) ...@@ -937,11 +937,11 @@ static irqreturn_t rt286_irq(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int rt286_probe(struct snd_soc_codec *codec) static int rt286_probe(struct snd_soc_component *component)
{ {
struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
rt286->codec = codec; rt286->component = component;
if (rt286->i2c->irq) { if (rt286->i2c->irq) {
regmap_update_bits(rt286->regmap, regmap_update_bits(rt286->regmap,
...@@ -956,19 +956,17 @@ static int rt286_probe(struct snd_soc_codec *codec) ...@@ -956,19 +956,17 @@ static int rt286_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int rt286_remove(struct snd_soc_codec *codec) static void rt286_remove(struct snd_soc_component *component)
{ {
struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
cancel_delayed_work_sync(&rt286->jack_detect_work); cancel_delayed_work_sync(&rt286->jack_detect_work);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int rt286_suspend(struct snd_soc_codec *codec) static int rt286_suspend(struct snd_soc_component *component)
{ {
struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
regcache_cache_only(rt286->regmap, true); regcache_cache_only(rt286->regmap, true);
regcache_mark_dirty(rt286->regmap); regcache_mark_dirty(rt286->regmap);
...@@ -976,12 +974,12 @@ static int rt286_suspend(struct snd_soc_codec *codec) ...@@ -976,12 +974,12 @@ static int rt286_suspend(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int rt286_resume(struct snd_soc_codec *codec) static int rt286_resume(struct snd_soc_component *component)
{ {
struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
regcache_cache_only(rt286->regmap, false); regcache_cache_only(rt286->regmap, false);
rt286_index_sync(codec); rt286_index_sync(component);
regcache_sync(rt286->regmap); regcache_sync(rt286->regmap);
return 0; return 0;
...@@ -1046,21 +1044,21 @@ static struct snd_soc_dai_driver rt286_dai[] = { ...@@ -1046,21 +1044,21 @@ static struct snd_soc_dai_driver rt286_dai[] = {
}; };
static const struct snd_soc_codec_driver soc_codec_dev_rt286 = { static const struct snd_soc_component_driver soc_component_dev_rt286 = {
.probe = rt286_probe, .probe = rt286_probe,
.remove = rt286_remove, .remove = rt286_remove,
.suspend = rt286_suspend, .suspend = rt286_suspend,
.resume = rt286_resume, .resume = rt286_resume,
.set_bias_level = rt286_set_bias_level, .set_bias_level = rt286_set_bias_level,
.idle_bias_off = true,
.component_driver = {
.controls = rt286_snd_controls, .controls = rt286_snd_controls,
.num_controls = ARRAY_SIZE(rt286_snd_controls), .num_controls = ARRAY_SIZE(rt286_snd_controls),
.dapm_widgets = rt286_dapm_widgets, .dapm_widgets = rt286_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(rt286_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(rt286_dapm_widgets),
.dapm_routes = rt286_dapm_routes, .dapm_routes = rt286_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(rt286_dapm_routes), .num_dapm_routes = ARRAY_SIZE(rt286_dapm_routes),
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config rt286_regmap = { static const struct regmap_config rt286_regmap = {
...@@ -1243,7 +1241,8 @@ static int rt286_i2c_probe(struct i2c_client *i2c, ...@@ -1243,7 +1241,8 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
} }
} }
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt286, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_rt286,
rt286_dai, ARRAY_SIZE(rt286_dai)); rt286_dai, ARRAY_SIZE(rt286_dai));
return ret; return ret;
...@@ -1255,7 +1254,6 @@ static int rt286_i2c_remove(struct i2c_client *i2c) ...@@ -1255,7 +1254,6 @@ static int rt286_i2c_remove(struct i2c_client *i2c)
if (i2c->irq) if (i2c->irq)
free_irq(i2c->irq, rt286); free_irq(i2c->irq, rt286);
snd_soc_unregister_codec(&i2c->dev);
return 0; return 0;
} }
......
...@@ -199,7 +199,7 @@ enum { ...@@ -199,7 +199,7 @@ enum {
RT286_AIFS, RT286_AIFS,
}; };
int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack);
#endif /* __RT286_H__ */ #endif /* __RT286_H__ */
...@@ -39,7 +39,7 @@ struct rt298_priv { ...@@ -39,7 +39,7 @@ struct rt298_priv {
struct reg_default *index_cache; struct reg_default *index_cache;
int index_cache_size; int index_cache_size;
struct regmap *regmap; struct regmap *regmap;
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct rt298_platform_data pdata; struct rt298_platform_data pdata;
struct i2c_client *i2c; struct i2c_client *i2c;
struct snd_soc_jack *jack; struct snd_soc_jack *jack;
...@@ -194,13 +194,13 @@ static bool rt298_readable_register(struct device *dev, unsigned int reg) ...@@ -194,13 +194,13 @@ static bool rt298_readable_register(struct device *dev, unsigned int reg)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static void rt298_index_sync(struct snd_soc_codec *codec) static void rt298_index_sync(struct snd_soc_component *component)
{ {
struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
int i; int i;
for (i = 0; i < INDEX_CACHE_SIZE; i++) { for (i = 0; i < INDEX_CACHE_SIZE; i++) {
snd_soc_write(codec, rt298->index_cache[i].reg, snd_soc_component_write(component, rt298->index_cache[i].reg,
rt298->index_cache[i].def); rt298->index_cache[i].def);
} }
} }
...@@ -227,10 +227,10 @@ static int rt298_jack_detect(struct rt298_priv *rt298, bool *hp, bool *mic) ...@@ -227,10 +227,10 @@ static int rt298_jack_detect(struct rt298_priv *rt298, bool *hp, bool *mic)
*hp = false; *hp = false;
*mic = false; *mic = false;
if (!rt298->codec) if (!rt298->component)
return -EINVAL; return -EINVAL;
dapm = snd_soc_codec_get_dapm(rt298->codec); dapm = snd_soc_component_get_dapm(rt298->component);
if (rt298->pdata.cbj_en) { if (rt298->pdata.cbj_en) {
regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf); regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf);
...@@ -323,9 +323,9 @@ static void rt298_jack_detect_work(struct work_struct *work) ...@@ -323,9 +323,9 @@ static void rt298_jack_detect_work(struct work_struct *work)
SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
} }
int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) int rt298_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack)
{ {
struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm; struct snd_soc_dapm_context *dapm;
bool hp = false; bool hp = false;
bool mic = false; bool mic = false;
...@@ -334,7 +334,7 @@ int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) ...@@ -334,7 +334,7 @@ int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
/* If jack in NULL, disable HS jack */ /* If jack in NULL, disable HS jack */
if (!jack) { if (!jack) {
regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x0); regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x0);
dapm = snd_soc_codec_get_dapm(codec); dapm = snd_soc_component_get_dapm(component);
snd_soc_dapm_disable_pin(dapm, "LDO1"); snd_soc_dapm_disable_pin(dapm, "LDO1");
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
return 0; return 0;
...@@ -360,8 +360,8 @@ EXPORT_SYMBOL_GPL(rt298_mic_detect); ...@@ -360,8 +360,8 @@ EXPORT_SYMBOL_GPL(rt298_mic_detect);
static int is_mclk_mode(struct snd_soc_dapm_widget *source, static int is_mclk_mode(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink) struct snd_soc_dapm_widget *sink)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
if (rt298->clk_id == RT298_SCLK_S_MCLK) if (rt298->clk_id == RT298_SCLK_S_MCLK)
return 1; return 1;
...@@ -458,15 +458,15 @@ SOC_DAPM_ENUM("SPO source", rt298_spo_enum); ...@@ -458,15 +458,15 @@ SOC_DAPM_ENUM("SPO source", rt298_spo_enum);
static int rt298_spk_event(struct snd_soc_dapm_widget *w, static int rt298_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);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_write(codec, snd_soc_component_write(component,
RT298_SPK_EAPD, RT298_SET_EAPD_HIGH); RT298_SPK_EAPD, RT298_SET_EAPD_HIGH);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_write(codec, snd_soc_component_write(component,
RT298_SPK_EAPD, RT298_SET_EAPD_LOW); RT298_SPK_EAPD, RT298_SET_EAPD_LOW);
break; break;
...@@ -480,14 +480,14 @@ static int rt298_spk_event(struct snd_soc_dapm_widget *w, ...@@ -480,14 +480,14 @@ static int rt298_spk_event(struct snd_soc_dapm_widget *w,
static int rt298_set_dmic1_event(struct snd_soc_dapm_widget *w, static int rt298_set_dmic1_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);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_write(codec, RT298_SET_PIN_DMIC1, 0x20); snd_soc_component_write(component, RT298_SET_PIN_DMIC1, 0x20);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_write(codec, RT298_SET_PIN_DMIC1, 0); snd_soc_component_write(component, RT298_SET_PIN_DMIC1, 0);
break; break;
default: default:
return 0; return 0;
...@@ -499,39 +499,39 @@ static int rt298_set_dmic1_event(struct snd_soc_dapm_widget *w, ...@@ -499,39 +499,39 @@ static int rt298_set_dmic1_event(struct snd_soc_dapm_widget *w,
static int rt298_adc_event(struct snd_soc_dapm_widget *w, static int rt298_adc_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
unsigned int nid; unsigned int nid;
nid = (w->reg >> 20) & 0xff; nid = (w->reg >> 20) & 0xff;
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0),
0x7080, 0x7000); 0x7080, 0x7000);
/* If MCLK doesn't exist, reset AD filter */ /* If MCLK doesn't exist, reset AD filter */
if (!(snd_soc_read(codec, RT298_VAD_CTRL) & 0x200)) { if (!(snd_soc_component_read32(component, RT298_VAD_CTRL) & 0x200)) {
pr_info("NO MCLK\n"); pr_info("NO MCLK\n");
switch (nid) { switch (nid) {
case RT298_ADC_IN1: case RT298_ADC_IN1:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_D_FILTER_CTRL, 0x2, 0x2); RT298_D_FILTER_CTRL, 0x2, 0x2);
mdelay(10); mdelay(10);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_D_FILTER_CTRL, 0x2, 0x0); RT298_D_FILTER_CTRL, 0x2, 0x0);
break; break;
case RT298_ADC_IN2: case RT298_ADC_IN2:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_D_FILTER_CTRL, 0x4, 0x4); RT298_D_FILTER_CTRL, 0x4, 0x4);
mdelay(10); mdelay(10);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_D_FILTER_CTRL, 0x4, 0x0); RT298_D_FILTER_CTRL, 0x4, 0x0);
break; break;
} }
} }
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0),
0x7080, 0x7080); 0x7080, 0x7080);
break; break;
...@@ -545,19 +545,19 @@ static int rt298_adc_event(struct snd_soc_dapm_widget *w, ...@@ -545,19 +545,19 @@ static int rt298_adc_event(struct snd_soc_dapm_widget *w,
static int rt298_mic1_event(struct snd_soc_dapm_widget *w, static int rt298_mic1_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);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_A_BIAS_CTRL3, 0xc000, 0x8000); RT298_A_BIAS_CTRL3, 0xc000, 0x8000);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_A_BIAS_CTRL2, 0xc000, 0x8000); RT298_A_BIAS_CTRL2, 0xc000, 0x8000);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_A_BIAS_CTRL3, 0xc000, 0x0000); RT298_A_BIAS_CTRL3, 0xc000, 0x0000);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_A_BIAS_CTRL2, 0xc000, 0x0000); RT298_A_BIAS_CTRL2, 0xc000, 0x0000);
break; break;
default: default:
...@@ -745,8 +745,8 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, ...@@ -745,8 +745,8 @@ static int rt298_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 rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
unsigned int val = 0; unsigned int val = 0;
int d_len_code; int d_len_code;
...@@ -756,7 +756,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, ...@@ -756,7 +756,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream,
case 48000: case 48000:
break; break;
default: default:
dev_err(codec->dev, "Unsupported sample rate %d\n", dev_err(component->dev, "Unsupported sample rate %d\n",
params_rate(params)); params_rate(params));
return -EINVAL; return -EINVAL;
} }
...@@ -764,7 +764,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, ...@@ -764,7 +764,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream,
case 12288000: case 12288000:
case 24576000: case 24576000:
if (params_rate(params) != 48000) { if (params_rate(params) != 48000) {
dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", dev_err(component->dev, "Sys_clk is not matched (%d %d)\n",
params_rate(params), rt298->sys_clk); params_rate(params), rt298->sys_clk);
return -EINVAL; return -EINVAL;
} }
...@@ -772,7 +772,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, ...@@ -772,7 +772,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream,
case 11289600: case 11289600:
case 22579200: case 22579200:
if (params_rate(params) != 44100) { if (params_rate(params) != 44100) {
dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", dev_err(component->dev, "Sys_clk is not matched (%d %d)\n",
params_rate(params), rt298->sys_clk); params_rate(params), rt298->sys_clk);
return -EINVAL; return -EINVAL;
} }
...@@ -783,7 +783,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, ...@@ -783,7 +783,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream,
/* bit 3:0 Number of Channel */ /* bit 3:0 Number of Channel */
val |= (params_channels(params) - 1); val |= (params_channels(params) - 1);
} else { } else {
dev_err(codec->dev, "Unsupported channels %d\n", dev_err(component->dev, "Unsupported channels %d\n",
params_channels(params)); params_channels(params));
return -EINVAL; return -EINVAL;
} }
...@@ -814,27 +814,27 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, ...@@ -814,27 +814,27 @@ static int rt298_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL1, 0x0018, d_len_code << 3); RT298_I2S_CTRL1, 0x0018, d_len_code << 3);
dev_dbg(codec->dev, "format val = 0x%x\n", val); dev_dbg(component->dev, "format val = 0x%x\n", val);
snd_soc_update_bits(codec, RT298_DAC_FORMAT, 0x407f, val); snd_soc_component_update_bits(component, RT298_DAC_FORMAT, 0x407f, val);
snd_soc_update_bits(codec, RT298_ADC_FORMAT, 0x407f, val); snd_soc_component_update_bits(component, RT298_ADC_FORMAT, 0x407f, val);
return 0; return 0;
} }
static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt298_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;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFM:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL1, 0x800, 0x800); RT298_I2S_CTRL1, 0x800, 0x800);
break; break;
case SND_SOC_DAIFMT_CBS_CFS: case SND_SOC_DAIFMT_CBS_CFS:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL1, 0x800, 0x0); RT298_I2S_CTRL1, 0x800, 0x0);
break; break;
default: default:
...@@ -843,27 +843,27 @@ static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -843,27 +843,27 @@ static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_I2S:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL1, 0x300, 0x0); RT298_I2S_CTRL1, 0x300, 0x0);
break; break;
case SND_SOC_DAIFMT_LEFT_J: case SND_SOC_DAIFMT_LEFT_J:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL1, 0x300, 0x1 << 8); RT298_I2S_CTRL1, 0x300, 0x1 << 8);
break; break;
case SND_SOC_DAIFMT_DSP_A: case SND_SOC_DAIFMT_DSP_A:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL1, 0x300, 0x2 << 8); RT298_I2S_CTRL1, 0x300, 0x2 << 8);
break; break;
case SND_SOC_DAIFMT_DSP_B: case SND_SOC_DAIFMT_DSP_B:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL1, 0x300, 0x3 << 8); RT298_I2S_CTRL1, 0x300, 0x3 << 8);
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
/* bit 15 Stream Type 0:PCM 1:Non-PCM */ /* bit 15 Stream Type 0:PCM 1:Non-PCM */
snd_soc_update_bits(codec, RT298_DAC_FORMAT, 0x8000, 0); snd_soc_component_update_bits(component, RT298_DAC_FORMAT, 0x8000, 0);
snd_soc_update_bits(codec, RT298_ADC_FORMAT, 0x8000, 0); snd_soc_component_update_bits(component, RT298_ADC_FORMAT, 0x8000, 0);
return 0; return 0;
} }
...@@ -871,56 +871,56 @@ static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -871,56 +871,56 @@ static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
static int rt298_set_dai_sysclk(struct snd_soc_dai *dai, static int rt298_set_dai_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq); dev_dbg(component->dev, "%s freq=%d\n", __func__, freq);
if (RT298_SCLK_S_MCLK == clk_id) { if (RT298_SCLK_S_MCLK == clk_id) {
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL2, 0x0100, 0x0); RT298_I2S_CTRL2, 0x0100, 0x0);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_PLL_CTRL1, 0x20, 0x20); RT298_PLL_CTRL1, 0x20, 0x20);
} else { } else {
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL2, 0x0100, 0x0100); RT298_I2S_CTRL2, 0x0100, 0x0100);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_PLL_CTRL1, 0x20, 0x0); RT298_PLL_CTRL1, 0x20, 0x0);
} }
switch (freq) { switch (freq) {
case 19200000: case 19200000:
if (RT298_SCLK_S_MCLK == clk_id) { if (RT298_SCLK_S_MCLK == clk_id) {
dev_err(codec->dev, "Should not use MCLK\n"); dev_err(component->dev, "Should not use MCLK\n");
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL2, 0x40, 0x40); RT298_I2S_CTRL2, 0x40, 0x40);
break; break;
case 24000000: case 24000000:
if (RT298_SCLK_S_MCLK == clk_id) { if (RT298_SCLK_S_MCLK == clk_id) {
dev_err(codec->dev, "Should not use MCLK\n"); dev_err(component->dev, "Should not use MCLK\n");
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL2, 0x40, 0x0); RT298_I2S_CTRL2, 0x40, 0x0);
break; break;
case 12288000: case 12288000:
case 11289600: case 11289600:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL2, 0x8, 0x0); RT298_I2S_CTRL2, 0x8, 0x0);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_CLK_DIV, 0xfc1e, 0x0004); RT298_CLK_DIV, 0xfc1e, 0x0004);
break; break;
case 24576000: case 24576000:
case 22579200: case 22579200:
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL2, 0x8, 0x8); RT298_I2S_CTRL2, 0x8, 0x8);
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_CLK_DIV, 0xfc1e, 0x5406); RT298_CLK_DIV, 0xfc1e, 0x5406);
break; break;
default: default:
dev_err(codec->dev, "Unsupported system clock\n"); dev_err(component->dev, "Unsupported system clock\n");
return -EINVAL; return -EINVAL;
} }
...@@ -932,39 +932,39 @@ static int rt298_set_dai_sysclk(struct snd_soc_dai *dai, ...@@ -932,39 +932,39 @@ static int rt298_set_dai_sysclk(struct snd_soc_dai *dai,
static int rt298_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) static int rt298_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio);
if (50 == ratio) if (50 == ratio)
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL1, 0x1000, 0x1000); RT298_I2S_CTRL1, 0x1000, 0x1000);
else else
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
RT298_I2S_CTRL1, 0x1000, 0x0); RT298_I2S_CTRL1, 0x1000, 0x0);
return 0; return 0;
} }
static int rt298_set_bias_level(struct snd_soc_codec *codec, static int rt298_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
if (SND_SOC_BIAS_STANDBY == if (SND_SOC_BIAS_STANDBY ==
snd_soc_codec_get_bias_level(codec)) { snd_soc_component_get_bias_level(component)) {
snd_soc_write(codec, snd_soc_component_write(component,
RT298_SET_AUDIO_POWER, AC_PWRST_D0); RT298_SET_AUDIO_POWER, AC_PWRST_D0);
snd_soc_update_bits(codec, 0x0d, 0x200, 0x200); snd_soc_component_update_bits(component, 0x0d, 0x200, 0x200);
snd_soc_update_bits(codec, 0x52, 0x80, 0x0); snd_soc_component_update_bits(component, 0x52, 0x80, 0x0);
mdelay(20); mdelay(20);
snd_soc_update_bits(codec, 0x0d, 0x200, 0x0); snd_soc_component_update_bits(component, 0x0d, 0x200, 0x0);
snd_soc_update_bits(codec, 0x52, 0x80, 0x80); snd_soc_component_update_bits(component, 0x52, 0x80, 0x80);
} }
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
snd_soc_write(codec, snd_soc_component_write(component,
RT298_SET_AUDIO_POWER, AC_PWRST_D3); RT298_SET_AUDIO_POWER, AC_PWRST_D3);
break; break;
...@@ -1003,11 +1003,11 @@ static irqreturn_t rt298_irq(int irq, void *data) ...@@ -1003,11 +1003,11 @@ static irqreturn_t rt298_irq(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int rt298_probe(struct snd_soc_codec *codec) static int rt298_probe(struct snd_soc_component *component)
{ {
struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
rt298->codec = codec; rt298->component = component;
if (rt298->i2c->irq) { if (rt298->i2c->irq) {
regmap_update_bits(rt298->regmap, regmap_update_bits(rt298->regmap,
...@@ -1022,19 +1022,17 @@ static int rt298_probe(struct snd_soc_codec *codec) ...@@ -1022,19 +1022,17 @@ static int rt298_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int rt298_remove(struct snd_soc_codec *codec) static void rt298_remove(struct snd_soc_component *component)
{ {
struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
cancel_delayed_work_sync(&rt298->jack_detect_work); cancel_delayed_work_sync(&rt298->jack_detect_work);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int rt298_suspend(struct snd_soc_codec *codec) static int rt298_suspend(struct snd_soc_component *component)
{ {
struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
rt298->is_hp_in = -1; rt298->is_hp_in = -1;
regcache_cache_only(rt298->regmap, true); regcache_cache_only(rt298->regmap, true);
...@@ -1043,12 +1041,12 @@ static int rt298_suspend(struct snd_soc_codec *codec) ...@@ -1043,12 +1041,12 @@ static int rt298_suspend(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int rt298_resume(struct snd_soc_codec *codec) static int rt298_resume(struct snd_soc_component *component)
{ {
struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
regcache_cache_only(rt298->regmap, false); regcache_cache_only(rt298->regmap, false);
rt298_index_sync(codec); rt298_index_sync(component);
regcache_sync(rt298->regmap); regcache_sync(rt298->regmap);
return 0; return 0;
...@@ -1113,21 +1111,21 @@ static struct snd_soc_dai_driver rt298_dai[] = { ...@@ -1113,21 +1111,21 @@ static struct snd_soc_dai_driver rt298_dai[] = {
}; };
static const struct snd_soc_codec_driver soc_codec_dev_rt298 = { static const struct snd_soc_component_driver soc_component_dev_rt298 = {
.probe = rt298_probe, .probe = rt298_probe,
.remove = rt298_remove, .remove = rt298_remove,
.suspend = rt298_suspend, .suspend = rt298_suspend,
.resume = rt298_resume, .resume = rt298_resume,
.set_bias_level = rt298_set_bias_level, .set_bias_level = rt298_set_bias_level,
.idle_bias_off = true,
.component_driver = {
.controls = rt298_snd_controls, .controls = rt298_snd_controls,
.num_controls = ARRAY_SIZE(rt298_snd_controls), .num_controls = ARRAY_SIZE(rt298_snd_controls),
.dapm_widgets = rt298_dapm_widgets, .dapm_widgets = rt298_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(rt298_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(rt298_dapm_widgets),
.dapm_routes = rt298_dapm_routes, .dapm_routes = rt298_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(rt298_dapm_routes), .num_dapm_routes = ARRAY_SIZE(rt298_dapm_routes),
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config rt298_regmap = { static const struct regmap_config rt298_regmap = {
...@@ -1288,7 +1286,8 @@ static int rt298_i2c_probe(struct i2c_client *i2c, ...@@ -1288,7 +1286,8 @@ static int rt298_i2c_probe(struct i2c_client *i2c,
} }
} }
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt298, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_rt298,
rt298_dai, ARRAY_SIZE(rt298_dai)); rt298_dai, ARRAY_SIZE(rt298_dai));
return ret; return ret;
...@@ -1300,7 +1299,6 @@ static int rt298_i2c_remove(struct i2c_client *i2c) ...@@ -1300,7 +1299,6 @@ static int rt298_i2c_remove(struct i2c_client *i2c)
if (i2c->irq) if (i2c->irq)
free_irq(i2c->irq, rt298); free_irq(i2c->irq, rt298);
snd_soc_unregister_codec(&i2c->dev);
return 0; return 0;
} }
......
...@@ -210,7 +210,7 @@ enum { ...@@ -210,7 +210,7 @@ enum {
RT298_AIFS, RT298_AIFS,
}; };
int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); int rt298_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack);
#endif /* __RT298_H__ */ #endif /* __RT298_H__ */
...@@ -49,7 +49,7 @@ struct impedance_mapping_table { ...@@ -49,7 +49,7 @@ struct impedance_mapping_table {
}; };
struct rt5663_priv { struct rt5663_priv {
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct rt5663_platform_data pdata; struct rt5663_platform_data pdata;
struct regmap *regmap; struct regmap *regmap;
struct delayed_work jack_detect_work, jd_unplug_work; struct delayed_work jack_detect_work, jd_unplug_work;
...@@ -1384,57 +1384,57 @@ static const char * const rt5663_if1_adc_data_select[] = { ...@@ -1384,57 +1384,57 @@ static const char * const rt5663_if1_adc_data_select[] = {
static SOC_ENUM_SINGLE_DECL(rt5663_if1_adc_enum, RT5663_TDM_2, static SOC_ENUM_SINGLE_DECL(rt5663_if1_adc_enum, RT5663_TDM_2,
RT5663_DATA_SWAP_ADCDAT1_SHIFT, rt5663_if1_adc_data_select); RT5663_DATA_SWAP_ADCDAT1_SHIFT, rt5663_if1_adc_data_select);
static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec, static void rt5663_enable_push_button_irq(struct snd_soc_component *component,
bool enable) bool enable)
{ {
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
if (enable) { if (enable) {
snd_soc_update_bits(codec, RT5663_IL_CMD_6, snd_soc_component_update_bits(component, RT5663_IL_CMD_6,
RT5663_EN_4BTN_INL_MASK, RT5663_EN_4BTN_INL_EN); RT5663_EN_4BTN_INL_MASK, RT5663_EN_4BTN_INL_EN);
/* reset in-line command */ /* reset in-line command */
snd_soc_update_bits(codec, RT5663_IL_CMD_6, snd_soc_component_update_bits(component, RT5663_IL_CMD_6,
RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_MASK,
RT5663_RESET_4BTN_INL_RESET); RT5663_RESET_4BTN_INL_RESET);
snd_soc_update_bits(codec, RT5663_IL_CMD_6, snd_soc_component_update_bits(component, RT5663_IL_CMD_6,
RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_MASK,
RT5663_RESET_4BTN_INL_NOR); RT5663_RESET_4BTN_INL_NOR);
switch (rt5663->codec_ver) { switch (rt5663->codec_ver) {
case CODEC_VER_1: case CODEC_VER_1:
snd_soc_update_bits(codec, RT5663_IRQ_3, snd_soc_component_update_bits(component, RT5663_IRQ_3,
RT5663_V2_EN_IRQ_INLINE_MASK, RT5663_V2_EN_IRQ_INLINE_MASK,
RT5663_V2_EN_IRQ_INLINE_NOR); RT5663_V2_EN_IRQ_INLINE_NOR);
break; break;
case CODEC_VER_0: case CODEC_VER_0:
snd_soc_update_bits(codec, RT5663_IRQ_2, snd_soc_component_update_bits(component, RT5663_IRQ_2,
RT5663_EN_IRQ_INLINE_MASK, RT5663_EN_IRQ_INLINE_MASK,
RT5663_EN_IRQ_INLINE_NOR); RT5663_EN_IRQ_INLINE_NOR);
break; break;
default: default:
dev_err(codec->dev, "Unknown CODEC Version\n"); dev_err(component->dev, "Unknown CODEC Version\n");
} }
} else { } else {
switch (rt5663->codec_ver) { switch (rt5663->codec_ver) {
case CODEC_VER_1: case CODEC_VER_1:
snd_soc_update_bits(codec, RT5663_IRQ_3, snd_soc_component_update_bits(component, RT5663_IRQ_3,
RT5663_V2_EN_IRQ_INLINE_MASK, RT5663_V2_EN_IRQ_INLINE_MASK,
RT5663_V2_EN_IRQ_INLINE_BYP); RT5663_V2_EN_IRQ_INLINE_BYP);
break; break;
case CODEC_VER_0: case CODEC_VER_0:
snd_soc_update_bits(codec, RT5663_IRQ_2, snd_soc_component_update_bits(component, RT5663_IRQ_2,
RT5663_EN_IRQ_INLINE_MASK, RT5663_EN_IRQ_INLINE_MASK,
RT5663_EN_IRQ_INLINE_BYP); RT5663_EN_IRQ_INLINE_BYP);
break; break;
default: default:
dev_err(codec->dev, "Unknown CODEC Version\n"); dev_err(component->dev, "Unknown CODEC Version\n");
} }
snd_soc_update_bits(codec, RT5663_IL_CMD_6, snd_soc_component_update_bits(component, RT5663_IL_CMD_6,
RT5663_EN_4BTN_INL_MASK, RT5663_EN_4BTN_INL_DIS); RT5663_EN_4BTN_INL_MASK, RT5663_EN_4BTN_INL_DIS);
/* reset in-line command */ /* reset in-line command */
snd_soc_update_bits(codec, RT5663_IL_CMD_6, snd_soc_component_update_bits(component, RT5663_IL_CMD_6,
RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_MASK,
RT5663_RESET_4BTN_INL_RESET); RT5663_RESET_4BTN_INL_RESET);
snd_soc_update_bits(codec, RT5663_IL_CMD_6, snd_soc_component_update_bits(component, RT5663_IL_CMD_6,
RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_MASK,
RT5663_RESET_4BTN_INL_NOR); RT5663_RESET_4BTN_INL_NOR);
} }
...@@ -1442,7 +1442,7 @@ static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec, ...@@ -1442,7 +1442,7 @@ static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec,
/** /**
* rt5663_v2_jack_detect - Detect headset. * rt5663_v2_jack_detect - Detect headset.
* @codec: SoC audio codec device. * @component: SoC audio component device.
* @jack_insert: Jack insert or not. * @jack_insert: Jack insert or not.
* *
* Detect whether is headset or not when jack inserted. * Detect whether is headset or not when jack inserted.
...@@ -1450,41 +1450,41 @@ static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec, ...@@ -1450,41 +1450,41 @@ static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec,
* Returns detect status. * Returns detect status.
*/ */
static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert) static int rt5663_v2_jack_detect(struct snd_soc_component *component, int jack_insert)
{ {
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 rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
int val, i = 0, sleep_time[5] = {300, 150, 100, 50, 30}; int val, i = 0, sleep_time[5] = {300, 150, 100, 50, 30};
dev_dbg(codec->dev, "%s jack_insert:%d\n", __func__, jack_insert); dev_dbg(component->dev, "%s jack_insert:%d\n", __func__, jack_insert);
if (jack_insert) { if (jack_insert) {
snd_soc_write(codec, RT5663_CBJ_TYPE_2, 0x8040); snd_soc_component_write(component, RT5663_CBJ_TYPE_2, 0x8040);
snd_soc_write(codec, RT5663_CBJ_TYPE_3, 0x1484); snd_soc_component_write(component, RT5663_CBJ_TYPE_3, 0x1484);
snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
snd_soc_dapm_force_enable_pin(dapm, "MICBIAS2"); snd_soc_dapm_force_enable_pin(dapm, "MICBIAS2");
snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power");
snd_soc_dapm_force_enable_pin(dapm, "CBJ Power"); snd_soc_dapm_force_enable_pin(dapm, "CBJ Power");
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
snd_soc_update_bits(codec, RT5663_RC_CLK, snd_soc_component_update_bits(component, RT5663_RC_CLK,
RT5663_DIG_1M_CLK_MASK, RT5663_DIG_1M_CLK_EN); RT5663_DIG_1M_CLK_MASK, RT5663_DIG_1M_CLK_EN);
snd_soc_update_bits(codec, RT5663_RECMIX, 0x8, 0x8); snd_soc_component_update_bits(component, RT5663_RECMIX, 0x8, 0x8);
while (i < 5) { while (i < 5) {
msleep(sleep_time[i]); msleep(sleep_time[i]);
val = snd_soc_read(codec, RT5663_CBJ_TYPE_2) & 0x0003; val = snd_soc_component_read32(component, RT5663_CBJ_TYPE_2) & 0x0003;
if (val == 0x1 || val == 0x2 || val == 0x3) if (val == 0x1 || val == 0x2 || val == 0x3)
break; break;
dev_dbg(codec->dev, "%s: MX-0011 val=%x sleep %d\n", dev_dbg(component->dev, "%s: MX-0011 val=%x sleep %d\n",
__func__, val, sleep_time[i]); __func__, val, sleep_time[i]);
i++; i++;
} }
dev_dbg(codec->dev, "%s val = %d\n", __func__, val); dev_dbg(component->dev, "%s val = %d\n", __func__, val);
switch (val) { switch (val) {
case 1: case 1:
case 2: case 2:
rt5663->jack_type = SND_JACK_HEADSET; rt5663->jack_type = SND_JACK_HEADSET;
rt5663_enable_push_button_irq(codec, true); rt5663_enable_push_button_irq(component, true);
break; break;
default: default:
snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); snd_soc_dapm_disable_pin(dapm, "MICBIAS1");
...@@ -1496,10 +1496,10 @@ static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert) ...@@ -1496,10 +1496,10 @@ static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert)
break; break;
} }
} else { } else {
snd_soc_update_bits(codec, RT5663_RECMIX, 0x8, 0x0); snd_soc_component_update_bits(component, RT5663_RECMIX, 0x8, 0x0);
if (rt5663->jack_type == SND_JACK_HEADSET) { if (rt5663->jack_type == SND_JACK_HEADSET) {
rt5663_enable_push_button_irq(codec, false); rt5663_enable_push_button_irq(component, false);
snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); snd_soc_dapm_disable_pin(dapm, "MICBIAS1");
snd_soc_dapm_disable_pin(dapm, "MICBIAS2"); snd_soc_dapm_disable_pin(dapm, "MICBIAS2");
snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
...@@ -1509,60 +1509,60 @@ static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert) ...@@ -1509,60 +1509,60 @@ static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert)
rt5663->jack_type = 0; rt5663->jack_type = 0;
} }
dev_dbg(codec->dev, "jack_type = %d\n", rt5663->jack_type); dev_dbg(component->dev, "jack_type = %d\n", rt5663->jack_type);
return rt5663->jack_type; return rt5663->jack_type;
} }
/** /**
* rt5663_jack_detect - Detect headset. * rt5663_jack_detect - Detect headset.
* @codec: SoC audio codec device. * @component: SoC audio component device.
* @jack_insert: Jack insert or not. * @jack_insert: Jack insert or not.
* *
* Detect whether is headset or not when jack inserted. * Detect whether is headset or not when jack inserted.
* *
* Returns detect status. * Returns detect status.
*/ */
static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) static int rt5663_jack_detect(struct snd_soc_component *component, int jack_insert)
{ {
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
int val, i = 0; int val, i = 0;
dev_dbg(codec->dev, "%s jack_insert:%d\n", __func__, jack_insert); dev_dbg(component->dev, "%s jack_insert:%d\n", __func__, jack_insert);
if (jack_insert) { if (jack_insert) {
snd_soc_update_bits(codec, RT5663_DIG_MISC, snd_soc_component_update_bits(component, RT5663_DIG_MISC,
RT5663_DIG_GATE_CTRL_MASK, RT5663_DIG_GATE_CTRL_EN); RT5663_DIG_GATE_CTRL_MASK, RT5663_DIG_GATE_CTRL_EN);
snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1,
RT5663_SI_HP_MASK | RT5663_OSW_HP_L_MASK | RT5663_SI_HP_MASK | RT5663_OSW_HP_L_MASK |
RT5663_OSW_HP_R_MASK, RT5663_SI_HP_EN | RT5663_OSW_HP_R_MASK, RT5663_SI_HP_EN |
RT5663_OSW_HP_L_DIS | RT5663_OSW_HP_R_DIS); RT5663_OSW_HP_L_DIS | RT5663_OSW_HP_R_DIS);
snd_soc_update_bits(codec, RT5663_DUMMY_1, snd_soc_component_update_bits(component, RT5663_DUMMY_1,
RT5663_EMB_CLK_MASK | RT5663_HPA_CPL_BIAS_MASK | RT5663_EMB_CLK_MASK | RT5663_HPA_CPL_BIAS_MASK |
RT5663_HPA_CPR_BIAS_MASK, RT5663_EMB_CLK_EN | RT5663_HPA_CPR_BIAS_MASK, RT5663_EMB_CLK_EN |
RT5663_HPA_CPL_BIAS_1 | RT5663_HPA_CPR_BIAS_1); RT5663_HPA_CPL_BIAS_1 | RT5663_HPA_CPR_BIAS_1);
snd_soc_update_bits(codec, RT5663_CBJ_1, snd_soc_component_update_bits(component, RT5663_CBJ_1,
RT5663_INBUF_CBJ_BST1_MASK | RT5663_CBJ_SENSE_BST1_MASK, RT5663_INBUF_CBJ_BST1_MASK | RT5663_CBJ_SENSE_BST1_MASK,
RT5663_INBUF_CBJ_BST1_ON | RT5663_CBJ_SENSE_BST1_L); RT5663_INBUF_CBJ_BST1_ON | RT5663_CBJ_SENSE_BST1_L);
snd_soc_update_bits(codec, RT5663_IL_CMD_2, snd_soc_component_update_bits(component, RT5663_IL_CMD_2,
RT5663_PWR_MIC_DET_MASK, RT5663_PWR_MIC_DET_ON); RT5663_PWR_MIC_DET_MASK, RT5663_PWR_MIC_DET_ON);
/* BST1 power on for JD */ /* BST1 power on for JD */
snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2,
RT5663_PWR_BST1_MASK, RT5663_PWR_BST1_ON); RT5663_PWR_BST1_MASK, RT5663_PWR_BST1_ON);
snd_soc_update_bits(codec, RT5663_EM_JACK_TYPE_1, snd_soc_component_update_bits(component, RT5663_EM_JACK_TYPE_1,
RT5663_CBJ_DET_MASK | RT5663_EXT_JD_MASK | RT5663_CBJ_DET_MASK | RT5663_EXT_JD_MASK |
RT5663_POL_EXT_JD_MASK, RT5663_CBJ_DET_EN | RT5663_POL_EXT_JD_MASK, RT5663_CBJ_DET_EN |
RT5663_EXT_JD_EN | RT5663_POL_EXT_JD_EN); RT5663_EXT_JD_EN | RT5663_POL_EXT_JD_EN);
snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1,
RT5663_PWR_MB_MASK | RT5663_LDO1_DVO_MASK | RT5663_PWR_MB_MASK | RT5663_LDO1_DVO_MASK |
RT5663_AMP_HP_MASK, RT5663_PWR_MB | RT5663_AMP_HP_MASK, RT5663_PWR_MB |
RT5663_LDO1_DVO_0_9V | RT5663_AMP_HP_3X); RT5663_LDO1_DVO_0_9V | RT5663_AMP_HP_3X);
snd_soc_update_bits(codec, RT5663_AUTO_1MRC_CLK, snd_soc_component_update_bits(component, RT5663_AUTO_1MRC_CLK,
RT5663_IRQ_POW_SAV_MASK, RT5663_IRQ_POW_SAV_EN); RT5663_IRQ_POW_SAV_MASK, RT5663_IRQ_POW_SAV_EN);
snd_soc_update_bits(codec, RT5663_IRQ_1, snd_soc_component_update_bits(component, RT5663_IRQ_1,
RT5663_EN_IRQ_JD1_MASK, RT5663_EN_IRQ_JD1_EN); RT5663_EN_IRQ_JD1_MASK, RT5663_EN_IRQ_JD1_EN);
snd_soc_update_bits(codec, RT5663_EM_JACK_TYPE_1, snd_soc_component_update_bits(component, RT5663_EM_JACK_TYPE_1,
RT5663_EM_JD_MASK, RT5663_EM_JD_RST); RT5663_EM_JD_MASK, RT5663_EM_JD_RST);
snd_soc_update_bits(codec, RT5663_EM_JACK_TYPE_1, snd_soc_component_update_bits(component, RT5663_EM_JACK_TYPE_1,
RT5663_EM_JD_MASK, RT5663_EM_JD_NOR); RT5663_EM_JD_MASK, RT5663_EM_JD_NOR);
while (true) { while (true) {
...@@ -1577,10 +1577,10 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) ...@@ -1577,10 +1577,10 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert)
i++; i++;
} }
val = snd_soc_read(codec, RT5663_EM_JACK_TYPE_2) & 0x0003; val = snd_soc_component_read32(component, RT5663_EM_JACK_TYPE_2) & 0x0003;
dev_dbg(codec->dev, "%s val = %d\n", __func__, val); dev_dbg(component->dev, "%s val = %d\n", __func__, val);
snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1,
RT5663_OSW_HP_L_MASK | RT5663_OSW_HP_R_MASK, RT5663_OSW_HP_L_MASK | RT5663_OSW_HP_R_MASK,
RT5663_OSW_HP_L_EN | RT5663_OSW_HP_R_EN); RT5663_OSW_HP_L_EN | RT5663_OSW_HP_R_EN);
...@@ -1588,7 +1588,7 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) ...@@ -1588,7 +1588,7 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert)
case 1: case 1:
case 2: case 2:
rt5663->jack_type = SND_JACK_HEADSET; rt5663->jack_type = SND_JACK_HEADSET;
rt5663_enable_push_button_irq(codec, true); rt5663_enable_push_button_irq(component, true);
if (rt5663->pdata.impedance_sensing_num) if (rt5663->pdata.impedance_sensing_num)
break; break;
...@@ -1636,17 +1636,17 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) ...@@ -1636,17 +1636,17 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert)
} }
} else { } else {
if (rt5663->jack_type == SND_JACK_HEADSET) if (rt5663->jack_type == SND_JACK_HEADSET)
rt5663_enable_push_button_irq(codec, false); rt5663_enable_push_button_irq(component, false);
rt5663->jack_type = 0; rt5663->jack_type = 0;
} }
dev_dbg(codec->dev, "jack_type = %d\n", rt5663->jack_type); dev_dbg(component->dev, "jack_type = %d\n", rt5663->jack_type);
return rt5663->jack_type; return rt5663->jack_type;
} }
static int rt5663_impedance_sensing(struct snd_soc_codec *codec) static int rt5663_impedance_sensing(struct snd_soc_component *component)
{ {
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
unsigned int value, i, reg84, reg26, reg2fa, reg91, reg10, reg80; unsigned int value, i, reg84, reg26, reg2fa, reg91, reg10, reg80;
for (i = 0; i < rt5663->pdata.impedance_sensing_num; i++) { for (i = 0; i < rt5663->pdata.impedance_sensing_num; i++) {
...@@ -1655,59 +1655,59 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec) ...@@ -1655,59 +1655,59 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec)
} }
if (rt5663->jack_type == SND_JACK_HEADSET) { if (rt5663->jack_type == SND_JACK_HEADSET) {
snd_soc_write(codec, RT5663_MIC_DECRO_2, snd_soc_component_write(component, RT5663_MIC_DECRO_2,
rt5663->imp_table[i].dc_offset_l_manual_mic >> 16); rt5663->imp_table[i].dc_offset_l_manual_mic >> 16);
snd_soc_write(codec, RT5663_MIC_DECRO_3, snd_soc_component_write(component, RT5663_MIC_DECRO_3,
rt5663->imp_table[i].dc_offset_l_manual_mic & 0xffff); rt5663->imp_table[i].dc_offset_l_manual_mic & 0xffff);
snd_soc_write(codec, RT5663_MIC_DECRO_5, snd_soc_component_write(component, RT5663_MIC_DECRO_5,
rt5663->imp_table[i].dc_offset_r_manual_mic >> 16); rt5663->imp_table[i].dc_offset_r_manual_mic >> 16);
snd_soc_write(codec, RT5663_MIC_DECRO_6, snd_soc_component_write(component, RT5663_MIC_DECRO_6,
rt5663->imp_table[i].dc_offset_r_manual_mic & 0xffff); rt5663->imp_table[i].dc_offset_r_manual_mic & 0xffff);
} else { } else {
snd_soc_write(codec, RT5663_MIC_DECRO_2, snd_soc_component_write(component, RT5663_MIC_DECRO_2,
rt5663->imp_table[i].dc_offset_l_manual >> 16); rt5663->imp_table[i].dc_offset_l_manual >> 16);
snd_soc_write(codec, RT5663_MIC_DECRO_3, snd_soc_component_write(component, RT5663_MIC_DECRO_3,
rt5663->imp_table[i].dc_offset_l_manual & 0xffff); rt5663->imp_table[i].dc_offset_l_manual & 0xffff);
snd_soc_write(codec, RT5663_MIC_DECRO_5, snd_soc_component_write(component, RT5663_MIC_DECRO_5,
rt5663->imp_table[i].dc_offset_r_manual >> 16); rt5663->imp_table[i].dc_offset_r_manual >> 16);
snd_soc_write(codec, RT5663_MIC_DECRO_6, snd_soc_component_write(component, RT5663_MIC_DECRO_6,
rt5663->imp_table[i].dc_offset_r_manual & 0xffff); rt5663->imp_table[i].dc_offset_r_manual & 0xffff);
} }
reg84 = snd_soc_read(codec, RT5663_ASRC_2); reg84 = snd_soc_component_read32(component, RT5663_ASRC_2);
reg26 = snd_soc_read(codec, RT5663_STO1_ADC_MIXER); reg26 = snd_soc_component_read32(component, RT5663_STO1_ADC_MIXER);
reg2fa = snd_soc_read(codec, RT5663_DUMMY_1); reg2fa = snd_soc_component_read32(component, RT5663_DUMMY_1);
reg91 = snd_soc_read(codec, RT5663_HP_CHARGE_PUMP_1); reg91 = snd_soc_component_read32(component, RT5663_HP_CHARGE_PUMP_1);
reg10 = snd_soc_read(codec, RT5663_RECMIX); reg10 = snd_soc_component_read32(component, RT5663_RECMIX);
reg80 = snd_soc_read(codec, RT5663_GLB_CLK); reg80 = snd_soc_component_read32(component, RT5663_GLB_CLK);
snd_soc_update_bits(codec, RT5663_STO_DRE_1, 0x8000, 0); snd_soc_component_update_bits(component, RT5663_STO_DRE_1, 0x8000, 0);
snd_soc_write(codec, RT5663_ASRC_2, 0); snd_soc_component_write(component, RT5663_ASRC_2, 0);
snd_soc_write(codec, RT5663_STO1_ADC_MIXER, 0x4040); snd_soc_component_write(component, RT5663_STO1_ADC_MIXER, 0x4040);
snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1,
RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK | RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK |
RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK, RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK,
RT5663_PWR_VREF1 | RT5663_PWR_VREF2); RT5663_PWR_VREF1 | RT5663_PWR_VREF2);
usleep_range(10000, 10005); usleep_range(10000, 10005);
snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1,
RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK, RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK,
RT5663_PWR_FV1 | RT5663_PWR_FV2); RT5663_PWR_FV1 | RT5663_PWR_FV2);
snd_soc_update_bits(codec, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, snd_soc_component_update_bits(component, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK,
RT5663_SCLK_SRC_RCCLK); RT5663_SCLK_SRC_RCCLK);
snd_soc_update_bits(codec, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK, snd_soc_component_update_bits(component, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK,
RT5663_DIG_25M_CLK_EN); RT5663_DIG_25M_CLK_EN);
snd_soc_update_bits(codec, RT5663_ADDA_CLK_1, RT5663_I2S_PD1_MASK, 0); snd_soc_component_update_bits(component, RT5663_ADDA_CLK_1, RT5663_I2S_PD1_MASK, 0);
snd_soc_write(codec, RT5663_PRE_DIV_GATING_1, 0xff00); snd_soc_component_write(component, RT5663_PRE_DIV_GATING_1, 0xff00);
snd_soc_write(codec, RT5663_PRE_DIV_GATING_2, 0xfffc); snd_soc_component_write(component, RT5663_PRE_DIV_GATING_2, 0xfffc);
snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_1, 0x1232); snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_1, 0x1232);
snd_soc_write(codec, RT5663_HP_LOGIC_2, 0x0005); snd_soc_component_write(component, RT5663_HP_LOGIC_2, 0x0005);
snd_soc_write(codec, RT5663_DEPOP_2, 0x3003); snd_soc_component_write(component, RT5663_DEPOP_2, 0x3003);
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0x0030); snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0x0030);
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, 0x0003); snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0x0003);
snd_soc_update_bits(codec, RT5663_PWR_DIG_2, snd_soc_component_update_bits(component, RT5663_PWR_DIG_2,
RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F, RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F,
RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F); RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F);
snd_soc_update_bits(codec, RT5663_PWR_DIG_1, snd_soc_component_update_bits(component, RT5663_PWR_DIG_1,
RT5663_PWR_DAC_L1 | RT5663_PWR_DAC_R1 | RT5663_PWR_DAC_L1 | RT5663_PWR_DAC_R1 |
RT5663_PWR_LDO_DACREF_MASK | RT5663_PWR_ADC_L1 | RT5663_PWR_LDO_DACREF_MASK | RT5663_PWR_ADC_L1 |
RT5663_PWR_ADC_R1, RT5663_PWR_ADC_R1,
...@@ -1715,71 +1715,71 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec) ...@@ -1715,71 +1715,71 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec)
RT5663_PWR_LDO_DACREF_ON | RT5663_PWR_ADC_L1 | RT5663_PWR_LDO_DACREF_ON | RT5663_PWR_ADC_L1 |
RT5663_PWR_ADC_R1); RT5663_PWR_ADC_R1);
msleep(40); msleep(40);
snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2,
RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2, RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2,
RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2); RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2);
msleep(30); msleep(30);
snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_2, 0x1371); snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_2, 0x1371);
snd_soc_write(codec, RT5663_STO_DAC_MIXER, 0); snd_soc_component_write(component, RT5663_STO_DAC_MIXER, 0);
snd_soc_write(codec, RT5663_BYPASS_STO_DAC, 0x000c); snd_soc_component_write(component, RT5663_BYPASS_STO_DAC, 0x000c);
snd_soc_write(codec, RT5663_HP_BIAS, 0xafaa); snd_soc_component_write(component, RT5663_HP_BIAS, 0xafaa);
snd_soc_write(codec, RT5663_CHARGE_PUMP_1, 0x2224); snd_soc_component_write(component, RT5663_CHARGE_PUMP_1, 0x2224);
snd_soc_write(codec, RT5663_HP_OUT_EN, 0x8088); snd_soc_component_write(component, RT5663_HP_OUT_EN, 0x8088);
snd_soc_write(codec, RT5663_CHOP_ADC, 0x3000); snd_soc_component_write(component, RT5663_CHOP_ADC, 0x3000);
snd_soc_write(codec, RT5663_ADDA_RST, 0xc000); snd_soc_component_write(component, RT5663_ADDA_RST, 0xc000);
snd_soc_write(codec, RT5663_STO1_HPF_ADJ1, 0x3320); snd_soc_component_write(component, RT5663_STO1_HPF_ADJ1, 0x3320);
snd_soc_write(codec, RT5663_HP_CALIB_2, 0x00c9); snd_soc_component_write(component, RT5663_HP_CALIB_2, 0x00c9);
snd_soc_write(codec, RT5663_DUMMY_1, 0x004c); snd_soc_component_write(component, RT5663_DUMMY_1, 0x004c);
snd_soc_write(codec, RT5663_ANA_BIAS_CUR_1, 0x7733); snd_soc_component_write(component, RT5663_ANA_BIAS_CUR_1, 0x7733);
snd_soc_write(codec, RT5663_CHARGE_PUMP_2, 0x7777); snd_soc_component_write(component, RT5663_CHARGE_PUMP_2, 0x7777);
snd_soc_write(codec, RT5663_STO_DRE_9, 0x0007); snd_soc_component_write(component, RT5663_STO_DRE_9, 0x0007);
snd_soc_write(codec, RT5663_STO_DRE_10, 0x0007); snd_soc_component_write(component, RT5663_STO_DRE_10, 0x0007);
snd_soc_write(codec, RT5663_DUMMY_2, 0x02a4); snd_soc_component_write(component, RT5663_DUMMY_2, 0x02a4);
snd_soc_write(codec, RT5663_RECMIX, 0x0005); snd_soc_component_write(component, RT5663_RECMIX, 0x0005);
snd_soc_write(codec, RT5663_HP_IMP_SEN_1, 0x4334); snd_soc_component_write(component, RT5663_HP_IMP_SEN_1, 0x4334);
snd_soc_update_bits(codec, RT5663_IRQ_3, 0x0004, 0x0004); snd_soc_component_update_bits(component, RT5663_IRQ_3, 0x0004, 0x0004);
snd_soc_write(codec, RT5663_HP_LOGIC_1, 0x2200); snd_soc_component_write(component, RT5663_HP_LOGIC_1, 0x2200);
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0x3000); snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0x3000);
snd_soc_write(codec, RT5663_HP_LOGIC_1, 0x6200); snd_soc_component_write(component, RT5663_HP_LOGIC_1, 0x6200);
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
msleep(20); msleep(20);
if (snd_soc_read(codec, RT5663_INT_ST_1) & 0x2) if (snd_soc_component_read32(component, RT5663_INT_ST_1) & 0x2)
break; break;
} }
value = snd_soc_read(codec, RT5663_HP_IMP_SEN_4); value = snd_soc_component_read32(component, RT5663_HP_IMP_SEN_4);
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0); snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0);
snd_soc_write(codec, RT5663_INT_ST_1, 0); snd_soc_component_write(component, RT5663_INT_ST_1, 0);
snd_soc_write(codec, RT5663_HP_LOGIC_1, 0); snd_soc_component_write(component, RT5663_HP_LOGIC_1, 0);
snd_soc_update_bits(codec, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK, snd_soc_component_update_bits(component, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK,
RT5663_DIG_25M_CLK_DIS); RT5663_DIG_25M_CLK_DIS);
snd_soc_write(codec, RT5663_GLB_CLK, reg80); snd_soc_component_write(component, RT5663_GLB_CLK, reg80);
snd_soc_write(codec, RT5663_RECMIX, reg10); snd_soc_component_write(component, RT5663_RECMIX, reg10);
snd_soc_write(codec, RT5663_DUMMY_2, 0x00a4); snd_soc_component_write(component, RT5663_DUMMY_2, 0x00a4);
snd_soc_write(codec, RT5663_DUMMY_1, reg2fa); snd_soc_component_write(component, RT5663_DUMMY_1, reg2fa);
snd_soc_write(codec, RT5663_HP_CALIB_2, 0x00c8); snd_soc_component_write(component, RT5663_HP_CALIB_2, 0x00c8);
snd_soc_write(codec, RT5663_STO1_HPF_ADJ1, 0xb320); snd_soc_component_write(component, RT5663_STO1_HPF_ADJ1, 0xb320);
snd_soc_write(codec, RT5663_ADDA_RST, 0xe400); snd_soc_component_write(component, RT5663_ADDA_RST, 0xe400);
snd_soc_write(codec, RT5663_CHOP_ADC, 0x2000); snd_soc_component_write(component, RT5663_CHOP_ADC, 0x2000);
snd_soc_write(codec, RT5663_HP_OUT_EN, 0x0008); snd_soc_component_write(component, RT5663_HP_OUT_EN, 0x0008);
snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2,
RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2, 0); RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2, 0);
snd_soc_update_bits(codec, RT5663_PWR_DIG_1, snd_soc_component_update_bits(component, RT5663_PWR_DIG_1,
RT5663_PWR_DAC_L1 | RT5663_PWR_DAC_R1 | RT5663_PWR_DAC_L1 | RT5663_PWR_DAC_R1 |
RT5663_PWR_LDO_DACREF_MASK | RT5663_PWR_ADC_L1 | RT5663_PWR_LDO_DACREF_MASK | RT5663_PWR_ADC_L1 |
RT5663_PWR_ADC_R1, 0); RT5663_PWR_ADC_R1, 0);
snd_soc_update_bits(codec, RT5663_PWR_DIG_2, snd_soc_component_update_bits(component, RT5663_PWR_DIG_2,
RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F, 0); RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F, 0);
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, 0); snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0);
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0); snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0);
snd_soc_write(codec, RT5663_HP_LOGIC_2, 0); snd_soc_component_write(component, RT5663_HP_LOGIC_2, 0);
snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_1, reg91); snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_1, reg91);
snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1,
RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK, 0); RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK, 0);
snd_soc_write(codec, RT5663_STO1_ADC_MIXER, reg26); snd_soc_component_write(component, RT5663_STO1_ADC_MIXER, reg26);
snd_soc_write(codec, RT5663_ASRC_2, reg84); snd_soc_component_write(component, RT5663_ASRC_2, reg84);
for (i = 0; i < rt5663->pdata.impedance_sensing_num; i++) { for (i = 0; i < rt5663->pdata.impedance_sensing_num; i++) {
if (value >= rt5663->imp_table[i].imp_min && if (value >= rt5663->imp_table[i].imp_min &&
...@@ -1787,42 +1787,42 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec) ...@@ -1787,42 +1787,42 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec)
break; break;
} }
snd_soc_update_bits(codec, RT5663_STO_DRE_9, RT5663_DRE_GAIN_HP_MASK, snd_soc_component_update_bits(component, RT5663_STO_DRE_9, RT5663_DRE_GAIN_HP_MASK,
rt5663->imp_table[i].vol); rt5663->imp_table[i].vol);
snd_soc_update_bits(codec, RT5663_STO_DRE_10, RT5663_DRE_GAIN_HP_MASK, snd_soc_component_update_bits(component, RT5663_STO_DRE_10, RT5663_DRE_GAIN_HP_MASK,
rt5663->imp_table[i].vol); rt5663->imp_table[i].vol);
if (rt5663->jack_type == SND_JACK_HEADSET) { if (rt5663->jack_type == SND_JACK_HEADSET) {
snd_soc_write(codec, RT5663_MIC_DECRO_2, snd_soc_component_write(component, RT5663_MIC_DECRO_2,
rt5663->imp_table[i].dc_offset_l_manual_mic >> 16); rt5663->imp_table[i].dc_offset_l_manual_mic >> 16);
snd_soc_write(codec, RT5663_MIC_DECRO_3, snd_soc_component_write(component, RT5663_MIC_DECRO_3,
rt5663->imp_table[i].dc_offset_l_manual_mic & 0xffff); rt5663->imp_table[i].dc_offset_l_manual_mic & 0xffff);
snd_soc_write(codec, RT5663_MIC_DECRO_5, snd_soc_component_write(component, RT5663_MIC_DECRO_5,
rt5663->imp_table[i].dc_offset_r_manual_mic >> 16); rt5663->imp_table[i].dc_offset_r_manual_mic >> 16);
snd_soc_write(codec, RT5663_MIC_DECRO_6, snd_soc_component_write(component, RT5663_MIC_DECRO_6,
rt5663->imp_table[i].dc_offset_r_manual_mic & 0xffff); rt5663->imp_table[i].dc_offset_r_manual_mic & 0xffff);
} else { } else {
snd_soc_write(codec, RT5663_MIC_DECRO_2, snd_soc_component_write(component, RT5663_MIC_DECRO_2,
rt5663->imp_table[i].dc_offset_l_manual >> 16); rt5663->imp_table[i].dc_offset_l_manual >> 16);
snd_soc_write(codec, RT5663_MIC_DECRO_3, snd_soc_component_write(component, RT5663_MIC_DECRO_3,
rt5663->imp_table[i].dc_offset_l_manual & 0xffff); rt5663->imp_table[i].dc_offset_l_manual & 0xffff);
snd_soc_write(codec, RT5663_MIC_DECRO_5, snd_soc_component_write(component, RT5663_MIC_DECRO_5,
rt5663->imp_table[i].dc_offset_r_manual >> 16); rt5663->imp_table[i].dc_offset_r_manual >> 16);
snd_soc_write(codec, RT5663_MIC_DECRO_6, snd_soc_component_write(component, RT5663_MIC_DECRO_6,
rt5663->imp_table[i].dc_offset_r_manual & 0xffff); rt5663->imp_table[i].dc_offset_r_manual & 0xffff);
} }
return 0; return 0;
} }
static int rt5663_button_detect(struct snd_soc_codec *codec) static int rt5663_button_detect(struct snd_soc_component *component)
{ {
int btn_type, val; int btn_type, val;
val = snd_soc_read(codec, RT5663_IL_CMD_5); val = snd_soc_component_read32(component, RT5663_IL_CMD_5);
dev_dbg(codec->dev, "%s: val=0x%x\n", __func__, val); dev_dbg(component->dev, "%s: val=0x%x\n", __func__, val);
btn_type = val & 0xfff0; btn_type = val & 0xfff0;
snd_soc_write(codec, RT5663_IL_CMD_5, val); snd_soc_component_write(component, RT5663_IL_CMD_5, val);
return btn_type; return btn_type;
} }
...@@ -1840,10 +1840,10 @@ static irqreturn_t rt5663_irq(int irq, void *data) ...@@ -1840,10 +1840,10 @@ static irqreturn_t rt5663_irq(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
int rt5663_set_jack_detect(struct snd_soc_codec *codec, int rt5663_set_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *hs_jack) struct snd_soc_jack *hs_jack)
{ {
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
rt5663->hs_jack = hs_jack; rt5663->hs_jack = hs_jack;
...@@ -1853,12 +1853,12 @@ int rt5663_set_jack_detect(struct snd_soc_codec *codec, ...@@ -1853,12 +1853,12 @@ int rt5663_set_jack_detect(struct snd_soc_codec *codec,
} }
EXPORT_SYMBOL_GPL(rt5663_set_jack_detect); EXPORT_SYMBOL_GPL(rt5663_set_jack_detect);
static bool rt5663_check_jd_status(struct snd_soc_codec *codec) static bool rt5663_check_jd_status(struct snd_soc_component *component)
{ {
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
int val = snd_soc_read(codec, RT5663_INT_ST_1); int val = snd_soc_component_read32(component, RT5663_INT_ST_1);
dev_dbg(codec->dev, "%s val=%x\n", __func__, val); dev_dbg(component->dev, "%s val=%x\n", __func__, val);
/* JD1 */ /* JD1 */
switch (rt5663->codec_ver) { switch (rt5663->codec_ver) {
...@@ -1867,7 +1867,7 @@ static bool rt5663_check_jd_status(struct snd_soc_codec *codec) ...@@ -1867,7 +1867,7 @@ static bool rt5663_check_jd_status(struct snd_soc_codec *codec)
case CODEC_VER_0: case CODEC_VER_0:
return !(val & 0x1000); return !(val & 0x1000);
default: default:
dev_err(codec->dev, "Unknown CODEC Version\n"); dev_err(component->dev, "Unknown CODEC Version\n");
} }
return false; return false;
...@@ -1877,28 +1877,28 @@ static void rt5663_jack_detect_work(struct work_struct *work) ...@@ -1877,28 +1877,28 @@ static void rt5663_jack_detect_work(struct work_struct *work)
{ {
struct rt5663_priv *rt5663 = struct rt5663_priv *rt5663 =
container_of(work, struct rt5663_priv, jack_detect_work.work); container_of(work, struct rt5663_priv, jack_detect_work.work);
struct snd_soc_codec *codec = rt5663->codec; struct snd_soc_component *component = rt5663->component;
int btn_type, report = 0; int btn_type, report = 0;
if (!codec) if (!component)
return; return;
if (rt5663_check_jd_status(codec)) { if (rt5663_check_jd_status(component)) {
/* jack in */ /* jack in */
if (rt5663->jack_type == 0) { if (rt5663->jack_type == 0) {
/* jack was out, report jack type */ /* jack was out, report jack type */
switch (rt5663->codec_ver) { switch (rt5663->codec_ver) {
case CODEC_VER_1: case CODEC_VER_1:
report = rt5663_v2_jack_detect( report = rt5663_v2_jack_detect(
rt5663->codec, 1); rt5663->component, 1);
break; break;
case CODEC_VER_0: case CODEC_VER_0:
report = rt5663_jack_detect(rt5663->codec, 1); report = rt5663_jack_detect(rt5663->component, 1);
if (rt5663->pdata.impedance_sensing_num) if (rt5663->pdata.impedance_sensing_num)
rt5663_impedance_sensing(rt5663->codec); rt5663_impedance_sensing(rt5663->component);
break; break;
default: default:
dev_err(codec->dev, "Unknown CODEC Version\n"); dev_err(component->dev, "Unknown CODEC Version\n");
} }
/* Delay the jack insert report to avoid pop noise */ /* Delay the jack insert report to avoid pop noise */
...@@ -1906,7 +1906,7 @@ static void rt5663_jack_detect_work(struct work_struct *work) ...@@ -1906,7 +1906,7 @@ static void rt5663_jack_detect_work(struct work_struct *work)
} else { } else {
/* jack is already in, report button event */ /* jack is already in, report button event */
report = SND_JACK_HEADSET; report = SND_JACK_HEADSET;
btn_type = rt5663_button_detect(rt5663->codec); btn_type = rt5663_button_detect(rt5663->component);
/** /**
* rt5663 can report three kinds of button behavior, * rt5663 can report three kinds of button behavior,
* one click, double click and hold. However, * one click, double click and hold. However,
...@@ -1939,7 +1939,7 @@ static void rt5663_jack_detect_work(struct work_struct *work) ...@@ -1939,7 +1939,7 @@ static void rt5663_jack_detect_work(struct work_struct *work)
break; break;
default: default:
btn_type = 0; btn_type = 0;
dev_err(rt5663->codec->dev, dev_err(rt5663->component->dev,
"Unexpected button code 0x%04x\n", "Unexpected button code 0x%04x\n",
btn_type); btn_type);
break; break;
...@@ -1959,16 +1959,16 @@ static void rt5663_jack_detect_work(struct work_struct *work) ...@@ -1959,16 +1959,16 @@ static void rt5663_jack_detect_work(struct work_struct *work)
/* jack out */ /* jack out */
switch (rt5663->codec_ver) { switch (rt5663->codec_ver) {
case CODEC_VER_1: case CODEC_VER_1:
report = rt5663_v2_jack_detect(rt5663->codec, 0); report = rt5663_v2_jack_detect(rt5663->component, 0);
break; break;
case CODEC_VER_0: case CODEC_VER_0:
report = rt5663_jack_detect(rt5663->codec, 0); report = rt5663_jack_detect(rt5663->component, 0);
break; break;
default: default:
dev_err(codec->dev, "Unknown CODEC Version\n"); dev_err(component->dev, "Unknown CODEC Version\n");
} }
} }
dev_dbg(codec->dev, "%s jack report: 0x%04x\n", __func__, report); dev_dbg(component->dev, "%s jack report: 0x%04x\n", __func__, report);
snd_soc_jack_report(rt5663->hs_jack, report, SND_JACK_HEADSET | snd_soc_jack_report(rt5663->hs_jack, report, SND_JACK_HEADSET |
SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3); SND_JACK_BTN_2 | SND_JACK_BTN_3);
...@@ -1978,22 +1978,22 @@ static void rt5663_jd_unplug_work(struct work_struct *work) ...@@ -1978,22 +1978,22 @@ static void rt5663_jd_unplug_work(struct work_struct *work)
{ {
struct rt5663_priv *rt5663 = struct rt5663_priv *rt5663 =
container_of(work, struct rt5663_priv, jd_unplug_work.work); container_of(work, struct rt5663_priv, jd_unplug_work.work);
struct snd_soc_codec *codec = rt5663->codec; struct snd_soc_component *component = rt5663->component;
if (!codec) if (!component)
return; return;
if (!rt5663_check_jd_status(codec)) { if (!rt5663_check_jd_status(component)) {
/* jack out */ /* jack out */
switch (rt5663->codec_ver) { switch (rt5663->codec_ver) {
case CODEC_VER_1: case CODEC_VER_1:
rt5663_v2_jack_detect(rt5663->codec, 0); rt5663_v2_jack_detect(rt5663->component, 0);
break; break;
case CODEC_VER_0: case CODEC_VER_0:
rt5663_jack_detect(rt5663->codec, 0); rt5663_jack_detect(rt5663->component, 0);
break; break;
default: default:
dev_err(codec->dev, "Unknown CODEC Version\n"); dev_err(component->dev, "Unknown CODEC Version\n");
} }
snd_soc_jack_report(rt5663->hs_jack, 0, SND_JACK_HEADSET | snd_soc_jack_report(rt5663->hs_jack, 0, SND_JACK_HEADSET |
...@@ -2047,9 +2047,9 @@ static int rt5663_is_sys_clk_from_pll(struct snd_soc_dapm_widget *w, ...@@ -2047,9 +2047,9 @@ static int rt5663_is_sys_clk_from_pll(struct snd_soc_dapm_widget *w,
struct snd_soc_dapm_widget *sink) struct snd_soc_dapm_widget *sink)
{ {
unsigned int val; unsigned int val;
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
val = snd_soc_read(codec, RT5663_GLB_CLK); val = snd_soc_component_read32(component, RT5663_GLB_CLK);
val &= RT5663_SCLK_SRC_MASK; val &= RT5663_SCLK_SRC_MASK;
if (val == RT5663_SCLK_SRC_PLL1) if (val == RT5663_SCLK_SRC_PLL1)
return 1; return 1;
...@@ -2061,8 +2061,8 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w, ...@@ -2061,8 +2061,8 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w,
struct snd_soc_dapm_widget *sink) struct snd_soc_dapm_widget *sink)
{ {
unsigned int reg, shift, val; unsigned int reg, shift, val;
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 rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
if (rt5663->codec_ver == CODEC_VER_1) { if (rt5663->codec_ver == CODEC_VER_1) {
switch (w->shift) { switch (w->shift) {
...@@ -2092,7 +2092,7 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w, ...@@ -2092,7 +2092,7 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w,
} }
} }
val = (snd_soc_read(codec, reg) >> shift) & 0x7; val = (snd_soc_component_read32(component, reg) >> shift) & 0x7;
if (val) if (val)
return 1; return 1;
...@@ -2103,23 +2103,23 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w, ...@@ -2103,23 +2103,23 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w,
static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source, static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink) struct snd_soc_dapm_widget *sink)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
int da_asrc_en, ad_asrc_en; int da_asrc_en, ad_asrc_en;
da_asrc_en = (snd_soc_read(codec, RT5663_ASRC_2) & da_asrc_en = (snd_soc_component_read32(component, RT5663_ASRC_2) &
RT5663_DA_STO1_TRACK_MASK) ? 1 : 0; RT5663_DA_STO1_TRACK_MASK) ? 1 : 0;
switch (rt5663->codec_ver) { switch (rt5663->codec_ver) {
case CODEC_VER_1: case CODEC_VER_1:
ad_asrc_en = (snd_soc_read(codec, RT5663_ASRC_3) & ad_asrc_en = (snd_soc_component_read32(component, RT5663_ASRC_3) &
RT5663_V2_AD_STO1_TRACK_MASK) ? 1 : 0; RT5663_V2_AD_STO1_TRACK_MASK) ? 1 : 0;
break; break;
case CODEC_VER_0: case CODEC_VER_0:
ad_asrc_en = (snd_soc_read(codec, RT5663_ASRC_2) & ad_asrc_en = (snd_soc_component_read32(component, RT5663_ASRC_2) &
RT5663_AD_STO1_TRACK_MASK) ? 1 : 0; RT5663_AD_STO1_TRACK_MASK) ? 1 : 0;
break; break;
default: default:
dev_err(codec->dev, "Unknown CODEC Version\n"); dev_err(component->dev, "Unknown CODEC Version\n");
return 1; return 1;
} }
...@@ -2127,14 +2127,14 @@ static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source, ...@@ -2127,14 +2127,14 @@ static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source,
if (rt5663->sysclk > rt5663->lrck * 384) if (rt5663->sysclk > rt5663->lrck * 384)
return 1; return 1;
dev_err(codec->dev, "sysclk < 384 x fs, disable i2s asrc\n"); dev_err(component->dev, "sysclk < 384 x fs, disable i2s asrc\n");
return 0; return 0;
} }
/** /**
* rt5663_sel_asrc_clk_src - select ASRC clock source for a set of filters * rt5663_sel_asrc_clk_src - select ASRC clock source for a set of filters
* @codec: SoC audio codec device. * @component: SoC audio component device.
* @filter_mask: mask of filters. * @filter_mask: mask of filters.
* @clk_src: clock source * @clk_src: clock source
* *
...@@ -2146,10 +2146,10 @@ static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source, ...@@ -2146,10 +2146,10 @@ static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source,
* set of filters specified by the mask. And the codec driver will turn on ASRC * set of filters specified by the mask. And the codec driver will turn on ASRC
* for these filters if ASRC is selected as their clock source. * for these filters if ASRC is selected as their clock source.
*/ */
int rt5663_sel_asrc_clk_src(struct snd_soc_codec *codec, int rt5663_sel_asrc_clk_src(struct snd_soc_component *component,
unsigned int filter_mask, unsigned int clk_src) unsigned int filter_mask, unsigned int clk_src)
{ {
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
unsigned int asrc2_mask = 0; unsigned int asrc2_mask = 0;
unsigned int asrc2_value = 0; unsigned int asrc2_value = 0;
unsigned int asrc3_mask = 0; unsigned int asrc3_mask = 0;
...@@ -2180,16 +2180,16 @@ int rt5663_sel_asrc_clk_src(struct snd_soc_codec *codec, ...@@ -2180,16 +2180,16 @@ int rt5663_sel_asrc_clk_src(struct snd_soc_codec *codec,
asrc2_value |= clk_src << RT5663_AD_STO1_TRACK_SHIFT; asrc2_value |= clk_src << RT5663_AD_STO1_TRACK_SHIFT;
break; break;
default: default:
dev_err(codec->dev, "Unknown CODEC Version\n"); dev_err(component->dev, "Unknown CODEC Version\n");
} }
} }
if (asrc2_mask) if (asrc2_mask)
snd_soc_update_bits(codec, RT5663_ASRC_2, asrc2_mask, snd_soc_component_update_bits(component, RT5663_ASRC_2, asrc2_mask,
asrc2_value); asrc2_value);
if (asrc3_mask) if (asrc3_mask)
snd_soc_update_bits(codec, RT5663_ASRC_3, asrc3_mask, snd_soc_component_update_bits(component, RT5663_ASRC_3, asrc3_mask,
asrc3_value); asrc3_value);
return 0; return 0;
...@@ -2295,42 +2295,42 @@ static const struct snd_kcontrol_new rt5663_alg_dacr_mux = ...@@ -2295,42 +2295,42 @@ static const struct snd_kcontrol_new rt5663_alg_dacr_mux =
static int rt5663_hp_event(struct snd_soc_dapm_widget *w, static int rt5663_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);
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
if (rt5663->codec_ver == CODEC_VER_1) { if (rt5663->codec_ver == CODEC_VER_1) {
snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1,
RT5663_SEL_PM_HP_SHIFT, RT5663_SEL_PM_HP_HIGH); RT5663_SEL_PM_HP_SHIFT, RT5663_SEL_PM_HP_HIGH);
snd_soc_update_bits(codec, RT5663_HP_LOGIC_2, snd_soc_component_update_bits(component, RT5663_HP_LOGIC_2,
RT5663_HP_SIG_SRC1_MASK, RT5663_HP_SIG_SRC1_MASK,
RT5663_HP_SIG_SRC1_SILENCE); RT5663_HP_SIG_SRC1_SILENCE);
} else { } else {
snd_soc_write(codec, RT5663_DEPOP_2, 0x3003); snd_soc_component_write(component, RT5663_DEPOP_2, 0x3003);
snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1,
RT5663_OVCD_HP_MASK, RT5663_OVCD_HP_DIS); RT5663_OVCD_HP_MASK, RT5663_OVCD_HP_DIS);
snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_2, 0x1371); snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_2, 0x1371);
snd_soc_write(codec, RT5663_HP_BIAS, 0xabba); snd_soc_component_write(component, RT5663_HP_BIAS, 0xabba);
snd_soc_write(codec, RT5663_CHARGE_PUMP_1, 0x2224); snd_soc_component_write(component, RT5663_CHARGE_PUMP_1, 0x2224);
snd_soc_write(codec, RT5663_ANA_BIAS_CUR_1, 0x7766); snd_soc_component_write(component, RT5663_ANA_BIAS_CUR_1, 0x7766);
snd_soc_write(codec, RT5663_HP_BIAS, 0xafaa); snd_soc_component_write(component, RT5663_HP_BIAS, 0xafaa);
snd_soc_write(codec, RT5663_CHARGE_PUMP_2, 0x7777); snd_soc_component_write(component, RT5663_CHARGE_PUMP_2, 0x7777);
snd_soc_update_bits(codec, RT5663_STO_DRE_1, 0x8000, snd_soc_component_update_bits(component, RT5663_STO_DRE_1, 0x8000,
0x8000); 0x8000);
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000,
0x3000); 0x3000);
} }
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
if (rt5663->codec_ver == CODEC_VER_1) { if (rt5663->codec_ver == CODEC_VER_1) {
snd_soc_update_bits(codec, RT5663_HP_LOGIC_2, snd_soc_component_update_bits(component, RT5663_HP_LOGIC_2,
RT5663_HP_SIG_SRC1_MASK, RT5663_HP_SIG_SRC1_MASK,
RT5663_HP_SIG_SRC1_REG); RT5663_HP_SIG_SRC1_REG);
} else { } else {
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0x0); snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0x0);
snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1,
RT5663_OVCD_HP_MASK, RT5663_OVCD_HP_EN); RT5663_OVCD_HP_MASK, RT5663_OVCD_HP_EN);
} }
break; break;
...@@ -2345,23 +2345,23 @@ static int rt5663_hp_event(struct snd_soc_dapm_widget *w, ...@@ -2345,23 +2345,23 @@ static int rt5663_hp_event(struct snd_soc_dapm_widget *w,
static int rt5663_charge_pump_event(struct snd_soc_dapm_widget *w, static int rt5663_charge_pump_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 rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
if (rt5663->codec_ver == CODEC_VER_0) { if (rt5663->codec_ver == CODEC_VER_0) {
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030,
0x0030); 0x0030);
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003,
0x0003); 0x0003);
} }
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
if (rt5663->codec_ver == CODEC_VER_0) { if (rt5663->codec_ver == CODEC_VER_0) {
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, 0); snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0);
snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0); snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0);
} }
break; break;
...@@ -2375,17 +2375,17 @@ static int rt5663_charge_pump_event(struct snd_soc_dapm_widget *w, ...@@ -2375,17 +2375,17 @@ static int rt5663_charge_pump_event(struct snd_soc_dapm_widget *w,
static int rt5663_bst2_power(struct snd_soc_dapm_widget *w, static int rt5663_bst2_power(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);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2,
RT5663_PWR_BST2_MASK | RT5663_PWR_BST2_OP_MASK, RT5663_PWR_BST2_MASK | RT5663_PWR_BST2_OP_MASK,
RT5663_PWR_BST2 | RT5663_PWR_BST2_OP); RT5663_PWR_BST2 | RT5663_PWR_BST2_OP);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2,
RT5663_PWR_BST2_MASK | RT5663_PWR_BST2_OP_MASK, 0); RT5663_PWR_BST2_MASK | RT5663_PWR_BST2_OP_MASK, 0);
break; break;
...@@ -2399,17 +2399,17 @@ static int rt5663_bst2_power(struct snd_soc_dapm_widget *w, ...@@ -2399,17 +2399,17 @@ static int rt5663_bst2_power(struct snd_soc_dapm_widget *w,
static int rt5663_pre_div_power(struct snd_soc_dapm_widget *w, static int rt5663_pre_div_power(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);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_write(codec, RT5663_PRE_DIV_GATING_1, 0xff00); snd_soc_component_write(component, RT5663_PRE_DIV_GATING_1, 0xff00);
snd_soc_write(codec, RT5663_PRE_DIV_GATING_2, 0xfffc); snd_soc_component_write(component, RT5663_PRE_DIV_GATING_2, 0xfffc);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_write(codec, RT5663_PRE_DIV_GATING_1, 0x0000); snd_soc_component_write(component, RT5663_PRE_DIV_GATING_1, 0x0000);
snd_soc_write(codec, RT5663_PRE_DIV_GATING_2, 0x0000); snd_soc_component_write(component, RT5663_PRE_DIV_GATING_2, 0x0000);
break; break;
default: default:
...@@ -2731,8 +2731,8 @@ static const struct snd_soc_dapm_route rt5663_specific_dapm_routes[] = { ...@@ -2731,8 +2731,8 @@ static const struct snd_soc_dapm_route rt5663_specific_dapm_routes[] = {
static int rt5663_hw_params(struct snd_pcm_substream *substream, static int rt5663_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
unsigned int val_len = 0; unsigned int val_len = 0;
int pre_div; int pre_div;
...@@ -2743,7 +2743,7 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream, ...@@ -2743,7 +2743,7 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream,
pre_div = rl6231_get_clk_info(rt5663->sysclk, rt5663->lrck); pre_div = rl6231_get_clk_info(rt5663->sysclk, rt5663->lrck);
if (pre_div < 0) { if (pre_div < 0) {
dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n",
rt5663->lrck, dai->id); rt5663->lrck, dai->id);
return -EINVAL; return -EINVAL;
} }
...@@ -2767,10 +2767,10 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream, ...@@ -2767,10 +2767,10 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, RT5663_I2S1_SDP, snd_soc_component_update_bits(component, RT5663_I2S1_SDP,
RT5663_I2S_DL_MASK, val_len); RT5663_I2S_DL_MASK, val_len);
snd_soc_update_bits(codec, RT5663_ADDA_CLK_1, snd_soc_component_update_bits(component, RT5663_ADDA_CLK_1,
RT5663_I2S_PD1_MASK, pre_div << RT5663_I2S_PD1_SHIFT); RT5663_I2S_PD1_MASK, pre_div << RT5663_I2S_PD1_SHIFT);
return 0; return 0;
...@@ -2778,7 +2778,7 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream, ...@@ -2778,7 +2778,7 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream,
static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5663_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;
unsigned int reg_val = 0; unsigned int reg_val = 0;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
...@@ -2817,7 +2817,7 @@ static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2817,7 +2817,7 @@ static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, RT5663_I2S1_SDP, RT5663_I2S_MS_MASK | snd_soc_component_update_bits(component, RT5663_I2S1_SDP, RT5663_I2S_MS_MASK |
RT5663_I2S_BP_MASK | RT5663_I2S_DF_MASK, reg_val); RT5663_I2S_BP_MASK | RT5663_I2S_DF_MASK, reg_val);
return 0; return 0;
...@@ -2826,8 +2826,8 @@ static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2826,8 +2826,8 @@ static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, static int rt5663_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 rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
unsigned int reg_val = 0; unsigned int reg_val = 0;
if (freq == rt5663->sysclk && clk_id == rt5663->sysclk_src) if (freq == rt5663->sysclk && clk_id == rt5663->sysclk_src)
...@@ -2844,15 +2844,15 @@ static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, ...@@ -2844,15 +2844,15 @@ static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
reg_val |= RT5663_SCLK_SRC_RCCLK; reg_val |= RT5663_SCLK_SRC_RCCLK;
break; break;
default: default:
dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); dev_err(component->dev, "Invalid clock id (%d)\n", clk_id);
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, snd_soc_component_update_bits(component, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK,
reg_val); reg_val);
rt5663->sysclk = freq; rt5663->sysclk = freq;
rt5663->sysclk_src = clk_id; rt5663->sysclk_src = clk_id;
dev_dbg(codec->dev, "Sysclk is %dHz and clock id is %d\n", dev_dbg(component->dev, "Sysclk is %dHz and clock id is %d\n",
freq, clk_id); freq, clk_id);
return 0; return 0;
...@@ -2861,8 +2861,8 @@ static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, ...@@ -2861,8 +2861,8 @@ static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
unsigned int freq_in, unsigned int freq_out) unsigned int freq_in, unsigned int freq_out)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
struct rl6231_pll_code pll_code; struct rl6231_pll_code pll_code;
int ret; int ret;
int mask, shift, val; int mask, shift, val;
...@@ -2872,11 +2872,11 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, ...@@ -2872,11 +2872,11 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
return 0; return 0;
if (!freq_in || !freq_out) { if (!freq_in || !freq_out) {
dev_dbg(codec->dev, "PLL disabled\n"); dev_dbg(component->dev, "PLL disabled\n");
rt5663->pll_in = 0; rt5663->pll_in = 0;
rt5663->pll_out = 0; rt5663->pll_out = 0;
snd_soc_update_bits(codec, RT5663_GLB_CLK, snd_soc_component_update_bits(component, RT5663_GLB_CLK,
RT5663_SCLK_SRC_MASK, RT5663_SCLK_SRC_MCLK); RT5663_SCLK_SRC_MASK, RT5663_SCLK_SRC_MCLK);
return 0; return 0;
} }
...@@ -2891,7 +2891,7 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, ...@@ -2891,7 +2891,7 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
shift = RT5663_PLL1_SRC_SHIFT; shift = RT5663_PLL1_SRC_SHIFT;
break; break;
default: default:
dev_err(codec->dev, "Unknown CODEC Version\n"); dev_err(component->dev, "Unknown CODEC Version\n");
return -EINVAL; return -EINVAL;
} }
...@@ -2903,24 +2903,24 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, ...@@ -2903,24 +2903,24 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
val = 0x1; val = 0x1;
break; break;
default: default:
dev_err(codec->dev, "Unknown PLL source %d\n", source); dev_err(component->dev, "Unknown PLL source %d\n", source);
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, RT5663_GLB_CLK, mask, (val << shift)); snd_soc_component_update_bits(component, RT5663_GLB_CLK, mask, (val << shift));
ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); ret = rl6231_pll_calc(freq_in, freq_out, &pll_code);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); dev_err(component->dev, "Unsupport input clock %d\n", freq_in);
return ret; return ret;
} }
dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp,
(pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code,
pll_code.k_code); pll_code.k_code);
snd_soc_write(codec, RT5663_PLL_1, snd_soc_component_write(component, RT5663_PLL_1,
pll_code.n_code << RT5663_PLL_N_SHIFT | pll_code.k_code); pll_code.n_code << RT5663_PLL_N_SHIFT | pll_code.k_code);
snd_soc_write(codec, RT5663_PLL_2, snd_soc_component_write(component, RT5663_PLL_2,
(pll_code.m_bp ? 0 : pll_code.m_code) << RT5663_PLL_M_SHIFT | (pll_code.m_bp ? 0 : pll_code.m_code) << RT5663_PLL_M_SHIFT |
pll_code.m_bp << RT5663_PLL_M_BP_SHIFT); pll_code.m_bp << RT5663_PLL_M_BP_SHIFT);
...@@ -2934,8 +2934,8 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, ...@@ -2934,8 +2934,8 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots, int slot_width) unsigned int rx_mask, int slots, int slot_width)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
unsigned int val = 0, reg; unsigned int val = 0, reg;
if (rx_mask || tx_mask) if (rx_mask || tx_mask)
...@@ -2987,11 +2987,11 @@ static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, ...@@ -2987,11 +2987,11 @@ static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
reg = RT5663_TDM_1; reg = RT5663_TDM_1;
break; break;
default: default:
dev_err(codec->dev, "Unknown CODEC Version\n"); dev_err(component->dev, "Unknown CODEC Version\n");
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, reg, RT5663_TDM_MODE_MASK | snd_soc_component_update_bits(component, reg, RT5663_TDM_MODE_MASK |
RT5663_TDM_IN_CH_MASK | RT5663_TDM_OUT_CH_MASK | RT5663_TDM_IN_CH_MASK | RT5663_TDM_OUT_CH_MASK |
RT5663_TDM_IN_LEN_MASK | RT5663_TDM_OUT_LEN_MASK, val); RT5663_TDM_IN_LEN_MASK | RT5663_TDM_OUT_LEN_MASK, val);
...@@ -3000,11 +3000,11 @@ static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, ...@@ -3000,11 +3000,11 @@ static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
static int rt5663_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) static int rt5663_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
unsigned int reg; unsigned int reg;
dev_dbg(codec->dev, "%s ratio = %d\n", __func__, ratio); dev_dbg(component->dev, "%s ratio = %d\n", __func__, ratio);
if (rt5663->codec_ver == CODEC_VER_1) if (rt5663->codec_ver == CODEC_VER_1)
reg = RT5663_TDM_9; reg = RT5663_TDM_9;
...@@ -3013,51 +3013,51 @@ static int rt5663_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) ...@@ -3013,51 +3013,51 @@ static int rt5663_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
switch (ratio) { switch (ratio) {
case 32: case 32:
snd_soc_update_bits(codec, reg, snd_soc_component_update_bits(component, reg,
RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_MASK,
RT5663_TDM_LENGTN_16); RT5663_TDM_LENGTN_16);
break; break;
case 40: case 40:
snd_soc_update_bits(codec, reg, snd_soc_component_update_bits(component, reg,
RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_MASK,
RT5663_TDM_LENGTN_20); RT5663_TDM_LENGTN_20);
break; break;
case 48: case 48:
snd_soc_update_bits(codec, reg, snd_soc_component_update_bits(component, reg,
RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_MASK,
RT5663_TDM_LENGTN_24); RT5663_TDM_LENGTN_24);
break; break;
case 64: case 64:
snd_soc_update_bits(codec, reg, snd_soc_component_update_bits(component, reg,
RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_MASK,
RT5663_TDM_LENGTN_32); RT5663_TDM_LENGTN_32);
break; break;
default: default:
dev_err(codec->dev, "Invalid ratio!\n"); dev_err(component->dev, "Invalid ratio!\n");
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
} }
static int rt5663_set_bias_level(struct snd_soc_codec *codec, static int rt5663_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1,
RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK, RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK,
RT5663_PWR_FV1 | RT5663_PWR_FV2); RT5663_PWR_FV1 | RT5663_PWR_FV2);
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
if (rt5663->codec_ver == CODEC_VER_1) { if (rt5663->codec_ver == CODEC_VER_1) {
snd_soc_update_bits(codec, RT5663_DIG_MISC, snd_soc_component_update_bits(component, RT5663_DIG_MISC,
RT5663_DIG_GATE_CTRL_MASK, RT5663_DIG_GATE_CTRL_MASK,
RT5663_DIG_GATE_CTRL_EN); RT5663_DIG_GATE_CTRL_EN);
snd_soc_update_bits(codec, RT5663_SIG_CLK_DET, snd_soc_component_update_bits(component, RT5663_SIG_CLK_DET,
RT5663_EN_ANA_CLK_DET_MASK | RT5663_EN_ANA_CLK_DET_MASK |
RT5663_PWR_CLK_DET_MASK, RT5663_PWR_CLK_DET_MASK,
RT5663_EN_ANA_CLK_DET_AUTO | RT5663_EN_ANA_CLK_DET_AUTO |
...@@ -3067,17 +3067,17 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec, ...@@ -3067,17 +3067,17 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (rt5663->codec_ver == CODEC_VER_1) if (rt5663->codec_ver == CODEC_VER_1)
snd_soc_update_bits(codec, RT5663_DIG_MISC, snd_soc_component_update_bits(component, RT5663_DIG_MISC,
RT5663_DIG_GATE_CTRL_MASK, RT5663_DIG_GATE_CTRL_MASK,
RT5663_DIG_GATE_CTRL_DIS); RT5663_DIG_GATE_CTRL_DIS);
snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1,
RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK | RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK |
RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK | RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK |
RT5663_PWR_MB_MASK, RT5663_PWR_VREF1 | RT5663_PWR_MB_MASK, RT5663_PWR_VREF1 |
RT5663_PWR_VREF2 | RT5663_PWR_MB); RT5663_PWR_VREF2 | RT5663_PWR_MB);
usleep_range(10000, 10005); usleep_range(10000, 10005);
if (rt5663->codec_ver == CODEC_VER_1) { if (rt5663->codec_ver == CODEC_VER_1) {
snd_soc_update_bits(codec, RT5663_SIG_CLK_DET, snd_soc_component_update_bits(component, RT5663_SIG_CLK_DET,
RT5663_EN_ANA_CLK_DET_MASK | RT5663_EN_ANA_CLK_DET_MASK |
RT5663_PWR_CLK_DET_MASK, RT5663_PWR_CLK_DET_MASK,
RT5663_EN_ANA_CLK_DET_DIS | RT5663_EN_ANA_CLK_DET_DIS |
...@@ -3086,7 +3086,7 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec, ...@@ -3086,7 +3086,7 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1,
RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK | RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK |
RT5663_PWR_FV1 | RT5663_PWR_FV2, 0x0); RT5663_PWR_FV1 | RT5663_PWR_FV2, 0x0);
break; break;
...@@ -3098,12 +3098,12 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec, ...@@ -3098,12 +3098,12 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec,
return 0; return 0;
} }
static int rt5663_probe(struct snd_soc_codec *codec) static int rt5663_probe(struct snd_soc_component *component)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
rt5663->codec = codec; rt5663->component = component;
switch (rt5663->codec_ver) { switch (rt5663->codec_ver) {
case CODEC_VER_1: case CODEC_VER_1:
...@@ -3113,7 +3113,7 @@ static int rt5663_probe(struct snd_soc_codec *codec) ...@@ -3113,7 +3113,7 @@ static int rt5663_probe(struct snd_soc_codec *codec)
snd_soc_dapm_add_routes(dapm, snd_soc_dapm_add_routes(dapm,
rt5663_v2_specific_dapm_routes, rt5663_v2_specific_dapm_routes,
ARRAY_SIZE(rt5663_v2_specific_dapm_routes)); ARRAY_SIZE(rt5663_v2_specific_dapm_routes));
snd_soc_add_codec_controls(codec, rt5663_v2_specific_controls, snd_soc_add_component_controls(component, rt5663_v2_specific_controls,
ARRAY_SIZE(rt5663_v2_specific_controls)); ARRAY_SIZE(rt5663_v2_specific_controls));
break; break;
case CODEC_VER_0: case CODEC_VER_0:
...@@ -3123,11 +3123,11 @@ static int rt5663_probe(struct snd_soc_codec *codec) ...@@ -3123,11 +3123,11 @@ static int rt5663_probe(struct snd_soc_codec *codec)
snd_soc_dapm_add_routes(dapm, snd_soc_dapm_add_routes(dapm,
rt5663_specific_dapm_routes, rt5663_specific_dapm_routes,
ARRAY_SIZE(rt5663_specific_dapm_routes)); ARRAY_SIZE(rt5663_specific_dapm_routes));
snd_soc_add_codec_controls(codec, rt5663_specific_controls, snd_soc_add_component_controls(component, rt5663_specific_controls,
ARRAY_SIZE(rt5663_specific_controls)); ARRAY_SIZE(rt5663_specific_controls));
if (!rt5663->imp_table) if (!rt5663->imp_table)
snd_soc_add_codec_controls(codec, rt5663_hpvol_controls, snd_soc_add_component_controls(component, rt5663_hpvol_controls,
ARRAY_SIZE(rt5663_hpvol_controls)); ARRAY_SIZE(rt5663_hpvol_controls));
break; break;
} }
...@@ -3135,19 +3135,17 @@ static int rt5663_probe(struct snd_soc_codec *codec) ...@@ -3135,19 +3135,17 @@ static int rt5663_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int rt5663_remove(struct snd_soc_codec *codec) static void rt5663_remove(struct snd_soc_component *component)
{ {
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
regmap_write(rt5663->regmap, RT5663_RESET, 0); regmap_write(rt5663->regmap, RT5663_RESET, 0);
return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int rt5663_suspend(struct snd_soc_codec *codec) static int rt5663_suspend(struct snd_soc_component *component)
{ {
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
regcache_cache_only(rt5663->regmap, true); regcache_cache_only(rt5663->regmap, true);
regcache_mark_dirty(rt5663->regmap); regcache_mark_dirty(rt5663->regmap);
...@@ -3155,9 +3153,9 @@ static int rt5663_suspend(struct snd_soc_codec *codec) ...@@ -3155,9 +3153,9 @@ static int rt5663_suspend(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int rt5663_resume(struct snd_soc_codec *codec) static int rt5663_resume(struct snd_soc_component *component)
{ {
struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component);
regcache_cache_only(rt5663->regmap, false); regcache_cache_only(rt5663->regmap, false);
regcache_sync(rt5663->regmap); regcache_sync(rt5663->regmap);
...@@ -3206,21 +3204,22 @@ static struct snd_soc_dai_driver rt5663_dai[] = { ...@@ -3206,21 +3204,22 @@ static struct snd_soc_dai_driver rt5663_dai[] = {
}, },
}; };
static const struct snd_soc_codec_driver soc_codec_dev_rt5663 = { static const struct snd_soc_component_driver soc_component_dev_rt5663 = {
.probe = rt5663_probe, .probe = rt5663_probe,
.remove = rt5663_remove, .remove = rt5663_remove,
.suspend = rt5663_suspend, .suspend = rt5663_suspend,
.resume = rt5663_resume, .resume = rt5663_resume,
.set_bias_level = rt5663_set_bias_level, .set_bias_level = rt5663_set_bias_level,
.idle_bias_off = true,
.component_driver = {
.controls = rt5663_snd_controls, .controls = rt5663_snd_controls,
.num_controls = ARRAY_SIZE(rt5663_snd_controls), .num_controls = ARRAY_SIZE(rt5663_snd_controls),
.dapm_widgets = rt5663_dapm_widgets, .dapm_widgets = rt5663_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(rt5663_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(rt5663_dapm_widgets),
.dapm_routes = rt5663_dapm_routes, .dapm_routes = rt5663_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(rt5663_dapm_routes), .num_dapm_routes = ARRAY_SIZE(rt5663_dapm_routes),
} .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config rt5663_v2_regmap = { static const struct regmap_config rt5663_v2_regmap = {
...@@ -3610,7 +3609,8 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, ...@@ -3610,7 +3609,8 @@ static int rt5663_i2c_probe(struct i2c_client *i2c,
__func__, ret); __func__, ret);
} }
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5663, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_rt5663,
rt5663_dai, ARRAY_SIZE(rt5663_dai)); rt5663_dai, ARRAY_SIZE(rt5663_dai));
if (ret) { if (ret) {
...@@ -3628,8 +3628,6 @@ static int rt5663_i2c_remove(struct i2c_client *i2c) ...@@ -3628,8 +3628,6 @@ static int rt5663_i2c_remove(struct i2c_client *i2c)
if (i2c->irq) if (i2c->irq)
free_irq(i2c->irq, rt5663); free_irq(i2c->irq, rt5663);
snd_soc_unregister_codec(&i2c->dev);
return 0; return 0;
} }
......
...@@ -1125,9 +1125,9 @@ enum { ...@@ -1125,9 +1125,9 @@ enum {
RT5663_AD_STEREO_FILTER = 0x2, RT5663_AD_STEREO_FILTER = 0x2,
}; };
int rt5663_set_jack_detect(struct snd_soc_codec *codec, int rt5663_set_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *hs_jack); struct snd_soc_jack *hs_jack);
int rt5663_sel_asrc_clk_src(struct snd_soc_codec *codec, int rt5663_sel_asrc_clk_src(struct snd_soc_component *component,
unsigned int filter_mask, unsigned int clk_src); unsigned int filter_mask, unsigned int clk_src);
#endif /* __RT5663_H__ */ #endif /* __RT5663_H__ */
...@@ -78,7 +78,7 @@ static const struct snd_soc_dapm_route broadwell_rt286_map[] = { ...@@ -78,7 +78,7 @@ static const struct snd_soc_dapm_route broadwell_rt286_map[] = {
static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
int ret = 0; int ret = 0;
ret = snd_soc_card_jack_new(rtd->card, "Headset", ret = snd_soc_card_jack_new(rtd->card, "Headset",
SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset, SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset,
...@@ -86,7 +86,7 @@ static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -86,7 +86,7 @@ static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd)
if (ret) if (ret)
return ret; return ret;
rt286_mic_detect(codec, &broadwell_headset); rt286_mic_detect(component, &broadwell_headset);
return 0; return 0;
} }
...@@ -224,10 +224,9 @@ static int broadwell_suspend(struct snd_soc_card *card){ ...@@ -224,10 +224,9 @@ static int broadwell_suspend(struct snd_soc_card *card){
list_for_each_entry(component, &card->component_dev_list, card_list) { list_for_each_entry(component, &card->component_dev_list, card_list) {
if (!strcmp(component->name, "i2c-INT343A:00")) { if (!strcmp(component->name, "i2c-INT343A:00")) {
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n"); dev_dbg(component->dev, "disabling jack detect before going to suspend.\n");
rt286_mic_detect(codec, NULL); rt286_mic_detect(component, NULL);
break; break;
} }
} }
...@@ -239,10 +238,9 @@ static int broadwell_resume(struct snd_soc_card *card){ ...@@ -239,10 +238,9 @@ static int broadwell_resume(struct snd_soc_card *card){
list_for_each_entry(component, &card->component_dev_list, card_list) { list_for_each_entry(component, &card->component_dev_list, card_list) {
if (!strcmp(component->name, "i2c-INT343A:00")) { if (!strcmp(component->name, "i2c-INT343A:00")) {
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
dev_dbg(codec->dev, "enabling jack detect for resume.\n"); dev_dbg(component->dev, "enabling jack detect for resume.\n");
rt286_mic_detect(codec, &broadwell_headset); rt286_mic_detect(component, &broadwell_headset);
break; break;
} }
} }
......
...@@ -169,7 +169,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -169,7 +169,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
{ {
int ret; int ret;
struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
/* Configure sysclk for codec */ /* Configure sysclk for codec */
ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 19200000, ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 19200000,
...@@ -192,7 +192,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -192,7 +192,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
return ret; return ret;
} }
da7219_aad_jack_det(codec, &broxton_headset); da7219_aad_jack_det(component, &broxton_headset);
snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
...@@ -522,12 +522,12 @@ static int bxt_card_late_probe(struct snd_soc_card *card) ...@@ -522,12 +522,12 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
{ {
struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card); struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card);
struct bxt_hdmi_pcm *pcm; struct bxt_hdmi_pcm *pcm;
struct snd_soc_codec *codec = NULL; struct snd_soc_component *component = NULL;
int err, i = 0; int err, i = 0;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
codec = pcm->codec_dai->codec; component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name), snprintf(jack_name, sizeof(jack_name),
"HDMI/DP, pcm=%d Jack", pcm->device); "HDMI/DP, pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name, err = snd_soc_card_jack_new(card, jack_name,
...@@ -545,10 +545,10 @@ static int bxt_card_late_probe(struct snd_soc_card *card) ...@@ -545,10 +545,10 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!codec) if (!component)
return -EINVAL; return -EINVAL;
return hdac_hdmi_jack_port_init(codec, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
/* broxton audio machine driver for SPT + da7219 */ /* broxton audio machine driver for SPT + da7219 */
......
...@@ -167,7 +167,7 @@ static int broxton_rt298_fe_init(struct snd_soc_pcm_runtime *rtd) ...@@ -167,7 +167,7 @@ static int broxton_rt298_fe_init(struct snd_soc_pcm_runtime *rtd)
static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd) static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
int ret = 0; int ret = 0;
ret = snd_soc_card_jack_new(rtd->card, "Headset", ret = snd_soc_card_jack_new(rtd->card, "Headset",
...@@ -178,7 +178,7 @@ static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -178,7 +178,7 @@ static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd)
if (ret) if (ret)
return ret; return ret;
rt298_mic_detect(codec, &broxton_headset); rt298_mic_detect(component, &broxton_headset);
snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
...@@ -496,12 +496,12 @@ static int bxt_card_late_probe(struct snd_soc_card *card) ...@@ -496,12 +496,12 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
{ {
struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(card); struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(card);
struct bxt_hdmi_pcm *pcm; struct bxt_hdmi_pcm *pcm;
struct snd_soc_codec *codec = NULL; struct snd_soc_component *component = NULL;
int err, i = 0; int err, i = 0;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
codec = pcm->codec_dai->codec; component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name), snprintf(jack_name, sizeof(jack_name),
"HDMI/DP, pcm=%d Jack", pcm->device); "HDMI/DP, pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name, err = snd_soc_card_jack_new(card, jack_name,
...@@ -519,10 +519,10 @@ static int bxt_card_late_probe(struct snd_soc_card *card) ...@@ -519,10 +519,10 @@ static int bxt_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!codec) if (!component)
return -EINVAL; return -EINVAL;
return hdac_hdmi_jack_port_init(codec, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
......
...@@ -272,7 +272,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -272,7 +272,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)
{ {
int ret; int ret;
struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
struct snd_soc_jack *jack; struct snd_soc_jack *jack;
/* /*
...@@ -294,7 +294,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -294,7 +294,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
rt5663_set_jack_detect(codec, &ctx->kabylake_headset); rt5663_set_jack_detect(component, &ctx->kabylake_headset);
return ret; return ret;
} }
...@@ -448,7 +448,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream, ...@@ -448,7 +448,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream,
int ret; int ret;
/* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */ /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */
rt5663_sel_asrc_clk_src(codec_dai->codec, rt5663_sel_asrc_clk_src(codec_dai->component,
RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER, RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER,
RT5663_CLK_SEL_I2S1_ASRC); RT5663_CLK_SEL_I2S1_ASRC);
...@@ -898,12 +898,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) ...@@ -898,12 +898,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card)
{ {
struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card);
struct kbl_hdmi_pcm *pcm; struct kbl_hdmi_pcm *pcm;
struct snd_soc_codec *codec = NULL; struct snd_soc_component *component = NULL;
int err, i = 0; int err, i = 0;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
codec = pcm->codec_dai->codec; component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name), snprintf(jack_name, sizeof(jack_name),
"HDMI/DP, pcm=%d Jack", pcm->device); "HDMI/DP, pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name, err = snd_soc_card_jack_new(card, jack_name,
...@@ -921,10 +921,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) ...@@ -921,10 +921,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!codec) if (!component)
return -EINVAL; return -EINVAL;
return hdac_hdmi_jack_port_init(codec, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
/* kabylake audio machine driver for SPT + RT5663 */ /* kabylake audio machine driver for SPT + RT5663 */
......
...@@ -178,7 +178,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -178,7 +178,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)
{ {
int ret; int ret;
struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
struct snd_soc_jack *jack; struct snd_soc_jack *jack;
/* /*
...@@ -200,7 +200,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -200,7 +200,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
rt5663_set_jack_detect(codec, &ctx->kabylake_headset); rt5663_set_jack_detect(component, &ctx->kabylake_headset);
ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "DMIC"); ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "DMIC");
if (ret) if (ret)
...@@ -333,7 +333,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream, ...@@ -333,7 +333,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream,
int ret; int ret;
/* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */ /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */
rt5663_sel_asrc_clk_src(codec_dai->codec, rt5663_sel_asrc_clk_src(codec_dai->component,
RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER, RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER,
RT5663_CLK_SEL_I2S1_ASRC); RT5663_CLK_SEL_I2S1_ASRC);
...@@ -599,12 +599,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) ...@@ -599,12 +599,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card)
{ {
struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
struct kbl_hdmi_pcm *pcm; struct kbl_hdmi_pcm *pcm;
struct snd_soc_codec *codec = NULL; struct snd_soc_component *component = NULL;
int err, i = 0; int err, i = 0;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
codec = pcm->codec_dai->codec; component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name), snprintf(jack_name, sizeof(jack_name),
"HDMI/DP,pcm=%d Jack", pcm->device); "HDMI/DP,pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name, err = snd_soc_card_jack_new(card, jack_name,
...@@ -620,10 +620,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) ...@@ -620,10 +620,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!codec) if (!component)
return -EINVAL; return -EINVAL;
return hdac_hdmi_jack_port_init(codec, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
/* /*
......
...@@ -165,7 +165,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, ...@@ -165,7 +165,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
{ {
int ret; int ret;
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
/* /*
* Headset buttons map to the google Reference headset. * Headset buttons map to the google Reference headset.
...@@ -180,7 +180,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -180,7 +180,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
return ret; return ret;
} }
nau8825_enable_jack_detect(codec, &skylake_headset); nau8825_enable_jack_detect(component, &skylake_headset);
snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
...@@ -592,12 +592,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) ...@@ -592,12 +592,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card)
{ {
struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(card); struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(card);
struct skl_hdmi_pcm *pcm; struct skl_hdmi_pcm *pcm;
struct snd_soc_codec *codec = NULL; struct snd_soc_component *component = NULL;
int err, i = 0; int err, i = 0;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
codec = pcm->codec_dai->codec; component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name), snprintf(jack_name, sizeof(jack_name),
"HDMI/DP, pcm=%d Jack", pcm->device); "HDMI/DP, pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name, err = snd_soc_card_jack_new(card, jack_name,
...@@ -616,10 +616,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) ...@@ -616,10 +616,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!codec) if (!component)
return -EINVAL; return -EINVAL;
return hdac_hdmi_jack_port_init(codec, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
/* skylake audio machine driver for SPT + NAU88L25 */ /* skylake audio machine driver for SPT + NAU88L25 */
......
...@@ -195,7 +195,7 @@ static int skylake_ssm4567_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -195,7 +195,7 @@ static int skylake_ssm4567_codec_init(struct snd_soc_pcm_runtime *rtd)
static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
{ {
int ret; int ret;
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
/* /*
* 4 buttons here map to the google Reference headset * 4 buttons here map to the google Reference headset
...@@ -210,7 +210,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -210,7 +210,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
return ret; return ret;
} }
nau8825_enable_jack_detect(codec, &skylake_headset); nau8825_enable_jack_detect(component, &skylake_headset);
snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
...@@ -643,12 +643,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) ...@@ -643,12 +643,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card)
{ {
struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(card); struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(card);
struct skl_hdmi_pcm *pcm; struct skl_hdmi_pcm *pcm;
struct snd_soc_codec *codec = NULL; struct snd_soc_component *component = NULL;
int err, i = 0; int err, i = 0;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
codec = pcm->codec_dai->codec; component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name), snprintf(jack_name, sizeof(jack_name),
"HDMI/DP, pcm=%d Jack", pcm->device); "HDMI/DP, pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name, err = snd_soc_card_jack_new(card, jack_name,
...@@ -667,10 +667,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) ...@@ -667,10 +667,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!codec) if (!component)
return -EINVAL; return -EINVAL;
return hdac_hdmi_jack_port_init(codec, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
/* skylake audio machine driver for SPT + NAU88L25 */ /* skylake audio machine driver for SPT + NAU88L25 */
......
...@@ -130,7 +130,7 @@ static int skylake_rt286_fe_init(struct snd_soc_pcm_runtime *rtd) ...@@ -130,7 +130,7 @@ static int skylake_rt286_fe_init(struct snd_soc_pcm_runtime *rtd)
static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
int ret; int ret;
ret = snd_soc_card_jack_new(rtd->card, "Headset", ret = snd_soc_card_jack_new(rtd->card, "Headset",
...@@ -141,7 +141,7 @@ static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -141,7 +141,7 @@ static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd)
if (ret) if (ret)
return ret; return ret;
rt286_mic_detect(codec, &skylake_headset); rt286_mic_detect(component, &skylake_headset);
snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
...@@ -478,12 +478,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) ...@@ -478,12 +478,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card)
{ {
struct skl_rt286_private *ctx = snd_soc_card_get_drvdata(card); struct skl_rt286_private *ctx = snd_soc_card_get_drvdata(card);
struct skl_hdmi_pcm *pcm; struct skl_hdmi_pcm *pcm;
struct snd_soc_codec *codec = NULL; struct snd_soc_component *component = NULL;
int err, i = 0; int err, i = 0;
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
codec = pcm->codec_dai->codec; component = pcm->codec_dai->component;
snprintf(jack_name, sizeof(jack_name), snprintf(jack_name, sizeof(jack_name),
"HDMI/DP, pcm=%d Jack", pcm->device); "HDMI/DP, pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name, err = snd_soc_card_jack_new(card, jack_name,
...@@ -501,10 +501,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) ...@@ -501,10 +501,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card)
i++; i++;
} }
if (!codec) if (!component)
return -EINVAL; return -EINVAL;
return hdac_hdmi_jack_port_init(codec, &card->dapm); return hdac_hdmi_jack_port_init(component, &card->dapm);
} }
/* skylake audio machine driver for SPT + RT286S */ /* skylake audio machine driver for SPT + RT286S */
......
...@@ -176,7 +176,7 @@ static int rockchip_sound_da7219_hw_params(struct snd_pcm_substream *substream, ...@@ -176,7 +176,7 @@ static int rockchip_sound_da7219_hw_params(struct snd_pcm_substream *substream,
static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd) static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_codec *codec = rtd->codec_dais[0]->codec; struct snd_soc_component *component = rtd->codec_dais[0]->component;
struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai;
int ret; int ret;
...@@ -215,7 +215,7 @@ static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd) ...@@ -215,7 +215,7 @@ static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd)
snd_jack_set_key( snd_jack_set_key(
rockchip_sound_jack.jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); rockchip_sound_jack.jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
da7219_aad_jack_det(codec, &rockchip_sound_jack); da7219_aad_jack_det(component, &rockchip_sound_jack);
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