xref: /linux/drivers/irqchip/irq-riscv-aplic-main.h (revision 3ff78451b8e446e9a548b98a0d4dd8d24dc5780b)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2021 Western Digital Corporation or its affiliates.
4  * Copyright (C) 2022 Ventana Micro Systems Inc.
5  */
6 
7 #ifndef _IRQ_RISCV_APLIC_MAIN_H
8 #define _IRQ_RISCV_APLIC_MAIN_H
9 
10 #include <linux/device.h>
11 #include <linux/io.h>
12 #include <linux/irq.h>
13 #include <linux/irqdomain.h>
14 #include <linux/fwnode.h>
15 
16 #define APLIC_DEFAULT_PRIORITY		1
17 
18 struct aplic_msicfg {
19 	phys_addr_t		base_ppn;
20 	u32			hhxs;
21 	u32			hhxw;
22 	u32			lhxs;
23 	u32			lhxw;
24 };
25 
26 struct aplic_priv {
27 	struct device		*dev;
28 	u32			gsi_base;
29 	u32			nr_irqs;
30 	u32			nr_idcs;
31 	void __iomem		*regs;
32 	struct aplic_msicfg	msicfg;
33 };
34 
35 void aplic_irq_unmask(struct irq_data *d);
36 void aplic_irq_mask(struct irq_data *d);
37 int aplic_irq_set_type(struct irq_data *d, unsigned int type);
38 int aplic_irqdomain_translate(struct irq_fwspec *fwspec, u32 gsi_base,
39 			      unsigned long *hwirq, unsigned int *type);
40 void aplic_init_hw_global(struct aplic_priv *priv, bool msi_mode);
41 int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *regs);
42 int aplic_direct_setup(struct device *dev, void __iomem *regs);
43 #ifdef CONFIG_RISCV_APLIC_MSI
44 int aplic_msi_setup(struct device *dev, void __iomem *regs);
45 #else
46 static inline int aplic_msi_setup(struct device *dev, void __iomem *regs)
47 {
48 	return -ENODEV;
49 }
50 #endif
51 
52 #endif
53