2008-08-26 21:14:52     BF533 PPI driver...

Document created by Aaronwu Employee on Aug 7, 2013
Version 1Show Document
  • View in full screen mode

2008-08-26 21:14:52     BF533 PPI driver...

alan pan (CHINA)

Message: 61139   


I want to write a simple ppi driver for my own application. But can not enter DMA0 interrupt. It always says DMA error.  Some code shows as below. I use BF533 EVM board. Could you please help me to have a analysis. What's the possible problem?




static char buf[LEN];


static int ppi_open(struct inode *inode, struct file *filp) {

    int ret;


   // lets ask for the DMA channel

    ret = request_dma(CH_PPI, "BF533_PPI_DMA");

    if ( ret < 0 ) {

       printk(" Unable to get DMA channel\n");

       return -EFAULT;

    }else {

      // set the IRQ callback

      set_dma_callback(CH_PPI, ppi_dma0_irq_handler, filp->private_data);


    // turn off the DMA channel



    // Enable Interrupts

    set_dma_config(CH_PPI, 0x0B6);


    // set address to drop data into

    set_dma_start_addr(CH_PPI, (unsigned long)buf);


    // set the transfer size in bytes



    // set the X modify ( dont worry about Y for this one )



   // set the transfer size in bytes



    // set the X modify ( dont worry about Y for this one )



    //clear dma status




  // sync the cores up





    //The PPI is set to receive 576 lines for each frame




    /* clear ppi status before enabling */




  // sync the cores up




static irqreturn_t ppi_dma0_irq_handler(int irq, void *dev_id) {


    printk("Interrupt entered! %d \n", c++);


    return IRQ_HANDLED;



struct file_operations ppi_driver_fops = {

      owner: THIS_MODULE,

      read: ppi_read,

      write:  NULL,

      open: ppi_open,




static int __init ppi_init(void){

    int ret;

    unsigned char tempReg;


    printk("ppi driver initialize. \n");


    //Setup of the async interface





   //EVM setting

   *pFlashA_PortA_Out = 0x0;  // clear data registers

   *pFlashA_PortA_Dir = 0xFFFF; // set dir=output


    tempReg = *pFlashA_PortA_Out;

    *pFlashA_PortA_Out = tempReg | RST_7183 | PPICLK_ADV7183_SELECT;


    tempReg = bfin_read_FIO_DIR();

    bfin_write_FIO_DIR(tempReg | ADV7183_OE);


    //Set the Blackfin pin PF2 to output enable the ADV7183 data bus 

    tempReg = bfin_read_FIO_FLAG_C();

    bfin_write_FIO_FLAG_C(tempReg | ADV7183_OE);








    ret = register_chrdev(250, "ppi_driver", &ppi_driver_fops);        

    if (ret < 0) {

        printk(": chrdev registration failed. \n");

        return ret;

    }else {

        printk(": register char device. \n");



    return 0;













2008-08-26 21:24:42     Re: BF533 PPI driver...

Mike Frysinger (UNITED STATES)

Message: 61140   


you are mucking with a lot of core registers that you should not.  do not access port registers directly, use the GPIO/peripheral framework.  do not muck with the async ebiu registers, use the kernel configuration for that.


if your purpose is simply to drive the ADV7183, then use the V4L framework in svn trunk as it supports the ADV7183




2008-08-27 03:27:01     Re: BF533 PPI driver...

alan pan (CHINA)

Message: 61152   


Actually those are not core registers. Just a adresses on output data bus. I use BF533 EVM board. Before video capturing, ADV7183 should be enabled(Just pull OE to low, select ppi clock). By default, ADV7183 will output itu656 video streaming.


You said V4L framework? But I can not find the exactly code on ADV7183 enable of BF533 EVM board. So could you please give me a guidence of that?


I also comment out the async ebiu registers setting, i.e., use the kernel configuration for that. But the result is the same.






2008-08-27 16:26:45     Re: BF533 PPI driver...

Mike Frysinger (UNITED STATES)

Message: 61196   


they are core registers that are maintained by the core Blackfin code ... where the device lives is irrelevant


all V4L stuff can be found in svn trunk and in the documentation wiki




2008-08-27 21:09:19     Re: BF533 PPI driver...

alan pan (CHINA)

Message: 61208   


Add the define of those "core registers":


#define pFlashA_PortA_Dir ((volatile unsigned short *)0x20270006)

#define pFlashA_PortA_Out ((volatile unsigned char *)0x20270004)


They are in ASYNC MEMORY.


So is there any registers you think they are core registers? Or I've misunderstood what's you meaning?


I've read the code of v4l. But I don't think they are working BF533 EVM board. So it is not related with ADV7183 enable on EVM board.




2008-08-28 02:44:55     Re: BF533 PPI driver...

Mike Frysinger (UNITED STATES)

Message: 61224   


look at all the bfin_write_* calls you're making.  you should only be hitting DMA/PPI registers -- the rest are wrong.




2008-08-28 21:50:39     Re: BF533 PPI driver...

alan pan (CHINA)

Message: 61291   


Could you please give a more detailed explanation? and how to correct them? I once developed a PPI driver in uclinux kernal 2.4, it's not a problem for such code.


Thanks a lot.




2008-08-28 22:03:43     Re: 回复: Re: BF533 PPI driver...


Message: 61293   




2.6 != 2.4


We are not doing thing the proper way - this means there are resource managers to manage the hardware so all the drivers play well together - the key part of this working - is that the resource manager assumes that it has 100% of the complete hardware.


You making changes behind the resource managers back is a sure fire way for random kernel crashes.






2008-08-28 22:53:17     Re: BF533 PPI driver...

Mike Frysinger (UNITED STATES)

Message: 61300   


if you need to allocate pins for peripheral function, use the peripheral API.  if you need to allocate pins for GPIO function, use the GPIO API.


you can search the wiki for documentation, or look at other PPI drivers in the current kernel.




2008-08-29 04:48:26     回复: Re: BF533 PPI driver...

alan pan (CHINA)

Message: 61317   


It seems that the DMA address has issues. Now I use "__get_free_pages" with "GFP_DMA" to get the required memory buffer. Now it works properly.