2 * OF helpers for the GPIO API
4 * Copyright (c) 2007-2008 MontaVista Software, Inc.
6 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #ifndef __LINUX_OF_GPIO_H
15 #define __LINUX_OF_GPIO_H
17 #include <linux/errno.h>
18 #include <linux/gpio.h>
23 * Generic OF GPIO chip
28 int (*xlate)(struct of_gpio_chip *of_gc, struct device_node *np,
29 const void *gpio_spec);
32 static inline struct of_gpio_chip *to_of_gpio_chip(struct gpio_chip *gc)
34 return container_of(gc, struct of_gpio_chip, gc);
38 * OF GPIO chip for memory mapped banks
40 struct of_mm_gpio_chip {
41 struct of_gpio_chip of_gc;
42 void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
46 static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
48 struct of_gpio_chip *of_gc = to_of_gpio_chip(gc);
50 return container_of(of_gc, struct of_mm_gpio_chip, of_gc);
53 extern int of_get_gpio(struct device_node *np, int index);
54 extern int of_mm_gpiochip_add(struct device_node *np,
55 struct of_mm_gpio_chip *mm_gc);
56 extern int of_gpio_simple_xlate(struct of_gpio_chip *of_gc,
57 struct device_node *np,
58 const void *gpio_spec);
61 /* Drivers may not strictly depend on the GPIO support, so let them link. */
62 static inline int of_get_gpio(struct device_node *np, int index)
67 #endif /* CONFIG_OF_GPIO */
69 #endif /* __LINUX_OF_GPIO_H */