Commit 7ad2d1d5 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branch 'asoc/topic/rt5645' into asoc-next

parents aab0bb17 37322551
...@@ -1270,6 +1270,8 @@ static void hp_amp_power(struct snd_soc_codec *codec, int on) ...@@ -1270,6 +1270,8 @@ static void hp_amp_power(struct snd_soc_codec *codec, int on)
snd_soc_update_bits(codec, RT5645_PWR_ANLG1, snd_soc_update_bits(codec, RT5645_PWR_ANLG1,
RT5645_PWR_HP_L | RT5645_PWR_HP_R | RT5645_PWR_HP_L | RT5645_PWR_HP_R |
RT5645_PWR_HA, 0); RT5645_PWR_HA, 0);
snd_soc_update_bits(codec, RT5645_DEPOP_M2,
RT5645_DEPOP_MASK, 0);
} }
} }
} }
...@@ -1538,8 +1540,6 @@ static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = { ...@@ -1538,8 +1540,6 @@ static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = {
SND_SOC_DAPM_SUPPLY_S("adc stereo1 filter", 1, RT5645_PWR_DIG2, SND_SOC_DAPM_SUPPLY_S("adc stereo1 filter", 1, RT5645_PWR_DIG2,
RT5645_PWR_ADC_S1F_BIT, 0, NULL, 0), RT5645_PWR_ADC_S1F_BIT, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY_S("adc stereo2 filter", 1, RT5645_PWR_DIG2,
RT5645_PWR_ADC_S2F_BIT, 0, NULL, 0),
SND_SOC_DAPM_MIXER_E("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0, SND_SOC_DAPM_MIXER_E("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0,
rt5645_sto1_adc_l_mix, ARRAY_SIZE(rt5645_sto1_adc_l_mix), rt5645_sto1_adc_l_mix, ARRAY_SIZE(rt5645_sto1_adc_l_mix),
NULL, 0), NULL, 0),
...@@ -1729,7 +1729,6 @@ static const struct snd_soc_dapm_widget rt5650_specific_dapm_widgets[] = { ...@@ -1729,7 +1729,6 @@ static const struct snd_soc_dapm_widget rt5650_specific_dapm_widgets[] = {
static const struct snd_soc_dapm_route rt5645_dapm_routes[] = { static const struct snd_soc_dapm_route rt5645_dapm_routes[] = {
{ "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc }, { "adc stereo1 filter", NULL, "ADC STO1 ASRC", is_using_asrc },
{ "adc stereo2 filter", NULL, "ADC STO2 ASRC", is_using_asrc },
{ "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc }, { "adc mono left filter", NULL, "ADC MONO L ASRC", is_using_asrc },
{ "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc }, { "adc mono right filter", NULL, "ADC MONO R ASRC", is_using_asrc },
{ "dac mono left filter", NULL, "DAC MONO L ASRC", is_using_asrc }, { "dac mono left filter", NULL, "DAC MONO L ASRC", is_using_asrc },
...@@ -2052,7 +2051,7 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream, ...@@ -2052,7 +2051,7 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream,
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_codec *codec = dai->codec;
struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec);
unsigned int val_len = 0, val_clk, mask_clk; unsigned int val_len = 0, val_clk, mask_clk, dl_sft;
int pre_div, bclk_ms, frame_size; int pre_div, bclk_ms, frame_size;
rt5645->lrck[dai->id] = params_rate(params); rt5645->lrck[dai->id] = params_rate(params);
...@@ -2066,6 +2065,16 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream, ...@@ -2066,6 +2065,16 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream,
dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size);
return -EINVAL; return -EINVAL;
} }
switch (rt5645->codec_type) {
case CODEC_TYPE_RT5650:
dl_sft = 4;
break;
default:
dl_sft = 2;
break;
}
bclk_ms = frame_size > 32; bclk_ms = frame_size > 32;
rt5645->bclk[dai->id] = rt5645->lrck[dai->id] * (32 << bclk_ms); rt5645->bclk[dai->id] = rt5645->lrck[dai->id] * (32 << bclk_ms);
...@@ -2078,13 +2087,13 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream, ...@@ -2078,13 +2087,13 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream,
case 16: case 16:
break; break;
case 20: case 20:
val_len |= RT5645_I2S_DL_20; val_len = 0x1;
break; break;
case 24: case 24:
val_len |= RT5645_I2S_DL_24; val_len = 0x2;
break; break;
case 8: case 8:
val_len |= RT5645_I2S_DL_8; val_len = 0x3;
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -2096,7 +2105,7 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream, ...@@ -2096,7 +2105,7 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream,
val_clk = bclk_ms << RT5645_I2S_BCLK_MS1_SFT | val_clk = bclk_ms << RT5645_I2S_BCLK_MS1_SFT |
pre_div << RT5645_I2S_PD1_SFT; pre_div << RT5645_I2S_PD1_SFT;
snd_soc_update_bits(codec, RT5645_I2S1_SDP, snd_soc_update_bits(codec, RT5645_I2S1_SDP,
RT5645_I2S_DL_MASK, val_len); (0x3 << dl_sft), (val_len << dl_sft));
snd_soc_update_bits(codec, RT5645_ADDA_CLK1, mask_clk, val_clk); snd_soc_update_bits(codec, RT5645_ADDA_CLK1, mask_clk, val_clk);
break; break;
case RT5645_AIF2: case RT5645_AIF2:
...@@ -2104,7 +2113,7 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream, ...@@ -2104,7 +2113,7 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream,
val_clk = bclk_ms << RT5645_I2S_BCLK_MS2_SFT | val_clk = bclk_ms << RT5645_I2S_BCLK_MS2_SFT |
pre_div << RT5645_I2S_PD2_SFT; pre_div << RT5645_I2S_PD2_SFT;
snd_soc_update_bits(codec, RT5645_I2S2_SDP, snd_soc_update_bits(codec, RT5645_I2S2_SDP,
RT5645_I2S_DL_MASK, val_len); (0x3 << dl_sft), (val_len << dl_sft));
snd_soc_update_bits(codec, RT5645_ADDA_CLK1, mask_clk, val_clk); snd_soc_update_bits(codec, RT5645_ADDA_CLK1, mask_clk, val_clk);
break; break;
default: default:
...@@ -2119,7 +2128,16 @@ static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2119,7 +2128,16 @@ static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_codec *codec = dai->codec;
struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec);
unsigned int reg_val = 0; unsigned int reg_val = 0, pol_sft;
switch (rt5645->codec_type) {
case CODEC_TYPE_RT5650:
pol_sft = 8;
break;
default:
pol_sft = 7;
break;
}
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:
...@@ -2137,7 +2155,7 @@ static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2137,7 +2155,7 @@ static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
case SND_SOC_DAIFMT_NB_NF: case SND_SOC_DAIFMT_NB_NF:
break; break;
case SND_SOC_DAIFMT_IB_NF: case SND_SOC_DAIFMT_IB_NF:
reg_val |= RT5645_I2S_BP_INV; reg_val |= (1 << pol_sft);
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -2161,12 +2179,12 @@ static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2161,12 +2179,12 @@ static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
switch (dai->id) { switch (dai->id) {
case RT5645_AIF1: case RT5645_AIF1:
snd_soc_update_bits(codec, RT5645_I2S1_SDP, snd_soc_update_bits(codec, RT5645_I2S1_SDP,
RT5645_I2S_MS_MASK | RT5645_I2S_BP_MASK | RT5645_I2S_MS_MASK | (1 << pol_sft) |
RT5645_I2S_DF_MASK, reg_val); RT5645_I2S_DF_MASK, reg_val);
break; break;
case RT5645_AIF2: case RT5645_AIF2:
snd_soc_update_bits(codec, RT5645_I2S2_SDP, snd_soc_update_bits(codec, RT5645_I2S2_SDP,
RT5645_I2S_MS_MASK | RT5645_I2S_BP_MASK | RT5645_I2S_MS_MASK | (1 << pol_sft) |
RT5645_I2S_DF_MASK, reg_val); RT5645_I2S_DF_MASK, reg_val);
break; break;
default: default:
...@@ -2285,23 +2303,42 @@ static int rt5645_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, ...@@ -2285,23 +2303,42 @@ static int rt5645_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_codec *codec = dai->codec;
unsigned int val = 0; struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec);
unsigned int i_slot_sft, o_slot_sft, i_width_sht, o_width_sht, en_sft;
unsigned int mask, val = 0;
switch (rt5645->codec_type) {
case CODEC_TYPE_RT5650:
en_sft = 15;
i_slot_sft = 10;
o_slot_sft = 8;
i_width_sht = 6;
o_width_sht = 4;
mask = 0x8ff0;
break;
default:
en_sft = 14;
i_slot_sft = o_slot_sft = 12;
i_width_sht = o_width_sht = 10;
mask = 0x7c00;
break;
}
if (rx_mask || tx_mask) { if (rx_mask || tx_mask) {
val |= (1 << 14); val |= (1 << en_sft);
snd_soc_update_bits(codec, RT5645_BASS_BACK, if (rt5645->codec_type == CODEC_TYPE_RT5645)
RT5645_G_BB_BST_MASK, RT5645_G_BB_BST_25DB); snd_soc_update_bits(codec, RT5645_BASS_BACK,
RT5645_G_BB_BST_MASK, RT5645_G_BB_BST_25DB);
} }
switch (slots) { switch (slots) {
case 4: case 4:
val |= (1 << 12); val |= (1 << i_slot_sft) | (1 << o_slot_sft);
break; break;
case 6: case 6:
val |= (2 << 12); val |= (2 << i_slot_sft) | (2 << o_slot_sft);
break; break;
case 8: case 8:
val |= (3 << 12); val |= (3 << i_slot_sft) | (3 << o_slot_sft);
break; break;
case 2: case 2:
default: default:
...@@ -2310,20 +2347,20 @@ static int rt5645_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, ...@@ -2310,20 +2347,20 @@ static int rt5645_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
switch (slot_width) { switch (slot_width) {
case 20: case 20:
val |= (1 << 10); val |= (1 << i_width_sht) | (1 << o_width_sht);
break; break;
case 24: case 24:
val |= (2 << 10); val |= (2 << i_width_sht) | (2 << o_width_sht);
break; break;
case 32: case 32:
val |= (3 << 10); val |= (3 << i_width_sht) | (3 << o_width_sht);
break; break;
case 16: case 16:
default: default:
break; break;
} }
snd_soc_update_bits(codec, RT5645_TDM_CTRL_1, 0x7c00, val); snd_soc_update_bits(codec, RT5645_TDM_CTRL_1, mask, val);
return 0; return 0;
} }
...@@ -2361,7 +2398,8 @@ static int rt5645_set_bias_level(struct snd_soc_codec *codec, ...@@ -2361,7 +2398,8 @@ static int rt5645_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_write(codec, RT5645_DEPOP_M2, 0x1100); snd_soc_write(codec, RT5645_DEPOP_M2, 0x1100);
snd_soc_write(codec, RT5645_GEN_CTRL1, 0x0128); snd_soc_update_bits(codec, RT5645_GEN_CTRL1,
RT5645_DIG_GATE_CTRL, 0);
snd_soc_update_bits(codec, RT5645_PWR_ANLG1, snd_soc_update_bits(codec, RT5645_PWR_ANLG1,
RT5645_PWR_VREF1 | RT5645_PWR_MB | RT5645_PWR_VREF1 | RT5645_PWR_MB |
RT5645_PWR_BG | RT5645_PWR_VREF2 | RT5645_PWR_BG | RT5645_PWR_VREF2 |
...@@ -2598,7 +2636,7 @@ static struct snd_soc_codec_driver soc_codec_dev_rt5645 = { ...@@ -2598,7 +2636,7 @@ static struct snd_soc_codec_driver soc_codec_dev_rt5645 = {
static const struct regmap_config rt5645_regmap = { static const struct regmap_config rt5645_regmap = {
.reg_bits = 8, .reg_bits = 8,
.val_bits = 16, .val_bits = 16,
.use_single_rw = true,
.max_register = RT5645_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5645_ranges) * .max_register = RT5645_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5645_ranges) *
RT5645_PR_SPACING), RT5645_PR_SPACING),
.volatile_reg = rt5645_volatile_register, .volatile_reg = rt5645_volatile_register,
......
...@@ -804,8 +804,6 @@ ...@@ -804,8 +804,6 @@
#define RT5645_PWR_DAC_MF_L_BIT 10 #define RT5645_PWR_DAC_MF_L_BIT 10
#define RT5645_PWR_DAC_MF_R (0x1 << 9) #define RT5645_PWR_DAC_MF_R (0x1 << 9)
#define RT5645_PWR_DAC_MF_R_BIT 9 #define RT5645_PWR_DAC_MF_R_BIT 9
#define RT5645_PWR_ADC_S2F (0x1 << 8)
#define RT5645_PWR_ADC_S2F_BIT 8
#define RT5645_PWR_PDM1 (0x1 << 7) #define RT5645_PWR_PDM1 (0x1 << 7)
#define RT5645_PWR_PDM1_BIT 7 #define RT5645_PWR_PDM1_BIT 7
#define RT5645_PWR_PDM2 (0x1 << 6) #define RT5645_PWR_PDM2 (0x1 << 6)
......
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