mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: sbi_irqchip: Call driver warm_init from SBI core
Currently, each platform keeps track of which irqchip driver is in use and calls its warm init function. Since the generic platform may use multiple irqchip drivers, it has logic to track an array of drivers. The code is simplified and made common across platforms by treating warm init and exit as properties of the driver, not the platform. Then the platform's only role is to select and prepare a driver during cold boot. For now, only add a .warm_init hook, since none of the existing drivers need an .exit hook. It could be added in the future if needed. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
e3e5686ef9
commit
2dd6eaf680
@@ -19,6 +19,9 @@ struct sbi_scratch;
|
||||
struct sbi_irqchip_device {
|
||||
/** Node in the list of irqchip devices */
|
||||
struct sbi_dlist node;
|
||||
|
||||
/** Initialize per-hart state for the current hart */
|
||||
int (*warm_init)(struct sbi_irqchip_device *dev);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -43,8 +43,6 @@ int imsic_get_target_file(u32 hartindex);
|
||||
|
||||
void imsic_local_irqchip_init(void);
|
||||
|
||||
int imsic_warm_irqchip_init(void);
|
||||
|
||||
int imsic_data_check(struct imsic_data *imsic);
|
||||
|
||||
int imsic_cold_irqchip_init(struct imsic_data *imsic);
|
||||
|
@@ -42,8 +42,6 @@ void plic_suspend(void);
|
||||
|
||||
void plic_resume(void);
|
||||
|
||||
int plic_warm_irqchip_init(void);
|
||||
|
||||
int plic_cold_irqchip_init(struct plic_data *plic);
|
||||
|
||||
#endif
|
||||
|
@@ -40,11 +40,20 @@ int sbi_irqchip_init(struct sbi_scratch *scratch, bool cold_boot)
|
||||
{
|
||||
int rc;
|
||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||
struct sbi_irqchip_device *dev;
|
||||
|
||||
rc = sbi_platform_irqchip_init(plat, cold_boot);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
sbi_list_for_each_entry(dev, &irqchip_list, node) {
|
||||
if (!dev->warm_init)
|
||||
continue;
|
||||
rc = dev->warm_init(dev);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (ext_irqfn != default_irqfn)
|
||||
csr_set(CSR_MIE, MIP_MEIP);
|
||||
|
||||
|
@@ -16,12 +16,6 @@
|
||||
#include <sbi_utils/irqchip/fdt_irqchip.h>
|
||||
#include <sbi_utils/irqchip/aplic.h>
|
||||
|
||||
static int irqchip_aplic_warm_init(void)
|
||||
{
|
||||
/* Nothing to do here. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int irqchip_aplic_cold_init(const void *fdt, int nodeoff,
|
||||
const struct fdt_match *match)
|
||||
{
|
||||
@@ -55,6 +49,6 @@ static const struct fdt_match irqchip_aplic_match[] = {
|
||||
struct fdt_irqchip fdt_irqchip_aplic = {
|
||||
.match_table = irqchip_aplic_match,
|
||||
.cold_init = irqchip_aplic_cold_init,
|
||||
.warm_init = irqchip_aplic_warm_init,
|
||||
.warm_init = NULL,
|
||||
.exit = NULL,
|
||||
};
|
||||
|
@@ -95,5 +95,5 @@ static const struct fdt_match irqchip_imsic_match[] = {
|
||||
struct fdt_irqchip fdt_irqchip_imsic = {
|
||||
.match_table = irqchip_imsic_match,
|
||||
.cold_init = irqchip_imsic_cold_init,
|
||||
.warm_init = imsic_warm_irqchip_init,
|
||||
.warm_init = NULL,
|
||||
};
|
||||
|
@@ -108,6 +108,6 @@ static const struct fdt_match irqchip_plic_match[] = {
|
||||
struct fdt_irqchip fdt_irqchip_plic = {
|
||||
.match_table = irqchip_plic_match,
|
||||
.cold_init = irqchip_plic_cold_init,
|
||||
.warm_init = plic_warm_irqchip_init,
|
||||
.warm_init = NULL,
|
||||
.exit = NULL,
|
||||
};
|
||||
|
@@ -255,7 +255,7 @@ void imsic_local_irqchip_init(void)
|
||||
imsic_local_eix_update(IMSIC_IPI_ID, 1, false, true);
|
||||
}
|
||||
|
||||
int imsic_warm_irqchip_init(void)
|
||||
static int imsic_warm_irqchip_init(struct sbi_irqchip_device *dev)
|
||||
{
|
||||
struct imsic_data *imsic = imsic_get_data(current_hartindex());
|
||||
|
||||
@@ -346,6 +346,7 @@ int imsic_data_check(struct imsic_data *imsic)
|
||||
}
|
||||
|
||||
static struct sbi_irqchip_device imsic_device = {
|
||||
.warm_init = imsic_warm_irqchip_init,
|
||||
};
|
||||
|
||||
int imsic_cold_irqchip_init(struct imsic_data *imsic)
|
||||
|
@@ -190,7 +190,7 @@ void plic_resume(void)
|
||||
plic_delegate(plic);
|
||||
}
|
||||
|
||||
int plic_warm_irqchip_init(void)
|
||||
static int plic_warm_irqchip_init(struct sbi_irqchip_device *dev)
|
||||
{
|
||||
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
|
||||
const struct plic_data *plic = plic_get_hart_data_ptr(scratch);
|
||||
@@ -222,6 +222,7 @@ int plic_warm_irqchip_init(void)
|
||||
}
|
||||
|
||||
static struct sbi_irqchip_device plic_device = {
|
||||
.warm_init = plic_warm_irqchip_init,
|
||||
};
|
||||
|
||||
int plic_cold_irqchip_init(struct plic_data *plic)
|
||||
|
@@ -110,7 +110,7 @@ static int ariane_irqchip_init(bool cold_boot)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return plic_warm_irqchip_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -143,7 +143,7 @@ static int openpiton_irqchip_init(bool cold_boot)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return plic_warm_irqchip_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -146,7 +146,7 @@ static int k210_irqchip_init(bool cold_boot)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return plic_warm_irqchip_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int k210_ipi_init(void)
|
||||
|
@@ -200,7 +200,7 @@ static int ux600_irqchip_init(bool cold_boot)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return plic_warm_irqchip_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ux600_ipi_init(void)
|
||||
|
@@ -100,7 +100,7 @@ static int platform_irqchip_init(bool cold_boot)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return plic_warm_irqchip_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user