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.

GPIO driver for dm365

Other Parts Discussed in Thread: TMS320DM6446, TMS320DM355

Hi all,

I have to write GPIO driver for dm365 to toggle GPIO31 with a delay of one microsecond to generate PWM because one microsecond delay can not be provided from user space(Upto mili second delay to be provided from user space).

I  am using kernel version 2.6.18 having gpiolib.c .

I am new in driver areas so please help me how to proceed .

If any one have done it please post code.

Really I am struggling for that because I donot have idea what kernel API for pinmuxing and offset setting.

Please help me!

 

Regards,

Ramjee

  • Modify some source file, such as include/asm-arm/arch-davinci/mux.h and arch/arm/mach-davinci/mux_cfg.c, and then use davinci_cfg_reg() to configure the pinmux register, at last read Documentation/gpio.txt to figure out HOW-TO use the gpio function in kernel.

  • Thanks for replay Yinglin.

     

    If I have pinmux driver , gpio driver , gpio direction driver for Dm355 kernel version 2.6.10  then to make same drivers for DM365 kernel version 2.6.18 what changes should I do to make it work.

    Please have a look to following pdf and link below. And help me.

    GPIO and PINMUX Driver for TMS320DM6446 and TMS320DM355 (SPRAB39)
     and

    http://www-s.ti.com/sc/techlit/sprab39.zip

     Thanks in advance.

    Regards,

    Ramjee Y

     

  • Application written in Above .zip file is for toggling GPIO 16 then why pin 17 is get used in application? I checked in Dm355 data sheet also but unable to find the reason .

    Why all four bits has been cleared for pinmuxing instead of one bit for 16 or 17?


    val=val & 0xFFF0FFFF; //Set pin 17 to Output

    Why always 16 bit is getting read?
    No any clue from data sheet or above mentioned pdf.

    Please help me I am struggling?

  • int main()
    {
            int fdg,fdp,fdgd,val;

            fdg=open("/dev/gpiocustom",O_RDWR);
            if(fdg==-1)
            {
            printf("Failed to open the driver\n");
            return 0;
            }

            fdgd=open("/dev/gpiocustomdir",O_RDWR);
            if(fdgd==-1)
            {
            printf("Failed to open the driver\n");
            return 0;
            }

            fdp=open("/dev/pinmuxcustom",O_RDWR);
            if(fdp==-1)
            {
            printf("Failed to open the driver\n");
            return 0;
            }

            /* Set the PINMUX */
            val=read(fdp,PINMUX3,0);
            printf("PinMux3 = 0x%X\n",val);
            val=val & 0xFFF9FFFF; //Set pin 16 & pin 17 to GPIO
            write(fdp,PINMUX3,val);
            val=read(fdp,PINMUX3,0);
            printf("PinMux3 = 0x%X\n",val);

      /* Set the Direction */
            write(fdgd,17,0);
            val=read(fdgd,17,0);
            printf("DIR01-17 = 0x%X\n",val);
    /* Different method
            val=read(fdgd,DIR01,0);
            printf("DIR01 = 0x%X\n",val);
            val=val & 0xFFF0FFFF; //Set pin 17 to Output  //Why clearing all bits  instead of only one bit for 17 pin?
            printf("val = 0x%X\n",val);
            write(fdgd,DIR01,val);  */
            val=read(fdgd,DIR01,0);
            printf("DIR01 = 0x%X\n",val);

            while(1){
            write(fdg,17,0);
            val = read(fdg,16,0);
            printf ("val 16 = 0x%X\n",val);
            val= read(fdp,IN_DATA01,0);
            printf ("IN_DATA01 = 0x%X\n",val);
            usleep(500000);
            write(fdg,17,1);
            val = read(fdg,16,0);
            printf ("val 16 = 0x%X\n",val);
            val= read(fdp,IN_DATA01,0);
            printf ("IN_DATA01 = 0x%X\n",val);
            usleep(500000);
            }

    }