forked from Mirrors/opensbi
lib: utils/irqchip: plic: Provide a hartindex to context map
This removes platform-specific arguments to plic_warm_irqchip_init(), which makes the driver independent from the platform after cold init, and allows for further refactoring. 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
c26e3fd2ed
commit
69448a0790
@@ -40,6 +40,9 @@ static struct plic_data plic = {
|
||||
.size = ARIANE_PLIC_SIZE,
|
||||
.num_src = ARIANE_PLIC_NUM_SOURCES,
|
||||
.flags = PLIC_FLAG_ARIANE_BUG,
|
||||
.context_map = {
|
||||
[0] = { 0, 1 },
|
||||
},
|
||||
};
|
||||
|
||||
static struct aclint_mswi_data mswi = {
|
||||
@@ -99,7 +102,6 @@ static int ariane_final_init(bool cold_boot)
|
||||
*/
|
||||
static int ariane_irqchip_init(bool cold_boot)
|
||||
{
|
||||
u32 hartid = current_hartid();
|
||||
int ret;
|
||||
|
||||
if (cold_boot) {
|
||||
@@ -108,7 +110,7 @@ static int ariane_irqchip_init(bool cold_boot)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return plic_warm_irqchip_init(&plic, 2 * hartid, 2 * hartid + 1);
|
||||
return plic_warm_irqchip_init(&plic);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -44,6 +44,11 @@ static struct plic_data plic = {
|
||||
.size = OPENPITON_DEFAULT_PLIC_SIZE,
|
||||
.num_src = OPENPITON_DEFAULT_PLIC_NUM_SOURCES,
|
||||
.flags = PLIC_FLAG_ARIANE_BUG,
|
||||
.context_map = {
|
||||
[0] = { 0, 1 },
|
||||
[1] = { 2, 3 },
|
||||
[2] = { 4, 5 },
|
||||
},
|
||||
};
|
||||
|
||||
static struct aclint_mswi_data mswi = {
|
||||
@@ -130,7 +135,6 @@ static int openpiton_final_init(bool cold_boot)
|
||||
*/
|
||||
static int openpiton_irqchip_init(bool cold_boot)
|
||||
{
|
||||
u32 hartid = current_hartid();
|
||||
int ret;
|
||||
|
||||
if (cold_boot) {
|
||||
@@ -139,7 +143,7 @@ static int openpiton_irqchip_init(bool cold_boot)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return plic_warm_irqchip_init(&plic, 2 * hartid, 2 * hartid + 1);
|
||||
return plic_warm_irqchip_init(&plic);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -33,6 +33,10 @@ static struct plic_data plic = {
|
||||
.addr = K210_PLIC_BASE_ADDR,
|
||||
.size = K210_PLIC_BASE_SIZE,
|
||||
.num_src = K210_PLIC_NUM_SOURCES,
|
||||
.context_map = {
|
||||
[0] = { 0, 1 },
|
||||
[1] = { 2, 3 },
|
||||
},
|
||||
};
|
||||
|
||||
static struct aclint_mswi_data mswi = {
|
||||
@@ -135,7 +139,6 @@ static int k210_final_init(bool cold_boot)
|
||||
static int k210_irqchip_init(bool cold_boot)
|
||||
{
|
||||
int rc;
|
||||
u32 hartid = current_hartid();
|
||||
|
||||
if (cold_boot) {
|
||||
rc = plic_cold_irqchip_init(&plic);
|
||||
@@ -143,7 +146,7 @@ static int k210_irqchip_init(bool cold_boot)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return plic_warm_irqchip_init(&plic, hartid * 2, hartid * 2 + 1);
|
||||
return plic_warm_irqchip_init(&plic);
|
||||
}
|
||||
|
||||
static int k210_ipi_init(void)
|
||||
|
@@ -66,6 +66,9 @@ static struct plic_data plic = {
|
||||
.addr = UX600_PLIC_ADDR,
|
||||
.size = UX600_PLIC_SIZE,
|
||||
.num_src = UX600_PLIC_NUM_SOURCES,
|
||||
.context_map = {
|
||||
[0] = { 0, -1 },
|
||||
},
|
||||
};
|
||||
|
||||
static struct aclint_mswi_data mswi = {
|
||||
@@ -190,7 +193,6 @@ static int ux600_final_init(bool cold_boot)
|
||||
static int ux600_irqchip_init(bool cold_boot)
|
||||
{
|
||||
int rc;
|
||||
u32 hartid = current_hartid();
|
||||
|
||||
if (cold_boot) {
|
||||
rc = plic_cold_irqchip_init(&plic);
|
||||
@@ -198,8 +200,7 @@ static int ux600_irqchip_init(bool cold_boot)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return plic_warm_irqchip_init(&plic, (hartid) ? (2 * hartid - 1) : 0,
|
||||
(hartid) ? (2 * hartid) : -1);
|
||||
return plic_warm_irqchip_init(&plic);
|
||||
}
|
||||
|
||||
static int ux600_ipi_init(void)
|
||||
|
@@ -37,6 +37,12 @@ static struct plic_data plic = {
|
||||
.addr = PLATFORM_PLIC_ADDR,
|
||||
.size = PLATFORM_PLIC_SIZE,
|
||||
.num_src = PLATFORM_PLIC_NUM_SOURCES,
|
||||
.context_map = {
|
||||
[0] = { 0, 1 },
|
||||
[1] = { 2, 3 },
|
||||
[2] = { 4, 5 },
|
||||
[3] = { 6, 7 },
|
||||
},
|
||||
};
|
||||
|
||||
static struct aclint_mswi_data mswi = {
|
||||
@@ -85,7 +91,6 @@ static int platform_final_init(bool cold_boot)
|
||||
*/
|
||||
static int platform_irqchip_init(bool cold_boot)
|
||||
{
|
||||
u32 hartid = current_hartid();
|
||||
int ret;
|
||||
|
||||
/* Example if the generic PLIC driver is used */
|
||||
@@ -95,7 +100,7 @@ static int platform_irqchip_init(bool cold_boot)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return plic_warm_irqchip_init(&plic, 2 * hartid, 2 * hartid + 1);
|
||||
return plic_warm_irqchip_init(&plic);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user