hi, all

now , I want to use the SPI to tranfer a file to a FPGA. the file is
saved in nor flash (0x2200000).
The transmition by CPU is ok , then I want to use the EDMA .

the DMA transfer finished after transfer only 1 byte,then  enter the DMA
callback function.
waht worse is that  this one byte is 0x00, not the data in flash
0x2200000.

I set the dma parameters like this: coulde anybody tell me why?

static void spi_davinci_tx_dma_cb( void )
{
        DBGENTER;
        davinci_stop_dma(spi_dma_config.dma_tx_lch  );
        davinci_free_dma(spi_dma_config.dma_tx_lch  );
        spi_dma_config.dma_tx_lch = -1;
        complete(&(spi_dma_config.tx_dma_completion));
}

int spi_davinci_tx_dma( dma_addr_t  buffer, unsigned int len /*bytes*/)
{

      spi_dma_config.dma_tx_sync = DAVINCI_DMA_SPI_SPIX ;
       if ((r = davinci_request_dma(spi_dma_config.dma_tx_sync ,
"SPI_TX",
                                    spi_davinci_tx_dma_cb,
spi_davinci_saved_oadap,
                                   &edma_chan_num, &tcc, queue_no)) !=
0)
       {
                DBG("davinci_request_dma() failed with %d\n", r);
                return r;
        }

        spi_dma_config.dma_tx_lch =edma_chan_num;
        DBG("TX DMA on channel %d\n", edma_chan_num);
       // init dma tx completion.
       init_completion(&(spi_dma_config.tx_dma_completion));


       DBG("buffer addr(0x%x),len(%d)\n", buffer,len);
       davinci_set_dma_src_params(spi_dma_config.dma_tx_lch, buffer,
0,0);
       davinci_set_dma_dest_params(spi_dma_config.dma_tx_lch, (unsigned
long)0x01c6683c, 1, 0); // 0x01c6683c is SPIDAT1 register address.
       davinci_set_dma_src_index(spi_dma_config.dma_tx_lch,len,0);
       davinci_set_dma_dest_index(spi_dma_config.dma_tx_lch, 0 ,0);
       davinci_set_dma_transfer_params(spi_dma_config.dma_tx_lch, len,
1, 1, 0,ASYNC);
       #endif

        // start system DMA
       //davinci_start_dma(spi_dma_config.dma_tx_lch);
       spi_davinci_saved_oadap->regs->SPIINT0 |=(1<<16); //enable SPI
DAM function 
       ret  = davinci_start_dma(spi_dma_config.dma_tx_lch);

        // wait DMA xfer over.
       wait_for_completion(&(spi_dma_config.tx_dma_completion));
       return ret;
}

static void  fpga_test (void)
{
     #define LEN   (100)
     int ret ;
     unsigned int flash_addr ;

    flash_addr =  0x2200000;
    ret =  spi_davinci_tx_dma(flash_addr, LEN );
    DBG("ret(%d)\n",ret);
}


_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to