diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/gpio.h | 12 | ||||
-rw-r--r-- | include/linux/of_gpio.h | 29 |
2 files changed, 17 insertions, 24 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 4f3d75e1ad39..af2544ef0b59 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h | |||
@@ -31,6 +31,7 @@ static inline int gpio_is_valid(int number) | |||
31 | struct device; | 31 | struct device; |
32 | struct seq_file; | 32 | struct seq_file; |
33 | struct module; | 33 | struct module; |
34 | struct device_node; | ||
34 | 35 | ||
35 | /** | 36 | /** |
36 | * struct gpio_chip - abstract a GPIO controller | 37 | * struct gpio_chip - abstract a GPIO controller |
@@ -106,6 +107,17 @@ struct gpio_chip { | |||
106 | const char *const *names; | 107 | const char *const *names; |
107 | unsigned can_sleep:1; | 108 | unsigned can_sleep:1; |
108 | unsigned exported:1; | 109 | unsigned exported:1; |
110 | |||
111 | #if defined(CONFIG_OF_GPIO) | ||
112 | /* | ||
113 | * If CONFIG_OF is enabled, then all GPIO controllers described in the | ||
114 | * device tree automatically may have an OF translation | ||
115 | */ | ||
116 | struct device_node *of_node; | ||
117 | int of_gpio_n_cells; | ||
118 | int (*of_xlate)(struct gpio_chip *gc, struct device_node *np, | ||
119 | const void *gpio_spec, u32 *flags); | ||
120 | #endif | ||
109 | }; | 121 | }; |
110 | 122 | ||
111 | extern const char *gpiochip_is_requested(struct gpio_chip *chip, | 123 | extern const char *gpiochip_is_requested(struct gpio_chip *chip, |
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index fc2472c3c254..460d6810c5eb 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h | |||
@@ -33,34 +33,17 @@ enum of_gpio_flags { | |||
33 | #ifdef CONFIG_OF_GPIO | 33 | #ifdef CONFIG_OF_GPIO |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * Generic OF GPIO chip | ||
37 | */ | ||
38 | struct of_gpio_chip { | ||
39 | struct gpio_chip gc; | ||
40 | int gpio_cells; | ||
41 | int (*xlate)(struct of_gpio_chip *of_gc, struct device_node *np, | ||
42 | const void *gpio_spec, enum of_gpio_flags *flags); | ||
43 | }; | ||
44 | |||
45 | static inline struct of_gpio_chip *to_of_gpio_chip(struct gpio_chip *gc) | ||
46 | { | ||
47 | return container_of(gc, struct of_gpio_chip, gc); | ||
48 | } | ||
49 | |||
50 | /* | ||
51 | * OF GPIO chip for memory mapped banks | 36 | * OF GPIO chip for memory mapped banks |
52 | */ | 37 | */ |
53 | struct of_mm_gpio_chip { | 38 | struct of_mm_gpio_chip { |
54 | struct of_gpio_chip of_gc; | 39 | struct gpio_chip gc; |
55 | void (*save_regs)(struct of_mm_gpio_chip *mm_gc); | 40 | void (*save_regs)(struct of_mm_gpio_chip *mm_gc); |
56 | void __iomem *regs; | 41 | void __iomem *regs; |
57 | }; | 42 | }; |
58 | 43 | ||
59 | static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) | 44 | static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) |
60 | { | 45 | { |
61 | struct of_gpio_chip *of_gc = to_of_gpio_chip(gc); | 46 | return container_of(gc, struct of_mm_gpio_chip, gc); |
62 | |||
63 | return container_of(of_gc, struct of_mm_gpio_chip, of_gc); | ||
64 | } | 47 | } |
65 | 48 | ||
66 | extern int of_get_gpio_flags(struct device_node *np, int index, | 49 | extern int of_get_gpio_flags(struct device_node *np, int index, |
@@ -69,11 +52,9 @@ extern unsigned int of_gpio_count(struct device_node *np); | |||
69 | 52 | ||
70 | extern int of_mm_gpiochip_add(struct device_node *np, | 53 | extern int of_mm_gpiochip_add(struct device_node *np, |
71 | struct of_mm_gpio_chip *mm_gc); | 54 | struct of_mm_gpio_chip *mm_gc); |
72 | extern int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, | 55 | extern int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, |
73 | struct device_node *np, | 56 | const void *gpio_spec, u32 *flags); |
74 | const void *gpio_spec, | 57 | #else /* CONFIG_OF_GPIO */ |
75 | enum of_gpio_flags *flags); | ||
76 | #else | ||
77 | 58 | ||
78 | /* Drivers may not strictly depend on the GPIO support, so let them link. */ | 59 | /* Drivers may not strictly depend on the GPIO support, so let them link. */ |
79 | static inline int of_get_gpio_flags(struct device_node *np, int index, | 60 | static inline int of_get_gpio_flags(struct device_node *np, int index, |