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

Commit 2c28ca7a authored by Aravind Kumar's avatar Aravind Kumar
Browse files

ASoC: support external codec for 8916



8916 supports external audio codec (tapan) over I2C\I2S.
Add suport for tapan audio codec and also add pinctrl support
for codec reset GPIO.

Change-Id: I3f2820139c644bd993c17e12e27f7a54f58f692e
Signed-off-by: default avatarAravind Kumar <akumark@codeaurora.org>
parent 6212b769
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -524,6 +524,7 @@ normally open.
switch type on target typically the switch type will be normally open or
normally close, value for this property 0 for normally close and 1 for
normally open.
- qcom,audio-routing : A list of the connections between audio components.
- pinctrl-names : Pincntrl entries to configure the PDM gpio lines and
		  cross connection switch gpio accordingly
- pinctrl-0 : This explains the active state of the PDM gpio lines
@@ -532,6 +533,14 @@ normally open.
	      gpio lines
- pinctrl-3 : This explains the suspend state of the cross connection
              gpio lines
- qcom,tapan-mclk-clk-freq : Tapan mclk Freq in Hz.
- qcom,prim-auxpcm-gpio-clk  : GPIO on which Primary AUXPCM clk signal is coming.
- qcom,prim-auxpcm-gpio-sync : GPIO on which Primary AUXPCM SYNC signal is coming.
- qcom,prim-auxpcm-gpio-din  : GPIO on which Primary AUXPCM DIN signal is coming.
- qcom,prim-auxpcm-gpio-dout : GPIO on which Primary AUXPCM DOUT signal is coming.
- qcom,prim-auxpcm-gpio-set : set of GPIO lines used for Primary AUXPCM port
- qcom,tapan-codec-9302: Indicates that this device node is for WCD9302 audio
			    codec.

Optional Properties:
- qcom,us-euro-gpios : GPIO on which gnd/mic swap signal is coming.
@@ -564,6 +573,13 @@ Example:
		pinctrl-1 = <&cdc_pdm_lines_sus>;
		pinctrl-2 = <&cross_conn_det_act>;
		pinctrl-3 = <&cross_conn_det_sus>;
		qcom,tapan-mclk-clk-freq = <9600000>;
		qcom,prim-auxpcm-gpio-clk  = <&msm_gpio 63 0>;
		qcom,prim-auxpcm-gpio-sync = <&msm_gpio 64 0>;
		qcom,prim-auxpcm-gpio-din  = <&msm_gpio 65 0>;
		qcom,prim-auxpcm-gpio-dout = <&msm_gpio 66 0>;
		qcom,prim-auxpcm-gpio-set = "prim-gpio-prim";
		qcom,tapan-codec-9302;
	};

* MSM8974 ASoC Machine driver
+2 −0
Original line number Diff line number Diff line
@@ -99,6 +99,8 @@ obj-$(CONFIG_WCD9306_CODEC) += wcd9xxx-core.o wcd9xxx-irq.o\
						wcd9xxx-slimslave.o wcd9xxx-core-resource.o
obj-$(CONFIG_WCD9330_CODEC)	+= wcd9xxx-core.o wcd9xxx-irq.o wcd9xxx-slimslave.o\
						wcd9xxx-core-resource.o
obj-$(CONFIG_SND_SOC_MSM8X16_WCD)	+= wcd9xxx-core.o wcd9xxx-irq.o\
						wcd9xxx-slimslave.o wcd9xxx-core-resource.o

ifeq ($(CONFIG_SA1100_ASSABET),y)
obj-$(CONFIG_MCP_UCB1200)	+= ucb1x00-assabet.o
+73 −7
Original line number Diff line number Diff line
@@ -64,6 +64,40 @@ struct wcd9xxx_i2c {
	int mod_id;
};

struct pinctrl_info {
	struct pinctrl *pinctrl;
	struct pinctrl_state *extncodec_sus;
	struct pinctrl_state *extncodec_act;
};

static struct pinctrl_info pinctrl_info;

static int extcodec_get_pinctrl(struct device *dev)
{
	struct pinctrl *pinctrl;

	pinctrl = pinctrl_get(dev);
	if (IS_ERR(pinctrl)) {
		pr_err("%s: Unable to get pinctrl handle\n", __func__);
		return -EINVAL;
	}
	pinctrl_info.pinctrl = pinctrl;
	/* get all the states handles from Device Tree */
	pinctrl_info.extncodec_sus = pinctrl_lookup_state(pinctrl, "suspend");
	if (IS_ERR(pinctrl_info.extncodec_sus)) {
		pr_err("%s: Unable to get pinctrl disable state handle, err: %ld\n",
				__func__, PTR_ERR(pinctrl_info.extncodec_sus));
		return -EINVAL;
	}
	pinctrl_info.extncodec_act = pinctrl_lookup_state(pinctrl, "active");
	if (IS_ERR(pinctrl_info.extncodec_act)) {
		pr_err("%s: Unable to get pinctrl disable state handle, err: %ld\n",
				__func__, PTR_ERR(pinctrl_info.extncodec_act));
		return -EINVAL;
	}
	return 0;
}

