summaryrefslogtreecommitdiff
path: root/asoc
diff options
context:
space:
mode:
authorqctecmdr <qctecmdr@localhost>2020-08-04 23:06:56 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2020-08-04 23:06:56 -0700
commitd9d35c27d72a2db21384615af079adcca4f87b36 (patch)
tree7eb9f5c7ea0821c1da4f3772b9c4965b07f49cce /asoc
parent73d67e6681986f909635149355c532b93936fd41 (diff)
parent4b3e523207e04954ff8c49082f9772ddb2edf37f (diff)
downloadmsm-extra-d9d35c27d72a2db21384615af079adcca4f87b36.tar.gz
Merge "ASoC: rouleur: Update hph registers based on foundry id"
Diffstat (limited to 'asoc')
-rw-r--r--asoc/codecs/bolero/bolero-cdc.c12
-rw-r--r--asoc/codecs/bolero/bolero-cdc.h2
-rw-r--r--asoc/codecs/bolero/internal.h2
-rw-r--r--asoc/codecs/bolero/rx-macro.c10
-rw-r--r--asoc/codecs/rouleur/internal.h5
-rw-r--r--asoc/codecs/rouleur/pm2250-spmi.h5
-rw-r--r--asoc/codecs/rouleur/pm2250_spmi.c34
-rw-r--r--asoc/codecs/rouleur/rouleur.c55
8 files changed, 125 insertions, 0 deletions
diff --git a/asoc/codecs/bolero/bolero-cdc.c b/asoc/codecs/bolero/bolero-cdc.c
index 173343ca..53c70fab 100644
--- a/asoc/codecs/bolero/bolero-cdc.c
+++ b/asoc/codecs/bolero/bolero-cdc.c
@@ -238,6 +238,18 @@ static int bolero_cdc_update_wcd_event(void *handle, u16 event, u32 data)
priv->component,
BOLERO_MACRO_EVT_RX_PA_GAIN_UPDATE, data);
break;
+ case WCD_BOLERO_EVT_HPHL_HD2_ENABLE:
+ if (priv->macro_params[RX_MACRO].event_handler)
+ priv->macro_params[RX_MACRO].event_handler(
+ priv->component,
+ BOLERO_MACRO_EVT_HPHL_HD2_ENABLE, data);
+ break;
+ case WCD_BOLERO_EVT_HPHR_HD2_ENABLE:
+ if (priv->macro_params[RX_MACRO].event_handler)
+ priv->macro_params[RX_MACRO].event_handler(
+ priv->component,
+ BOLERO_MACRO_EVT_HPHR_HD2_ENABLE, data);
+ break;
default:
dev_err(priv->dev, "%s: Invalid event %d trigger from wcd\n",
__func__, event);
diff --git a/asoc/codecs/bolero/bolero-cdc.h b/asoc/codecs/bolero/bolero-cdc.h
index bcd4a255..48f6cd3c 100644
--- a/asoc/codecs/bolero/bolero-cdc.h
+++ b/asoc/codecs/bolero/bolero-cdc.h
@@ -56,6 +56,8 @@ enum {
BOLERO_MACRO_EVT_SSR_GFMUX_UP,
BOLERO_MACRO_EVT_PRE_SSR_UP,
BOLERO_MACRO_EVT_RX_PA_GAIN_UPDATE,
+ BOLERO_MACRO_EVT_HPHL_HD2_ENABLE, /* Enable HD2 cfg for HPHL */
+ BOLERO_MACRO_EVT_HPHR_HD2_ENABLE, /* Enable HD2 cfg for HPHR */
};
enum {
diff --git a/asoc/codecs/bolero/internal.h b/asoc/codecs/bolero/internal.h
index 4d098da3..cf132bdd 100644
--- a/asoc/codecs/bolero/internal.h
+++ b/asoc/codecs/bolero/internal.h
@@ -34,6 +34,8 @@ enum {
WCD_BOLERO_EVT_RX_COMPANDER_SOFT_RST,
WCD_BOLERO_EVT_BCS_CLK_OFF,
WCD_BOLERO_EVT_RX_PA_GAIN_UPDATE,
+ WCD_BOLERO_EVT_HPHL_HD2_ENABLE, /* to enable hd2 config for hphl */
+ WCD_BOLERO_EVT_HPHR_HD2_ENABLE, /* to enable hd2 config for hphr */
};
struct wcd_ctrl_platform_data {
diff --git a/asoc/codecs/bolero/rx-macro.c b/asoc/codecs/bolero/rx-macro.c
index f79e984e..07dd8ada 100644
--- a/asoc/codecs/bolero/rx-macro.c
+++ b/asoc/codecs/bolero/rx-macro.c
@@ -1463,6 +1463,16 @@ static int rx_macro_event_handler(struct snd_soc_component *component,
RX_MACRO_MOD_GAIN));
}
break;
+ case BOLERO_MACRO_EVT_HPHL_HD2_ENABLE:
+ /* Enable hd2 config for hphl*/
+ snd_soc_component_update_bits(component,
+ BOLERO_CDC_RX_RX0_RX_PATH_CFG0, 0x04, data);
+ break;
+ case BOLERO_MACRO_EVT_HPHR_HD2_ENABLE:
+ /* Enable hd2 config for hphr*/
+ snd_soc_component_update_bits(component,
+ BOLERO_CDC_RX_RX1_RX_PATH_CFG0, 0x04, data);
+ break;
}
done:
return ret;
diff --git a/asoc/codecs/rouleur/internal.h b/asoc/codecs/rouleur/internal.h
index b1d21faa..a8fc8332 100644
--- a/asoc/codecs/rouleur/internal.h
+++ b/asoc/codecs/rouleur/internal.h
@@ -88,6 +88,8 @@ struct rouleur_priv {
struct notifier_block psy_nb;
struct work_struct soc_eval_work;
bool low_soc;
+ int foundry_id_reg;
+ int foundry_id;
};
struct rouleur_micbias_setting {
@@ -105,6 +107,7 @@ struct rouleur_pdata {
struct cdc_regulator *regulator;
int num_supplies;
int reset_reg;
+ int foundry_id_reg;
};
struct wcd_ctrl_platform_data {
@@ -135,6 +138,8 @@ enum {
WCD_BOLERO_EVT_RX_COMPANDER_SOFT_RST,
WCD_BOLERO_EVT_BCS_CLK_OFF,
WCD_BOLERO_EVT_RX_PA_GAIN_UPDATE, /* To reduce PA gain for low SoC */
+ WCD_BOLERO_EVT_HPHL_HD2_ENABLE, /* to enable hd2 config for hphl */
+ WCD_BOLERO_EVT_HPHR_HD2_ENABLE, /* to enable hd2 config for hphr */
};
enum {
diff --git a/asoc/codecs/rouleur/pm2250-spmi.h b/asoc/codecs/rouleur/pm2250-spmi.h
index 87c913d4..2eaf28f0 100644
--- a/asoc/codecs/rouleur/pm2250-spmi.h
+++ b/asoc/codecs/rouleur/pm2250-spmi.h
@@ -7,11 +7,16 @@
#ifdef CONFIG_PM2250_SPMI
int pm2250_spmi_write(struct device *dev, int reg, int value);
+int pm2250_spmi_read(struct device *dev, int reg, int *value);
#else
int pm2250_spmi_write(struct device *dev, int reg, int value)
{
return 0;
}
+int pm2250_spmi_read(struct device *dev, int reg, int *value);
+{
+ return 0;
+}
#endif /* CONFIG_PM2250_SPMI */
#endif
diff --git a/asoc/codecs/rouleur/pm2250_spmi.c b/asoc/codecs/rouleur/pm2250_spmi.c
index 1e5f70d1..10a7d109 100644
--- a/asoc/codecs/rouleur/pm2250_spmi.c
+++ b/asoc/codecs/rouleur/pm2250_spmi.c
@@ -25,6 +25,12 @@ static const struct of_device_id pm2250_id_table[] = {
};
MODULE_DEVICE_TABLE(of, pm2250_id_table);
+/**
+ * pm2250_spmi_write: Function to write to PMIC register
+ * @device: node for rouleur device
+ * @reg: PMIC register to write value
+ * @value: Value to be written to PMIC register
+ */
int pm2250_spmi_write(struct device *dev, int reg, int value)
{
int rc;
@@ -47,6 +53,34 @@ int pm2250_spmi_write(struct device *dev, int reg, int value)
}
EXPORT_SYMBOL(pm2250_spmi_write);
+/**
+ * pm2250_spmi_read: Function to read PMIC register
+ * @device: node for rouleur device
+ * @reg: PMIC register to read value
+ * @value: Pointer to value of reg to be read
+ */
+int pm2250_spmi_read(struct device *dev, int reg, int *value)
+{
+ int rc;
+ struct pm2250_spmi *spmi_dd;
+
+ if (!of_device_is_compatible(dev->of_node, "qcom,pm2250-spmi")) {
+ pr_err("%s: Device node is invalid\n", __func__);
+ return -EINVAL;
+ }
+
+ spmi_dd = dev_get_drvdata(dev);
+ if (!spmi_dd)
+ return -EINVAL;
+
+ rc = regmap_read(spmi_dd->regmap, reg, value);
+ if (rc)
+ dev_err(dev, "%s: Read from PMIC register failed\n", __func__);
+
+ return rc;
+}
+EXPORT_SYMBOL(pm2250_spmi_read);
+
static int pm2250_spmi_probe(struct platform_device *pdev)
{
struct pm2250_spmi *spmi_dd;
diff --git a/asoc/codecs/rouleur/rouleur.c b/asoc/codecs/rouleur/rouleur.c
index 9066bd8e..0a2cf8f9 100644
--- a/asoc/codecs/rouleur/rouleur.c
+++ b/asoc/codecs/rouleur/rouleur.c
@@ -39,6 +39,8 @@
#define SOC_THRESHOLD_LEVEL 25
#define LOW_SOC_MBIAS_REG_MIN_VOLTAGE 2850000
+#define FOUNDRY_ID_SEC 0x5
+
enum {
CODEC_TX = 0,
CODEC_RX,
@@ -641,6 +643,11 @@ static int rouleur_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
set_bit(HPH_PA_DELAY, &rouleur->status_mask);
usleep_range(200, 210);
+ /* Enable HD2 Config for HPHR if foundry id is SEC */
+ if (rouleur->foundry_id == FOUNDRY_ID_SEC)
+ rouleur->update_wcd_event(rouleur->handle,
+ WCD_BOLERO_EVT_HPHR_HD2_ENABLE,
+ 0x04);
snd_soc_component_update_bits(component,
ROULEUR_DIG_SWR_PDM_WD_CTL1,
0x03, 0x03);
@@ -685,6 +692,10 @@ static int rouleur_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
clear_bit(HPH_PA_DELAY, &rouleur->status_mask);
}
+ if (rouleur->foundry_id == FOUNDRY_ID_SEC)
+ rouleur->update_wcd_event(rouleur->handle,
+ WCD_BOLERO_EVT_HPHR_HD2_ENABLE,
+ 0x00);
blocking_notifier_call_chain(&rouleur->mbhc->notifier,
WCD_EVENT_POST_HPHR_PA_OFF,
&rouleur->mbhc->wcd_mbhc);
@@ -715,6 +726,10 @@ static int rouleur_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
true);
set_bit(HPH_PA_DELAY, &rouleur->status_mask);
usleep_range(200, 210);
+ if (rouleur->foundry_id == FOUNDRY_ID_SEC)
+ rouleur->update_wcd_event(rouleur->handle,
+ WCD_BOLERO_EVT_HPHL_HD2_ENABLE,
+ 0x04);
snd_soc_component_update_bits(component,
ROULEUR_DIG_SWR_PDM_WD_CTL0,
0x03, 0x03);
@@ -758,6 +773,10 @@ static int rouleur_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
clear_bit(HPH_PA_DELAY, &rouleur->status_mask);
}
+ if (rouleur->foundry_id == FOUNDRY_ID_SEC)
+ rouleur->update_wcd_event(rouleur->handle,
+ WCD_BOLERO_EVT_HPHL_HD2_ENABLE,
+ 0x00);
blocking_notifier_call_chain(&rouleur->mbhc->notifier,
WCD_EVENT_POST_HPHL_PA_OFF,
&rouleur->mbhc->wcd_mbhc);
@@ -798,6 +817,10 @@ static int rouleur_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
snd_soc_component_update_bits(component,
ROULEUR_ANA_COMBOPA_CTL,
0x40, 0x00);
+ if (rouleur->foundry_id == FOUNDRY_ID_SEC)
+ rouleur->update_wcd_event(rouleur->handle,
+ WCD_BOLERO_EVT_HPHL_HD2_ENABLE,
+ 0x04);
snd_soc_component_update_bits(component,
ROULEUR_DIG_SWR_PDM_WD_CTL0,
0x03, 0x03);
@@ -824,6 +847,10 @@ static int rouleur_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
break;
case SND_SOC_DAPM_POST_PMD:
usleep_range(5000, 5100);
+ if (rouleur->foundry_id == FOUNDRY_ID_SEC)
+ rouleur->update_wcd_event(rouleur->handle,
+ WCD_BOLERO_EVT_HPHL_HD2_ENABLE,
+ 0x00);
snd_soc_component_update_bits(component,
ROULEUR_DIG_SWR_PDM_WD_CTL0,
0x03, 0x00);
@@ -2104,6 +2131,25 @@ static void rouleur_evaluate_soc(struct work_struct *work)
}
}
+static void rouleur_get_foundry_id(struct rouleur_priv *rouleur)
+{
+ int ret;
+
+ if (rouleur->foundry_id_reg == 0) {
+ pr_debug("%s: foundry id not defined\n", __func__);
+ return;
+ }
+
+ ret = pm2250_spmi_read(rouleur->spmi_dev,
+ rouleur->foundry_id_reg, &rouleur->foundry_id);
+ if (ret == 0)
+ pr_debug("%s: rouleur foundry id = %x\n", rouleur->foundry_id,
+ __func__);
+ else
+ pr_debug("%s: rouleur error spmi read ret = %d\n",
+ __func__, ret);
+}
+
static int rouleur_soc_codec_probe(struct snd_soc_component *component)
{
struct rouleur_priv *rouleur = snd_soc_component_get_drvdata(component);
@@ -2159,6 +2205,8 @@ static int rouleur_soc_codec_probe(struct snd_soc_component *component)
snd_soc_dapm_sync(dapm);
rouleur_init_reg(component);
+ /* Get rouleur foundry id */
+ rouleur_get_foundry_id(rouleur);
rouleur->version = ROULEUR_VERSION_1_0;
/* Register event notifier */
@@ -2417,6 +2465,12 @@ struct rouleur_pdata *rouleur_populate_dt_data(struct device *dev)
}
pdata->reset_reg = reg;
+ if (of_property_read_u32(dev->of_node, "qcom,foundry-id-reg", &reg))
+ dev_dbg(dev, "%s: Failed to obtain foundry id\n",
+ __func__);
+ else
+ pdata->foundry_id_reg = reg;
+
/* Parse power supplies */
msm_cdc_get_power_supplies(dev, &pdata->regulator,
&pdata->num_supplies);
@@ -2492,6 +2546,7 @@ static int rouleur_bind(struct device *dev)
rouleur->spmi_dev = &pdev->dev;
rouleur->reset_reg = pdata->reset_reg;
+ rouleur->foundry_id_reg = pdata->foundry_id_reg;
ret = msm_cdc_init_supplies(dev, &rouleur->supplies,
pdata->regulator, pdata->num_supplies);
if (!rouleur->supplies) {