|
9 | 9 | #include <linux/module.h> |
10 | 10 | #include <linux/bitops.h> |
11 | 11 | #include <linux/seq_file.h> |
| 12 | +#include <linux/interrupt.h> |
12 | 13 |
|
13 | 14 | #include "gpio-phytium-core.h" |
14 | 15 |
|
@@ -378,6 +379,35 @@ int phytium_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) |
378 | 379 | } |
379 | 380 | EXPORT_SYMBOL_GPL(phytium_gpio_get_direction); |
380 | 381 |
|
| 382 | +int phytium_gpio_irq_set_wake(struct irq_data *d, unsigned int enable) |
| 383 | +{ |
| 384 | + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
| 385 | + struct phytium_gpio *gpio = gpiochip_get_data(gc); |
| 386 | + struct phytium_gpio_ctx *ctx = &gpio->ctx; |
| 387 | + irq_hw_number_t bit = irqd_to_hwirq(d); |
| 388 | + int ret; |
| 389 | + |
| 390 | + if (gpio->irq[bit]) |
| 391 | + ret = irq_set_irq_wake(gpio->irq[bit], enable); |
| 392 | + else |
| 393 | + ret = irq_set_irq_wake(gpio->irq[0], enable); |
| 394 | + |
| 395 | + if (ret < 0) |
| 396 | + dev_err(gc->parent, "set gpio irq wake failed!\n"); |
| 397 | + |
| 398 | + if (enable) { |
| 399 | + ctx->wake_en |= BIT(bit); |
| 400 | + if (gpio->is_resuming == 1) { |
| 401 | + writel(~ctx->wake_en, gpio->regs + GPIO_INTMASK); |
| 402 | + writel(ctx->wake_en, gpio->regs + GPIO_INTEN); |
| 403 | + } |
| 404 | + } else |
| 405 | + ctx->wake_en &= ~BIT(bit); |
| 406 | + |
| 407 | + return 0; |
| 408 | +} |
| 409 | +EXPORT_SYMBOL_GPL(phytium_gpio_irq_set_wake); |
| 410 | + |
381 | 411 | int phytium_gpio_irq_set_affinity(struct irq_data *d, const struct cpumask *mask_val, bool force) |
382 | 412 | { |
383 | 413 | int hwirq = irqd_to_hwirq(d); |
|
0 commit comments