ASoC: rsnd: add DT support to DVC
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 23 Jun 2014 00:59:28 +0000 (17:59 -0700)
committerMark Brown <broonie@linaro.org>
Wed, 2 Jul 2014 11:35:56 +0000 (12:35 +0100)
Now, DVC can use DT

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Documentation/devicetree/bindings/sound/renesas,rsnd.txt
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/dvc.c

index 41a120c2389de5b46881403965c14fbf1ccc90db..aa697abf337e7aa645f435fb9e77b809f62a49df 100644 (file)
@@ -13,6 +13,9 @@ Required properties:
 - rcar_sound,src               : Should contain SRC feature.
                                  The number of SRC subnode should be same as HW.
                                  see below for detail.
+- rcar_sound,dvc               : Should contain DVC feature.
+                                 The number of DVC subnode should be same as HW.
+                                 see below for detail.
 - rcar_sound,dai               : DAI contents.
                                  The number of DAI subnode should be same as HW.
                                  see below for detail.
@@ -40,6 +43,11 @@ rcar_sound: rcar_sound@0xffd90000 {
                <0 0xec540000 0 0x1000>, /* SSIU */
                <0 0xec541000 0 0x1280>; /* SSI */
 
+       rcar_sound,dvc {
+               dvc0: dvc@0 { };
+               dvc1: dvc@1 { };
+       };
+
        rcar_sound,src {
                src0: src@0 { };
                src1: src@1 { };
index 49d9b31b185c4ce8943921d648e1ecd5245aef3c..907d4802fd5c7f3069f703630e78f569d46a4b5a 100644 (file)
@@ -286,7 +286,13 @@ static void rsnd_dma_of_path(struct rsnd_dma *dma,
                        mod[i] = src;
                        src = NULL;
                } else {
-                       mod[i] = dvc;
+                       if ((!is_play) && (this == src))
+                               this = dvc;
+
+                       mod[i] = (is_play) ? src : dvc;
+                       i++;
+                       mod[i] = (is_play) ? dvc : src;
+                       src = NULL;
                        dvc = NULL;
                }
 
@@ -719,12 +725,13 @@ static void rsnd_of_parse_dai(struct platform_device *pdev,
        struct device_node *dai_node,   *dai_np;
        struct device_node *ssi_node,   *ssi_np;
        struct device_node *src_node,   *src_np;
+       struct device_node *dvc_node,   *dvc_np;
        struct device_node *playback, *capture;
        struct rsnd_dai_platform_info *dai_info;
        struct rcar_snd_info *info = rsnd_priv_to_info(priv);
        struct device *dev = &pdev->dev;
        int nr, i;
-       int dai_i, ssi_i, src_i;
+       int dai_i, ssi_i, src_i, dvc_i;
 
        if (!of_data)
                return;
@@ -750,6 +757,7 @@ static void rsnd_of_parse_dai(struct platform_device *pdev,
 
        ssi_node = of_get_child_by_name(dev->of_node, "rcar_sound,ssi");
        src_node = of_get_child_by_name(dev->of_node, "rcar_sound,src");
+       dvc_node = of_get_child_by_name(dev->of_node, "rcar_sound,dvc");
 
 #define mod_parse(name)                                                        \
 if (name##_node) {                                                     \
@@ -785,6 +793,7 @@ if (name##_node) {                                                  \
 
                        mod_parse(ssi);
                        mod_parse(src);
+                       mod_parse(dvc);
 
                        if (playback)
                                of_node_put(playback);
index deef310c75dced97bbbb16ce0d47bbb974f01c1c..9096fb03d0010a53fb806838254aae53a7bf1b86 100644 (file)
@@ -235,6 +235,42 @@ struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id)
        return &((struct rsnd_dvc *)(priv->dvc) + id)->mod;
 }
 
+static void rsnd_of_parse_dvc(struct platform_device *pdev,
+                             const struct rsnd_of_data *of_data,
+                             struct rsnd_priv *priv)
+{
+       struct device_node *node;
+       struct rsnd_dvc_platform_info *dvc_info;
+       struct rcar_snd_info *info = rsnd_priv_to_info(priv);
+       struct device *dev = &pdev->dev;
+       int nr;
+
+       if (!of_data)
+               return;
+
+       node = of_get_child_by_name(dev->of_node, "rcar_sound,dvc");
+       if (!node)
+               return;
+
+       nr = of_get_child_count(node);
+       if (!nr)
+               goto rsnd_of_parse_dvc_end;
+
+       dvc_info = devm_kzalloc(dev,
+                               sizeof(struct rsnd_dvc_platform_info) * nr,
+                               GFP_KERNEL);
+       if (!dvc_info) {
+               dev_err(dev, "dvc info allocation error\n");
+               goto rsnd_of_parse_dvc_end;
+       }
+
+       info->dvc_info          = dvc_info;
+       info->dvc_info_nr       = nr;
+
+rsnd_of_parse_dvc_end:
+       of_node_put(node);
+}
+
 int rsnd_dvc_probe(struct platform_device *pdev,
                   const struct rsnd_of_data *of_data,
                   struct rsnd_priv *priv)
@@ -246,6 +282,8 @@ int rsnd_dvc_probe(struct platform_device *pdev,
        char name[RSND_DVC_NAME_SIZE];
        int i, nr;
 
+       rsnd_of_parse_dvc(pdev, of_data, priv);
+
        nr = info->dvc_info_nr;
        if (!nr)
                return 0;