ASoC: sm6150: Use FSA for USBC gnd-mic swap
USBC gnd mic swap is taken care of by FSA4480. Gpio does not need to be swapped for this purpose. CRs-Fixed: 2323772 Change-Id: Ida490995761ec5361ff2302b990d3c6fe1f32f85 Signed-off-by: Vatsal Bucha <vbucha@codeaurora.org>
Цей коміт міститься в:
@@ -22,6 +22,7 @@
|
|||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/of_device.h>
|
||||||
#include <linux/pm_qos.h>
|
#include <linux/pm_qos.h>
|
||||||
|
#include <linux/soc/qcom/fsa4480-i2c.h>
|
||||||
#include <sound/core.h>
|
#include <sound/core.h>
|
||||||
#include <sound/soc.h>
|
#include <sound/soc.h>
|
||||||
#include <sound/soc-dapm.h>
|
#include <sound/soc-dapm.h>
|
||||||
@@ -202,6 +203,7 @@ struct msm_asoc_mach_data {
|
|||||||
struct device_node *hph_en1_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 *hph_en0_gpio_p; /* used by pinctrl API */
|
||||||
bool is_afe_config_done;
|
bool is_afe_config_done;
|
||||||
|
struct device_node *fsa_handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct msm_asoc_wcd93xx_codec {
|
struct msm_asoc_wcd93xx_codec {
|
||||||
@@ -4465,88 +4467,14 @@ done:
|
|||||||
|
|
||||||
static bool msm_usbc_swap_gnd_mic(struct snd_soc_codec *codec, bool active)
|
static bool msm_usbc_swap_gnd_mic(struct snd_soc_codec *codec, bool active)
|
||||||
{
|
{
|
||||||
int value = 0;
|
|
||||||
bool ret = 0;
|
|
||||||
struct snd_soc_card *card = codec->component.card;
|
struct snd_soc_card *card = codec->component.card;
|
||||||
struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
|
struct msm_asoc_mach_data *pdata =
|
||||||
struct pinctrl_state *en2_pinctrl_active;
|
snd_soc_card_get_drvdata(card);
|
||||||
struct pinctrl_state *en2_pinctrl_sleep;
|
|
||||||
|
|
||||||
if (!pdata->usbc_en2_gpio_p) {
|
if (!pdata->fsa_handle)
|
||||||
if (active) {
|
|
||||||
/* if active and usbc_en2_gpio undefined, get pin */
|
|
||||||
pdata->usbc_en2_gpio_p = devm_pinctrl_get(card->dev);
|
|
||||||
if (IS_ERR_OR_NULL(pdata->usbc_en2_gpio_p)) {
|
|
||||||
dev_err(card->dev,
|
|
||||||
"%s: Can't get EN2 gpio pinctrl:%ld\n",
|
|
||||||
__func__,
|
|
||||||
PTR_ERR(pdata->usbc_en2_gpio_p));
|
|
||||||
pdata->usbc_en2_gpio_p = NULL;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* if not active and usbc_en2_gpio undefined, return */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pdata->usbc_en2_gpio = of_get_named_gpio(card->dev->of_node,
|
|
||||||
"qcom,usbc-analog-en2-gpio", 0);
|
|
||||||
if (!gpio_is_valid(pdata->usbc_en2_gpio)) {
|
|
||||||
dev_err(card->dev, "%s, property %s not in node %s",
|
|
||||||
__func__, "qcom,usbc-analog-en2-gpio",
|
|
||||||
card->dev->of_node->full_name);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
en2_pinctrl_active = pinctrl_lookup_state(
|
return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
|
||||||
pdata->usbc_en2_gpio_p, "aud_active");
|
|
||||||
if (IS_ERR_OR_NULL(en2_pinctrl_active)) {
|
|
||||||
dev_err(card->dev,
|
|
||||||
"%s: Cannot get aud_active pinctrl state:%ld\n",
|
|
||||||
__func__, PTR_ERR(en2_pinctrl_active));
|
|
||||||
ret = false;
|
|
||||||
goto err_lookup_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
en2_pinctrl_sleep = pinctrl_lookup_state(
|
|
||||||
pdata->usbc_en2_gpio_p, "aud_sleep");
|
|
||||||
if (IS_ERR_OR_NULL(en2_pinctrl_sleep)) {
|
|
||||||
dev_err(card->dev,
|
|
||||||
"%s: Cannot get aud_sleep pinctrl state:%ld\n",
|
|
||||||
__func__, PTR_ERR(en2_pinctrl_sleep));
|
|
||||||
ret = false;
|
|
||||||
goto err_lookup_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if active and usbc_en2_gpio_p defined, swap using usbc_en2_gpio_p */
|
|
||||||
if (active) {
|
|
||||||
dev_dbg(codec->dev, "%s: enter\n", __func__);
|
|
||||||
if (pdata->usbc_en2_gpio_p) {
|
|
||||||
value = gpio_get_value_cansleep(pdata->usbc_en2_gpio);
|
|
||||||
if (value)
|
|
||||||
pinctrl_select_state(pdata->usbc_en2_gpio_p,
|
|
||||||
en2_pinctrl_sleep);
|
|
||||||
else
|
|
||||||
pinctrl_select_state(pdata->usbc_en2_gpio_p,
|
|
||||||
en2_pinctrl_active);
|
|
||||||
} else if (pdata->usbc_en2_gpio >= 0) {
|
|
||||||
value = gpio_get_value_cansleep(pdata->usbc_en2_gpio);
|
|
||||||
gpio_set_value_cansleep(pdata->usbc_en2_gpio, !value);
|
|
||||||
}
|
|
||||||
pr_debug("%s: swap select switch %d to %d\n", __func__,
|
|
||||||
value, !value);
|
|
||||||
ret = true;
|
|
||||||
} else {
|
|
||||||
/* if not active, release usbc_en2_gpio_p pin */
|
|
||||||
pinctrl_select_state(pdata->usbc_en2_gpio_p,
|
|
||||||
en2_pinctrl_sleep);
|
|
||||||
}
|
|
||||||
|
|
||||||
err_lookup_state:
|
|
||||||
devm_pinctrl_put(pdata->usbc_en2_gpio_p);
|
|
||||||
pdata->usbc_en2_gpio_p = NULL;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool msm_swap_gnd_mic(struct snd_soc_codec *codec, bool active)
|
static bool msm_swap_gnd_mic(struct snd_soc_codec *codec, bool active)
|
||||||
@@ -8459,6 +8387,18 @@ static int msm_asoc_machine_probe(struct platform_device *pdev)
|
|||||||
"qcom,us-euro-gpios");
|
"qcom,us-euro-gpios");
|
||||||
wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
|
wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wcd_mbhc_cfg.enable_usbc_analog) {
|
||||||
|
wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
|
||||||
|
|
||||||
|
pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
|
||||||
|
"fsa4480-i2c-handle", 0);
|
||||||
|
if (!pdata->fsa_handle)
|
||||||
|
dev_err(&pdev->dev,
|
||||||
|
"property %s not detected in node %s\n",
|
||||||
|
"fsa4480-i2c-handle",
|
||||||
|
pdev->dev.of_node->full_name);
|
||||||
|
}
|
||||||
/* Parse pinctrl info from devicetree */
|
/* Parse pinctrl info from devicetree */
|
||||||
ret = msm_get_pinctrl(pdev);
|
ret = msm_get_pinctrl(pdev);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
Посилання в новій задачі
Заблокувати користувача