aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2008-04-29 10:05:24 -0400
committerPaul Mackerras <paulus@samba.org>2008-05-23 01:27:19 -0400
commit21451155d8858773ee764e9218de2ca0f4d6fc38 (patch)
tree90018593f5dc833b010dc5729a0d4699e0f8c784 /drivers/of
parent09e67ca2c523544e6b38aa570a5f62a0cf20b87b (diff)
[POWERPC] of/gpio: Use dynamic base allocation
Since the "gpiolib: dynamic gpio number allocation" patch was recently merged into Linus' tree (commit 8d0aab2f16c4fa170f32e7a74a52cd0122bbafef), we can use dynamic GPIO base allocation now. This, in turn, removes number of gpios per chip constraint. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/gpio.c38
1 files changed, 1 insertions, 37 deletions
diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
index 000681e98f2c..1c9cab844f10 100644
--- a/drivers/of/gpio.c
+++ b/drivers/of/gpio.c
@@ -137,38 +137,6 @@ int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,
137} 137}
138EXPORT_SYMBOL(of_gpio_simple_xlate); 138EXPORT_SYMBOL(of_gpio_simple_xlate);
139 139
140/* Should be sufficient for now, later we'll use dynamic bases. */
141#if defined(CONFIG_PPC32) || defined(CONFIG_SPARC32)
142#define GPIOS_PER_CHIP 32
143#else
144#define GPIOS_PER_CHIP 64
145#endif
146
147static int of_get_gpiochip_base(struct device_node *np)
148{
149 struct device_node *gc = NULL;
150 int gpiochip_base = 0;
151
152 while ((gc = of_find_all_nodes(gc))) {
153 if (!of_get_property(gc, "gpio-controller", NULL))
154 continue;
155
156 if (gc != np) {
157 gpiochip_base += GPIOS_PER_CHIP;
158 continue;
159 }
160
161 of_node_put(gc);
162
163 if (gpiochip_base >= ARCH_NR_GPIOS)
164 return -ENOSPC;
165
166 return gpiochip_base;
167 }
168
169 return -ENOENT;
170}
171
172/** 140/**
173 * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank) 141 * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank)
174 * @np: device node of the GPIO chip 142 * @np: device node of the GPIO chip
@@ -205,11 +173,7 @@ int of_mm_gpiochip_add(struct device_node *np,
205 if (!mm_gc->regs) 173 if (!mm_gc->regs)
206 goto err1; 174 goto err1;
207 175
208 gc->base = of_get_gpiochip_base(np); 176 gc->base = -1;
209 if (gc->base < 0) {
210 ret = gc->base;
211 goto err1;
212 }
213 177
214 if (!of_gc->xlate) 178 if (!of_gc->xlate)
215 of_gc->xlate = of_gpio_simple_xlate; 179 of_gc->xlate = of_gpio_simple_xlate;