aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/xilinx_gpio.c
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 /drivers/gpio/xilinx_gpio.c
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 'drivers/gpio/xilinx_gpio.c')
-rw-r--r--drivers/gpio/xilinx_gpio.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index b8fa65b5bfca..2993c40b48e1 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -161,14 +161,12 @@ static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc)
161static int __devinit xgpio_of_probe(struct device_node *np) 161static int __devinit xgpio_of_probe(struct device_node *np)
162{ 162{
163 struct xgpio_instance *chip; 163 struct xgpio_instance *chip;
164 struct of_gpio_chip *ofchip;
165 int status = 0; 164 int status = 0;
166 const u32 *tree_info; 165 const u32 *tree_info;
167 166
168 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 167 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
169 if (!chip) 168 if (!chip)
170 return -ENOMEM; 169 return -ENOMEM;
171 ofchip = &chip->mmchip.of_gc;
172 170
173 /* Update GPIO state shadow register with default value */ 171 /* Update GPIO state shadow register with default value */
174 tree_info = of_get_property(np, "xlnx,dout-default", NULL); 172 tree_info = of_get_property(np, "xlnx,dout-default", NULL);
@@ -182,21 +180,21 @@ static int __devinit xgpio_of_probe(struct device_node *np)
182 chip->gpio_dir = *tree_info; 180 chip->gpio_dir = *tree_info;
183 181
184 /* Check device node and parent device node for device width */ 182 /* Check device node and parent device node for device width */
185 ofchip->gc.ngpio = 32; /* By default assume full GPIO controller */ 183 chip->mmchip.gc.ngpio = 32; /* By default assume full GPIO controller */
186 tree_info = of_get_property(np, "xlnx,gpio-width", NULL); 184 tree_info = of_get_property(np, "xlnx,gpio-width", NULL);
187 if (!tree_info) 185 if (!tree_info)
188 tree_info = of_get_property(np->parent, 186 tree_info = of_get_property(np->parent,
189 "xlnx,gpio-width", NULL); 187 "xlnx,gpio-width", NULL);
190 if (tree_info) 188 if (tree_info)
191 ofchip->gc.ngpio = *tree_info; 189 chip->mmchip.gc.ngpio = *tree_info;
192 190
193 spin_lock_init(&chip->gpio_lock); 191 spin_lock_init(&chip->gpio_lock);
194 192
195 ofchip->gpio_cells = 2; 193 chip->mmchip.gc.of_gpio_n_cells = 2;
196 ofchip->gc.direction_input = xgpio_dir_in; 194 chip->mmchip.gc.direction_input = xgpio_dir_in;
197 ofchip->gc.direction_output = xgpio_dir_out; 195 chip->mmchip.gc.direction_output = xgpio_dir_out;
198 ofchip->gc.get = xgpio_get; 196 chip->mmchip.gc.get = xgpio_get;
199 ofchip->gc.set = xgpio_set; 197 chip->mmchip.gc.set = xgpio_set;
200 198
201 chip->mmchip.save_regs = xgpio_save_regs; 199 chip->mmchip.save_regs = xgpio_save_regs;
202 200