diff options
author | Jiang Qiu <qiujiang@huawei.com> | 2016-04-28 05:32:03 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-04-29 05:24:47 -0400 |
commit | e6cb3486f5a1bd55240e8326691dbfb86564f8c6 (patch) | |
tree | 6c260ebefee508cc78041148d2aa58ef6f424221 | |
parent | 4ba8cfa79f44a9489b1d562430cb70fb53200adb (diff) |
gpio: dwapb: add gpio-signaled acpi event support
This patch adds gpio-signaled acpi event support. It is used for
power button on hisilicon D02 board, an arm64 platform.
The corresponding DSDT file is defined as follows:
Device(GPI0) {
Name(_HID, "HISI0181")
Name(_ADR, 0)
Name(_UID, 0)
Name (_CRS, ResourceTemplate () {
Memory32Fixed (ReadWrite, 0x802e0000, 0x10000)
Interrupt (ResourceConsumer, Level, ActiveHigh,
Exclusive,,,) {344}
})
Device(PRTa) {
Name (_DSD, Package () {
Package () {
Package () {"reg",0},
Package () {"snps,nr-gpios",32},
}
})
}
Name (_AEI, ResourceTemplate () {
GpioInt(Edge, ActiveLow, ExclusiveAndWake,
PullUp, , " \\_SB.GPI0") {8}
})
Method (_E08, 0x0, NotSerialized) {
Notify (\_SB.PWRB, 0x80)
}
}
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jiang Qiu <qiujiang@huawei.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-dwapb.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 7517c2fcba56..b235d7005c85 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * | 7 | * |
8 | * All enquiries to support@picochip.com | 8 | * All enquiries to support@picochip.com |
9 | */ | 9 | */ |
10 | #include <linux/acpi.h> | ||
10 | #include <linux/gpio/driver.h> | 11 | #include <linux/gpio/driver.h> |
11 | /* FIXME: for gpio_get_value(), replace this with direct register read */ | 12 | /* FIXME: for gpio_get_value(), replace this with direct register read */ |
12 | #include <linux/gpio.h> | 13 | #include <linux/gpio.h> |
@@ -27,6 +28,8 @@ | |||
27 | #include <linux/platform_data/gpio-dwapb.h> | 28 | #include <linux/platform_data/gpio-dwapb.h> |
28 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
29 | 30 | ||
31 | #include "gpiolib.h" | ||
32 | |||
30 | #define GPIO_SWPORTA_DR 0x00 | 33 | #define GPIO_SWPORTA_DR 0x00 |
31 | #define GPIO_SWPORTA_DDR 0x04 | 34 | #define GPIO_SWPORTA_DDR 0x04 |
32 | #define GPIO_SWPORTB_DR 0x0c | 35 | #define GPIO_SWPORTB_DR 0x0c |
@@ -435,6 +438,10 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio, | |||
435 | else | 438 | else |
436 | port->is_registered = true; | 439 | port->is_registered = true; |
437 | 440 | ||
441 | /* Add GPIO-signaled ACPI event support */ | ||
442 | if (pp->irq) | ||
443 | acpi_gpiochip_request_interrupts(&port->gc); | ||
444 | |||
438 | return err; | 445 | return err; |
439 | } | 446 | } |
440 | 447 | ||
@@ -502,6 +509,9 @@ dwapb_gpio_get_pdata(struct device *dev) | |||
502 | dev_warn(dev, "no irq for port%d\n", pp->idx); | 509 | dev_warn(dev, "no irq for port%d\n", pp->idx); |
503 | } | 510 | } |
504 | 511 | ||
512 | if (has_acpi_companion(dev) && pp->idx == 0) | ||
513 | pp->irq = platform_get_irq(to_platform_device(dev), 0); | ||
514 | |||
505 | pp->irq_shared = false; | 515 | pp->irq_shared = false; |
506 | pp->gpio_base = -1; | 516 | pp->gpio_base = -1; |
507 | } | 517 | } |
@@ -576,6 +586,12 @@ static const struct of_device_id dwapb_of_match[] = { | |||
576 | }; | 586 | }; |
577 | MODULE_DEVICE_TABLE(of, dwapb_of_match); | 587 | MODULE_DEVICE_TABLE(of, dwapb_of_match); |
578 | 588 | ||
589 | static const struct acpi_device_id dwapb_acpi_match[] = { | ||
590 | {"HISI0181", 0}, | ||
591 | { } | ||
592 | }; | ||
593 | MODULE_DEVICE_TABLE(acpi, dwapb_acpi_match); | ||
594 | |||
579 | #ifdef CONFIG_PM_SLEEP | 595 | #ifdef CONFIG_PM_SLEEP |
580 | static int dwapb_gpio_suspend(struct device *dev) | 596 | static int dwapb_gpio_suspend(struct device *dev) |
581 | { | 597 | { |
@@ -670,6 +686,7 @@ static struct platform_driver dwapb_gpio_driver = { | |||
670 | .name = "gpio-dwapb", | 686 | .name = "gpio-dwapb", |
671 | .pm = &dwapb_gpio_pm_ops, | 687 | .pm = &dwapb_gpio_pm_ops, |
672 | .of_match_table = of_match_ptr(dwapb_of_match), | 688 | .of_match_table = of_match_ptr(dwapb_of_match), |
689 | .acpi_match_table = ACPI_PTR(dwapb_acpi_match), | ||
673 | }, | 690 | }, |
674 | .probe = dwapb_gpio_probe, | 691 | .probe = dwapb_gpio_probe, |
675 | .remove = dwapb_gpio_remove, | 692 | .remove = dwapb_gpio_remove, |