Loading asoc/codecs/msm-cdc-supply.c +29 −3 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. */ #include <linux/kernel.h> Loading Loading @@ -357,7 +357,7 @@ EXPORT_SYMBOL(msm_cdc_enable_static_supplies); /* * msm_cdc_init_supplies: * Initialize codec static supplies with regulator get * Initialize codec static supplies * * @dev: pointer to codec device * @supplies: pointer to regulator bulk data Loading @@ -370,6 +370,29 @@ int msm_cdc_init_supplies(struct device *dev, struct regulator_bulk_data **supplies, struct cdc_regulator *cdc_vreg, int num_supplies) { return msm_cdc_init_supplies_v2(dev, supplies, cdc_vreg, num_supplies, false); } EXPORT_SYMBOL(msm_cdc_init_supplies); /* * msm_cdc_init_supplies_v2: * Initialize codec static supplies. * Initialize codec dynamic supplies based on vote_regulator_on_demand * * @dev: pointer to codec device * @supplies: pointer to regulator bulk data * @cdc_vreg: pointer to platform regulator data * @num_supplies: number of supplies * @vote_regulator_on_demand: initialize codec dynamic supplies at runtime * * Return error code if supply init is failed */ int msm_cdc_init_supplies_v2(struct device *dev, struct regulator_bulk_data **supplies, struct cdc_regulator *cdc_vreg, int num_supplies, u32 vote_regulator_on_demand) { struct regulator_bulk_data *vsup; int rc; Loading Loading @@ -413,6 +436,9 @@ int msm_cdc_init_supplies(struct device *dev, if (regulator_count_voltages(vsup[i].consumer) < 0) continue; if (cdc_vreg[i].ondemand && vote_regulator_on_demand) continue; rc = regulator_set_voltage(vsup[i].consumer, cdc_vreg[i].min_uV, cdc_vreg[i].max_uV); Loading @@ -437,7 +463,7 @@ int msm_cdc_init_supplies(struct device *dev, err_supply: return rc; } EXPORT_SYMBOL(msm_cdc_init_supplies); EXPORT_SYMBOL(msm_cdc_init_supplies_v2); /* * msm_cdc_get_power_supplies: Loading asoc/codecs/wcd9335.c +40 −7 Original line number Diff line number Diff line Loading @@ -151,6 +151,8 @@ MODULE_PARM_DESC(cpe_debug_mode, "boot cpe in debug mode"); static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = { "cdc-vdd-mic-bias", "cdc-vdd-tx-h", "cdc-vdd-rx-h" }; enum { Loading Loading @@ -5634,6 +5636,9 @@ static int tasha_codec_enable_on_demand_supply( snd_soc_dapm_to_component(w->dapm); struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct on_demand_supply *supply; struct wcd9xxx *wcd9xxx = tasha->wcd9xxx; struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent); const char *supply_name; if (w->shift >= ON_DEMAND_SUPPLIES_MAX) { dev_err(component->dev, "%s: error index > MAX Demand supplies", Loading @@ -5646,6 +5651,7 @@ static int tasha_codec_enable_on_demand_supply( __func__, on_demand_supply_name[w->shift], event); supply = &tasha->on_demand_list[w->shift]; supply_name = on_demand_supply_name[w->shift]; WARN_ONCE(!supply->supply, "%s isn't defined\n", on_demand_supply_name[w->shift]); if (!supply->supply) { Loading @@ -5656,6 +5662,15 @@ static int tasha_codec_enable_on_demand_supply( switch (event) { case SND_SOC_DAPM_PRE_PMU: if (pdata->vote_regulator_on_demand) { ret = wcd9xxx_vote_ondemand_regulator(wcd9xxx, pdata, supply_name, true); if (ret) dev_err(component->dev, "%s: Failed to vote %s\n", __func__, on_demand_supply_name[w->shift]); } ret = regulator_enable(supply->supply); if (ret) dev_err(component->dev, "%s: Failed to enable %s\n", Loading @@ -5668,6 +5683,15 @@ static int tasha_codec_enable_on_demand_supply( dev_err(component->dev, "%s: Failed to disable %s\n", __func__, on_demand_supply_name[w->shift]); if (pdata->vote_regulator_on_demand) { ret = wcd9xxx_vote_ondemand_regulator(wcd9xxx, pdata, supply_name, false); if (ret) dev_err(component->dev, "%s: Failed to unvote %s\n", __func__, on_demand_supply_name[w->shift]); } break; default: break; Loading Loading @@ -11130,7 +11154,14 @@ static const struct snd_soc_dapm_widget tasha_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY(DAPM_LDO_H_STANDALONE, SND_SOC_NOPM, 0, 0, tasha_codec_force_enable_ldo_h, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("tx regulator", SND_SOC_NOPM, ON_DEMAND_TX_SUPPLY, 0, tasha_codec_enable_on_demand_supply, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("rx regulator", SND_SOC_NOPM, ON_DEMAND_RX_SUPPLY, 0, tasha_codec_enable_on_demand_supply, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_MUX("ANC0 FB MUX", SND_SOC_NOPM, 0, 0, &anc0_fb_mux), SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux), Loading Loading @@ -13899,13 +13930,15 @@ static int tasha_codec_probe(struct snd_soc_component *component) goto err; } for (i = ON_DEMAND_MICBIAS; i < ON_DEMAND_SUPPLIES_MAX; i++) { supply = tasha_codec_find_ondemand_regulator(component, on_demand_supply_name[ON_DEMAND_MICBIAS]); on_demand_supply_name[i]); if (supply) { tasha->on_demand_list[ON_DEMAND_MICBIAS].supply = supply; tasha->on_demand_list[ON_DEMAND_MICBIAS].ondemand_supply_count = tasha->on_demand_list[i].supply = supply; tasha->on_demand_list[i].ondemand_supply_count = 0; } } tasha->fw_data = devm_kzalloc(component->dev, sizeof(*(tasha->fw_data)), GFP_KERNEL); Loading asoc/codecs/wcd9335.h +3 −1 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. */ #ifndef WCD9335_H #define WCD9335_H Loading Loading @@ -81,6 +81,8 @@ enum wcd9335_codec_event { enum tasha_on_demand_supply { ON_DEMAND_MICBIAS = 0, ON_DEMAND_TX_SUPPLY, ON_DEMAND_RX_SUPPLY, ON_DEMAND_SUPPLIES_MAX, }; Loading asoc/codecs/wcd9xxx-core.c +68 −7 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2011-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved. */ #include <linux/kernel.h> Loading Loading @@ -98,6 +98,65 @@ static int wcd9xxx_slim_device_down(struct slim_device *sldev); struct wcd9xxx_i2c wcd9xxx_modules[MAX_WCD9XXX_DEVICE]; /* * wcd9xxx_vote_ondemand_regulator: Initialize codec dynamic supplies * * @wcd9xxx: Pointer to wcd9xxx structure * @wcd9xxx_pdata: Pointer to wcd9xxx_pdata structure * @supply_name: supply parameter to initialize regulator * @enable: flag to initialize/uninitialize supply * * Return error code if supply init is failed */ int wcd9xxx_vote_ondemand_regulator(struct wcd9xxx *wcd9xxx, struct wcd9xxx_pdata *pdata, const char *supply_name, bool enable) { int i, rc, index = -EINVAL; pr_debug("%s: enable %d\n", __func__, enable); for (i = 0; i < wcd9xxx->num_of_supplies; ++i) { if (pdata->regulator[i].ondemand && wcd9xxx->supplies[i].supply && !strcmp(wcd9xxx->supplies[i].supply, supply_name)) { index = i; break; } } if (index < 0) { pr_err("%s: no matching regulator found\n", __func__); return -EINVAL; } if (enable) { rc = regulator_set_voltage(wcd9xxx->supplies[index].consumer, pdata->regulator[index].min_uV, pdata->regulator[index].max_uV); if (rc) { pr_err("%s: set regulator voltage failed for %s, err:%d\n", __func__, supply_name, rc); return rc; } rc = regulator_set_load(wcd9xxx->supplies[index].consumer, pdata->regulator[index].optimum_uA); if (rc < 0) { pr_err("%s: set regulator optimum mode failed for %s, err:%d\n", __func__, supply_name, rc); return rc; } } else { regulator_set_voltage(wcd9xxx->supplies[index].consumer, 0, pdata->regulator[index].max_uV); regulator_set_load(wcd9xxx->supplies[index].consumer, 0); } return 0; } EXPORT_SYMBOL(wcd9xxx_vote_ondemand_regulator); static int wcd9xxx_slim_multi_reg_write(struct wcd9xxx *wcd9xxx, const void *data, size_t count) { Loading Loading @@ -1069,9 +1128,10 @@ static int wcd9xxx_i2c_probe(struct i2c_client *client, wcd9xxx->mclk_rate = pdata->mclk_rate; wcd9xxx->num_of_supplies = pdata->num_supplies; ret = msm_cdc_init_supplies(wcd9xxx->dev, &wcd9xxx->supplies, ret = msm_cdc_init_supplies_v2(wcd9xxx->dev, &wcd9xxx->supplies, pdata->regulator, pdata->num_supplies); pdata->num_supplies, pdata->vote_regulator_on_demand); if (!wcd9xxx->supplies) { dev_err(wcd9xxx->dev, "%s: Cannot init wcd supplies\n", __func__); Loading Loading @@ -1327,9 +1387,10 @@ static int wcd9xxx_slim_probe(struct slim_device *slim) } wcd9xxx->num_of_supplies = pdata->num_supplies; ret = msm_cdc_init_supplies(&slim->dev, &wcd9xxx->supplies, ret = msm_cdc_init_supplies_v2(&slim->dev, &wcd9xxx->supplies, pdata->regulator, pdata->num_supplies); pdata->num_supplies, pdata->vote_regulator_on_demand); if (!wcd9xxx->supplies) { dev_err(wcd9xxx->dev, "%s: Cannot init wcd supplies\n", __func__); Loading asoc/codecs/wcd9xxx-utils.c +9 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. */ #include <linux/kernel.h> Loading Loading @@ -414,6 +414,14 @@ struct wcd9xxx_pdata *wcd9xxx_populate_dt_data(struct device *dev) pdata->dmic_clk_drv = dmic_clk_drive; rc = of_property_read_u32(dev->of_node, "qcom,vote-dynamic-supply-on-demand", &pdata->vote_regulator_on_demand); if (rc) dev_dbg(dev, "%s No entry for %s property in node %s\n", __func__, "qcom,vote-dynamic-supply-on-demand", dev->of_node->full_name); return pdata; err_parse_dt_prop: Loading Loading
asoc/codecs/msm-cdc-supply.c +29 −3 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. */ #include <linux/kernel.h> Loading Loading @@ -357,7 +357,7 @@ EXPORT_SYMBOL(msm_cdc_enable_static_supplies); /* * msm_cdc_init_supplies: * Initialize codec static supplies with regulator get * Initialize codec static supplies * * @dev: pointer to codec device * @supplies: pointer to regulator bulk data Loading @@ -370,6 +370,29 @@ int msm_cdc_init_supplies(struct device *dev, struct regulator_bulk_data **supplies, struct cdc_regulator *cdc_vreg, int num_supplies) { return msm_cdc_init_supplies_v2(dev, supplies, cdc_vreg, num_supplies, false); } EXPORT_SYMBOL(msm_cdc_init_supplies); /* * msm_cdc_init_supplies_v2: * Initialize codec static supplies. * Initialize codec dynamic supplies based on vote_regulator_on_demand * * @dev: pointer to codec device * @supplies: pointer to regulator bulk data * @cdc_vreg: pointer to platform regulator data * @num_supplies: number of supplies * @vote_regulator_on_demand: initialize codec dynamic supplies at runtime * * Return error code if supply init is failed */ int msm_cdc_init_supplies_v2(struct device *dev, struct regulator_bulk_data **supplies, struct cdc_regulator *cdc_vreg, int num_supplies, u32 vote_regulator_on_demand) { struct regulator_bulk_data *vsup; int rc; Loading Loading @@ -413,6 +436,9 @@ int msm_cdc_init_supplies(struct device *dev, if (regulator_count_voltages(vsup[i].consumer) < 0) continue; if (cdc_vreg[i].ondemand && vote_regulator_on_demand) continue; rc = regulator_set_voltage(vsup[i].consumer, cdc_vreg[i].min_uV, cdc_vreg[i].max_uV); Loading @@ -437,7 +463,7 @@ int msm_cdc_init_supplies(struct device *dev, err_supply: return rc; } EXPORT_SYMBOL(msm_cdc_init_supplies); EXPORT_SYMBOL(msm_cdc_init_supplies_v2); /* * msm_cdc_get_power_supplies: Loading
asoc/codecs/wcd9335.c +40 −7 Original line number Diff line number Diff line Loading @@ -151,6 +151,8 @@ MODULE_PARM_DESC(cpe_debug_mode, "boot cpe in debug mode"); static char on_demand_supply_name[][MAX_ON_DEMAND_SUPPLY_NAME_LENGTH] = { "cdc-vdd-mic-bias", "cdc-vdd-tx-h", "cdc-vdd-rx-h" }; enum { Loading Loading @@ -5634,6 +5636,9 @@ static int tasha_codec_enable_on_demand_supply( snd_soc_dapm_to_component(w->dapm); struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct on_demand_supply *supply; struct wcd9xxx *wcd9xxx = tasha->wcd9xxx; struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent); const char *supply_name; if (w->shift >= ON_DEMAND_SUPPLIES_MAX) { dev_err(component->dev, "%s: error index > MAX Demand supplies", Loading @@ -5646,6 +5651,7 @@ static int tasha_codec_enable_on_demand_supply( __func__, on_demand_supply_name[w->shift], event); supply = &tasha->on_demand_list[w->shift]; supply_name = on_demand_supply_name[w->shift]; WARN_ONCE(!supply->supply, "%s isn't defined\n", on_demand_supply_name[w->shift]); if (!supply->supply) { Loading @@ -5656,6 +5662,15 @@ static int tasha_codec_enable_on_demand_supply( switch (event) { case SND_SOC_DAPM_PRE_PMU: if (pdata->vote_regulator_on_demand) { ret = wcd9xxx_vote_ondemand_regulator(wcd9xxx, pdata, supply_name, true); if (ret) dev_err(component->dev, "%s: Failed to vote %s\n", __func__, on_demand_supply_name[w->shift]); } ret = regulator_enable(supply->supply); if (ret) dev_err(component->dev, "%s: Failed to enable %s\n", Loading @@ -5668,6 +5683,15 @@ static int tasha_codec_enable_on_demand_supply( dev_err(component->dev, "%s: Failed to disable %s\n", __func__, on_demand_supply_name[w->shift]); if (pdata->vote_regulator_on_demand) { ret = wcd9xxx_vote_ondemand_regulator(wcd9xxx, pdata, supply_name, false); if (ret) dev_err(component->dev, "%s: Failed to unvote %s\n", __func__, on_demand_supply_name[w->shift]); } break; default: break; Loading Loading @@ -11130,7 +11154,14 @@ static const struct snd_soc_dapm_widget tasha_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY(DAPM_LDO_H_STANDALONE, SND_SOC_NOPM, 0, 0, tasha_codec_force_enable_ldo_h, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("tx regulator", SND_SOC_NOPM, ON_DEMAND_TX_SUPPLY, 0, tasha_codec_enable_on_demand_supply, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("rx regulator", SND_SOC_NOPM, ON_DEMAND_RX_SUPPLY, 0, tasha_codec_enable_on_demand_supply, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_MUX("ANC0 FB MUX", SND_SOC_NOPM, 0, 0, &anc0_fb_mux), SND_SOC_DAPM_MUX("ANC1 FB MUX", SND_SOC_NOPM, 0, 0, &anc1_fb_mux), Loading Loading @@ -13899,13 +13930,15 @@ static int tasha_codec_probe(struct snd_soc_component *component) goto err; } for (i = ON_DEMAND_MICBIAS; i < ON_DEMAND_SUPPLIES_MAX; i++) { supply = tasha_codec_find_ondemand_regulator(component, on_demand_supply_name[ON_DEMAND_MICBIAS]); on_demand_supply_name[i]); if (supply) { tasha->on_demand_list[ON_DEMAND_MICBIAS].supply = supply; tasha->on_demand_list[ON_DEMAND_MICBIAS].ondemand_supply_count = tasha->on_demand_list[i].supply = supply; tasha->on_demand_list[i].ondemand_supply_count = 0; } } tasha->fw_data = devm_kzalloc(component->dev, sizeof(*(tasha->fw_data)), GFP_KERNEL); Loading
asoc/codecs/wcd9335.h +3 −1 Original line number Diff line number Diff line /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. */ #ifndef WCD9335_H #define WCD9335_H Loading Loading @@ -81,6 +81,8 @@ enum wcd9335_codec_event { enum tasha_on_demand_supply { ON_DEMAND_MICBIAS = 0, ON_DEMAND_TX_SUPPLY, ON_DEMAND_RX_SUPPLY, ON_DEMAND_SUPPLIES_MAX, }; Loading
asoc/codecs/wcd9xxx-core.c +68 −7 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2011-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved. */ #include <linux/kernel.h> Loading Loading @@ -98,6 +98,65 @@ static int wcd9xxx_slim_device_down(struct slim_device *sldev); struct wcd9xxx_i2c wcd9xxx_modules[MAX_WCD9XXX_DEVICE]; /* * wcd9xxx_vote_ondemand_regulator: Initialize codec dynamic supplies * * @wcd9xxx: Pointer to wcd9xxx structure * @wcd9xxx_pdata: Pointer to wcd9xxx_pdata structure * @supply_name: supply parameter to initialize regulator * @enable: flag to initialize/uninitialize supply * * Return error code if supply init is failed */ int wcd9xxx_vote_ondemand_regulator(struct wcd9xxx *wcd9xxx, struct wcd9xxx_pdata *pdata, const char *supply_name, bool enable) { int i, rc, index = -EINVAL; pr_debug("%s: enable %d\n", __func__, enable); for (i = 0; i < wcd9xxx->num_of_supplies; ++i) { if (pdata->regulator[i].ondemand && wcd9xxx->supplies[i].supply && !strcmp(wcd9xxx->supplies[i].supply, supply_name)) { index = i; break; } } if (index < 0) { pr_err("%s: no matching regulator found\n", __func__); return -EINVAL; } if (enable) { rc = regulator_set_voltage(wcd9xxx->supplies[index].consumer, pdata->regulator[index].min_uV, pdata->regulator[index].max_uV); if (rc) { pr_err("%s: set regulator voltage failed for %s, err:%d\n", __func__, supply_name, rc); return rc; } rc = regulator_set_load(wcd9xxx->supplies[index].consumer, pdata->regulator[index].optimum_uA); if (rc < 0) { pr_err("%s: set regulator optimum mode failed for %s, err:%d\n", __func__, supply_name, rc); return rc; } } else { regulator_set_voltage(wcd9xxx->supplies[index].consumer, 0, pdata->regulator[index].max_uV); regulator_set_load(wcd9xxx->supplies[index].consumer, 0); } return 0; } EXPORT_SYMBOL(wcd9xxx_vote_ondemand_regulator); static int wcd9xxx_slim_multi_reg_write(struct wcd9xxx *wcd9xxx, const void *data, size_t count) { Loading Loading @@ -1069,9 +1128,10 @@ static int wcd9xxx_i2c_probe(struct i2c_client *client, wcd9xxx->mclk_rate = pdata->mclk_rate; wcd9xxx->num_of_supplies = pdata->num_supplies; ret = msm_cdc_init_supplies(wcd9xxx->dev, &wcd9xxx->supplies, ret = msm_cdc_init_supplies_v2(wcd9xxx->dev, &wcd9xxx->supplies, pdata->regulator, pdata->num_supplies); pdata->num_supplies, pdata->vote_regulator_on_demand); if (!wcd9xxx->supplies) { dev_err(wcd9xxx->dev, "%s: Cannot init wcd supplies\n", __func__); Loading Loading @@ -1327,9 +1387,10 @@ static int wcd9xxx_slim_probe(struct slim_device *slim) } wcd9xxx->num_of_supplies = pdata->num_supplies; ret = msm_cdc_init_supplies(&slim->dev, &wcd9xxx->supplies, ret = msm_cdc_init_supplies_v2(&slim->dev, &wcd9xxx->supplies, pdata->regulator, pdata->num_supplies); pdata->num_supplies, pdata->vote_regulator_on_demand); if (!wcd9xxx->supplies) { dev_err(wcd9xxx->dev, "%s: Cannot init wcd supplies\n", __func__); Loading
asoc/codecs/wcd9xxx-utils.c +9 −1 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. */ #include <linux/kernel.h> Loading Loading @@ -414,6 +414,14 @@ struct wcd9xxx_pdata *wcd9xxx_populate_dt_data(struct device *dev) pdata->dmic_clk_drv = dmic_clk_drive; rc = of_property_read_u32(dev->of_node, "qcom,vote-dynamic-supply-on-demand", &pdata->vote_regulator_on_demand); if (rc) dev_dbg(dev, "%s No entry for %s property in node %s\n", __func__, "qcom,vote-dynamic-supply-on-demand", dev->of_node->full_name); return pdata; err_parse_dt_prop: Loading