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

Commit 27b1bdb3 authored by Banajit Goswami's avatar Banajit Goswami
Browse files

ASoC: msm8974: Update PCM MUX for 8974Pro variant



MSM8974Pro aa/ab/ac have different addresses for MUX register
which selects the same set of GPIO lines between PCM and MI2S
devices. Update PCM/MI2S MUX register addresses for MSM8974Pro

CRs-fixed: 563134
Change-Id: Icec7bcd77fe59f6f10474fd99aa2f37955d9afc1
Signed-off-by: default avatarBanajit Goswami <bgoswami@codeaurora.org>
parent c07b9ea7
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -426,6 +426,17 @@ Example:
Required properties:
- compatible : "qcom,msm8974-audio-taiko"
- qcom,model : The user-visible name of this sound card.
- reg : Offset and length of the register region(s) for MI2S/PCM MUX
- reg-names : Register region name(s) referenced in reg above
	 Required register resource entries are:
	 "lpaif_pri_mode_muxsel": Physical address of MUX to select between
				  Primary PCM and Primary MI2S
	 "lpaif_sec_mode_muxsel": Physical address of MUX to select between
				  Secondary PCM and Secondary MI2S
	 "lpaif_tert_mode_muxsel": Physical address of MUX to select between
				   Primary PCM and Tertiary MI2S
	 "lpaif_quat_mode_muxsel": Physical address of MUX to select between
				   Secondary PCM and Quarternary MI2S
- qcom,audio-routing : A list of the connections between audio components.
  Each entry is a pair of strings, the first being the connection's sink,
  the second being the connection's source.
+8 −0
Original line number Diff line number Diff line
@@ -773,6 +773,14 @@
	sound {
		compatible = "qcom,msm8974-audio-taiko";
		qcom,model = "msm8974-taiko-snd-card";
		reg = <0xfe02b000 0x4>,
		      <0xfe02c000 0x4>,
		      <0xfe02d000 0x4>,
		      <0xfe02e000 0x4>;
		reg-names = "lpaif_pri_mode_muxsel",
			    "lpaif_sec_mode_muxsel",
			    "lpaif_tert_mode_muxsel",
			    "lpaif_quat_mode_muxsel";

		qcom,audio-routing =
			"RX_BIAS", "MCLK",
+11 −0
Original line number Diff line number Diff line
@@ -1555,6 +1555,17 @@
			< 2265600 1728000 7448 /* 931 MHz */ >,
			< 2457600 1728000 7448 /* 931 MHz */ >;
	};

	sound {
		reg = <0xfe02c000 0x4>,
		      <0xfe02d000 0x4>,
		      <0xfe02e000 0x4>,
		      <0xfe02f000 0x4>;
		reg-names = "lpaif_pri_mode_muxsel",
			    "lpaif_sec_mode_muxsel",
			    "lpaif_tert_mode_muxsel",
			    "lpaif_quat_mode_muxsel";
	};
};

/* GPU overrides */
+49 −32
Original line number Diff line number Diff line
@@ -58,16 +58,9 @@ static int msm8974_auxpcm_rate = 8000;
#define LO_2_SPK_AMP	0x4
#define LO_4_SPK_AMP	0x8

#define LPAIF_OFFSET 0xFE000000
#define LPAIF_PRI_MODE_MUXSEL (LPAIF_OFFSET + 0x2B000)
#define LPAIF_SEC_MODE_MUXSEL (LPAIF_OFFSET + 0x2C000)
#define LPAIF_TER_MODE_MUXSEL (LPAIF_OFFSET + 0x2D000)
#define LPAIF_QUAD_MODE_MUXSEL (LPAIF_OFFSET + 0x2E000)

#define I2S_PCM_SEL 1
#define I2S_PCM_SEL_OFFSET 1


