blob: 897cb8db5084ff8019cf7e265ffad2a81cd33bba [file] [log] [blame]
Hauke Mehrtensec43b082012-11-20 22:24:33 +00001/*
2 * Sonics Silicon Backplane
3 * GPIO driver
4 *
5 * Copyright 2011, Broadcom Corporation
6 * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
7 *
8 * Licensed under the GNU/GPL. See COPYING for details.
9 */
10
Michael Büschb8b60692018-07-31 21:56:38 +020011#include "ssb_private.h"
12
Linus Walleij2d4443b2015-12-08 23:00:46 +010013#include <linux/gpio/driver.h>
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +010014#include <linux/irq.h>
15#include <linux/interrupt.h>
16#include <linux/irqdomain.h>
Hauke Mehrtensec43b082012-11-20 22:24:33 +000017#include <linux/export.h>
18#include <linux/ssb/ssb.h>
19
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +010020
21/**************************************************
22 * Shared
23 **************************************************/
24
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +010025#if IS_ENABLED(CONFIG_SSB_EMBEDDED)
Hugh Sipièrec683ffe2016-06-04 17:17:01 +010026static int ssb_gpio_to_irq(struct gpio_chip *chip, unsigned int gpio)
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +010027{
Linus Walleij2d4443b2015-12-08 23:00:46 +010028 struct ssb_bus *bus = gpiochip_get_data(chip);
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +010029
30 if (bus->bustype == SSB_BUSTYPE_SSB)
31 return irq_find_mapping(bus->irq_domain, gpio);
32 else
33 return -EINVAL;
34}
35#endif
36
37/**************************************************
38 * ChipCommon
39 **************************************************/
40
Hugh Sipièrec683ffe2016-06-04 17:17:01 +010041static int ssb_gpio_chipco_get_value(struct gpio_chip *chip, unsigned int gpio)
Hauke Mehrtensec43b082012-11-20 22:24:33 +000042{
Linus Walleij2d4443b2015-12-08 23:00:46 +010043 struct ssb_bus *bus = gpiochip_get_data(chip);
Hauke Mehrtensec43b082012-11-20 22:24:33 +000044
45 return !!ssb_chipco_gpio_in(&bus->chipco, 1 << gpio);
46}
47
Hugh Sipièrec683ffe2016-06-04 17:17:01 +010048static void ssb_gpio_chipco_set_value(struct gpio_chip *chip, unsigned int gpio,
Hauke Mehrtensec43b082012-11-20 22:24:33 +000049 int value)
50{
Linus Walleij2d4443b2015-12-08 23:00:46 +010051 struct ssb_bus *bus = gpiochip_get_data(chip);
Hauke Mehrtensec43b082012-11-20 22:24:33 +000052
53 ssb_chipco_gpio_out(&bus->chipco, 1 << gpio, value ? 1 << gpio : 0);
54}
55
56static int ssb_gpio_chipco_direction_input(struct gpio_chip *chip,
Hugh Sipièrec683ffe2016-06-04 17:17:01 +010057 unsigned int gpio)
Hauke Mehrtensec43b082012-11-20 22:24:33 +000058{
Linus Walleij2d4443b2015-12-08 23:00:46 +010059 struct ssb_bus *bus = gpiochip_get_data(chip);
Hauke Mehrtensec43b082012-11-20 22:24:33 +000060
61 ssb_chipco_gpio_outen(&bus->chipco, 1 << gpio, 0);
62 return 0;
63}
64
65static int ssb_gpio_chipco_direction_output(struct gpio_chip *chip,
Hugh Sipièrec683ffe2016-06-04 17:17:01 +010066 unsigned int gpio, int value)
Hauke Mehrtensec43b082012-11-20 22:24:33 +000067{
Linus Walleij2d4443b2015-12-08 23:00:46 +010068 struct ssb_bus *bus = gpiochip_get_data(chip);
Hauke Mehrtensec43b082012-11-20 22:24:33 +000069
70 ssb_chipco_gpio_outen(&bus->chipco, 1 << gpio, 1 << gpio);
71 ssb_chipco_gpio_out(&bus->chipco, 1 << gpio, value ? 1 << gpio : 0);
72 return 0;
73}
74
Hugh Sipièrec683ffe2016-06-04 17:17:01 +010075static int ssb_gpio_chipco_request(struct gpio_chip *chip, unsigned int gpio)
Hauke Mehrtensec43b082012-11-20 22:24:33 +000076{
Linus Walleij2d4443b2015-12-08 23:00:46 +010077 struct ssb_bus *bus = gpiochip_get_data(chip);
Hauke Mehrtensec43b082012-11-20 22:24:33 +000078
79 ssb_chipco_gpio_control(&bus->chipco, 1 << gpio, 0);
80 /* clear pulldown */
81 ssb_chipco_gpio_pulldown(&bus->chipco, 1 << gpio, 0);
82 /* Set pullup */
83 ssb_chipco_gpio_pullup(&bus->chipco, 1 << gpio, 1 << gpio);
84
85 return 0;
86}
87
Hugh Sipièrec683ffe2016-06-04 17:17:01 +010088static void ssb_gpio_chipco_free(struct gpio_chip *chip, unsigned int gpio)
Hauke Mehrtensec43b082012-11-20 22:24:33 +000089{
Linus Walleij2d4443b2015-12-08 23:00:46 +010090 struct ssb_bus *bus = gpiochip_get_data(chip);
Hauke Mehrtensec43b082012-11-20 22:24:33 +000091
92 /* clear pullup */
93 ssb_chipco_gpio_pullup(&bus->chipco, 1 << gpio, 0);
94}
95
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +010096#if IS_ENABLED(CONFIG_SSB_EMBEDDED)
97static void ssb_gpio_irq_chipco_mask(struct irq_data *d)
Hauke Mehrtensa6ca2e12013-01-26 21:38:35 +010098{
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +010099 struct ssb_bus *bus = irq_data_get_irq_chip_data(d);
100 int gpio = irqd_to_hwirq(d);
Hauke Mehrtensa6ca2e12013-01-26 21:38:35 +0100101
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100102 ssb_chipco_gpio_intmask(&bus->chipco, BIT(gpio), 0);
Hauke Mehrtensa6ca2e12013-01-26 21:38:35 +0100103}
104
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100105static void ssb_gpio_irq_chipco_unmask(struct irq_data *d)
106{
107 struct ssb_bus *bus = irq_data_get_irq_chip_data(d);
108 int gpio = irqd_to_hwirq(d);
109 u32 val = ssb_chipco_gpio_in(&bus->chipco, BIT(gpio));
110
111 ssb_chipco_gpio_polarity(&bus->chipco, BIT(gpio), val);
112 ssb_chipco_gpio_intmask(&bus->chipco, BIT(gpio), BIT(gpio));
113}
114
115static struct irq_chip ssb_gpio_irq_chipco_chip = {
116 .name = "SSB-GPIO-CC",
117 .irq_mask = ssb_gpio_irq_chipco_mask,
118 .irq_unmask = ssb_gpio_irq_chipco_unmask,
119};
120
121static irqreturn_t ssb_gpio_irq_chipco_handler(int irq, void *dev_id)
122{
123 struct ssb_bus *bus = dev_id;
124 struct ssb_chipcommon *chipco = &bus->chipco;
125 u32 val = chipco_read32(chipco, SSB_CHIPCO_GPIOIN);
126 u32 mask = chipco_read32(chipco, SSB_CHIPCO_GPIOIRQ);
127 u32 pol = chipco_read32(chipco, SSB_CHIPCO_GPIOPOL);
128 unsigned long irqs = (val ^ pol) & mask;
129 int gpio;
130
131 if (!irqs)
132 return IRQ_NONE;
133
134 for_each_set_bit(gpio, &irqs, bus->gpio.ngpio)
Sebastian Andrzej Siewiorf285de72022-09-19 14:43:46 +0200135 generic_handle_domain_irq_safe(bus->irq_domain, gpio);
136
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100137 ssb_chipco_gpio_polarity(chipco, irqs, val & irqs);
138
139 return IRQ_HANDLED;
140}
141
142static int ssb_gpio_irq_chipco_domain_init(struct ssb_bus *bus)
143{
144 struct ssb_chipcommon *chipco = &bus->chipco;
145 struct gpio_chip *chip = &bus->gpio;
146 int gpio, hwirq, err;
147
148 if (bus->bustype != SSB_BUSTYPE_SSB)
149 return 0;
150
151 bus->irq_domain = irq_domain_add_linear(NULL, chip->ngpio,
152 &irq_domain_simple_ops, chipco);
153 if (!bus->irq_domain) {
154 err = -ENODEV;
155 goto err_irq_domain;
156 }
157 for (gpio = 0; gpio < chip->ngpio; gpio++) {
158 int irq = irq_create_mapping(bus->irq_domain, gpio);
159
160 irq_set_chip_data(irq, bus);
161 irq_set_chip_and_handler(irq, &ssb_gpio_irq_chipco_chip,
162 handle_simple_irq);
163 }
164
165 hwirq = ssb_mips_irq(bus->chipco.dev) + 2;
166 err = request_irq(hwirq, ssb_gpio_irq_chipco_handler, IRQF_SHARED,
167 "gpio", bus);
168 if (err)
169 goto err_req_irq;
170
171 ssb_chipco_gpio_intmask(&bus->chipco, ~0, 0);
172 chipco_set32(chipco, SSB_CHIPCO_IRQMASK, SSB_CHIPCO_IRQ_GPIO);
173
174 return 0;
175
176err_req_irq:
177 for (gpio = 0; gpio < chip->ngpio; gpio++) {
178 int irq = irq_find_mapping(bus->irq_domain, gpio);
179
180 irq_dispose_mapping(irq);
181 }
182 irq_domain_remove(bus->irq_domain);
183err_irq_domain:
184 return err;
185}
186
187static void ssb_gpio_irq_chipco_domain_exit(struct ssb_bus *bus)
188{
189 struct ssb_chipcommon *chipco = &bus->chipco;
190 struct gpio_chip *chip = &bus->gpio;
191 int gpio;
192
193 if (bus->bustype != SSB_BUSTYPE_SSB)
194 return;
195
196 chipco_mask32(chipco, SSB_CHIPCO_IRQMASK, ~SSB_CHIPCO_IRQ_GPIO);
197 free_irq(ssb_mips_irq(bus->chipco.dev) + 2, chipco);
198 for (gpio = 0; gpio < chip->ngpio; gpio++) {
199 int irq = irq_find_mapping(bus->irq_domain, gpio);
200
201 irq_dispose_mapping(irq);
202 }
203 irq_domain_remove(bus->irq_domain);
204}
205#else
206static int ssb_gpio_irq_chipco_domain_init(struct ssb_bus *bus)
207{
208 return 0;
209}
210
211static void ssb_gpio_irq_chipco_domain_exit(struct ssb_bus *bus)
212{
213}
214#endif
215
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000216static int ssb_gpio_chipco_init(struct ssb_bus *bus)
217{
218 struct gpio_chip *chip = &bus->gpio;
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100219 int err;
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000220
221 chip->label = "ssb_chipco_gpio";
222 chip->owner = THIS_MODULE;
223 chip->request = ssb_gpio_chipco_request;
224 chip->free = ssb_gpio_chipco_free;
225 chip->get = ssb_gpio_chipco_get_value;
226 chip->set = ssb_gpio_chipco_set_value;
227 chip->direction_input = ssb_gpio_chipco_direction_input;
228 chip->direction_output = ssb_gpio_chipco_direction_output;
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100229#if IS_ENABLED(CONFIG_SSB_EMBEDDED)
230 chip->to_irq = ssb_gpio_to_irq;
231#endif
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000232 chip->ngpio = 16;
233 /* There is just one SoC in one device and its GPIO addresses should be
234 * deterministic to address them more easily. The other buses could get
Shubhankar Kuranagatti5615eb52021-04-28 21:37:47 +0530235 * a random base number.
236 */
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000237 if (bus->bustype == SSB_BUSTYPE_SSB)
238 chip->base = 0;
239 else
240 chip->base = -1;
241
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100242 err = ssb_gpio_irq_chipco_domain_init(bus);
243 if (err)
244 return err;
245
Linus Walleij2d4443b2015-12-08 23:00:46 +0100246 err = gpiochip_add_data(chip, bus);
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100247 if (err) {
248 ssb_gpio_irq_chipco_domain_exit(bus);
249 return err;
250 }
251
252 return 0;
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000253}
254
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100255/**************************************************
256 * EXTIF
257 **************************************************/
258
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000259#ifdef CONFIG_SSB_DRIVER_EXTIF
260
Hugh Sipièrec683ffe2016-06-04 17:17:01 +0100261static int ssb_gpio_extif_get_value(struct gpio_chip *chip, unsigned int gpio)
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000262{
Linus Walleij2d4443b2015-12-08 23:00:46 +0100263 struct ssb_bus *bus = gpiochip_get_data(chip);
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000264
265 return !!ssb_extif_gpio_in(&bus->extif, 1 << gpio);
266}
267
Hugh Sipièrec683ffe2016-06-04 17:17:01 +0100268static void ssb_gpio_extif_set_value(struct gpio_chip *chip, unsigned int gpio,
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000269 int value)
270{
Linus Walleij2d4443b2015-12-08 23:00:46 +0100271 struct ssb_bus *bus = gpiochip_get_data(chip);
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000272
273 ssb_extif_gpio_out(&bus->extif, 1 << gpio, value ? 1 << gpio : 0);
274}
275
276static int ssb_gpio_extif_direction_input(struct gpio_chip *chip,
Hugh Sipièrec683ffe2016-06-04 17:17:01 +0100277 unsigned int gpio)
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000278{
Linus Walleij2d4443b2015-12-08 23:00:46 +0100279 struct ssb_bus *bus = gpiochip_get_data(chip);
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000280
281 ssb_extif_gpio_outen(&bus->extif, 1 << gpio, 0);
282 return 0;
283}
284
285static int ssb_gpio_extif_direction_output(struct gpio_chip *chip,
Hugh Sipièrec683ffe2016-06-04 17:17:01 +0100286 unsigned int gpio, int value)
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000287{
Linus Walleij2d4443b2015-12-08 23:00:46 +0100288 struct ssb_bus *bus = gpiochip_get_data(chip);
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000289
290 ssb_extif_gpio_outen(&bus->extif, 1 << gpio, 1 << gpio);
291 ssb_extif_gpio_out(&bus->extif, 1 << gpio, value ? 1 << gpio : 0);
292 return 0;
293}
294
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100295#if IS_ENABLED(CONFIG_SSB_EMBEDDED)
296static void ssb_gpio_irq_extif_mask(struct irq_data *d)
Hauke Mehrtensa6ca2e12013-01-26 21:38:35 +0100297{
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100298 struct ssb_bus *bus = irq_data_get_irq_chip_data(d);
299 int gpio = irqd_to_hwirq(d);
Hauke Mehrtensa6ca2e12013-01-26 21:38:35 +0100300
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100301 ssb_extif_gpio_intmask(&bus->extif, BIT(gpio), 0);
Hauke Mehrtensa6ca2e12013-01-26 21:38:35 +0100302}
303
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100304static void ssb_gpio_irq_extif_unmask(struct irq_data *d)
305{
306 struct ssb_bus *bus = irq_data_get_irq_chip_data(d);
307 int gpio = irqd_to_hwirq(d);
308 u32 val = ssb_extif_gpio_in(&bus->extif, BIT(gpio));
309
310 ssb_extif_gpio_polarity(&bus->extif, BIT(gpio), val);
311 ssb_extif_gpio_intmask(&bus->extif, BIT(gpio), BIT(gpio));
312}
313
314static struct irq_chip ssb_gpio_irq_extif_chip = {
315 .name = "SSB-GPIO-EXTIF",
316 .irq_mask = ssb_gpio_irq_extif_mask,
317 .irq_unmask = ssb_gpio_irq_extif_unmask,
318};
319
320static irqreturn_t ssb_gpio_irq_extif_handler(int irq, void *dev_id)
321{
322 struct ssb_bus *bus = dev_id;
323 struct ssb_extif *extif = &bus->extif;
324 u32 val = ssb_read32(extif->dev, SSB_EXTIF_GPIO_IN);
325 u32 mask = ssb_read32(extif->dev, SSB_EXTIF_GPIO_INTMASK);
326 u32 pol = ssb_read32(extif->dev, SSB_EXTIF_GPIO_INTPOL);
327 unsigned long irqs = (val ^ pol) & mask;
328 int gpio;
329
330 if (!irqs)
331 return IRQ_NONE;
332
333 for_each_set_bit(gpio, &irqs, bus->gpio.ngpio)
Sebastian Andrzej Siewiorf285de72022-09-19 14:43:46 +0200334 generic_handle_domain_irq_safe(bus->irq_domain, gpio);
335
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100336 ssb_extif_gpio_polarity(extif, irqs, val & irqs);
337
338 return IRQ_HANDLED;
339}
340
341static int ssb_gpio_irq_extif_domain_init(struct ssb_bus *bus)
342{
343 struct ssb_extif *extif = &bus->extif;
344 struct gpio_chip *chip = &bus->gpio;
345 int gpio, hwirq, err;
346
347 if (bus->bustype != SSB_BUSTYPE_SSB)
348 return 0;
349
350 bus->irq_domain = irq_domain_add_linear(NULL, chip->ngpio,
351 &irq_domain_simple_ops, extif);
352 if (!bus->irq_domain) {
353 err = -ENODEV;
354 goto err_irq_domain;
355 }
356 for (gpio = 0; gpio < chip->ngpio; gpio++) {
357 int irq = irq_create_mapping(bus->irq_domain, gpio);
358
359 irq_set_chip_data(irq, bus);
360 irq_set_chip_and_handler(irq, &ssb_gpio_irq_extif_chip,
361 handle_simple_irq);
362 }
363
364 hwirq = ssb_mips_irq(bus->extif.dev) + 2;
365 err = request_irq(hwirq, ssb_gpio_irq_extif_handler, IRQF_SHARED,
366 "gpio", bus);
367 if (err)
368 goto err_req_irq;
369
370 ssb_extif_gpio_intmask(&bus->extif, ~0, 0);
371
372 return 0;
373
374err_req_irq:
375 for (gpio = 0; gpio < chip->ngpio; gpio++) {
376 int irq = irq_find_mapping(bus->irq_domain, gpio);
377
378 irq_dispose_mapping(irq);
379 }
380 irq_domain_remove(bus->irq_domain);
381err_irq_domain:
382 return err;
383}
384
385static void ssb_gpio_irq_extif_domain_exit(struct ssb_bus *bus)
386{
387 struct ssb_extif *extif = &bus->extif;
388 struct gpio_chip *chip = &bus->gpio;
389 int gpio;
390
391 if (bus->bustype != SSB_BUSTYPE_SSB)
392 return;
393
394 free_irq(ssb_mips_irq(bus->extif.dev) + 2, extif);
395 for (gpio = 0; gpio < chip->ngpio; gpio++) {
396 int irq = irq_find_mapping(bus->irq_domain, gpio);
397
398 irq_dispose_mapping(irq);
399 }
400 irq_domain_remove(bus->irq_domain);
401}
402#else
403static int ssb_gpio_irq_extif_domain_init(struct ssb_bus *bus)
404{
405 return 0;
406}
407
408static void ssb_gpio_irq_extif_domain_exit(struct ssb_bus *bus)
409{
410}
411#endif
412
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000413static int ssb_gpio_extif_init(struct ssb_bus *bus)
414{
415 struct gpio_chip *chip = &bus->gpio;
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100416 int err;
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000417
418 chip->label = "ssb_extif_gpio";
419 chip->owner = THIS_MODULE;
420 chip->get = ssb_gpio_extif_get_value;
421 chip->set = ssb_gpio_extif_set_value;
422 chip->direction_input = ssb_gpio_extif_direction_input;
423 chip->direction_output = ssb_gpio_extif_direction_output;
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100424#if IS_ENABLED(CONFIG_SSB_EMBEDDED)
425 chip->to_irq = ssb_gpio_to_irq;
426#endif
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000427 chip->ngpio = 5;
428 /* There is just one SoC in one device and its GPIO addresses should be
429 * deterministic to address them more easily. The other buses could get
Shubhankar Kuranagatti5615eb52021-04-28 21:37:47 +0530430 * a random base number.
431 */
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000432 if (bus->bustype == SSB_BUSTYPE_SSB)
433 chip->base = 0;
434 else
435 chip->base = -1;
436
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100437 err = ssb_gpio_irq_extif_domain_init(bus);
438 if (err)
439 return err;
440
Linus Walleij2d4443b2015-12-08 23:00:46 +0100441 err = gpiochip_add_data(chip, bus);
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100442 if (err) {
443 ssb_gpio_irq_extif_domain_exit(bus);
444 return err;
445 }
446
447 return 0;
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000448}
449
450#else
451static int ssb_gpio_extif_init(struct ssb_bus *bus)
452{
453 return -ENOTSUPP;
454}
455#endif
456
Rafał Miłecki7c1bc0d2014-01-13 19:56:08 +0100457/**************************************************
458 * Init
459 **************************************************/
460
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000461int ssb_gpio_init(struct ssb_bus *bus)
462{
463 if (ssb_chipco_available(&bus->chipco))
464 return ssb_gpio_chipco_init(bus);
465 else if (ssb_extif_available(&bus->extif))
466 return ssb_gpio_extif_init(bus);
Hauke Mehrtensec43b082012-11-20 22:24:33 +0000467 return -1;
468}
Hauke Mehrtens600485e2013-02-03 23:25:34 +0100469
470int ssb_gpio_unregister(struct ssb_bus *bus)
471{
472 if (ssb_chipco_available(&bus->chipco) ||
473 ssb_extif_available(&bus->extif)) {
abdoulaye berthe88d5e522014-07-12 22:30:14 +0200474 gpiochip_remove(&bus->gpio);
475 return 0;
Hauke Mehrtens600485e2013-02-03 23:25:34 +0100476 }
Hauke Mehrtens600485e2013-02-03 23:25:34 +0100477 return -1;
478}