summaryrefslogtreecommitdiffstats
path: root/include/linux/irq_sim.h
diff options
context:
space:
mode:
authorBartosz Golaszewski <brgl@bgdev.pl>2017-08-14 16:53:16 +0200
committerThomas Gleixner <tglx@linutronix.de>2017-08-16 16:40:02 +0200
commitb19af510e67e6ca696b8721f45c148119437307c (patch)
tree11cdc519ec17a7696b3c8ee0f37351fde8dec6c3 /include/linux/irq_sim.h
parentef954844c7ace62f773f4f23e28d2d915adc419f (diff)
downloadlinux-0-day-b19af510e67e6ca696b8721f45c148119437307c.tar.gz
linux-0-day-b19af510e67e6ca696b8721f45c148119437307c.tar.xz
genirq/irq_sim: Add a simple interrupt simulator framework
Implement a simple, irq_work-based framework for simulating interrupts. Currently the API exposes routines for initializing and deinitializing the simulator object, enqueueing the interrupts and retrieving the allocated interrupt numbers based on the offset of the dummy interrupt in the simulator struct. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Marc Zyngier <marc.zyngier@arm.com> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: linux-doc@vger.kernel.org Cc: linux-gpio@vger.kernel.org Cc: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org> Cc: Jonathan Cameron <jic23@kernel.org> Link: http://lkml.kernel.org/r/20170814145318.6495-2-brgl@bgdev.pl Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux/irq_sim.h')
-rw-r--r--include/linux/irq_sim.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/linux/irq_sim.h b/include/linux/irq_sim.h
new file mode 100644
index 0000000000000..39ce57bfa9953
--- /dev/null
+++ b/include/linux/irq_sim.h
@@ -0,0 +1,41 @@
+#ifndef _LINUX_IRQ_SIM_H
+#define _LINUX_IRQ_SIM_H
+/*
+ * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/irq_work.h>
+
+/*
+ * Provides a framework for allocating simulated interrupts which can be
+ * requested like normal irqs and enqueued from process context.
+ */
+
+struct irq_sim_work_ctx {
+ struct irq_work work;
+ int irq;
+};
+
+struct irq_sim_irq_ctx {
+ int irqnum;
+ bool enabled;
+};
+
+struct irq_sim {
+ struct irq_sim_work_ctx work_ctx;
+ int irq_base;
+ unsigned int irq_count;
+ struct irq_sim_irq_ctx *irqs;
+};
+
+int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs);
+void irq_sim_fini(struct irq_sim *sim);
+void irq_sim_fire(struct irq_sim *sim, unsigned int offset);
+int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset);
+
+#endif /* _LINUX_IRQ_SIM_H */