Bartosz Golaszewski | b19af51 | 2017-08-14 16:53:16 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_IRQ_SIM_H |
| 2 | #define _LINUX_IRQ_SIM_H |
| 3 | /* |
| 4 | * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/irq_work.h> |
Bartosz Golaszewski | 44e72c7 | 2017-08-14 16:53:17 +0200 | [diff] [blame] | 13 | #include <linux/device.h> |
Bartosz Golaszewski | b19af51 | 2017-08-14 16:53:16 +0200 | [diff] [blame] | 14 | |
| 15 | /* |
| 16 | * Provides a framework for allocating simulated interrupts which can be |
| 17 | * requested like normal irqs and enqueued from process context. |
| 18 | */ |
| 19 | |
| 20 | struct irq_sim_work_ctx { |
| 21 | struct irq_work work; |
| 22 | int irq; |
| 23 | }; |
| 24 | |
| 25 | struct irq_sim_irq_ctx { |
| 26 | int irqnum; |
| 27 | bool enabled; |
| 28 | }; |
| 29 | |
| 30 | struct irq_sim { |
| 31 | struct irq_sim_work_ctx work_ctx; |
| 32 | int irq_base; |
| 33 | unsigned int irq_count; |
| 34 | struct irq_sim_irq_ctx *irqs; |
| 35 | }; |
| 36 | |
| 37 | int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs); |
Bartosz Golaszewski | 44e72c7 | 2017-08-14 16:53:17 +0200 | [diff] [blame] | 38 | int devm_irq_sim_init(struct device *dev, struct irq_sim *sim, |
| 39 | unsigned int num_irqs); |
Bartosz Golaszewski | b19af51 | 2017-08-14 16:53:16 +0200 | [diff] [blame] | 40 | void irq_sim_fini(struct irq_sim *sim); |
| 41 | void irq_sim_fire(struct irq_sim *sim, unsigned int offset); |
| 42 | int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset); |
| 43 | |
| 44 | #endif /* _LINUX_IRQ_SIM_H */ |