From 6256c5b9892ff0a0395ab322e7c27960db2ae900 Mon Sep 17 00:00:00 2001 From: Tanya Dixit Date: Thu, 9 Aug 2018 14:29:51 +0530 Subject: [PATCH] asoc: codecs: Tanggu reset pin and supplies Enable power supplies and reset of Tanggu CRs-Fixed: 2281591 Change-Id: I7d693263f328b51d2f333bddac5e15e98a5f9f51 Signed-off-by: Tanya Dixit --- asoc/codecs/wcd937x/internal.h | 4 ++++ asoc/codecs/wcd937x/wcd937x.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/wcd937x/internal.h b/asoc/codecs/wcd937x/internal.h index ba1b626c91..b693f6a9bc 100644 --- a/asoc/codecs/wcd937x/internal.h +++ b/asoc/codecs/wcd937x/internal.h @@ -71,6 +71,7 @@ struct wcd937x_priv { tx_port_mapping[MAX_PORT][MAX_CH_PER_PORT]; struct codec_port_info rx_port_mapping[MAX_PORT][MAX_CH_PER_PORT]; + struct regulator_bulk_data *supplies; }; struct wcd937x_micbias_setting { @@ -85,6 +86,9 @@ struct wcd937x_pdata { struct device_node *rx_slave; struct device_node *tx_slave; struct wcd937x_micbias_setting micbias; + + struct cdc_regulator *regulator; + int num_supplies; }; enum { diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c index 45a3b96bd5..96e859c88c 100644 --- a/asoc/codecs/wcd937x/wcd937x.c +++ b/asoc/codecs/wcd937x/wcd937x.c @@ -29,6 +29,7 @@ #include "wcd937x-registers.h" #include "../msm-cdc-pinctrl.h" #include +#include "../msm-cdc-supply.h" #define WCD9370_VARIANT 0 #define WCD9375_VARIANT 5 @@ -1734,15 +1735,24 @@ struct wcd937x_pdata *wcd937x_populate_dt_data(struct device *dev) return NULL; pdata->rst_np = of_parse_phandle(dev->of_node, - "qcom,wcd937x-reset-node", 0); + "qcom,wcd-rst-gpio-node", 0); if (!pdata->rst_np) { dev_err(dev, "%s: Looking up %s property in node %s failed\n", - __func__, "qcom,wcd937x-reset-node", + __func__, "qcom,wcd-rst-gpio-node", dev->of_node->full_name); return NULL; } + /* Parse power supplies */ + msm_cdc_get_power_supplies(dev, &pdata->regulator, + &pdata->num_supplies); + if (!pdata->regulator || (pdata->num_supplies <= 0)) { + dev_err(dev, "%s: no power supplies defined for codec\n", + __func__); + return NULL; + } + pdata->rx_slave = of_parse_phandle(dev->of_node, "qcom,rx-slave", 0); pdata->tx_slave = of_parse_phandle(dev->of_node, "qcom,tx-slave", 0); @@ -1775,6 +1785,24 @@ static int wcd937x_bind(struct device *dev) * as per HW requirement. */ usleep_range(5000, 5010); + + ret = msm_cdc_init_supplies(dev, &wcd937x->supplies, + pdata->regulator, pdata->num_supplies); + if (!wcd937x->supplies) { + dev_err(dev, "%s: Cannot init wcd supplies\n", + __func__); + return ret; + } + + ret = msm_cdc_enable_static_supplies(dev, wcd937x->supplies, + pdata->regulator, + pdata->num_supplies); + if (ret) { + dev_err(dev, "%s: wcd static supply enable failed!\n", + __func__); + return ret; + } + ret = component_bind_all(dev, wcd937x); if (ret) { dev_err(dev, "%s: Slave bind failed, ret = %d\n",