intc: gic: convert SYS_INIT to DEVICE_DT_INST_DEFINE

Convert SYS_INIT to DEVICE_DT_INST_DEFINE, this allows the build system
to track the device dependencies and ensure that the interrupt
controller is initialized before other devices using it.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri 2023-09-15 09:59:41 +00:00 committed by Carles Cufí
commit 17ae9a7680
2 changed files with 18 additions and 8 deletions

View file

@ -10,7 +10,7 @@
* NOTE: This driver implements the GICv1 and GICv2 interfaces. * NOTE: This driver implements the GICv1 and GICv2 interfaces.
*/ */
#include <zephyr/init.h> #include <zephyr/device.h>
#include <zephyr/arch/cpu.h> #include <zephyr/arch/cpu.h>
#include <zephyr/devicetree.h> #include <zephyr/devicetree.h>
#include <zephyr/sw_isr_table.h> #include <zephyr/sw_isr_table.h>
@ -18,6 +18,14 @@
#include <zephyr/drivers/interrupt_controller/gic.h> #include <zephyr/drivers/interrupt_controller/gic.h>
#include <zephyr/sys/barrier.h> #include <zephyr/sys/barrier.h>
#if defined(CONFIG_GIC_V1)
#define DT_DRV_COMPAT arm_gic_v1
#elif defined(CONFIG_GIC_V2)
#define DT_DRV_COMPAT arm_gic_v2
#else
#error "Unknown GIC controller compatible for this configuration"
#endif
static const uint64_t cpu_mpid_list[] = { static const uint64_t cpu_mpid_list[] = {
DT_FOREACH_CHILD_STATUS_OKAY_SEP(DT_PATH(cpus), DT_REG_ADDR, (,)) DT_FOREACH_CHILD_STATUS_OKAY_SEP(DT_PATH(cpus), DT_REG_ADDR, (,))
}; };
@ -253,9 +261,8 @@ static void gic_cpu_init(void)
/** /**
* @brief Initialize the GIC device driver * @brief Initialize the GIC device driver
*/ */
int arm_gic_init(void) int arm_gic_init(const struct device *dev)
{ {
/* Init of Distributor interface registers */ /* Init of Distributor interface registers */
gic_dist_init(); gic_dist_init();
@ -265,7 +272,8 @@ int arm_gic_init(void)
return 0; return 0;
} }
SYS_INIT(arm_gic_init, PRE_KERNEL_1, CONFIG_INTC_INIT_PRIORITY); DEVICE_DT_INST_DEFINE(0, arm_gic_init, NULL, NULL, NULL,
PRE_KERNEL_1, CONFIG_INTC_INIT_PRIORITY, NULL);
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
void arm_gic_secondary_init(void) void arm_gic_secondary_init(void)

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include <zephyr/init.h> #include <zephyr/device.h>
#include <zephyr/kernel.h> #include <zephyr/kernel.h>
#include <zephyr/arch/cpu.h> #include <zephyr/arch/cpu.h>
#include <zephyr/sys/__assert.h> #include <zephyr/sys/__assert.h>
@ -17,6 +17,8 @@
#include <string.h> #include <string.h>
#define DT_DRV_COMPAT arm_gic_v3
/* Redistributor base addresses for each core */ /* Redistributor base addresses for each core */
mem_addr_t gic_rdists[CONFIG_MP_MAX_NUM_CPUS]; mem_addr_t gic_rdists[CONFIG_MP_MAX_NUM_CPUS];
@ -596,16 +598,16 @@ static void __arm_gic_init(void)
gicv3_cpuif_init(); gicv3_cpuif_init();
} }
int arm_gic_init(void) int arm_gic_init(const struct device *dev)
{ {
gicv3_dist_init(); gicv3_dist_init();
__arm_gic_init(); __arm_gic_init();
return 0; return 0;
} }
SYS_INIT(arm_gic_init, PRE_KERNEL_1, CONFIG_INTC_INIT_PRIORITY); DEVICE_DT_INST_DEFINE(0, arm_gic_init, NULL, NULL, NULL,
PRE_KERNEL_1, CONFIG_INTC_INIT_PRIORITY, NULL);
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
void arm_gic_secondary_init(void) void arm_gic_secondary_init(void)