#define WCD9XXX_MBHC_DEF_BUTTONS 8
#define WCD9XXX_MBHC_DEF_RLOADS 5
#define TAIKO_EXT_CLK_RATE 9600000
@@ -146,6 +139,7 @@ struct msm_auxpcm_gpio {
struct msm_auxpcm_ctrl {
	struct msm_auxpcm_gpio *pin_data;
	u32 cnt;
	void __iomem *mux;
};

struct msm8974_asoc_mach_data {
@@ -173,9 +167,6 @@ static char *msm_sec_auxpcm_gpio_name[][2] = {
	{"SEC_AUXPCM_DOUT",      "qcom,sec-auxpcm-gpio-dout"},
};

void *lpaif_pri_muxsel_virt_addr;
void *lpaif_sec_muxsel_virt_addr;

struct msm8974_liquid_dock_dev {
	int dock_plug_gpio;
	int dock_plug_irq;
@@ -1190,12 +1181,14 @@ static int msm_prim_auxpcm_startup(struct snd_pcm_substream *substream)
		goto err;
	}
	if (atomic_inc_return(&prim_auxpcm_rsc_ref) == 1) {
		if (lpaif_pri_muxsel_virt_addr != NULL)
		if (auxpcm_ctrl->mux != NULL) {
			iowrite32(I2S_PCM_SEL << I2S_PCM_SEL_OFFSET,
				lpaif_pri_muxsel_virt_addr);
		else
			pr_err("%s lpaif_pri_muxsel_virt_addr is NULL\n",
				 __func__);
				  auxpcm_ctrl->mux);
		} else {
			pr_err("%s: Pri AUXPCM MUX addr is NULL\n", __func__);
			ret = -EINVAL;
			goto err;
		}
		ret = msm_aux_pcm_get_gpios(auxpcm_ctrl);
	}
	if (ret < 0) {
@@ -1245,12 +1238,14 @@ static int msm_sec_auxpcm_startup(struct snd_pcm_substream *substream)
		goto err;
	}
	if (atomic_inc_return(&sec_auxpcm_rsc_ref) == 1) {
		if (lpaif_sec_muxsel_virt_addr != NULL)
		if (auxpcm_ctrl->mux != NULL) {
			iowrite32(I2S_PCM_SEL << I2S_PCM_SEL_OFFSET,
				lpaif_sec_muxsel_virt_addr);
		else
			pr_err("%s lpaif_sec_muxsel_virt_addr is NULL\n",
				 __func__);
				  auxpcm_ctrl->mux);
		} else {
			pr_err("%s Sec AUXPCM MUX addr is NULL\n", __func__);
			ret = -EINVAL;
			goto err;
		}
		ret = msm_aux_pcm_get_gpios(auxpcm_ctrl);
	}
	if (ret < 0) {
@@ -2679,6 +2674,8 @@ static int msm8974_asoc_machine_probe(struct platform_device *pdev)
	int ret;
	const char *auxpcm_pri_gpio_set = NULL;
	const char *prop_name_ult_lo_gpio = "qcom,ext-ult-lo-amp-gpio";
	struct resource	*pri_muxsel;
	struct resource	*sec_muxsel;

	if (!pdev->dev.of_node) {
		dev_err(&pdev->dev, "No platform supplied from device tree\n");
@@ -2804,7 +2801,6 @@ static int msm8974_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) {
@@ -2831,28 +2827,49 @@ static int msm8974_asoc_machine_probe(struct platform_device *pdev)
		goto err1;
	}
	if (!strcmp(auxpcm_pri_gpio_set, "prim-gpio-prim")) {
		lpaif_pri_muxsel_virt_addr = ioremap(LPAIF_PRI_MODE_MUXSEL, 4);
		pri_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
						"lpaif_pri_mode_muxsel");
	} else if (!strcmp(auxpcm_pri_gpio_set, "prim-gpio-tert")) {
		lpaif_pri_muxsel_virt_addr = ioremap(LPAIF_TER_MODE_MUXSEL, 4);
		pri_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
						"lpaif_tert_mode_muxsel");
	} else {
		dev_err(&pdev->dev, "Invalid value %s for AUXPCM GPIO set\n",
			auxpcm_pri_gpio_set);
		ret = -EINVAL;
		goto err1;
	}
	if (lpaif_pri_muxsel_virt_addr == NULL) {
	if (!pri_muxsel) {
		dev_err(&pdev->dev, "MUX addr invalid for primary AUXPCM\n");
			ret = -ENODEV;
			goto err1;
	} else {
		pdata->pri_auxpcm_ctrl->mux = ioremap(pri_muxsel->start,
						    resource_size(pri_muxsel));
		if (pdata->pri_auxpcm_ctrl->mux == NULL) {
			pr_err("%s Pri muxsel virt addr is null\n", __func__);
			ret = -EINVAL;
			goto err1;
		}
	lpaif_sec_muxsel_virt_addr = ioremap(LPAIF_SEC_MODE_MUXSEL, 4);
	if (lpaif_sec_muxsel_virt_addr == NULL) {
	}

	sec_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
						"lpaif_sec_mode_muxsel");
	if (!sec_muxsel) {
		dev_err(&pdev->dev, "MUX addr invalid for secondary AUXPCM\n");
		ret = -ENODEV;
		goto err2;
	}
	pdata->sec_auxpcm_ctrl->mux = ioremap(sec_muxsel->start,
					     resource_size(sec_muxsel));
	if (pdata->sec_auxpcm_ctrl->mux == NULL) {
		pr_err("%s Sec muxsel virt addr is null\n", __func__);
		ret = -EINVAL;
		goto err1;
		goto err2;
	}
	return 0;

err2:
	iounmap(pdata->pri_auxpcm_ctrl->mux);
err1:
	if (ext_ult_lo_amp_gpio > 0)
		gpio_free(ext_ult_lo_amp_gpio);
@@ -2905,8 +2922,8 @@ static int msm8974_asoc_machine_remove(struct platform_device *pdev)
		msm8974_liquid_dock_dev = NULL;
	}

	iounmap(lpaif_pri_muxsel_virt_addr);
	iounmap(lpaif_sec_muxsel_virt_addr);
	iounmap(pdata->pri_auxpcm_ctrl->mux);
	iounmap(pdata->sec_auxpcm_ctrl->mux);
	snd_soc_unregister_card(card);

	return 0;