mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-04-13 06:11:37 +01:00
lib: sbi_irqchip: Associate 32-bit unique ID for each irqchip device
Allow locating irqchip device instance using a unique 32-bit ID. This 32-bit unique ID can be set by the irqchip driver at the time of adding irqchip device. Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260213055342.3124872-8-anup.patel@oss.qualcomm.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -21,6 +21,9 @@ struct sbi_irqchip_device {
|
|||||||
/** Node in the list of irqchip devices */
|
/** Node in the list of irqchip devices */
|
||||||
struct sbi_dlist node;
|
struct sbi_dlist node;
|
||||||
|
|
||||||
|
/** Unique ID of this irqchip */
|
||||||
|
u32 id;
|
||||||
|
|
||||||
/** Set of harts targetted by this irqchip */
|
/** Set of harts targetted by this irqchip */
|
||||||
struct sbi_hartmask target_harts;
|
struct sbi_hartmask target_harts;
|
||||||
|
|
||||||
@@ -41,6 +44,9 @@ struct sbi_irqchip_device {
|
|||||||
*/
|
*/
|
||||||
int sbi_irqchip_process(void);
|
int sbi_irqchip_process(void);
|
||||||
|
|
||||||
|
/** Find an irqchip device based on unique ID */
|
||||||
|
struct sbi_irqchip_device *sbi_irqchip_find_device(u32 id);
|
||||||
|
|
||||||
/** Register an irqchip device to receive callbacks */
|
/** Register an irqchip device to receive callbacks */
|
||||||
int sbi_irqchip_add_device(struct sbi_irqchip_device *chip);
|
int sbi_irqchip_add_device(struct sbi_irqchip_device *chip);
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ int sbi_irqchip_process(void)
|
|||||||
return hd->chip->process_hwirqs(hd->chip);
|
return hd->chip->process_hwirqs(hd->chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct sbi_irqchip_device *sbi_irqchip_find_device(u32 id)
|
||||||
|
{
|
||||||
|
struct sbi_irqchip_device *chip;
|
||||||
|
|
||||||
|
sbi_list_for_each_entry(chip, &irqchip_list, node) {
|
||||||
|
if (chip->id == id)
|
||||||
|
return chip;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int sbi_irqchip_add_device(struct sbi_irqchip_device *chip)
|
int sbi_irqchip_add_device(struct sbi_irqchip_device *chip)
|
||||||
{
|
{
|
||||||
struct sbi_irqchip_hart_data *hd;
|
struct sbi_irqchip_hart_data *hd;
|
||||||
@@ -39,6 +51,9 @@ int sbi_irqchip_add_device(struct sbi_irqchip_device *chip)
|
|||||||
if (!chip || !sbi_hartmask_weight(&chip->target_harts))
|
if (!chip || !sbi_hartmask_weight(&chip->target_harts))
|
||||||
return SBI_EINVAL;
|
return SBI_EINVAL;
|
||||||
|
|
||||||
|
if (sbi_irqchip_find_device(chip->id))
|
||||||
|
return SBI_EALREADY;
|
||||||
|
|
||||||
if (chip->process_hwirqs) {
|
if (chip->process_hwirqs) {
|
||||||
sbi_hartmask_for_each_hartindex(h, &chip->target_harts) {
|
sbi_hartmask_for_each_hartindex(h, &chip->target_harts) {
|
||||||
scratch = sbi_hartindex_to_scratch(h);
|
scratch = sbi_hartindex_to_scratch(h);
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ int aplic_cold_irqchip_init(struct aplic_data *aplic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Register irqchip device */
|
/* Register irqchip device */
|
||||||
|
aplic->irqchip.id = aplic->unique_id;
|
||||||
rc = sbi_irqchip_add_device(&aplic->irqchip);
|
rc = sbi_irqchip_add_device(&aplic->irqchip);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@@ -391,6 +391,7 @@ int imsic_cold_irqchip_init(struct imsic_data *imsic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Register irqchip device */
|
/* Register irqchip device */
|
||||||
|
imsic_device.id = imsic->unique_id;
|
||||||
sbi_hartmask_set_all(&imsic_device.target_harts);
|
sbi_hartmask_set_all(&imsic_device.target_harts);
|
||||||
rc = sbi_irqchip_add_device(&imsic_device);
|
rc = sbi_irqchip_add_device(&imsic_device);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
|||||||
@@ -280,6 +280,7 @@ int plic_cold_irqchip_init(struct plic_data *plic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Register irqchip device */
|
/* Register irqchip device */
|
||||||
|
plic->irqchip.id = plic->unique_id;
|
||||||
plic->irqchip.warm_init = plic_warm_irqchip_init;
|
plic->irqchip.warm_init = plic_warm_irqchip_init;
|
||||||
return sbi_irqchip_add_device(&plic->irqchip);
|
return sbi_irqchip_add_device(&plic->irqchip);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user