linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* DMA Problem
@ 2005-04-20 17:37 Sanjay Bajaj
  2005-04-21 20:42 ` [DBG SRC] " Roger Larsson
  0 siblings, 1 reply; 2+ messages in thread
From: Sanjay Bajaj @ 2005-04-20 17:37 UTC (permalink / raw)
  To: linuxppc-embedded

I am having a setup issue with the DMA channel 0 with the DMA Controller 
on PPC440GX. The code I wrote is:

#if defined(CONFIG_PPC4xx_DMA)
    /* Setup the DMA */
    DPRINTK("PPC4xx pwidth: %d\n", ppc4xx_get_peripheral_width(DMA_CH0));
    ppc4xx_set_dma_mode(DMA_CH0, DMA_MODE_READ);
    ppc4xx_set_src_addr(DMA_CH0, (phys_addr_t)(pdev->x2mem_phys_addr + 
src_addr));
    ppc4xx_set_dst_addr(DMA_CH0, (phys_addr_t)dst_addr);
    ppc4xx_set_dma_count(DMA_CH0, count);
    ppc4xx_enable_dma(DMA_CH0);
    DPRINTK("PPC4xx DMA Status: %d\n", ppc4xx_get_dma_status());
#endif

The DMA never completes and leaves a residue of 'count'. What am I missing?

Please Help.
Sanjay

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [DBG SRC] Re: DMA Problem
  2005-04-20 17:37 DMA Problem Sanjay Bajaj
@ 2005-04-21 20:42 ` Roger Larsson
  0 siblings, 0 replies; 2+ messages in thread
From: Roger Larsson @ 2005-04-21 20:42 UTC (permalink / raw)
  To: linuxppc-embedded

On Wednesday 20 April 2005 19.37, Sanjay Bajaj wrote:
> I am having a setup issue with the DMA channel 0 with the DMA Controller
> on PPC440GX. The code I wrote is:
>
> #if defined(CONFIG_PPC4xx_DMA)
>     /* Setup the DMA */
>     DPRINTK("PPC4xx pwidth: %d\n", ppc4xx_get_peripheral_width(DMA_CH0));
>     ppc4xx_set_dma_mode(DMA_CH0, DMA_MODE_READ);
>     ppc4xx_set_src_addr(DMA_CH0, (phys_addr_t)(pdev->x2mem_phys_addr +
> src_addr));
>     ppc4xx_set_dst_addr(DMA_CH0, (phys_addr_t)dst_addr);
>     ppc4xx_set_dma_count(DMA_CH0, count);
>     ppc4xx_enable_dma(DMA_CH0);
>     DPRINTK("PPC4xx DMA Status: %d\n", ppc4xx_get_dma_status());
> #endif
>
> The DMA never completes and leaves a residue of 'count'. What am I missing?
>

Request irq and dma?

	if ((ret = request_irq(dma_irq, dma_irq_handler, SA_SHIRQ, "NAME")))
		- - -
	/* reserve a DMA channel */
	if (DBG_DMA(request_dma(DMA_CH0, const char *device_id))

BTW you should check return values, try this:

int fgrabber_report_dma_error(const char *call, int ret)
{
    switch (ret)
    {
	case DMA_STATUS_GOOD:
//	    printk(KERN_DEBUG "dma: %s STATUS_GOOD\n", call);
	    break;
	case DMA_STATUS_BAD_CHANNEL:
	    printk(KERN_DEBUG "dma: %s STATUS_BAD_CHANNEL\n", call);
	    break;
	case DMA_STATUS_BAD_HANDLE:
	    printk(KERN_DEBUG "dma: %s STATUS_BAD_HANDLE", call);
	    break;
	case DMA_STATUS_BAD_MODE:
	    printk(KERN_DEBUG "dma: %s STATUS_BAD_MODE", call);
	    break;
	case DMA_STATUS_NULL_POINTER:
	    printk(KERN_DEBUG "dma: %s STATUS_NULL_POINTER", call);
	    break;
	case DMA_STATUS_OUT_OF_MEMORY:
	    printk(KERN_DEBUG "dma: %s STATUS_OUT_OF_MEMORY", call);
	    break;
	case DMA_STATUS_SGL_LIST_EMPTY:
	    printk(KERN_DEBUG "dma: %s STATUS_SGL_LIST_EMPTY", call);
	    break;
	case DMA_STATUS_GENERAL_ERROR:
	    printk(KERN_DEBUG "dma: %s STATUS_GENERAL_ERROR", call);
	    break;
	case DMA_STATUS_CHANNEL_NOTFREE:   
	    printk(KERN_DEBUG "dma: %s STATUS_CHANNEL_NOTFREE", call);
	    break;
	default:
	    printk(KERN_DEBUG "dma: %s STATUS(0x%x)", call, ret);
	    break;
     }

    return ret;
}

#ifdef DEBUG_DMA
#define DBG_DMA(call) fgrabber_report_dma_error(#call, call)
#else
#define DBG_DMA(call) call
#endif

/RogerL

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-04-21 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-20 17:37 DMA Problem Sanjay Bajaj
2005-04-21 20:42 ` [DBG SRC] " Roger Larsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).