asoc multi-component: mpc8610 hpcd updates
Subsystems (3)
PATCH 1/1 asoc multi-component: mpc8610 hpcd updates
Additional updates to the multi-component branch. Liam, please squash these in.
Signed-off-by Timur Tabi <[email protected]>
--- sound/soc/fsl/fsl_dma.c | 68 +++++++++++++++-------- sound/soc/fsl/fsl_dma.h | 3 - sound/soc/fsl/fsl_ssi.c | 37 +++++++----- sound/soc/fsl/mpc8610_hpcd.c | 125 ++++++++++++++++++++++++++--------------- 4 files changed, 144 insertions(+), 89 deletions(-)
sound/soc/fsl/fsl_dma.c +44 -24
@@ -32,6 +32,7 @@#include <asm/io.h> #include "fsl_dma.h" +#include "fsl_ssi.h" /* For the offset of stx0 and srx0 */ /* * The formats that the DMA controller supports, which is anything
@@ -798,36 +799,35 @@ static void fsl_dma_free_dma_buffers(struct snd_pcm *pcm)static LIST_HEAD (dma_list);/** -* fsl_soc_dma_to_dai - returning the DAI struct for a given DMA node -* -* When a machine driver registers itself with ASoC, it must provide the -* address of the DAI structures that it wants to connect. Most drivers simply -* reference global data structures in the various drivers, but we PowerPC -* developers are better than that. This driver keeps a list of every DMA -* node that it probes, and when the machine driver wants to reference a -* DMA DAI, this function provides that service. -* -* Hopefully one day, ASoC will just want the name of the DMA device, not -* some obscure pointer, and this function will go away. +* find_ssi_node -- returns the SSI node that points to his DMA channel node +* +* Although this DMA driver attempts to operate independently of the other +* devices, it still needs to determine some information about the SSI device +* that it's working with. Unfortunately, the device tree does not contain +* a pointer from the DMA channel node to the SSI node -- the pointer goes the +* other way. So we need to scan the device tree for SSI nodes until we find +* the one that points to the given DMA channel node. It's ugly, but at least +* it's contained in this one function. */ -struct snd_soc_platform_driver *fsl_soc_dma_to_dai (const char *path, -dma_addr_t ssi_stx_phys,dma_addr_t ssi_srx_phys) +static struct device_node *find_ssi_node (struct device_node *dma_channel_np) { -struct list_head *ptr; -struct dma_object *dma; +struct device_node *ssi_np, *np; -list_for_each (ptr, &dma_list) { - dma = list_entry(ptr, struct dma_object, list); -if (strcmp (path, dma->path) ==0 ) { - dma->ssi_stx_phys = ssi_stx_phys; - dma->ssi_srx_phys = ssi_srx_phys; -return &dma->dai; - } +for_each_compatible_node (ssi_np,NULL ,"fsl,mpc8610-ssi" ) { +/* Check each DMA phandle to see if it points to us. We +* assume that device_node pointers are a valid comparison. +*/ + np =of_parse_phandle (ssi_np,"fsl,playback-dma" ,0 ); +if (np == dma_channel_np) +return ssi_np; + + np =of_parse_phandle (ssi_np,"fsl,capture-dma" ,0 ); +if (np == dma_channel_np) +return ssi_np; }return NULL ; } -EXPORT_SYMBOL (fsl_soc_dma_to_dai);static struct snd_pcm_ops fsl_dma_ops = { .open = fsl_dma_open,
@@ -843,8 +843,24 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev, {struct dma_object *dma;struct device_node *np = of_dev->dev.of_node; +struct device_node *ssi_np; +struct resource res;int ret; +/* Find the SSI node that points to us. */ + ssi_np =find_ssi_node (np); +if (!ssi_np) { +dev_err (&of_dev->dev,"cannot find parent SSI node\n" ); +return -ENODEV ; + } + + ret =of_address_to_resource (ssi_np,0 , &res); +of_node_put (ssi_np); +if (ret) { +dev_err (&of_dev->dev,"could not determine device resources\n" ); +return ret; + } + dma =kzalloc (sizeof (*dma) +strlen (np->full_name),GFP_KERNEL );if (!dma) {dev_err (&of_dev->dev,"could not allocate dma object\n" );
@@ -856,6 +872,10 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev, dma->dai.pcm_new = fsl_dma_new; dma->dai.pcm_free = fsl_dma_free_dma_buffers; +/* Store the SSI-specific information that we need */ + dma->ssi_stx_phys = res.start + offsetof(struct ccsr_ssi , stx0); + dma->ssi_srx_phys = res.start + offsetof(struct ccsr_ssi , srx0); + ret =snd_soc_register_platform (&of_dev->dev, &dma->dai);if (ret) {dev_err (&of_dev->dev,"could not register platform\n" );
@@ -921,7 +941,7 @@ static void __exit fsl_soc_dma_exit(void)* will already have been probed. The easiest way to do that is to make the * __init function called via arch_initcall(). */ -arch_initcall (fsl_soc_dma_init); +module_init (fsl_soc_dma_init);module_exit (fsl_soc_dma_exit);MODULE_AUTHOR ("Timur Tabi <[email protected]>" );
sound/soc/fsl/fsl_dma.h +0 -3
@@ -126,7 +126,4 @@ struct fsl_dma_link_descriptor {u8 res[4 ];/* Reserved */ } __attribute__ ((aligned(32), packed)); -struct snd_soc_platform_driver *fsl_soc_dma_to_dai (const char *path, -dma_addr_t ssi_stx_phys,dma_addr_t ssi_srx_phys); -#endif
sound/soc/fsl/fsl_ssi.c +21 -16
@@ -292,8 +292,7 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,/* The 'name' should not have any slashes in it. */ ret =request_irq (ssi_private->irq, fsl_ssi_isr,0 , -strrchr (ssi_private->name,'/' ) +1 , - ssi_private); + ssi_private->name, ssi_private);if (ret <0 ) {dev_err (substream->pcm->card->dev,"could not claim irq %u\n" , ssi_private->irq);
@@ -622,11 +621,9 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,int ret =0 ;struct device_attribute *dev_attr;struct device_node *np = of_dev->dev.of_node; -const char *sprop; +const char *p, *sprop;struct resource res;char name[64 ]; -struct platform_device *pdev; -void *platform_data;/* We are only interested in SSIs with a codec phandle in them, so let's * make sure this SSI has one.
@@ -641,21 +638,22 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,return -ENODEV ; } - ssi_private =kzalloc (sizeof (struct fsl_ssi_private ) + -strlen (np->full_name),GFP_KERNEL ); +/* The DAI name is the last part of the full name of the node. */ + p =strrchr (np->full_name,'/' ) +1 ; + ssi_private =kzalloc (sizeof (struct fsl_ssi_private ) +strlen (p), +GFP_KERNEL );if (!ssi_private) {dev_err (&of_dev->dev,"could not allocate DAI object\n" );return -ENOMEM ; } +strcpy (ssi_private->name, p); +/* Initialize this copy of the CPU DAI driver structure */ memcpy (&ssi_private->cpu_dai_drv, &fsl_ssi_dai_template,sizeof (fsl_ssi_dai_template)); ssi_private->cpu_dai_drv.name = ssi_private->name; -/* The name we register with ASoC is the full node name */ -strlcpy (ssi_private->name, np->full_name,sizeof (ssi_private->name)); -/* Get the addresses and IRQ */ ret =of_address_to_resource (np,0 , &res);if (ret) {
@@ -698,19 +696,26 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, }/* Trigger the machine driver's probe function. The platform driver -* name of the machine driver is taken from the /model node of the +* name of the machine driver is taken from the /model property of the * device tree. We also pass the address of the CPU DAI driver * structure. */ sprop =of_get_property (of_find_node_by_path ("/" ),"model" ,NULL ); +/* Sometimes the model name has a "fsl," prefix, so we strip that. */ + p =strrchr (sprop,',' ); +if (p) + sprop = p +1 ;snprintf (name,sizeof (name),"snd-soc-%s" , sprop);make_lowercase (name); - platform_data = &ssi_private->cpu_dai_drv; - pdev =platform_device_register_data (&of_dev->dev, name, -0 , &platform_data,sizeof (void *)); - - ssi_private->pdev = pdev; + ssi_private->pdev = +platform_device_register_data (&of_dev->dev, name,0 ,NULL ,0 ); +if (IS_ERR (ssi_private->pdev)) { + ret =PTR_ERR (ssi_private->pdev); +dev_err (&of_dev->dev,"failed to register platform: %d\n" , ret); +kfree (ssi_private); +return ret; + }return 0 ; }
sound/soc/fsl/mpc8610_hpcd.c +79 -46
224 lines not on this page · raw message
Signature · 1 line
1.7.0.1
Quoted 4 lines · Timur Tabi
Additional updates to the multi-component branch. Liam, please squash these in.
Signed-off-by Timur Tabi <[email protected]>
Applied and rebased.
Thanks !
Liam
Signature · 3 lines
Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk