Skip to content

Commit 76c05c8

Browse files
Rob Herringglikely
authored andcommitted
gpio: pl061: add DT binding support
This adds devicetree binding support to the ARM pl061 driver removing the platform_data dependency. When DT binding is used, the gpio numbering is assigned dynamically. For now, interrupts are not supported with DT until irqdomains learn dynamic irq assignment. Rather than add another case of -1, updating the driver to use NO_IRQ. Signed-off-by: Rob Herring <rob.herring@calxeda.com> Acked-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
1 parent eb9ae7f commit 76c05c8

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

‎drivers/gpio/gpio-pl061.c‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static int pl061_to_irq(struct gpio_chip *gc, unsigned offset)
118118
{
119119
struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
120120

121-
if (chip->irq_base == (unsigned) -1)
121+
if (chip->irq_base == NO_IRQ)
122122
return -EINVAL;
123123

124124
return chip->irq_base + offset;
@@ -246,6 +246,18 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
246246
if (chip == NULL)
247247
return -ENOMEM;
248248

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+
249261
if (!request_mem_region(dev->res.start,
250262
resource_size(&dev->res), "pl061")) {
251263
ret = -EBUSY;
@@ -267,14 +279,11 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
267279
chip->gc.get = pl061_get_value;
268280
chip->gc.set = pl061_set_value;
269281
chip->gc.to_irq = pl061_to_irq;
270-
chip->gc.base = pdata->gpio_base;
271282
chip->gc.ngpio = PL061_GPIO_NR;
272283
chip->gc.label = dev_name(&dev->dev);
273284
chip->gc.dev = &dev->dev;
274285
chip->gc.owner = THIS_MODULE;
275286

276-
chip->irq_base = pdata->irq_base;
277-
278287
ret = gpiochip_add(&chip->gc);
279288
if (ret)
280289
goto iounmap;
@@ -283,7 +292,7 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
283292
* irq_chip support
284293
*/
285294

286-
if (chip->irq_base == (unsigned) -1)
295+
if (chip->irq_base == NO_IRQ)
287296
return 0;
288297

289298
writeb(0, chip->base + GPIOIE); /* disable irqs */
@@ -307,11 +316,13 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)
307316
list_add(&chip->list, chip_list);
308317

309318
for (i = 0; i < PL061_GPIO_NR; i++) {
310-
if (pdata->directions & (1 << i))
311-
pl061_direction_output(&chip->gc, i,
312-
pdata->values & (1 << i));
313-
else
314-
pl061_direction_input(&chip->gc, i);
319+
if (pdata) {
320+
if (pdata->directions & (1 << i))
321+
pl061_direction_output(&chip->gc, i,
322+
pdata->values & (1 << i));
323+
else
324+
pl061_direction_input(&chip->gc, i);
325+
}
315326

316327
irq_set_chip_and_handler(i + chip->irq_base, &pl061_irqchip,
317328
handle_simple_irq);

‎include/linux/amba/pl061.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ struct pl061_platform_data {
77
unsigned gpio_base;
88

99
/* number of the first IRQ.
10-
* If the IRQ functionality in not desired this must be set to
11-
* (unsigned) -1.
10+
* If the IRQ functionality in not desired this must be set to NO_IRQ.
1211
*/
1312
unsigned irq_base;
1413

0 commit comments

Comments
 (0)