aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/of_gpio.h
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2008-04-11 09:06:45 -0400
committerPaul Mackerras <paulus@samba.org>2008-04-16 17:46:11 -0400
commit863fbf4966a7ac301a4077e4a04d73e8abfdd7b2 (patch)
treebbe7d6f08f9dbd706882c48024d41fc2578c3370 /include/linux/of_gpio.h
parenta2879fef7ccd1e0891a8f147c20ce6f1501e373b (diff)
[POWERPC] OF helpers for the GPIO API
This implements various helpers to support OF bindings for the GPIO LIB API. Previously this was PowerPC specific, but it seems this code isn't arch-dependent anyhow, so let's place it into of/. SPARC will not see this addition yet, real hardware seem to not use GPIOs at all. But this might change: http://www.leox.org/docs/faq_MLleon.html "16-bit I/O port" sounds promising. :-) Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Acked-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include/linux/of_gpio.h')
-rw-r--r--include/linux/of_gpio.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
new file mode 100644
index 000000000000..2ee97e9877a7
--- /dev/null
+++ b/include/linux/of_gpio.h
@@ -0,0 +1,69 @@
1/*
2 * OF helpers for the GPIO API
3 *
4 * Copyright (c) 2007-2008 MontaVista Software, Inc.
5 *
6 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
7 *
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.
12 */
13
14#ifndef __LINUX_OF_GPIO_H
15#define __LINUX_OF_GPIO_H
16
17#include <linux/errno.h>
18#include <asm/gpio.h>
19
20#ifdef CONFIG_OF_GPIO
21
22/*
23 * Generic OF GPIO chip
24 */
25struct of_gpio_chip {
26 struct gpio_chip gc;
27 int gpio_cells;
28 int (*xlate)(struct of_gpio_chip *of_gc, struct device_node *np,
29 const void *gpio_spec);
30};
31
32static inline struct of_gpio_chip *to_of_gpio_chip(struct gpio_chip *gc)
33{
34 return container_of(gc, struct of_gpio_chip, gc);
35}
36
37/*
38 * OF GPIO chip for memory mapped banks
39 */
40struct of_mm_gpio_chip {
41 struct of_gpio_chip of_gc;
42 void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
43 void __iomem *regs;
44};
45
46static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
47{
48 struct of_gpio_chip *of_gc = to_of_gpio_chip(gc);
49
50 return container_of(of_gc, struct of_mm_gpio_chip, of_gc);
51}
52
53extern int of_get_gpio(struct device_node *np, int index);
54extern int of_mm_gpiochip_add(struct device_node *np,
55 struct of_mm_gpio_chip *mm_gc);
56extern int of_gpio_simple_xlate(struct of_gpio_chip *of_gc,
57 struct device_node *np,
58 const void *gpio_spec);
59#else
60
61/* Drivers may not strictly depend on the GPIO support, so let them link. */
62static inline int of_get_gpio(struct device_node *np, int index)
63{
64 return -ENOSYS;
65}
66
67#endif /* CONFIG_OF_GPIO */
68
69#endif /* __LINUX_OF_GPIO_H */