Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions
gpiolib-of.c File Reference
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_gpio.h>
#include <linux/slab.h>

Go to the source code of this file.

Data Structures

struct  gg_data
 

Functions

int of_get_named_gpio_flags (struct device_node *np, const char *propname, int index, enum of_gpio_flags *flags)
 
 EXPORT_SYMBOL (of_get_named_gpio_flags)
 
unsigned int of_gpio_named_count (struct device_node *np, const char *propname)
 
 EXPORT_SYMBOL (of_gpio_named_count)
 
int of_gpio_simple_xlate (struct gpio_chip *gc, const struct of_phandle_args *gpiospec, u32 *flags)
 
 EXPORT_SYMBOL (of_gpio_simple_xlate)
 
int of_mm_gpiochip_add (struct device_node *np, struct of_mm_gpio_chip *mm_gc)
 
 EXPORT_SYMBOL (of_mm_gpiochip_add)
 
void of_gpiochip_add (struct gpio_chip *chip)
 
void of_gpiochip_remove (struct gpio_chip *chip)
 

Function Documentation

EXPORT_SYMBOL ( of_get_named_gpio_flags  )
EXPORT_SYMBOL ( of_gpio_named_count  )
EXPORT_SYMBOL ( of_gpio_simple_xlate  )
EXPORT_SYMBOL ( of_mm_gpiochip_add  )
int of_get_named_gpio_flags ( struct device_node np,
const char propname,
int  index,
enum of_gpio_flags flags 
)

of_get_named_gpio_flags() - Get a GPIO number and flags to use with GPIO API : device node to get GPIO from : property name containing gpio specifier(s) : index of the GPIO : a flags pointer to fill in

Returns GPIO number to use with Linux generic GPIO API, or one of the errno value on the error condition. If is not NULL the function also fills in flags for the GPIO.

Definition at line 62 of file gpiolib-of.c.

unsigned int of_gpio_named_count ( struct device_node np,
const char propname 
)

of_gpio_named_count - Count GPIOs for a device : device node to count GPIOs for : property name containing gpio specifier(s)

The function returns the count of GPIOs specified for a node.

Note that the empty GPIO specifiers counts too. For example,

gpios = <0 &pio1 1 2 0 &pio2 3 4>;

defines four GPIOs (so this function will return 4), two of which are not specified.

Definition at line 107 of file gpiolib-of.c.

int of_gpio_simple_xlate ( struct gpio_chip *  gc,
const struct of_phandle_args gpiospec,
u32 flags 
)

of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags : pointer to the gpio_chip structure : device node of the GPIO chip : gpio specifier as found in the device tree : a flags pointer to fill in

This is simple translation function, suitable for the most 1:1 mapped gpio chips. This function performs only one sanity check: whether gpio is less than ngpios (that is specified in the gpio_chip).

Definition at line 136 of file gpiolib-of.c.

void of_gpiochip_add ( struct gpio_chip *  chip)

Definition at line 219 of file gpiolib-of.c.

void of_gpiochip_remove ( struct gpio_chip *  chip)

Definition at line 235 of file gpiolib-of.c.

int of_mm_gpiochip_add ( struct device_node np,
struct of_mm_gpio_chip *  mm_gc 
)

of_mm_gpiochip_add - Add memory mapped GPIO chip (bank) : device node of the GPIO chip : pointer to the of_mm_gpio_chip allocated structure

To use this function you should allocate and fill mm_gc with:

1) In the gpio_chip structure:

  • all the callbacks
  • of_gpio_n_cells
  • of_xlate callback (optional)

3) In the of_mm_gpio_chip structure:

  • save_regs callback (optional)

If succeeded, this function will map bank's memory and will do all necessary work for you. Then you'll able to use .regs to manage GPIOs from the callbacks.

Definition at line 182 of file gpiolib-of.c.