~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/fsl/fsl_utils.c

Version: ~ [ linux-5.11-rc3 ] ~ [ linux-5.10.7 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.89 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.167 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.215 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.251 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.251 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**
  2  * Freescale ALSA SoC Machine driver utility
  3  *
  4  * Author: Timur Tabi <timur@freescale.com>
  5  *
  6  * Copyright 2010 Freescale Semiconductor, Inc.
  7  *
  8  * This file is licensed under the terms of the GNU General Public License
  9  * version 2.  This program is licensed "as is" without any warranty of any
 10  * kind, whether express or implied.
 11  */
 12 
 13 #include <linux/module.h>
 14 #include <linux/of_address.h>
 15 #include <sound/soc.h>
 16 
 17 #include "fsl_utils.h"
 18 
 19 /**
 20  * fsl_asoc_get_dma_channel - determine the dma channel for a SSI node
 21  *
 22  * @ssi_np: pointer to the SSI device tree node
 23  * @name: name of the phandle pointing to the dma channel
 24  * @dai: ASoC DAI link pointer to be filled with platform_name
 25  * @dma_channel_id: dma channel id to be returned
 26  * @dma_id: dma id to be returned
 27  *
 28  * This function determines the dma and channel id for given SSI node.  It
 29  * also discovers the platform_name for the ASoC DAI link.
 30  */
 31 int fsl_asoc_get_dma_channel(struct device_node *ssi_np,
 32                              const char *name,
 33                              struct snd_soc_dai_link *dai,
 34                              unsigned int *dma_channel_id,
 35                              unsigned int *dma_id)
 36 {
 37         struct resource res;
 38         struct device_node *dma_channel_np, *dma_np;
 39         const u32 *iprop;
 40         int ret;
 41 
 42         dma_channel_np = of_parse_phandle(ssi_np, name, 0);
 43         if (!dma_channel_np)
 44                 return -EINVAL;
 45 
 46         if (!of_device_is_compatible(dma_channel_np, "fsl,ssi-dma-channel")) {
 47                 of_node_put(dma_channel_np);
 48                 return -EINVAL;
 49         }
 50 
 51         /* Determine the dev_name for the device_node.  This code mimics the
 52          * behavior of of_device_make_bus_id(). We need this because ASoC uses
 53          * the dev_name() of the device to match the platform (DMA) device with
 54          * the CPU (SSI) device.  It's all ugly and hackish, but it works (for
 55          * now).
 56          *
 57          * dai->platform name should already point to an allocated buffer.
 58          */
 59         ret = of_address_to_resource(dma_channel_np, 0, &res);
 60         if (ret) {
 61                 of_node_put(dma_channel_np);
 62                 return ret;
 63         }
 64         snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%s",
 65                  (unsigned long long) res.start, dma_channel_np->name);
 66 
 67         iprop = of_get_property(dma_channel_np, "cell-index", NULL);
 68         if (!iprop) {
 69                 of_node_put(dma_channel_np);
 70                 return -EINVAL;
 71         }
 72         *dma_channel_id = be32_to_cpup(iprop);
 73 
 74         dma_np = of_get_parent(dma_channel_np);
 75         iprop = of_get_property(dma_np, "cell-index", NULL);
 76         if (!iprop) {
 77                 of_node_put(dma_np);
 78                 return -EINVAL;
 79         }
 80         *dma_id = be32_to_cpup(iprop);
 81 
 82         of_node_put(dma_np);
 83         of_node_put(dma_channel_np);
 84 
 85         return 0;
 86 }
 87 EXPORT_SYMBOL(fsl_asoc_get_dma_channel);
 88 
 89 MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
 90 MODULE_DESCRIPTION("Freescale ASoC utility code");
 91 MODULE_LICENSE("GPL v2");
 92 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp