ENGR00305648-1 ASoC: imx-sgtl5000: Support non-ssi cpu-dai
authorNicolin Chen <Guangyu.Chen@freescale.com>
Tue, 25 Mar 2014 12:56:18 +0000 (20:56 +0800)
committerNitin Garg <nitin.garg@freescale.com>
Wed, 16 Apr 2014 13:58:10 +0000 (08:58 -0500)
The current imx-sgtl5000 driver always attaches the cpu-dai to ssi while
in fact it could be attached to other cpu-dais like SAI. Thus this patch
use a general code to support another cpu-dai. And meanwhile update the
devicetree for i.MX6 Series.

Acked-by: Wang Shengjiu <b02247@freescale.com>
Signed-off-by: Nicolin Chen <Guangyu.Chen@freescale.com>
Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt
arch/arm/boot/dts/imx6q-sabrelite.dts
arch/arm/boot/dts/imx6sx-17x17-arm2.dts
sound/soc/fsl/imx-sgtl5000.c

index e4acdd891e49f9bee64cd18394d64326ac54236c..04bb62b20dd2310697d91728f6c7a7626465b4ad 100644 (file)
@@ -3,7 +3,7 @@ Freescale i.MX audio complex with SGTL5000 codec
 Required properties:
 - compatible : "fsl,imx-audio-sgtl5000"
 - model : The user-visible name of this sound complex
-- ssi-controller : The phandle of the i.MX SSI controller
+- cpu-dai : The phandle of CPU dai
 - audio-codec : The phandle of the SGTL5000 audio codec
 - audio-routing : A list of the connections between audio components.
   Each entry is a pair of strings, the first being the connection's sink,
@@ -38,7 +38,7 @@ sound {
        compatible = "fsl,imx51-babbage-sgtl5000",
                     "fsl,imx-audio-sgtl5000";
        model = "imx51-babbage-sgtl5000";
-       ssi-controller = <&ssi1>;
+       cpu-dai = <&ssi1>;
        audio-codec = <&sgtl5000>;
        audio-routing =
                "MIC_IN", "Mic Jack",
index bdcabc9f5b41680805a25b8daf1503153c69d7ed..73430596baa99a12380d38ba72604abf44e0aefd 100644 (file)
@@ -54,7 +54,7 @@
                compatible = "fsl,imx6q-sabrelite-sgtl5000",
                             "fsl,imx-audio-sgtl5000";
                model = "imx6q-sabrelite-sgtl5000";
-               ssi-controller = <&ssi1>;
+               cpu-dai = <&ssi1>;
                audio-codec = <&codec>;
                audio-routing =
                        "MIC_IN", "Mic Jack",
index 741725ae30b34ee0f44de0e2c86a6f2b7b28da90..23a6b3c87ccdc3e9a788799d7638504c56139948 100644 (file)
@@ -94,7 +94,7 @@
                compatible = "fsl,imx6sx-arm2-sgtl5000",
                           "fsl,imx-audio-sgtl5000";
                model = "imx6sx-arm2-sgtl5000";
-               ssi-controller = <&ssi1>;
+               cpu-dai = <&ssi1>;
                audio-codec = <&codec>;
                audio-routing =
                        "LINE_IN", "Line In Jack",
index 8d491658d419495d7030b8116123f1b869da1994..a80a5d03c7da77ee9fc5392693294537f7eae584 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2012, 2014 Freescale Semiconductor, Inc.
  * Copyright 2012 Linaro Ltd.
  *
  * The code contained herein is licensed under the GNU General Public
@@ -56,13 +56,9 @@ static const struct snd_soc_dapm_widget imx_sgtl5000_dapm_widgets[] = {
        SND_SOC_DAPM_SPK("Ext Spk", NULL),
 };
 
-static int imx_sgtl5000_probe(struct platform_device *pdev)
+static int imx_sgtl5000_audmux_config(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
-       struct device_node *ssi_np, *codec_np;
-       struct platform_device *ssi_pdev;
-       struct i2c_client *codec_dev;
-       struct imx_sgtl5000_data *data;
        int int_port, ext_port;
        int ret;
 
@@ -102,16 +98,33 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
                return ret;
        }
 
-       ssi_np = of_parse_phandle(pdev->dev.of_node, "ssi-controller", 0);
+       return 0;
+}
+
+static int imx_sgtl5000_probe(struct platform_device *pdev)
+{
+       struct device_node *cpu_np, *codec_np;
+       struct platform_device *cpu_pdev;
+       struct i2c_client *codec_dev;
+       struct imx_sgtl5000_data *data;
+       int ret;
+
+       cpu_np = of_parse_phandle(pdev->dev.of_node, "cpu-dai", 0);
        codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0);
-       if (!ssi_np || !codec_np) {
+       if (!cpu_np || !codec_np) {
                dev_err(&pdev->dev, "phandle missing or invalid\n");
                ret = -EINVAL;
                goto fail;
        }
 
-       ssi_pdev = of_find_device_by_node(ssi_np);
-       if (!ssi_pdev) {
+       if (strstr(cpu_np->name, "ssi")) {
+               ret = imx_sgtl5000_audmux_config(pdev);
+               if (ret)
+                       goto fail;
+       }
+
+       cpu_pdev = of_find_device_by_node(cpu_np);
+       if (!cpu_pdev) {
                dev_err(&pdev->dev, "failed to find SSI platform device\n");
                ret = -EINVAL;
                goto fail;
@@ -148,8 +161,8 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
        data->dai.stream_name = "HiFi";
        data->dai.codec_dai_name = "sgtl5000";
        data->dai.codec_of_node = codec_np;
-       data->dai.cpu_of_node = ssi_np;
-       data->dai.platform_of_node = ssi_np;
+       data->dai.cpu_of_node = cpu_np;
+       data->dai.platform_of_node = cpu_np;
        data->dai.init = &imx_sgtl5000_dai_init;
        data->dai.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
                            SND_SOC_DAIFMT_CBM_CFM;
@@ -177,8 +190,8 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
 clk_fail:
        clk_put(data->codec_clk);
 fail:
-       if (ssi_np)
-               of_node_put(ssi_np);
+       if (cpu_np)
+               of_node_put(cpu_np);
        if (codec_np)
                of_node_put(codec_np);