summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaxminath Kasam <lkasam@codeaurora.org>2016-12-14 20:00:35 +0530
committerLaxminath Kasam <lkasam@codeaurora.org>2016-12-17 11:38:24 +0530
commit69898f67286504e23e5433afe9f1a6c473a89c6b (patch)
tree6a069d9a1c6f7926e72b647b65f70c8d17ced118
parent7296f6d92b1c4e92aa90990621434f02bbe1d5ed (diff)
ASoC: msm: migrate to cdc pinctrl functions
For audio pinctrl settings in internal codec, use cdc pinctrl functions to activate and suspend gpios. Change-Id: Ib0de01379a02636d35b49770aa82ea53de7c2768 Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
-rw-r--r--Documentation/devicetree/bindings/sound/qcom-audio-dev.txt29
-rw-r--r--drivers/mfd/msm-cdc-pinctrl.c16
-rw-r--r--sound/soc/codecs/msmfalcon_cdc/msm-digital-cdc.c7
-rw-r--r--sound/soc/codecs/msmfalcon_cdc/msm-digital-cdc.h5
-rw-r--r--sound/soc/msm/Kconfig1
-rw-r--r--sound/soc/msm/Makefile2
-rw-r--r--sound/soc/msm/msmfalcon-common.c20
-rw-r--r--sound/soc/msm/msmfalcon-common.h5
-rw-r--r--sound/soc/msm/msmfalcon-internal.c41
9 files changed, 71 insertions, 55 deletions
diff --git a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
index 336b9f0087a5..8957ff9dc9ee 100644
--- a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
+++ b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
@@ -361,6 +361,10 @@ Required properties:
- compatible : "qcom,msm-cdc-pinctrl"
+Optional properties:
+ - qcom,lpi-gpios : This boolean property is added if GPIOs are under
+ LPI TLMM.
+
* msm-dai-slim
Required properties:
@@ -1655,6 +1659,10 @@ mclk frequency needs to be configured for internal and external PA.
- qcom,wsa-max-devs : Maximum number of WSA881x devices present in the target
- qcom,wsa-devs : List of phandles for all possible WSA881x devices supported for the target
- qcom,wsa-aux-dev-prefix : Name prefix with Left/Right configuration for WSA881x device
+- qcom,cdc-pdm-gpios : phandle for pdm gpios.
+- qcom,cdc-comp-gpios : phandle for compander gpios.
+- qcom,cdc-dmic-gpios : phandle for Digital mic clk and data gpios.
+- qcom,cdc-sdw-gpios : phandle for soundwire clk and data gpios.
Example:
sound {
@@ -1675,24 +1683,11 @@ Example:
"AMIC1", "MIC BIAS External",
"AMIC2", "MIC BIAS Internal2",
"AMIC3", "MIC BIAS External";
- qcom,msm-gpios =
- "int_pdm",
- "us_eu_gpio";
- qcom,pinctrl-names =
- "all_off",
- "int_pdm_act",
- "us_eu_gpio_act",
- "int_pdm_us_eu_gpio_act";
- pinctrl-names =
- "all_off",
- "int_pdm_act",
- "us_eu_gpio_act",
- "int_pdm_us_eu_gpio_act";
- pinctrl-0 = <&cdc_pdm_lines_sus &cdc_pdm_lines_2_sus &cross_conn_det_sus>;
- pinctrl-1 = <&cdc_pdm_lines_act &cdc_pdm_lines_2_act &cross_conn_det_sus>;
- pinctrl-2 = <&cdc_pdm_lines_sus &cdc_pdm_lines_2_sus &cross_conn_det_act>;
- pinctrl-3 = <&cdc_pdm_lines_act &cdc_pdm_lines_2_act &cross_conn_det_act>;
qcom,cdc-us-euro-gpios = <&msm_gpio 63 0>;
+ qcom,cdc-pdm-gpios = <&cdc_pdm_gpios>;
+ qcom,cdc-comp-gpios = <&cdc_comp_gpios>;
+ qcom,cdc-dmic-gpios = <&cdc_dmic_gpios>;
+ qcom,cdc-sdw-gpios = <&cdc_sdw_gpios>;
asoc-platform = <&pcm0>, <&pcm1>, <&voip>, <&voice>,
<&loopback>, <&compress>, <&hostless>,
<&afe>, <&lsm>, <&routing>, <&lpa>;
diff --git a/drivers/mfd/msm-cdc-pinctrl.c b/drivers/mfd/msm-cdc-pinctrl.c
index 3ffd20245877..9622256a280d 100644
--- a/drivers/mfd/msm-cdc-pinctrl.c
+++ b/drivers/mfd/msm-cdc-pinctrl.c
@@ -180,13 +180,15 @@ static int msm_cdc_pinctrl_probe(struct platform_device *pdev)
ret = PTR_ERR(gpio_data->pinctrl_sleep);
goto err_lookup_state;
}
-
- /* Set pinctrl state to aud_sleep by default */
- ret = pinctrl_select_state(gpio_data->pinctrl,
- gpio_data->pinctrl_sleep);
- if (ret)
- dev_err(&pdev->dev, "%s: set cdc gpio sleep state fail: %d\n",
- __func__, ret);
+ /* skip setting to sleep state for LPI_TLMM GPIOs */
+ if (!of_property_read_bool(pdev->dev.of_node, "qcom,lpi-gpios")) {
+ /* Set pinctrl state to aud_sleep by default */
+ ret = pinctrl_select_state(gpio_data->pinctrl,
+ gpio_data->pinctrl_sleep);
+ if (ret)
+ dev_err(&pdev->dev, "%s: set cdc gpio sleep state fail: %d\n",
+ __func__, ret);
+ }
gpio_data->gpio = of_get_named_gpio(pdev->dev.of_node,
"qcom,cdc-rst-n-gpio", 0);
diff --git a/sound/soc/codecs/msmfalcon_cdc/msm-digital-cdc.c b/sound/soc/codecs/msmfalcon_cdc/msm-digital-cdc.c
index 32f8dc6bc7ef..d036b82654f0 100644
--- a/sound/soc/codecs/msmfalcon_cdc/msm-digital-cdc.c
+++ b/sound/soc/codecs/msmfalcon_cdc/msm-digital-cdc.c
@@ -232,11 +232,11 @@ static int msm_dig_cdc_codec_config_compander(struct snd_soc_codec *codec,
/* Enable Compander GPIO */
if (dig_cdc->codec_hph_comp_gpio)
- dig_cdc->codec_hph_comp_gpio(1);
+ dig_cdc->codec_hph_comp_gpio(1, codec);
} else if (SND_SOC_DAPM_EVENT_OFF(event)) {
/* Disable Compander GPIO */
if (dig_cdc->codec_hph_comp_gpio)
- dig_cdc->codec_hph_comp_gpio(0);
+ dig_cdc->codec_hph_comp_gpio(0, codec);
snd_soc_update_bits(codec,
MSM89XX_CDC_CORE_COMP0_B2_CTL, 0x0F, 0x05);
@@ -264,7 +264,8 @@ static int msm_dig_cdc_codec_config_compander(struct snd_soc_codec *codec,
*
*/
void msm_dig_cdc_hph_comp_cb(
- int (*codec_hph_comp_gpio)(bool enable), struct snd_soc_codec *codec)
+ int (*codec_hph_comp_gpio)(bool enable, struct snd_soc_codec *codec),
+ struct snd_soc_codec *codec)
{
struct msm_dig_priv *dig_cdc = snd_soc_codec_get_drvdata(codec);
diff --git a/sound/soc/codecs/msmfalcon_cdc/msm-digital-cdc.h b/sound/soc/codecs/msmfalcon_cdc/msm-digital-cdc.h
index eaf61329996c..4cb82cd421b0 100644
--- a/sound/soc/codecs/msmfalcon_cdc/msm-digital-cdc.h
+++ b/sound/soc/codecs/msmfalcon_cdc/msm-digital-cdc.h
@@ -35,7 +35,7 @@ enum {
struct msm_dig_priv {
struct snd_soc_codec *codec;
u32 comp_enabled[MSM89XX_RX_MAX];
- int (*codec_hph_comp_gpio)(bool enable);
+ int (*codec_hph_comp_gpio)(bool enable, struct snd_soc_codec *codec);
s32 dmic_1_2_clk_cnt;
s32 dmic_3_4_clk_cnt;
bool dec_active[NUM_DECIMATORS];
@@ -85,7 +85,8 @@ enum {
};
extern void msm_dig_cdc_hph_comp_cb(
- int (*codec_hph_comp_gpio)(bool enable),
+ int (*codec_hph_comp_gpio)(
+ bool enable, struct snd_soc_codec *codec),
struct snd_soc_codec *codec);
int msm_dig_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
struct snd_soc_codec *codec);
diff --git a/sound/soc/msm/Kconfig b/sound/soc/msm/Kconfig
index f1249e9397e7..69d74a8703b6 100644
--- a/sound/soc/msm/Kconfig
+++ b/sound/soc/msm/Kconfig
@@ -119,6 +119,7 @@ config SND_SOC_INT_CODEC
select MSM_QDSP6_PDR
select MSM_QDSP6_NOTIFIER
select MSM_QDSP6V2_CODECS
+ select MSM_CDC_PINCTRL
select SND_SOC_MSM_SDW
select SND_SOC_MSMFALCON_CDC
select QTI_PP
diff --git a/sound/soc/msm/Makefile b/sound/soc/msm/Makefile
index 8df7fad3893d..d66f9eb79cea 100644
--- a/sound/soc/msm/Makefile
+++ b/sound/soc/msm/Makefile
@@ -21,7 +21,7 @@ snd-soc-msm8998-objs := msm8998.o
obj-$(CONFIG_SND_SOC_MSM8998) += snd-soc-msm8998.o
# for MSMFALCON sound card driver
-snd-soc-msmfalcon-common-objs := msm-audio-pinctrl.o msmfalcon-common.o
+snd-soc-msmfalcon-common-objs := msmfalcon-common.o
obj-$(CONFIG_SND_SOC_MSMFALCON_COMMON) += snd-soc-msmfalcon-common.o
# for MSMFALCON sound card driver
diff --git a/sound/soc/msm/msmfalcon-common.c b/sound/soc/msm/msmfalcon-common.c
index e2338e761fca..def558d4bf8b 100644
--- a/sound/soc/msm/msmfalcon-common.c
+++ b/sound/soc/msm/msmfalcon-common.c
@@ -16,7 +16,6 @@
#include <sound/pcm_params.h>
#include <sound/q6afe-v2.h>
#include "qdsp6v2/msm-pcm-routing-v2.h"
-#include "msm-audio-pinctrl.h"
#include "msmfalcon-common.h"
#include "msmfalcon-internal.h"
#include "msmfalcon-external.h"
@@ -2316,7 +2315,7 @@ codec_dai:
dai_link[i].codec_of_node = phandle;
dai_link[i].codec_name = NULL;
}
- if (pdata->int_codec) {
+ if (pdata->snd_card_val == INT_SND_CARD) {
if ((dai_link[i].be_id ==
MSM_BACKEND_DAI_INT0_MI2S_RX) ||
(dai_link[i].be_id ==
@@ -2720,13 +2719,16 @@ static int msm_asoc_machine_probe(struct platform_device *pdev)
if (pdata->snd_card_val == INT_SND_CARD) {
/*reading the gpio configurations from dtsi file*/
- ret = msm_gpioset_initialize(CLIENT_WCD, &pdev->dev);
- if (ret < 0) {
- dev_err(&pdev->dev,
- "%s: error reading dtsi files%d\n",
- __func__, ret);
- goto err;
- }
+ pdata->pdm_gpio_p = of_parse_phandle(pdev->dev.of_node,
+ "qcom,cdc-pdm-gpios", 0);
+ pdata->comp_gpio_p = of_parse_phandle(pdev->dev.of_node,
+ "qcom,cdc-comp-gpios", 0);
+ pdata->sdw_gpio_p = of_parse_phandle(pdev->dev.of_node,
+ "qcom,cdc-sdw-gpios", 0);
+ pdata->dmic_gpio_p = of_parse_phandle(pdev->dev.of_node,
+ "qcom,cdc-dmic-gpios", 0);
+ pdata->ext_spk_gpio_p = of_parse_phandle(pdev->dev.of_node,
+ "qcom,cdc-ext-spk-gpios", 0);
}
/*
diff --git a/sound/soc/msm/msmfalcon-common.h b/sound/soc/msm/msmfalcon-common.h
index ff3edec4f212..3c18852cf897 100644
--- a/sound/soc/msm/msmfalcon-common.h
+++ b/sound/soc/msm/msmfalcon-common.h
@@ -84,6 +84,11 @@ struct msm_asoc_mach_data {
struct device_node *us_euro_gpio_p; /* used by pinctrl API */
struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
+ struct device_node *pdm_gpio_p; /* used by pinctrl API */
+ struct device_node *comp_gpio_p; /* used by pinctrl API */
+ struct device_node *sdw_gpio_p; /* used by pinctrl API */
+ struct device_node *dmic_gpio_p; /* used by pinctrl API */
+ struct device_node *ext_spk_gpio_p; /* used by pinctrl API */
struct snd_soc_codec *codec;
struct msmfalcon_codec msmfalcon_codec_fn;
struct snd_info_entry *codec_root;
diff --git a/sound/soc/msm/msmfalcon-internal.c b/sound/soc/msm/msmfalcon-internal.c
index 6eca0c391553..a40740d02582 100644
--- a/sound/soc/msm/msmfalcon-internal.c
+++ b/sound/soc/msm/msmfalcon-internal.c
@@ -13,9 +13,9 @@
#include <linux/of_gpio.h>
#include <linux/platform_device.h>
#include <linux/module.h>
+#include <linux/mfd/msm-cdc-pinctrl.h>
#include <sound/pcm_params.h>
#include "qdsp6v2/msm-pcm-routing-v2.h"
-#include "msm-audio-pinctrl.h"
#include "msmfalcon-common.h"
#include "../codecs/msmfalcon_cdc/msm-digital-cdc.h"
#include "../codecs/msmfalcon_cdc/msm-analog-cdc.h"
@@ -451,22 +451,25 @@ static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
};
-static int msm_config_hph_compander_gpio(bool enable)
+static int msm_config_hph_compander_gpio(bool enable,
+ struct snd_soc_codec *codec)
{
+ struct snd_soc_card *card = codec->component.card;
+ struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
int ret = 0;
pr_debug("%s: %s HPH Compander\n", __func__,
enable ? "Enable" : "Disable");
if (enable) {
- ret = msm_gpioset_activate(CLIENT_WCD, "comp_gpio");
+ ret = msm_cdc_pinctrl_select_active_state(pdata->comp_gpio_p);
if (ret) {
pr_err("%s: gpio set cannot be activated %s\n",
__func__, "comp_gpio");
goto done;
}
} else {
- ret = msm_gpioset_suspend(CLIENT_WCD, "comp_gpio");
+ ret = msm_cdc_pinctrl_select_sleep_state(pdata->comp_gpio_p);
if (ret) {
pr_err("%s: gpio set cannot be de-activated %s\n",
__func__, "comp_gpio");
@@ -517,7 +520,8 @@ static int enable_spk_ext_pa(struct snd_soc_codec *codec, int enable)
enable ? "Enable" : "Disable");
if (enable) {
- ret = msm_gpioset_activate(CLIENT_WCD, "ext_spk_gpio");
+ ret = msm_cdc_pinctrl_select_active_state(
+ pdata->ext_spk_gpio_p);
if (ret) {
pr_err("%s: gpio set cannot be de-activated %s\n",
__func__, "ext_spk_gpio");
@@ -526,7 +530,8 @@ static int enable_spk_ext_pa(struct snd_soc_codec *codec, int enable)
gpio_set_value_cansleep(pdata->spk_ext_pa_gpio, enable);
} else {
gpio_set_value_cansleep(pdata->spk_ext_pa_gpio, enable);
- ret = msm_gpioset_suspend(CLIENT_WCD, "ext_spk_gpio");
+ ret = msm_cdc_pinctrl_select_sleep_state(
+ pdata->ext_spk_gpio_p);
if (ret) {
pr_err("%s: gpio set cannot be de-activated %s\n",
__func__, "ext_spk_gpio");
@@ -538,20 +543,22 @@ static int enable_spk_ext_pa(struct snd_soc_codec *codec, int enable)
static int msm_config_sdw_gpio(bool enable, struct snd_soc_codec *codec)
{
+ struct snd_soc_card *card = codec->component.card;
+ struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
int ret = 0;
pr_debug("%s: %s SDW Clk/Data Gpios\n", __func__,
enable ? "Enable" : "Disable");
if (enable) {
- ret = msm_gpioset_activate(CLIENT_WCD, "sdw_pin");
+ ret = msm_cdc_pinctrl_select_active_state(pdata->sdw_gpio_p);
if (ret) {
pr_err("%s: gpio set cannot be activated %s\n",
__func__, "sdw_pin");
goto done;
}
} else {
- ret = msm_gpioset_suspend(CLIENT_WCD, "sdw_pin");
+ ret = msm_cdc_pinctrl_select_sleep_state(pdata->sdw_gpio_p);
if (ret) {
pr_err("%s: gpio set cannot be de-activated %s\n",
__func__, "sdw_pin");
@@ -782,7 +789,7 @@ static int loopback_mclk_put(struct snd_kcontrol *kcontrol,
ucontrol->value.integer.value[0]);
switch (ucontrol->value.integer.value[0]) {
case 1:
- ret = msm_gpioset_activate(CLIENT_WCD, "int_pdm");
+ ret = msm_cdc_pinctrl_select_active_state(pdata->pdm_gpio_p);
if (ret) {
pr_err("%s: failed to enable the pri gpios: %d\n",
__func__, ret);
@@ -799,8 +806,8 @@ static int loopback_mclk_put(struct snd_kcontrol *kcontrol,
pr_err("%s: failed to enable the MCLK: %d\n",
__func__, ret);
mutex_unlock(&pdata->cdc_int_mclk0_mutex);
- ret = msm_gpioset_suspend(CLIENT_WCD,
- "int_pdm");
+ ret = msm_cdc_pinctrl_select_sleep_state(
+ pdata->pdm_gpio_p);
if (ret)
pr_err("%s: failed to disable the pri gpios: %d\n",
__func__, ret);
@@ -832,7 +839,7 @@ static int loopback_mclk_put(struct snd_kcontrol *kcontrol,
atomic_set(&pdata->int_mclk0_enabled, false);
}
mutex_unlock(&pdata->cdc_int_mclk0_mutex);
- ret = msm_gpioset_suspend(CLIENT_WCD, "int_pdm");
+ ret = msm_cdc_pinctrl_select_sleep_state(pdata->pdm_gpio_p);
if (ret)
pr_err("%s: failed to disable the pri gpios: %d\n",
__func__, ret);
@@ -957,7 +964,7 @@ static int msm_dmic_event(struct snd_soc_dapm_widget *w,
pr_debug("%s: event = %d\n", __func__, event);
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
- ret = msm_gpioset_activate(CLIENT_WCD, "dmic_gpio");
+ ret = msm_cdc_pinctrl_select_active_state(pdata->dmic_gpio_p);
if (ret < 0) {
pr_err("%s: gpio set cannot be activated %sd",
__func__, "dmic_gpio");
@@ -965,7 +972,7 @@ static int msm_dmic_event(struct snd_soc_dapm_widget *w,
}
break;
case SND_SOC_DAPM_POST_PMD:
- ret = msm_gpioset_suspend(CLIENT_WCD, "dmic_gpio");
+ ret = msm_cdc_pinctrl_select_sleep_state(pdata->dmic_gpio_p);
if (ret < 0) {
pr_err("%s: gpio set cannot be de-activated %sd",
__func__, "dmic_gpio");
@@ -992,7 +999,7 @@ static int msm_int_mclk0_event(struct snd_soc_dapm_widget *w,
case SND_SOC_DAPM_POST_PMD:
pr_debug("%s: mclk_res_ref = %d\n",
__func__, atomic_read(&pdata->int_mclk0_rsc_ref));
- ret = msm_gpioset_suspend(CLIENT_WCD, "int_pdm");
+ ret = msm_cdc_pinctrl_select_sleep_state(pdata->pdm_gpio_p);
if (ret < 0) {
pr_err("%s: gpio set cannot be de-activated %sd",
__func__, "int_pdm");
@@ -1177,7 +1184,9 @@ static int msm_int_mi2s_snd_startup(struct snd_pcm_substream *substream)
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_codec *codec = rtd->codec_dais[ANA_CDC]->codec;
int ret = 0;
+ struct msm_asoc_mach_data *pdata = NULL;
+ pdata = snd_soc_card_get_drvdata(codec->component.card);
pr_debug("%s(): substream = %s stream = %d\n", __func__,
substream->name, substream->stream);
@@ -1193,7 +1202,7 @@ static int msm_int_mi2s_snd_startup(struct snd_pcm_substream *substream)
return ret;
}
/* Enable the codec mclk config */
- ret = msm_gpioset_activate(CLIENT_WCD, "int_pdm");
+ ret = msm_cdc_pinctrl_select_active_state(pdata->pdm_gpio_p);
if (ret < 0) {
pr_err("%s: gpio set cannot be activated %s\n",
__func__, "int_pdm");