From 7bc77136ad5579eb139ca9278afd38872ff9e502 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Tue, 25 Aug 2020 15:55:36 +0530 Subject: [PATCH] ASoC: rouleur: Reduce PA Gain for low state of charge based on dt node Configure low PA Gain for low state of charge based on dt node. Change-Id: I7f36cf4b17d9794a2763edc3c2fd5cec53a3521f Signed-off-by: Vatsal Bucha --- asoc/codecs/rouleur/internal.h | 1 + asoc/codecs/rouleur/rouleur.c | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/asoc/codecs/rouleur/internal.h b/asoc/codecs/rouleur/internal.h index a8fc83325c33..3e560ebd750a 100644 --- a/asoc/codecs/rouleur/internal.h +++ b/asoc/codecs/rouleur/internal.h @@ -108,6 +108,7 @@ struct rouleur_pdata { int num_supplies; int reset_reg; int foundry_id_reg; + u32 soc_threshold_val; }; struct wcd_ctrl_platform_data { diff --git a/asoc/codecs/rouleur/rouleur.c b/asoc/codecs/rouleur/rouleur.c index 44ec2476a8e0..4fd94d2b6823 100644 --- a/asoc/codecs/rouleur/rouleur.c +++ b/asoc/codecs/rouleur/rouleur.c @@ -2087,7 +2087,7 @@ static void rouleur_evaluate_soc(struct work_struct *work) return; } - if (soc_val < SOC_THRESHOLD_LEVEL) { + if (soc_val < pdata->soc_threshold_val) { dev_dbg(rouleur->dev, "%s battery SoC less than threshold soc_val = %d\n", __func__, soc_val); @@ -2224,14 +2224,6 @@ 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; } @@ -2471,6 +2463,16 @@ 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); @@ -2688,6 +2690,14 @@ 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);