diff options
Diffstat (limited to 'drivers/gpio/gpio-pl061.c')
-rw-r--r-- | drivers/gpio/gpio-pl061.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 2c5a18f32bf3..093c90bd3c1d 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c | |||
@@ -118,7 +118,7 @@ static int pl061_to_irq(struct gpio_chip *gc, unsigned offset) | |||
118 | { | 118 | { |
119 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 119 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); |
120 | 120 | ||
121 | if (chip->irq_base == (unsigned) -1) | 121 | if (chip->irq_base == NO_IRQ) |
122 | return -EINVAL; | 122 | return -EINVAL; |
123 | 123 | ||
124 | return chip->irq_base + offset; | 124 | return chip->irq_base + offset; |
@@ -246,6 +246,18 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) | |||
246 | if (chip == NULL) | 246 | if (chip == NULL) |
247 | return -ENOMEM; | 247 | return -ENOMEM; |
248 | 248 | ||
249 | pdata = dev->dev.platform_data; | ||
250 | if (pdata) { | ||
251 | chip->gc.base = pdata->gpio_base; | ||
252 | chip->irq_base = pdata->irq_base; | ||
253 | } else if (dev->dev.of_node) { | ||
254 | chip->gc.base = -1; | ||
255 | chip->irq_base = NO_IRQ; | ||
256 | } else { | ||
257 | ret = -ENODEV; | ||
258 | goto free_mem; | ||
259 | } | ||
260 | |||
249 | if (!request_mem_region(dev->res.start, | 261 | if (!request_mem_region(dev->res.start, |
250 | resource_size(&dev->res), "pl061")) { | 262 | resource_size(&dev->res), "pl061")) { |
251 | ret = -EBUSY; | 263 | ret = -EBUSY; |
@@ -267,14 +279,11 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) | |||
267 | chip->gc.get = pl061_get_value; | 279 | chip->gc.get = pl061_get_value; |
268 | chip->gc.set = pl061_set_value; | 280 | chip->gc.set = pl061_set_value; |
269 | chip->gc.to_irq = pl061_to_irq; | 281 | chip->gc.to_irq = pl061_to_irq; |
270 | chip->gc.base = pdata->gpio_base; | ||
271 | chip->gc.ngpio = PL061_GPIO_NR; | 282 | chip->gc.ngpio = PL061_GPIO_NR; |
272 | chip->gc.label = dev_name(&dev->dev); | 283 | chip->gc.label = dev_name(&dev->dev); |
273 | chip->gc.dev = &dev->dev; | 284 | chip->gc.dev = &dev->dev; |
274 | chip->gc.owner = THIS_MODULE; | 285 | chip->gc.owner = THIS_MODULE; |
275 | 286 | ||
276 | chip->irq_base = pdata->irq_base; | ||
277 | |||
278 | ret = gpiochip_add(&chip->gc); | 287 | ret = gpiochip_add(&chip->gc); |
279 | if (ret) | 288 | if (ret) |
280 | goto iounmap; | 289 | goto iounmap; |
@@ -283,7 +292,7 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) | |||
283 | * irq_chip support | 292 | * irq_chip support |
284 | */ | 293 | */ |
285 | 294 | ||
286 | if (chip->irq_base == (unsigned) -1) | 295 | if (chip->irq_base == NO_IRQ) |
287 | return 0; | 296 | return 0; |
288 | 297 | ||
289 | writeb(0, chip->base + GPIOIE); /* disable irqs */ | 298 | writeb(0, chip->base + GPIOIE); /* disable irqs */ |
@@ -307,11 +316,13 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id) | |||
307 | list_add(&chip->list, chip_list); | 316 | list_add(&chip->list, chip_list); |
308 | 317 | ||
309 | for (i = 0; i < PL061_GPIO_NR; i++) { | 318 | for (i = 0; i < PL061_GPIO_NR; i++) { |
310 | if (pdata->directions & (1 << i)) | 319 | if (pdata) { |
311 | pl061_direction_output(&chip->gc, i, | 320 | if (pdata->directions & (1 << i)) |
312 | pdata->values & (1 << i)); | 321 | pl061_direction_output(&chip->gc, i, |
313 | else | 322 | pdata->values & (1 << i)); |
314 | pl061_direction_input(&chip->gc, i); | 323 | else |
324 | pl061_direction_input(&chip->gc, i); | ||
325 | } | ||
315 | 326 | ||
316 | irq_set_chip_and_handler(i + chip->irq_base, &pl061_irqchip, | 327 | irq_set_chip_and_handler(i + chip->irq_base, &pl061_irqchip, |
317 | handle_simple_irq); | 328 | handle_simple_irq); |