Skip to contentSkip to conversation

gpio Interrupt handling for omap5912

DISCUSSION Arnold 3 participants 4 messages Aug 4, 2006 – Aug 14, 2006 1 message not in the archive

lore
Share & tools
lore

Arnold

author
#1 lore raw
In reply to a message not in the archive

Hi Dirk,

Quoted 11 lines

In your first mail you asked for a description/spec how to
program GPIO. Maybe you can now write a short howto how to
program and use GPIO API and send it to the list? Then the
result of our discussion can be helpful for others as well.
Giving something back to the community must not be code or
patches, it can be documentation as well.

Here's the a little of what I know on howto for gpio. There may be an error, so feel free to edit/modify.

GPIO API's How To.

INCLUDE
#include <asm/arch/gpio.h>

I. GPIO Modules/Banks

        A.) GPIO MODULE/BANK 0 - PIN  0-15
        B.) GPIO MODULE/BANK 1 - PIN 16-31
        C.) GPIO MODULE/BANK 2 - PIN 32-47
        D.) GPIO MODULE/BANK 3 - PIN 48-63

II. GPIO API's
A.) omap_request_gpio(int gpio)
Description:
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
Note:
>Using this function, you dont have to worry
about
banks/modules where the gpio pin is.
B.) omap_set_gpio_direction(int gpio, int is_input)
Description:
> This function is responsible for setting the
gpio pin direction(input or output).
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
> int is_input - pin direction (0=output,
1=input)

C.) omap_set_gpio_dataout(int gpio, int enable)
Description:
> This function is responsible for writing to a
pin.
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
> int enable - pin value (0 or 1)
D.) omap_get_gpio_datain(int gpio)
Description:
> This function is responsible for reading pin
values.
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
E.) omap_free_gpio(int gpio)
Description:
> This function is responsible for freeing the pin
used.
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
F.) OMAP_GPIO_IRQ(int gpio)
Description:
> Returns the Interrupt number for the specified
gpio pin.
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
G.) set_irq_type(unsigned int irq, unsigned int type)
Description:
> This function is responsible for setting the
type of interrupt(RISING or FALLING).
Parameter:
> unsigned int irq - The interrupt number for the
gpio pin.

Quoted 1 line

unsigned int type - (IRQT_RISING = rising,

IRQT_FALLING= falling)

Example:
1.) Writing to gpio pin#3 a value 1. and reading the value of gpio pin#3.

        Request for gpio pin
                omap_request_gpio(3);
        Writing a 1 to gpio pin # 3:
                omap_set_gpio_direction(3,0);
                omap_set_set_dataout(3,1);
        Reading the value of pin # 3;
                ret = omap_get_datain(3);
                printk("value of pin # 3 = %d\n",ret);
        Freeing gpio pin # 3;
                omap_free_gpio(3);

2.) Interrupt

        Request for gpio pin
                omap_request_gpio(3);
        Setting up pin for interrupt
         omap_set_gpio_direction(3,0);
         set_irq_type(OMAP_GPIO_IRQ(3),IRQT_RISING);  
    
         request_irq(OMAP_GPIO_IRQ(3),(void
*)&my_int_handler,SA_SHIRQ,....);
        Freeing interrupt and gpio pin
                free_irq(OMAP_GPIO_IRQ(3),&id);
                omap_free_gpio(3);

I dont know if this will help. Thanks for all the
help.

Regards,
OJ

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#2 lore raw

Hi all,

to avoid that things like HowTo below are lost, what do you think is the best place to store them?

I can imagine

- Documentation/arm/OMAP/GPIO
- http://tree.celinuxforum.org/CelfPubWiki/OSK
- ?

Cheers

Dirk

Quoted 98 lines · Arnold

Here's the a little of what I know on howto for gpio. There may be an error, so feel free to edit/modify.

GPIO API's How To.

INCLUDE
#include <asm/arch/gpio.h>

I. GPIO Modules/Banks

        A.) GPIO MODULE/BANK 0 - PIN  0-15
        B.) GPIO MODULE/BANK 1 - PIN 16-31
        C.) GPIO MODULE/BANK 2 - PIN 32-47
        D.) GPIO MODULE/BANK 3 - PIN 48-63

II. GPIO API's
A.) omap_request_gpio(int gpio)
Description:
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
Note:
>Using this function, you dont have to worry
about
banks/modules where the gpio pin is.
B.) omap_set_gpio_direction(int gpio, int is_input)
Description:
> This function is responsible for setting the
gpio pin direction(input or output).
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
> int is_input - pin direction (0=output,
1=input)

C.) omap_set_gpio_dataout(int gpio, int enable)
Description:
> This function is responsible for writing to a
pin.
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
> int enable - pin value (0 or 1)
D.) omap_get_gpio_datain(int gpio)
Description:
> This function is responsible for reading pin
values.
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
E.) omap_free_gpio(int gpio)
Description:
> This function is responsible for freeing the pin
used.
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
F.) OMAP_GPIO_IRQ(int gpio)
Description:
> Returns the Interrupt number for the specified
gpio pin.
Parameter:
> int gpio - GPIO PIN (Pin 0-63)
G.) set_irq_type(unsigned int irq, unsigned int type)
Description:
> This function is responsible for setting the
type of interrupt(RISING or FALLING).
Parameter:
> unsigned int irq - The interrupt number for the
gpio pin.

Quoted 1 line

unsigned int type - (IRQT_RISING = rising,

IRQT_FALLING= falling)

Example:
1.) Writing to gpio pin#3 a value 1. and reading the value of gpio pin#3.

        Request for gpio pin
                omap_request_gpio(3);
        Writing a 1 to gpio pin # 3:
                omap_set_gpio_direction(3,0);
                omap_set_set_dataout(3,1);
        Reading the value of pin # 3;
                ret = omap_get_datain(3);
                printk("value of pin # 3 = %d\n",ret);
        Freeing gpio pin # 3;
                omap_free_gpio(3);

2.) Interrupt

        Request for gpio pin
                omap_request_gpio(3);
        Setting up pin for interrupt
         omap_set_gpio_direction(3,0);
         set_irq_type(OMAP_GPIO_IRQ(3),IRQT_RISING);  
    
         request_irq(OMAP_GPIO_IRQ(3),(void
*)&my_int_handler,SA_SHIRQ,....);
        Freeing interrupt and gpio pin
                free_irq(OMAP_GPIO_IRQ(3),&id);
                omap_free_gpio(3);

I dont know if this will help. Thanks for all the
help.

#3 lore raw
Quoted 8 lines · Dirk Behme

Hi all,

to avoid that things like HowTo below are lost, what do you think is the best place to store them?

I can imagine

- Documentation/arm/OMAP/GPIO

I would prefer this even it might be even too obvious place to search this kind of docs :-) But of course OSK wiki is also good location. Maybe there could also be something from the just added GPIO switch framework usage and omap platforms it should support. (OMAP1, OMAP2?)

Another area from which I would be interested in would be ARMIOs, as I have only found my self couple of references to them without good explanation what they really are. They seems to be something that remains GPIO's and I would be interested in to know whether GPIO functions are supposed to handle also them by just using certain high enought ID numbers, or should they be treated diffrerently?

Mika

#4 lore raw
Quoted 10 lines · lamikr
Quoted 6 lines · Dirk Behme

to avoid that things like HowTo below are lost, what do you think is the best place to store them?

I can imagine

- Documentation/arm/OMAP/GPIO

I would prefer this even it might be even too obvious place to search this kind of docs :-) But of course OSK wiki is also good location.

Okay, let us put it into Documentation/arm/OMAP (see patch I sent). If it is there, I will add a link to

http://tree.celinuxforum.org/CelfPubWiki/OSK#head-0bda81ff448870f0aa282eb95524f2c157ca3e83

Then, we have it at both places ;)

Quoted 9 lines

Maybe there could also be something from the just added GPIO switch framework usage and omap platforms it should support. (OMAP1, OMAP2?)

Another area from which I would be interested in would be ARMIOs, as I have only found my self couple of references to them without good explanation what they really are. They seems to be something that remains GPIO's and I would be interested in to know whether GPIO functions are supposed to handle also them by just using certain high enought ID numbers, or should they be treated diffrerently?

Anybody who is familiar with this can add this info to GPIO howto?

Thanks

Dirk