blob: 55eaf75decff4e048883b9fd1f7711c223d56e56 [file] [log] [blame]
Paul Mundtb3c185a2012-06-20 17:29:04 +09001/*
2 * SuperH Pin Function Controller GPIO driver.
3 *
4 * Copyright (C) 2008 Magnus Damm
5 * Copyright (C) 2009 - 2012 Paul Mundt
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
Laurent Pinchartc6193ea2012-12-15 23:50:47 +010011
12#define pr_fmt(fmt) KBUILD_MODNAME " gpio: " fmt
Paul Mundtb3c185a2012-06-20 17:29:04 +090013
Laurent Pinchart1724acf2012-12-15 23:50:48 +010014#include <linux/device.h>
Paul Mundtb3c185a2012-06-20 17:29:04 +090015#include <linux/gpio.h>
Laurent Pinchart90efde22012-12-15 23:50:52 +010016#include <linux/init.h>
Paul Mundtb3c185a2012-06-20 17:29:04 +090017#include <linux/module.h>
Paul Mundtca5481c62012-07-10 12:08:14 +090018#include <linux/pinctrl/consumer.h>
Laurent Pinchart90efde22012-12-15 23:50:52 +010019#include <linux/slab.h>
20#include <linux/spinlock.h>
Paul Mundtb3c185a2012-06-20 17:29:04 +090021
Laurent Pinchartf9165132012-12-15 23:50:44 +010022#include "core.h"
23
Laurent Pinchart51cb2262013-02-16 18:34:32 +010024struct sh_pfc_gpio_data_reg {
25 const struct pinmux_data_reg *info;
26 unsigned long shadow;
27};
28
Paul Mundtb3c185a2012-06-20 17:29:04 +090029struct sh_pfc_chip {
30 struct sh_pfc *pfc;
31 struct gpio_chip gpio_chip;
Laurent Pincharte51d5342013-02-17 00:26:33 +010032
33 struct sh_pfc_window *mem;
Laurent Pinchart51cb2262013-02-16 18:34:32 +010034 struct sh_pfc_gpio_data_reg *regs;
Paul Mundtb3c185a2012-06-20 17:29:04 +090035};
36
37static struct sh_pfc_chip *gpio_to_pfc_chip(struct gpio_chip *gc)
38{
39 return container_of(gc, struct sh_pfc_chip, gpio_chip);
40}
41
42static struct sh_pfc *gpio_to_pfc(struct gpio_chip *gc)
43{
44 return gpio_to_pfc_chip(gc)->pfc;
45}
46
Laurent Pinchart51cb2262013-02-16 18:34:32 +010047static void gpio_get_data_reg(struct sh_pfc_chip *chip, unsigned int gpio,
48 struct sh_pfc_gpio_data_reg **reg,
49 unsigned int *bit)
Laurent Pinchart41f12192013-02-15 02:04:55 +010050{
Laurent Pinchart51cb2262013-02-16 18:34:32 +010051 struct sh_pfc_pin *gpiop = sh_pfc_get_pin(chip->pfc, gpio);
52 unsigned int reg_idx;
Laurent Pinchart41f12192013-02-15 02:04:55 +010053
Laurent Pinchart51cb2262013-02-16 18:34:32 +010054 reg_idx = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT;
55
56 *reg = &chip->regs[reg_idx];
Laurent Pinchart41f12192013-02-15 02:04:55 +010057 *bit = (gpiop->flags & PINMUX_FLAG_DBIT) >> PINMUX_FLAG_DBIT_SHIFT;
58}
59
Laurent Pincharte51d5342013-02-17 00:26:33 +010060static unsigned long gpio_read_data_reg(struct sh_pfc_chip *chip,
61 const struct pinmux_data_reg *dreg)
62{
63 void __iomem *mem = dreg->reg - chip->mem->phys + chip->mem->virt;
64
65 return sh_pfc_read_raw_reg(mem, dreg->reg_width);
66}
67
68static void gpio_write_data_reg(struct sh_pfc_chip *chip,
69 const struct pinmux_data_reg *dreg,
70 unsigned long value)
71{
72 void __iomem *mem = dreg->reg - chip->mem->phys + chip->mem->virt;
73
74 sh_pfc_write_raw_reg(mem, dreg->reg_width, value);
75}
76
Laurent Pinchart41f12192013-02-15 02:04:55 +010077static void gpio_setup_data_reg(struct sh_pfc *pfc, unsigned gpio)
78{
79 struct sh_pfc_pin *gpiop = &pfc->info->pins[gpio];
Laurent Pincharte51d5342013-02-17 00:26:33 +010080 const struct pinmux_data_reg *dreg;
81 unsigned int bit;
82 unsigned int i;
Laurent Pinchart41f12192013-02-15 02:04:55 +010083
Laurent Pincharte51d5342013-02-17 00:26:33 +010084 for (i = 0, dreg = pfc->info->data_regs; dreg->reg; ++i, ++dreg) {
85 for (bit = 0; bit < dreg->reg_width; bit++) {
86 if (dreg->enum_ids[bit] == gpiop->enum_id) {
Laurent Pinchart41f12192013-02-15 02:04:55 +010087 gpiop->flags &= ~PINMUX_FLAG_DREG;
Laurent Pincharte51d5342013-02-17 00:26:33 +010088 gpiop->flags |= i << PINMUX_FLAG_DREG_SHIFT;
Laurent Pinchart41f12192013-02-15 02:04:55 +010089 gpiop->flags &= ~PINMUX_FLAG_DBIT;
Laurent Pincharte51d5342013-02-17 00:26:33 +010090 gpiop->flags |= bit << PINMUX_FLAG_DBIT_SHIFT;
Laurent Pinchart41f12192013-02-15 02:04:55 +010091 return;
92 }
93 }
Laurent Pinchart41f12192013-02-15 02:04:55 +010094 }
95
96 BUG();
97}
98
Laurent Pincharte51d5342013-02-17 00:26:33 +010099static int gpio_setup_data_regs(struct sh_pfc_chip *chip)
Laurent Pinchart41f12192013-02-15 02:04:55 +0100100{
Laurent Pincharte51d5342013-02-17 00:26:33 +0100101 struct sh_pfc *pfc = chip->pfc;
102 unsigned long addr = pfc->info->data_regs[0].reg;
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100103 const struct pinmux_data_reg *dreg;
Laurent Pincharte51d5342013-02-17 00:26:33 +0100104 unsigned int i;
Laurent Pinchart41f12192013-02-15 02:04:55 +0100105
Laurent Pincharte51d5342013-02-17 00:26:33 +0100106 /* Find the window that contain the GPIO registers. */
107 for (i = 0; i < pfc->num_windows; ++i) {
108 struct sh_pfc_window *window = &pfc->window[i];
109
110 if (addr >= window->phys && addr < window->phys + window->size)
111 break;
112 }
113
114 if (i == pfc->num_windows)
115 return -EINVAL;
116
117 /* GPIO data registers must be in the first memory resource. */
118 chip->mem = &pfc->window[i];
119
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100120 /* Count the number of data registers, allocate memory and initialize
121 * them.
122 */
123 for (i = 0; pfc->info->data_regs[i].reg_width; ++i)
124 ;
125
126 chip->regs = devm_kzalloc(pfc->dev, i * sizeof(*chip->regs),
127 GFP_KERNEL);
128 if (chip->regs == NULL)
129 return -ENOMEM;
130
131 for (i = 0, dreg = pfc->info->data_regs; dreg->reg_width; ++i, ++dreg) {
132 chip->regs[i].info = dreg;
133 chip->regs[i].shadow = gpio_read_data_reg(chip, dreg);
134 }
Laurent Pincharte51d5342013-02-17 00:26:33 +0100135
136 for (i = 0; i < pfc->info->nr_pins; i++) {
137 if (pfc->info->pins[i].enum_id == 0)
Laurent Pinchart41f12192013-02-15 02:04:55 +0100138 continue;
139
Laurent Pincharte51d5342013-02-17 00:26:33 +0100140 gpio_setup_data_reg(pfc, i);
Laurent Pinchart41f12192013-02-15 02:04:55 +0100141 }
142
Laurent Pincharte51d5342013-02-17 00:26:33 +0100143 return 0;
Laurent Pinchart41f12192013-02-15 02:04:55 +0100144}
145
Laurent Pinchart16883812012-12-06 14:49:25 +0100146/* -----------------------------------------------------------------------------
147 * Pin GPIOs
148 */
149
150static int gpio_pin_request(struct gpio_chip *gc, unsigned offset)
Paul Mundtb3c185a2012-06-20 17:29:04 +0900151{
Laurent Pinchart0b73ee52013-02-14 22:12:11 +0100152 struct sh_pfc *pfc = gpio_to_pfc(gc);
Laurent Pinchart934cb022013-02-14 22:35:09 +0100153 struct sh_pfc_pin *pin = sh_pfc_get_pin(pfc, offset);
Laurent Pinchart0b73ee52013-02-14 22:12:11 +0100154
Laurent Pinchart63d57382013-02-15 01:33:38 +0100155 if (pin == NULL || pin->enum_id == 0)
Laurent Pinchart0b73ee52013-02-14 22:12:11 +0100156 return -EINVAL;
157
Laurent Pinchart16883812012-12-06 14:49:25 +0100158 return pinctrl_request_gpio(offset);
Paul Mundtb3c185a2012-06-20 17:29:04 +0900159}
160
Laurent Pinchart16883812012-12-06 14:49:25 +0100161static void gpio_pin_free(struct gpio_chip *gc, unsigned offset)
Paul Mundtb3c185a2012-06-20 17:29:04 +0900162{
Laurent Pinchart16883812012-12-06 14:49:25 +0100163 return pinctrl_free_gpio(offset);
Paul Mundtb3c185a2012-06-20 17:29:04 +0900164}
165
Laurent Pincharte51d5342013-02-17 00:26:33 +0100166static void gpio_pin_set_value(struct sh_pfc_chip *chip, unsigned offset,
167 int value)
Paul Mundtb3c185a2012-06-20 17:29:04 +0900168{
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100169 struct sh_pfc_gpio_data_reg *reg;
Laurent Pinchart41f12192013-02-15 02:04:55 +0100170 unsigned long pos;
171 unsigned int bit;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900172
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100173 gpio_get_data_reg(chip, offset, &reg, &bit);
Laurent Pinchart41f12192013-02-15 02:04:55 +0100174
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100175 pos = reg->info->reg_width - (bit + 1);
Laurent Pinchart41f12192013-02-15 02:04:55 +0100176
177 if (value)
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100178 set_bit(pos, &reg->shadow);
Laurent Pinchart41f12192013-02-15 02:04:55 +0100179 else
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100180 clear_bit(pos, &reg->shadow);
Laurent Pinchart41f12192013-02-15 02:04:55 +0100181
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100182 gpio_write_data_reg(chip, reg->info, reg->shadow);
Paul Mundtb3c185a2012-06-20 17:29:04 +0900183}
184
Laurent Pinchart16883812012-12-06 14:49:25 +0100185static int gpio_pin_direction_input(struct gpio_chip *gc, unsigned offset)
Paul Mundtb3c185a2012-06-20 17:29:04 +0900186{
Laurent Pinchart16883812012-12-06 14:49:25 +0100187 return pinctrl_gpio_direction_input(offset);
188}
189
190static int gpio_pin_direction_output(struct gpio_chip *gc, unsigned offset,
191 int value)
192{
Laurent Pincharte51d5342013-02-17 00:26:33 +0100193 gpio_pin_set_value(gpio_to_pfc_chip(gc), offset, value);
Laurent Pinchart16883812012-12-06 14:49:25 +0100194
195 return pinctrl_gpio_direction_output(offset);
196}
197
198static int gpio_pin_get(struct gpio_chip *gc, unsigned offset)
199{
Laurent Pincharte51d5342013-02-17 00:26:33 +0100200 struct sh_pfc_chip *chip = gpio_to_pfc_chip(gc);
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100201 struct sh_pfc_gpio_data_reg *reg;
Laurent Pinchart41f12192013-02-15 02:04:55 +0100202 unsigned long pos;
203 unsigned int bit;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900204
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100205 gpio_get_data_reg(chip, offset, &reg, &bit);
Laurent Pinchart41f12192013-02-15 02:04:55 +0100206
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100207 pos = reg->info->reg_width - (bit + 1);
Laurent Pinchart41f12192013-02-15 02:04:55 +0100208
Laurent Pinchart51cb2262013-02-16 18:34:32 +0100209 return (gpio_read_data_reg(chip, reg->info) >> pos) & 1;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900210}
211
Laurent Pinchart16883812012-12-06 14:49:25 +0100212static void gpio_pin_set(struct gpio_chip *gc, unsigned offset, int value)
Paul Mundtca5481c62012-07-10 12:08:14 +0900213{
Laurent Pincharte51d5342013-02-17 00:26:33 +0100214 gpio_pin_set_value(gpio_to_pfc_chip(gc), offset, value);
Paul Mundtca5481c62012-07-10 12:08:14 +0900215}
216
Laurent Pinchart16883812012-12-06 14:49:25 +0100217static int gpio_pin_to_irq(struct gpio_chip *gc, unsigned offset)
Paul Mundtb3c185a2012-06-20 17:29:04 +0900218{
219 struct sh_pfc *pfc = gpio_to_pfc(gc);
Laurent Pinchartc07f54f2013-01-03 14:12:14 +0100220 int i, k;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900221
Laurent Pinchartc07f54f2013-01-03 14:12:14 +0100222 for (i = 0; i < pfc->info->gpio_irq_size; i++) {
223 unsigned short *gpios = pfc->info->gpio_irq[i].gpios;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900224
Laurent Pinchartc07f54f2013-01-03 14:12:14 +0100225 for (k = 0; gpios[k]; k++) {
226 if (gpios[k] == offset)
227 return pfc->info->gpio_irq[i].irq;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900228 }
229 }
230
231 return -ENOSYS;
232}
233
Laurent Pincharte51d5342013-02-17 00:26:33 +0100234static int gpio_pin_setup(struct sh_pfc_chip *chip)
Paul Mundtb3c185a2012-06-20 17:29:04 +0900235{
236 struct sh_pfc *pfc = chip->pfc;
237 struct gpio_chip *gc = &chip->gpio_chip;
Laurent Pincharte51d5342013-02-17 00:26:33 +0100238 int ret;
239
240 ret = gpio_setup_data_regs(chip);
241 if (ret < 0)
242 return ret;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900243
Laurent Pinchart16883812012-12-06 14:49:25 +0100244 gc->request = gpio_pin_request;
245 gc->free = gpio_pin_free;
246 gc->direction_input = gpio_pin_direction_input;
247 gc->get = gpio_pin_get;
248 gc->direction_output = gpio_pin_direction_output;
249 gc->set = gpio_pin_set;
250 gc->to_irq = gpio_pin_to_irq;
251
252 gc->label = pfc->info->name;
253 gc->dev = pfc->dev;
254 gc->owner = THIS_MODULE;
255 gc->base = 0;
Laurent Pinchart63d57382013-02-15 01:33:38 +0100256 gc->ngpio = pfc->nr_pins;
Laurent Pincharte51d5342013-02-17 00:26:33 +0100257
258 return 0;
Laurent Pinchart16883812012-12-06 14:49:25 +0100259}
260
261/* -----------------------------------------------------------------------------
262 * Function GPIOs
263 */
264
265static int gpio_function_request(struct gpio_chip *gc, unsigned offset)
266{
267 struct sh_pfc *pfc = gpio_to_pfc(gc);
Laurent Pincharta68fdca92013-02-14 17:36:56 +0100268 unsigned int mark = pfc->info->func_gpios[offset].enum_id;
Laurent Pinchart16883812012-12-06 14:49:25 +0100269 unsigned long flags;
270 int ret = -EINVAL;
271
272 pr_notice_once("Use of GPIO API for function requests is deprecated, convert to pinctrl\n");
273
Laurent Pincharta68fdca92013-02-14 17:36:56 +0100274 if (mark == 0)
Laurent Pinchart16883812012-12-06 14:49:25 +0100275 return ret;
276
277 spin_lock_irqsave(&pfc->lock, flags);
278
Laurent Pincharta68fdca92013-02-14 17:36:56 +0100279 if (sh_pfc_config_mux(pfc, mark, PINMUX_TYPE_FUNCTION, GPIO_CFG_DRYRUN))
Laurent Pinchart16883812012-12-06 14:49:25 +0100280 goto done;
281
Laurent Pincharta68fdca92013-02-14 17:36:56 +0100282 if (sh_pfc_config_mux(pfc, mark, PINMUX_TYPE_FUNCTION, GPIO_CFG_REQ))
Laurent Pinchart16883812012-12-06 14:49:25 +0100283 goto done;
284
285 ret = 0;
286
287done:
288 spin_unlock_irqrestore(&pfc->lock, flags);
289 return ret;
290}
291
292static void gpio_function_free(struct gpio_chip *gc, unsigned offset)
293{
294 struct sh_pfc *pfc = gpio_to_pfc(gc);
Laurent Pincharta68fdca92013-02-14 17:36:56 +0100295 unsigned int mark = pfc->info->func_gpios[offset].enum_id;
Laurent Pinchart16883812012-12-06 14:49:25 +0100296 unsigned long flags;
297
298 spin_lock_irqsave(&pfc->lock, flags);
299
Laurent Pincharta68fdca92013-02-14 17:36:56 +0100300 sh_pfc_config_mux(pfc, mark, PINMUX_TYPE_FUNCTION, GPIO_CFG_FREE);
Laurent Pinchart16883812012-12-06 14:49:25 +0100301
302 spin_unlock_irqrestore(&pfc->lock, flags);
303}
304
Laurent Pincharte51d5342013-02-17 00:26:33 +0100305static int gpio_function_setup(struct sh_pfc_chip *chip)
Laurent Pinchart16883812012-12-06 14:49:25 +0100306{
307 struct sh_pfc *pfc = chip->pfc;
308 struct gpio_chip *gc = &chip->gpio_chip;
309
310 gc->request = gpio_function_request;
311 gc->free = gpio_function_free;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900312
Laurent Pinchart19bb7fe32012-12-15 23:51:20 +0100313 gc->label = pfc->info->name;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900314 gc->owner = THIS_MODULE;
Laurent Pinchart63d57382013-02-15 01:33:38 +0100315 gc->base = pfc->nr_pins;
Laurent Pinchart16883812012-12-06 14:49:25 +0100316 gc->ngpio = pfc->info->nr_func_gpios;
Laurent Pincharte51d5342013-02-17 00:26:33 +0100317
318 return 0;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900319}
320
Laurent Pinchart16883812012-12-06 14:49:25 +0100321/* -----------------------------------------------------------------------------
322 * Register/unregister
323 */
324
325static struct sh_pfc_chip *
Laurent Pincharte51d5342013-02-17 00:26:33 +0100326sh_pfc_add_gpiochip(struct sh_pfc *pfc, int(*setup)(struct sh_pfc_chip *))
Paul Mundtb3c185a2012-06-20 17:29:04 +0900327{
328 struct sh_pfc_chip *chip;
329 int ret;
330
Laurent Pinchart1724acf2012-12-15 23:50:48 +0100331 chip = devm_kzalloc(pfc->dev, sizeof(*chip), GFP_KERNEL);
Paul Mundtb3c185a2012-06-20 17:29:04 +0900332 if (unlikely(!chip))
Laurent Pinchart16883812012-12-06 14:49:25 +0100333 return ERR_PTR(-ENOMEM);
Paul Mundtb3c185a2012-06-20 17:29:04 +0900334
335 chip->pfc = pfc;
336
Laurent Pincharte51d5342013-02-17 00:26:33 +0100337 ret = setup(chip);
338 if (ret < 0)
339 return ERR_PTR(ret);
Paul Mundtb3c185a2012-06-20 17:29:04 +0900340
341 ret = gpiochip_add(&chip->gpio_chip);
Laurent Pinchart1724acf2012-12-15 23:50:48 +0100342 if (unlikely(ret < 0))
Laurent Pinchart16883812012-12-06 14:49:25 +0100343 return ERR_PTR(ret);
344
345 pr_info("%s handling gpio %u -> %u\n",
346 chip->gpio_chip.label, chip->gpio_chip.base,
347 chip->gpio_chip.base + chip->gpio_chip.ngpio - 1);
348
349 return chip;
350}
351
352int sh_pfc_register_gpiochip(struct sh_pfc *pfc)
353{
Laurent Pinchart63d57382013-02-15 01:33:38 +0100354 const struct pinmux_range *ranges;
355 struct pinmux_range def_range;
Laurent Pinchart16883812012-12-06 14:49:25 +0100356 struct sh_pfc_chip *chip;
Laurent Pinchart63d57382013-02-15 01:33:38 +0100357 unsigned int nr_ranges;
358 unsigned int i;
Laurent Pinchart247127f2013-03-08 00:45:12 +0100359 int ret;
Laurent Pinchart16883812012-12-06 14:49:25 +0100360
Laurent Pinchart63d57382013-02-15 01:33:38 +0100361 /* Register the real GPIOs chip. */
Laurent Pinchart16883812012-12-06 14:49:25 +0100362 chip = sh_pfc_add_gpiochip(pfc, gpio_pin_setup);
363 if (IS_ERR(chip))
364 return PTR_ERR(chip);
Laurent Pinchart6f6a4a62012-12-15 23:50:46 +0100365
366 pfc->gpio = chip;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900367
Laurent Pinchart63d57382013-02-15 01:33:38 +0100368 /* Register the GPIO to pin mappings. */
369 if (pfc->info->ranges == NULL) {
370 def_range.begin = 0;
371 def_range.end = pfc->info->nr_pins - 1;
372 ranges = &def_range;
373 nr_ranges = 1;
374 } else {
375 ranges = pfc->info->ranges;
376 nr_ranges = pfc->info->nr_ranges;
377 }
Laurent Pinchart247127f2013-03-08 00:45:12 +0100378
Laurent Pinchart63d57382013-02-15 01:33:38 +0100379 for (i = 0; i < nr_ranges; ++i) {
380 const struct pinmux_range *range = &ranges[i];
381
382 ret = gpiochip_add_pin_range(&chip->gpio_chip,
383 dev_name(pfc->dev),
384 range->begin, range->begin,
385 range->end - range->begin + 1);
386 if (ret < 0)
387 return ret;
388 }
389
390 /* Register the function GPIOs chip. */
Laurent Pinchart16883812012-12-06 14:49:25 +0100391 chip = sh_pfc_add_gpiochip(pfc, gpio_function_setup);
392 if (IS_ERR(chip))
393 return PTR_ERR(chip);
394
395 pfc->func = chip;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900396
Paul Mundtb3c185a2012-06-20 17:29:04 +0900397 return 0;
398}
399
Laurent Pinchart6f6a4a62012-12-15 23:50:46 +0100400int sh_pfc_unregister_gpiochip(struct sh_pfc *pfc)
Paul Mundtb3c185a2012-06-20 17:29:04 +0900401{
Laurent Pinchart16883812012-12-06 14:49:25 +0100402 int err;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900403 int ret;
404
Laurent Pinchart16883812012-12-06 14:49:25 +0100405 ret = gpiochip_remove(&pfc->gpio->gpio_chip);
406 err = gpiochip_remove(&pfc->func->gpio_chip);
Paul Mundtb3c185a2012-06-20 17:29:04 +0900407
Laurent Pinchart16883812012-12-06 14:49:25 +0100408 return ret < 0 ? ret : err;
Paul Mundtb3c185a2012-06-20 17:29:04 +0900409}