|
@@ -22,6 +22,7 @@
|
|
|
#include <linux/input.h>
|
|
|
#include <linux/of_device.h>
|
|
|
#include <linux/pm_qos.h>
|
|
|
+#include <linux/soc/qcom/fsa4480-i2c.h>
|
|
|
#include <sound/core.h>
|
|
|
#include <sound/soc.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_en0_gpio_p; /* used by pinctrl API */
|
|
|
bool is_afe_config_done;
|
|
|
+ struct device_node *fsa_handle;
|
|
|
};
|
|
|
|
|
|
struct msm_asoc_wcd93xx_codec {
|
|
@@ -4601,88 +4603,14 @@ done:
|
|
|
|
|
|
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 msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
|
|
|
- struct pinctrl_state *en2_pinctrl_active;
|
|
|
- struct pinctrl_state *en2_pinctrl_sleep;
|
|
|
-
|
|
|
- if (!pdata->usbc_en2_gpio_p) {
|
|
|
- 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;
|
|
|
- }
|
|
|
- }
|
|
|
+ struct msm_asoc_mach_data *pdata =
|
|
|
+ snd_soc_card_get_drvdata(card);
|
|
|
|
|
|
- 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);
|
|
|
+ if (!pdata->fsa_handle)
|
|
|
return false;
|
|
|
- }
|
|
|
-
|
|
|
- en2_pinctrl_active = pinctrl_lookup_state(
|
|
|
- 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;
|
|
|
+ return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
|
|
|
}
|
|
|
|
|
|
static bool msm_swap_gnd_mic(struct snd_soc_codec *codec, bool active)
|
|
@@ -8595,6 +8523,18 @@ static int msm_asoc_machine_probe(struct platform_device *pdev)
|
|
|
"qcom,us-euro-gpios");
|
|
|
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 */
|
|
|
ret = msm_get_pinctrl(pdev);
|
|
|
if (!ret) {
|