aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/sound/imx-audmux.txt9
-rw-r--r--sound/soc/fsl/imx-audmux.c62
2 files changed, 71 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/imx-audmux.txt b/Documentation/devicetree/bindings/sound/imx-audmux.txt
index 215aa9817213..f88a00e54c63 100644
--- a/Documentation/devicetree/bindings/sound/imx-audmux.txt
+++ b/Documentation/devicetree/bindings/sound/imx-audmux.txt
@@ -5,6 +5,15 @@ Required properties:
5 or "fsl,imx31-audmux" for the version firstly used on i.MX31. 5 or "fsl,imx31-audmux" for the version firstly used on i.MX31.
6- reg : Should contain AUDMUX registers location and length 6- reg : Should contain AUDMUX registers location and length
7 7
8An initial configuration can be setup using child nodes.
9
10Required properties of optional child nodes:
11- fsl,audmux-port : Integer of the audmux port that is configured by this
12 child node.
13- fsl,port-config : List of configuration options for the specific port. For
14 imx31-audmux and above, it is a list of tuples <ptcr pdcr>. For
15 imx21-audmux it is a list of pcr values.
16
8Example: 17Example:
9 18
10audmux@021d8000 { 19audmux@021d8000 {
diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index 1a5da1e13077..103d1b020496 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -251,6 +251,66 @@ int imx_audmux_v2_configure_port(unsigned int port, unsigned int ptcr,
251} 251}
252EXPORT_SYMBOL_GPL(imx_audmux_v2_configure_port); 252EXPORT_SYMBOL_GPL(imx_audmux_v2_configure_port);
253 253
254static int imx_audmux_parse_dt_defaults(struct platform_device *pdev,
255 struct device_node *of_node)
256{
257 struct device_node *child;
258
259 for_each_available_child_of_node(of_node, child) {
260 unsigned int port;
261 unsigned int ptcr = 0;
262 unsigned int pdcr = 0;
263 unsigned int pcr = 0;
264 unsigned int val;
265 int ret;
266 int i = 0;
267
268 ret = of_property_read_u32(child, "fsl,audmux-port", &port);
269 if (ret) {
270 dev_warn(&pdev->dev, "Failed to get fsl,audmux-port of child node \"%s\"\n",
271 child->full_name);
272 continue;
273 }
274 if (!of_property_read_bool(child, "fsl,port-config")) {
275 dev_warn(&pdev->dev, "child node \"%s\" does not have property fsl,port-config\n",
276 child->full_name);
277 continue;
278 }
279
280 for (i = 0; (ret = of_property_read_u32_index(child,
281 "fsl,port-config\n", i, &val)) == 0;
282 ++i) {
283 if (audmux_type == IMX31_AUDMUX) {
284 if (i % 2)
285 pdcr |= val;
286 else
287 ptcr |= val;
288 } else {
289 pcr |= val;
290 }
291 }
292
293 if (ret != -ENODATA) {
294 dev_err(&pdev->dev, "Failed to read u32 at index %d of child %s\n",
295 i, child->full_name);
296 continue;
297 }
298
299 if (audmux_type == IMX31_AUDMUX) {
300 if (i % 2) {
301 dev_err(&pdev->dev, "One pdcr value is missing in child node %s\n",
302 child->full_name);
303 continue;
304 }
305 imx_audmux_v2_configure_port(port, ptcr, pdcr);
306 } else {
307 imx_audmux_v1_configure_port(port, pcr);
308 }
309 }
310
311 return 0;
312}
313
254static int imx_audmux_probe(struct platform_device *pdev) 314static int imx_audmux_probe(struct platform_device *pdev)
255{ 315{
256 struct resource *res; 316 struct resource *res;
@@ -275,6 +335,8 @@ static int imx_audmux_probe(struct platform_device *pdev)
275 if (audmux_type == IMX31_AUDMUX) 335 if (audmux_type == IMX31_AUDMUX)
276 audmux_debugfs_init(); 336 audmux_debugfs_init();
277 337
338 imx_audmux_parse_dt_defaults(pdev, pdev->dev.of_node);
339
278 return 0; 340 return 0;
279} 341}
280 342