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.
1024 lines
38 KiB
Diff
1024 lines
38 KiB
Diff
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 @@
|
|
#define CDC_A_REVISION4 (0xf103)
|
|
#define CDC_A_PERPH_TYPE (0xf104)
|
|
#define CDC_A_PERPH_SUBTYPE (0xf105)
|
|
+#define CDC_A_PERPH_SUBTYPE_CAJON 0x0a
|
|
#define CDC_A_INT_RT_STS (0xf110)
|
|
#define CDC_A_INT_SET_TYPE (0xf111)
|
|
#define CDC_A_INT_POLARITY_HIGH (0xf112)
|
|
@@ -220,20 +221,28 @@
|
|
#define CDC_A_RX_HPH_BIAS_LDO_OCP (0xf195)
|
|
#define CDC_A_RX_HPH_BIAS_CNP (0xf196)
|
|
#define CDC_A_RX_HPH_CNP_EN (0xf197)
|
|
+#define CDC_A_RX_HPH_CNP_EN_PU_MASK BIT(3)
|
|
+#define CDC_A_RX_HPH_L_TEST (0xf19A)
|
|
#define CDC_A_RX_HPH_L_PA_DAC_CTL (0xf19B)
|
|
#define RX_HPA_L_PA_DAC_CTL_DATA_RESET_MASK BIT(1)
|
|
#define RX_HPA_L_PA_DAC_CTL_DATA_RESET_RESET BIT(1)
|
|
+#define CDC_A_RX_HPH_R_TEST (0xf19C)
|
|
#define CDC_A_RX_HPH_R_PA_DAC_CTL (0xf19D)
|
|
#define RX_HPH_R_PA_DAC_CTL_DATA_RESET BIT(1)
|
|
#define RX_HPH_R_PA_DAC_CTL_DATA_RESET_MASK BIT(1)
|
|
+#define RX_HPH_TEST_PA_EN BIT(2)
|
|
+#define RX_HPH_TEST_CAJON_CFG BIT(7)
|
|
|
|
#define CDC_A_RX_EAR_CTL (0xf19E)
|
|
#define RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK BIT(0)
|
|
#define RX_EAR_CTL_SPK_VBAT_LDO_EN_ENABLE BIT(0)
|
|
+#define RX_EAR_CTL_PA_GAIN_POS_6_DB_MASK BIT(5)
|
|
+#define RX_EAR_CTL_PA_GAIN_POS_6_DB BIT(5)
|
|
#define RX_EAR_CTL_PA_EAR_PA_EN_MASK BIT(6)
|
|
#define RX_EAR_CTL_PA_EAR_PA_EN_ENABLE BIT(6)
|
|
#define RX_EAR_CTL_PA_SEL_MASK BIT(7)
|
|
#define RX_EAR_CTL_PA_SEL BIT(7)
|
|
+#define CDC_A_RX_EAR_STATUS (0xf1A1)
|
|
|
|
#define CDC_A_SPKR_DAC_CTL (0xf1B0)
|
|
#define SPKR_DAC_CTL_DAC_RESET_MASK BIT(4)
|
|
@@ -249,10 +258,13 @@
|
|
#define SPKR_DRV_BOOST_SET BIT(2)
|
|
#define SPKR_DRV_CMFB_SET BIT(1)
|
|
#define SPKR_DRV_GAIN_SET BIT(0)
|
|
+#define SPKR_DRV_CTL_NO_BOOST_VAL (SPKR_DRV_CAL_EN | SPKR_DRV_SETTLE_EN | \
|
|
+ SPKR_DRV_FW_EN | SPKR_DRV_GAIN_SET)
|
|
#define SPKR_DRV_CTL_DEF_VAL (SPKR_DRV_CLASSD_PA_EN_ENABLE | \
|
|
SPKR_DRV_CAL_EN | SPKR_DRV_SETTLE_EN | \
|
|
SPKR_DRV_FW_EN | SPKR_DRV_BOOST_SET | \
|
|
SPKR_DRV_CMFB_SET | SPKR_DRV_GAIN_SET)
|
|
+#define CDC_A_SPKR_ANA_BIAS_SET (0xf1B3)
|
|
#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 @@ struct pm8916_wcd_analog_priv {
|
|
bool audio_active;
|
|
bool jack_inserted;
|
|
bool s2_enabled;
|
|
+ bool is_cajon;
|
|
};
|
|
|
|
static const char *const adc2_mux_text[] = { "ZERO", "INP2", "INP3" };
|
|
@@ -435,6 +448,9 @@ static int pm8916_wcd_analog_enable_micbias2(struct snd_soc_dapm_widget *w,
|
|
|
|
}
|
|
|
|
+static void pm8916_wcd_analog_apply_defaults(struct snd_soc_component *component,
|
|
+ bool preserve_switch);
|
|
+
|
|
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 @@ static int pm8916_wcd_analog_update_power_locked(struct snd_soc_component *compo
|
|
if (!ret) {
|
|
priv->s2_enabled = true;
|
|
usleep_range(1000, 1500);
|
|
- snd_soc_component_write(component, CDC_A_MASTER_BIAS_CTL, 0x30);
|
|
+ if (priv->is_cajon)
|
|
+ pm8916_wcd_analog_apply_defaults(component, true);
|
|
+ else
|
|
+ snd_soc_component_write(component, CDC_A_MASTER_BIAS_CTL, 0x30);
|
|
} else {
|
|
dev_err(component->dev, "failed to enable vdd-cdc-tx-rx-cx (%d)\n", ret);
|
|
}
|
|
@@ -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);
|
|
+ struct pm8916_wcd_analog_priv *priv = snd_soc_component_get_drvdata(component);
|
|
|
|
switch (event) {
|
|
case SND_SOC_DAPM_PRE_PMU:
|
|
- snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL,
|
|
- SPKR_PWRSTG_CTL_DAC_EN_MASK |
|
|
- SPKR_PWRSTG_CTL_BBM_MASK |
|
|
- SPKR_PWRSTG_CTL_HBRDGE_EN_MASK |
|
|
- SPKR_PWRSTG_CTL_CLAMP_EN_MASK,
|
|
- SPKR_PWRSTG_CTL_DAC_EN|
|
|
- SPKR_PWRSTG_CTL_BBM_EN |
|
|
- SPKR_PWRSTG_CTL_HBRDGE_EN |
|
|
- SPKR_PWRSTG_CTL_CLAMP_EN);
|
|
+ if (priv->is_cajon) {
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL,
|
|
+ SPKR_PWRSTG_CTL_DAC_EN_MASK,
|
|
+ SPKR_PWRSTG_CTL_DAC_EN);
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_DAC_CTL,
|
|
+ SPKR_DAC_CTL_DAC_RESET_MASK,
|
|
+ SPKR_DAC_CTL_DAC_RESET_MASK);
|
|
+ usleep_range(1000, 1100);
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL,
|
|
+ SPKR_PWRSTG_CTL_MASK,
|
|
+ SPKR_PWRSTG_CTL_BBM_EN |
|
|
+ SPKR_PWRSTG_CTL_HBRDGE_EN |
|
|
+ SPKR_PWRSTG_CTL_CLAMP_EN);
|
|
+ } else {
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL,
|
|
+ SPKR_PWRSTG_CTL_DAC_EN_MASK |
|
|
+ SPKR_PWRSTG_CTL_BBM_MASK |
|
|
+ SPKR_PWRSTG_CTL_HBRDGE_EN_MASK |
|
|
+ SPKR_PWRSTG_CTL_CLAMP_EN_MASK,
|
|
+ SPKR_PWRSTG_CTL_DAC_EN |
|
|
+ SPKR_PWRSTG_CTL_BBM_EN |
|
|
+ SPKR_PWRSTG_CTL_HBRDGE_EN |
|
|
+ SPKR_PWRSTG_CTL_CLAMP_EN);
|
|
+ }
|
|
|
|
snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
|
|
RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK,
|
|
RX_EAR_CTL_SPK_VBAT_LDO_EN_ENABLE);
|
|
break;
|
|
case SND_SOC_DAPM_POST_PMU:
|
|
- snd_soc_component_update_bits(component, CDC_A_SPKR_DRV_CTL,
|
|
- SPKR_DRV_CTL_DEF_MASK,
|
|
- SPKR_DRV_CTL_DEF_VAL);
|
|
+ if (priv->is_cajon) {
|
|
+ usleep_range(1000, 1100);
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_DAC_CTL,
|
|
+ SPKR_DAC_CTL_DAC_RESET_MASK,
|
|
+ SPKR_DAC_CTL_DAC_RESET_NORMAL);
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_DRV_CTL,
|
|
+ SPKR_DRV_CTL_DEF_MASK &
|
|
+ ~SPKR_DRV_CLASSD_PA_EN_MASK,
|
|
+ SPKR_DRV_CTL_NO_BOOST_VAL);
|
|
+ } else {
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_DRV_CTL,
|
|
+ SPKR_DRV_CTL_DEF_MASK,
|
|
+ SPKR_DRV_CTL_DEF_VAL);
|
|
+ }
|
|
snd_soc_component_update_bits(component, w->reg,
|
|
SPKR_DRV_CLASSD_PA_EN_MASK,
|
|
SPKR_DRV_CLASSD_PA_EN_ENABLE);
|
|
break;
|
|
+ case SND_SOC_DAPM_PRE_PMD:
|
|
+ if (priv->is_cajon) {
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_DAC_CTL,
|
|
+ SPKR_DAC_CTL_DAC_RESET_MASK,
|
|
+ SPKR_DAC_CTL_DAC_RESET_MASK);
|
|
+ snd_soc_component_update_bits(component, w->reg,
|
|
+ SPKR_DRV_CLASSD_PA_EN_MASK, 0);
|
|
+ }
|
|
+ break;
|
|
case SND_SOC_DAPM_POST_PMD:
|
|
- snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL,
|
|
- SPKR_PWRSTG_CTL_DAC_EN_MASK|
|
|
- SPKR_PWRSTG_CTL_BBM_MASK |
|
|
- SPKR_PWRSTG_CTL_HBRDGE_EN_MASK |
|
|
- SPKR_PWRSTG_CTL_CLAMP_EN_MASK, 0);
|
|
+ if (priv->is_cajon) {
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL,
|
|
+ SPKR_PWRSTG_CTL_MASK, 0);
|
|
+ usleep_range(1000, 1100);
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL,
|
|
+ SPKR_PWRSTG_CTL_DAC_EN_MASK, 0);
|
|
+ } else {
|
|
+ snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL,
|
|
+ SPKR_PWRSTG_CTL_DAC_EN_MASK |
|
|
+ SPKR_PWRSTG_CTL_BBM_MASK |
|
|
+ SPKR_PWRSTG_CTL_HBRDGE_EN_MASK |
|
|
+ SPKR_PWRSTG_CTL_CLAMP_EN_MASK, 0);
|
|
+ }
|
|
|
|
snd_soc_component_update_bits(component, CDC_A_SPKR_DAC_CTL,
|
|
SPKR_DAC_CTL_DAC_RESET_MASK,
|
|
@@ -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);
|
|
+ struct pm8916_wcd_analog_priv *priv = snd_soc_component_get_drvdata(component);
|
|
|
|
switch (event) {
|
|
case SND_SOC_DAPM_PRE_PMU:
|
|
snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
|
|
- RX_EAR_CTL_PA_SEL_MASK, RX_EAR_CTL_PA_SEL);
|
|
+ RX_EAR_CTL_PA_SEL_MASK |
|
|
+ (priv->is_cajon ? RX_EAR_CTL_PA_GAIN_POS_6_DB_MASK : 0),
|
|
+ RX_EAR_CTL_PA_SEL |
|
|
+ (priv->is_cajon ? RX_EAR_CTL_PA_GAIN_POS_6_DB : 0));
|
|
break;
|
|
case SND_SOC_DAPM_POST_PMU:
|
|
snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
|
|
@@ -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,
|
|
- RX_EAR_CTL_PA_SEL_MASK, 0);
|
|
+ RX_EAR_CTL_PA_SEL_MASK |
|
|
+ (priv->is_cajon ? RX_EAR_CTL_PA_GAIN_POS_6_DB_MASK : 0),
|
|
+ 0);
|
|
+ break;
|
|
+ }
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int pm8916_wcd_analog_enable_hphl_dac(struct snd_soc_dapm_widget *w,
|
|
+ struct snd_kcontrol *kcontrol,
|
|
+ int event)
|
|
+{
|
|
+ struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
|
+ struct pm8916_wcd_analog_priv *priv = snd_soc_component_get_drvdata(component);
|
|
+
|
|
+ switch (event) {
|
|
+ case SND_SOC_DAPM_PRE_PMU:
|
|
+ if (priv->is_cajon) {
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_HPH_CNP_EN,
|
|
+ CDC_A_RX_HPH_CNP_EN_PU_MASK,
|
|
+ CDC_A_RX_HPH_CNP_EN_PU_MASK);
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_HPH_L_TEST,
|
|
+ RX_HPH_TEST_CAJON_CFG,
|
|
+ RX_HPH_TEST_CAJON_CFG);
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_HPH_R_TEST,
|
|
+ RX_HPH_TEST_CAJON_CFG,
|
|
+ RX_HPH_TEST_CAJON_CFG);
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_HPH_CNP_EN,
|
|
+ CDC_A_RX_HPH_CNP_EN_PU_MASK, 0);
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
|
|
+ RX_EAR_CTL_PA_GAIN_POS_6_DB_MASK,
|
|
+ RX_EAR_CTL_PA_GAIN_POS_6_DB);
|
|
+ snd_soc_component_update_bits(component, CDC_A_NCP_VCTRL,
|
|
+ 0x07, 0x07);
|
|
+ }
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_HPH_L_PA_DAC_CTL,
|
|
+ RX_HPA_L_PA_DAC_CTL_DATA_RESET_MASK,
|
|
+ RX_HPA_L_PA_DAC_CTL_DATA_RESET_RESET);
|
|
+ break;
|
|
+ case SND_SOC_DAPM_POST_PMU:
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_HPH_L_PA_DAC_CTL,
|
|
+ RX_HPA_L_PA_DAC_CTL_DATA_RESET_MASK, 0);
|
|
+ break;
|
|
+ case SND_SOC_DAPM_POST_PMD:
|
|
+ if (priv->is_cajon) {
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
|
|
+ RX_EAR_CTL_PA_GAIN_POS_6_DB_MASK, 0);
|
|
+ snd_soc_component_update_bits(component, CDC_A_NCP_VCTRL,
|
|
+ 0x07, 0x04);
|
|
+ }
|
|
+ break;
|
|
+ }
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int pm8916_wcd_analog_enable_hphr_dac(struct snd_soc_dapm_widget *w,
|
|
+ struct snd_kcontrol *kcontrol,
|
|
+ int event)
|
|
+{
|
|
+ struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
|
+
|
|
+ switch (event) {
|
|
+ case SND_SOC_DAPM_PRE_PMU:
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_HPH_R_PA_DAC_CTL,
|
|
+ RX_HPH_R_PA_DAC_CTL_DATA_RESET_MASK,
|
|
+ RX_HPH_R_PA_DAC_CTL_DATA_RESET);
|
|
+ break;
|
|
+ case SND_SOC_DAPM_POST_PMU:
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_HPH_R_PA_DAC_CTL,
|
|
+ RX_HPH_R_PA_DAC_CTL_DATA_RESET_MASK, 0);
|
|
+ break;
|
|
+ }
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int pm8916_wcd_analog_enable_hph_pa(struct snd_soc_dapm_widget *w,
|
|
+ struct snd_kcontrol *kcontrol,
|
|
+ int event)
|
|
+{
|
|
+ struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
|
+ struct pm8916_wcd_analog_priv *priv = snd_soc_component_get_drvdata(component);
|
|
+ unsigned int test_reg = (w->shift == 5) ? CDC_A_RX_HPH_L_TEST : CDC_A_RX_HPH_R_TEST;
|
|
+
|
|
+ if (!priv->is_cajon)
|
|
+ return 0;
|
|
+
|
|
+ switch (event) {
|
|
+ case SND_SOC_DAPM_PRE_PMU:
|
|
+ snd_soc_component_update_bits(component, CDC_A_NCP_FBCTRL,
|
|
+ CDC_A_NCP_FBCTRL_FB_CLK_INV_MASK,
|
|
+ CDC_A_NCP_FBCTRL_FB_CLK_INV);
|
|
+ break;
|
|
+ case SND_SOC_DAPM_POST_PMU:
|
|
+ usleep_range(7000, 7100);
|
|
+ snd_soc_component_update_bits(component, test_reg,
|
|
+ RX_HPH_TEST_PA_EN,
|
|
+ RX_HPH_TEST_PA_EN);
|
|
+ break;
|
|
+ case SND_SOC_DAPM_PRE_PMD:
|
|
+ snd_soc_component_update_bits(component, test_reg,
|
|
+ RX_HPH_TEST_PA_EN, 0);
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_HPH_BIAS_CNP,
|
|
+ 0xF0, 0x30);
|
|
+ break;
|
|
+ case SND_SOC_DAPM_POST_PMD:
|
|
+ snd_soc_component_update_bits(component, CDC_A_RX_HPH_BIAS_CNP,
|
|
+ 0xF0, 0x20);
|
|
+ usleep_range(5000, 5200);
|
|
break;
|
|
}
|
|
return 0;
|
|
@@ -787,10 +961,59 @@ static const struct reg_default wcd_reg_defaults_2_0[] = {
|
|
{CDC_A_MASTER_BIAS_CTL, 0x30},
|
|
};
|
|
|
|
+static const struct reg_default wcd_reg_defaults_cajon_2_0[] = {
|
|
+ {CDC_A_RX_COM_OCP_CTL, 0xD1},
|
|
+ {CDC_A_RX_COM_OCP_COUNT, 0xFF},
|
|
+ {CDC_D_SEC_ACCESS, 0xA5},
|
|
+ {CDC_D_PERPH_RESET_CTL3, 0x0F},
|
|
+ {CDC_A_SEC_ACCESS, 0xA5},
|
|
+ {CDC_A_PERPH_RESET_CTL3, 0x0F},
|
|
+ {CDC_A_TX_1_2_OPAMP_BIAS, 0x4C},
|
|
+ {CDC_A_NCP_FBCTRL, 0xA8},
|
|
+ {CDC_A_NCP_VCTRL, 0xA4},
|
|
+ {CDC_A_RX_HPH_BIAS_PA, 0xFA},
|
|
+ {CDC_A_SPKR_ANA_BIAS_SET, 0x41},
|
|
+ {CDC_A_SPKR_DRV_CTL, 0x69},
|
|
+ {CDC_A_SPKR_DRV_DBG, 0x01},
|
|
+ {CDC_A_SPKR_OCP_CTL, 0xE1},
|
|
+ {CDC_A_SPKR_DAC_CTL, 0x03},
|
|
+ {CDC_A_RX_EAR_STATUS, 0x10},
|
|
+ {CDC_A_MASTER_BIAS_CTL, 0x30},
|
|
+};
|
|
+
|
|
+static void pm8916_wcd_analog_apply_defaults(struct snd_soc_component *component,
|
|
+ bool preserve_switch)
|
|
+{
|
|
+ struct pm8916_wcd_analog_priv *priv = snd_soc_component_get_drvdata(component);
|
|
+ const struct reg_default *defs = priv->is_cajon ?
|
|
+ wcd_reg_defaults_cajon_2_0 : wcd_reg_defaults_2_0;
|
|
+ size_t count = priv->is_cajon ?
|
|
+ ARRAY_SIZE(wcd_reg_defaults_cajon_2_0) :
|
|
+ ARRAY_SIZE(wcd_reg_defaults_2_0);
|
|
+ size_t i;
|
|
+
|
|
+ for (i = 0; i < count; i++) {
|
|
+ if (preserve_switch && defs[i].reg == CDC_A_SPKR_DAC_CTL) {
|
|
+ snd_soc_component_update_bits(component, defs[i].reg,
|
|
+ 0x7F, defs[i].def & 0x7F);
|
|
+ } else if (preserve_switch && defs[i].reg == CDC_A_SPKR_DRV_CTL) {
|
|
+ snd_soc_component_update_bits(component, defs[i].reg,
|
|
+ SPKR_DRV_CTL_DEF_MASK &
|
|
+ ~SPKR_DRV_CLASSD_PA_EN_MASK &
|
|
+ ~SPKR_DRV_CAL_EN,
|
|
+ defs[i].def &
|
|
+ ~SPKR_DRV_CLASSD_PA_EN_MASK &
|
|
+ ~SPKR_DRV_CAL_EN);
|
|
+ } else {
|
|
+ snd_soc_component_write(component, defs[i].reg, defs[i].def);
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
static int pm8916_wcd_analog_probe(struct snd_soc_component *component)
|
|
{
|
|
struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(component->dev);
|
|
- int err, reg;
|
|
+ int err;
|
|
|
|
err = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
|
if (err != 0) {
|
|
@@ -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);
|
|
+ priv->is_cajon = (snd_soc_component_read(component, CDC_A_PERPH_SUBTYPE) ==
|
|
+ CDC_A_PERPH_SUBTYPE_CAJON);
|
|
|
|
- dev_info(component->dev, "PMIC REV: %d\t CODEC Version: %d\n",
|
|
- priv->pmic_rev, priv->codec_version);
|
|
+ dev_info(component->dev, "PMIC REV: %d\t CODEC Version: %d%s\n",
|
|
+ priv->pmic_rev, priv->codec_version,
|
|
+ priv->is_cajon ? " (CAJON)" : "");
|
|
|
|
snd_soc_component_write(component, CDC_D_PERPH_RESET_CTL4, 0x01);
|
|
snd_soc_component_write(component, CDC_A_PERPH_RESET_CTL4, 0x01);
|
|
|
|
- for (reg = 0; reg < ARRAY_SIZE(wcd_reg_defaults_2_0); reg++)
|
|
- snd_soc_component_write(component, wcd_reg_defaults_2_0[reg].reg,
|
|
- wcd_reg_defaults_2_0[reg].def);
|
|
+ pm8916_wcd_analog_apply_defaults(component, false);
|
|
|
|
priv->component = component;
|
|
|
|
@@ -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),
|
|
|
|
- SND_SOC_DAPM_PGA("HPHL PA", CDC_A_RX_HPH_CNP_EN, 5, 0, NULL, 0),
|
|
+ SND_SOC_DAPM_PGA_E("HPHL PA", CDC_A_RX_HPH_CNP_EN,
|
|
+ 5, 0, NULL, 0,
|
|
+ pm8916_wcd_analog_enable_hph_pa,
|
|
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
|
|
+ SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
|
|
SND_SOC_DAPM_MUX("HPHL", SND_SOC_NOPM, 0, 0, &hphl_mux),
|
|
- SND_SOC_DAPM_MIXER("HPHL DAC", CDC_A_RX_HPH_L_PA_DAC_CTL, 3, 0, NULL,
|
|
- 0),
|
|
- SND_SOC_DAPM_PGA("HPHR PA", CDC_A_RX_HPH_CNP_EN, 4, 0, NULL, 0),
|
|
+ SND_SOC_DAPM_MIXER_E("HPHL DAC", CDC_A_RX_HPH_L_PA_DAC_CTL,
|
|
+ 3, 0, NULL, 0,
|
|
+ pm8916_wcd_analog_enable_hphl_dac,
|
|
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
|
|
+ SND_SOC_DAPM_POST_PMD),
|
|
+ SND_SOC_DAPM_PGA_E("HPHR PA", CDC_A_RX_HPH_CNP_EN,
|
|
+ 4, 0, NULL, 0,
|
|
+ pm8916_wcd_analog_enable_hph_pa,
|
|
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
|
|
+ SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
|
|
SND_SOC_DAPM_MUX("HPHR", SND_SOC_NOPM, 0, 0, &hphr_mux),
|
|
- SND_SOC_DAPM_MIXER("HPHR DAC", CDC_A_RX_HPH_R_PA_DAC_CTL, 3, 0, NULL,
|
|
- 0),
|
|
+ SND_SOC_DAPM_MIXER_E("HPHR DAC", CDC_A_RX_HPH_R_PA_DAC_CTL,
|
|
+ 3, 0, NULL, 0,
|
|
+ pm8916_wcd_analog_enable_hphr_dac,
|
|
+ SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
|
|
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 @@
|
|
#define LPASS_CDC_RX1_B5_CTL (0x050)
|
|
#define LPASS_CDC_RX2_B5_CTL (0x070)
|
|
#define LPASS_CDC_RX3_B5_CTL (0x090)
|
|
+#define RXn_B5_CTL_INTERP_FS_RATE_MASK GENMASK(7, 5)
|
|
+#define RXn_B5_CTL_INTERP_FS_RATE_SHIFT 5
|
|
+#define RXn_B5_CTL_INTERP_HALFBAND_EN BIT(3)
|
|
#define LPASS_CDC_RX1_B6_CTL (0x054)
|
|
#define RXn_B6_CTL_MUTE_MASK BIT(0)
|
|
#define RXn_B6_CTL_MUTE_ENABLE BIT(0)
|
|
@@ -172,6 +175,7 @@
|
|
#define LPASS_CDC_TX2_MUX_CTL (0x2AC)
|
|
#define LPASS_CDC_TX1_CLK_FS_CTL (0x290)
|
|
#define LPASS_CDC_TX2_CLK_FS_CTL (0x2B0)
|
|
+#define TXn_CLK_FS_CTL_FS_RATE_MASK GENMASK(2, 0)
|
|
#define LPASS_CDC_TX1_DMIC_CTL (0x294)
|
|
#define LPASS_CDC_TX2_DMIC_CTL (0x2B4)
|
|
#define TXN_DMIC_CTL_CLK_SEL_MASK GENMASK(2, 0)
|
|
@@ -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);
|
|
+ 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);
|
|
+ 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;
|
|
@@ -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, 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, 0x00 },
|
|
+ { LPASS_CDC_CLK_RX_B1_CTL, 0x00 },
|
|
+ { LPASS_CDC_CLK_MCLK_CTL, 0x00 },
|
|
+ { LPASS_CDC_CLK_PDM_CTL, 0x00 },
|
|
+ { LPASS_CDC_CLK_SD_CTL, 0x00 },
|
|
+ { LPASS_CDC_RX1_B1_CTL, 0x00 },
|
|
+ { LPASS_CDC_RX1_B2_CTL, 0x00 },
|
|
+ { LPASS_CDC_RX1_B3_CTL, 0x00 },
|
|
+ { LPASS_CDC_RX1_B4_CTL, 0x00 },
|
|
+ { 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 },
|
|
+ { LPASS_CDC_RX2_B1_CTL, 0x00 },
|
|
+ { LPASS_CDC_RX2_B2_CTL, 0x00 },
|
|
+ { LPASS_CDC_RX2_B3_CTL, 0x00 },
|
|
+ { LPASS_CDC_RX2_B4_CTL, 0x00 },
|
|
+ { 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 },
|
|
+ { LPASS_CDC_RX3_B1_CTL, 0x00 },
|
|
+ { LPASS_CDC_RX3_B2_CTL, 0x00 },
|
|
+ { LPASS_CDC_RX3_B3_CTL, 0x00 },
|
|
+ { LPASS_CDC_RX3_B4_CTL, 0x00 },
|
|
+ { 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, 0x00 },
|
|
+ { LPASS_CDC_DEBUG_DESER1_CTL, 0x00 },
|
|
+ { LPASS_CDC_DEBUG_DESER2_CTL, 0x00 },
|
|
+ { LPASS_CDC_DEBUG_B1_CTL_CFG, 0x00 },
|
|
+ { LPASS_CDC_DEBUG_B2_CTL_CFG, 0x00 },
|
|
+ { LPASS_CDC_DEBUG_B3_CTL_CFG, 0x00 },
|
|
+ { LPASS_CDC_IIR1_GAIN_B1_CTL, 0x00 },
|
|
+ { LPASS_CDC_IIR1_GAIN_B2_CTL, 0x00 },
|
|
+ { LPASS_CDC_IIR1_GAIN_B3_CTL, 0x00 },
|
|
+ { LPASS_CDC_IIR1_GAIN_B4_CTL, 0x00 },
|
|
+ { LPASS_CDC_IIR1_GAIN_B5_CTL, 0x00 },
|
|
+ { 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, 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 },
|
|
+ { LPASS_CDC_IIR2_GAIN_B4_CTL, 0x00 },
|
|
+ { LPASS_CDC_IIR2_GAIN_B5_CTL, 0x00 },
|
|
+ { 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, 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 },
|
|
+ { LPASS_CDC_CONN_RX2_B1_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_RX2_B2_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_RX2_B3_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_RX3_B1_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_RX3_B2_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_TX_B1_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_EQ1_B1_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_EQ1_B2_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_EQ1_B3_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_EQ1_B4_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_EQ2_B1_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_EQ2_B2_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_EQ2_B3_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_EQ2_B4_CTL, 0x00 },
|
|
+ { LPASS_CDC_CONN_TX_I2S_SD1_CTL, 0x00 },
|
|
+ { LPASS_CDC_TX1_VOL_CTL_TIMER, 0x00 },
|
|
+ { 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, 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, 0x00 },
|
|
+ { LPASS_CDC_TX2_DMIC_CTL, 0x00 },
|
|
+};
|
|
+
|
|
+static bool msm8916_wcd_digital_valid_reg(struct device *dev, unsigned int reg)
|
|
+{
|
|
+ switch (reg) {
|
|
+ case LPASS_CDC_CLK_RX_RESET_CTL ... LPASS_CDC_CLK_SD_CTL:
|
|
+ case LPASS_CDC_RX1_B1_CTL ... LPASS_CDC_RX1_VOL_CTL_B2_CTL:
|
|
+ case LPASS_CDC_RX2_B1_CTL ... LPASS_CDC_RX2_VOL_CTL_B2_CTL:
|
|
+ case LPASS_CDC_RX3_B1_CTL ... LPASS_CDC_TOP_CTL:
|
|
+ case LPASS_CDC_DEBUG_DESER1_CTL ... LPASS_CDC_DEBUG_B3_CTL_CFG:
|
|
+ case LPASS_CDC_IIR1_GAIN_B1_CTL ... LPASS_CDC_IIR1_COEF_B2_CTL:
|
|
+ case LPASS_CDC_IIR2_GAIN_B1_CTL ... LPASS_CDC_IIR2_COEF_B2_CTL:
|
|
+ case LPASS_CDC_CONN_RX1_B1_CTL ... LPASS_CDC_CONN_TX_B1_CTL:
|
|
+ case LPASS_CDC_CONN_EQ1_B1_CTL ... LPASS_CDC_CONN_TX_I2S_SD1_CTL:
|
|
+ case LPASS_CDC_TX1_VOL_CTL_TIMER ... LPASS_CDC_TX1_DMIC_CTL:
|
|
+ case LPASS_CDC_TX2_VOL_CTL_TIMER ... LPASS_CDC_TX2_DMIC_CTL:
|
|
+ return true;
|
|
+ default:
|
|
+ return false;
|
|
+ }
|
|
+}
|
|
+
|
|
static const struct regmap_config msm8916_codec_regmap_config = {
|
|
.reg_bits = 32,
|
|
.reg_stride = 4,
|
|
.val_bits = 32,
|
|
.max_register = LPASS_CDC_TX2_DMIC_CTL,
|
|
+ .readable_reg = msm8916_wcd_digital_valid_reg,
|
|
+ .writeable_reg = msm8916_wcd_digital_valid_reg,
|
|
+ .reg_defaults = msm8916_wcd_digital_reg_defaults,
|
|
+ .num_reg_defaults = ARRAY_SIZE(msm8916_wcd_digital_reg_defaults),
|
|
.cache_type = REGCACHE_FLAT,
|
|
};
|
|
|
|
@@ -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;
|
|
- unsigned int reg, val;
|
|
int ret;
|
|
|
|
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
|
@@ -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_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);
|