2018-04-27 03:07:47 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2017-08-14 21:53:16 +07:00
|
|
|
/*
|
2018-04-27 03:07:47 +07:00
|
|
|
* Copyright (C) 2017-2018 Bartosz Golaszewski <brgl@bgdev.pl>
|
2017-08-14 21:53:16 +07:00
|
|
|
*/
|
|
|
|
|
2018-04-27 03:07:47 +07:00
|
|
|
#ifndef _LINUX_IRQ_SIM_H
|
|
|
|
#define _LINUX_IRQ_SIM_H
|
|
|
|
|
2017-08-14 21:53:16 +07:00
|
|
|
#include <linux/irq_work.h>
|
2017-08-14 21:53:17 +07:00
|
|
|
#include <linux/device.h>
|
2017-08-14 21:53:16 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
2018-11-10 00:21:32 +07:00
|
|
|
unsigned long *pending;
|
2017-08-14 21:53:16 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
2017-08-14 21:53:17 +07:00
|
|
|
int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
|
|
|
|
unsigned int num_irqs);
|
2017-08-14 21:53:16 +07:00
|
|
|
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 */
|