mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
hw/intc/loongarch_pch_pic: add irq number property
With loongarch 7A1000 manual, irq number supported can be set in PCH_PIC_INT_ID_HI register. This patch adds irq number property for loongarch_pch_pic, so that virt machine can set different irq number when pch_pic intc is added. Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn> Message-Id: <20230104020518.2564263-3-zhaotianrui@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>
This commit is contained in:
parent
6027d27405
commit
270950b49d
3 changed files with 37 additions and 10 deletions
|
@ -6,12 +6,15 @@
|
|||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/bitops.h"
|
||||
#include "hw/sysbus.h"
|
||||
#include "hw/loongarch/virt.h"
|
||||
#include "hw/irq.h"
|
||||
#include "hw/intc/loongarch_pch_pic.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "trace.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
static void pch_pic_update_irq(LoongArchPCHPIC *s, uint64_t mask, int level)
|
||||
{
|
||||
|
@ -40,7 +43,7 @@ static void pch_pic_irq_handler(void *opaque, int irq, int level)
|
|||
LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(opaque);
|
||||
uint64_t mask = 1ULL << irq;
|
||||
|
||||
assert(irq < PCH_PIC_IRQ_NUM);
|
||||
assert(irq < s->irq_num);
|
||||
trace_loongarch_pch_pic_irq_handler(irq, level);
|
||||
|
||||
if (s->intedge & mask) {
|
||||
|
@ -78,7 +81,12 @@ static uint64_t loongarch_pch_pic_low_readw(void *opaque, hwaddr addr,
|
|||
val = PCH_PIC_INT_ID_VAL;
|
||||
break;
|
||||
case PCH_PIC_INT_ID_HI:
|
||||
val = PCH_PIC_INT_ID_NUM;
|
||||
/*
|
||||
* With 7A1000 manual
|
||||
* bit 0-15 pch irqchip version
|
||||
* bit 16-31 irq number supported with pch irqchip
|
||||
*/
|
||||
val = deposit32(PCH_PIC_INT_ID_VER, 16, 16, s->irq_num - 1);
|
||||
break;
|
||||
case PCH_PIC_INT_MASK_LO:
|
||||
val = (uint32_t)s->int_mask;
|
||||
|
@ -365,6 +373,19 @@ static void loongarch_pch_pic_reset(DeviceState *d)
|
|||
s->int_polarity = 0x0;
|
||||
}
|
||||
|
||||
static void loongarch_pch_pic_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(dev);
|
||||
|
||||
if (!s->irq_num || s->irq_num > PCH_PIC_IRQ_NUM) {
|
||||
error_setg(errp, "Invalid 'pic_irq_num'");
|
||||
return;
|
||||
}
|
||||
|
||||
qdev_init_gpio_out(dev, s->parent_irq, s->irq_num);
|
||||
qdev_init_gpio_in(dev, pch_pic_irq_handler, s->irq_num);
|
||||
}
|
||||
|
||||
static void loongarch_pch_pic_init(Object *obj)
|
||||
{
|
||||
LoongArchPCHPIC *s = LOONGARCH_PCH_PIC(obj);
|
||||
|
@ -382,10 +403,13 @@ static void loongarch_pch_pic_init(Object *obj)
|
|||
sysbus_init_mmio(sbd, &s->iomem8);
|
||||
sysbus_init_mmio(sbd, &s->iomem32_high);
|
||||
|
||||
qdev_init_gpio_out(DEVICE(obj), s->parent_irq, PCH_PIC_IRQ_NUM);
|
||||
qdev_init_gpio_in(DEVICE(obj), pch_pic_irq_handler, PCH_PIC_IRQ_NUM);
|
||||
}
|
||||
|
||||
static Property loongarch_pch_pic_properties[] = {
|
||||
DEFINE_PROP_UINT32("pch_pic_irq_num", LoongArchPCHPIC, irq_num, 0),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static const VMStateDescription vmstate_loongarch_pch_pic = {
|
||||
.name = TYPE_LOONGARCH_PCH_PIC,
|
||||
.version_id = 1,
|
||||
|
@ -411,8 +435,10 @@ static void loongarch_pch_pic_class_init(ObjectClass *klass, void *data)
|
|||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
|
||||
dc->realize = loongarch_pch_pic_realize;
|
||||
dc->reset = loongarch_pch_pic_reset;
|
||||
dc->vmsd = &vmstate_loongarch_pch_pic;
|
||||
device_class_set_props(dc, loongarch_pch_pic_properties);
|
||||
}
|
||||
|
||||
static const TypeInfo loongarch_pch_pic_info = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue