e>
aboutsummaryrefslogblamecommitdiffstats
path: root/Documentation/gpio.txt
blob: b1b9887012478f9b654edaa90bcdd13e72a9f20e (plain) (tree)
1
2
3
4
5
6
7



                                                              


                                                                         
























                                                                            
                                                          



                                                                           
                                                                     


























                                                                            
                                                                           

                                                                         



                                                                          

                                                                           




                                                                             
 
                               



                                                                            


                                                                          




                                                                        

                                                                       













                                                                         









                                                                       










                                                                         
                                                            


                                                                       


                                                                         
 


                                                                      




                                                                        











                                                                            
                                               











                                                                         
                                                           

                                                                          
                                                                          
                                                                           

                                                                             
 
                                                                    















                                                                          

                                                                        






























                                                                            


                                                                           



                                                                       




                                                                      
 



                                                                        










                                                                           


                                                                    









                                                                       
                                                                



                                                                       
                                                                          
                                                                      











                                                                           
                                                                       

                                                                       

 




























                                                                             













                                                                           
                                                                   


                                                                       



                                                                          
                                                                      
                                                                           


                                                                        
 
                                                                      

                                                                      




                                                                         
                                                                    



































                                                                           

                                                                    



                                                                           








                                                                               









































                                                                            




















































































































                                                                          
GPIO Interfaces

This provides an overview of GPIO access conventions on Linux.

These calls use the gpio_* naming prefix.  No other calls should use that
prefix, or the related __gpio_* prefix.


What is a GPIO?
===============
A "General Purpose Input/Output" (GPIO) is a flexible software-controlled
digital signal.  They are provided from many kinds of chip, and are familiar
to Linux developers working with embedded and custom hardware.  Each GPIO
represents a bit connected to a particular pin, or "ball" on Ball Grid Array
(BGA) packages.  Board schematics show which external hardware connects to
which GPIOs.  Drivers can be written generically, so that board setup code
passes such pin configuration data to drivers.

System-on-Chip (SOC) processors heavily rely on GPIOs.  In some cases, every
non-dedicated pin can be configured as a GPIO; and most chips have at least
several dozen of them.  Programmable logic devices (like FPGAs) can easily
provide GPIOs; multifunction chips like power managers, and audio codecs
often have a few such pins to help with pin scarcity on SOCs; and there are
also "GPIO Expander" chips that connect using the I2C or SPI serial busses.
Most PC southbridges have a few dozen GPIO-capable pins (with only the BIOS
firmware knowing how they're used).

The exact capabilities of GPIOs vary between systems.  Common options:

  - Output values are writable (high=1, low=0).  Some chips also have
    options about how that value is driven, so that for example only one
    value might be driven ... supporting "wire-OR" and similar schemes
    for the other value (notably, "open drain" signaling).

  - Input values are likewise readable (1, 0).  Some chips support readback
    of pins configured as "output", which is very useful in such "wire-OR"
    cases (to support bidirectional signaling).  GPIO controllers may have
    input de-glitch/debounce logic, sometimes with software controls.

  - Inputs can often be used as IRQ signals, often edge triggered but
    sometimes level triggered.  Such IRQs may be configurable as system
    wakeup events, to wake the system from a low power state.

  - Usually a GPIO will be configurable as either input or output, as needed
    by different product boards; single direction ones exist too.

  - Most GPIOs can be accessed while holding spinlocks, but those accessed
    through a serial bus normally can't.  Some systems support both types.

On a given board each GPIO is used for one specific purpose like monitoring