Commit 4e46c228 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: tscs42xx: replace codec to component

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

Note:
	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 7928b2cb
...@@ -91,15 +91,15 @@ static const struct regmap_config tscs42xx_regmap = { ...@@ -91,15 +91,15 @@ static const struct regmap_config tscs42xx_regmap = {
}; };
#define MAX_PLL_LOCK_20MS_WAITS 1 #define MAX_PLL_LOCK_20MS_WAITS 1
static bool plls_locked(struct snd_soc_codec *codec) static bool plls_locked(struct snd_soc_component *component)
{ {
int ret; int ret;
int count = MAX_PLL_LOCK_20MS_WAITS; int count = MAX_PLL_LOCK_20MS_WAITS;
do { do {
ret = snd_soc_read(codec, R_PLLCTL0); ret = snd_soc_component_read32(component, R_PLLCTL0);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to read PLL lock status (%d)\n", ret); "Failed to read PLL lock status (%d)\n", ret);
return false; return false;
} else if (ret > 0) { } else if (ret > 0) {
...@@ -131,10 +131,10 @@ static int sample_rate_to_pll_freq_out(int sample_rate) ...@@ -131,10 +131,10 @@ static int sample_rate_to_pll_freq_out(int sample_rate)
} }
#define DACCRSTAT_MAX_TRYS 10 #define DACCRSTAT_MAX_TRYS 10
static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram, static int write_coeff_ram(struct snd_soc_component *component, u8 *coeff_ram,
unsigned int addr, unsigned int coeff_cnt) unsigned int addr, unsigned int coeff_cnt)
{ {
struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int cnt; int cnt;
int trys; int trys;
int ret; int ret;
...@@ -142,9 +142,9 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram, ...@@ -142,9 +142,9 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram,
for (cnt = 0; cnt < coeff_cnt; cnt++, addr++) { for (cnt = 0; cnt < coeff_cnt; cnt++, addr++) {
for (trys = 0; trys < DACCRSTAT_MAX_TRYS; trys++) { for (trys = 0; trys < DACCRSTAT_MAX_TRYS; trys++) {
ret = snd_soc_read(codec, R_DACCRSTAT); ret = snd_soc_component_read32(component, R_DACCRSTAT);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to read stat (%d)\n", ret); "Failed to read stat (%d)\n", ret);
return ret; return ret;
} }
...@@ -154,14 +154,14 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram, ...@@ -154,14 +154,14 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram,
if (trys == DACCRSTAT_MAX_TRYS) { if (trys == DACCRSTAT_MAX_TRYS) {
ret = -EIO; ret = -EIO;
dev_err(codec->dev, dev_err(component->dev,
"dac coefficient write error (%d)\n", ret); "dac coefficient write error (%d)\n", ret);
return ret; return ret;
} }
ret = regmap_write(tscs42xx->regmap, R_DACCRADDR, addr); ret = regmap_write(tscs42xx->regmap, R_DACCRADDR, addr);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to write dac ram address (%d)\n", ret); "Failed to write dac ram address (%d)\n", ret);
return ret; return ret;
} }
...@@ -170,7 +170,7 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram, ...@@ -170,7 +170,7 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram,
&coeff_ram[addr * COEFF_SIZE], &coeff_ram[addr * COEFF_SIZE],
COEFF_SIZE); COEFF_SIZE);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to write dac ram (%d)\n", ret); "Failed to write dac ram (%d)\n", ret);
return ret; return ret;
} }
...@@ -179,9 +179,9 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram, ...@@ -179,9 +179,9 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram,
return 0; return 0;
} }
static int power_up_audio_plls(struct snd_soc_codec *codec) static int power_up_audio_plls(struct snd_soc_component *component)
{ {
struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int freq_out; int freq_out;
int ret; int ret;
unsigned int mask; unsigned int mask;
...@@ -199,20 +199,20 @@ static int power_up_audio_plls(struct snd_soc_codec *codec) ...@@ -199,20 +199,20 @@ static int power_up_audio_plls(struct snd_soc_codec *codec)
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
dev_err(codec->dev, "Unrecognized PLL output freq (%d)\n", ret); dev_err(component->dev, "Unrecognized PLL output freq (%d)\n", ret);
return ret; return ret;
} }
mutex_lock(&tscs42xx->pll_lock); mutex_lock(&tscs42xx->pll_lock);
ret = snd_soc_update_bits(codec, R_PLLCTL1C, mask, val); ret = snd_soc_component_update_bits(component, R_PLLCTL1C, mask, val);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to turn PLL on (%d)\n", ret); dev_err(component->dev, "Failed to turn PLL on (%d)\n", ret);
goto exit; goto exit;
} }
if (!plls_locked(codec)) { if (!plls_locked(component)) {
dev_err(codec->dev, "Failed to lock plls\n"); dev_err(component->dev, "Failed to lock plls\n");
ret = -ENOMSG; ret = -ENOMSG;
goto exit; goto exit;
} }
...@@ -224,25 +224,25 @@ static int power_up_audio_plls(struct snd_soc_codec *codec) ...@@ -224,25 +224,25 @@ static int power_up_audio_plls(struct snd_soc_codec *codec)
return ret; return ret;
} }
static int power_down_audio_plls(struct snd_soc_codec *codec) static int power_down_audio_plls(struct snd_soc_component *component)
{ {
struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret; int ret;
mutex_lock(&tscs42xx->pll_lock); mutex_lock(&tscs42xx->pll_lock);
ret = snd_soc_update_bits(codec, R_PLLCTL1C, ret = snd_soc_component_update_bits(component, R_PLLCTL1C,
RM_PLLCTL1C_PDB_PLL1, RM_PLLCTL1C_PDB_PLL1,
RV_PLLCTL1C_PDB_PLL1_DISABLE); RV_PLLCTL1C_PDB_PLL1_DISABLE);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to turn PLL off (%d)\n", ret); dev_err(component->dev, "Failed to turn PLL off (%d)\n", ret);
goto exit; goto exit;
} }
ret = snd_soc_update_bits(codec, R_PLLCTL1C, ret = snd_soc_component_update_bits(component, R_PLLCTL1C,
RM_PLLCTL1C_PDB_PLL2, RM_PLLCTL1C_PDB_PLL2,
RV_PLLCTL1C_PDB_PLL2_DISABLE); RV_PLLCTL1C_PDB_PLL2_DISABLE);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to turn PLL off (%d)\n", ret); dev_err(component->dev, "Failed to turn PLL off (%d)\n", ret);
goto exit; goto exit;
} }
...@@ -256,8 +256,8 @@ static int power_down_audio_plls(struct snd_soc_codec *codec) ...@@ -256,8 +256,8 @@ static int power_down_audio_plls(struct snd_soc_codec *codec)
static int coeff_ram_get(struct snd_kcontrol *kcontrol, static int coeff_ram_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 tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl = struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value; (struct coeff_ram_ctl *)kcontrol->private_value;
struct soc_bytes_ext *params = &ctl->bytes_ext; struct soc_bytes_ext *params = &ctl->bytes_ext;
...@@ -275,8 +275,8 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol, ...@@ -275,8 +275,8 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol,
static int coeff_ram_put(struct snd_kcontrol *kcontrol, static int coeff_ram_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 tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl = struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value; (struct coeff_ram_ctl *)kcontrol->private_value;
struct soc_bytes_ext *params = &ctl->bytes_ext; struct soc_bytes_ext *params = &ctl->bytes_ext;
...@@ -292,11 +292,11 @@ static int coeff_ram_put(struct snd_kcontrol *kcontrol, ...@@ -292,11 +292,11 @@ static int coeff_ram_put(struct snd_kcontrol *kcontrol,
mutex_lock(&tscs42xx->pll_lock); mutex_lock(&tscs42xx->pll_lock);
if (plls_locked(codec)) { if (plls_locked(component)) {
ret = write_coeff_ram(codec, tscs42xx->coeff_ram, ret = write_coeff_ram(component, tscs42xx->coeff_ram,
ctl->addr, coeff_cnt); ctl->addr, coeff_cnt);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to flush coeff ram cache (%d)\n", ret); "Failed to flush coeff ram cache (%d)\n", ret);
goto exit; goto exit;
} }
...@@ -358,13 +358,13 @@ static int dapm_micb_event(struct snd_soc_dapm_widget *w, ...@@ -358,13 +358,13 @@ static int dapm_micb_event(struct snd_soc_dapm_widget *w,
static int pll_event(struct snd_soc_dapm_widget *w, static int pll_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
int ret; int ret;
if (SND_SOC_DAPM_EVENT_ON(event)) if (SND_SOC_DAPM_EVENT_ON(event))
ret = power_up_audio_plls(codec); ret = power_up_audio_plls(component);
else else
ret = power_down_audio_plls(codec); ret = power_down_audio_plls(component);
return ret; return ret;
} }
...@@ -372,14 +372,14 @@ static int pll_event(struct snd_soc_dapm_widget *w, ...@@ -372,14 +372,14 @@ static int pll_event(struct snd_soc_dapm_widget *w,
static int dac_event(struct snd_soc_dapm_widget *w, static int 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 tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret; int ret;
mutex_lock(&tscs42xx->coeff_ram_lock); mutex_lock(&tscs42xx->coeff_ram_lock);
if (tscs42xx->coeff_ram_synced == false) { if (tscs42xx->coeff_ram_synced == false) {
ret = write_coeff_ram(codec, tscs42xx->coeff_ram, 0x00, ret = write_coeff_ram(component, tscs42xx->coeff_ram, 0x00,
COEFF_RAM_COEFF_COUNT); COEFF_RAM_COEFF_COUNT);
if (ret < 0) if (ret < 0)
goto exit; goto exit;
...@@ -790,7 +790,7 @@ static const struct snd_kcontrol_new tscs42xx_snd_controls[] = { ...@@ -790,7 +790,7 @@ static const struct snd_kcontrol_new tscs42xx_snd_controls[] = {
R_DACMBCREL3L, 2), R_DACMBCREL3L, 2),
}; };
static int setup_sample_format(struct snd_soc_codec *codec, static int setup_sample_format(struct snd_soc_component *component,
snd_pcm_format_t format) snd_pcm_format_t format)
{ {
unsigned int width; unsigned int width;
...@@ -811,21 +811,21 @@ static int setup_sample_format(struct snd_soc_codec *codec, ...@@ -811,21 +811,21 @@ static int setup_sample_format(struct snd_soc_codec *codec,
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
dev_err(codec->dev, "Unsupported format width (%d)\n", ret); dev_err(component->dev, "Unsupported format width (%d)\n", ret);
return ret; return ret;
} }
ret = snd_soc_update_bits(codec, R_AIC1, RM_AIC1_WL, width); ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_WL, width);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to set sample width (%d)\n", ret); dev_err(component->dev, "Failed to set sample width (%d)\n", ret);
return ret; return ret;
} }
return 0; return 0;
} }
static int setup_sample_rate(struct snd_soc_codec *codec, unsigned int rate) static int setup_sample_rate(struct snd_soc_component *component, unsigned int rate)
{ {
struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
unsigned int br, bm; unsigned int br, bm;
int ret; int ret;
...@@ -871,29 +871,29 @@ static int setup_sample_rate(struct snd_soc_codec *codec, unsigned int rate) ...@@ -871,29 +871,29 @@ static int setup_sample_rate(struct snd_soc_codec *codec, unsigned int rate)
bm = RV_DACSR_DBM_2; bm = RV_DACSR_DBM_2;
break; break;
default: default:
dev_err(codec->dev, "Unsupported sample rate %d\n", rate); dev_err(component->dev, "Unsupported sample rate %d\n", rate);
return -EINVAL; return -EINVAL;
} }
/* DAC and ADC share bit and frame clock */ /* DAC and ADC share bit and frame clock */
ret = snd_soc_update_bits(codec, R_DACSR, RM_DACSR_DBR, br); ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBR, br);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to update register (%d)\n", ret); dev_err(component->dev, "Failed to update register (%d)\n", ret);
return ret; return ret;
} }
ret = snd_soc_update_bits(codec, R_DACSR, RM_DACSR_DBM, bm); ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBM, bm);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to update register (%d)\n", ret); dev_err(component->dev, "Failed to update register (%d)\n", ret);
return ret; return ret;
} }
ret = snd_soc_update_bits(codec, R_ADCSR, RM_DACSR_DBR, br); ret = snd_soc_component_update_bits(component, R_ADCSR, RM_DACSR_DBR, br);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to update register (%d)\n", ret); dev_err(component->dev, "Failed to update register (%d)\n", ret);
return ret; return ret;
} }
ret = snd_soc_update_bits(codec, R_ADCSR, RM_DACSR_DBM, bm); ret = snd_soc_component_update_bits(component, R_ADCSR, RM_DACSR_DBM, bm);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to update register (%d)\n", ret); dev_err(component->dev, "Failed to update register (%d)\n", ret);
return ret; return ret;
} }
...@@ -1025,7 +1025,7 @@ static const struct pll_ctl *get_pll_ctl(int input_freq) ...@@ -1025,7 +1025,7 @@ static const struct pll_ctl *get_pll_ctl(int input_freq)
return pll_ctl; return pll_ctl;
} }
static int set_pll_ctl_from_input_freq(struct snd_soc_codec *codec, static int set_pll_ctl_from_input_freq(struct snd_soc_component *component,
const int input_freq) const int input_freq)
{ {
int ret; int ret;
...@@ -1035,18 +1035,18 @@ static int set_pll_ctl_from_input_freq(struct snd_soc_codec *codec, ...@@ -1035,18 +1035,18 @@ static int set_pll_ctl_from_input_freq(struct snd_soc_codec *codec,
pll_ctl = get_pll_ctl(input_freq); pll_ctl = get_pll_ctl(input_freq);
if (!pll_ctl) { if (!pll_ctl) {
ret = -EINVAL; ret = -EINVAL;
dev_err(codec->dev, "No PLL input entry for %d (%d)\n", dev_err(component->dev, "No PLL input entry for %d (%d)\n",
input_freq, ret); input_freq, ret);
return ret; return ret;
} }
for (i = 0; i < PLL_REG_SETTINGS_COUNT; ++i) { for (i = 0; i < PLL_REG_SETTINGS_COUNT; ++i) {
ret = snd_soc_update_bits(codec, ret = snd_soc_component_update_bits(component,
pll_ctl->settings[i].addr, pll_ctl->settings[i].addr,
pll_ctl->settings[i].mask, pll_ctl->settings[i].mask,
pll_ctl->settings[i].val); pll_ctl->settings[i].val);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to set pll ctl (%d)\n", dev_err(component->dev, "Failed to set pll ctl (%d)\n",
ret); ret);
return ret; return ret;
} }
...@@ -1059,33 +1059,33 @@ static int tscs42xx_hw_params(struct snd_pcm_substream *substream, ...@@ -1059,33 +1059,33 @@ static int tscs42xx_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *codec_dai) struct snd_soc_dai *codec_dai)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
int ret; int ret;
ret = setup_sample_format(codec, params_format(params)); ret = setup_sample_format(component, params_format(params));
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to setup sample format (%d)\n", dev_err(component->dev, "Failed to setup sample format (%d)\n",
ret); ret);
return ret; return ret;
} }
ret = setup_sample_rate(codec, params_rate(params)); ret = setup_sample_rate(component, params_rate(params));
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to setup sample rate (%d)\n", ret); dev_err(component->dev, "Failed to setup sample rate (%d)\n", ret);
return ret; return ret;
} }
return 0; return 0;
} }
static inline int dac_mute(struct snd_soc_codec *codec) static inline int dac_mute(struct snd_soc_component *component)
{ {
int ret; int ret;
ret = snd_soc_update_bits(codec, R_CNVRTR1, RM_CNVRTR1_DACMU, ret = snd_soc_component_update_bits(component, R_CNVRTR1, RM_CNVRTR1_DACMU,
RV_CNVRTR1_DACMU_ENABLE); RV_CNVRTR1_DACMU_ENABLE);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to mute DAC (%d)\n", dev_err(component->dev, "Failed to mute DAC (%d)\n",
ret); ret);
return ret; return ret;
} }
...@@ -1093,14 +1093,14 @@ static inline int dac_mute(struct snd_soc_codec *codec) ...@@ -1093,14 +1093,14 @@ static inline int dac_mute(struct snd_soc_codec *codec)
return 0; return 0;
} }
static inline int dac_unmute(struct snd_soc_codec *codec) static inline int dac_unmute(struct snd_soc_component *component)
{ {
int ret; int ret;
ret = snd_soc_update_bits(codec, R_CNVRTR1, RM_CNVRTR1_DACMU, ret = snd_soc_component_update_bits(component, R_CNVRTR1, RM_CNVRTR1_DACMU,
RV_CNVRTR1_DACMU_DISABLE); RV_CNVRTR1_DACMU_DISABLE);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to unmute DAC (%d)\n", dev_err(component->dev, "Failed to unmute DAC (%d)\n",
ret); ret);
return ret; return ret;
} }
...@@ -1108,14 +1108,14 @@ static inline int dac_unmute(struct snd_soc_codec *codec) ...@@ -1108,14 +1108,14 @@ static inline int dac_unmute(struct snd_soc_codec *codec)
return 0; return 0;
} }
static inline int adc_mute(struct snd_soc_codec *codec) static inline int adc_mute(struct snd_soc_component *component)
{ {
int ret; int ret;
ret = snd_soc_update_bits(codec, R_CNVRTR0, RM_CNVRTR0_ADCMU, ret = snd_soc_component_update_bits(component, R_CNVRTR0, RM_CNVRTR0_ADCMU,
RV_CNVRTR0_ADCMU_ENABLE); RV_CNVRTR0_ADCMU_ENABLE);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to mute ADC (%d)\n", dev_err(component->dev, "Failed to mute ADC (%d)\n",
ret); ret);
return ret; return ret;
} }
...@@ -1123,14 +1123,14 @@ static inline int adc_mute(struct snd_soc_codec *codec) ...@@ -1123,14 +1123,14 @@ static inline int adc_mute(struct snd_soc_codec *codec)
return 0; return 0;
} }
static inline int adc_unmute(struct snd_soc_codec *codec) static inline int adc_unmute(struct snd_soc_component *component)
{ {
int ret; int ret;
ret = snd_soc_update_bits(codec, R_CNVRTR0, RM_CNVRTR0_ADCMU, ret = snd_soc_component_update_bits(component, R_CNVRTR0, RM_CNVRTR0_ADCMU,
RV_CNVRTR0_ADCMU_DISABLE); RV_CNVRTR0_ADCMU_DISABLE);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to unmute ADC (%d)\n", dev_err(component->dev, "Failed to unmute ADC (%d)\n",
ret); ret);
return ret; return ret;
} }
...@@ -1140,19 +1140,19 @@ static inline int adc_unmute(struct snd_soc_codec *codec) ...@@ -1140,19 +1140,19 @@ static inline int adc_unmute(struct snd_soc_codec *codec)
static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int stream) static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
int ret; int ret;
if (mute) if (mute)
if (stream == SNDRV_PCM_STREAM_PLAYBACK) if (stream == SNDRV_PCM_STREAM_PLAYBACK)
ret = dac_mute(codec); ret = dac_mute(component);
else else
ret = adc_mute(codec); ret = adc_mute(component);
else else
if (stream == SNDRV_PCM_STREAM_PLAYBACK) if (stream == SNDRV_PCM_STREAM_PLAYBACK)
ret = dac_unmute(codec); ret = dac_unmute(component);
else else
ret = adc_unmute(codec); ret = adc_unmute(component);
return ret; return ret;
} }
...@@ -1160,23 +1160,23 @@ static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int stream) ...@@ -1160,23 +1160,23 @@ static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
static int tscs42xx_set_dai_fmt(struct snd_soc_dai *codec_dai, static int tscs42xx_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
int ret; int ret;
/* Slave mode not supported since it needs always-on frame clock */ /* Slave mode not supported since it needs always-on frame clock */
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:
ret = snd_soc_update_bits(codec, R_AIC1, RM_AIC1_MS, ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_MS,
RV_AIC1_MS_MASTER); RV_AIC1_MS_MASTER);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to set codec DAI master (%d)\n", ret); "Failed to set codec DAI master (%d)\n", ret);
return ret; return ret;
} }
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
dev_err(codec->dev, "Unsupported format (%d)\n", ret); dev_err(component->dev, "Unsupported format (%d)\n", ret);
return ret; return ret;
} }
...@@ -1186,8 +1186,8 @@ static int tscs42xx_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -1186,8 +1186,8 @@ static int tscs42xx_set_dai_fmt(struct snd_soc_dai *codec_dai,
static int tscs42xx_set_dai_bclk_ratio(struct snd_soc_dai *codec_dai, static int tscs42xx_set_dai_bclk_ratio(struct snd_soc_dai *codec_dai,
unsigned int ratio) unsigned int ratio)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
unsigned int value; unsigned int value;
int ret = 0; int ret = 0;
...@@ -1202,18 +1202,18 @@ static int tscs42xx_set_dai_bclk_ratio(struct snd_soc_dai *codec_dai, ...@@ -1202,18 +1202,18 @@ static int tscs42xx_set_dai_bclk_ratio(struct snd_soc_dai *codec_dai,
value = RV_DACSR_DBCM_64; value = RV_DACSR_DBCM_64;
break; break;
default: default:
dev_err(codec->dev, "Unsupported bclk ratio (%d)\n", ret); dev_err(component->dev, "Unsupported bclk ratio (%d)\n", ret);
return -EINVAL; return -EINVAL;
} }
ret = snd_soc_update_bits(codec, R_DACSR, RM_DACSR_DBCM, value); ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBCM, value);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to set DAC BCLK ratio (%d)\n", ret); dev_err(component->dev, "Failed to set DAC BCLK ratio (%d)\n", ret);
return ret; return ret;
} }
ret = snd_soc_update_bits(codec, R_ADCSR, RM_ADCSR_ABCM, value); ret = snd_soc_component_update_bits(component, R_ADCSR, RM_ADCSR_ABCM, value);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to set ADC BCLK ratio (%d)\n", ret); dev_err(component->dev, "Failed to set ADC BCLK ratio (%d)\n", ret);
return ret; return ret;
} }
...@@ -1229,40 +1229,40 @@ static int tscs42xx_set_dai_bclk_ratio(struct snd_soc_dai *codec_dai, ...@@ -1229,40 +1229,40 @@ static int tscs42xx_set_dai_bclk_ratio(struct snd_soc_dai *codec_dai,
static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int tscs42xx_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;
int ret; int ret;
switch (clk_id) { switch (clk_id) {
case TSCS42XX_PLL_SRC_XTAL: case TSCS42XX_PLL_SRC_XTAL:
case TSCS42XX_PLL_SRC_MCLK1: case TSCS42XX_PLL_SRC_MCLK1:
ret = snd_soc_write(codec, R_PLLREFSEL, ret = snd_soc_component_write(component, R_PLLREFSEL,
RV_PLLREFSEL_PLL1_REF_SEL_XTAL_MCLK1 | RV_PLLREFSEL_PLL1_REF_SEL_XTAL_MCLK1 |
RV_PLLREFSEL_PLL2_REF_SEL_XTAL_MCLK1); RV_PLLREFSEL_PLL2_REF_SEL_XTAL_MCLK1);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to set pll reference input (%d)\n", "Failed to set pll reference input (%d)\n",
ret); ret);
return ret; return ret;
} }
break; break;
case TSCS42XX_PLL_SRC_MCLK2: case TSCS42XX_PLL_SRC_MCLK2:
ret = snd_soc_write(codec, R_PLLREFSEL, ret = snd_soc_component_write(component, R_PLLREFSEL,
RV_PLLREFSEL_PLL1_REF_SEL_MCLK2 | RV_PLLREFSEL_PLL1_REF_SEL_MCLK2 |
RV_PLLREFSEL_PLL2_REF_SEL_MCLK2); RV_PLLREFSEL_PLL2_REF_SEL_MCLK2);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to set PLL reference (%d)\n", ret); "Failed to set PLL reference (%d)\n", ret);
return ret; return ret;
} }
break; break;
default: default:
dev_err(codec->dev, "pll src is unsupported\n"); dev_err(component->dev, "pll src is unsupported\n");
return -EINVAL; return -EINVAL;
} }
ret = set_pll_ctl_from_input_freq(codec, freq); ret = set_pll_ctl_from_input_freq(component, freq);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to setup PLL input freq (%d)\n", ret); "Failed to setup PLL input freq (%d)\n", ret);
return ret; return ret;
} }
...@@ -1304,15 +1304,17 @@ static int part_is_valid(struct tscs42xx *tscs42xx) ...@@ -1304,15 +1304,17 @@ static int part_is_valid(struct tscs42xx *tscs42xx)
}; };
} }
static struct snd_soc_codec_driver soc_codec_dev_tscs42xx = { static struct snd_soc_component_driver soc_codec_dev_tscs42xx = {
.component_driver = {
.dapm_widgets = tscs42xx_dapm_widgets, .dapm_widgets = tscs42xx_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tscs42xx_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(tscs42xx_dapm_widgets),
.dapm_routes = tscs42xx_intercon, .dapm_routes = tscs42xx_intercon,
.num_dapm_routes = ARRAY_SIZE(tscs42xx_intercon), .num_dapm_routes = ARRAY_SIZE(tscs42xx_intercon),
.controls = tscs42xx_snd_controls, .controls = tscs42xx_snd_controls,
.num_controls = ARRAY_SIZE(tscs42xx_snd_controls), .num_controls = ARRAY_SIZE(tscs42xx_snd_controls),
}, .idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static inline void init_coeff_ram_cache(struct tscs42xx *tscs42xx) static inline void init_coeff_ram_cache(struct tscs42xx *tscs42xx)
...@@ -1407,7 +1409,7 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c, ...@@ -1407,7 +1409,7 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
mutex_init(&tscs42xx->coeff_ram_lock); mutex_init(&tscs42xx->coeff_ram_lock);
mutex_init(&tscs42xx->pll_lock); mutex_init(&tscs42xx->pll_lock);
ret = snd_soc_register_codec(tscs42xx->dev, &soc_codec_dev_tscs42xx, ret = devm_snd_soc_register_component(tscs42xx->dev, &soc_codec_dev_tscs42xx,
&tscs42xx_dai, 1); &tscs42xx_dai, 1);
if (ret) { if (ret) {
dev_err(tscs42xx->dev, "Failed to register codec (%d)\n", ret); dev_err(tscs42xx->dev, "Failed to register codec (%d)\n", ret);
...@@ -1417,13 +1419,6 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c, ...@@ -1417,13 +1419,6 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
return 0; return 0;
} }
static int tscs42xx_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id tscs42xx_i2c_id[] = { static const struct i2c_device_id tscs42xx_i2c_id[] = {
{ "tscs42A1", 0 }, { "tscs42A1", 0 },
{ "tscs42A2", 0 }, { "tscs42A2", 0 },
...@@ -1445,7 +1440,6 @@ static struct i2c_driver tscs42xx_i2c_driver = { ...@@ -1445,7 +1440,6 @@ static struct i2c_driver tscs42xx_i2c_driver = {
.of_match_table = tscs42xx_of_match, .of_match_table = tscs42xx_of_match,
}, },
.probe = tscs42xx_i2c_probe, .probe = tscs42xx_i2c_probe,
.remove = tscs42xx_i2c_remove,
.id_table = tscs42xx_i2c_id, .id_table = tscs42xx_i2c_id,
}; };
......
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