Commit 7275949e authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/msm8916-wcd-digital',...

Merge remote-tracking branches 'asoc/topic/msm8916-wcd-digital', 'asoc/topic/mtk', 'asoc/topic/nau8540', 'asoc/topic/nau8810' and 'asoc/topic/nau8824' into asoc-next
...@@ -348,14 +348,14 @@ static int msm8916_wcd_digital_enable_interpolator( ...@@ -348,14 +348,14 @@ static int msm8916_wcd_digital_enable_interpolator(
struct snd_kcontrol *kcontrol, struct snd_kcontrol *kcontrol,
int event) 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:
/* apply the digital gain after the interpolator is enabled */ /* apply the digital gain after the interpolator is enabled */
usleep_range(10000, 10100); usleep_range(10000, 10100);
snd_soc_write(codec, rx_gain_reg[w->shift], snd_soc_component_write(component, rx_gain_reg[w->shift],
snd_soc_read(codec, rx_gain_reg[w->shift])); snd_soc_component_read32(component, rx_gain_reg[w->shift]));
break; break;
} }
return 0; return 0;
...@@ -365,7 +365,7 @@ static int msm8916_wcd_digital_enable_dec(struct snd_soc_dapm_widget *w, ...@@ -365,7 +365,7 @@ static int msm8916_wcd_digital_enable_dec(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, struct snd_kcontrol *kcontrol,
int event) 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 decimator = w->shift + 1; unsigned int decimator = w->shift + 1;
u16 dec_reset_reg, tx_vol_ctl_reg, tx_mux_ctl_reg; u16 dec_reset_reg, tx_vol_ctl_reg, tx_mux_ctl_reg;
u8 dec_hpf_cut_of_freq; u8 dec_hpf_cut_of_freq;
...@@ -377,46 +377,46 @@ static int msm8916_wcd_digital_enable_dec(struct snd_soc_dapm_widget *w, ...@@ -377,46 +377,46 @@ static int msm8916_wcd_digital_enable_dec(struct snd_soc_dapm_widget *w,
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
/* Enable TX digital mute */ /* Enable TX digital mute */
snd_soc_update_bits(codec, tx_vol_ctl_reg, snd_soc_component_update_bits(component, tx_vol_ctl_reg,
TX_VOL_CTL_CFG_MUTE_EN_MASK, TX_VOL_CTL_CFG_MUTE_EN_MASK,
TX_VOL_CTL_CFG_MUTE_EN_ENABLE); TX_VOL_CTL_CFG_MUTE_EN_ENABLE);
dec_hpf_cut_of_freq = snd_soc_read(codec, tx_mux_ctl_reg) & dec_hpf_cut_of_freq = snd_soc_component_read32(component, tx_mux_ctl_reg) &
TX_MUX_CTL_CUT_OFF_FREQ_MASK; TX_MUX_CTL_CUT_OFF_FREQ_MASK;
dec_hpf_cut_of_freq >>= TX_MUX_CTL_CUT_OFF_FREQ_SHIFT; dec_hpf_cut_of_freq >>= TX_MUX_CTL_CUT_OFF_FREQ_SHIFT;
if (dec_hpf_cut_of_freq != TX_MUX_CTL_CF_NEG_3DB_150HZ) { if (dec_hpf_cut_of_freq != TX_MUX_CTL_CF_NEG_3DB_150HZ) {
/* set cut of freq to CF_MIN_3DB_150HZ (0x1) */ /* set cut of freq to CF_MIN_3DB_150HZ (0x1) */
snd_soc_update_bits(codec, tx_mux_ctl_reg, snd_soc_component_update_bits(component, tx_mux_ctl_reg,
TX_MUX_CTL_CUT_OFF_FREQ_MASK, TX_MUX_CTL_CUT_OFF_FREQ_MASK,
TX_MUX_CTL_CF_NEG_3DB_150HZ); TX_MUX_CTL_CF_NEG_3DB_150HZ);
} }
break; break;
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
/* enable HPF */ /* enable HPF */
snd_soc_update_bits(codec, tx_mux_ctl_reg, snd_soc_component_update_bits(component, tx_mux_ctl_reg,
TX_MUX_CTL_HPF_BP_SEL_MASK, TX_MUX_CTL_HPF_BP_SEL_MASK,
TX_MUX_CTL_HPF_BP_SEL_NO_BYPASS); TX_MUX_CTL_HPF_BP_SEL_NO_BYPASS);
/* apply the digital gain after the decimator is enabled */ /* apply the digital gain after the decimator is enabled */
snd_soc_write(codec, tx_gain_reg[w->shift], snd_soc_component_write(component, tx_gain_reg[w->shift],
snd_soc_read(codec, tx_gain_reg[w->shift])); snd_soc_component_read32(component, tx_gain_reg[w->shift]));
snd_soc_update_bits(codec, tx_vol_ctl_reg, snd_soc_component_update_bits(component, tx_vol_ctl_reg,
TX_VOL_CTL_CFG_MUTE_EN_MASK, 0); TX_VOL_CTL_CFG_MUTE_EN_MASK, 0);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, tx_vol_ctl_reg, snd_soc_component_update_bits(component, tx_vol_ctl_reg,
TX_VOL_CTL_CFG_MUTE_EN_MASK, TX_VOL_CTL_CFG_MUTE_EN_MASK,
TX_VOL_CTL_CFG_MUTE_EN_ENABLE); TX_VOL_CTL_CFG_MUTE_EN_ENABLE);
snd_soc_update_bits(codec, tx_mux_ctl_reg, snd_soc_component_update_bits(component, tx_mux_ctl_reg,
TX_MUX_CTL_HPF_BP_SEL_MASK, TX_MUX_CTL_HPF_BP_SEL_MASK,
TX_MUX_CTL_HPF_BP_SEL_BYPASS); TX_MUX_CTL_HPF_BP_SEL_BYPASS);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, snd_soc_component_update_bits(component, dec_reset_reg, 1 << w->shift,
1 << w->shift); 1 << w->shift);
snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 0x0); snd_soc_component_update_bits(component, dec_reset_reg, 1 << w->shift, 0x0);
snd_soc_update_bits(codec, tx_mux_ctl_reg, snd_soc_component_update_bits(component, tx_mux_ctl_reg,
TX_MUX_CTL_HPF_BP_SEL_MASK, TX_MUX_CTL_HPF_BP_SEL_MASK,
TX_MUX_CTL_HPF_BP_SEL_BYPASS); TX_MUX_CTL_HPF_BP_SEL_BYPASS);
snd_soc_update_bits(codec, tx_vol_ctl_reg, snd_soc_component_update_bits(component, tx_vol_ctl_reg,
TX_VOL_CTL_CFG_MUTE_EN_MASK, 0); TX_VOL_CTL_CFG_MUTE_EN_MASK, 0);
break; break;
} }
...@@ -428,35 +428,35 @@ static int msm8916_wcd_digital_enable_dmic(struct snd_soc_dapm_widget *w, ...@@ -428,35 +428,35 @@ static int msm8916_wcd_digital_enable_dmic(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, struct snd_kcontrol *kcontrol,
int event) 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 dmic; unsigned int dmic;
int ret; int ret;
/* get dmic number out of widget name */ /* get dmic number out of widget name */
char *dmic_num = strpbrk(w->name, "12"); char *dmic_num = strpbrk(w->name, "12");
if (dmic_num == NULL) { if (dmic_num == NULL) {
dev_err(codec->dev, "Invalid DMIC\n"); dev_err(component->dev, "Invalid DMIC\n");
return -EINVAL; return -EINVAL;
} }
ret = kstrtouint(dmic_num, 10, &dmic); ret = kstrtouint(dmic_num, 10, &dmic);
if (ret < 0 || dmic > 2) { if (ret < 0 || dmic > 2) {
dev_err(codec->dev, "Invalid DMIC line on the codec\n"); dev_err(component->dev, "Invalid DMIC line on the component\n");
return -EINVAL; return -EINVAL;
} }
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
snd_soc_update_bits(codec, LPASS_CDC_CLK_DMIC_B1_CTL, snd_soc_component_update_bits(component, LPASS_CDC_CLK_DMIC_B1_CTL,
DMIC_B1_CTL_DMIC0_CLK_SEL_MASK, DMIC_B1_CTL_DMIC0_CLK_SEL_MASK,
DMIC_B1_CTL_DMIC0_CLK_SEL_DIV3); DMIC_B1_CTL_DMIC0_CLK_SEL_DIV3);
switch (dmic) { switch (dmic) {
case 1: case 1:
snd_soc_update_bits(codec, LPASS_CDC_TX1_DMIC_CTL, snd_soc_component_update_bits(component, LPASS_CDC_TX1_DMIC_CTL,
TXN_DMIC_CTL_CLK_SEL_MASK, TXN_DMIC_CTL_CLK_SEL_MASK,
TXN_DMIC_CTL_CLK_SEL_DIV3); TXN_DMIC_CTL_CLK_SEL_DIV3);
break; break;
case 2: case 2:
snd_soc_update_bits(codec, LPASS_CDC_TX2_DMIC_CTL, snd_soc_component_update_bits(component, LPASS_CDC_TX2_DMIC_CTL,
TXN_DMIC_CTL_CLK_SEL_MASK, TXN_DMIC_CTL_CLK_SEL_MASK,
TXN_DMIC_CTL_CLK_SEL_DIV3); TXN_DMIC_CTL_CLK_SEL_DIV3);
break; break;
...@@ -575,20 +575,20 @@ static int msm8916_wcd_digital_get_clks(struct platform_device *pdev, ...@@ -575,20 +575,20 @@ static int msm8916_wcd_digital_get_clks(struct platform_device *pdev,
return 0; return 0;
} }
static int msm8916_wcd_digital_codec_probe(struct snd_soc_codec *codec) static int msm8916_wcd_digital_component_probe(struct snd_soc_component *component)
{ {
struct msm8916_wcd_digital_priv *priv = dev_get_drvdata(codec->dev); struct msm8916_wcd_digital_priv *priv = dev_get_drvdata(component->dev);
snd_soc_codec_set_drvdata(codec, priv); snd_soc_component_set_drvdata(component, priv);
return 0; return 0;
} }
static int msm8916_wcd_digital_codec_set_sysclk(struct snd_soc_codec *codec, static int msm8916_wcd_digital_component_set_sysclk(struct snd_soc_component *component,
int clk_id, int source, int clk_id, int source,
unsigned int freq, int dir) unsigned int freq, int dir)
{ {
struct msm8916_wcd_digital_priv *p = dev_get_drvdata(codec->dev); struct msm8916_wcd_digital_priv *p = dev_get_drvdata(component->dev);
return clk_set_rate(p->mclk, freq); return clk_set_rate(p->mclk, freq);
} }
...@@ -618,18 +618,18 @@ static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream, ...@@ -618,18 +618,18 @@ static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream,
rx_fs_rate = RX_I2S_CTL_RX_I2S_FS_RATE_F_48_KHZ; rx_fs_rate = RX_I2S_CTL_RX_I2S_FS_RATE_F_48_KHZ;
break; break;
default: default:
dev_err(dai->codec->dev, "Invalid sampling rate %d\n", dev_err(dai->component->dev, "Invalid sampling rate %d\n",
params_rate(params)); params_rate(params));
return -EINVAL; return -EINVAL;
} }
switch (substream->stream) { switch (substream->stream) {
case SNDRV_PCM_STREAM_CAPTURE: case SNDRV_PCM_STREAM_CAPTURE:
snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_TX_I2S_CTL, snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_TX_I2S_CTL,
TX_I2S_CTL_TX_I2S_FS_RATE_MASK, tx_fs_rate); TX_I2S_CTL_TX_I2S_FS_RATE_MASK, tx_fs_rate);
break; break;
case SNDRV_PCM_STREAM_PLAYBACK: case SNDRV_PCM_STREAM_PLAYBACK:
snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_RX_I2S_CTL, snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_RX_I2S_CTL,
RX_I2S_CTL_RX_I2S_FS_RATE_MASK, rx_fs_rate); RX_I2S_CTL_RX_I2S_FS_RATE_MASK, rx_fs_rate);
break; break;
default: default:
...@@ -638,18 +638,19 @@ static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream, ...@@ -638,18 +638,19 @@ static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream,
switch (params_format(params)) { switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE: case SNDRV_PCM_FORMAT_S16_LE:
snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_TX_I2S_CTL, snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_TX_I2S_CTL,
TX_I2S_CTL_TX_I2S_MODE_MASK, TX_I2S_CTL_TX_I2S_MODE_MASK,
TX_I2S_CTL_TX_I2S_MODE_16); TX_I2S_CTL_TX_I2S_MODE_16);
snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_RX_I2S_CTL, snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_RX_I2S_CTL,
RX_I2S_CTL_RX_I2S_MODE_MASK, RX_I2S_CTL_RX_I2S_MODE_MASK,
RX_I2S_CTL_RX_I2S_MODE_16); RX_I2S_CTL_RX_I2S_MODE_16);
break; break;
case SNDRV_PCM_FORMAT_S32_LE: case SNDRV_PCM_FORMAT_S32_LE:
snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_TX_I2S_CTL, snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_TX_I2S_CTL,
TX_I2S_CTL_TX_I2S_MODE_MASK, TX_I2S_CTL_TX_I2S_MODE_MASK,
TX_I2S_CTL_TX_I2S_MODE_32); TX_I2S_CTL_TX_I2S_MODE_32);
snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_RX_I2S_CTL, snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_RX_I2S_CTL,
RX_I2S_CTL_RX_I2S_MODE_MASK, RX_I2S_CTL_RX_I2S_MODE_MASK,
RX_I2S_CTL_RX_I2S_MODE_32); RX_I2S_CTL_RX_I2S_MODE_32);
break; break;
...@@ -780,32 +781,32 @@ static const struct snd_soc_dapm_route msm8916_wcd_digital_audio_map[] = { ...@@ -780,32 +781,32 @@ static const struct snd_soc_dapm_route msm8916_wcd_digital_audio_map[] = {
static int msm8916_wcd_digital_startup(struct snd_pcm_substream *substream, static int msm8916_wcd_digital_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct msm8916_wcd_digital_priv *msm8916_wcd; struct msm8916_wcd_digital_priv *msm8916_wcd;
unsigned long mclk_rate; unsigned long mclk_rate;
msm8916_wcd = snd_soc_codec_get_drvdata(codec); msm8916_wcd = snd_soc_component_get_drvdata(component);
snd_soc_update_bits(codec, LPASS_CDC_CLK_MCLK_CTL, snd_soc_component_update_bits(component, LPASS_CDC_CLK_MCLK_CTL,
MCLK_CTL_MCLK_EN_MASK, MCLK_CTL_MCLK_EN_MASK,
MCLK_CTL_MCLK_EN_ENABLE); MCLK_CTL_MCLK_EN_ENABLE);
snd_soc_update_bits(codec, LPASS_CDC_CLK_PDM_CTL, snd_soc_component_update_bits(component, LPASS_CDC_CLK_PDM_CTL,
LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_MASK, LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_MASK,
LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_FB); LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_FB);
mclk_rate = clk_get_rate(msm8916_wcd->mclk); mclk_rate = clk_get_rate(msm8916_wcd->mclk);
switch (mclk_rate) { switch (mclk_rate) {
case 12288000: case 12288000:
snd_soc_update_bits(codec, LPASS_CDC_TOP_CTL, snd_soc_component_update_bits(component, LPASS_CDC_TOP_CTL,
TOP_CTL_DIG_MCLK_FREQ_MASK, TOP_CTL_DIG_MCLK_FREQ_MASK,
TOP_CTL_DIG_MCLK_FREQ_F_12_288MHZ); TOP_CTL_DIG_MCLK_FREQ_F_12_288MHZ);
break; break;
case 9600000: case 9600000:
snd_soc_update_bits(codec, LPASS_CDC_TOP_CTL, snd_soc_component_update_bits(component, LPASS_CDC_TOP_CTL,
TOP_CTL_DIG_MCLK_FREQ_MASK, TOP_CTL_DIG_MCLK_FREQ_MASK,
TOP_CTL_DIG_MCLK_FREQ_F_9_6MHZ); TOP_CTL_DIG_MCLK_FREQ_F_9_6MHZ);
break; break;
default: default:
dev_err(codec->dev, "Invalid mclk rate %ld\n", mclk_rate); dev_err(component->dev, "Invalid mclk rate %ld\n", mclk_rate);
break; break;
} }
return 0; return 0;
...@@ -814,7 +815,7 @@ static int msm8916_wcd_digital_startup(struct snd_pcm_substream *substream, ...@@ -814,7 +815,7 @@ static int msm8916_wcd_digital_startup(struct snd_pcm_substream *substream,
static void msm8916_wcd_digital_shutdown(struct snd_pcm_substream *substream, static void msm8916_wcd_digital_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_PDM_CTL, snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_PDM_CTL,
LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_MASK, 0); LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_MASK, 0);
} }
...@@ -851,18 +852,19 @@ static struct snd_soc_dai_driver msm8916_wcd_digital_dai[] = { ...@@ -851,18 +852,19 @@ static struct snd_soc_dai_driver msm8916_wcd_digital_dai[] = {
}, },
}; };
static const struct snd_soc_codec_driver msm8916_wcd_digital = { static const struct snd_soc_component_driver msm8916_wcd_digital = {
.probe = msm8916_wcd_digital_codec_probe, .probe = msm8916_wcd_digital_component_probe,
.set_sysclk = msm8916_wcd_digital_codec_set_sysclk, .set_sysclk = msm8916_wcd_digital_component_set_sysclk,
.component_driver = { .controls = msm8916_wcd_digital_snd_controls,
.controls = msm8916_wcd_digital_snd_controls, .num_controls = ARRAY_SIZE(msm8916_wcd_digital_snd_controls),
.num_controls = ARRAY_SIZE(msm8916_wcd_digital_snd_controls), .dapm_widgets = msm8916_wcd_digital_dapm_widgets,
.dapm_widgets = msm8916_wcd_digital_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(msm8916_wcd_digital_dapm_widgets),
.num_dapm_widgets = .dapm_routes = msm8916_wcd_digital_audio_map,
ARRAY_SIZE(msm8916_wcd_digital_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(msm8916_wcd_digital_audio_map),
.dapm_routes = msm8916_wcd_digital_audio_map, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(msm8916_wcd_digital_audio_map), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config msm8916_codec_regmap_config = { static const struct regmap_config msm8916_codec_regmap_config = {
...@@ -915,7 +917,7 @@ static int msm8916_wcd_digital_probe(struct platform_device *pdev) ...@@ -915,7 +917,7 @@ static int msm8916_wcd_digital_probe(struct platform_device *pdev)
dev_set_drvdata(dev, priv); dev_set_drvdata(dev, priv);
return snd_soc_register_codec(dev, &msm8916_wcd_digital, return devm_snd_soc_register_component(dev, &msm8916_wcd_digital,
msm8916_wcd_digital_dai, msm8916_wcd_digital_dai,
ARRAY_SIZE(msm8916_wcd_digital_dai)); ARRAY_SIZE(msm8916_wcd_digital_dai));
} }
...@@ -924,7 +926,6 @@ static int msm8916_wcd_digital_remove(struct platform_device *pdev) ...@@ -924,7 +926,6 @@ static int msm8916_wcd_digital_remove(struct platform_device *pdev)
{ {
struct msm8916_wcd_digital_priv *priv = dev_get_drvdata(&pdev->dev); struct msm8916_wcd_digital_priv *priv = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_codec(&pdev->dev);
clk_disable_unprepare(priv->mclk); clk_disable_unprepare(priv->mclk);
clk_disable_unprepare(priv->ahbclk); clk_disable_unprepare(priv->ahbclk);
......
...@@ -236,8 +236,8 @@ static const struct snd_kcontrol_new digital_ch1_mux = ...@@ -236,8 +236,8 @@ static const struct snd_kcontrol_new digital_ch1_mux =
static int adc_power_control(struct snd_soc_dapm_widget *w, static int adc_power_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, 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 nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component);
if (SND_SOC_DAPM_EVENT_ON(event)) { if (SND_SOC_DAPM_EVENT_ON(event)) {
msleep(300); msleep(300);
...@@ -258,8 +258,8 @@ static int adc_power_control(struct snd_soc_dapm_widget *w, ...@@ -258,8 +258,8 @@ static int adc_power_control(struct snd_soc_dapm_widget *w,
static int aiftx_power_control(struct snd_soc_dapm_widget *w, static int aiftx_power_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, 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 nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component);
if (SND_SOC_DAPM_EVENT_OFF(event)) { if (SND_SOC_DAPM_EVENT_OFF(event)) {
regmap_write(nau8540->regmap, NAU8540_REG_RST, 0x0001); regmap_write(nau8540->regmap, NAU8540_REG_RST, 0x0001);
...@@ -379,8 +379,8 @@ static int nau8540_clock_check(struct nau8540 *nau8540, int rate, int osr) ...@@ -379,8 +379,8 @@ static int nau8540_clock_check(struct nau8540 *nau8540, int rate, int osr)
static int nau8540_hw_params(struct snd_pcm_substream *substream, static int nau8540_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 nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component);
unsigned int val_len = 0, osr; unsigned int val_len = 0, osr;
/* CLK_ADC = OSR * FS /* CLK_ADC = OSR * FS
...@@ -422,8 +422,8 @@ static int nau8540_hw_params(struct snd_pcm_substream *substream, ...@@ -422,8 +422,8 @@ static int nau8540_hw_params(struct snd_pcm_substream *substream,
static int nau8540_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int nau8540_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); struct nau8540 *nau8540 = 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) {
...@@ -493,8 +493,8 @@ static int nau8540_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -493,8 +493,8 @@ static int nau8540_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
static int nau8540_set_tdm_slot(struct snd_soc_dai *dai, static int nau8540_set_tdm_slot(struct snd_soc_dai *dai,
unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component);
unsigned int ctrl2_val = 0, ctrl4_val = 0; unsigned int ctrl2_val = 0, ctrl4_val = 0;
if (slots > 4 || ((tx_mask & 0xf0) && (tx_mask & 0xf))) if (slots > 4 || ((tx_mask & 0xf0) && (tx_mask & 0xf)))
...@@ -649,10 +649,10 @@ static void nau8540_fll_apply(struct regmap *regmap, ...@@ -649,10 +649,10 @@ static void nau8540_fll_apply(struct regmap *regmap,
} }
/* 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 nau8540_set_pll(struct snd_soc_codec *codec, int pll_id, int source, static int nau8540_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 nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component);
struct nau8540_fll fll_param; struct nau8540_fll fll_param;
int ret, fs; int ret, fs;
...@@ -702,10 +702,10 @@ static int nau8540_set_pll(struct snd_soc_codec *codec, int pll_id, int source, ...@@ -702,10 +702,10 @@ static int nau8540_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
return 0; return 0;
} }
static int nau8540_set_sysclk(struct snd_soc_codec *codec, static int nau8540_set_sysclk(struct snd_soc_component *component,
int clk_id, int source, unsigned int freq, int dir) int clk_id, int source, unsigned int freq, int dir)
{ {
struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component);
switch (clk_id) { switch (clk_id) {
case NAU8540_CLK_DIS: case NAU8540_CLK_DIS:
...@@ -777,9 +777,9 @@ static void nau8540_init_regs(struct nau8540 *nau8540) ...@@ -777,9 +777,9 @@ static void nau8540_init_regs(struct nau8540 *nau8540)
NAU8540_I2S_DO34_TRI, NAU8540_I2S_DO34_TRI); NAU8540_I2S_DO34_TRI, NAU8540_I2S_DO34_TRI);
} }
static int __maybe_unused nau8540_suspend(struct snd_soc_codec *codec) static int __maybe_unused nau8540_suspend(struct snd_soc_component *component)
{ {
struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component);
regcache_cache_only(nau8540->regmap, true); regcache_cache_only(nau8540->regmap, true);
regcache_mark_dirty(nau8540->regmap); regcache_mark_dirty(nau8540->regmap);
...@@ -787,9 +787,9 @@ static int __maybe_unused nau8540_suspend(struct snd_soc_codec *codec) ...@@ -787,9 +787,9 @@ static int __maybe_unused nau8540_suspend(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int __maybe_unused nau8540_resume(struct snd_soc_codec *codec) static int __maybe_unused nau8540_resume(struct snd_soc_component *component)
{ {
struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component);
regcache_cache_only(nau8540->regmap, false); regcache_cache_only(nau8540->regmap, false);
regcache_sync(nau8540->regmap); regcache_sync(nau8540->regmap);
...@@ -797,21 +797,22 @@ static int __maybe_unused nau8540_resume(struct snd_soc_codec *codec) ...@@ -797,21 +797,22 @@ static int __maybe_unused nau8540_resume(struct snd_soc_codec *codec)
return 0; return 0;
} }
static const struct snd_soc_codec_driver nau8540_codec_driver = { static const struct snd_soc_component_driver nau8540_component_driver = {
.set_sysclk = nau8540_set_sysclk, .set_sysclk = nau8540_set_sysclk,
.set_pll = nau8540_set_pll, .set_pll = nau8540_set_pll,
.suspend = nau8540_suspend, .suspend = nau8540_suspend,
.resume = nau8540_resume, .resume = nau8540_resume,
.suspend_bias_off = true, .controls = nau8540_snd_controls,
.num_controls = ARRAY_SIZE(nau8540_snd_controls),
.component_driver = { .dapm_widgets = nau8540_dapm_widgets,
.controls = nau8540_snd_controls, .num_dapm_widgets = ARRAY_SIZE(nau8540_dapm_widgets),
.num_controls = ARRAY_SIZE(nau8540_snd_controls), .dapm_routes = nau8540_dapm_routes,
.dapm_widgets = nau8540_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(nau8540_dapm_routes),
.num_dapm_widgets = ARRAY_SIZE(nau8540_dapm_widgets), .suspend_bias_off = 1,
.dapm_routes = nau8540_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(nau8540_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config nau8540_regmap_config = { static const struct regmap_config nau8540_regmap_config = {
...@@ -856,17 +857,10 @@ static int nau8540_i2c_probe(struct i2c_client *i2c, ...@@ -856,17 +857,10 @@ static int nau8540_i2c_probe(struct i2c_client *i2c,
nau8540_reset_chip(nau8540->regmap); nau8540_reset_chip(nau8540->regmap);
nau8540_init_regs(nau8540); nau8540_init_regs(nau8540);
return snd_soc_register_codec(dev, return devm_snd_soc_register_component(dev,
&nau8540_codec_driver, &nau8540_dai, 1); &nau8540_component_driver, &nau8540_dai, 1);
}
static int nau8540_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
} }
static const struct i2c_device_id nau8540_i2c_ids[] = { static const struct i2c_device_id nau8540_i2c_ids[] = {
{ "nau8540", 0 }, { "nau8540", 0 },
{ } { }
...@@ -887,7 +881,6 @@ static struct i2c_driver nau8540_i2c_driver = { ...@@ -887,7 +881,6 @@ static struct i2c_driver nau8540_i2c_driver = {
.of_match_table = of_match_ptr(nau8540_of_ids), .of_match_table = of_match_ptr(nau8540_of_ids),
}, },
.probe = nau8540_i2c_probe, .probe = nau8540_i2c_probe,
.remove = nau8540_i2c_remove,
.id_table = nau8540_i2c_ids, .id_table = nau8540_i2c_ids,
}; };
module_i2c_driver(nau8540_i2c_driver); module_i2c_driver(nau8540_i2c_driver);
......
...@@ -167,8 +167,8 @@ static bool nau8810_volatile_reg(struct device *dev, unsigned int reg) ...@@ -167,8 +167,8 @@ static bool nau8810_volatile_reg(struct device *dev, unsigned int reg)
static int nau8810_eq_get(struct snd_kcontrol *kcontrol, static int nau8810_eq_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 nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
struct soc_bytes_ext *params = (void *)kcontrol->private_value; struct soc_bytes_ext *params = (void *)kcontrol->private_value;
int i, reg, reg_val; int i, reg, reg_val;
u16 *val; u16 *val;
...@@ -198,8 +198,8 @@ static int nau8810_eq_get(struct snd_kcontrol *kcontrol, ...@@ -198,8 +198,8 @@ static int nau8810_eq_get(struct snd_kcontrol *kcontrol,
static int nau8810_eq_put(struct snd_kcontrol *kcontrol, static int nau8810_eq_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 nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
struct soc_bytes_ext *params = (void *)kcontrol->private_value; struct soc_bytes_ext *params = (void *)kcontrol->private_value;
void *data; void *data;
u16 *val, value; u16 *val, value;
...@@ -219,7 +219,7 @@ static int nau8810_eq_put(struct snd_kcontrol *kcontrol, ...@@ -219,7 +219,7 @@ static int nau8810_eq_put(struct snd_kcontrol *kcontrol,
value = be16_to_cpu(*(val + i)); value = be16_to_cpu(*(val + i));
ret = regmap_write(nau8810->regmap, reg + i, value); ret = regmap_write(nau8810->regmap, reg + i, value);
if (ret) { if (ret) {
dev_err(codec->dev, "EQ configuration fail, register: %x ret: %d\n", dev_err(component->dev, "EQ configuration fail, register: %x ret: %d\n",
reg + i, ret); reg + i, ret);
kfree(data); kfree(data);
return ret; return ret;
...@@ -399,8 +399,8 @@ static const struct snd_kcontrol_new nau8810_loopback = ...@@ -399,8 +399,8 @@ static const struct snd_kcontrol_new nau8810_loopback =
static int check_mclk_select_pll(struct snd_soc_dapm_widget *source, static int check_mclk_select_pll(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 nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
unsigned int value; unsigned int value;
regmap_read(nau8810->regmap, NAU8810_REG_CLOCK, &value); regmap_read(nau8810->regmap, NAU8810_REG_CLOCK, &value);
...@@ -485,8 +485,8 @@ static const struct snd_soc_dapm_route nau8810_dapm_routes[] = { ...@@ -485,8 +485,8 @@ static const struct snd_soc_dapm_route nau8810_dapm_routes[] = {
static int nau8810_set_sysclk(struct snd_soc_dai *dai, static int nau8810_set_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 nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
nau8810->clk_id = clk_id; nau8810->clk_id = clk_id;
nau8810->sysclk = freq; nau8810->sysclk = freq;
...@@ -538,8 +538,8 @@ static int nau88l0_calc_pll(unsigned int pll_in, ...@@ -538,8 +538,8 @@ static int nau88l0_calc_pll(unsigned int pll_in,
static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id, static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id,
int source, unsigned int freq_in, unsigned int freq_out) int source, unsigned int freq_in, unsigned int freq_out)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
struct regmap *map = nau8810->regmap; struct regmap *map = nau8810->regmap;
struct nau8810_pll *pll_param = &nau8810->pll; struct nau8810_pll *pll_param = &nau8810->pll;
int ret, fs; int ret, fs;
...@@ -577,8 +577,8 @@ static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id, ...@@ -577,8 +577,8 @@ static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id,
static int nau8810_set_dai_fmt(struct snd_soc_dai *codec_dai, static int nau8810_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
u16 ctrl1_val = 0, ctrl2_val = 0; u16 ctrl1_val = 0, ctrl2_val = 0;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
...@@ -667,8 +667,8 @@ static int nau8810_mclk_clkdiv(struct nau8810 *nau8810, int rate) ...@@ -667,8 +667,8 @@ static int nau8810_mclk_clkdiv(struct nau8810 *nau8810, int rate)
static int nau8810_pcm_hw_params(struct snd_pcm_substream *substream, static int nau8810_pcm_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 nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
int val_len = 0, val_rate = 0, ret = 0; int val_len = 0, val_rate = 0, ret = 0;
switch (params_width(params)) { switch (params_width(params)) {
...@@ -723,10 +723,10 @@ static int nau8810_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -723,10 +723,10 @@ static int nau8810_pcm_hw_params(struct snd_pcm_substream *substream,
return ret; return ret;
} }
static int nau8810_set_bias_level(struct snd_soc_codec *codec, static int nau8810_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component);
struct regmap *map = nau8810->regmap; struct regmap *map = nau8810->regmap;
switch (level) { switch (level) {
...@@ -741,7 +741,7 @@ static int nau8810_set_bias_level(struct snd_soc_codec *codec, ...@@ -741,7 +741,7 @@ static int nau8810_set_bias_level(struct snd_soc_codec *codec,
NAU8810_IOBUF_EN | NAU8810_ABIAS_EN, NAU8810_IOBUF_EN | NAU8810_ABIAS_EN,
NAU8810_IOBUF_EN | NAU8810_ABIAS_EN); NAU8810_IOBUF_EN | NAU8810_ABIAS_EN);
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
regcache_sync(map); regcache_sync(map);
regmap_update_bits(map, NAU8810_REG_POWER1, regmap_update_bits(map, NAU8810_REG_POWER1,
NAU8810_REFIMP_MASK, NAU8810_REFIMP_3K); NAU8810_REFIMP_MASK, NAU8810_REFIMP_3K);
...@@ -808,18 +808,19 @@ static const struct regmap_config nau8810_regmap_config = { ...@@ -808,18 +808,19 @@ static const struct regmap_config nau8810_regmap_config = {
.num_reg_defaults = ARRAY_SIZE(nau8810_reg_defaults), .num_reg_defaults = ARRAY_SIZE(nau8810_reg_defaults),
}; };
static const struct snd_soc_codec_driver nau8810_codec_driver = { static const struct snd_soc_component_driver nau8810_component_driver = {
.set_bias_level = nau8810_set_bias_level, .set_bias_level = nau8810_set_bias_level,
.suspend_bias_off = true, .controls = nau8810_snd_controls,
.num_controls = ARRAY_SIZE(nau8810_snd_controls),
.component_driver = { .dapm_widgets = nau8810_dapm_widgets,
.controls = nau8810_snd_controls, .num_dapm_widgets = ARRAY_SIZE(nau8810_dapm_widgets),
.num_controls = ARRAY_SIZE(nau8810_snd_controls), .dapm_routes = nau8810_dapm_routes,
.dapm_widgets = nau8810_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(nau8810_dapm_routes),
.num_dapm_widgets = ARRAY_SIZE(nau8810_dapm_widgets), .suspend_bias_off = 1,
.dapm_routes = nau8810_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(nau8810_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int nau8810_i2c_probe(struct i2c_client *i2c, static int nau8810_i2c_probe(struct i2c_client *i2c,
...@@ -842,15 +843,8 @@ static int nau8810_i2c_probe(struct i2c_client *i2c, ...@@ -842,15 +843,8 @@ static int nau8810_i2c_probe(struct i2c_client *i2c,
regmap_write(nau8810->regmap, NAU8810_REG_RESET, 0x00); regmap_write(nau8810->regmap, NAU8810_REG_RESET, 0x00);
return snd_soc_register_codec(dev, return devm_snd_soc_register_component(dev,
&nau8810_codec_driver, &nau8810_dai, 1); &nau8810_component_driver, &nau8810_dai, 1);
}
static int nau8810_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
} }
static const struct i2c_device_id nau8810_i2c_id[] = { static const struct i2c_device_id nau8810_i2c_id[] = {
...@@ -873,7 +867,6 @@ static struct i2c_driver nau8810_i2c_driver = { ...@@ -873,7 +867,6 @@ static struct i2c_driver nau8810_i2c_driver = {
.of_match_table = of_match_ptr(nau8810_of_match), .of_match_table = of_match_ptr(nau8810_of_match),
}, },
.probe = nau8810_i2c_probe, .probe = nau8810_i2c_probe,
.remove = nau8810_i2c_remove,
.id_table = nau8810_i2c_id, .id_table = nau8810_i2c_id,
}; };
......
...@@ -414,8 +414,8 @@ static const struct snd_kcontrol_new nau8824_snd_controls[] = { ...@@ -414,8 +414,8 @@ static const struct snd_kcontrol_new nau8824_snd_controls[] = {
static int nau8824_output_dac_event(struct snd_soc_dapm_widget *w, static int nau8824_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 nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
...@@ -437,8 +437,8 @@ static int nau8824_output_dac_event(struct snd_soc_dapm_widget *w, ...@@ -437,8 +437,8 @@ static int nau8824_output_dac_event(struct snd_soc_dapm_widget *w,
static int nau8824_spk_event(struct snd_soc_dapm_widget *w, static int nau8824_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);
struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
...@@ -461,8 +461,8 @@ static int nau8824_spk_event(struct snd_soc_dapm_widget *w, ...@@ -461,8 +461,8 @@ static int nau8824_spk_event(struct snd_soc_dapm_widget *w,
static int nau8824_pump_event(struct snd_soc_dapm_widget *w, static int nau8824_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 nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
...@@ -487,10 +487,14 @@ static int nau8824_pump_event(struct snd_soc_dapm_widget *w, ...@@ -487,10 +487,14 @@ static int nau8824_pump_event(struct snd_soc_dapm_widget *w,
static int system_clock_control(struct snd_soc_dapm_widget *w, static int system_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, 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 nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
struct regmap *regmap = nau8824->regmap;
unsigned int value;
bool clk_fll, error;
if (SND_SOC_DAPM_EVENT_OFF(event)) { if (SND_SOC_DAPM_EVENT_OFF(event)) {
dev_dbg(nau8824->dev, "system clock control : POWER OFF\n");
/* Set clock source to disable or internal clock before the /* Set clock source to disable or internal clock before the
* playback or capture end. Codec needs clock for Jack * playback or capture end. Codec needs clock for Jack
* detection and button press if jack inserted; otherwise, * detection and button press if jack inserted; otherwise,
...@@ -502,15 +506,48 @@ static int system_clock_control(struct snd_soc_dapm_widget *w, ...@@ -502,15 +506,48 @@ static int system_clock_control(struct snd_soc_dapm_widget *w,
} else { } else {
nau8824_config_sysclk(nau8824, NAU8824_CLK_DIS, 0); nau8824_config_sysclk(nau8824, NAU8824_CLK_DIS, 0);
} }
} else {
dev_dbg(nau8824->dev, "system clock control : POWER ON\n");
/* Check the clock source setting is proper or not
* no matter the source is from FLL or MCLK.
*/
regmap_read(regmap, NAU8824_REG_FLL1, &value);
clk_fll = value & NAU8824_FLL_RATIO_MASK;
/* It's error to use internal clock when playback */
regmap_read(regmap, NAU8824_REG_FLL6, &value);
error = value & NAU8824_DCO_EN;
if (!error) {
/* Check error depending on source is FLL or MCLK. */
regmap_read(regmap, NAU8824_REG_CLK_DIVIDER, &value);
if (clk_fll)
error = !(value & NAU8824_CLK_SRC_VCO);
else
error = value & NAU8824_CLK_SRC_VCO;
}
/* Recover the clock source setting if error. */
if (error) {
if (clk_fll) {
regmap_update_bits(regmap,
NAU8824_REG_FLL6, NAU8824_DCO_EN, 0);
regmap_update_bits(regmap,
NAU8824_REG_CLK_DIVIDER,
NAU8824_CLK_SRC_MASK,
NAU8824_CLK_SRC_VCO);
} else {
nau8824_config_sysclk(nau8824,
NAU8824_CLK_MCLK, 0);
}
}
} }
return 0; return 0;
} }
static int dmic_clock_control(struct snd_soc_dapm_widget *w, static int dmic_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, 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 nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
int src; int src;
/* The DMIC clock is gotten from system clock (256fs) divided by /* The DMIC clock is gotten from system clock (256fs) divided by
...@@ -591,7 +628,8 @@ static const struct snd_kcontrol_new nau8824_dacr_mux = ...@@ -591,7 +628,8 @@ static const struct snd_kcontrol_new nau8824_dacr_mux =
static const struct snd_soc_dapm_widget nau8824_dapm_widgets[] = { static const struct snd_soc_dapm_widget nau8824_dapm_widgets[] = {
SND_SOC_DAPM_SUPPLY("System Clock", SND_SOC_NOPM, 0, 0, SND_SOC_DAPM_SUPPLY("System Clock", SND_SOC_NOPM, 0, 0,
system_clock_control, SND_SOC_DAPM_POST_PMD), system_clock_control, SND_SOC_DAPM_POST_PMD |
SND_SOC_DAPM_POST_PMU),
SND_SOC_DAPM_INPUT("HSMIC1"), SND_SOC_DAPM_INPUT("HSMIC1"),
SND_SOC_DAPM_INPUT("HSMIC2"), SND_SOC_DAPM_INPUT("HSMIC2"),
...@@ -988,8 +1026,8 @@ static int nau8824_clock_check(struct nau8824 *nau8824, ...@@ -988,8 +1026,8 @@ static int nau8824_clock_check(struct nau8824 *nau8824,
static int nau8824_hw_params(struct snd_pcm_substream *substream, static int nau8824_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 nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = 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;
nau8824_sema_acquire(nau8824, HZ); nau8824_sema_acquire(nau8824, HZ);
...@@ -1072,8 +1110,8 @@ static int nau8824_hw_params(struct snd_pcm_substream *substream, ...@@ -1072,8 +1110,8 @@ static int nau8824_hw_params(struct snd_pcm_substream *substream,
static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
unsigned int ctrl1_val = 0, ctrl2_val = 0; unsigned int ctrl1_val = 0, ctrl2_val = 0;
nau8824_sema_acquire(nau8824, HZ); nau8824_sema_acquire(nau8824, HZ);
...@@ -1149,8 +1187,8 @@ static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -1149,8 +1187,8 @@ static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
static int nau8824_set_tdm_slot(struct snd_soc_dai *dai, static int nau8824_set_tdm_slot(struct snd_soc_dai *dai,
unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
unsigned int tslot_l = 0, ctrl_val = 0; unsigned int tslot_l = 0, ctrl_val = 0;
if (slots > 4 || ((tx_mask & 0xf0) && (tx_mask & 0xf)) || if (slots > 4 || ((tx_mask & 0xf0) && (tx_mask & 0xf)) ||
...@@ -1288,10 +1326,10 @@ static void nau8824_fll_apply(struct regmap *regmap, ...@@ -1288,10 +1326,10 @@ static void nau8824_fll_apply(struct regmap *regmap,
} }
/* 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 nau8824_set_pll(struct snd_soc_codec *codec, int pll_id, int source, static int nau8824_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 nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
struct nau8824_fll fll_param; struct nau8824_fll fll_param;
int ret, fs; int ret, fs;
...@@ -1374,10 +1412,10 @@ static int nau8824_config_sysclk(struct nau8824 *nau8824, ...@@ -1374,10 +1412,10 @@ static int nau8824_config_sysclk(struct nau8824 *nau8824,
return 0; return 0;
} }
static int nau8824_set_sysclk(struct snd_soc_codec *codec, static int nau8824_set_sysclk(struct snd_soc_component *component,
int clk_id, int source, unsigned int freq, int dir) int clk_id, int source, unsigned int freq, int dir)
{ {
struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
return nau8824_config_sysclk(nau8824, clk_id, freq); return nau8824_config_sysclk(nau8824, clk_id, freq);
} }
...@@ -1403,10 +1441,10 @@ static void nau8824_resume_setup(struct nau8824 *nau8824) ...@@ -1403,10 +1441,10 @@ static void nau8824_resume_setup(struct nau8824 *nau8824)
} }
} }
static int nau8824_set_bias_level(struct snd_soc_codec *codec, static int nau8824_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
...@@ -1416,7 +1454,7 @@ static int nau8824_set_bias_level(struct snd_soc_codec *codec, ...@@ -1416,7 +1454,7 @@ static int nau8824_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) {
/* Setup codec configuration after resume */ /* Setup codec configuration after resume */
nau8824_resume_setup(nau8824); nau8824_resume_setup(nau8824);
} }
...@@ -1434,23 +1472,23 @@ static int nau8824_set_bias_level(struct snd_soc_codec *codec, ...@@ -1434,23 +1472,23 @@ static int nau8824_set_bias_level(struct snd_soc_codec *codec,
return 0; return 0;
} }
static int nau8824_codec_probe(struct snd_soc_codec *codec) static int nau8824_component_probe(struct snd_soc_component *component)
{ {
struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = 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);
nau8824->dapm = dapm; nau8824->dapm = dapm;
return 0; return 0;
} }
static int __maybe_unused nau8824_suspend(struct snd_soc_codec *codec) static int __maybe_unused nau8824_suspend(struct snd_soc_component *component)
{ {
struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
if (nau8824->irq) { if (nau8824->irq) {
disable_irq(nau8824->irq); disable_irq(nau8824->irq);
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
} }
regcache_cache_only(nau8824->regmap, true); regcache_cache_only(nau8824->regmap, true);
regcache_mark_dirty(nau8824->regmap); regcache_mark_dirty(nau8824->regmap);
...@@ -1458,9 +1496,9 @@ static int __maybe_unused nau8824_suspend(struct snd_soc_codec *codec) ...@@ -1458,9 +1496,9 @@ static int __maybe_unused nau8824_suspend(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int __maybe_unused nau8824_resume(struct snd_soc_codec *codec) static int __maybe_unused nau8824_resume(struct snd_soc_component *component)
{ {
struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
regcache_cache_only(nau8824->regmap, false); regcache_cache_only(nau8824->regmap, false);
regcache_sync(nau8824->regmap); regcache_sync(nau8824->regmap);
...@@ -1475,23 +1513,24 @@ static int __maybe_unused nau8824_resume(struct snd_soc_codec *codec) ...@@ -1475,23 +1513,24 @@ static int __maybe_unused nau8824_resume(struct snd_soc_codec *codec)
return 0; return 0;
} }
static const struct snd_soc_codec_driver nau8824_codec_driver = { static const struct snd_soc_component_driver nau8824_component_driver = {
.probe = nau8824_codec_probe, .probe = nau8824_component_probe,
.set_sysclk = nau8824_set_sysclk, .set_sysclk = nau8824_set_sysclk,
.set_pll = nau8824_set_pll, .set_pll = nau8824_set_pll,
.set_bias_level = nau8824_set_bias_level, .set_bias_level = nau8824_set_bias_level,
.suspend = nau8824_suspend, .suspend = nau8824_suspend,
.resume = nau8824_resume, .resume = nau8824_resume,
.suspend_bias_off = true, .controls = nau8824_snd_controls,
.num_controls = ARRAY_SIZE(nau8824_snd_controls),
.component_driver = { .dapm_widgets = nau8824_dapm_widgets,
.controls = nau8824_snd_controls, .num_dapm_widgets = ARRAY_SIZE(nau8824_dapm_widgets),
.num_controls = ARRAY_SIZE(nau8824_snd_controls), .dapm_routes = nau8824_dapm_routes,
.dapm_widgets = nau8824_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(nau8824_dapm_routes),
.num_dapm_widgets = ARRAY_SIZE(nau8824_dapm_widgets), .suspend_bias_off = 1,
.dapm_routes = nau8824_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(nau8824_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct snd_soc_dai_ops nau8824_dai_ops = { static const struct snd_soc_dai_ops nau8824_dai_ops = {
...@@ -1547,10 +1586,10 @@ static const struct regmap_config nau8824_regmap_config = { ...@@ -1547,10 +1586,10 @@ static const struct regmap_config nau8824_regmap_config = {
* 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 nau8824_enable_jack_detect(struct snd_soc_codec *codec, int nau8824_enable_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *jack) struct snd_soc_jack *jack)
{ {
struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
int ret; int ret;
nau8824->jack = jack; nau8824->jack = jack;
...@@ -1838,15 +1877,8 @@ static int nau8824_i2c_probe(struct i2c_client *i2c, ...@@ -1838,15 +1877,8 @@ static int nau8824_i2c_probe(struct i2c_client *i2c,
if (i2c->irq) if (i2c->irq)
nau8824_setup_irq(nau8824); nau8824_setup_irq(nau8824);
return snd_soc_register_codec(dev, return devm_snd_soc_register_component(dev,
&nau8824_codec_driver, &nau8824_dai, 1); &nau8824_component_driver, &nau8824_dai, 1);
}
static int nau8824_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
} }
static const struct i2c_device_id nau8824_i2c_ids[] = { static const struct i2c_device_id nau8824_i2c_ids[] = {
...@@ -1878,7 +1910,6 @@ static struct i2c_driver nau8824_i2c_driver = { ...@@ -1878,7 +1910,6 @@ static struct i2c_driver nau8824_i2c_driver = {
.acpi_match_table = ACPI_PTR(nau8824_acpi_match), .acpi_match_table = ACPI_PTR(nau8824_acpi_match),
}, },
.probe = nau8824_i2c_probe, .probe = nau8824_i2c_probe,
.remove = nau8824_i2c_remove,
.id_table = nau8824_i2c_ids, .id_table = nau8824_i2c_ids,
}; };
module_i2c_driver(nau8824_i2c_driver); module_i2c_driver(nau8824_i2c_driver);
......
...@@ -471,7 +471,7 @@ struct nau8824_osr_attr { ...@@ -471,7 +471,7 @@ struct nau8824_osr_attr {
}; };
int nau8824_enable_jack_detect(struct snd_soc_codec *codec, int nau8824_enable_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *jack); struct snd_soc_jack *jack);
#endif /* _NAU8824_H */ #endif /* _NAU8824_H */
......
...@@ -56,6 +56,9 @@ config SND_SOC_RK3288_HDMI_ANALOG ...@@ -56,6 +56,9 @@ config SND_SOC_RK3288_HDMI_ANALOG
depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP
select SND_SOC_ROCKCHIP_I2S select SND_SOC_ROCKCHIP_I2S
select SND_SOC_HDMI_CODEC select SND_SOC_HDMI_CODEC
select SND_SOC_ES8328_I2C
select SND_SOC_ES8328_SPI if SPI_MASTER
select DRM_DW_HDMI_I2S_AUDIO if DRM_DW_HDMI
help help
Say Y or M here if you want to add support for SoC audio on Rockchip Say Y or M here if you want to add support for SoC audio on Rockchip
RK3288 boards using an analog output and the built-in HDMI audio. RK3288 boards using an analog output and the built-in HDMI audio.
......
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