diff options
author | Olof Johansson <olof@lixom.net> | 2012-09-05 18:35:48 -0400 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2012-09-05 18:35:48 -0400 |
commit | 1875962377574b4edb7b164001e3e341c25290d5 (patch) | |
tree | 374a5299403ec21e2d9a66a6548ce876a388b589 /drivers/gpio/gpio-pxa.c | |
parent | 5cbee140a28c2746449ae31e85738043ae4da927 (diff) | |
parent | c88a79a7789b2909ad1cf69ea2c9142030bbd6f4 (diff) |
Merge branch 'soc-core' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas into next/dt
* 'soc-core' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas:
ARM: mach-shmobile: Add compilation support for dtbs using 'make dtbs'
+ sync to 3.6-rc3
Diffstat (limited to 'drivers/gpio/gpio-pxa.c')
-rw-r--r-- | drivers/gpio/gpio-pxa.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index db5c2958f973..9528779ca463 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c | |||
@@ -65,6 +65,7 @@ static int irq_base; | |||
65 | 65 | ||
66 | #ifdef CONFIG_OF | 66 | #ifdef CONFIG_OF |
67 | static struct irq_domain *domain; | 67 | static struct irq_domain *domain; |
68 | static struct device_node *pxa_gpio_of_node; | ||
68 | #endif | 69 | #endif |
69 | 70 | ||
70 | struct pxa_gpio_chip { | 71 | struct pxa_gpio_chip { |
@@ -231,6 +232,24 @@ static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
231 | (value ? GPSR_OFFSET : GPCR_OFFSET)); | 232 | (value ? GPSR_OFFSET : GPCR_OFFSET)); |
232 | } | 233 | } |
233 | 234 | ||
235 | #ifdef CONFIG_OF_GPIO | ||
236 | static int pxa_gpio_of_xlate(struct gpio_chip *gc, | ||
237 | const struct of_phandle_args *gpiospec, | ||
238 | u32 *flags) | ||
239 | { | ||
240 | if (gpiospec->args[0] > pxa_last_gpio) | ||
241 | return -EINVAL; | ||
242 | |||
243 | if (gc != &pxa_gpio_chips[gpiospec->args[0] / 32].chip) | ||
244 | return -EINVAL; | ||
245 | |||
246 | if (flags) | ||
247 | *flags = gpiospec->args[1]; | ||
248 | |||
249 | return gpiospec->args[0] % 32; | ||
250 | } | ||
251 | #endif | ||
252 | |||
234 | static int __devinit pxa_init_gpio_chip(int gpio_end, | 253 | static int __devinit pxa_init_gpio_chip(int gpio_end, |
235 | int (*set_wake)(unsigned int, unsigned int)) | 254 | int (*set_wake)(unsigned int, unsigned int)) |
236 | { | 255 | { |
@@ -258,6 +277,11 @@ static int __devinit pxa_init_gpio_chip(int gpio_end, | |||
258 | c->get = pxa_gpio_get; | 277 | c->get = pxa_gpio_get; |
259 | c->set = pxa_gpio_set; | 278 | c->set = pxa_gpio_set; |
260 | c->to_irq = pxa_gpio_to_irq; | 279 | c->to_irq = pxa_gpio_to_irq; |
280 | #ifdef CONFIG_OF_GPIO | ||
281 | c->of_node = pxa_gpio_of_node; | ||
282 | c->of_xlate = pxa_gpio_of_xlate; | ||
283 | c->of_gpio_n_cells = 2; | ||
284 | #endif | ||
261 | 285 | ||
262 | /* number of GPIOs on last bank may be less than 32 */ | 286 | /* number of GPIOs on last bank may be less than 32 */ |
263 | c->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32; | 287 | c->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32; |
@@ -447,6 +471,7 @@ static int pxa_gpio_nums(void) | |||
447 | return count; | 471 | return count; |
448 | } | 472 | } |
449 | 473 | ||
474 | #ifdef CONFIG_OF | ||
450 | static struct of_device_id pxa_gpio_dt_ids[] = { | 475 | static struct of_device_id pxa_gpio_dt_ids[] = { |
451 | { .compatible = "mrvl,pxa-gpio" }, | 476 | { .compatible = "mrvl,pxa-gpio" }, |
452 | { .compatible = "mrvl,mmp-gpio", .data = (void *)MMP_GPIO }, | 477 | { .compatible = "mrvl,mmp-gpio", .data = (void *)MMP_GPIO }, |
@@ -464,9 +489,9 @@ static int pxa_irq_domain_map(struct irq_domain *d, unsigned int irq, | |||
464 | 489 | ||
465 | const struct irq_domain_ops pxa_irq_domain_ops = { | 490 | const struct irq_domain_ops pxa_irq_domain_ops = { |
466 | .map = pxa_irq_domain_map, | 491 | .map = pxa_irq_domain_map, |
492 | .xlate = irq_domain_xlate_twocell, | ||
467 | }; | 493 | }; |
468 | 494 | ||
469 | #ifdef CONFIG_OF | ||
470 | static int __devinit pxa_gpio_probe_dt(struct platform_device *pdev) | 495 | static int __devinit pxa_gpio_probe_dt(struct platform_device *pdev) |
471 | { | 496 | { |
472 | int ret, nr_banks, nr_gpios; | 497 | int ret, nr_banks, nr_gpios; |
@@ -504,6 +529,7 @@ static int __devinit pxa_gpio_probe_dt(struct platform_device *pdev) | |||
504 | } | 529 | } |
505 | domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0, | 530 | domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0, |
506 | &pxa_irq_domain_ops, NULL); | 531 | &pxa_irq_domain_ops, NULL); |
532 | pxa_gpio_of_node = np; | ||
507 | return 0; | 533 | return 0; |
508 | err: | 534 | err: |
509 | iounmap(gpio_reg_base); | 535 | iounmap(gpio_reg_base); |
@@ -622,7 +648,7 @@ static struct platform_driver pxa_gpio_driver = { | |||
622 | .probe = pxa_gpio_probe, | 648 | .probe = pxa_gpio_probe, |
623 | .driver = { | 649 | .driver = { |
624 | .name = "pxa-gpio", | 650 | .name = "pxa-gpio", |
625 | .of_match_table = pxa_gpio_dt_ids, | 651 | .of_match_table = of_match_ptr(pxa_gpio_dt_ids), |
626 | }, | 652 | }, |
627 | }; | 653 | }; |
628 | 654 | ||