Alsa-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Markus Pargmann <mpa@pengutronix.de>
To: Mark Brown <broonie@kernel.org>
Cc: Fabio Estevam <fabio.estevam@freescale.com>,
	alsa-devel@alsa-project.org, Alexander Shiyan <shc_work@mail.ru>,
	Timur Tabi <timur@tabi.org>,
	"Li.Xiubo@freescale.com" <Li.Xiubo@freescale.com>,
	kernel@pengutronix.de, Nicolin Chen <Guangyu.Chen@freescale.com>,
	Markus Pargmann <mpa@pengutronix.de>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 10/18] ASoC: fsl-ssi: make fsl,mode property optional
Date: Mon, 14 Apr 2014 15:35:40 +0200
Message-ID: <1397482548-28463-11-git-send-email-mpa@pengutronix.de> (raw)
In-Reply-To: <1397482548-28463-1-git-send-email-mpa@pengutronix.de>

The simple soundcard binding has its own way for specifying the dai
format. To be able to use this binding we have to make the fsl,mode
property optional. As the property is used in existing devicetrees
keep the option around for compatibility reasons.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 sound/soc/fsl/fsl_ssi.c | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index d6d3f0a3..5c4b4bb 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -588,12 +588,9 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-/**
- * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format.
- */
-static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
+static int _fsl_ssi_set_dai_fmt(struct fsl_ssi_private *ssi_private,
+		unsigned int fmt)
 {
-	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
 	struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
 	u32 strcr = 0, stcr, srcr, scr, mask;
 	u8 wm;
@@ -601,7 +598,7 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
 	ssi_private->dai_fmt = fmt;
 
 	if (fsl_ssi_is_i2s_master(ssi_private) && IS_ERR(ssi_private->baudclk)) {
-		dev_err(cpu_dai->dev, "no baudclk needed for master mode\n");
+		dev_err(&ssi_private->pdev->dev, "no baudclk needed for master mode\n");
 		return -EINVAL;
 	}
 
@@ -736,6 +733,17 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
 		fsl_ssi_setup_ac97(ssi_private);
 
 	return 0;
+
+}
+
+/**
+ * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format.
+ */
+static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
+{
+	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
+
+	return _fsl_ssi_set_dai_fmt(ssi_private, fmt);
 }
 
 /**
@@ -1153,7 +1161,6 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 	const uint32_t *iprop;
 	struct resource res;
 	char name[64];
-	bool ac97 = false;
 
 	/* SSIs that are not connected on the board should have a
 	 *      status = "disabled"
@@ -1166,14 +1173,6 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 	if (!of_id || !of_id->data)
 		return -EINVAL;
 
-	sprop = of_get_property(np, "fsl,mode", NULL);
-	if (!sprop) {
-		dev_err(&pdev->dev, "fsl,mode property is necessary\n");
-		return -EINVAL;
-	}
-	if (!strcmp(sprop, "ac97-slave"))
-		ac97 = true;
-
 	ssi_private = devm_kzalloc(&pdev->dev, sizeof(*ssi_private),
 			GFP_KERNEL);
 	if (!ssi_private) {
@@ -1183,10 +1182,19 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 
 	ssi_private->soc = of_id->data;
 
+	sprop = of_get_property(np, "fsl,mode", NULL);
+	if (sprop) {
+		if (!strcmp(sprop, "ac97-slave"))
+			ssi_private->dai_fmt = SND_SOC_DAIFMT_AC97;
+		else if (!strcmp(sprop, "i2s-slave"))
+			ssi_private->dai_fmt = SND_SOC_DAIFMT_I2S |
+				SND_SOC_DAIFMT_CBM_CFM;
+	}
+
 	ssi_private->use_dma = !of_property_read_bool(np,
 			"fsl,fiq-stream-filter");
 
-	if (ac97) {
+	if (fsl_ssi_is_ac97(ssi_private)) {
 		memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_ac97_dai,
 				sizeof(fsl_ssi_ac97_dai));
 
@@ -1297,6 +1305,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 	}
 
 done:
+	if (ssi_private->dai_fmt)
+		_fsl_ssi_set_dai_fmt(ssi_private, ssi_private->dai_fmt);
+
 	return 0;
 
 error_sound_card:
-- 
1.9.1

  parent reply index

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-14 13:35 [PATCH v3 00/18] ASoC: fsl-ssi: Driver cleanup Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 01/18] ASoC: fsl-ssi: Fix register values when disabling Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 02/18] ASoC: fsl-ssi: Move debugging to seperate file Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 03/18] ASoC: fsl-ssi: Use dev_name for DAI driver struct Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 04/18] ASoC: fsl-ssi: Move imx-specific probe to seperate function Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 05/18] ASoC: fsl-ssi: Remove useless DMA code Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 06/18] ASoC: fsl-ssi: Cleanup probe function Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 07/18] ASoC: fsl-ssi: Remove unnecessary variables from ssi_private Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 08/18] ASoC: fsl-ssi: introduce SoC specific data Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 09/18] ASoC: fsl-ssi: Only enable baudclk when used Markus Pargmann
2014-04-14 15:28   ` Nicolin Chen
2014-04-16  7:27     ` Markus Pargmann
2014-04-16  8:08       ` Nicolin Chen
2014-04-16  8:43         ` Markus Pargmann
2014-04-16  8:40           ` Nicolin Chen
2014-04-16 17:42         ` Mark Brown
2014-04-17 13:46       ` Timur Tabi
2014-04-14 13:35 ` Markus Pargmann [this message]
2014-04-14 13:35 ` [PATCH v3 11/18] ASoC: fsl-ssi: Transmit enable synchronization Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 12/18] ASoC: fsl-ssi: Move fsl_ssi_set_dai_sysclk above fsl_ssi_hw_params Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 13/18] ASoC: fsl-ssi: set bitclock in master mode from hw_params Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 14/18] ASoC: fsl-ssi: remove unnecessary spinlock Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 15/18] ASoC: fsl-ssi: Allow first stream to set the bitclock Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 16/18] ASoC: fsl-ssi: Set framerate divider correctly for i2s master mode Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 17/18] ASoC: fsl-ssi: reorder and document fsl_ssi_private Markus Pargmann
2014-04-14 13:35 ` [PATCH v3 18/18] ASoC: fsl-ssi: Use regmap Markus Pargmann
2014-04-24 11:44 ` [PATCH v3 00/18] ASoC: fsl-ssi: Driver cleanup Mark Brown
2014-04-28  8:54   ` Markus Pargmann
2014-04-29 16:22     ` Mark Brown
2014-04-30  2:01       ` Li.Xiubo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397482548-28463-11-git-send-email-mpa@pengutronix.de \
    --to=mpa@pengutronix.de \
    --cc=Guangyu.Chen@freescale.com \
    --cc=Li.Xiubo@freescale.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=fabio.estevam@freescale.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=shc_work@mail.ru \
    --cc=timur@tabi.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Alsa-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/alsa-devel/0 alsa-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 alsa-devel alsa-devel/ https://lore.kernel.org/alsa-devel \
		alsa-devel@alsa-project.org
	public-inbox-index alsa-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.alsa-project.alsa-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git