Fix MSM8905 WCD 48 kHz interpolators, ADSP clock retention, and boot audio sync
Ensure LPASS_CDC_RX1/2/3_B5_CTL and TX1/2_CLK_FS_CTL are always reprogrammed for 48 kHz on MSM8905 (Q6_ADSP_VERSION_2_6) targets (nokia-beatles, nokia-argon, nokia-coconut), preserve INT_DIGITAL_CDC_CLK on ADSP < 2.7, eliminate unclocked debugfs AHB reads, harden PipeWire boot sink/unity sync, and update rebuilt a1125 (ampere) image checksums.
This commit is contained in:
1 parent
4f73c28e5e
commit
aba38a58f2
21 files changed
+568
-104
No files matched your search
@@ -1,3 +1,5 @@
|
||||
diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
|
||||
index 257f780..457b552 100644
|
||||
--- a/sound/soc/codecs/msm8916-wcd-analog.c
|
||||
+++ b/sound/soc/codecs/msm8916-wcd-analog.c
|
||||
@@ -82,6 +82,7 @@
|
||||
@@ -51,7 +53,7 @@
|
||||
#define CDC_A_SPKR_OCP_CTL (0xf1B4)
|
||||
#define CDC_A_SPKR_PWRSTG_CTL (0xf1B5)
|
||||
#define SPKR_PWRSTG_CTL_DAC_EN_MASK BIT(0)
|
||||
@@ -314,6 +326,7 @@
|
||||
@@ -314,6 +326,7 @@ struct pm8916_wcd_analog_priv {
|
||||
bool audio_active;
|
||||
bool jack_inserted;
|
||||
bool s2_enabled;
|
||||
@@ -59,7 +61,7 @@
|
||||
};
|
||||
|
||||
static const char *const adc2_mux_text[] = { "ZERO", "INP2", "INP3" };
|
||||
@@ -435,6 +448,9 @@
|
||||
@@ -435,6 +448,9 @@ static int pm8916_wcd_analog_enable_micbias2(struct snd_soc_dapm_widget *w,
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +71,7 @@
|
||||
static int pm8916_wcd_analog_update_power_locked(struct snd_soc_component *component)
|
||||
{
|
||||
struct pm8916_wcd_analog_priv *priv = snd_soc_component_get_drvdata(component);
|
||||
@@ -446,7 +462,10 @@
|
||||
@@ -446,7 +462,10 @@ static int pm8916_wcd_analog_update_power_locked(struct snd_soc_component *compo
|
||||
if (!ret) {
|
||||
priv->s2_enabled = true;
|
||||
usleep_range(1000, 1500);
|
||||
@@ -81,7 +83,7 @@
|
||||
} else {
|
||||
dev_err(component->dev, "failed to enable vdd-cdc-tx-rx-cx (%d)\n", ret);
|
||||
}
|
||||
@@ -698,37 +717,81 @@
|
||||
@@ -698,37 +717,81 @@ static int pm8916_wcd_analog_enable_spk_pa(struct snd_soc_dapm_widget *w,
|
||||
int event)
|
||||
{
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
@@ -180,7 +182,7 @@
|
||||
|
||||
snd_soc_component_update_bits(component, CDC_A_SPKR_DAC_CTL,
|
||||
SPKR_DAC_CTL_DAC_RESET_MASK,
|
||||
@@ -745,11 +808,15 @@
|
||||
@@ -745,11 +808,15 @@ static int pm8916_wcd_analog_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
||||
int event)
|
||||
{
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
@@ -197,7 +199,7 @@
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
|
||||
@@ -762,7 +829,114 @@
|
||||
@@ -762,7 +829,114 @@ static int pm8916_wcd_analog_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
||||
/* Delay to reduce ear turn off pop */
|
||||
usleep_range(7000, 7100);
|
||||
snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
|
||||
@@ -313,7 +315,7 @@
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@@ -787,10 +961,59 @@
|
||||
@@ -787,10 +961,59 @@ static const struct reg_default wcd_reg_defaults_2_0[] = {
|
||||
{CDC_A_MASTER_BIAS_CTL, 0x30},
|
||||
};
|
||||
|
||||
@@ -374,7 +376,7 @@
|
||||
|
||||
err = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
||||
if (err != 0) {
|
||||
@@ -806,16 +1029,17 @@
|
||||
@@ -806,16 +1029,17 @@ static int pm8916_wcd_analog_probe(struct snd_soc_component *component)
|
||||
snd_soc_component_set_drvdata(component, priv);
|
||||
priv->pmic_rev = snd_soc_component_read(component, CDC_D_REVISION1);
|
||||
priv->codec_version = snd_soc_component_read(component, CDC_D_PERPH_SUBTYPE);
|
||||
@@ -397,7 +399,7 @@
|
||||
|
||||
priv->component = component;
|
||||
|
||||
@@ -981,14 +1205,27 @@
|
||||
@@ -981,14 +1205,27 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_MUX("EAR_S", SND_SOC_NOPM, 0, 0, &ear_mux),
|
||||
SND_SOC_DAPM_SUPPLY("EAR CP", CDC_A_NCP_EN, 4, 0, NULL, 0),
|
||||
|
||||
@@ -431,6 +433,8 @@
|
||||
SND_SOC_DAPM_MIXER("SPK DAC", SND_SOC_NOPM, 0, 0,
|
||||
spkr_switch, ARRAY_SIZE(spkr_switch)),
|
||||
|
||||
diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c
|
||||
index 81d1134..fc2520e 100644
|
||||
--- a/sound/soc/codecs/msm8916-wcd-digital.c
|
||||
+++ b/sound/soc/codecs/msm8916-wcd-digital.c
|
||||
@@ -85,6 +85,9 @@
|
||||
@@ -451,46 +455,261 @@
|
||||
#define LPASS_CDC_TX1_DMIC_CTL (0x294)
|
||||
#define LPASS_CDC_TX2_DMIC_CTL (0x2B4)
|
||||
#define TXN_DMIC_CTL_CLK_SEL_MASK GENMASK(2, 0)
|
||||
@@ -895,10 +899,29 @@
|
||||
@@ -236,6 +240,12 @@ static const unsigned long rx_gain_reg[] = {
|
||||
LPASS_CDC_RX3_VOL_CTL_B2_CTL,
|
||||
};
|
||||
|
||||
+static const unsigned long rx_b5_reg[] = {
|
||||
+ LPASS_CDC_RX1_B5_CTL,
|
||||
+ LPASS_CDC_RX2_B5_CTL,
|
||||
+ LPASS_CDC_RX3_B5_CTL,
|
||||
+};
|
||||
+
|
||||
static const unsigned long tx_gain_reg[] = {
|
||||
LPASS_CDC_TX1_VOL_CTL_GAIN,
|
||||
LPASS_CDC_TX2_VOL_CTL_GAIN,
|
||||
@@ -580,19 +590,26 @@ static int msm8916_wcd_digital_enable_interpolator(
|
||||
int event)
|
||||
{
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
+ struct msm8916_wcd_digital_priv *priv = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (event) {
|
||||
+ case SND_SOC_DAPM_PRE_PMU:
|
||||
+ regmap_write_bits(priv->regmap, rx_b5_reg[w->shift], ~0U,
|
||||
+ snd_soc_component_read(component, rx_b5_reg[w->shift]));
|
||||
+ break;
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
/* apply the digital gain after the interpolator is enabled */
|
||||
usleep_range(10000, 10100);
|
||||
+ regmap_write_bits(priv->regmap, rx_b5_reg[w->shift], ~0U,
|
||||
+ snd_soc_component_read(component, rx_b5_reg[w->shift]));
|
||||
snd_soc_component_write(component, rx_gain_reg[w->shift],
|
||||
snd_soc_component_read(component, rx_gain_reg[w->shift]));
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
- snd_soc_component_update_bits(component, LPASS_CDC_CLK_RX_RESET_CTL,
|
||||
- 1 << w->shift, 1 << w->shift);
|
||||
- snd_soc_component_update_bits(component, LPASS_CDC_CLK_RX_RESET_CTL,
|
||||
- 1 << w->shift, 0x0);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_CLK_RX_RESET_CTL,
|
||||
+ BIT(w->shift), BIT(w->shift));
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_CLK_RX_RESET_CTL,
|
||||
+ BIT(w->shift), 0);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@@ -603,6 +620,7 @@ static int msm8916_wcd_digital_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
int event)
|
||||
{
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
+ struct msm8916_wcd_digital_priv *priv = snd_soc_component_get_drvdata(component);
|
||||
unsigned int decimator = w->shift + 1;
|
||||
u16 dec_reset_reg, tx_vol_ctl_reg, tx_mux_ctl_reg;
|
||||
u8 dec_hpf_cut_of_freq;
|
||||
@@ -647,9 +665,9 @@ static int msm8916_wcd_digital_enable_dec(struct snd_soc_dapm_widget *w,
|
||||
TX_MUX_CTL_HPF_BP_SEL_BYPASS);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
- snd_soc_component_update_bits(component, dec_reset_reg, 1 << w->shift,
|
||||
- 1 << w->shift);
|
||||
- snd_soc_component_update_bits(component, dec_reset_reg, 1 << w->shift, 0x0);
|
||||
+ regmap_write_bits(priv->regmap, dec_reset_reg, BIT(w->shift),
|
||||
+ BIT(w->shift));
|
||||
+ regmap_write_bits(priv->regmap, dec_reset_reg, BIT(w->shift), 0);
|
||||
snd_soc_component_update_bits(component, tx_mux_ctl_reg,
|
||||
TX_MUX_CTL_HPF_BP_SEL_MASK,
|
||||
TX_MUX_CTL_HPF_BP_SEL_BYPASS);
|
||||
@@ -741,13 +759,16 @@ static const struct snd_soc_dapm_widget msm8916_wcd_digital_dapm_widgets[] = {
|
||||
/* Interpolator */
|
||||
SND_SOC_DAPM_MIXER_E("RX1 INT", LPASS_CDC_CLK_RX_B1_CTL, 0, 0, NULL,
|
||||
0, msm8916_wcd_digital_enable_interpolator,
|
||||
- SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
|
||||
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
|
||||
+ SND_SOC_DAPM_POST_PMD),
|
||||
SND_SOC_DAPM_MIXER_E("RX2 INT", LPASS_CDC_CLK_RX_B1_CTL, 1, 0, NULL,
|
||||
0, msm8916_wcd_digital_enable_interpolator,
|
||||
- SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
|
||||
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
|
||||
+ SND_SOC_DAPM_POST_PMD),
|
||||
SND_SOC_DAPM_MIXER_E("RX3 INT", LPASS_CDC_CLK_RX_B1_CTL, 2, 0, NULL,
|
||||
0, msm8916_wcd_digital_enable_interpolator,
|
||||
- SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
|
||||
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
|
||||
+ SND_SOC_DAPM_POST_PMD),
|
||||
SND_SOC_DAPM_MUX("RX1 MIX1 INP1", SND_SOC_NOPM, 0, 0,
|
||||
&rx_mix1_inp1_mux),
|
||||
SND_SOC_DAPM_MUX("RX1 MIX1 INP2", SND_SOC_NOPM, 0, 0,
|
||||
@@ -865,6 +886,7 @@ static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
+ struct msm8916_wcd_digital_priv *priv = snd_soc_component_get_drvdata(dai->component);
|
||||
u8 tx_fs_rate;
|
||||
u8 rx_fs_rate;
|
||||
|
||||
@@ -893,12 +915,31 @@ static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
switch (substream->stream) {
|
||||
case SNDRV_PCM_STREAM_CAPTURE:
|
||||
snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_TX_I2S_CTL,
|
||||
TX_I2S_CTL_TX_I2S_FS_RATE_MASK, tx_fs_rate);
|
||||
+ snd_soc_component_update_bits(dai->component, LPASS_CDC_TX1_CLK_FS_CTL,
|
||||
+ TXn_CLK_FS_CTL_FS_RATE_MASK, tx_fs_rate);
|
||||
+ snd_soc_component_update_bits(dai->component, LPASS_CDC_TX2_CLK_FS_CTL,
|
||||
+ TXn_CLK_FS_CTL_FS_RATE_MASK, tx_fs_rate);
|
||||
- snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_TX_I2S_CTL,
|
||||
- TX_I2S_CTL_TX_I2S_FS_RATE_MASK, tx_fs_rate);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_CLK_TX_I2S_CTL,
|
||||
+ TX_I2S_CTL_TX_I2S_FS_RATE_MASK, tx_fs_rate);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_TX1_CLK_FS_CTL,
|
||||
+ TXn_CLK_FS_CTL_FS_RATE_MASK, tx_fs_rate);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_TX2_CLK_FS_CTL,
|
||||
+ TXn_CLK_FS_CTL_FS_RATE_MASK, tx_fs_rate);
|
||||
break;
|
||||
case SNDRV_PCM_STREAM_PLAYBACK:
|
||||
snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_RX_I2S_CTL,
|
||||
RX_I2S_CTL_RX_I2S_FS_RATE_MASK, rx_fs_rate);
|
||||
+ snd_soc_component_update_bits(dai->component, LPASS_CDC_RX1_B5_CTL,
|
||||
+ RXn_B5_CTL_INTERP_FS_RATE_MASK |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN,
|
||||
+ (rx_fs_rate << RXn_B5_CTL_INTERP_FS_RATE_SHIFT) |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN);
|
||||
+ snd_soc_component_update_bits(dai->component, LPASS_CDC_RX2_B5_CTL,
|
||||
+ RXn_B5_CTL_INTERP_FS_RATE_MASK |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN,
|
||||
+ (rx_fs_rate << RXn_B5_CTL_INTERP_FS_RATE_SHIFT) |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN);
|
||||
+ snd_soc_component_update_bits(dai->component, LPASS_CDC_RX3_B5_CTL,
|
||||
+ RXn_B5_CTL_INTERP_FS_RATE_MASK |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN,
|
||||
+ (rx_fs_rate << RXn_B5_CTL_INTERP_FS_RATE_SHIFT) |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN);
|
||||
- snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_RX_I2S_CTL,
|
||||
- RX_I2S_CTL_RX_I2S_FS_RATE_MASK, rx_fs_rate);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_CLK_RX_I2S_CTL,
|
||||
+ RX_I2S_CTL_RX_I2S_FS_RATE_MASK, rx_fs_rate);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_RX1_B5_CTL,
|
||||
+ RXn_B5_CTL_INTERP_FS_RATE_MASK |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN,
|
||||
+ (rx_fs_rate << RXn_B5_CTL_INTERP_FS_RATE_SHIFT) |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_RX2_B5_CTL,
|
||||
+ RXn_B5_CTL_INTERP_FS_RATE_MASK |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN,
|
||||
+ (rx_fs_rate << RXn_B5_CTL_INTERP_FS_RATE_SHIFT) |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_RX3_B5_CTL,
|
||||
+ RXn_B5_CTL_INTERP_FS_RATE_MASK |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN,
|
||||
+ (rx_fs_rate << RXn_B5_CTL_INTERP_FS_RATE_SHIFT) |
|
||||
+ RXn_B5_CTL_INTERP_HALFBAND_EN);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
@@ -1159,11 +1182,145 @@
|
||||
@@ -906,21 +947,21 @@ static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
switch (params_format(params)) {
|
||||
case SNDRV_PCM_FORMAT_S16_LE:
|
||||
- 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_16);
|
||||
- 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_16);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_CLK_TX_I2S_CTL,
|
||||
+ TX_I2S_CTL_TX_I2S_MODE_MASK,
|
||||
+ TX_I2S_CTL_TX_I2S_MODE_16);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_CLK_RX_I2S_CTL,
|
||||
+ RX_I2S_CTL_RX_I2S_MODE_MASK,
|
||||
+ RX_I2S_CTL_RX_I2S_MODE_16);
|
||||
break;
|
||||
|
||||
case SNDRV_PCM_FORMAT_S32_LE:
|
||||
- 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_32);
|
||||
- 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_32);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_CLK_TX_I2S_CTL,
|
||||
+ TX_I2S_CTL_TX_I2S_MODE_MASK,
|
||||
+ TX_I2S_CTL_TX_I2S_MODE_32);
|
||||
+ regmap_write_bits(priv->regmap, LPASS_CDC_CLK_RX_I2S_CTL,
|
||||
+ RX_I2S_CTL_RX_I2S_MODE_MASK,
|
||||
+ RX_I2S_CTL_RX_I2S_MODE_32);
|
||||
break;
|
||||
default:
|
||||
dev_err(dai->dev, "%s: wrong format selected\n", __func__);
|
||||
@@ -1071,6 +1112,30 @@ static const struct snd_soc_dapm_route msm8916_wcd_digital_audio_map[] = {
|
||||
|
||||
};
|
||||
|
||||
+static void msm8916_wcd_digital_force_sync_ctl(struct regmap *map)
|
||||
+{
|
||||
+ static const unsigned int ctl_regs[] = {
|
||||
+ LPASS_CDC_CLK_RX_I2S_CTL,
|
||||
+ LPASS_CDC_CLK_TX_I2S_CTL,
|
||||
+ LPASS_CDC_CLK_OTHR_CTL,
|
||||
+ LPASS_CDC_RX1_B5_CTL,
|
||||
+ LPASS_CDC_RX2_B5_CTL,
|
||||
+ LPASS_CDC_RX3_B5_CTL,
|
||||
+ LPASS_CDC_TOP_CTL,
|
||||
+ LPASS_CDC_IIR1_CTL,
|
||||
+ LPASS_CDC_IIR2_CTL,
|
||||
+ LPASS_CDC_TX1_CLK_FS_CTL,
|
||||
+ LPASS_CDC_TX2_CLK_FS_CTL,
|
||||
+ };
|
||||
+ unsigned int val;
|
||||
+ size_t i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(ctl_regs); i++) {
|
||||
+ if (regmap_read(map, ctl_regs[i], &val) == 0)
|
||||
+ regmap_write_bits(map, ctl_regs[i], ~0U, val);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int msm8916_wcd_digital_startup(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
@@ -1079,29 +1144,30 @@ static int msm8916_wcd_digital_startup(struct snd_pcm_substream *substream,
|
||||
unsigned long mclk_rate;
|
||||
|
||||
msm8916_wcd = snd_soc_component_get_drvdata(component);
|
||||
- snd_soc_component_update_bits(component, LPASS_CDC_CLK_MCLK_CTL,
|
||||
- MCLK_CTL_MCLK_EN_MASK,
|
||||
- MCLK_CTL_MCLK_EN_ENABLE);
|
||||
- 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_FB);
|
||||
+ regmap_write_bits(msm8916_wcd->regmap, LPASS_CDC_CLK_MCLK_CTL,
|
||||
+ MCLK_CTL_MCLK_EN_MASK,
|
||||
+ MCLK_CTL_MCLK_EN_ENABLE);
|
||||
+ regmap_write_bits(msm8916_wcd->regmap, LPASS_CDC_CLK_PDM_CTL,
|
||||
+ LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_MASK,
|
||||
+ LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_FB);
|
||||
|
||||
mclk_rate = clk_get_rate(msm8916_wcd->mclk);
|
||||
switch (mclk_rate) {
|
||||
case 12288000:
|
||||
- snd_soc_component_update_bits(component, LPASS_CDC_TOP_CTL,
|
||||
- TOP_CTL_DIG_MCLK_FREQ_MASK,
|
||||
- TOP_CTL_DIG_MCLK_FREQ_F_12_288MHZ);
|
||||
+ regmap_write_bits(msm8916_wcd->regmap, LPASS_CDC_TOP_CTL,
|
||||
+ TOP_CTL_DIG_MCLK_FREQ_MASK,
|
||||
+ TOP_CTL_DIG_MCLK_FREQ_F_12_288MHZ);
|
||||
break;
|
||||
case 9600000:
|
||||
- snd_soc_component_update_bits(component, LPASS_CDC_TOP_CTL,
|
||||
- TOP_CTL_DIG_MCLK_FREQ_MASK,
|
||||
- TOP_CTL_DIG_MCLK_FREQ_F_9_6MHZ);
|
||||
+ regmap_write_bits(msm8916_wcd->regmap, LPASS_CDC_TOP_CTL,
|
||||
+ TOP_CTL_DIG_MCLK_FREQ_MASK,
|
||||
+ TOP_CTL_DIG_MCLK_FREQ_F_9_6MHZ);
|
||||
break;
|
||||
default:
|
||||
dev_err(component->dev, "Invalid mclk rate %ld\n", mclk_rate);
|
||||
break;
|
||||
}
|
||||
+ msm8916_wcd_digital_force_sync_ctl(msm8916_wcd->regmap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1155,15 +1221,139 @@ static const struct snd_soc_component_driver msm8916_wcd_digital = {
|
||||
.dapm_routes = msm8916_wcd_digital_audio_map,
|
||||
.num_dapm_routes = ARRAY_SIZE(msm8916_wcd_digital_audio_map),
|
||||
.idle_bias_on = 0,
|
||||
- .use_pmdown_time = 1,
|
||||
+ .use_pmdown_time = 0,
|
||||
.endianness = 1,
|
||||
};
|
||||
|
||||
+static const struct reg_default msm8916_wcd_digital_reg_defaults[] = {
|
||||
+ { LPASS_CDC_CLK_RX_RESET_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CLK_TX_RESET_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CLK_DMIC_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CLK_RX_I2S_CTL, 0x13 },
|
||||
+ { LPASS_CDC_CLK_TX_I2S_CTL, 0x13 },
|
||||
+ { LPASS_CDC_CLK_RX_I2S_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CLK_TX_I2S_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CLK_OTHR_RESET_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CLK_TX_CLK_EN_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CLK_OTHR_CTL, 0x04 },
|
||||
+ { LPASS_CDC_CLK_OTHR_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CLK_RX_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CLK_MCLK_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CLK_PDM_CTL, 0x00 },
|
||||
@@ -499,7 +718,7 @@
|
||||
+ { LPASS_CDC_RX1_B2_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX1_B3_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX1_B4_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX1_B5_CTL, 0x68 },
|
||||
+ { LPASS_CDC_RX1_B5_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX1_B6_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX1_VOL_CTL_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX1_VOL_CTL_B2_CTL, 0x00 },
|
||||
@@ -507,7 +726,7 @@
|
||||
+ { LPASS_CDC_RX2_B2_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX2_B3_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX2_B4_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX2_B5_CTL, 0x68 },
|
||||
+ { LPASS_CDC_RX2_B5_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX2_B6_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX2_VOL_CTL_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX2_VOL_CTL_B2_CTL, 0x00 },
|
||||
@@ -515,12 +734,12 @@
|
||||
+ { LPASS_CDC_RX3_B2_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX3_B3_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX3_B4_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX3_B5_CTL, 0x68 },
|
||||
+ { LPASS_CDC_RX3_B5_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX3_B6_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX3_VOL_CTL_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_RX3_VOL_CTL_B2_CTL, 0x00 },
|
||||
+ { LPASS_CDC_TOP_GAIN_UPDATE, 0x00 },
|
||||
+ { LPASS_CDC_TOP_CTL, 0x01 },
|
||||
+ { LPASS_CDC_TOP_CTL, 0x00 },
|
||||
+ { LPASS_CDC_DEBUG_DESER1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_DEBUG_DESER2_CTL, 0x00 },
|
||||
+ { LPASS_CDC_DEBUG_B1_CTL_CFG, 0x00 },
|
||||
@@ -534,8 +753,10 @@
|
||||
+ { LPASS_CDC_IIR1_GAIN_B6_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR1_GAIN_B7_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR1_GAIN_B8_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR1_CTL, 0x40 },
|
||||
+ { LPASS_CDC_IIR1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR1_GAIN_TIMER_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR1_COEF_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR1_COEF_B2_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR2_GAIN_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR2_GAIN_B2_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR2_GAIN_B3_CTL, 0x00 },
|
||||
@@ -544,8 +765,10 @@
|
||||
+ { LPASS_CDC_IIR2_GAIN_B6_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR2_GAIN_B7_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR2_GAIN_B8_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR2_CTL, 0x40 },
|
||||
+ { LPASS_CDC_IIR2_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR2_GAIN_TIMER_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR2_COEF_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_IIR2_COEF_B2_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CONN_RX1_B1_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CONN_RX1_B2_CTL, 0x00 },
|
||||
+ { LPASS_CDC_CONN_RX1_B3_CTL, 0x00 },
|
||||
@@ -568,13 +791,13 @@
|
||||
+ { LPASS_CDC_TX1_VOL_CTL_GAIN, 0x00 },
|
||||
+ { LPASS_CDC_TX1_VOL_CTL_CFG, 0x00 },
|
||||
+ { LPASS_CDC_TX1_MUX_CTL, 0x00 },
|
||||
+ { LPASS_CDC_TX1_CLK_FS_CTL, 0x03 },
|
||||
+ { LPASS_CDC_TX1_CLK_FS_CTL, 0x00 },
|
||||
+ { LPASS_CDC_TX1_DMIC_CTL, 0x00 },
|
||||
+ { LPASS_CDC_TX2_VOL_CTL_TIMER, 0x00 },
|
||||
+ { LPASS_CDC_TX2_VOL_CTL_GAIN, 0x00 },
|
||||
+ { LPASS_CDC_TX2_VOL_CTL_CFG, 0x00 },
|
||||
+ { LPASS_CDC_TX2_MUX_CTL, 0x00 },
|
||||
+ { LPASS_CDC_TX2_CLK_FS_CTL, 0x03 },
|
||||
+ { LPASS_CDC_TX2_CLK_FS_CTL, 0x00 },
|
||||
+ { LPASS_CDC_TX2_DMIC_CTL, 0x00 },
|
||||
+};
|
||||
+
|
||||
@@ -597,22 +820,6 @@
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static bool msm8916_wcd_digital_volatile_reg(struct device *dev, unsigned int reg)
|
||||
+{
|
||||
+ switch (reg) {
|
||||
+ case LPASS_CDC_CLK_RX_RESET_CTL:
|
||||
+ case LPASS_CDC_CLK_TX_RESET_B1_CTL:
|
||||
+ case LPASS_CDC_CLK_OTHR_RESET_B1_CTL:
|
||||
+ case LPASS_CDC_IIR1_COEF_B1_CTL:
|
||||
+ case LPASS_CDC_IIR1_COEF_B2_CTL:
|
||||
+ case LPASS_CDC_IIR2_COEF_B1_CTL:
|
||||
+ case LPASS_CDC_IIR2_COEF_B2_CTL:
|
||||
+ return true;
|
||||
+ default:
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static const struct regmap_config msm8916_codec_regmap_config = {
|
||||
.reg_bits = 32,
|
||||
@@ -621,13 +828,25 @@
|
||||
.max_register = LPASS_CDC_TX2_DMIC_CTL,
|
||||
+ .readable_reg = msm8916_wcd_digital_valid_reg,
|
||||
+ .writeable_reg = msm8916_wcd_digital_valid_reg,
|
||||
+ .volatile_reg = msm8916_wcd_digital_volatile_reg,
|
||||
+ .reg_defaults = msm8916_wcd_digital_reg_defaults,
|
||||
+ .num_reg_defaults = ARRAY_SIZE(msm8916_wcd_digital_reg_defaults),
|
||||
.cache_type = REGCACHE_FLAT,
|
||||
};
|
||||
|
||||
@@ -1209,7 +1366,6 @@
|
||||
@@ -1195,7 +1385,11 @@ static int msm8916_wcd_digital_runtime_resume(struct device *dev)
|
||||
}
|
||||
|
||||
regcache_cache_only(priv->regmap, false);
|
||||
- return regcache_sync(priv->regmap);
|
||||
+ ret = regcache_sync(priv->regmap);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ msm8916_wcd_digital_force_sync_ctl(priv->regmap);
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops msm8916_wcd_digital_pm_ops = {
|
||||
@@ -1209,7 +1403,6 @@ static int msm8916_wcd_digital_probe(struct platform_device *pdev)
|
||||
struct device *dev = &pdev->dev;
|
||||
void __iomem *base;
|
||||
struct regmap *digital_map;
|
||||
@@ -635,20 +854,170 @@
|
||||
int ret;
|
||||
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
@@ -1244,7 +1400,14 @@
|
||||
@@ -1244,8 +1437,17 @@ static int msm8916_wcd_digital_probe(struct platform_device *pdev)
|
||||
goto err_clk;
|
||||
}
|
||||
|
||||
- for (reg = 0; reg <= LPASS_CDC_TX2_DMIC_CTL; reg += 4)
|
||||
- regmap_read(digital_map, reg, &val);
|
||||
+ regmap_write(digital_map, LPASS_CDC_CLK_OTHR_CTL, 0x04);
|
||||
+ regmap_write(digital_map, LPASS_CDC_RX1_B5_CTL, 0x68);
|
||||
+ regmap_write(digital_map, LPASS_CDC_RX2_B5_CTL, 0x68);
|
||||
+ regmap_write(digital_map, LPASS_CDC_RX3_B5_CTL, 0x68);
|
||||
+ regmap_write(digital_map, LPASS_CDC_TOP_CTL, 0x01);
|
||||
+ regmap_write(digital_map, LPASS_CDC_IIR1_CTL, 0x40);
|
||||
+ regmap_write(digital_map, LPASS_CDC_IIR2_CTL, 0x40);
|
||||
+ regmap_write(digital_map, LPASS_CDC_TX1_CLK_FS_CTL, 0x03);
|
||||
+ regmap_write(digital_map, LPASS_CDC_TX2_CLK_FS_CTL, 0x03);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_CLK_RX_I2S_CTL, ~0U, 0x13);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_CLK_TX_I2S_CTL, ~0U, 0x13);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_CLK_OTHR_CTL, ~0U, 0x04);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_RX1_B5_CTL, ~0U, 0x68);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_RX2_B5_CTL, ~0U, 0x68);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_RX3_B5_CTL, ~0U, 0x68);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_TOP_CTL, ~0U, 0x01);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_IIR1_CTL, ~0U, 0x40);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_IIR2_CTL, ~0U, 0x40);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_TX1_CLK_FS_CTL, ~0U, 0x03);
|
||||
+ regmap_write_bits(digital_map, LPASS_CDC_TX2_CLK_FS_CTL, ~0U, 0x03);
|
||||
|
||||
dev_set_drvdata(dev, priv);
|
||||
|
||||
diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
|
||||
index a5b0c48..08f6b28 100644
|
||||
--- a/sound/soc/qcom/qdsp6/q6afe.c
|
||||
+++ b/sound/soc/qcom/qdsp6/q6afe.c
|
||||
@@ -373,6 +373,7 @@ struct q6afe {
|
||||
wait_queue_head_t wait;
|
||||
struct list_head port_list;
|
||||
spinlock_t port_list_lock;
|
||||
+ unsigned int digital_cdc_clk_freq;
|
||||
};
|
||||
|
||||
struct afe_port_cmd_device_start {
|
||||
@@ -1032,13 +1033,12 @@ static int q6afe_port_set_param(struct q6afe_port *port, void *data,
|
||||
}
|
||||
|
||||
static int q6afe_set_param_v2(struct q6afe *afe, struct q6afe_port *port,
|
||||
- void *data, int param_id, int module_id, int psize,
|
||||
- int token)
|
||||
+ u16 port_id, void *data, int param_id,
|
||||
+ int module_id, int psize, int token)
|
||||
{
|
||||
struct afe_port_cmd_set_param_v2 *param;
|
||||
struct afe_port_param_data_v2 *pdata;
|
||||
struct apr_pkt *pkt;
|
||||
- u16 port_id = port ? port->id : 0;
|
||||
int ret, pkt_size;
|
||||
void *p, *pl;
|
||||
|
||||
@@ -1083,8 +1083,8 @@ static int q6afe_set_param_v2(struct q6afe *afe, struct q6afe_port *port,
|
||||
static int q6afe_port_set_param_v2(struct q6afe_port *port, void *data,
|
||||
int param_id, int module_id, int psize)
|
||||
{
|
||||
- return q6afe_set_param_v2(port->afe, port, data, param_id, module_id,
|
||||
- psize, port->token);
|
||||
+ return q6afe_set_param_v2(port->afe, port, port->id, data, param_id,
|
||||
+ module_id, psize, port->token);
|
||||
}
|
||||
|
||||
static int q6afe_port_set_lpass_clock(struct q6afe_port *port,
|
||||
@@ -1120,6 +1120,7 @@ int q6afe_set_lpass_clock(struct device *dev, int clk_id, int attri,
|
||||
|
||||
if (q6core_get_adsp_version() < Q6_ADSP_VERSION_2_7) {
|
||||
struct afe_digital_clk_cfg dcfg = {0,};
|
||||
+ int ret;
|
||||
|
||||
switch (clk_id) {
|
||||
/*
|
||||
@@ -1130,11 +1131,18 @@ int q6afe_set_lpass_clock(struct device *dev, int clk_id, int attri,
|
||||
dcfg.i2s_cfg_minor_version = AFE_API_VERSION_I2S_CONFIG;
|
||||
dcfg.clk_val = freq;
|
||||
dcfg.clk_root = 5;
|
||||
- return q6afe_set_param_v2(afe, NULL, &dcfg,
|
||||
- AFE_PARAM_ID_INT_DIGITAL_CDC_CLK_CONFIG,
|
||||
- AFE_MODULE_AUDIO_DEV_INTERFACE,
|
||||
- sizeof(dcfg),
|
||||
- AFE_CLK_TOKEN);
|
||||
+ if (freq == 0)
|
||||
+ afe->digital_cdc_clk_freq = 0;
|
||||
+ ret = q6afe_set_param_v2(afe, NULL,
|
||||
+ AFE_PORT_ID_PRIMARY_MI2S_RX,
|
||||
+ &dcfg,
|
||||
+ AFE_PARAM_ID_INT_DIGITAL_CDC_CLK_CONFIG,
|
||||
+ AFE_MODULE_AUDIO_DEV_INTERFACE,
|
||||
+ sizeof(dcfg),
|
||||
+ AFE_CLK_TOKEN);
|
||||
+ if (!ret && freq > 0)
|
||||
+ afe->digital_cdc_clk_freq = freq;
|
||||
+ return ret;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1254,6 +1262,27 @@ int q6afe_port_stop(struct q6afe_port *port)
|
||||
dev_err(afe->dev, "AFE close failed %d\n", ret);
|
||||
|
||||
kfree(pkt);
|
||||
+ if (!ret && port_id == AFE_PORT_ID_PRIMARY_MI2S_RX &&
|
||||
+ q6core_get_adsp_version() < Q6_ADSP_VERSION_2_7 &&
|
||||
+ afe->digital_cdc_clk_freq > 0) {
|
||||
+ struct afe_digital_clk_cfg dcfg = {0,};
|
||||
+ int clk_ret;
|
||||
+
|
||||
+ dcfg.i2s_cfg_minor_version = AFE_API_VERSION_I2S_CONFIG;
|
||||
+ dcfg.clk_val = afe->digital_cdc_clk_freq;
|
||||
+ dcfg.clk_root = 5;
|
||||
+ clk_ret = q6afe_set_param_v2(afe, NULL,
|
||||
+ AFE_PORT_ID_PRIMARY_MI2S_RX,
|
||||
+ &dcfg,
|
||||
+ AFE_PARAM_ID_INT_DIGITAL_CDC_CLK_CONFIG,
|
||||
+ AFE_MODULE_AUDIO_DEV_INTERFACE,
|
||||
+ sizeof(dcfg),
|
||||
+ AFE_CLK_TOKEN);
|
||||
+ if (clk_ret)
|
||||
+ dev_warn(afe->dev,
|
||||
+ "Failed to retain digital codec clk after PRI_MI2S_RX stop (%d)\n",
|
||||
+ clk_ret);
|
||||
+ }
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(q6afe_port_stop);
|
||||
diff --git a/sound/soc/qcom/qdsp6/q6core.c b/sound/soc/qcom/qdsp6/q6core.c
|
||||
index 855ab4f..7200330 100644
|
||||
--- a/sound/soc/qcom/qdsp6/q6core.c
|
||||
+++ b/sound/soc/qcom/qdsp6/q6core.c
|
||||
@@ -275,6 +275,18 @@ static bool __q6core_is_adsp_ready(struct q6core *core)
|
||||
return false;
|
||||
}
|
||||
|
||||
+static void q6core_query_versions_locked(struct q6core *core)
|
||||
+{
|
||||
+ if (core->is_version_requested)
|
||||
+ return;
|
||||
+
|
||||
+ if (q6core_get_fwk_versions(core) || !core->fwk_version_supported)
|
||||
+ q6core_get_svc_versions(core);
|
||||
+
|
||||
+ if (core->adsp_version != Q6_ADSP_VERSION_UNKNOWN)
|
||||
+ core->is_version_requested = true;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* q6core_get_svc_api_info() - Get version number of a service.
|
||||
*
|
||||
@@ -292,11 +304,7 @@ int q6core_get_svc_api_info(int svc_id, struct q6core_svc_api_info *ainfo)
|
||||
return 0;
|
||||
|
||||
mutex_lock(&g_core->lock);
|
||||
- if (!g_core->is_version_requested) {
|
||||
- if (q6core_get_fwk_versions(g_core) == -ENOTSUPP)
|
||||
- q6core_get_svc_versions(g_core);
|
||||
- g_core->is_version_requested = true;
|
||||
- }
|
||||
+ q6core_query_versions_locked(g_core);
|
||||
|
||||
if (g_core->fwk_version_supported) {
|
||||
for (i = 0; i < g_core->fwk_version->num_services; i++) {
|
||||
@@ -345,10 +353,6 @@ enum q6core_version q6core_get_adsp_version(void)
|
||||
return Q6_ADSP_VERSION_UNKNOWN;
|
||||
|
||||
mutex_lock(&g_core->lock);
|
||||
- if (!g_core->is_version_requested) {
|
||||
- if (q6core_get_fwk_versions(g_core) == -ENOTSUPP)
|
||||
- q6core_get_svc_versions(g_core);
|
||||
- g_core->is_version_requested = true;
|
||||
- }
|
||||
+ q6core_query_versions_locked(g_core);
|
||||
ret = g_core->adsp_version;
|
||||
mutex_unlock(&g_core->lock);
|
||||
Reference in new issue
Block a user