aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev/qe_lib
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2010-06-08 09:48:16 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-07-05 18:14:30 -0400
commita19e3da5bc5fc6c10ab73f310bea80f3845b4531 (patch)
tree49b6e952f48e56d9701f92e0c24044a14b676a34 /arch/powerpc/sysdev/qe_lib
parentcedb1881ba32f7e9cd49250bd79debccbe52b094 (diff)
of/gpio: Kill of_gpio_chip and add members directly to gpio_chip
The OF gpio infrastructure is great for describing GPIO connections within the device tree. However, using a GPIO binding still requires changes to the gpio controller just to add an of_gpio structure. In most cases, the gpio controller doesn't actually need any special support and the simple OF gpio mapping function is more than sufficient. Additional, the current scheme of using of_gpio_chip requires a convoluted scheme to maintain 1:1 mappings between of_gpio_chip and gpio_chip instances. If the struct of_gpio_chip data members were moved into struct gpio_chip, then it would simplify the processing of OF gpio bindings, and it would make it trivial to use device tree OF connections on existing gpiolib controller drivers. This patch eliminates the of_gpio_chip structure and moves the relevant fields into struct gpio_chip (conditional on CONFIG_OF_GPIO). This move simplifies the existing code and prepares for adding automatic device tree support to existing drivers. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Anton Vorontsov <avorontsov@ru.mvista.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Bill Gatliff <bgat@billgatliff.com> Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'arch/powerpc/sysdev/qe_lib')
-rw-r--r--arch/powerpc/sysdev/qe_lib/gpio.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c
index dc8f8d618074..194478c2f4b4 100644
--- a/arch/powerpc/sysdev/qe_lib/gpio.c
+++ b/arch/powerpc/sysdev/qe_lib/gpio.c
@@ -138,8 +138,8 @@ struct qe_pin {
138struct qe_pin *qe_pin_request(struct device_node *np, int index) 138struct qe_pin *qe_pin_request(struct device_node *np, int index)
139{ 139{
140 struct qe_pin *qe_pin; 140 struct qe_pin *qe_pin;
141 struct device_node *gc; 141 struct device_node *gpio_np;
142 struct of_gpio_chip *of_gc = NULL; 142 struct gpio_chip *gc;
143 struct of_mm_gpio_chip *mm_gc; 143 struct of_mm_gpio_chip *mm_gc;
144 struct qe_gpio_chip *qe_gc; 144 struct qe_gpio_chip *qe_gc;
145 int err; 145 int err;
@@ -155,40 +155,40 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
155 } 155 }
156 156
157 err = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, 157 err = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index,
158 &gc, &gpio_spec); 158 &gpio_np, &gpio_spec);
159 if (err) { 159 if (err) {
160 pr_debug("%s: can't parse gpios property\n", __func__); 160 pr_debug("%s: can't parse gpios property\n", __func__);
161 goto err0; 161 goto err0;
162 } 162 }
163 163
164 if (!of_device_is_compatible(gc, "fsl,mpc8323-qe-pario-bank")) { 164 if (!of_device_is_compatible(gpio_np, "fsl,mpc8323-qe-pario-bank")) {
165 pr_debug("%s: tried to get a non-qe pin\n", __func__); 165 pr_debug("%s: tried to get a non-qe pin\n", __func__);
166 err = -EINVAL; 166 err = -EINVAL;
167 goto err1; 167 goto err1;
168 } 168 }
169 169
170 of_gc = gc->data; 170 gc = gpio_np->data;
171 if (!of_gc) { 171 if (!gc) {
172 pr_debug("%s: gpio controller %s isn't registered\n", 172 pr_debug("%s: gpio controller %s isn't registered\n",
173 np->full_name, gc->full_name); 173 np->full_name, gpio_np->full_name);
174 err = -ENODEV; 174 err = -ENODEV;
175 goto err1; 175 goto err1;
176 } 176 }
177 177
178 gpio_cells = of_get_property(gc, "#gpio-cells", &size); 178 gpio_cells = of_get_property(gpio_np, "#gpio-cells", &size);
179 if (!gpio_cells || size != sizeof(*gpio_cells) || 179 if (!gpio_cells || size != sizeof(*gpio_cells) ||
180 *gpio_cells != of_gc->gpio_cells) { 180 *gpio_cells != gc->of_gpio_n_cells) {
181 pr_debug("%s: wrong #gpio-cells for %s\n", 181 pr_debug("%s: wrong #gpio-cells for %s\n",
182 np->full_name, gc->full_name); 182 np->full_name, gpio_np->full_name);
183 err = -EINVAL; 183 err = -EINVAL;
184 goto err1; 184 goto err1;
185 } 185 }
186 186
187 err = of_gc->xlate(of_gc, np, gpio_spec, NULL); 187 err = gc->of_xlate(gc, np, gpio_spec, NULL);
188 if (err < 0) 188 if (err < 0)
189 goto err1; 189 goto err1;
190 190
191 mm_gc = to_of_mm_gpio_chip(&of_gc->gc); 191 mm_gc = to_of_mm_gpio_chip(gc);
192 qe_gc = to_qe_gpio_chip(mm_gc); 192 qe_gc = to_qe_gpio_chip(mm_gc);
193 193
194 spin_lock_irqsave(&qe_gc->lock, flags); 194 spin_lock_irqsave(&qe_gc->lock, flags);
@@ -206,7 +206,7 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
206 if (!err) 206 if (!err)
207 return qe_pin; 207 return qe_pin;
208err1: 208err1:
209 of_node_put(gc); 209 of_node_put(gpio_np);
210err0: 210err0:
211 kfree(qe_pin); 211 kfree(qe_pin);
212 pr_debug("%s failed with status %d\n", __func__, err); 212 pr_debug("%s failed with status %d\n", __func__, err);
@@ -307,7 +307,6 @@ static int __init qe_add_gpiochips(void)
307 int ret; 307 int ret;
308 struct qe_gpio_chip *qe_gc; 308 struct qe_gpio_chip *qe_gc;
309 struct of_mm_gpio_chip *mm_gc; 309 struct of_mm_gpio_chip *mm_gc;
310 struct of_gpio_chip *of_gc;
311 struct gpio_chip *gc; 310 struct gpio_chip *gc;
312 311
313 qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL); 312 qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL);
@@ -319,11 +318,10 @@ static int __init qe_add_gpiochips(void)
319 spin_lock_init(&qe_gc->lock); 318 spin_lock_init(&qe_gc->lock);
320 319
321 mm_gc = &qe_gc->mm_gc; 320 mm_gc = &qe_gc->mm_gc;
322 of_gc = &mm_gc->of_gc; 321 gc = &mm_gc->gc;
323 gc = &of_gc->gc;
324 322
325 mm_gc->save_regs = qe_gpio_save_regs; 323 mm_gc->save_regs = qe_gpio_save_regs;
326 of_gc->gpio_cells = 2; 324 gc->of_gpio_n_cells = 2;
327 gc->ngpio = QE_PIO_PINS; 325 gc->ngpio = QE_PIO_PINS;
328 gc->direction_input = qe_gpio_dir_in; 326 gc->direction_input = qe_gpio_dir_in;
329 gc->direction_output = qe_gpio_dir_out; 327 gc->direction_output = qe_gpio_dir_out;