mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
platform: Drop irqchip warm init and exit hooks
Now that driver lifecycle is managed from within the SBI irqchip core, platforms need only to initialize the driver once during cold init. Remove the remaining platform hooks that are no longer used. 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
2dd6eaf680
commit
678f5909a3
@@ -111,10 +111,8 @@ struct sbi_platform_operations {
|
|||||||
/** Get platform specific mhpmevent value */
|
/** Get platform specific mhpmevent value */
|
||||||
uint64_t (*pmu_xlate_to_mhpmevent)(uint32_t event_idx, uint64_t data);
|
uint64_t (*pmu_xlate_to_mhpmevent)(uint32_t event_idx, uint64_t data);
|
||||||
|
|
||||||
/** Initialize the platform interrupt controller for current HART */
|
/** Initialize the platform interrupt controller during cold boot */
|
||||||
int (*irqchip_init)(bool cold_boot);
|
int (*irqchip_init)(void);
|
||||||
/** Exit the platform interrupt controller for current HART */
|
|
||||||
void (*irqchip_exit)(void);
|
|
||||||
|
|
||||||
/** Initialize IPI during cold boot */
|
/** Initialize IPI during cold boot */
|
||||||
int (*ipi_init)(void);
|
int (*ipi_init)(void);
|
||||||
@@ -543,32 +541,19 @@ static inline uint64_t sbi_platform_pmu_xlate_to_mhpmevent(const struct sbi_plat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the platform interrupt controller for current HART
|
* Initialize the platform interrupt controller during cold boot
|
||||||
*
|
*
|
||||||
* @param plat pointer to struct sbi_platform
|
* @param plat pointer to struct sbi_platform
|
||||||
* @param cold_boot whether cold boot (true) or warm_boot (false)
|
|
||||||
*
|
*
|
||||||
* @return 0 on success and negative error code on failure
|
* @return 0 on success and negative error code on failure
|
||||||
*/
|
*/
|
||||||
static inline int sbi_platform_irqchip_init(const struct sbi_platform *plat,
|
static inline int sbi_platform_irqchip_init(const struct sbi_platform *plat)
|
||||||
bool cold_boot)
|
|
||||||
{
|
{
|
||||||
if (plat && sbi_platform_ops(plat)->irqchip_init)
|
if (plat && sbi_platform_ops(plat)->irqchip_init)
|
||||||
return sbi_platform_ops(plat)->irqchip_init(cold_boot);
|
return sbi_platform_ops(plat)->irqchip_init();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Exit the platform interrupt controller for current HART
|
|
||||||
*
|
|
||||||
* @param plat pointer to struct sbi_platform
|
|
||||||
*/
|
|
||||||
static inline void sbi_platform_irqchip_exit(const struct sbi_platform *plat)
|
|
||||||
{
|
|
||||||
if (plat && sbi_platform_ops(plat)->irqchip_exit)
|
|
||||||
sbi_platform_ops(plat)->irqchip_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the platform IPI support during cold boot
|
* Initialize the platform IPI support during cold boot
|
||||||
*
|
*
|
||||||
|
@@ -17,19 +17,13 @@
|
|||||||
struct fdt_irqchip {
|
struct fdt_irqchip {
|
||||||
const struct fdt_match *match_table;
|
const struct fdt_match *match_table;
|
||||||
int (*cold_init)(const void *fdt, int nodeoff, const struct fdt_match *match);
|
int (*cold_init)(const void *fdt, int nodeoff, const struct fdt_match *match);
|
||||||
int (*warm_init)(void);
|
|
||||||
void (*exit)(void);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void fdt_irqchip_exit(void);
|
int fdt_irqchip_init(void);
|
||||||
|
|
||||||
int fdt_irqchip_init(bool cold_boot);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static inline void fdt_irqchip_exit(void) { }
|
static inline int fdt_irqchip_init(void) { return 0; }
|
||||||
|
|
||||||
static inline int fdt_irqchip_init(bool cold_boot) { return 0; }
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -42,9 +42,11 @@ int sbi_irqchip_init(struct sbi_scratch *scratch, bool cold_boot)
|
|||||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
||||||
struct sbi_irqchip_device *dev;
|
struct sbi_irqchip_device *dev;
|
||||||
|
|
||||||
rc = sbi_platform_irqchip_init(plat, cold_boot);
|
if (cold_boot) {
|
||||||
|
rc = sbi_platform_irqchip_init(plat);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
sbi_list_for_each_entry(dev, &irqchip_list, node) {
|
sbi_list_for_each_entry(dev, &irqchip_list, node) {
|
||||||
if (!dev->warm_init)
|
if (!dev->warm_init)
|
||||||
@@ -62,10 +64,6 @@ int sbi_irqchip_init(struct sbi_scratch *scratch, bool cold_boot)
|
|||||||
|
|
||||||
void sbi_irqchip_exit(struct sbi_scratch *scratch)
|
void sbi_irqchip_exit(struct sbi_scratch *scratch)
|
||||||
{
|
{
|
||||||
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
|
|
||||||
|
|
||||||
if (ext_irqfn != default_irqfn)
|
if (ext_irqfn != default_irqfn)
|
||||||
csr_clear(CSR_MIE, MIP_MEIP);
|
csr_clear(CSR_MIE, MIP_MEIP);
|
||||||
|
|
||||||
sbi_platform_irqchip_exit(plat);
|
|
||||||
}
|
}
|
||||||
|
@@ -16,40 +16,8 @@
|
|||||||
extern struct fdt_irqchip *fdt_irqchip_drivers[];
|
extern struct fdt_irqchip *fdt_irqchip_drivers[];
|
||||||
extern unsigned long fdt_irqchip_drivers_size;
|
extern unsigned long fdt_irqchip_drivers_size;
|
||||||
|
|
||||||
#define FDT_IRQCHIP_MAX_DRIVERS 8
|
int fdt_irqchip_init(void)
|
||||||
|
|
||||||
static struct fdt_irqchip *current_drivers[FDT_IRQCHIP_MAX_DRIVERS] = {0};
|
|
||||||
static int current_drivers_count;
|
|
||||||
|
|
||||||
void fdt_irqchip_exit(void)
|
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < current_drivers_count; i++) {
|
|
||||||
if (!current_drivers[i] || !current_drivers[i]->exit)
|
|
||||||
continue;
|
|
||||||
current_drivers[i]->exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int fdt_irqchip_warm_init(void)
|
|
||||||
{
|
|
||||||
int i, rc;
|
|
||||||
|
|
||||||
for (i = 0; i < current_drivers_count; i++) {
|
|
||||||
if (!current_drivers[i] || !current_drivers[i]->warm_init)
|
|
||||||
continue;
|
|
||||||
rc = current_drivers[i]->warm_init();
|
|
||||||
if (rc)
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int fdt_irqchip_cold_init(void)
|
|
||||||
{
|
|
||||||
bool drv_added;
|
|
||||||
int pos, noff, rc;
|
int pos, noff, rc;
|
||||||
struct fdt_irqchip *drv;
|
struct fdt_irqchip *drv;
|
||||||
const struct fdt_match *match;
|
const struct fdt_match *match;
|
||||||
@@ -59,7 +27,6 @@ static int fdt_irqchip_cold_init(void)
|
|||||||
drv = fdt_irqchip_drivers[pos];
|
drv = fdt_irqchip_drivers[pos];
|
||||||
|
|
||||||
noff = -1;
|
noff = -1;
|
||||||
drv_added = false;
|
|
||||||
while ((noff = fdt_find_match(fdt, noff,
|
while ((noff = fdt_find_match(fdt, noff,
|
||||||
drv->match_table, &match)) >= 0) {
|
drv->match_table, &match)) >= 0) {
|
||||||
if (!fdt_node_is_enabled(fdt,noff))
|
if (!fdt_node_is_enabled(fdt,noff))
|
||||||
@@ -72,30 +39,8 @@ static int fdt_irqchip_cold_init(void)
|
|||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drv_added)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
current_drivers[current_drivers_count++] = drv;
|
|
||||||
drv_added = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FDT_IRQCHIP_MAX_DRIVERS <= current_drivers_count)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fdt_irqchip_init(bool cold_boot)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
if (cold_boot) {
|
|
||||||
rc = fdt_irqchip_cold_init();
|
|
||||||
if (rc)
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fdt_irqchip_warm_init();
|
|
||||||
}
|
|
||||||
|
@@ -49,6 +49,4 @@ static const struct fdt_match irqchip_aplic_match[] = {
|
|||||||
struct fdt_irqchip fdt_irqchip_aplic = {
|
struct fdt_irqchip fdt_irqchip_aplic = {
|
||||||
.match_table = irqchip_aplic_match,
|
.match_table = irqchip_aplic_match,
|
||||||
.cold_init = irqchip_aplic_cold_init,
|
.cold_init = irqchip_aplic_cold_init,
|
||||||
.warm_init = NULL,
|
|
||||||
.exit = NULL,
|
|
||||||
};
|
};
|
||||||
|
@@ -95,5 +95,4 @@ static const struct fdt_match irqchip_imsic_match[] = {
|
|||||||
struct fdt_irqchip fdt_irqchip_imsic = {
|
struct fdt_irqchip fdt_irqchip_imsic = {
|
||||||
.match_table = irqchip_imsic_match,
|
.match_table = irqchip_imsic_match,
|
||||||
.cold_init = irqchip_imsic_cold_init,
|
.cold_init = irqchip_imsic_cold_init,
|
||||||
.warm_init = NULL,
|
|
||||||
};
|
};
|
||||||
|
@@ -108,6 +108,4 @@ static const struct fdt_match irqchip_plic_match[] = {
|
|||||||
struct fdt_irqchip fdt_irqchip_plic = {
|
struct fdt_irqchip fdt_irqchip_plic = {
|
||||||
.match_table = irqchip_plic_match,
|
.match_table = irqchip_plic_match,
|
||||||
.cold_init = irqchip_plic_cold_init,
|
.cold_init = irqchip_plic_cold_init,
|
||||||
.warm_init = NULL,
|
|
||||||
.exit = NULL,
|
|
||||||
};
|
};
|
||||||
|
@@ -98,19 +98,11 @@ static int ariane_final_init(bool cold_boot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the ariane interrupt controller for current HART.
|
* Initialize the ariane interrupt controller during cold boot.
|
||||||
*/
|
*/
|
||||||
static int ariane_irqchip_init(bool cold_boot)
|
static int ariane_irqchip_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
return plic_cold_irqchip_init(&plic);
|
||||||
|
|
||||||
if (cold_boot) {
|
|
||||||
ret = plic_cold_irqchip_init(&plic);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -131,19 +131,11 @@ static int openpiton_final_init(bool cold_boot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the openpiton interrupt controller for current HART.
|
* Initialize the openpiton interrupt controller during cold boot.
|
||||||
*/
|
*/
|
||||||
static int openpiton_irqchip_init(bool cold_boot)
|
static int openpiton_irqchip_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
return plic_cold_irqchip_init(&plic);
|
||||||
|
|
||||||
if (cold_boot) {
|
|
||||||
ret = plic_cold_irqchip_init(&plic);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -419,7 +419,6 @@ const struct sbi_platform_operations platform_ops = {
|
|||||||
.extensions_init = generic_extensions_init,
|
.extensions_init = generic_extensions_init,
|
||||||
.domains_init = generic_domains_init,
|
.domains_init = generic_domains_init,
|
||||||
.irqchip_init = fdt_irqchip_init,
|
.irqchip_init = fdt_irqchip_init,
|
||||||
.irqchip_exit = fdt_irqchip_exit,
|
|
||||||
.ipi_init = fdt_ipi_init,
|
.ipi_init = fdt_ipi_init,
|
||||||
.pmu_init = generic_pmu_init,
|
.pmu_init = generic_pmu_init,
|
||||||
.pmu_xlate_to_mhpmevent = generic_pmu_xlate_to_mhpmevent,
|
.pmu_xlate_to_mhpmevent = generic_pmu_xlate_to_mhpmevent,
|
||||||
|
@@ -136,17 +136,9 @@ static int k210_final_init(bool cold_boot)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int k210_irqchip_init(bool cold_boot)
|
static int k210_irqchip_init(void)
|
||||||
{
|
{
|
||||||
int rc;
|
return plic_cold_irqchip_init(&plic);
|
||||||
|
|
||||||
if (cold_boot) {
|
|
||||||
rc = plic_cold_irqchip_init(&plic);
|
|
||||||
if (rc)
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int k210_ipi_init(void)
|
static int k210_ipi_init(void)
|
||||||
|
@@ -190,17 +190,9 @@ static int ux600_final_init(bool cold_boot)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ux600_irqchip_init(bool cold_boot)
|
static int ux600_irqchip_init(void)
|
||||||
{
|
{
|
||||||
int rc;
|
return plic_cold_irqchip_init(&plic);
|
||||||
|
|
||||||
if (cold_boot) {
|
|
||||||
rc = plic_cold_irqchip_init(&plic);
|
|
||||||
if (rc)
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ux600_ipi_init(void)
|
static int ux600_ipi_init(void)
|
||||||
|
@@ -87,20 +87,12 @@ static int platform_final_init(bool cold_boot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the platform interrupt controller for current HART.
|
* Initialize the platform interrupt controller during cold boot.
|
||||||
*/
|
*/
|
||||||
static int platform_irqchip_init(bool cold_boot)
|
static int platform_irqchip_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Example if the generic PLIC driver is used */
|
/* Example if the generic PLIC driver is used */
|
||||||
if (cold_boot) {
|
return plic_cold_irqchip_init(&plic);
|
||||||
ret = plic_cold_irqchip_init(&plic);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user