This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Working with DMA



Hello!

Where can I find sample working with DMA on DM355? I have interest in drivers and program.

Thank you and excuse me for my bad english.

  • The DMA kernel driver is available under the kernel tree in the following location

          ...lsp/ti-davinci/arch/arm/mach-davinci/dma.c

    that said, this driver is only accessible by other kernel drivers such as MMC driver and audio driver.  You could add proprietary ioctl request to the dma driver to allow user space access to DMA resources; however, this can be dangerous as you need to uderstand which DMA channels are dedicated to which peripherals and communication between ARM and MJCP.  What do you have in mind as far as DMA usage?

  • Thank you for your reply, Juan!

    We tried use this for dm9000 driver. That is what we have done:

    void dm9000_dmaHandler(int lch, unsigned short ch_status,void *data);

    static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
    {
    int res;

    int i;

    edmacc_paramentry_regs dmaParam;

    //writesb(reg, data, count);

    //заменить на write_DMA

    printk("start %s, data = %p,count = %d, channel = %d,tcc = %d,reg = %p\n",

    __FUNCTION__, data,count,lch,tcc,dmaTestData);

    printk(KERN_INFO "requesting dma channel\n");

    for (i = 12; i < 14; i++) {

    res = davinci_request_dma(i,"dm9000_dma_tx",dm9000_dmaHandler,

    dmaData,&lch,&tcc,0);

    if (!res)

    {

    printk(KERN_INFO "allocated dma channel %d\n",lch);

    break;

    }

    else

    {

    //printk(KERN_INFO "dma request error %d\n",res);

    }

    }

    if (res)

    printk(KERN_INFO "dma request error %d\n",res);

     

    davinci_set_dma_transfer_params(lch, count, 1, 1,

    0, ASYNC);

    davinci_set_dma_dest_params(lch,reg, 0, 0);

    davinci_set_dma_src_params(lch, data, 0, 0);

    davinci_set_dma_src_index(lch, 0, 0);

    davinci_set_dma_dest_index(lch, 0, 0);

    res = davinci_start_dma(lch);

    if (res)

    {

    printk("dm9000 dma start error\n");

    }

    printk("end %s\n",__FUNCTION__);

    }

    void dm9000_dmaHandler(int lch, unsigned short ch_status,void *data)

    {

    printk(KERN_INFO "%s, channel= %d,status = 0x%04X, data = %p\n",__FUNCTION__,lch,

    ch_status,data);

    davinci_stop_dma(lch);

    davinci_free_dma(lch);

    ch_status = ch_status;

    data = data;

    }

    But this don't works properly
    Driver output during ping command:
    # ping -c 3 192.168.15.129
    PING 192.168.15.129 (192.168.15.129)start dm9000_outblk_8bit, data = c0fc5202,count = 98, channel = 12,tcc = 12,reg = c6864002
    requesting dma channel
    allocated dma channel 12
    end dm9000_outblk_8bit
    dm9000_dmaHandler, channel= 12,status = 0x0001, data = c0353c30
    : 56 data bytes
    start dm9000_outblk_8bit, data = c0fc5202,count = 98, channel = 12,tcc = 12,reg = c6864002
    requesting dma channel
    allocated dma channel 12
    end dm9000_outblk_8bit
    dm9000_dmaHandler, channel= 12,status = 0x0001, data = c0353c30
    start dm9000_outblk_8bit, data = c0fc5202,count = 98, channel = 12,tcc = 12,reg = c6864002
    requesting dma channel
    allocated dma channel 12
    end dm9000_outblk_8bit
    dm9000_dmaHandler, channel= 12,status = 0x0001, data = c0353c30
    start dm9000_outblk_8bit, data = c324e0c2,count = 42, channel = 12,tcc = 12,reg = c6864002
    requesting dma channel
    allocated dma channel 12
    end dm9000_outblk_8bit
    dm9000_dmaHandler, channel= 12,status = 0x0001, data = c0353c30
    start dm9000_outblk_8bit, data = c324e0c2,count = 42, channel = 12,tcc = 12,reg = c6864002
    requesting dma channel
    allocated dma channel 12
    end dm9000_outblk_8bit
    dm9000_dmaHandler, channel= 12,status = 0x0001, data = c0353c30
    start dm9000_outblk_8bit, data = c324e0c2,count = 42, channel = 12,tcc = 12,reg = c6864002
    requesting dma channel
    allocated dma channel 12
    end dm9000_outblk_8bit
    dm9000_dmaHandler, channel= 12,status = 0x0001, data = c0353c30
    --- 192.168.15.129 ping statistics ---
    3 packets transmitted, 0 packets received, 100% packet loss
    What we do wrong?
    Thank you.

  • I cannot see anything obviously wrong in the code; can you try doing a DMA transfer from DDR2 to DDR2 first...this is probrably a easy way to verify if there is something wrong with the code or not...

  • Testing DMA transfer from DDR2 to DDR2.

    Source:

    static unsigned char dmaTestData[1536];
    static unsigned char dmaTestSource[1536];

    static void dm9000_outblk_8bit(void __iomem *reg, void *data, int count)
    {
    .........................................................................
     for (i = 0; i < 25; i++) {
    dmaTestData[i] = 0;
    dmaTestSource[i] = i + 1;
    }
    davinci_set_dma_transfer_params(lch, 25, 1, 1, 0, ASYNC);
    davinci_set_dma_dest_params(lch,(unsigned long)virt_to_phys(dmaTestData), 0, 0);
    davinci_set_dma_src_params(lch, (unsigned long)virt_to_phys(dmaTestSource), 0, 0);
    davinci_set_dma_src_index(lch, 0, 0);
    davinci_set_dma_dest_index(lch, 0, 0);
    .........................................
    }

    void dm9000_dmaHandler(int lch, unsigned short ch_status,void *data)
    {
    int i;
    ......................................
     printk(KERN_INFO "dmaTestData:");
    for (i = 0; i < 25; i++) {
    printk(KERN_INFO "%02X ", dmaTestData[i]);
    }
    printk(KERN_INFO "\n");
    ...............................
    }

    Result:

    start dm9000_outblk_8bit, data = c09c6202,count = 70, channel = 12,tcc = 12,reg = 0xC6864002
    requesting dma channel
    allocated dma channel 12
    end dm9000_outblk_8bit
    dm9000_dmaHandler, channel= 12,status = 0x0001, data = c0353c30
    dmaTestData:<6>01 <6>02 <6>03 <6>04 <6>05 <6>06 <6>07 <6>08 <6>09 <6>0A <6>0B <6>0C <6>0D <6>0E <6>0F <6>10 <6>11 <6>12 <6>13 <6>14 <6>15 <6>16 <6>17 <6>18 <6>19 <6>

    But with ping, as sample, this is don't work.