|
@@ -27,6 +27,7 @@
|
|
|
#include <dt-bindings/sound/audio-codec-port-types.h>
|
|
|
#include <asoc/msm-cdc-supply.h>
|
|
|
#include <linux/power_supply.h>
|
|
|
+#include "asoc/bolero-slave-internal.h"
|
|
|
|
|
|
#define DRV_NAME "rouleur_codec"
|
|
|
|
|
@@ -646,7 +647,7 @@ static int rouleur_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
|
|
|
/* 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,
|
|
|
+ SLV_BOLERO_EVT_HPHR_HD2_ENABLE,
|
|
|
0x04);
|
|
|
snd_soc_component_update_bits(component,
|
|
|
ROULEUR_DIG_SWR_PDM_WD_CTL1,
|
|
@@ -664,7 +665,7 @@ static int rouleur_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
|
|
|
|
|
|
if (rouleur->update_wcd_event)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_RX_MUTE,
|
|
|
+ SLV_BOLERO_EVT_RX_MUTE,
|
|
|
(WCD_RX2 << 0x10));
|
|
|
wcd_enable_irq(&rouleur->irq_info,
|
|
|
ROULEUR_IRQ_HPHR_PDM_WD_INT);
|
|
@@ -674,7 +675,7 @@ static int rouleur_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
|
|
|
ROULEUR_IRQ_HPHR_PDM_WD_INT);
|
|
|
if (rouleur->update_wcd_event)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_RX_MUTE,
|
|
|
+ SLV_BOLERO_EVT_RX_MUTE,
|
|
|
(WCD_RX2 << 0x10 | 0x1));
|
|
|
blocking_notifier_call_chain(&rouleur->mbhc->notifier,
|
|
|
WCD_EVENT_PRE_HPHR_PA_OFF,
|
|
@@ -694,7 +695,7 @@ static int rouleur_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
|
|
|
|
|
|
if (rouleur->foundry_id == FOUNDRY_ID_SEC)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_HPHR_HD2_ENABLE,
|
|
|
+ SLV_BOLERO_EVT_HPHR_HD2_ENABLE,
|
|
|
0x00);
|
|
|
blocking_notifier_call_chain(&rouleur->mbhc->notifier,
|
|
|
WCD_EVENT_POST_HPHR_PA_OFF,
|
|
@@ -728,7 +729,7 @@ static int rouleur_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
|
|
|
usleep_range(200, 210);
|
|
|
if (rouleur->foundry_id == FOUNDRY_ID_SEC)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_HPHL_HD2_ENABLE,
|
|
|
+ SLV_BOLERO_EVT_HPHL_HD2_ENABLE,
|
|
|
0x04);
|
|
|
snd_soc_component_update_bits(component,
|
|
|
ROULEUR_DIG_SWR_PDM_WD_CTL0,
|
|
@@ -746,7 +747,7 @@ static int rouleur_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
|
|
|
|
|
|
if (rouleur->update_wcd_event)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_RX_MUTE,
|
|
|
+ SLV_BOLERO_EVT_RX_MUTE,
|
|
|
(WCD_RX1 << 0x10));
|
|
|
wcd_enable_irq(&rouleur->irq_info,
|
|
|
ROULEUR_IRQ_HPHL_PDM_WD_INT);
|
|
@@ -756,7 +757,7 @@ static int rouleur_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
|
|
|
ROULEUR_IRQ_HPHL_PDM_WD_INT);
|
|
|
if (rouleur->update_wcd_event)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_RX_MUTE,
|
|
|
+ SLV_BOLERO_EVT_RX_MUTE,
|
|
|
(WCD_RX1 << 0x10 | 0x1));
|
|
|
blocking_notifier_call_chain(&rouleur->mbhc->notifier,
|
|
|
WCD_EVENT_PRE_HPHL_PA_OFF,
|
|
@@ -775,7 +776,7 @@ static int rouleur_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
|
|
|
|
|
|
if (rouleur->foundry_id == FOUNDRY_ID_SEC)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_HPHL_HD2_ENABLE,
|
|
|
+ SLV_BOLERO_EVT_HPHL_HD2_ENABLE,
|
|
|
0x00);
|
|
|
blocking_notifier_call_chain(&rouleur->mbhc->notifier,
|
|
|
WCD_EVENT_POST_HPHL_PA_OFF,
|
|
@@ -819,7 +820,7 @@ static int rouleur_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
|
|
0x40, 0x00);
|
|
|
if (rouleur->foundry_id == FOUNDRY_ID_SEC)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_HPHL_HD2_ENABLE,
|
|
|
+ SLV_BOLERO_EVT_HPHL_HD2_ENABLE,
|
|
|
0x04);
|
|
|
snd_soc_component_update_bits(component,
|
|
|
ROULEUR_DIG_SWR_PDM_WD_CTL0,
|
|
@@ -832,7 +833,7 @@ static int rouleur_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
|
|
0x0F, 0x04);
|
|
|
if (rouleur->update_wcd_event)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_RX_MUTE,
|
|
|
+ SLV_BOLERO_EVT_RX_MUTE,
|
|
|
(WCD_RX1 << 0x10));
|
|
|
wcd_enable_irq(&rouleur->irq_info,
|
|
|
ROULEUR_IRQ_HPHL_PDM_WD_INT);
|
|
@@ -842,14 +843,14 @@ static int rouleur_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
|
|
ROULEUR_IRQ_HPHL_PDM_WD_INT);
|
|
|
if (rouleur->update_wcd_event)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_RX_MUTE,
|
|
|
+ SLV_BOLERO_EVT_RX_MUTE,
|
|
|
(WCD_RX1 << 0x10 | 0x1));
|
|
|
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,
|
|
|
+ SLV_BOLERO_EVT_HPHL_HD2_ENABLE,
|
|
|
0x00);
|
|
|
snd_soc_component_update_bits(component,
|
|
|
ROULEUR_DIG_SWR_PDM_WD_CTL0,
|
|
@@ -897,7 +898,7 @@ static int rouleur_codec_enable_lo_pa(struct snd_soc_dapm_widget *w,
|
|
|
0x0F, 0x04);
|
|
|
if (rouleur->update_wcd_event)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_RX_MUTE,
|
|
|
+ SLV_BOLERO_EVT_RX_MUTE,
|
|
|
(WCD_RX1 << 0x10));
|
|
|
wcd_enable_irq(&rouleur->irq_info,
|
|
|
ROULEUR_IRQ_HPHL_PDM_WD_INT);
|
|
@@ -907,7 +908,7 @@ static int rouleur_codec_enable_lo_pa(struct snd_soc_dapm_widget *w,
|
|
|
ROULEUR_IRQ_HPHL_PDM_WD_INT);
|
|
|
if (rouleur->update_wcd_event)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_RX_MUTE,
|
|
|
+ SLV_BOLERO_EVT_RX_MUTE,
|
|
|
(WCD_RX1 << 0x10 | 0x1));
|
|
|
break;
|
|
|
case SND_SOC_DAPM_POST_PMD:
|
|
@@ -1371,10 +1372,10 @@ void rouleur_disable_bcs_before_slow_insert(struct snd_soc_component *component,
|
|
|
if (rouleur->update_wcd_event) {
|
|
|
if (bcs_disable)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_BCS_CLK_OFF, 0);
|
|
|
+ SLV_BOLERO_EVT_BCS_CLK_OFF, 0);
|
|
|
else
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_BCS_CLK_OFF, 1);
|
|
|
+ SLV_BOLERO_EVT_BCS_CLK_OFF, 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1420,7 +1421,7 @@ static int rouleur_event_notify(struct notifier_block *block,
|
|
|
struct wcd_mbhc *mbhc;
|
|
|
|
|
|
switch (event) {
|
|
|
- case BOLERO_WCD_EVT_PA_OFF_PRE_SSR:
|
|
|
+ case BOLERO_SLV_EVT_PA_OFF_PRE_SSR:
|
|
|
snd_soc_component_update_bits(component,
|
|
|
ROULEUR_ANA_HPHPA_CNP_CTL_2,
|
|
|
0xC0, 0x00);
|
|
@@ -1437,7 +1438,7 @@ static int rouleur_event_notify(struct notifier_block *block,
|
|
|
ROULEUR_ANA_COMBOPA_CTL,
|
|
|
0x80, 0x00);
|
|
|
break;
|
|
|
- case BOLERO_WCD_EVT_SSR_DOWN:
|
|
|
+ case BOLERO_SLV_EVT_SSR_DOWN:
|
|
|
rouleur->dev_up = false;
|
|
|
rouleur->mbhc->wcd_mbhc.deinit_in_progress = true;
|
|
|
mbhc = &rouleur->mbhc->wcd_mbhc;
|
|
@@ -1446,7 +1447,7 @@ static int rouleur_event_notify(struct notifier_block *block,
|
|
|
rouleur_mbhc_ssr_down(rouleur->mbhc, component);
|
|
|
rouleur_reset(rouleur->dev, 0x01);
|
|
|
break;
|
|
|
- case BOLERO_WCD_EVT_SSR_UP:
|
|
|
+ case BOLERO_SLV_EVT_SSR_UP:
|
|
|
rouleur_reset(rouleur->dev, 0x00);
|
|
|
/* allow reset to take effect */
|
|
|
usleep_range(10000, 10010);
|
|
@@ -2087,14 +2088,14 @@ static void rouleur_evaluate_soc(struct work_struct *work)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (soc_val < pdata->soc_threshold_val) {
|
|
|
+ if (soc_val < SOC_THRESHOLD_LEVEL) {
|
|
|
dev_dbg(rouleur->dev,
|
|
|
"%s battery SoC less than threshold soc_val = %d\n",
|
|
|
__func__, soc_val);
|
|
|
/* Reduce PA Gain by 6DB for low SoC */
|
|
|
if (rouleur->update_wcd_event)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_RX_PA_GAIN_UPDATE,
|
|
|
+ SLV_BOLERO_EVT_RX_PA_GAIN_UPDATE,
|
|
|
true);
|
|
|
rouleur->low_soc = true;
|
|
|
ret = msm_cdc_set_supply_min_voltage(rouleur->dev,
|
|
@@ -2113,7 +2114,7 @@ static void rouleur_evaluate_soc(struct work_struct *work)
|
|
|
/* Reset PA Gain to default for normal SoC */
|
|
|
if (rouleur->update_wcd_event)
|
|
|
rouleur->update_wcd_event(rouleur->handle,
|
|
|
- WCD_BOLERO_EVT_RX_PA_GAIN_UPDATE,
|
|
|
+ SLV_BOLERO_EVT_RX_PA_GAIN_UPDATE,
|
|
|
false);
|
|
|
ret = msm_cdc_set_supply_min_voltage(rouleur->dev,
|
|
|
rouleur->supplies,
|
|
@@ -2224,6 +2225,14 @@ static int rouleur_soc_codec_probe(struct snd_soc_component *component)
|
|
|
}
|
|
|
rouleur->low_soc = false;
|
|
|
rouleur->dev_up = true;
|
|
|
+ /* Register notifier to change gain based on state of charge */
|
|
|
+ INIT_WORK(&rouleur->soc_eval_work, rouleur_evaluate_soc);
|
|
|
+ rouleur->psy_nb.notifier_call = rouleur_battery_supply_cb;
|
|
|
+ if (power_supply_reg_notifier(&rouleur->psy_nb) < 0)
|
|
|
+ dev_dbg(rouleur->dev,
|
|
|
+ "%s: could not register pwr supply notifier\n",
|
|
|
+ __func__);
|
|
|
+ queue_work(system_freezable_wq, &rouleur->soc_eval_work);
|
|
|
done:
|
|
|
return ret;
|
|
|
}
|
|
@@ -2463,16 +2472,6 @@ struct rouleur_pdata *rouleur_populate_dt_data(struct device *dev)
|
|
|
else
|
|
|
pdata->foundry_id_reg = reg;
|
|
|
|
|
|
- if (of_property_read_u32(dev->of_node, "qcom,soc-threshold-voltage"
|
|
|
- , ®)) {
|
|
|
- dev_dbg(dev, "%s: Looking up %s property in node %s failed\n",
|
|
|
- __func__, "qcom,soc-threshold-voltage",
|
|
|
- dev->of_node->full_name);
|
|
|
- pdata->soc_threshold_val = SOC_THRESHOLD_LEVEL;
|
|
|
- } else {
|
|
|
- pdata->soc_threshold_val = reg;
|
|
|
- }
|
|
|
-
|
|
|
/* Parse power supplies */
|
|
|
msm_cdc_get_power_supplies(dev, &pdata->regulator,
|
|
|
&pdata->num_supplies);
|
|
@@ -2690,14 +2689,6 @@ static int rouleur_bind(struct device *dev)
|
|
|
goto err_irq;
|
|
|
}
|
|
|
|
|
|
- /* Register notifier to change gain based on state of charge */
|
|
|
- INIT_WORK(&rouleur->soc_eval_work, rouleur_evaluate_soc);
|
|
|
- rouleur->psy_nb.notifier_call = rouleur_battery_supply_cb;
|
|
|
- if (power_supply_reg_notifier(&rouleur->psy_nb) < 0)
|
|
|
- dev_dbg(rouleur->dev,
|
|
|
- "%s: could not register pwr supply notifier\n",
|
|
|
- __func__);
|
|
|
- queue_work(system_freezable_wq, &rouleur->soc_eval_work);
|
|
|
return ret;
|
|
|
err_irq:
|
|
|
wcd_irq_exit(&rouleur->irq_info, rouleur->virq);
|