lx_emul: support IRQCHIP_DECLARE initcalls

Similar to CLK_OF_DECLARE, this patch extends lx_emul with ability to
extend the __irqchip_of_table with secondary interrupt controllers.

Issue #4253
This commit is contained in:
Norman Feske 2021-08-20 16:44:17 +02:00 committed by Christian Helmuth
parent c95af254f4
commit 2cb4157211
3 changed files with 35 additions and 9 deletions

View File

@ -30,6 +30,8 @@ extern void * lx_emul_init_task_struct;
void lx_emul_register_of_clk_initcall(char const *compat, void *fn);
void lx_emul_register_of_irqchip_initcall(char const *compat, void *fn);
#ifdef __cplusplus
}
#endif

View File

@ -18,10 +18,18 @@
#include <lx_emul/init.h>
#undef OF_DECLARE_1
#undef OF_DECLARE_2
/* used to populate __clk_of_table */
#define OF_DECLARE_1(table, name, compat, fn) \
static void __of_declare_initcall_##fn##name(void)__attribute__((constructor)); \
static void __of_declare_initcall_##fn##name() { \
lx_emul_register_of_##table##_initcall(compat, fn); };
/* used to populate __irqchip_of_table */
#define OF_DECLARE_2(table, name, compat, fn) \
static void __of_declare_initcall_##fn##name(void)__attribute__((constructor)); \
static void __of_declare_initcall_##fn##name() { \
lx_emul_register_of_##table##_initcall(compat, fn); };
#endif /* _LX_EMUL__SHADOW__LINUX__OF_H_ */

View File

@ -134,16 +134,32 @@ static int __init dde_irqchip_init(struct device_node *node,
}
struct of_device_id __irqchip_of_table[] = {
{
.compatible = "arm,gic-v3",
.data = dde_irqchip_init
},
{
.compatible = "arm,gic-400",
.data = dde_irqchip_init
enum { LX_EMUL_MAX_OF_IRQ_CHIPS = 16 };
struct of_device_id __irqchip_of_table[LX_EMUL_MAX_OF_IRQ_CHIPS] = { };
void lx_emul_register_of_irqchip_initcall(char const *compat, void *fn)
{
static unsigned count;
if (count == LX_EMUL_MAX_OF_IRQ_CHIPS) {
printk("lx_emul_register_of_irqchip_initcall: __irqchip_of_table exhausted\n");
return;
}
};
strncpy(__irqchip_of_table[count].compatible, compat,
sizeof(__irqchip_of_table[count].compatible));
__irqchip_of_table[count].data = fn;
count++;
}
IRQCHIP_DECLARE(dde_gic_v3, "arm,gic-v3", dde_irqchip_init);
IRQCHIP_DECLARE(dde_gic_400, "arm,gic-400", dde_irqchip_init);
int lx_emul_irq_task_function(void * data)