static int wcd9xxx_dt_parse_vreg_info(struct device *dev,
				      struct wcd9xxx_regulator *vreg,
				      const char *vreg_name, bool ondemand);
@@ -512,7 +546,8 @@ static int wcd9xxx_reset(struct wcd9xxx *wcd9xxx)
{
	int ret;

	if (wcd9xxx->reset_gpio && wcd9xxx->slim_device_bootup) {
	if (wcd9xxx->reset_gpio && wcd9xxx->slim_device_bootup
			&& !wcd9xxx->use_pinctrl) {
		ret = gpio_request(wcd9xxx->reset_gpio, "CDC_RESET");
		if (ret) {
			pr_err("%s: Failed to request gpio %d\n", __func__,
@@ -522,19 +557,44 @@ static int wcd9xxx_reset(struct wcd9xxx *wcd9xxx)
		}
	}
	if (wcd9xxx->reset_gpio) {
		if (wcd9xxx->use_pinctrl) {
			/* Reset the CDC PDM TLMM pins to a default state */
			ret = pinctrl_select_state(pinctrl_info.pinctrl,
				pinctrl_info.extncodec_act);
			if (ret != 0) {
				pr_err("%s: Failed to enable gpio pins; ret=%d\n",
						__func__, ret);
				return ret;
			}
			gpio_set_value_cansleep(wcd9xxx->reset_gpio, 0);
			msleep(20);
			gpio_set_value_cansleep(wcd9xxx->reset_gpio, 1);
			msleep(20);
			ret = pinctrl_select_state(pinctrl_info.pinctrl,
					pinctrl_info.extncodec_sus);
			if (ret != 0) {
				pr_err("%s: Failed to suspend reset pins, ret: %d\n",
						__func__, ret);
				return ret;
			}
		} else {
			gpio_direction_output(wcd9xxx->reset_gpio, 0);
			msleep(20);
			gpio_direction_output(wcd9xxx->reset_gpio, 1);
			msleep(20);
		}
	}
	return 0;
}

static void wcd9xxx_free_reset(struct wcd9xxx *wcd9xxx)
{
	if (wcd9xxx->reset_gpio) {
		if (!wcd9xxx->use_pinctrl) {
			gpio_free(wcd9xxx->reset_gpio);
			wcd9xxx->reset_gpio = 0;
		} else
			pinctrl_put(pinctrl_info.pinctrl);
	}
}

@@ -1235,6 +1295,12 @@ static int wcd9xxx_i2c_probe(struct i2c_client *client,
			ret = -EINVAL;
			goto fail;
		}
		ret = extcodec_get_pinctrl(&client->dev);
		if (ret < 0)
			wcd9xxx->use_pinctrl = false;
		else
			wcd9xxx->use_pinctrl = true;

		if (i2c_check_functionality(client->adapter,
					    I2C_FUNC_I2C) == 0) {
			dev_dbg(&client->dev, "can't talk I2C?\n");
+1 −0
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@ struct wcd9xxx {
	struct wcd9xxx_ch *rx_chs;
	struct wcd9xxx_ch *tx_chs;
	u32 mclk_rate;
	u16 use_pinctrl;

	const struct wcd9xxx_codec_type *codec_type;
};
+2 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ snd-soc-wcd9330-objs := wcd9330.o wcd9330-tables.o
snd-soc-wcd9xxx-objs := wcd9xxx-resmgr.o wcd9xxx-mbhc.o wcd9xxx-common.o
snd-soc-msm8x10-wcd-objs := msm8x10-wcd.o msm8x10-wcd-tables.o wcd9xxx-common.o
snd-soc-msm8x16-wcd-objs := msm8x16-wcd.o msm8x16-wcd-tables.o wcd-mbhc-v2.o
snd-soc-msm8x16-wcd-objs += wcd9xxx-common.o wcd9xxx-resmgr.o wcd9xxx-mbhc.o
snd-soc-msm8x16-wcd-objs += wcd9xxx-common.o wcd9306.o wcd9306-tables.o
snd-soc-wcd-cpe-objs := wcd_cpe_services.o wcd_cpe_core.o
snd-soc-wl1273-objs := wl1273.o
snd-soc-wm-adsp-objs := wm_adsp.o
Loading