mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
hw/arm/iotkit: Wire up MPC interrupt lines
The interrupt outputs from the MPC in the IoTKit and the expansion MPCs in the board must be wired up to the security controller, and also all ORed together to produce a single line to the NVIC. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20180620132032.28865-8-peter.maydell@linaro.org
This commit is contained in:
parent
af60b29183
commit
bb75e16d5e
2 changed files with 80 additions and 0 deletions
|
@ -131,6 +131,18 @@ static void iotkit_init(Object *obj)
|
|||
init_sysbus_child(obj, "apb-ppc1", &s->apb_ppc1, sizeof(s->apb_ppc1),
|
||||
TYPE_TZ_PPC);
|
||||
init_sysbus_child(obj, "mpc", &s->mpc, sizeof(s->mpc), TYPE_TZ_MPC);
|
||||
object_initialize(&s->mpc_irq_orgate, sizeof(s->mpc_irq_orgate),
|
||||
TYPE_OR_IRQ);
|
||||
object_property_add_child(obj, "mpc-irq-orgate",
|
||||
OBJECT(&s->mpc_irq_orgate), &error_abort);
|
||||
for (i = 0; i < ARRAY_SIZE(s->mpc_irq_splitter); i++) {
|
||||
char *name = g_strdup_printf("mpc-irq-splitter-%d", i);
|
||||
SplitIRQ *splitter = &s->mpc_irq_splitter[i];
|
||||
|
||||
object_initialize(splitter, sizeof(*splitter), TYPE_SPLIT_IRQ);
|
||||
object_property_add_child(obj, name, OBJECT(splitter), &error_abort);
|
||||
g_free(name);
|
||||
}
|
||||
init_sysbus_child(obj, "timer0", &s->timer0, sizeof(s->timer0),
|
||||
TYPE_CMSDK_APB_TIMER);
|
||||
init_sysbus_child(obj, "timer1", &s->timer1, sizeof(s->timer1),
|
||||
|
@ -163,6 +175,12 @@ static void iotkit_exp_irq(void *opaque, int n, int level)
|
|||
qemu_set_irq(s->exp_irqs[n], level);
|
||||
}
|
||||
|
||||
static void iotkit_mpcexp_status(void *opaque, int n, int level)
|
||||
{
|
||||
IoTKit *s = IOTKIT(opaque);
|
||||
qemu_set_irq(s->mpcexp_status_in[n], level);
|
||||
}
|
||||
|
||||
static void iotkit_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
IoTKit *s = IOTKIT(dev);
|
||||
|
@ -328,6 +346,22 @@ static void iotkit_realize(DeviceState *dev, Error **errp)
|
|||
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mpc),
|
||||
0));
|
||||
|
||||
/* We must OR together lines from the MPC splitters to go to the NVIC */
|
||||
object_property_set_int(OBJECT(&s->mpc_irq_orgate),
|
||||
IOTS_NUM_EXP_MPC + IOTS_NUM_MPC, "num-lines", &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
object_property_set_bool(OBJECT(&s->mpc_irq_orgate), true,
|
||||
"realized", &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
qdev_connect_gpio_out(DEVICE(&s->mpc_irq_orgate), 0,
|
||||
qdev_get_gpio_in(DEVICE(&s->armv7m), 9));
|
||||
|
||||
/* Devices behind APB PPC0:
|
||||
* 0x40000000: timer0
|
||||
* 0x40001000: timer1
|
||||
|
@ -536,6 +570,46 @@ static void iotkit_realize(DeviceState *dev, Error **errp)
|
|||
g_free(gpioname);
|
||||
}
|
||||
|
||||
/* Wire up the splitters for the MPC IRQs */
|
||||
for (i = 0; i < IOTS_NUM_EXP_MPC + IOTS_NUM_MPC; i++) {
|
||||
SplitIRQ *splitter = &s->mpc_irq_splitter[i];
|
||||
DeviceState *dev_splitter = DEVICE(splitter);
|
||||
|
||||
object_property_set_int(OBJECT(splitter), 2, "num-lines", &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
object_property_set_bool(OBJECT(splitter), true, "realized", &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (i < IOTS_NUM_EXP_MPC) {
|
||||
/* Splitter input is from GPIO input line */
|
||||
s->mpcexp_status_in[i] = qdev_get_gpio_in(dev_splitter, 0);
|
||||
qdev_connect_gpio_out(dev_splitter, 0,
|
||||
qdev_get_gpio_in_named(dev_secctl,
|
||||
"mpcexp_status", i));
|
||||
} else {
|
||||
/* Splitter input is from our own MPC */
|
||||
qdev_connect_gpio_out_named(DEVICE(&s->mpc), "irq", 0,
|
||||
qdev_get_gpio_in(dev_splitter, 0));
|
||||
qdev_connect_gpio_out(dev_splitter, 0,
|
||||
qdev_get_gpio_in_named(dev_secctl,
|
||||
"mpc_status", 0));
|
||||
}
|
||||
|
||||
qdev_connect_gpio_out(dev_splitter, 1,
|
||||
qdev_get_gpio_in(DEVICE(&s->mpc_irq_orgate), i));
|
||||
}
|
||||
/* Create GPIO inputs which will pass the line state for our
|
||||
* mpcexp_irq inputs to the correct splitter devices.
|
||||
*/
|
||||
qdev_init_gpio_in_named(dev, iotkit_mpcexp_status, "mpcexp_status",
|
||||
IOTS_NUM_EXP_MPC);
|
||||
|
||||
iotkit_forward_sec_resp_cfg(s);
|
||||
|
||||
system_clock_scale = NANOSECONDS_PER_SECOND / s->mainclk_frq;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue