diff mbox

[2/5] ASoC: pxa: pxa-ssp: add DT bindings

Message ID 1376296961-20564-3-git-send-email-zonque@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Mack Aug. 12, 2013, 8:42 a.m. UTC
The pxa ssp DAI acts as a user of a pxa ssp port, and needs an
appropriate 'port' phandle in DT to reference the upstream.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 .../devicetree/bindings/sound/mrvl,pxa-ssp.txt     | 28 ++++++++++++++++
 sound/soc/pxa/pxa-ssp.c                            | 37 ++++++++++++++++++----
 2 files changed, 59 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/mrvl,pxa-ssp.txt

Comments

Mark Brown Aug. 15, 2013, 10:33 a.m. UTC | #1
On Mon, Aug 12, 2013 at 10:42:38AM +0200, Daniel Mack wrote:
> The pxa ssp DAI acts as a user of a pxa ssp port, and needs an
> appropriate 'port' phandle in DT to reference the upstream.

I've applied this and the rest of the series though I'm not really that
happy about having a binding for the DAI in the DT since there's at best
tenouous hardware there.
Daniel Mack Aug. 15, 2013, 10:51 a.m. UTC | #2
On 15.08.2013 12:33, Mark Brown wrote:
> On Mon, Aug 12, 2013 at 10:42:38AM +0200, Daniel Mack wrote:
>> The pxa ssp DAI acts as a user of a pxa ssp port, and needs an
>> appropriate 'port' phandle in DT to reference the upstream.
> 
> I've applied this and the rest of the series though I'm not really that
> happy about having a binding for the DAI in the DT since there's at best
> tenouous hardware there.
> 

Hmm, and you don't like the approach either of having upstream ports and
assign users to it via phandles?

Also note that the last patch in that series ("ASoC: pxa: add DT
bindings for pxa2xx-pcm") can be omitted, as Lars pointed out. I'll have
to care for a proper solution at some point.


Daniel
Mark Brown Aug. 15, 2013, 1:39 p.m. UTC | #3
On Thu, Aug 15, 2013 at 12:51:31PM +0200, Daniel Mack wrote:

> Hmm, and you don't like the approach either of having upstream ports and
> assign users to it via phandles?

I don't know what that means, sorry.

> Also note that the last patch in that series ("ASoC: pxa: add DT
> bindings for pxa2xx-pcm") can be omitted, as Lars pointed out. I'll have
> to care for a proper solution at some point.

I applied it since we were already adding a dummy device for the DAI.  I
can revert it if this work without that.
Daniel Mack Aug. 15, 2013, 1:43 p.m. UTC | #4
On 15.08.2013 15:39, Mark Brown wrote:
> On Thu, Aug 15, 2013 at 12:51:31PM +0200, Daniel Mack wrote:
> 
>> Hmm, and you don't like the approach either of having upstream ports and
>> assign users to it via phandles?
> 
> I don't know what that means, sorry.

Well, we have the 'real' devices registered in DT like this:

        ssp0: ssp@41000000 {
                compatible = "mrvl,pxa3xx-ssp";
                reg = <0x41000000 0x40>;
                interrupts = <24>;
                clock-names = "pxa27x-ssp.0";
                dmas = <&dma 13
                        &dma 14>;
                dma-names = "rx", "tx";
        };

And users, in that case, a ssp DAI, just reference a port like so:

        ssp_dai0: ssp_dai@0 {
                compatible = "mrvl,pxa-ssp-dai";
                port = <&ssp0>;
        };

Is that something we can live with?


>> Also note that the last patch in that series ("ASoC: pxa: add DT
>> bindings for pxa2xx-pcm") can be omitted, as Lars pointed out. I'll have
>> to care for a proper solution at some point.
> 
> I applied it since we were already adding a dummy device for the DAI.  I
> can revert it if this work without that.

I'll send a cleanup patch once I have a better solution.



Daniel
Mark Brown Aug. 15, 2013, 2:01 p.m. UTC | #5
On Thu, Aug 15, 2013 at 03:43:14PM +0200, Daniel Mack wrote:

> And users, in that case, a ssp DAI, just reference a port like so:

>         ssp_dai0: ssp_dai@0 {
>                 compatible = "mrvl,pxa-ssp-dai";
>                 port = <&ssp0>;
>         };

> Is that something we can live with?

The issue here is that in hardware terms this DAI is just the same thing
as the SSP port that's being referenced so it'd be more natural for the
sound card to just reference the SSP it's using directly rather than
have this DAI sitting in the middle as a proxy.
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/sound/mrvl,pxa-ssp.txt b/Documentation/devicetree/bindings/sound/mrvl,pxa-ssp.txt
new file mode 100644
index 0000000..74c9ba6
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/mrvl,pxa-ssp.txt
@@ -0,0 +1,28 @@ 
+Marvell PXA SSP CPU DAI bindings
+
+Required properties:
+
+	compatible	Must be "mrvl,pxa-ssp-dai"
+	port		A phandle reference to a PXA ssp upstream device
+
+Example:
+
+	/* upstream device */
+
+	ssp0: ssp@41000000 {
+		compatible = "mrvl,pxa3xx-ssp";
+		reg = <0x41000000 0x40>;
+		interrupts = <24>;
+		clock-names = "pxa27x-ssp.0";
+		dmas = <&dma 13
+			&dma 14>;
+		dma-names = "rx", "tx";
+	};
+
+	/* DAI as user */
+
+	ssp_dai0: ssp_dai@0 {
+		compatible = "mrvl,pxa-ssp-dai";
+		port = <&ssp0>;
+	};
+
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index 6f4dd75..19296f2 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -21,6 +21,7 @@ 
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/pxa2xx_ssp.h>
+#include <linux/of.h>
 
 #include <asm/irq.h>
 
@@ -719,6 +720,7 @@  static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd,
 
 static int pxa_ssp_probe(struct snd_soc_dai *dai)
 {
+	struct device *dev = dai->dev;
 	struct ssp_priv *priv;
 	int ret;
 
@@ -726,10 +728,26 @@  static int pxa_ssp_probe(struct snd_soc_dai *dai)
 	if (!priv)
 		return -ENOMEM;
 
-	priv->ssp = pxa_ssp_request(dai->id + 1, "SoC audio");
-	if (priv->ssp == NULL) {
-		ret = -ENODEV;
-		goto err_priv;
+	if (dev->of_node) {
+		struct device_node *ssp_handle;
+
+		ssp_handle = of_parse_phandle(dev->of_node, "port", 0);
+		if (!ssp_handle) {
+			dev_err(dev, "unable to get 'port' phandle\n");
+			return -ENODEV;
+		}
+
+		priv->ssp = pxa_ssp_request_of(ssp_handle, "SoC audio");
+		if (priv->ssp == NULL) {
+			ret = -ENODEV;
+			goto err_priv;
+		}
+	} else {
+		priv->ssp = pxa_ssp_request(dai->id + 1, "SoC audio");
+		if (priv->ssp == NULL) {
+			ret = -ENODEV;
+			goto err_priv;
+		}
 	}
 
 	priv->dai_fmt = (unsigned int) -1;
@@ -798,6 +816,12 @@  static const struct snd_soc_component_driver pxa_ssp_component = {
 	.name		= "pxa-ssp",
 };
 
+#ifdef CONFIG_OF
+static const struct of_device_id pxa_ssp_of_ids[] = {
+	{ .compatible = "mrvl,pxa-ssp-dai" },
+};
+#endif
+
 static int asoc_ssp_probe(struct platform_device *pdev)
 {
 	return snd_soc_register_component(&pdev->dev, &pxa_ssp_component,
@@ -812,8 +836,9 @@  static int asoc_ssp_remove(struct platform_device *pdev)
 
 static struct platform_driver asoc_ssp_driver = {
 	.driver = {
-			.name = "pxa-ssp-dai",
-			.owner = THIS_MODULE,
+		.name = "pxa-ssp-dai",
+		.owner = THIS_MODULE,
+		.of_match_table = of_match_ptr(pxa_ssp_of_ids),
 	},
 
 	.probe = asoc_ssp_probe,