[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <878tt5b9yo.wl%kuninori.morimoto.gx@renesas.com>
Date: Mon, 31 Oct 2016 01:19:19 +0000
From: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
To: Rob Herring <robh+dt@...nel.org>, Mark Brown <broonie@...nel.org>
CC: Linux-ALSA <alsa-devel@...a-project.org>,
Liam Girdwood <lgirdwood@...il.com>,
Simon <horms@...ge.net.au>,
Laurent <laurent.pinchart@...asonboard.com>,
Guennadi <g.liakhovetski@....de>,
Grant Likely <grant.likely@...aro.org>,
Frank Rowand <frowand.list@...il.com>,
Linux-DT <devicetree@...r.kernel.org>,
Linux-Kernel <linux-kernel@...r.kernel.org>
Subject: [PATCH 12/17] ASoC: simple-card-utils: add asoc_simple_card_try_to_probe_graph_card()
From: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
If CPU/Platform side driver probes successfully, and if it is supporting
both previous normal sound card style and graph style DT, it can call
asoc_simple_card_try_to_probe_graph_card().
It checks graph style DT, and do nothing if it was non graph style DT,
or register new simple-graph-card driver if graph style DT.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
---
include/sound/simple_card_utils.h | 8 +++++++
sound/soc/generic/simple-card-utils.c | 45 +++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 4b58954..7006150 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -22,6 +22,10 @@ struct asoc_simple_dai {
struct clk *clk;
};
+struct asoc_simple_graph_card_info {
+ int endpoint_num; /* sound endpoint number */
+};
+
int asoc_simple_card_parse_daifmt(struct device *dev,
struct device_node *node,
struct device_node *codec,
@@ -78,4 +82,8 @@ void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link,
int asoc_simple_card_clean_reference(struct snd_soc_card *card);
+void asoc_simple_card_try_to_probe_graph_card(struct device *dev,
+ struct asoc_simple_graph_card_info *info);
+
+
#endif /* __SIMPLE_CARD_CORE_H */
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 373ada3..85120f5 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -8,6 +8,7 @@
* published by the Free Software Foundation.
*/
#include <linux/clk.h>
+#include <linux/dma-mapping.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_graph.h>
@@ -285,6 +286,50 @@ int asoc_simple_card_clean_reference(struct snd_soc_card *card)
}
EXPORT_SYMBOL_GPL(asoc_simple_card_clean_reference);
+void asoc_simple_card_try_to_probe_graph_card(struct device *dev,
+ struct asoc_simple_graph_card_info *info)
+{
+ struct platform_device_info pdevinfo;
+ struct device_node *node;
+ const char *compatible;
+ int ret;
+
+ node = of_graph_get_top_port(dev);
+ if (!node || !info)
+ /*
+ * It doesn't have graph base sound DT, or its infomation.
+ * Do nothing here, It assumes that system has
+ * normal sound card.
+ */
+ return;
+
+ ret = of_property_read_string(node, "compatible", &compatible);
+ if (ret < 0)
+ goto probe_err;
+
+ /*
+ * FIXME
+ *
+ * It should use of_platform_xxx() instead of
+ * platform_device_register_full() ? but there is no solution.
+ * see also
+ * linux/sound/soc/generic/simple-graph-card.c :: asoc_simple_card_probe
+ */
+
+ memset(&pdevinfo, 0, sizeof(pdevinfo));
+ pdevinfo.parent = dev;
+ pdevinfo.id = PLATFORM_DEVID_AUTO;
+ pdevinfo.name = compatible;
+ pdevinfo.dma_mask = DMA_BIT_MASK(32);
+ pdevinfo.data = info;
+ pdevinfo.size_data = sizeof(*info);
+ platform_device_register_full(&pdevinfo);
+
+probe_err:
+ of_node_put(node);
+}
+EXPORT_SYMBOL_GPL(asoc_simple_card_try_to_probe_graph_card);
+
/* Module information */
MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>");
MODULE_DESCRIPTION("ALSA SoC Simple Card Utils");
--
1.9.1
Powered by blists - more mailing lists