Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bbcb7758 authored by Stephen Oglesby's avatar Stephen Oglesby Committed by Kyle Yan
Browse files

ASoC: msmcobalt: Switch ground/mic swap GPIO control to pinctrl



Switch to swap ground and mic headset poles is controlled by a
GPIO on the Apps processor instead of the PMIC, and therefore
software logic must change to use pinctrl APIs

CRs-fixed: 1019254
Change-Id: Ibccddc82b18614ddbe6ef9c9720b3de1ce00163e
Signed-off-by: default avatarStephen Oglesby <soglesby@codeaurora.org>
parent 402fc23f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -336,6 +336,12 @@ Required properties:

 - compatible : "qcom,msm-cpe-lsm"

* wcd_us_euro_gpio

Required properties:

 - compatible : "qcom,msm-cdc-pinctrl"

* msm-dai-slim

Required properties:
+21 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ struct msm_cdc_pinctrl_info {
	struct pinctrl *pinctrl;
	struct pinctrl_state *pinctrl_active;
	struct pinctrl_state *pinctrl_sleep;
	bool state;
};

static struct msm_cdc_pinctrl_info *msm_cdc_pinctrl_get_gpiodata(
@@ -70,6 +71,7 @@ int msm_cdc_pinctrl_select_sleep_state(struct device_node *np)
		pr_err("%s: pinctrl sleep state is null\n", __func__);
		return -EINVAL;
	}
	gpio_data->state = false;

	return pinctrl_select_state(gpio_data->pinctrl,
				    gpio_data->pinctrl_sleep);
@@ -94,12 +96,31 @@ int msm_cdc_pinctrl_select_active_state(struct device_node *np)
		pr_err("%s: pinctrl active state is null\n", __func__);
		return -EINVAL;
	}
	gpio_data->state = true;

	return pinctrl_select_state(gpio_data->pinctrl,
				    gpio_data->pinctrl_active);
}
EXPORT_SYMBOL(msm_cdc_pinctrl_select_active_state);

/*
 * msm_cdc_pinctrl_get_state: get curren pinctrl state
 * @np: pointer to struct device_node
 *
 * Returns 0 for sleep state, 1 for active state
 */
bool msm_cdc_pinctrl_get_state(struct device_node *np)
{
	struct msm_cdc_pinctrl_info *gpio_data;

	gpio_data = msm_cdc_pinctrl_get_gpiodata(np);
	if (!gpio_data)
		return -EINVAL;

	return gpio_data->state;
}
EXPORT_SYMBOL(msm_cdc_pinctrl_get_state);

static int msm_cdc_pinctrl_probe(struct platform_device *pdev)
{
	int ret = 0;
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#ifdef CONFIG_MSM_CDC_PINCTRL
extern int msm_cdc_pinctrl_select_sleep_state(struct device_node *);
extern int msm_cdc_pinctrl_select_active_state(struct device_node *);
extern bool msm_cdc_pinctrl_get_state(struct device_node *);

#else
int msm_cdc_pinctrl_select_sleep_state(struct device_node *np)
+23 −8
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <linux/module.h>
#include <linux/switch.h>
#include <linux/input.h>
#include <linux/mfd/msm-cdc-pinctrl.h>
#include <sound/core.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
@@ -107,9 +108,10 @@ struct msm_wsa881x_dev_info {

struct msm_asoc_mach_data {
	u32 mclk_freq;
	int us_euro_gpio;
	int hph_en1_gpio;
	int hph_en0_gpio;
	int us_euro_gpio; /* used by gpio driver API */
	struct device_node *us_euro_gpio_p; /* used by pinctrl API */
	struct snd_info_entry *codec_root;
};

@@ -1155,10 +1157,21 @@ static bool msm_swap_gnd_mic(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 value = gpio_get_value_cansleep(pdata->us_euro_gpio);
	int value;

	pr_debug("%s: swap select switch %d to %d\n", __func__, value, !value);
	if (pdata->us_euro_gpio_p) {
		value = msm_cdc_pinctrl_get_state(pdata->us_euro_gpio_p);
		if (value)
			msm_cdc_pinctrl_select_sleep_state(
							pdata->us_euro_gpio_p);
		else
			msm_cdc_pinctrl_select_active_state(
							pdata->us_euro_gpio_p);
	} else if (pdata->us_euro_gpio >= 0) {
		value = gpio_get_value_cansleep(pdata->us_euro_gpio);
		gpio_set_value_cansleep(pdata->us_euro_gpio, !value);
	}
	pr_debug("%s: swap select switch %d to %d\n", __func__, value, !value);
	return true;
}

@@ -3517,13 +3530,15 @@ static int msm_asoc_machine_probe(struct platform_device *pdev)
	 */
	pdata->us_euro_gpio = of_get_named_gpio(pdev->dev.of_node,
				"qcom,us-euro-gpios", 0);
	if (pdata->us_euro_gpio < 0) {
	if (pdata->us_euro_gpio < 0)
		pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
					"qcom,us-euro-gpios", 0);
	if ((pdata->us_euro_gpio < 0) && (!pdata->us_euro_gpio_p)) {
		dev_info(&pdev->dev, "property %s not detected in node %s",
			"qcom,us-euro-gpios",
			pdev->dev.of_node->full_name);
			"qcom,us-euro-gpios", pdev->dev.of_node->full_name);
	} else {
		dev_dbg(&pdev->dev, "%s detected %d",
			"qcom,us-euro-gpios", pdata->us_euro_gpio);
		dev_dbg(&pdev->dev, "%s detected",
			"qcom,us-euro-gpios");
		wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
	}