Bartosz Golaszewski | b5c5f39 | 2018-04-26 22:07:47 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright (C) 2017-2018 Bartosz Golaszewski <brgl@bgdev.pl> |
| 4 | */ |
| 5 | |
Bartosz Golaszewski | b19af51 | 2017-08-14 16:53:16 +0200 | [diff] [blame] | 6 | #ifndef _LINUX_IRQ_SIM_H |
| 7 | #define _LINUX_IRQ_SIM_H |
Bartosz Golaszewski | b19af51 | 2017-08-14 16:53:16 +0200 | [diff] [blame] | 8 | |
| 9 | #include <linux/irq_work.h> |
Bartosz Golaszewski | 44e72c7 | 2017-08-14 16:53:17 +0200 | [diff] [blame] | 10 | #include <linux/device.h> |
Bartosz Golaszewski | b19af51 | 2017-08-14 16:53:16 +0200 | [diff] [blame] | 11 | |
| 12 | /* |
| 13 | * Provides a framework for allocating simulated interrupts which can be |
| 14 | * requested like normal irqs and enqueued from process context. |
| 15 | */ |
| 16 | |
| 17 | struct irq_sim_work_ctx { |
| 18 | struct irq_work work; |
Bartosz Golaszewski | 0645990 | 2018-11-09 18:21:32 +0100 | [diff] [blame] | 19 | unsigned long *pending; |
Bartosz Golaszewski | b19af51 | 2017-08-14 16:53:16 +0200 | [diff] [blame] | 20 | }; |
| 21 | |
| 22 | struct irq_sim_irq_ctx { |
| 23 | int irqnum; |
| 24 | bool enabled; |
| 25 | }; |
| 26 | |
| 27 | struct irq_sim { |
| 28 | struct irq_sim_work_ctx work_ctx; |
| 29 | int irq_base; |
| 30 | unsigned int irq_count; |
| 31 | struct irq_sim_irq_ctx *irqs; |
| 32 | }; |
| 33 | |
| 34 | int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs); |
Bartosz Golaszewski | 44e72c7 | 2017-08-14 16:53:17 +0200 | [diff] [blame] | 35 | int devm_irq_sim_init(struct device *dev, struct irq_sim *sim, |
| 36 | unsigned int num_irqs); |
Bartosz Golaszewski | b19af51 | 2017-08-14 16:53:16 +0200 | [diff] [blame] | 37 | void irq_sim_fini(struct irq_sim *sim); |
| 38 | void irq_sim_fire(struct irq_sim *sim, unsigned int offset); |
| 39 | int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset); |
| 40 | |
| 41 | #endif /* _LINUX_IRQ_SIM_H */ |